stella
Class MasterMind

java.lang.Object
  extended by util.PropertyContainer
      extended by util.PropertyResources
          extended by util.PropertyBundles
              extended by util.rmi.RmiPropertyContainer
                  extended by util.rmi.AbstractRmiCaster
                      extended by stella.CastingContainer
                          extended by stella.MasterMind
All Implemented Interfaces:
Cloneable, Runnable, Remote, RmiErrorCaster, RmiParameterClustering, SchedulerControlling, SchedulerLogging, TargetOfOpportunity, AlarmHandler, CancelRunnable, ExitCleaning, Initializable, LocalizedSupplying, PropertySupplying, Refreshing, ResourceSupplying, RmiCaster, RmiPropertyBearing, RmiStatusProviding

public class MasterMind
extends CastingContainer
implements AlarmHandler, Refreshing, CancelRunnable, Initializable, ExitCleaning, RmiParameterClustering, TargetOfOpportunity, SchedulerLogging, RmiStatusProviding, RmiErrorCaster

The entry class for the STELLA-SCS control system. Starting this class with

 java stella.MasterMind [properties.file]
 
launches the STELLA-SCS. The following properties are stored within the file, specified with these keys. Note that all keys linked to properties files (KEY_RECEIVER, KEY_RENDER, KEY_GLOBAL, KEY_ERROR, KEY_SEQUENCER, KEY_SCHEDULER, and KEY_LOGGER) require that a class is present in these properties. Only the most important keys are explained. In version 1.1, a simulation modus was added, KEY_SIMULATE. In simulation mode, the only differences to normal action are Different simulation modi are possible, either full-fledged simulation, where also commands are relayed to (simulated) peripherals, or simulation just for testing the scheduling. In the latter case, the sequencer should advance the time variable for the anicipated target observing time. The errorhandler can in principle used to mimic bad-weather siutautions.


Nested Class Summary
private static class MasterMind.Stamp
          Class that holds the unique id plus the time stamp.
 
Nested classes/interfaces inherited from class util.PropertyResources
PropertyResources.URLResource
 
Field Summary
private  boolean cancel
          True if the master mind should stop.
private static int CLEANSEPRIORITY
          The priority at which ExitCleaning on this should occur.
private static boolean DEFBIND
          The default auto-binding as a RemoteParameter.
private static String DEFBINDNAME
          Default binding name for a target mangager.
private static long DEFCANCELTIME
          The default maximal wait for cancel time-out.
private static boolean DEFCLEANONEXIT
          Defaults adds a shutdown hook.
private static long DEFCOOLDOWN
          The default sleeping intervall, ms (600000).
private static long DEFINITDELAY
          The default delay before starting the master mind.
private static String DEFLOGGERGROUP
          The default name of the device trigger thread group (devicetrigger).
private static long DEFRUNTIME
          If true, master mind is in simulation modus.
private static boolean DEFSIMULATE
          If true, master mind is in simulation modus.
private static long DEFSLEEP
          The default sleeping intervall, ms (600000).
private static String DEFSTELLA
          Default STELLA identifier.
private static String DEFTIME
          The default name of the time parameter.
private static long DEFTIMEOUT
          The default maximal wait for sequence completion, ms (12h).
private static String DEFTOO
          The default name of the time parameter.
private static long DEFTOOALIVE
          The default time a ToO is active (=able to be picked).
private static String DEFTWILIGHT
          The default name of the time parameter.
private static String DEFUNIQUE
          The default target list parameter.
private static String DEFURL
          The default name of the url parameter.
private  Timer devicetimer
          The timer the device triggers run in.
private  ErrorHandling errorhandler
          The actual error handler object used.
private  ParameterServer globalserver
          The parameter server if any.
private  Map<String,ParsedTarget> grb
          A lookup table for ToOs.
static String GRBTEMPLATE
           
private static int HANDLERPRIORITY
          The priority at ExitCleaning on error handler should occur.
