stella.parameter
Class TelescopeError

java.lang.Object
  extended by util.PropertyContainer
      extended by util.PropertyResources
          extended by util.PropertyBundles
              extended by stella.parameter.AbstractParameter
                  extended by stella.parameter.AbstractCachedParameter
                      extended by stella.parameter.AbstractStatusRequestor
                          extended by stella.parameter.TelescopeError
All Implemented Interfaces:
Cloneable, Caster, ErrorCaster, ErrorDependingParameter, Parameter, StatusRequesting, ExitCleaning, Initializable, LocalizedSupplying, PropertySupplying, Reloadable, ResourceSupplying

public class TelescopeError
extends AbstractStatusRequestor
implements ErrorCaster, Reloadable

A class that uses incoming TelescopeStatus errors to deduce eventually occuring telescope errors. This is done by scanning the TelescopeStatus.getErrors() return as a comma-separated list of PILAR-specific errors. Each error encountered is matched to an internal lookup-table of PILAR error-names to SCS error-classes in KEY_TABLELIST or KEY_TABLEFILE. If a match is found, an appropriate error class is instantiated and passed to registered error-listeners (a error-handler presumably).

As this parameter is of a polling-type, the cache-time of the parent class is used as the polling-time. The value of the parameter are the list of currently active errors.


Nested Class Summary
 
Nested classes/interfaces inherited from class util.PropertyResources
PropertyResources.URLResource
 
Field Summary
private static String DEFCOMMAND
          The default class name of the status command to send.
static String DEFNAME
          The default name of this parameter.
private static long DEFPOLLTIME
          The default poll time.
private static String DEFTABLELIST
          The home position of the telescope.
private static long DEFWAIT
          The default wait time.
private  List<ErrorListener> ear
          The list of registered error listeners.
static String KEY_POLLTIME
          The polling time.
static String KEY_TABLEFILE
          The table of PILAR error-names to SCS error-classes.
static String KEY_TABLELIST
          The table of PILAR error-names to SCS error-classes.
static String KEY_WAIT
          The initial wait time.
private  Map<String,ErrorEvent> pilar
          The look-up table matching PILAR names to true error objects.
private  Timer request
          The timer used for issuing status requests.
 
Fields inherited from class stella.parameter.AbstractStatusRequestor
KEY_COMMAND, KEY_DISABLE, KEY_TIMEOUT
 
Fields inherited from class stella.parameter.AbstractCachedParameter
KEY_CACHE
 
Fields inherited from class stella.parameter.AbstractParameter
KEY_FORMAT, KEY_NAME, KEY_PRESERVE, UNKNOWN
 
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.ErrorDependingParameter
NAMING_EXTENSION
 
Fields inherited from interface util.PropertySupplying
CONFIG, KEY_CLASS
 
Fields inherited from interface util.ResourceSupplying
KEY_URLRESOURCES, KEY_URLUSECONFIG, KEY_URLUSECURRENT, KEY_URLUSEHOME
 
Constructor Summary
TelescopeError(Map<String,String> prop)
          Constructs a new telescope-error parameter.
 
Method Summary
 void addErrorListener(ErrorListener handler)
          Registers an error event listener to this property container.
private  void check()
          Checks if the currently valid errors stored in the cache are recognized and should spark a error-handler notification.
private  Map<String,ErrorEvent> constructTable()
           
 void exit()
          Exits this parameter.
 Object getForError(ErrorEvent ee)
          Returns the pilar-errors of the telescope deduced from a freshly received TelescopeStatus.
 void init()
          Initializes the telescope error parameter.
protected  boolean isStatusRequested(ErrorEvent ee)
          Returns true if the error event received is of TelescopeStatus
protected  void notifyErrorListeners(ErrorEvent ee)
          Notifies all registered ErrorListeners.
 boolean registerLauncher(CommandLaunching launch)
          Registers the appropriate command caster that can handle the appropriate request.
 void removeErrorListener(ErrorListener handler)
          Deregisters an error event listener from this property container.
 double rescanned(String key, String old, String newval)
          Returns zero if the polltime or wait period changed, reload the error lookup table if the tablelist or file changed.
 
Methods inherited from class stella.parameter.AbstractStatusRequestor
getUncached, registerError
 
Methods inherited from class stella.parameter.AbstractCachedParameter
get, getCache, getCacheFormatted, set
 
