stella.adapter
Class AdapterTelescopeCaster

java.lang.Object
  extended by util.PropertyContainer
      extended by util.rmi.RmiPropertyContainer
          extended by util.rmi.AbstractRmiCaster
              extended by stella.CastingContainer
                  extended by stella.AbstractCommandLauncher
                      extended by stella.net.CasterClient
                          extended by stella.adapter.AdapterTelescopeCaster
All Implemented Interfaces:
Cloneable, Remote, OffsetCaster, Caster, CommandLaunching, ErrorCaster, ReplyDeliverer, RmiAcknowledgeCaster, RmiCommandCaster, RmiDoneCaster, RmiErrorCaster, ExitCleaning, Initializable, PropertyBearing, RmiCaster, RmiPropertyBearing

public class AdapterTelescopeCaster
extends CasterClient
implements OffsetCaster

A simple class that allows sending of offset-commands from the adapter to the telescope. The main extension to the CasterClient is the ability to send a single command and wait until the final done is received or a KEY_MINTIMEOUT, KEY_DEGREETIMEOUT is surpassed. This is done by invoking castOffsetAndWait


Nested Class Summary
 
Nested classes/interfaces inherited from class stella.net.CasterClient
CasterClient.CommandSender
 
Nested classes/interfaces inherited from class util.PropertyContainer
PropertyContainer.URLResource
 
Field Summary
private static long DEFDEGREETIMEOUT
          The default time-out for the OffsetTelescope command.
private static long DEFMINTIMEOUT
          The default time-out for the OffsetTelescope command.
private  List guideoffsets
          A list of offset commands sent during guiding where we don't wait.
static String KEY_DEGREETIMEOUT
          The time-out added per degree shift.
static String KEY_MINTIMEOUT
          The minimum time-out for non-successful command submission.
private  ReplySubscriber reply
          The reply subscriber used for blocking command-sends.
private  Object wait
          A locking object.
 
Fields inherited from class stella.net.CasterClient
KEY_ACKNOWLEDGETIMEOUT, KEY_ALARMGROUP, KEY_BIND, KEY_BUFFERSIZE, KEY_CASTERNAME, KEY_MAXWAITONCLOSE, KEY_PORT, KEY_RECEIVER, KEY_RETRYCOUNT, KEY_RETRYSLEEP
 
Fields inherited from class util.rmi.AbstractRmiCaster
ALTERNATEHOST, ALTERNATEPORT, KEY_BINDNAME, KEY_EXPORTPORT, KEY_REGISTRYHOST, KEY_REGISTRYPORT
 
Fields inherited from class util.PropertyContainer
KEY_LISTSEPARATOR, KEY_LOCALECOUNTRY, KEY_LOCALELANGUAGE, KEY_MAPKEYVALUECHAR, KEY_MAPSEPARATOR, KEY_NOINITONCREATE, KEY_RESOURCEBUNDLES
 
Fields inherited from interface util.PropertyBearing
CONFIG, KEY_CLASS, KEY_URLRESOURCES, KEY_URLUSECONFIG, KEY_URLUSECURRENT, KEY_URLUSEHOME
 
Fields inherited from interface stella.rmi.RmiCommandCaster
NAMING_EXTENSION
 
Fields inherited from interface stella.rmi.RmiAcknowledgeCaster
NAMING_EXTENSION
 
Fields inherited from interface stella.rmi.RmiDoneCaster
NAMING_EXTENSION
 
Constructor Summary
AdapterTelescopeCaster(Map prop)
          Constructs a new adapter-to-telescope caster.
 
Method Summary
 boolean castCommandAndWait(TelescopeCommand tc, long timeout)
          Only used for manual acquire.
 boolean castOffsetAndWait(OffsetTelescope offset)
          Casts the offset command to the telescope and waits for notification on the appropriate done event.
 void castOffsetAtGuide(OffsetTelescope offset)
          Casts the offset command to the telescope during guiding phase.
 int getActiveOffsets()
          At guide, the guider task may want to know how many offsets are currently active to avoid overloading the telescope.
 CommandEvent getShutdownCommand()
          Needed to be non-abstract.
 boolean handles(CommandEvent ce)
          This caster handles only OffsetTelescope commands.
 void init()
          Registers a new reply subscriber to this command sender.
 
Methods inherited from class stella.net.CasterClient
addRmiAcknowledgeListener, addRmiCommandListener, addRmiDoneListener, announceInterest, castCommand, checkForward, close, exit, getAcknowledgeTimeOut, getAlarmGroup, getBufferSize, getClientName, getExitCommand, getPort, getReceiver, isReady, notifyAcknowledgeListener, notifyCommandListener, notifyDoneListener, recastCommand, registerReplySubscriber, removeRmiAcknowledgeListener, removeRmiCommandListener, removeRmiDoneListener
 
Methods inherited from class stella.AbstractCommandLauncher
createCommandLauncher
 
Methods inherited from class stella.CastingContainer
addErrorListener, addRmiErrorListener, isValid, notifyErrorListener, removeErrorListener, removeRmiErrorListener, sendError, sendError, sendError, sendStatus, sendStatus, sendStatus
 
Methods inherited from class util.rmi.AbstractRmiCaster
bindAlternate, bindToRegistry, bindToRegistry, bindToRegistry, casterExit, casterExit, getBindName, getBindName, unbindFromRegistry, unbindFromRegistry
 