private static boolean idle
          A logging flag.
static String KEY_BIND
          The key in the Map for auto-binding of the trigger.
static String KEY_CANCELTIME
          The maximal wait for one sequence completion.
static String KEY_CLEANONEXIT
          True, if the exit cleaner should act as a shutdown-hook.
static String KEY_COOLDOWN
          The coll-down time after one object was finished.
static String KEY_ERROR
          The key matching to the properties of the error handler.
static String KEY_GLOBAL
          The key matching to the properties of the global parameter set.
static String KEY_INITDELAY
          The sleep period before starting the master mind.
static String KEY_LOCALWEATHER
          The key matching to the properties of a local weather station.
static String KEY_LOGGER
          The key matching to the list of logger to use.
static String KEY_LOGGERGROUP
          The key to the name of the device trigger thread group.
static String KEY_RANKMONITOR
          An object that records and stores the scheduling history.
static String KEY_RECEIVER
          The key to the properties of the service provider.
static String KEY_RENDER
          The key to the properties of the template to command translater.
static String KEY_RUNTIME
          The maximum run-time, zero is run forever.
static String KEY_SCHEDULER
          The key matching to the properties of the scheduler.
static String KEY_SEQUENCER
          The key matching to the properties of the sequencer.
static String KEY_SERVER
          The key matching to the properties of the global parameter set.
static String KEY_SIMULATE
          If true, simulation modi is invoked.
static String KEY_SLEEP
          The maximal sleep period between unsuccessful scheduler querries.
static String KEY_STELLA
          The key to the telescope identifier.
static String KEY_TARGETLIST
          The key matching to the target list parameter.
static String KEY_THREADNAME
          The key matching to this master mind's thread name.
static String KEY_TIME
          The name of the time parameter to use.
static String KEY_TIMEOUT
          The maximal wait for one sequence completion.
static String KEY_TOO
          The name of the too trigger to use.
static String KEY_TOOALIVE
          The time a ToO is active.
static String KEY_TWILIGHT
          The name of the twilight parameter to use.
static String KEY_UNIQUE
          The key matching to the unique parameter.
static String KEY_URL
          The name of the CCD-data URL parameter to use.
private static int LAUNCHERPRIORITY
          The priority at which ExitCleaning on command handlers occur.
static Object LOCK
          A locking object for various purposes.
private static ThreadGroup loggergroup
          The thread group the loggers run in.
private  Logging[] loggers
          The loggers to use.
private static MasterMind mastermind
          The static reference to the single master mind that is running.
private static int MASTERPRIORITY
          The priority at ExitCleaning on error handler should occur.
private static Thread masterthread
          The thread the master mind runs in.
private  ParameterClustering parameters
          The global parameter set.
private  RankingMonitor rank
          If we are moitoring the target's rankings.
private  CommandRendering render
          The command rendering object.
private  Scheduling scheduler
          The actual scheduling object used.
private  Sequencing sequencer
          The actual sequencer object used.
private static int SEQUENCERPRIORITY
          The priority at which ExitCleaning on sequencer should occur.
private  CommandLaunching[] servers
          The array of command servers from the KEY_RECEIVER list.
private  TargetProviding<TargetDefinition> targetlist
          The global parameter set.
private  Map<TargetDefinition,MasterMind.Stamp> timetable
          A list of all targets in and their pick time.
private  WeatherSurveying weather
          A local weather station.
 
Fields inherited from class util.rmi.AbstractRmiCaster
ALTERNATEHOST, ALTERNATEPORT, KEY_BINDNAME, KEY_EXPORTPORT, KEY_REGISTRYHOST, KEY_REGISTRYPORT
 
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 util.ResourceSupplying
KEY_URLRESOURCES, KEY_URLUSECONFIG, KEY_URLUSECURRENT, KEY_URLUSEHOME
 
Fields inherited from interface util.PropertySupplying
CONFIG, KEY_CLASS
 
Constructor Summary
MasterMind(Map<String,String> prop)
          Constructs a new master mind with the given properties.
 
Method Summary
 boolean addMeritLog(String newtd)
          Adds a single target for extensive merit logging.
 boolean addTarget(TargetDefinition dom)
          Remote interface for adding targets.
private  void advanceTime(long sleep)
          Advances the time if the time parameter is a SettableTime object.
 void cancel()
          Cancels execution of the master mind program.
 void exit()
          On exit, cancel me and exit all exit-cleaning sub-objects.
private  String formatTime()
          If we run in simulator mode, we return a formatted version of the simulator time here, otherwise we return an empty string.
 Collection<String> getActive()
          Returns all active IDs.
 Collection<TargetDefinition> getAllTargets()
          Returns a collection of all targets.
 Thread getAsociatedThread()
          Returns the thread asociated with the master mind.
private static double getFreeMemory()
          Returns the free memory in k-bytes.
 long getRefreshInterval()
          Refresh intervall is one day.
 TargetDefinition getTarget(String name)
          Returns a single target specified by its name.
 String getTelescope()
          For remote queries on the telescope we operate.
private  long getTime()
          Returns the current time as a Long.
private  Unique getUnique()
          Returns the unique parameter.
 void init()
          Inits the master mind.
protected  void initOptional()
          Initializes optional components of the master mind.
protected  void initRequired()
          Initializes the required components of the master mind.
 boolean isFixedRate()
          Always do this prior to nightfall.
static boolean isIdle()
          Returns true, if last scheduler query has returned null.
 List<String> listAllTargets()
          Lists the name of all targets.
static void main(String[] arg)
          Starts the master mind with a Properties object constructed out of the first argument or with the default properties if no argument is given.
 long maxTimeToCancel()
          Returns the maximum time the master mind will need for canceling its thread.
static boolean nighttime()
          Returns true, if the master mind thinks its night.
 Object provideStatus()
          Returns a status from the master.
 void refresh()
          Each night we clear the target list from surviving left-overs before proceeding.
 boolean reloadTargets()
          Reloads all targets.
 void removeAllTargets()
          Removes all targets.
 boolean removeMeritLog(String newtd)
          Removes the target from the scheduler's list.
 boolean removeTarget(String name)
          Remote interface for removing a target having the name.
 boolean removeToo(String name)
          Removes the target from the scheduler's list.
 void rmiAddParameter(URL resource)
          Adds a parameter that is loadable from the given resource.
 Object rmiGet(String name)
          Returns the parameter's value as an object.
 Set rmiGetAllParameterNames()
          Returns all names of the parameters this parameter set serves, tailored for rmi-access.
 Object rmiProvideStatus()
          Returns a status from the master.
 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.
 Serializable rmiTooStatus(String id)
          Returns a short description of the status of the GRB targets.
 void run()
          The run method of the master mind.
private  boolean runOneSequence(TargetDefinition aux)
          Runs a single sequence on a target.
private  boolean runOneTarget(TargetDefinition sub)
          Runs a single target.
 void setOff(String id)
          Called if an ToO run out of its lifetime.
protected  void startMaster()
          Starts this master mind in an individual thread.
private static String statusProvider(StatusProviding stat)
          Provides a generic status string for StatusProviding objects by returning thei class name folowed by the string representation of their status.
 boolean triggerGrb(String id, double ra, double de, double exptime, boolean interrupt)
          Passes to triggerToo(java.lang.String, java.lang.String, double, double, double, boolean) with the special grb template GRBTEMPLATE.
 boolean triggerToo(String id, String templ, double ra, double de, double exptime, boolean interrupt)
          This method expects the template to point to the serialized version of a parsed target.
 boolean updateToo(String id, String field, Object to)
          This method grabs the ToO from the internal list via the supplied id, checks, if the target has a specific field as specified in the second argument, and, if so, tries to update it.
 
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.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, 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, 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.rmi.RmiErrorCaster
addRmiErrorListener, removeRmiErrorListener
 
