stella.roof
Class DomeReceiver.Slew

java.lang.Object
  extended by java.lang.Thread
      extended by stella.roof.DomeReceiver.Slew
All Implemented Interfaces:
Runnable
Enclosing class:
DomeReceiver

private class DomeReceiver.Slew
extends Thread

This thread never switches motors on or off! This class acts as a thread to slew to a desired position. It returns if this position is reached within the provided offset, or if canceled or the motor is stopped. Successful execution return true on a call to isAt(), successful meaning that the desired position was reached. The anticipated use of this class is to construct it supplying the desired position and the allowed offset, then starting it and joining on it for a certain timeout. If the thread did not finish successfully, it should be canceled. Remember: This thread never switches motors on or off!


Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
private  boolean cancel
          Signals a cancel issued from the outside.
private  double nominal
          The requested nominal position in degrees.
private  double offset
          The allowed offset.
private  boolean success
          If the position is reached, this boolean get true and we die.
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
protected DomeReceiver.Slew(double to, double off)
          Constructs a new slewing thread to watch the movement of the dome to the desired position, required accuracy given.
 
Method Summary
protected  void cancel()
          Cancels this thread.
 boolean isAt()
          Returns true, if the desired position is reached.
 void run()
          We constantly query the current position of the dome at a cycle of DomeReceiver.KEY_SLEWSLEEP until the required position is reached within the required offset.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

nominal

private double nominal
The requested nominal position in degrees.


offset

private double offset
The allowed offset.


cancel

private boolean cancel
Signals a cancel issued from the outside.


success

private boolean success
If the position is reached, this boolean get true and we die.

Constructor Detail

DomeReceiver.Slew

protected DomeReceiver.Slew(double to,
                            double off)
Constructs a new slewing thread to watch the movement of the dome to the desired position, required accuracy given. Note that This thread never switches motors on or off!

Method Detail

run

public void run()
We constantly query the current position of the dome at a cycle of DomeReceiver.KEY_SLEWSLEEP until the required position is reached within the required offset. If the motors are off, i.e. the dome is not moving, or if we are canceled from the outside, the success flag is set to false and we return. Otherwise we return when the position is reached. Remember: This thread never switches motors on or off!

Specified by:
run in interface Runnable
Overrides:
run in class Thread

isAt

public boolean isAt()
Returns true, if the desired position is reached.


cancel

protected void cancel()
Cancels this thread.