Methods inherited from class util.rmi.RmiPropertyContainer
containsRemoteProperty, getRemoteProperties, getRemoteProperty, setRemoteProperty
 
Methods inherited from class util.PropertyContainer
augment, augment, augment, clone, createFrom, createFrom, createFrom, defaultBoolean, defaultChar, defaultDouble, defaultFloat, defaultInt, defaultLong, defaultObject, defaultObject, defaultProperties, defaultProperty, getAsBoolean, getAsChar, getAsDouble, getAsEnums, getAsFloat, getAsInt, getAsList, getAsLong, getAsMap, getAsMap, getAsObject, getAsObject, getLocalClassLoader, getLocalized, getLocalized, getLocalizedString, getLocalizedString, getProperties, getPropertiesToKey, getPropertiesToKey, getProperty, getResource, getResourceAsStream, getResourceFromKey, getResources, has, isNew, keyCreate, keyCreate, parseObject, reload, reload, removeProperty, rescanned, setObject, setProperties, setProperty, stringProperties, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface stella.CommandLaunching
castCommand, getClientName, getExitCommand, isReady, recastCommand
 
Methods inherited from interface stella.ReplyDeliverer
announceInterest, registerReplySubscriber
 
Methods inherited from interface util.PropertyBearing
defaultBoolean, defaultChar, defaultDouble, defaultFloat, defaultInt, defaultLong, defaultObject, defaultObject, defaultProperties, defaultProperty, getAsBoolean, getAsChar, getAsDouble, getAsFloat, getAsInt, getAsList, getAsLong, getAsMap, getAsObject, getAsObject, getLocalized, getProperties, getProperty, getResource, getResourceAsStream, getResources, has, parseObject, removeProperty, setObject, setProperty, stringProperties
 
Methods inherited from interface stella.rmi.RmiErrorCaster
addRmiErrorListener, removeRmiErrorListener
 
Methods inherited from interface util.rmi.RmiCaster
bindToRegistry, isValid, unbindFromRegistry
 
Methods inherited from interface stella.ErrorCaster
addErrorListener, removeErrorListener
 

Field Detail

KEY_MINTIMEOUT

public static final String KEY_MINTIMEOUT
The minimum time-out for non-successful command submission.

See Also:
Constant Field Values

KEY_DEGREETIMEOUT

public static final String KEY_DEGREETIMEOUT
The time-out added per degree shift.

See Also:
Constant Field Values

DEFMINTIMEOUT

private static final long DEFMINTIMEOUT
The default time-out for the OffsetTelescope command.

See Also:
Constant Field Values

DEFDEGREETIMEOUT

private static final long DEFDEGREETIMEOUT
The default time-out for the OffsetTelescope command.

See Also:
Constant Field Values

reply

private ReplySubscriber reply
The reply subscriber used for blocking command-sends.


wait

private Object wait
A locking object.


guideoffsets

private List guideoffsets
A list of offset commands sent during guiding where we don't wait.

Constructor Detail

AdapterTelescopeCaster

public AdapterTelescopeCaster(Map prop)
                       throws RemoteException
Constructs a new adapter-to-telescope caster. A reply-subscriber that is used for blocking command transfer is registered to the caster client in the init() method.

Throws:
RemoteException
Method Detail

init

public void init()
Registers a new reply subscriber to this command sender. This reply subscriber is used to block the in the #sendBlocking method.

Specified by:
init in interface Initializable
Overrides:
init in class CasterClient
See Also:
CasterClient.KEY_RETRYCOUNT, CasterClient.KEY_RETRYSLEEP

castOffsetAtGuide

public void castOffsetAtGuide(OffsetTelescope offset)
Casts the offset command to the telescope during guiding phase. We immedeately return to the guiding loop.

Specified by:
castOffsetAtGuide in interface OffsetCaster
Parameters:
offset - A OffsetTelescope command

getActiveOffsets

public int getActiveOffsets()
At guide, the guider task may want to know how many offsets are currently active to avoid overloading the telescope.

Specified by:
getActiveOffsets in interface OffsetCaster

castOffsetAndWait

public boolean castOffsetAndWait(OffsetTelescope offset)
Casts the offset command to the telescope and waits for notification on the appropriate done event. This method only returns if the final done event to this OffsetTelescope command was received or a time-out has occured. The time-out depends on the offset: to the minimal time-out KEY_MINTIMEOUT an offset-depending KEY_DEGREETIMEOUT is added by multiplying the second number with the desired offset in degrees. Note that we have access to the telescope altitude via the enclosing class.
The method returns true, if the done-event was received on time.

Specified by:
castOffsetAndWait in interface OffsetCaster
Parameters:
offset - A OffsetTelescope command
Returns:
True, if command was sent successful and done was received.

castCommandAndWait

public boolean castCommandAndWait(TelescopeCommand tc,
                                  long timeout)
Only used for manual acquire.

Specified by:
castCommandAndWait in interface OffsetCaster

getShutdownCommand

public CommandEvent getShutdownCommand()
Needed to be non-abstract. Returns null, never needed.

Specified by:
getShutdownCommand in interface CommandLaunching

handles

public boolean handles(CommandEvent ce)
This caster handles only OffsetTelescope commands.

Specified by:
handles in interface CommandLaunching
Overrides:
handles in class CasterClient