Methods inherited from interface util.rmi.RmiCaster
bindToRegistry, isValid, unbindFromRegistry
 
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
 

Field Detail

LOCK

public static final Object LOCK
A locking object for various purposes. Anybody may use it.


GRBTEMPLATE

public static final String GRBTEMPLATE
See Also:
Constant Field Values

KEY_RENDER

public static final String KEY_RENDER
The key to the properties of the template to command translater.

See Also:
Constant Field Values

KEY_RECEIVER

public static final String KEY_RECEIVER
The key to the properties of the service provider.

See Also:
Constant Field Values

KEY_SEQUENCER

public static final String KEY_SEQUENCER
The key matching to the properties of the sequencer.

See Also:
Constant Field Values

KEY_SCHEDULER

public static final String KEY_SCHEDULER
The key matching to the properties of the scheduler.

See Also:
Constant Field Values

KEY_ERROR

public static final String KEY_ERROR
The key matching to the properties of the error handler.

See Also:
Constant Field Values

KEY_GLOBAL

public static final String KEY_GLOBAL
The key matching to the properties of the global parameter set.

See Also:
Constant Field Values

KEY_TARGETLIST

public static final String KEY_TARGETLIST
The key matching to the target list parameter.

See Also:
Constant Field Values

KEY_UNIQUE

public static final String KEY_UNIQUE
The key matching to the unique parameter.

See Also:
Constant Field Values

KEY_SIMULATE

public static final String KEY_SIMULATE
If true, simulation modi is invoked.

See Also:
Constant Field Values

KEY_RUNTIME

public static final String KEY_RUNTIME
The maximum run-time, zero is run forever.

See Also:
Constant Field Values

KEY_RANKMONITOR

public static final String KEY_RANKMONITOR
An object that records and stores the scheduling history.

See Also:
Constant Field Values

KEY_LOGGER

public static final String KEY_LOGGER
The key matching to the list of logger to use.

See Also:
Constant Field Values

KEY_SERVER

public static final String KEY_SERVER
The key matching to the properties of the global parameter set.

See Also:
Constant Field Values

KEY_LOCALWEATHER

public static final String KEY_LOCALWEATHER
The key matching to the properties of a local weather station.

See Also:
Constant Field Values

KEY_THREADNAME

public static final String KEY_THREADNAME
The key matching to this master mind's thread name.

See Also:
Constant Field Values

KEY_LOGGERGROUP

public static final String KEY_LOGGERGROUP
The key to the name of the device trigger thread group.

See Also:
Constant Field Values

KEY_TIME

public static final String KEY_TIME
The name of the time parameter to use.

See Also:
Constant Field Values

KEY_TWILIGHT

public static final String KEY_TWILIGHT
The name of the twilight parameter to use.

See Also:
Constant Field Values

KEY_TOO

public static final String KEY_TOO
The name of the too trigger to use.

See Also:
Constant Field Values

KEY_TOOALIVE

public static final String KEY_TOOALIVE
The time a ToO is active.

See Also:
Constant Field Values

KEY_URL

public static final String KEY_URL
The name of the CCD-data URL parameter to use.

See Also:
Constant Field Values

KEY_INITDELAY

public static final String KEY_INITDELAY
The sleep period before starting the master mind.

See Also:
Constant Field Values

KEY_COOLDOWN

public static final String KEY_COOLDOWN
The coll-down time after one object was finished.

See Also:
Constant Field Values

KEY_SLEEP

public static final String KEY_SLEEP
The maximal sleep period between unsuccessful scheduler querries.

See Also:
Constant Field Values

KEY_TIMEOUT

public static final String KEY_TIMEOUT
The maximal wait for one sequence completion.

See Also:
Constant Field Values

KEY_CANCELTIME

public static final String KEY_CANCELTIME
The maximal wait for one sequence completion.

