stella.roof
Class OneReadTrigger

java.lang.Object
  extended by util.PropertyContainer
      extended by util.PropertyResources
          extended by util.PropertyBundles
              extended by stella.parameter.AbstractParameter
                  extended by stella.parameter.AbstractTrigger
                      extended by stella.parameter.SimpleTrigger
                          extended by stella.roof.OneReadTrigger
All Implemented Interfaces:
DriverDepending, Cloneable, Parameter, Trigger, ExitCleaning, Initializable, LocalizedSupplying, PropertySupplying, Reloadable, ResourceSupplying

public class OneReadTrigger
extends SimpleTrigger
implements DriverDepending

A trigger that reads the serial line on startup. The value returned determines the on/off state of the trigger. After this initialization, only direct calls to the trigger methods may change its value. This trigger is only used for the power-on switch in the roof control. Additionally this trigger exports its value via RMI.


Nested Class Summary
 
Nested classes/interfaces inherited from class util.PropertyResources
PropertyResources.URLResource
 
Field Summary
private static int CLOSEMASK
          The bits masking to the close-roof switches.
private static int DEFCHANNEL
          The defalt input channel to read.
private static boolean DEFINVERSE
          The default inverse mask interpretation (false).
private static int DEFMASK
          The bits masking to the open-roof switches, used as default.
private static String DEFREADSWITCH
          The default read switch string.
private static int DEFRETRY
          The defalt input channel to read.
private static int DEFSKIP
          The default number of chars to skip on digital input.
private static long DEFSWITCHTIME
          The default limit switch polling, should at least equal polling time.
static String KEY_CHANNEL
          The key pointing to the digital input word to interpret.
static String KEY_INVERSE
          The key for interpreting the mask inversely, true or false.
static String KEY_MASK
          The key for interpreting the return bitmask as true or false.
static String KEY_READSWITCH
          The key linked to the string sent to the serial port before reading.
static String KEY_RETRY
          Maximum number of retries in determining power state.
static String KEY_SKIP
          The key for skiping leading bytes on digital input.
private static int OPENMASK
          The bits masking to the open-roof switches.
 
Fields inherited from class stella.parameter.SimpleTrigger
KEY_INITBOOLEAN
 
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 util.PropertySupplying
CONFIG, KEY_CLASS
 
Fields inherited from interface util.ResourceSupplying
KEY_URLRESOURCES, KEY_URLUSECONFIG, KEY_URLUSECURRENT, KEY_URLUSEHOME
 
Constructor Summary
OneReadTrigger(Map prop)
          Constructs a new switch trigger.
 
Method Summary
protected  Boolean getBooleanFromResponse(String read)
          This method transforms the output of the switches into a single information whether the roof-switches are down.
protected  int getDigiatlIOChannelsFromResponse(String read)
          The string read in from the serial port has the following format:
 boolean registerDriver(Driver serial)
          Registers the serial server to this switch trigger.
 
Methods inherited from class stella.parameter.SimpleTrigger
getLastToggleTime, getTrigger, init, rescanned, setTrigger
 
Methods inherited from class stella.parameter.AbstractTrigger
get, getElapsedToggleTime, isTrue, set, toggleTrigger
 
Methods inherited from class stella.parameter.AbstractParameter
createParameter, delivers, exit, 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.Parameter
getFormatted, getName, getString
 
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_READSWITCH

public static final String KEY_READSWITCH
The key linked to the string sent to the serial port before reading.

See Also:
Constant Field Values

KEY_SKIP

public static final String KEY_SKIP
The key for skiping leading bytes on digital input.

See Also:
Constant Field Values

KEY_CHANNEL

public static final String KEY_CHANNEL
The key pointing to the digital input word to interpret.

See Also:
Constant Field Values

KEY_MASK

public static final String KEY_MASK
The key for interpreting the return bitmask as true or false.

See Also:
Constant Field Values

KEY_INVERSE

public static final String KEY_INVERSE
The key for interpreting the mask inversely, true or false.

See Also:
Constant Field Values

KEY_RETRY

public static final String KEY_RETRY
Maximum number of retries in determining power state.

See Also:
Constant Field Values

DEFREADSWITCH

private static final String DEFREADSWITCH
The default read switch string.

See Also:
Constant Field Values

DEFSWITCHTIME

private static final long DEFSWITCHTIME
The default limit switch polling, should at least equal polling time.

See Also:
Constant Field Values

DEFSKIP

private static final int DEFSKIP
The default number of chars to skip on digital input.

See Also:
Constant Field Values

DEFCHANNEL

private static final int DEFCHANNEL
The defalt input channel to read.

See Also:
Constant Field Values

DEFMASK

private static final int DEFMASK
The bits masking to the open-roof switches, used as default.

See Also:
Constant Field Values

DEFRETRY

private static final int DEFRETRY
The defalt input channel to read.

See Also:
Constant Field Values

DEFINVERSE

private static final boolean DEFINVERSE
The default inverse mask interpretation (false).

See Also:
Constant Field Values

OPENMASK

private static final int OPENMASK
The bits masking to the open-roof switches.

See Also:
Constant Field Values

CLOSEMASK

private static final int CLOSEMASK
The bits masking to the close-roof switches.

See Also:
Constant Field Values
Constructor Detail

OneReadTrigger

public OneReadTrigger(Map prop)
Constructs a new switch trigger. Before starting the trigger a PollingRS485Server must be assigned to this trigger.

Method Detail

registerDriver

public boolean registerDriver(Driver serial)
Registers the serial server to this switch trigger. Must be called prior to starting this switch trigger.

Specified by:
registerDriver in interface DriverDepending
Returns:
True if registering at the driver was successful.

getBooleanFromResponse

protected Boolean getBooleanFromResponse(String read)
This method transforms the output of the switches into a single information whether the roof-switches are down. This method logical ANDs the digital output channels with this trigger's KEY_MASK and returns true if the result is equal to the trigger mask.


getDigiatlIOChannelsFromResponse

protected int getDigiatlIOChannelsFromResponse(String read)
The string read in from the serial port has the following format:
                 CH#0[CH#1]...[CH#N]
       
Where skip isthe number of chars to ignore at the start of the string. The following channels are all iun 2-char format, each representing a single byte. It depends on the module used how many channels will be available on the returned string. Depending on the values given in the required properties KEY_SKIP and KEY_CHANNEL, the returned integer represents the byte as deduced from a two-char hex-string.

Examples: