stella.rmi
Class GenericMaster

java.lang.Object
  extended by util.PropertyContainer
      extended by util.PropertyResources
          extended by util.PropertyBundles
              extended by util.rmi.RmiPropertyContainer
                  extended by util.rmi.AbstractRmiListener
                      extended by stella.rmi.AbstractRmiCasterAndListener
                          extended by stella.rmi.ReceiverTorso
                              extended by stella.rmi.GenericMaster
All Implemented Interfaces:
Cloneable, Remote, EventListener, Caster, ErrorSending, ErrorCaster, Alive, ListenerControlling, RmiAcknowledgeCaster, RmiCommandListener, RmiDoneCaster, RmiErrorCaster, RmiParameterClustering, ExitCleaning, Initializable, LocalizedSupplying, PropertySupplying, ResourceSupplying, RmiCaster, RmiEventListener, RmiListener, RmiPropertyBearing, TriggerableReload, StepInitializable
Direct Known Subclasses:
AdapterMaster, AuxiliaryMaster, CalibrationMaster, GenericMaster.Standalone, SesMaster, ShelterMaster, TelescopeMaster, TestReceiver, WifsipMaster

public abstract class GenericMaster
extends ReceiverTorso
implements Alive, ListenerControlling, RmiParameterClustering, TriggerableReload

A generic parent class for device masters. Carries a parameter set and completion-times for Generic commands.


Nested Class Summary
static class GenericMaster.Standalone
          Standalone class that does not respond to commands, but provides a set of global variables and switches.
 
Nested classes/interfaces inherited from class stella.rmi.ReceiverTorso
ReceiverTorso.CommandHandler
 
Nested classes/interfaces inherited from class util.PropertyResources
PropertyResources.URLResource
 
Field Summary
private  boolean auto
          True, if we are in automatic mode.
private static long DEFABORTTIME
          The default abort time.
private static boolean DEFAUTOMATIC
          The default automatic-mode of the roof.
private static long DEFCOMMTIME
          The time to wait for the telescope to come up.
private static long DEFINITTIME
          The default init time.
private static boolean DEFNODB
          Normally, we allow db connections
private static boolean DEFOVERRULEAUTO
          Normally, commands are ignored in manual mode
private static long DEFPARKTIME
          The default park time.
private static long DEFQUITTIME
          The default quit time acknowledge.
private static long DEFREAUTO
          Per default we stay in manual until set to automatic again
private static long DEFRESETTIME
          The default reset time.
private static long DEFSHUTDOWNDELAY
          The default shutdown delay time, 5 sec.
private static long DEFSTATUSTIME
          The default status time.
static String DEFUNIQUE
          The default name of the unique name identifier string.
private static int DRIVERPRIORITY
          The priority of the driver exit.
private  Map<String,Driver> drivers
          The mapping of driver names against the drivers of the master.
private  RmiCommandCaster externcaster
          A reference to the caster, if we are in external listening mode.
private  HistorySql histsql
          The history-db reference.
static String KEY_ABORTTIME
          Time for the abort command.
static String KEY_AUTOMATIC
          A key to the start-up mode automatic/manual.
static String KEY_COMMTIME
          The time to wait for the telescope to come up.
static String KEY_COMMUNICATOR
          The properties of the a telescope caster class.
static String KEY_DRIVERS
          The properties of the drivers served by this generic master.
static String KEY_HISTORYDB
          If special history-db properties are required.
static String KEY_INITTIME
          Time for the init command.
static String KEY_NODB
          If true, no dbs are inited.
static String KEY_OBSERVEDB
          If special observe-db properties are required.
static String KEY_OVERRULEAUTO
          If true, commands are also excepted in manual mode.
static String KEY_PARKTIME
          Time for the park command.
static String KEY_PERMISSIONDB
          If special permission-db properties are required.
static String KEY_PROPOSALDB
          If special proposal-db properties are required.
static String KEY_QUITTIME
          Time for the quit command.
static String KEY_REAUTO
          If non-null, the time intervall when we go back from manual to auto.
static String KEY_RESETTIME
          Time for the reset command.
static String KEY_SET
          The properties of the parameter set served by this generic master.
static String KEY_SHUTDOWNDELAY
          The time delay from receiving quit-command until orderly shutdown.
static String KEY_STATUSTIME
          Time for the status command.
static String KEY_TARGETDB
          If special target-db properties are required.