See Also:
Constant Field Values

KEY_CLEANONEXIT

public static final String KEY_CLEANONEXIT
True, if the exit cleaner should act as a shutdown-hook.

See Also:
Constant Field Values

KEY_BIND

public static final String KEY_BIND
The key in the Map for auto-binding of the trigger.

See Also:
Constant Field Values

KEY_STELLA

public static final String KEY_STELLA
The key to the telescope identifier.

See Also:
Constant Field Values

DEFLOGGERGROUP

private static final String DEFLOGGERGROUP
The default name of the device trigger thread group (devicetrigger).

See Also:
Constant Field Values

DEFTIME

private static final String DEFTIME
The default name of the time parameter.

See Also:
Constant Field Values

DEFTWILIGHT

private static final String DEFTWILIGHT
The default name of the time parameter.

See Also:
Constant Field Values

DEFTOO

private static final String DEFTOO
The default name of the time parameter.

See Also:
Constant Field Values

DEFTOOALIVE

private static final long DEFTOOALIVE
The default time a ToO is active (=able to be picked).

See Also:
Constant Field Values

DEFURL

private static final String DEFURL
The default name of the url parameter.

See Also:
Constant Field Values

DEFINITDELAY

private static final long DEFINITDELAY
The default delay before starting the master mind.

See Also:
Constant Field Values

DEFCOOLDOWN

private static final long DEFCOOLDOWN
The default sleeping intervall, ms (600000).

See Also:
Constant Field Values

DEFSLEEP

private static final long DEFSLEEP
The default sleeping intervall, ms (600000).

See Also:
Constant Field Values

DEFTIMEOUT

private static final long DEFTIMEOUT
The default maximal wait for sequence completion, ms (12h).

See Also:
Constant Field Values

DEFCANCELTIME

private static final long DEFCANCELTIME
The default maximal wait for cancel time-out.

See Also:
Constant Field Values

DEFUNIQUE

private static final String DEFUNIQUE
The default target list parameter.

See Also:
Constant Field Values

DEFSIMULATE

private static final boolean DEFSIMULATE
If true, master mind is in simulation modus.

See Also:
Constant Field Values

DEFRUNTIME

private static final long DEFRUNTIME
If true, master mind is in simulation modus.

See Also:
Constant Field Values

DEFCLEANONEXIT

private static final boolean DEFCLEANONEXIT
Defaults adds a shutdown hook.

See Also:
Constant Field Values

DEFBIND

private static final boolean DEFBIND
The default auto-binding as a RemoteParameter.

See Also:
Constant Field Values

DEFBINDNAME

private static final String DEFBINDNAME
Default binding name for a target mangager.

See Also:
Constant Field Values

DEFSTELLA

private static final String DEFSTELLA
Default STELLA identifier.

See Also:
Constant Field Values

render

private CommandRendering render
The command rendering object. Converts templates into commands.


servers

private CommandLaunching[] servers
The array of command servers from the KEY_RECEIVER list.


scheduler

private Scheduling scheduler
The actual scheduling object used.


sequencer

private Sequencing sequencer
The actual sequencer object used.


errorhandler

private ErrorHandling errorhandler
The actual error handler object used.


parameters

private ParameterClustering parameters
The global parameter set. Used for scheduling and sequencing.


targetlist

private TargetProviding<TargetDefinition> targetlist
The global parameter set. Used for scheduling and sequencing.


rank

private RankingMonitor rank
If we are moitoring the target's rankings.


timetable

private Map<TargetDefinition,MasterMind.Stamp> timetable
A list of all targets in and their pick time.


grb

private Map<String,ParsedTarget> grb
A lookup table for ToOs.


globalserver

private ParameterServer globalserver
The parameter server if any.


loggers

private Logging[] loggers
The loggers to use. Started, registered, no further care.


weather

private WeatherSurveying weather
A local weather station.


devicetimer

