public abstract class GenericMaster extends ReceiverTorso implements Alive, ListenerControlling, RmiParameterClustering, TriggerableReload, AlarmHandler
Generic commands.| Modifier and Type | Class and Description |
|---|---|
static class |
GenericMaster.Standalone
Standalone class that does not respond to commands, but provides a set of
global variables and switches.
|
ReceiverTorso.CommandHandlerPropertyResources.Load, PropertyResources.URLResource| Modifier and Type | Field and Description |
|---|---|
private Alarm |
alarm
handles the switchback, if the back-to-automatic property is set.
|
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 TelescopeSubsidiaryCaster |
telescope
If we have a communicator it is available after init1.
|
private UserSql |
usersql
The history-db reference.
|
KEY_BIND, KEY_BINDNAME, KEY_COMMANDCASTER, KEY_ERRORCOOLKEY_ALIVE, KEY_EXPORTPORT, KEY_INIT, KEY_LISTENERNAME, KEY_RETRY, KEY_RETRYSLEEPKEY_NOINITONCREATE, POSTFIX_ALPHABET, POSTFIX_BYTES, POSTFIX_DIR, POSTFIX_EXT, POSTFIX_FILE, POSTFIX_LIST, POSTFIX_MODTIME, POSTFIX_URLKEY_LISTSEPARATOR, KEY_MAPKEYVALUECHAR, KEY_MAPSEPARATORNAMING_EXTENSIONNAMING_EXTENSIONKEY_INITDEPTHKEY_URLRESOURCES, KEY_URLUSECONFIG, KEY_URLUSECURRENT, KEY_URLUSEHOMECONFIG, KEY_CLASS| Modifier | Constructor and Description |
|---|---|
protected |
GenericMaster(Map<String,String> prop)
Constructs a new generic master and defaults done times for
Generic commands. |
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
abortMaster(CommandEvent cmd)
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() |
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.
|
ObserveSql |
getObserveSql()
Accesor to db table.
|
OffsetCaster |
getOffsetCaster() |
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.
|
Object |
getUnique() |
String |
getUniqueId()
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(stella.CommandEvent) in the default implementation. |
protected abstract boolean |
initializeMaster(CommandEvent cmd)
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. |
boolean |
isAuto()
For daughters that have to check the automatic mode.
|
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)
Disables automatic operation.
|
boolean |
park()
|
protected abstract boolean |
parkMaster(CommandEvent cmd)
Method called to park the device.
|
protected boolean |
processCommand(CommandEvent cmd,
int acknr)
Processes the given command.
|
void |
quit()
|
protected void |
quitMaster(CommandEvent cmd)
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()
|
protected void |
resetAlarm()
Restarts the back-to-auto alarm.
|
protected boolean |
resetAllDrivers()
Resets all drivers.
|
private static boolean |
resetDrivers(Collection<Driver> drvs)
Restarts a list of drivers by iteration through all instances and
cumulating the failure flags.
|
protected abstract boolean |
resetMaster(CommandEvent cmd)
Method called to reset the device.
|
protected boolean |
restartAllDrivers()
Re-opens all drivers.
|
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(CommandEvent cmd,
ErrorEvent ee)
Sets the last error event occuring.
|
void |
setOff(String manual)
Entry point if an alarm was set off that brings the master back to
automatic mode.
|
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(CommandEvent cmd)
Method called to return the status.
|
protected boolean |
zeroAllOmc()
Zero-points all motor controllers.
|
addRmiAcknowledgeListener, addRmiDoneListener, bindDefault, containsRemoteProperty, deregisterAtCaster, equals, getLastError, getRemoteProperties, getRemoteProperty, hashCode, notifyAcknowledgeListener, notifyDoneListener, registerAtCaster, removeRmiAcknowledgeListener, removeRmiDoneListener, sendAllPrematureDone, sendPrematureDone, setRemoteProperty, toString, unbindDefaultbindToRegistry, getBindName, isValid, notifyErrorListener, removeErrorListener, removeRmiErrorListener, sendError, sendError, sendError, sendStatus, sendStatus, sendStatus, unbindFromRegistryallBound, blockBinding, blockBinding, disconnect, getIP, getListenerName, isConnected, listenerName, releaseBinding, releaseBinding, startBinding, startBindingclone, createFrom, createFrom, createFrom, createInstance, getApplet, getAsResources, getLocate, getPropertiesToKey, getPropertiesToKey, getResource, getResourceAsStream, getResourceFromKey, getResources, hasLocalURLs, initProperties, keyCreate, keyCreate, reload, setAppletaugment, augment, 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, parseObject, removeProperty, requires, setObject, setProperties, setProperty, stringPropertiesfinalize, getClass, notify, notifyAll, wait, wait, waitbindToRegistry, isValid, unbindFromRegistryremoveErrorListeneracceptsgetListenerNamedisconnect, isConnecteddefaultBoolean, 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, stringPropertiespublic static final String KEY_COMMUNICATOR
public static final String KEY_COMMTIME
public static final String KEY_SET
public static final String KEY_UNIQUE
public static final String KEY_DRIVERS
public static final String KEY_ABORTTIME
public static final String KEY_INITTIME
public static final String KEY_RESETTIME
public static final String KEY_PARKTIME
public static final String KEY_QUITTIME
public static final String KEY_STATUSTIME
public static final String KEY_AUTOMATIC
public static final String KEY_REAUTO
public static final String KEY_OVERRULEAUTO
public static final String KEY_SHUTDOWNDELAY
public static final String KEY_NODB
public static final String KEY_HISTORYDB
public static final String KEY_TASKDB
public static final String KEY_TARGETDB
public static final String KEY_PROPOSALDB
public static final String KEY_USERDB
public static final String KEY_PERMISSIONDB
public static final String KEY_OBSERVEDB
private static final long DEFCOMMTIME
public static final String DEFUNIQUE
private static final long DEFABORTTIME
private static final long DEFINITTIME
private static final long DEFRESETTIME
private static final long DEFPARKTIME
private static final long DEFSTATUSTIME
private static final long DEFQUITTIME
private static final long DEFREAUTO
private static final boolean DEFAUTOMATIC
private static final boolean DEFOVERRULEAUTO
private static final long DEFSHUTDOWNDELAY
private static final boolean DEFNODB
private static final int DRIVERPRIORITY
private static final int SETPRIORITY
protected TelescopeSubsidiaryCaster telescope
private Map<String,Driver> drivers
private ParameterClustering set
private ErrorEvent lasterror
private boolean auto
private RmiCommandCaster externcaster
private boolean passive
protected Date lastinit
protected Date lastpark
protected Date lastreset
protected Date lastabort
private HistorySql histsql
private TaskSql tasksql
private TargetSql targetsql
private ProposalSql proposalsql
private UserSql usersql
private PermissionSql permsql
private ObserveSql observesql
private String lastdate
private int targetcount
private Alarm alarm
public void initStep(int curstep)
throws InitException
initStep in interface StepInitializableinitStep in class ReceiverTorsoInitExceptionprivate void init1()
public OffsetCaster getOffsetCaster()
protected boolean createCommunicator()
public boolean createCommunicator(String key)
private void init4()
throws InitException
InitExceptionprotected String formatWithGlobals(String fill, Map<String,Object> extern)
If unmatched parenthesis are encountered, the input string is returned.
public String getUniqueId()
public Object getUnique()
public double revert()
throws RemoteException
revert in interface TriggerableReloadRemoteExceptionpublic ObserveSql getObserveSql()
public PermissionSql getPermissionSql()
public UserSql getUserSql()
public ProposalSql getProposalSql()
public TargetSql getTargetSql()
public TaskSql getTaskSql()
public HistorySql getHistorySql()
protected double rescanned(String key, String old, String newval)
reload() for
set-related changes.rescanned in class ReceiverTorsopublic double reload()
reload in class PropertyContainerpublic Collection<Driver> getAllDrivers()
protected boolean zeroAllOmc()
protected boolean restartAllDrivers()
#restartDriver.protected boolean resetAllDrivers()
private static boolean reopenDrivers(Collection<Driver> drvs)
private static boolean resetDrivers(Collection<Driver> drvs)
private static boolean reopenSingleDriver(Driver io)
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.public Parameter getParameterByName(String name)
public Parameter getParameterByKey(String key)
public Object getParameterValueByName(String name)
public Object getParameterValueByKey(String key)
public Object setParameterValueByName(String name, Object newval)
public Object setParameterValueByKey(String key, Object newval)
protected ParameterClustering getParameterCluster()
public boolean setPassive(boolean inert)
throws RemoteException
setPassive in interface ListenerControllingRemoteExceptionpublic boolean automatic()
throws RemoteException
RoofControlling#open.automatic in interface ListenerControllingRemoteExceptionpublic void setOff(String manual)
setOff in interface AlarmHandlermanual - Ignored.public boolean manual()
throws RemoteException
ReceiverTorso.unbindDefault() method and sets the automatic flag to false.manual in interface ListenerControllingRemoteExceptionprotected void resetAlarm()
private boolean manual(long reauto)
throws RemoteException
reauto - If >0, re-auto timeoutRemoteExceptionpublic boolean external(Remote caster) throws RemoteException
external in interface ListenerControllingRemoteExceptionpublic String getStatus() throws RemoteException
statusMaster method.getStatus in interface ListenerControllingRemoteExceptionpublic boolean initialize()
throws RemoteException
initializeMaster(stella.CommandEvent) in the default implementation.initialize in interface ListenerControllingRemoteExceptionpublic boolean reset()
throws RemoteException
reset in interface ListenerControllingRemoteExceptionpublic boolean park()
throws RemoteException
park in interface ListenerControllingRemoteExceptionpublic void quit()
throws RemoteException
quit in interface ListenerControllingRemoteExceptionpublic boolean isAuto()
auto flag is true and no external caster is
registered.public boolean isManual()
auto flag is false and no external caster is
registered.public void rmiCommand(CommandEvent cmd) throws RemoteException
rmiCommand in interface RmiCommandListenerrmiCommand in class ReceiverTorsocmd - The command to process.RemoteExceptionpublic void addRmiErrorListener(RmiErrorListener ear) throws RemoteException
addRmiErrorListener in interface RmiErrorCasteraddRmiErrorListener in class AbstractRmiCasterAndListenerRemoteExceptionpublic void addErrorListener(ErrorListener ear)
addErrorListener in interface ErrorCasteraddErrorListener in class AbstractRmiCasterAndListenerpublic boolean isAlive()
throws RemoteException
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.
isAlive in interface AliveRemoteExceptionpublic Set<String> rmiGetAllParameterNames() throws RemoteException
#getAllParameterNames and pipes the result
into a hash-set, which is guaranteed to be serializable.rmiGetAllParameterNames in interface RmiParameterClusteringRemoteExceptionpublic Object rmiGet(String name) throws RemoteException
#get.rmiGet in interface RmiParameterClusteringRemoteExceptionpublic Object rmiSet(String name, Object to) throws RemoteException
rmiSet in interface RmiParameterClusteringRemoteExceptionpublic void rmiAddParameter(URL resource) throws RemoteException
rmiAddParameter in interface RmiParameterClusteringRemoteExceptionpublic void rmiRemoveParameter(String name) throws RemoteException
rmiRemoveParameter in interface RmiParameterClusteringRemoteExceptionprotected boolean isPassive()
protected int getAcknowledgeNumber(CommandEvent cmd)
getAcknowledgeNumber in class ReceiverTorsoprotected long getCompletionTime(CommandEvent cmd, int acknr)
getCompletionTime in class ReceiverTorsocmd - The command to process.acknr - The number of the acknowledge that will be sent back.protected boolean processCommand(CommandEvent cmd, int acknr)
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.
processCommand in class ReceiverTorsoprotected void setLastError(CommandEvent cmd, ErrorEvent ee)
setLastError in class ReceiverTorsoprotected boolean abortMaster(CommandEvent cmd)
cmd - Non-null in automatic mode.protected abstract boolean resetMaster(CommandEvent cmd)
cmd - Non-null in automatic mode.protected abstract boolean initializeMaster(CommandEvent cmd)
cmd - Non-null in automatic mode.protected abstract boolean parkMaster(CommandEvent cmd)
cmd - Non-null in automatic mode.protected abstract Object statusMaster(CommandEvent cmd)
cmd - Non-null in automatic mode.ErrorEvent.protected void quitMaster(CommandEvent cmd)
shutdown() on the parent. If any exit-cleaning tasks have to be
performed, this method should be overriden.cmd - Non-null in automatic mode, ignored in this implementationprotected void shutdown()
public void exit()
exit in interface ExitCleaningexit in class ReceiverTorsoprivate void sendMasterStatus(Object tosend)