static String KEY_TASKDB
          If special task-db properties are required.
static String KEY_UNIQUE
          The unique name identifier string for acquire and guiding.
static String KEY_USERDB
          If special user-db properties are required.
protected  Date lastabort
          Last date an abort command was received.
private  String lastdate
          For naming of acquire/guide frames.
private  ErrorEvent lasterror
          The error message generated during last command execution.
protected  Date lastinit
          Last date an init command was received.
protected  Date lastpark
          Last date an park command was received.
protected  Date lastreset
          Last date an reset command was received.
private  ObserveSql observesql
          The history-db reference.
private  boolean passive
          If passive, all commands in automatic mode are answered with complete.
private  PermissionSql permsql
          The history-db reference.
private  ProposalSql proposalsql
          The history-db reference.
private  ParameterClustering set
          The parameter cluster of the adapter.
private static int SETPRIORITY
          The priority of the set exit.
private  int targetcount
          The target acquired at this date.
private  TargetSql targetsql
          The history-db reference.
private  TaskSql tasksql
          The history-db reference.
protected  TelescopeCaster telescope
          If we have a communicator it is available after init1.
private  UserSql usersql
          The history-db reference.
 
Fields inherited from class stella.rmi.ReceiverTorso
KEY_BIND, KEY_BINDNAME, KEY_COMMANDCASTER, KEY_ERRORCOOL
 
Fields inherited from class util.rmi.AbstractRmiListener
KEY_ALIVE, KEY_EXPORTPORT, KEY_INIT, KEY_LISTENERNAME, KEY_RETRY, KEY_RETRYSLEEP
 
Fields inherited from class util.PropertyBundles
KEY_LOCALECOUNTRY, KEY_LOCALELANGUAGE, KEY_RESOURCEBUNDLES
 
Fields inherited from class util.PropertyResources
KEY_NOINITONCREATE, localurl, locate, POSTFIX_DIR, POSTFIX_EXT, POSTFIX_FILE, POSTFIX_LIST, POSTFIX_URL, urlset
 
Fields inherited from class util.PropertyContainer
KEY_LISTSEPARATOR, KEY_MAPKEYVALUECHAR, KEY_MAPSEPARATOR
 
Fields inherited from interface stella.rmi.RmiAcknowledgeCaster
NAMING_EXTENSION
 
Fields inherited from interface stella.rmi.RmiDoneCaster
NAMING_EXTENSION
 
Fields inherited from interface util.StepInitializable
KEY_INITDEPTH
 
Fields inherited from interface util.ResourceSupplying
KEY_URLRESOURCES, KEY_URLUSECONFIG, KEY_URLUSECURRENT, KEY_URLUSEHOME
 
Fields inherited from interface util.PropertySupplying
CONFIG, KEY_CLASS
 
Constructor Summary
protected GenericMaster(Map<String,String> prop)
          Constructs a new generic master and defaults done times for Generic commands.
 
Method Summary
protected  boolean abortMaster()
          Method called to abort the device.
 void addErrorListener(ErrorListener ear)
          If we register a new error listener, we check if we have current status messages.
 void addRmiErrorListener(RmiErrorListener ear)
          If we register a new rmi-error listener, we check if we have current status messages.
 boolean automatic()
          The automatic mode.
protected  boolean createCommunicator(String key)
          (Re)creates the communicator.
 void exit()
          Exits the master by first exiting the drivers, then exiting the parameter set and then commancing super.exit.
 boolean external(Remote caster)
          Enrolls or deregisters from an external caster.
protected  String formatWithGlobals(String fill, Map<String,Object> extern)
          Formatting a fits file name from a place-holder supplied.
protected  int getAcknowledgeNumber(CommandEvent cmd)
          Returns the number of acknowledge event to be sent back as a function of the command type.
 Collection<Driver> getAllDrivers()
          Returns a collection of all drivers hosted.
protected  long getCompletionTime(CommandEvent cmd, int acknr)
          Returns the completion time for the specified command.
 Driver getDriver(String drivername)
          Access to the driver of the given name.
 HistorySql getHistorySql()
          Accesor to db table.
protected  ErrorEvent getLastError()
          Returns the last error event generated during a command subroutine.
 ObserveSql getObserveSql()
          Accesor to db table.
 Parameter getParameterByKey(String key)
          Access to a parameter from its property key.
 Parameter getParameterByName(String name)
          Access to a paramter by its name.
protected  ParameterClustering getParameterCluster()
          Access to the entire parameter set for daughter classes.
 Object getParameterValueByKey(String key)
          Access to a parameter value by the parameter key.
 Object getParameterValueByName(String name)
          Access to a parameter value by the parameter name.
 PermissionSql getPermissionSql()
          Accesor to db table.
 ProposalSql getProposalSql()
          Accesor to db table.
 String getStatus()
          Diverts to the statusMaster method.
 TargetSql getTargetSql()
          Accesor to db table.
 TaskSql getTaskSql()
          Accesor to db table.
 String getUnique()
          Returns the value of the unique parameter, or, if this is not accessible a 'home-made' version of it.
 UserSql getUserSql()
          Accesor to db table.
private  void init1()
          Initialization, second step.
private  void init4()
          The delayed, i.e.
 boolean initialize()
          Calls initializeMaster() in the default implementation.
protected abstract  boolean initializeMaster()
          Method called to init the device.
 void initStep(int curstep)
          Initializes the parameter set served by the master.
 boolean isAlive()
          An implementation of the Alive interface.
protected  boolean isAuto()
          For daughters that have to check the automatic mode.
protected  boolean isManual()
          For daughters that have to check the manual mode.
protected  boolean isPassive()
          Returns the status of the passive flag.
 boolean manual()
          Disables automatic operation.
private  boolean manual(long reauto)
           
 boolean park()
          Calls parkMaster().
protected abstract  boolean parkMaster()
          Method called to park the device.
protected  boolean processCommand(CommandEvent cmd, int acknr)
          Processes the given command.
 void quit()
          Calls quitMaster().
protected  void quitMaster()
          Quits the master by deregistering it from the registry and calling shutdown() on the parent.
 double reload()
          On reload, we always issue a reload to our parameter set and our drivers, too.
private static boolean reopenDrivers(Collection<Driver> drvs)
          Restarts a list of drivers by iteration through all instances and cumulating the failure flags.
private static boolean reopenSingleDriver(Driver io)
          Restarts a single driver by re-opening it.
protected  double rescanned(String key, String old, String newval)
          Method provided for subclasses to make it public and thus become a Reloadable target.
 boolean reset()
          calls resetMaster().
protected abstract  boolean resetMaster()
          Method called to reset the device.
protected  boolean restartAllDrivers()
          Re-opens all drivers.