private Timer devicetimer
The timer the device triggers run in.


cancel

private boolean cancel
True if the master mind should stop.


mastermind

private static MasterMind mastermind
The static reference to the single master mind that is running.


masterthread

private static Thread masterthread
The thread the master mind runs in.


loggergroup

private static ThreadGroup loggergroup
The thread group the loggers run in.


idle

private static boolean idle
A logging flag.


CLEANSEPRIORITY

private static final int CLEANSEPRIORITY
The priority at which ExitCleaning on this should occur.

See Also:
Constant Field Values

SEQUENCERPRIORITY

private static final int SEQUENCERPRIORITY
The priority at which ExitCleaning on sequencer should occur.

See Also:
Constant Field Values

HANDLERPRIORITY

private static final int HANDLERPRIORITY
The priority at ExitCleaning on error handler should occur.

See Also:
Constant Field Values

LAUNCHERPRIORITY

private static final int LAUNCHERPRIORITY
The priority at which ExitCleaning on command handlers occur.

See Also:
Constant Field Values

MASTERPRIORITY

private static final int MASTERPRIORITY
The priority at ExitCleaning on error handler should occur.

See Also:
Constant Field Values
Constructor Detail

MasterMind

public MasterMind(Map<String,String> prop)
           throws RemoteException
Constructs a new master mind with the given properties. Initializes and starts the mastermind in two separated methods, initRequired() and initOptional() before startMaster().

Throws:
RemoteException
Method Detail

init

public void init()
Inits the master mind. Does not start the master, this must be done explicetly with a call to startMaster().

Specified by:
init in interface Initializable
Overrides:
init in class PropertyResources

initRequired

protected void initRequired()
Initializes the required components of the master mind. Called immediately after construction. This method does the following (in the stated order): If one of these essential constructs fails, a MasterInitException is thrown. After initializing is complete, the master mind is started via a call to startMaster().

Throws:
MasterInitException - If construction of either object fails.

initOptional

protected void initOptional()
Initializes optional components of the master mind. This method is called immediately after the initialization of the required components of the master mind. It does the following Implementation note: Always construct the loggers as the last objects.


exit

public void exit()
On exit, cancel me and exit all exit-cleaning sub-objects.

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

rmiGetAllParameterNames

public Set rmiGetAllParameterNames()
                            throws RemoteException
Returns all names of the parameters this parameter set serves, tailored for rmi-access. Calls #getAllParameterNames

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

getTelescope

public String getTelescope()
                    throws RemoteException
For remote queries on the telescope we operate.

Specified by:
getTelescope in interface SchedulerControlling
Throws:
RemoteException

addTarget

public boolean addTarget(TargetDefinition dom)
                  throws RemoteException
Remote interface for adding targets.

Specified by:
addTarget in interface SchedulerControlling
Returns:
True, if a target was added
Throws:
RemoteException

removeTarget

public boolean removeTarget(String name)
                     throws RemoteException
Remote interface for removing a target having the name.

Specified by:
removeTarget in interface SchedulerControlling
Returns:
True, if a target was removed.
Throws:
RemoteException

removeAllTargets

public void removeAllTargets()
                      throws RemoteException
Removes all targets.

Specified by:
removeAllTargets in interface SchedulerControlling
Throws:
RemoteException

reloadTargets

public boolean reloadTargets()
                      throws RemoteException
Reloads all targets.

Specified by:
reloadTargets in interface SchedulerControlling
Returns:
True, if a targets were restored.
Throws:
RemoteException

addMeritLog

public boolean addMeritLog(String newtd)
                    throws RemoteException
Adds a single target for extensive merit logging.

Specified by:
addMeritLog in interface SchedulerLogging
Returns:
True, if a target was added
Throws:
RemoteException

removeMeritLog

public boolean removeMeritLog(String newtd)
                       throws RemoteException
Removes the target from the scheduler's list. The target is physically removed and cannot be restored except by re-adding it with the addTarget(stella.TargetDefinition) method.