Methods inherited from class stella.parameter.AbstractParameter
createParameter, delivers, getFormatted, getFormatted, getName, getPreserveFile, getString, getString, register, setName, toString
 
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, setObject, setProperties, setProperty, stringProperties
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface util.Reloadable
reload
 
Methods inherited from interface stella.StatusRequesting
getCache, getCacheFormatted
 
Methods inherited from interface stella.Parameter
get, getFormatted, getName, getString, set
 
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.ResourceSupplying
getResource, getResourceAsStream, getResources
 

Field Detail

KEY_WAIT

public static final String KEY_WAIT
The initial wait time. Can be quite high.

See Also:
Constant Field Values

KEY_POLLTIME

public static final String KEY_POLLTIME
The polling time. Must be higher then cache time.

See Also:
Constant Field Values

KEY_TABLELIST

public static final String KEY_TABLELIST
The table of PILAR error-names to SCS error-classes.

See Also:
Constant Field Values

KEY_TABLEFILE

public static final String KEY_TABLEFILE
The table of PILAR error-names to SCS error-classes.

See Also:
Constant Field Values

DEFNAME

public static final String DEFNAME
The default name of this parameter.

See Also:
Constant Field Values

DEFWAIT

private static final long DEFWAIT
The default wait time.

See Also:
Constant Field Values

DEFPOLLTIME

private static final long DEFPOLLTIME
The default poll time.

See Also:
Constant Field Values

DEFTABLELIST

private static final String DEFTABLELIST
The home position of the telescope. Value adopted at construct.

See Also:
Constant Field Values

DEFCOMMAND

private static final String DEFCOMMAND
The default class name of the status command to send.

See Also:
Constant Field Values

pilar

private Map<String,ErrorEvent> pilar
The look-up table matching PILAR names to true error objects.


ear

private List<ErrorListener> ear
The list of registered error listeners.


request

private Timer request
The timer used for issuing status requests.

Constructor Detail

TelescopeError

public TelescopeError(Map<String,String> prop)
Constructs a new telescope-error parameter. In the init section, the look-up table is constructed. The status-request timer is only started once the appropriate command caster is registered.

Method Detail

init

public void init()
Initializes the telescope error parameter. The look-up table is constructed, either using the KEY_TABLEFILE property to load a properties file, or, if this key is missing, the KEY_TABLELIST is used to convert the mapped string to a properties object with the StringTool.propertize(java.lang.String) mthod.

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

rescanned

public double rescanned(String key,
                        String old,
                        String newval)
Returns zero if the polltime or wait period changed, reload the error lookup table if the tablelist or file changed.

Specified by:
rescanned in interface Reloadable
Overrides:
rescanned in class AbstractStatusRequestor

constructTable

private Map<String,ErrorEvent> constructTable()

registerLauncher

public boolean registerLauncher(CommandLaunching launch)
Registers the appropriate command caster that can handle the appropriate request. If the registering is successful, a timer requesting continuosely the telescope status is constructed and started.

Specified by:
registerLauncher in interface StatusRequesting
Overrides:
registerLauncher in class AbstractStatusRequestor
Returns:
True, if this is the coorect command launcher.

getForError

public Object getForError(ErrorEvent ee)
Returns the pilar-errors of the telescope deduced from a freshly received TelescopeStatus. This method should be followed by a check() call which actually performs the test for errors.

Specified by:
getForError in interface ErrorDependingParameter

exit

public void exit()
Exits this parameter. This cancels the timer task.

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

addErrorListener

public void addErrorListener(ErrorListener handler)
Registers an error event listener to this property container. This method is used for local listeners.

Specified by:
addErrorListener in interface ErrorCaster

removeErrorListener

public void removeErrorListener(ErrorListener handler)
Deregisters an error event listener from this property container. This method is used for local listeners.

Specified by:
removeErrorListener in interface ErrorCaster

notifyErrorListeners

protected void notifyErrorListeners(ErrorEvent ee)
Notifies all registered ErrorListeners. This method parses through the Vector of ErrorListeners and passes the argument to their errorOccured method. Registered listeners are local.

Parameters:
ee - The ErrorEvent to pass to the Listeners.

isStatusRequested

protected boolean isStatusRequested(ErrorEvent ee)
Returns true if the error event received is of TelescopeStatus

Specified by:
isStatusRequested in class AbstractStatusRequestor

check

private void check()
Checks if the currently valid errors stored in the cache are recognized and should spark a error-handler notification.