protected  boolean restartNamedDriver(String drivername)
          Re-opens a single named driver.
 double revert()
          We are triggerable for reload, but are we also reloadable?
 void rmiAddParameter(URL resource)
          Adds a parameter that is loadable from the given resource.
 void rmiCommand(CommandEvent cmd)
          We catch the first invocation with a new command to check if we are in a state that allows accepting of remote commands (i.e.
 Object rmiGet(String name)
          Returns the parameter's value as an object.
 Set<String> rmiGetAllParameterNames()
          Returns all names of the parameters this parameter set serves, tailored for rmi-access.
 void rmiRemoveParameter(String name)
          Removes the parameter with the given name.
 Object rmiSet(String name, Object to)
          Sets the value of the parameter of the given name to the specified value.
private  void sendMasterStatus(Object tosend)
          Checks the argument type and either wraps it into a generic Status event or, if it is already a status message, sends it as-is.
protected  void setLastError(ErrorEvent ee)
          Sets the last error event occuring.
 Object setParameterValueByKey(String key, Object newval)
          Set a parameter value with the parameter key.
 Object setParameterValueByName(String name, Object newval)
          Set a parameter value with the parameter name.
 boolean setPassive(boolean inert)
          Sets the passive flag to the desired state.
protected  void shutdown()
          Quits the currently running java VM with a System.exit call.
protected abstract  Object statusMaster()
          Method called to return the status.
protected  boolean zeroAllOmc()
          Zero-points all motor controllers.
 
Methods inherited from class stella.rmi.ReceiverTorso
addRmiAcknowledgeListener, addRmiDoneListener, bindDefault, containsRemoteProperty, deregisterAtCaster, equals, getRemoteProperties, getRemoteProperty, hashCode, notifyAcknowledgeListener, notifyDoneListener, registerAtCaster, removeRmiAcknowledgeListener, removeRmiDoneListener, sendAllPrematureDone, sendPrematureDone, setRemoteProperty, toString, unbindDefault
 
Methods inherited from class stella.rmi.AbstractRmiCasterAndListener
bindToRegistry, getBindName, isValid, notifyErrorListener, removeErrorListener, removeRmiErrorListener, sendError, sendError, sendError, sendStatus, sendStatus, sendStatus, unbindFromRegistry
 
Methods inherited from class util.rmi.AbstractRmiListener
allBound, blockBinding, blockBinding, disconnect, getIP, getListenerName, isConnected, listenerName, releaseBinding, releaseBinding, startBinding, startBinding
 
Methods inherited from class util.PropertyBundles
clone, getLocalized, getLocalized, getLocalizedString, getLocalizedString, loadResource
 
Methods inherited from class util.PropertyResources
createFrom, createFrom, createFrom, getApplet, getAsResources, getLocalClassLoader, getPropertiesToKey, getPropertiesToKey, getResource, getResourceAsStream, getResourceFromKey, getResources, init, keyCreate, keyCreate, reload, setApplet
 
Methods inherited from class util.PropertyContainer
augment, augment, augment, defaultBoolean, defaultChar, defaultDouble, defaultFloat, defaultInt, defaultLong, defaultObject, defaultObject, defaultProperties, defaultProperty, getAsBoolean, getAsChar, getAsDouble, getAsEnums, getAsFloat, getAsInt, getAsList, getAsLong, getAsMap, getAsMap, getAsObject, getAsObject, getProperties, getProperty, has, isNew, parseObject, removeProperty, setObject, setProperties, setProperty, stringProperties
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface util.rmi.RmiCaster
bindToRegistry, isValid, unbindFromRegistry
 
Methods inherited from interface stella.ErrorCaster
removeErrorListener
 
Methods inherited from interface stella.rmi.RmiCommandListener
accepts
 
Methods inherited from interface util.rmi.RmiEventListener
getListenerName
 
Methods inherited from interface util.rmi.RmiListener
disconnect, isConnected
 
Methods inherited from interface util.ResourceSupplying
getResource, getResourceAsStream, getResources
 
Methods inherited from interface util.PropertySupplying
defaultBoolean, defaultChar, defaultDouble, defaultFloat, defaultInt, defaultLong, defaultObject, defaultObject, defaultProperties, defaultProperty, getAsBoolean, getAsChar, getAsDouble, getAsFloat, getAsInt, getAsList, getAsLong, getAsMap, getAsObject, getAsObject, getProperties, getProperty, has, parseObject, removeProperty, setObject, setProperty, stringProperties
 
Methods inherited from interface util.Initializable
init
 

Field Detail

KEY_COMMUNICATOR

public static final String KEY_COMMUNICATOR
The properties of the a telescope caster class.

See Also:
Constant Field Values

KEY_COMMTIME

public static final String KEY_COMMTIME
The time to wait for the telescope to come up. Zero waits forever.

See Also:
Constant Field Values

KEY_SET

public static final String KEY_SET
The properties of the parameter set served by this generic master.

See Also:
Constant Field Values

KEY_UNIQUE

public static final String KEY_UNIQUE
The unique name identifier string for acquire and guiding.

See Also:
Constant Field Values

KEY_DRIVERS

public static final String KEY_DRIVERS
The properties of the drivers served by this generic master.

See Also:
Constant Field Values

KEY_ABORTTIME

public static final String KEY_ABORTTIME
Time for the abort command.

See Also:
Constant Field Values

KEY_INITTIME

public static final String KEY_INITTIME
Time for the init command.

See Also:
Constant Field Values

KEY_RESETTIME

public static final String KEY_RESETTIME
Time for the reset command.

See Also:
Constant Field Values

KEY_PARKTIME

public static final String KEY_PARKTIME
Time for the park command.

See Also:
Constant Field Values

KEY_QUITTIME

public static final String KEY_QUITTIME
Time for the quit command.

See Also:
Constant Field Values

KEY_STATUSTIME

public static final String KEY_STATUSTIME
Time for the status command.

See Also:
Constant Field Values

KEY_AUTOMATIC

public static final String KEY_AUTOMATIC
A key to the start-up mode automatic/manual.

See Also:
Constant Field Values

KEY_REAUTO

public static final String KEY_REAUTO
If non-null, the time intervall when we go back from manual to auto.

See Also:
Constant Field Values

KEY_OVERRULEAUTO

public static final String KEY_OVERRULEAUTO
If true, commands are also excepted in manual mode. Use with care.

See Also:
Constant Field Values

KEY_SHUTDOWNDELAY

public static final String KEY_SHUTDOWNDELAY
The time delay from receiving quit-command until orderly shutdown.

See Also:
Constant Field Values

KEY_NODB

public static final String KEY_NODB
If true, no dbs are inited.

See Also:
Constant Field Values

KEY_HISTORYDB

public static final String KEY_HISTORYDB
If special history-db properties are required.

See Also:
Constant Field Values

KEY_TASKDB

public static final String KEY_TASKDB
If special task-db properties are required.

See Also:
Constant Field Values

KEY_TARGETDB

public static final String KEY_TARGETDB
If special target-db properties are required.

See Also:
Constant Field Values

KEY_PROPOSALDB

public static final String KEY_PROPOSALDB
If special proposal-db properties are required.

See Also:
Constant Field Values

KEY_USERDB

public static final String KEY_USERDB
If special user-db properties are required.

See Also:
Constant Field Values

KEY_PERMISSIONDB

public static final String KEY_PERMISSIONDB
If special permission-db properties are required.

See Also:
Constant Field Values

KEY_OBSERVEDB

public static final String KEY_OBSERVEDB
If special observe-db properties are required.

See Also:
Constant Field Values

DEFCOMMTIME

private static final long DEFCOMMTIME
The time to wait for the telescope to come up. Zero waits forever.

See Also:
Constant Field Values

DEFUNIQUE

public static final String DEFUNIQUE
The default name of the unique name identifier string.

See Also:
Constant Field Values

DEFABORTTIME

private static final long DEFABORTTIME
The default abort time.

See Also:
Constant Field Values

DEFINITTIME

private static final long DEFINITTIME
The default init time.

See Also:
Constant Field Values

DEFRESETTIME

private static final long DEFRESETTIME
The default reset time.

See Also:
Constant Field Values

DEFPARKTIME

private static final long DEFPARKTIME
The default park time.

See Also:
Constant Field Values

DEFSTATUSTIME

private static final long DEFSTATUSTIME
The default status time.

See Also:
Constant Field Values

DEFQUITTIME

private static final long DEFQUITTIME
The default quit time acknowledge.

See Also:
Constant Field Values

DEFREAUTO

private static final long DEFREAUTO
Per default we stay in manual until set to automatic again

See Also:
Constant Field Values

DEFAUTOMATIC

private static final boolean DEFAUTOMATIC
The default automatic-mode of the roof.

See Also:
Constant Field Values

DEFOVERRULEAUTO

private static final boolean DEFOVERRULEAUTO
Normally, commands are ignored in manual mode

See Also:
Constant Field Values

DEFSHUTDOWNDELAY

private static final long DEFSHUTDOWNDELAY
The default shutdown delay time, 5 sec.

See Also:
Constant Field Values

DEFNODB

private static final boolean DEFNODB
Normally, we allow db connections

See Also:
Constant Field Values

DRIVERPRIORITY

private static final int DRIVERPRIORITY
The priority of the driver exit.

See Also:
Constant Field Values

SETPRIORITY

private static final int SETPRIORITY
The priority of the set exit.

See Also:
Constant Field Values

telescope

protected TelescopeCaster telescope
If we have a communicator it is available after init1.


drivers

private Map<String,Driver> drivers
The mapping of driver names against the drivers of the master.


set

private ParameterClustering set
The parameter cluster of the adapter.


lasterror

private ErrorEvent lasterror
The error message generated during last command execution.


auto

private boolean auto
True, if we are in automatic mode.


externcaster

private RmiCommandCaster externcaster
A reference to the caster, if we are in external listening mode.


passive

private boolean passive
If passive, all commands in automatic mode are answered with complete.


lastinit

protected Date lastinit
Last date an init command was received.


lastpark

protected Date lastpark
Last date an park command was received.


lastreset

protected Date lastreset
Last date an reset command was received.


lastabort

protected Date lastabort
Last date an abort command was received.


histsql

private HistorySql histsql
The history-db reference.


tasksql

private TaskSql tasksql
The history-db reference.


targetsql

private TargetSql targetsql
The history-db reference.


proposalsql

private ProposalSql proposalsql
The history-db reference.


usersql

private UserSql usersql
The history-db reference.


permsql

private PermissionSql permsql
The history-db reference.


observesql

private ObserveSql observesql
The history-db reference.


lastdate

private String lastdate
For naming of acquire/guide frames.


targetcount

private int targetcount
The target acquired at this date.

Constructor Detail

GenericMaster

protected GenericMaster(Map<String,String> prop)
Constructs a new generic master and defaults done times for Generic commands. The parameter set is constructed in the PropertyResources.init() section.

Method Detail

initStep

public void initStep(int curstep)
Initializes the parameter set served by the master.

Specified by:
initStep in interface StepInitializable
Overrides:
initStep in class ReceiverTorso
Parameters:
curstep - The current initialization depth.

init1

private void init1()
Initialization, second step.


createCommunicator

protected boolean createCommunicator(String key)
(Re)creates the communicator.


init4

private void init4()
The delayed, i.e. the very last init procedure. We first bind to the registry, if desired by a call to the parental method. Then, we check the auto/manual mode and enable either auto or manual mode.


formatWithGlobals

protected String formatWithGlobals(String fill,
                                   Map<String,Object> extern)
Formatting a fits file name from a place-holder supplied. The following rules apply: Example: science{Unique} returns the classic entry, as if no name would be given.

If unmatched parenthesis are encountered, the input string is returned.


getUnique

public String getUnique()
Returns the value of the unique parameter, or, if this is not accessible a 'home-made' version of it.


revert

public double revert()
              throws RemoteException
We are triggerable for reload, but are we also reloadable?

Specified by:
revert in interface TriggerableReload
Returns:
Zero if reload failed, one if reload was totally successful.
Throws:
RemoteException
See Also:
Reloadable

getObserveSql

public ObserveSql getObserveSql()
Accesor to db table.


getPermissionSql

public PermissionSql getPermissionSql()
Accesor to db table.


getUserSql

public UserSql getUserSql()
Accesor to db table.


getProposalSql

public ProposalSql getProposalSql()
Accesor to db table.


getTargetSql

public TargetSql getTargetSql()
Accesor to db table.


getTaskSql

public TaskSql getTaskSql()
Accesor to db table.


getHistorySql

public HistorySql getHistorySql()
Accesor to db table.


rescanned

protected double rescanned(String key,
                           String old,
                           String newval)
Method provided for subclasses to make it public and thus become a Reloadable target. Special treatment if the automatic flag changed, no success if the driver list or set changed, but see reload() for set-related changes.

Overrides:
rescanned in class ReceiverTorso

reload

public double reload()
On reload, we always issue a reload to our parameter set and our drivers, too.

Overrides:
reload in class PropertyContainer

getDriver

public Driver getDriver(String drivername)
Access to the driver of the given name.


getAllDrivers

public Collection<Driver> getAllDrivers()
Returns a collection of all drivers hosted.


zeroAllOmc

protected boolean zeroAllOmc()
Zero-points all motor controllers.


restartAllDrivers

protected boolean restartAllDrivers()
Re-opens all drivers. We pass all known drivers to the driver-restart method #restartDriver.


restartNamedDriver

protected boolean restartNamedDriver(String drivername)
Re-opens a single named driver.


reopenDrivers

private static boolean reopenDrivers(Collection<Driver> drvs)
Restarts a list of drivers by iteration through all instances and cumulating the failure flags. This method always tries to restart all drivers; it does not stop on first failure.


reopenSingleDriver

private static boolean reopenSingleDriver(Driver io)
Restarts a single driver by re-opening it. If the driver implements the Cooldown interface, we wait the cool-down time returned by Cooldown#getRestartCooldown before restarting it, otherwise we proceed immediately. On resart, we synchronize on each driver instance.


getParameterByName

public Parameter getParameterByName(String name)
Access to a paramter by its name.


getParameterByKey

public Parameter getParameterByKey(String key)
Access to a parameter from its property key.


getParameterValueByName

public Object getParameterValueByName(String name)
Access to a parameter value by the parameter name. Returns null if either the master has no set or the set does not know the parameter. Might still return null, if the queried value returns null.


getParameterValueByKey

public Object getParameterValueByKey(String key)
Access to a parameter value by the parameter key. Returns null if either the master has no set or the set does not know the parameter. Might still return null, if the queried value returns null.


setParameterValueByName

public Object setParameterValueByName(String name,
                                      Object newval)
Set a parameter value with the parameter name.


setParameterValueByKey

public Object setParameterValueByKey(String key,
                                     Object newval)
Set a parameter value with the parameter key.


getParameterCluster

protected ParameterClustering getParameterCluster()
Access to the entire parameter set for daughter classes.


setPassive

public boolean setPassive(boolean inert)
                   throws RemoteException
Sets the passive flag to the desired state. A master that is passive responds to any incoming command with an immediate done message. This behaviour is intended as a workaround for failed devices.

Specified by:
setPassive in interface ListenerControlling
Throws:
RemoteException

automatic

public boolean automatic()
                  throws RemoteException
The automatic mode. In automatic mode, the master registers to its default listener, if specified, and blocks input from RMI-enabled direct access methods, like RoofControlling#open.

Specified by:
automatic in interface ListenerControlling
Returns:
True if automatic mode was attained.
Throws:
RemoteException

manual

public boolean manual()
               throws RemoteException
Disables automatic operation. This method calls the ReceiverTorso.unbindDefault() method and sets the automatic flag to false.

Specified by:
manual in interface ListenerControlling
Returns:
True if manual mode was attained.
Throws:
RemoteException

manual

private boolean manual(long reauto)
                throws RemoteException
Throws:
RemoteException

external

public boolean external(Remote caster)
                 throws RemoteException
Enrolls or deregisters from an external caster.

Specified by:
external in interface ListenerControlling
Returns:
True if everything went o.k.
Throws:
RemoteException

getStatus

public String getStatus()
                 throws RemoteException
Diverts to the statusMaster method.

Specified by:
getStatus in interface ListenerControlling
Throws:
RemoteException

initialize

public boolean initialize()
                   throws RemoteException
Calls initializeMaster() in the default implementation.

Specified by:
initialize in interface ListenerControlling
Throws:
RemoteException

reset

public boolean reset()
              throws RemoteException
calls resetMaster().

Specified by:
reset in interface ListenerControlling
Throws:
RemoteException

park

public boolean park()
             throws RemoteException
Calls parkMaster().

Specified by:
park in interface ListenerControlling
Throws:
RemoteException

quit

public void quit()
          throws RemoteException
Calls quitMaster().

Specified by:
quit in interface ListenerControlling
Throws:
RemoteException

isAuto

protected boolean isAuto()
For daughters that have to check the automatic mode. This method returns true if the auto flag is true and no external caster is registered.


isManual

protected boolean isManual()
For daughters that have to check the manual mode. This method returns true if the auto flag is false and no external caster is registered.


rmiCommand

public void rmiCommand(CommandEvent cmd)
                throws RemoteException
We catch the first invocation with a new command to check if we are in a state that allows accepting of remote commands (i.e. we are in automatic mode or we have an external caster reference). If we are allowed to conduct this command, we call the superclass method, which will then query the acknowledge number and execute the command with {link #processCommand}. If our state does not allow acceptance from remote casters (i.e. we are purely manual) the super method is not invoked and we exit with an error message here.

Specified by:
rmiCommand in interface RmiCommandListener
Overrides:
rmiCommand in class ReceiverTorso
Parameters:
cmd - The command to process.
Throws:
RemoteException

addRmiErrorListener

public void addRmiErrorListener(RmiErrorListener ear)
                         throws RemoteException
If we register a new rmi-error listener, we check if we have current status messages. If so, we send them to the new listeners.

Specified by:
addRmiErrorListener in interface RmiErrorCaster
Overrides:
addRmiErrorListener in class AbstractRmiCasterAndListener
Throws:
RemoteException

addErrorListener

public void addErrorListener(ErrorListener ear)
If we register a new error listener, we check if we have current status messages. If so, we send them to the new listeners.

Specified by:
addErrorListener in interface ErrorCaster
Overrides:
addErrorListener in class AbstractRmiCasterAndListener

isAlive

public boolean isAlive()
                throws RemoteException
An implementation of the Alive interface. Watchdogs call this method using rmi. If the method does not return true, either by returning false or by throwing an exception, a reboot will occur.

In the actual version, this method immediately returns true without checking the status of the camera.

Specified by:
isAlive in interface Alive
Returns:
True
Throws:
RemoteException

rmiGetAllParameterNames

public Set<String> rmiGetAllParameterNames()
                                    throws RemoteException
Returns all names of the parameters this parameter set serves, tailored for rmi-access. Calls #getAllParameterNames and pipes the result into a hash-set, which is guaranteed to be serializable.

Specified by:
rmiGetAllParameterNames in interface RmiParameterClustering
Throws:
RemoteException

rmiGet

public Object rmiGet(String name)
              throws RemoteException
Returns the parameter's value as an object. This method is tailored for rmi-access. Calls #get.

Specified by:
rmiGet in interface RmiParameterClustering
Throws:
RemoteException

rmiSet

public Object rmiSet(String name,
                     Object to)
              throws RemoteException
Sets the value of the parameter of the given name to the specified value.

Specified by:
rmiSet in interface RmiParameterClustering
Returns:
The old parameter value.
Throws:
RemoteException

rmiAddParameter

public void rmiAddParameter(URL resource)
                     throws RemoteException
Adds a parameter that is loadable from the given resource.

Specified by:
rmiAddParameter in interface RmiParameterClustering
Throws:
RemoteException

rmiRemoveParameter

public void rmiRemoveParameter(String name)
                        throws RemoteException
Removes the parameter with the given name.

Specified by:
rmiRemoveParameter in interface RmiParameterClustering
Throws:
RemoteException

isPassive

protected boolean isPassive()
Returns the status of the passive flag.


getAcknowledgeNumber

protected int getAcknowledgeNumber(CommandEvent cmd)
Returns the number of acknowledge event to be sent back as a function of the command type. Subclasses should interfere here to reflect the correct behaviour. In the default implementation, this method returns 1.

Specified by:
getAcknowledgeNumber in class ReceiverTorso

getCompletionTime

protected long getCompletionTime(CommandEvent cmd,
                                 int acknr)
Returns the completion time for the specified command. If the command triggers multiple acknowledge events this method returns the completion time for the current subtask. The subtask can be derived from the acknowledge type handed over with the command. The type of the acknowledge is the one the completion time is requested for.

Specified by:
getCompletionTime in class ReceiverTorso
Parameters:
cmd - The command to process.
acknr - The number of the acknowledge that will be sent back.

processCommand

protected boolean processCommand(CommandEvent cmd,
                                 int acknr)
Processes the given command. If the command consists of multiple subtasks this method processes only the current subtask. The subtask can be derived from the acknowledge type handed over with the command. The type of the acknowledge is the type of the acknowledge that has been sent immediately before this method was called.

The method returns true if the (sub)task was executed without an error. If it returns false the appropriate error event must be ready for retrival using the getLastError() method.

Specified by:
processCommand in class ReceiverTorso

getLastError

protected ErrorEvent getLastError()
Returns the last error event generated during a command subroutine. This method is called, if the processCommand(stella.CommandEvent, int) method returns false.

Specified by:
getLastError in class ReceiverTorso

setLastError

protected void setLastError(ErrorEvent ee)
Sets the last error event occuring. Daughter access only. Additionally passes the error to the parameter cluster to adjust its error-depending parameters.


abortMaster

protected boolean abortMaster()
Method called to abort the device. Empty implementation.


resetMaster

protected abstract boolean resetMaster()
Method called to reset the device.


initializeMaster

protected abstract boolean initializeMaster()
Method called to init the device.


parkMaster

protected abstract boolean parkMaster()
Method called to park the device.


statusMaster

protected abstract Object statusMaster()
Method called to return the status. This may be a simple string which is then wrapped into a generic status message or a specific error event which is sent as-is.

Returns:
A string or an ErrorEvent.

quitMaster

protected void quitMaster()
Quits the master by deregistering it from the registry and calling shutdown() on the parent. If any exit-cleaning tasks have to be performed, this method should be overriden.


shutdown

protected void shutdown()
Quits the currently running java VM with a System.exit call. Therefore, this method should only be invoked if no other master classes are executed in the same VM. It may nevertheless be called savely, if other classes execute on the same host (computer), but in different VMs.


exit

public void exit()
Exits the master by first exiting the drivers, then exiting the parameter set and then commancing super.exit.

Specified by:
exit in interface ExitCleaning
Overrides:
exit in class ReceiverTorso

sendMasterStatus

private void sendMasterStatus(Object tosend)
Checks the argument type and either wraps it into a generic Status event or, if it is already a status message, sends it as-is. Lists are also accepted.