Specified by:
removeMeritLog in interface SchedulerLogging
Returns:
True, if a target was removed.
Throws:
RemoteException

getRefreshInterval

public long getRefreshInterval()
Refresh intervall is one day.

Specified by:
getRefreshInterval in interface Refreshing

isFixedRate

public boolean isFixedRate()
Always do this prior to nightfall.

Specified by:
isFixedRate in interface Refreshing
See Also:
Timer

refresh

public void refresh()
Each night we clear the target list from surviving left-overs before proceeding. This means that the state of the db is automatically reflected in the master-mind.

Specified by:
refresh in interface Refreshing

listAllTargets

public List<String> listAllTargets()
                            throws RemoteException
Lists the name of all targets. This is a list rather than a collection as Strings provide a natural ordering, which can later be enforced on this list. Additionally, if a collection is the view of the values in a mapping, this view is not serializable, thus remote access will fail.

Specified by:
listAllTargets in interface SchedulerControlling
Throws:
RemoteException

getAllTargets

public Collection<TargetDefinition> getAllTargets()
                                           throws RemoteException
Returns a collection of all targets. Additionally, if a collection is the view of the values in a mapping, this view is not serializable, thus remote access will fail.

Specified by:
getAllTargets in interface SchedulerControlling
Throws:
RemoteException

getTarget

public TargetDefinition getTarget(String name)
                           throws RemoteException
Returns a single target specified by its name.

Specified by:
getTarget in interface SchedulerControlling
Throws:
RemoteException

rmiProvideStatus

public Object rmiProvideStatus()
                        throws RemoteException
Returns a status from the master. This is the string version of all known status providers.

Specified by:
rmiProvideStatus in interface RmiStatusProviding
Throws:
RemoteException

provideStatus

public Object provideStatus()
Returns a status from the master. This is the string version of all known status providers.


triggerGrb

public boolean triggerGrb(String id,
                          double ra,
                          double de,
                          double exptime,
                          boolean interrupt)
                   throws RemoteException
Passes to triggerToo(java.lang.String, java.lang.String, double, double, double, boolean) with the special grb template GRBTEMPLATE.

Specified by:
triggerGrb in interface TargetOfOpportunity
Parameters:
id - A unique identifier for the GRB, can be a count number.
ra - The right ascension of the GRB, degrees, J2000.0
de - The declination of the GRB, degrees, J2000.0.
exptime - The initial exposure time in seconds.
interrupt - If true, ongoing observation should be canceled.
Returns:
True, if the new target could be created.
Throws:
RemoteException

triggerToo

public boolean triggerToo(String id,
                          String templ,
                          double ra,
                          double de,
                          double exptime,
                          boolean interrupt)
                   throws RemoteException
This method expects the template to point to the serialized version of a parsed target. After deserialization, the name is set according to the id, and the ra and de of the main star is updated. If successful, the target is added to the grb lookup table. Then, the exposure time is updated via a call to updateToo(java.lang.String, java.lang.String, java.lang.Object). This method also updates the scheduler. Currently, the interrupt flag is ignored, but in future version, an exception could be generated as the final step, triggering the scheduler to get the next highest target, which is then the GRB.

Specified by:
triggerToo in interface TargetOfOpportunity
Parameters:
id - A unique identifier for the GRB, can be a count number.
templ - A resource description that describes the ToO to use.
ra - The right ascension of the GRB, degrees, J2000.0
de - The declination of the GRB, degrees, J2000.0.
exptime - The initial exposure time in seconds.
interrupt - If true, ongoing observation should be canceled.
Returns:
True, if the new target could be created.
Throws:
RemoteException

setOff

public void setOff(String id)
Called if an ToO run out of its lifetime. The id is the GRB id.

Specified by:
setOff in interface AlarmHandler

updateToo

public boolean updateToo(String id,
                         String field,
                         Object to)
                  throws RemoteException
This method grabs the ToO from the internal list via the supplied id, checks, if the target has a specific field as specified in the second argument, and, if so, tries to update it.
This method calls ParsedTarget.getSetups() and scans through all the constants in all setups for a constant of the given field name. If a constant is found, it is updated to the supplied object. If everything is successful, the target is reloaded into the scheduler.

Specified by:
updateToo in interface TargetOfOpportunity
Parameters:
id - The id used on creation of the GRB.
field - The name of the field to be updated.
to - The new value of the field, possible a Number or String.
Returns:
True, if the field was updated successfully.
Throws:
RemoteException

removeToo

public boolean removeToo(String name)
                  throws RemoteException
Removes the target from the scheduler's list. The target is physically removed and cannot be restored except by re-adding it with the addTarget(stella.TargetDefinition) method.

Specified by:
removeToo in interface TargetOfOpportunity
Returns:
True, if a target was removed.
Throws:
RemoteException

getActive

public Collection<String> getActive()
                             throws RemoteException
Returns all active IDs.

Specified by:
getActive in interface TargetOfOpportunity
Returns:
a collection of ToO id's.
Throws:
RemoteException

rmiTooStatus

public Serializable rmiTooStatus(String id)
                          throws RemoteException
Returns a short description of the status of the GRB targets.

Specified by:
rmiTooStatus in interface TargetOfOpportunity
Throws:
RemoteException

statusProvider

private static String statusProvider(StatusProviding stat)
Provides a generic status string for StatusProviding objects by returning thei class name folowed by the string representation of their status.


startMaster

protected void startMaster()
Starts this master mind in an individual thread. Called after initialization of all necessary components of the master mind has been initialized.


run

public void run()
The run method of the master mind. This method loops forever until the cancel method is called. It does the following:

Specified by:
run in interface Runnable

cancel

public void cancel()
Cancels execution of the master mind program. Will get effective after the current observation has finished. Cancels also the device checking timer.

Specified by:
cancel in interface CancelRunnable

isIdle

public static boolean isIdle()
Returns true, if last scheduler query has returned null. Intended for logging purposes of non-MasterMind childrens.


nighttime

public static boolean nighttime()
Returns true, if the master mind thinks its night. This returnes true if the twilight parameter returns negative number or is undefined.


getAsociatedThread

public Thread getAsociatedThread()
Returns the thread asociated with the master mind.

Specified by:
getAsociatedThread in interface CancelRunnable

maxTimeToCancel

public long maxTimeToCancel()
Returns the maximum time the master mind will need for canceling its thread.

Specified by:
maxTimeToCancel in interface CancelRunnable

runOneTarget

private boolean runOneTarget(TargetDefinition sub)
Runs a single target. Reentrant. Dives into the daughters of the target until no further daugther is found. Only then the single target execution runOneSequence(stella.TargetDefinition) starts. Returns only if the target has no unfinished Successor and no parent.


runOneSequence

private boolean runOneSequence(TargetDefinition aux)
Runs a single sequence on a target. The parent classes are also given. If the sequence is run on a generic target, those two parent classes are equal to the last target.

Parameters:
aux - The target to run the sequence on.
Returns:
The outcome of the sequence

getUnique

private Unique getUnique()
Returns the unique parameter.


getTime

private long getTime()
Returns the current time as a Long. If no parameter matching the time parameter can be found, the system time is used.


formatTime

private String formatTime()
If we run in simulator mode, we return a formatted version of the simulator time here, otherwise we return an empty string.


advanceTime

private void advanceTime(long sleep)
Advances the time if the time parameter is a SettableTime object. Otherwise we sleep for the anticipated period.


getFreeMemory

private static double getFreeMemory()
Returns the free memory in k-bytes.


main

public static void main(String[] arg)
                 throws IOException
Starts the master mind with a Properties object constructed out of the first argument or with the default properties if no argument is given.

Throws:
IOException