public class SwitchTrigger extends SimpleEventTrigger implements CacheChangedListener, DriverDepending
PollingRS485Server assigned to it. This trigger
is an event trigger without a run method, so it is not actively looking
for changes but is notified if a change occurs. This is done by
implementing the CacheChangedListener interface. During assignment
of the PollingRS485Server, this trigger registers itself as an
cache-changed listener with the KEY_READSWITCH as the monitored
value. The CacheChangedEvent passed over to this switch trigger
is then interpreted and transformed into a
simple true/false decision. If the trigger toggles a waiting object
can be notified.| Modifier and Type | Class and Description |
|---|---|
static class |
SwitchTrigger.Response
A class to manually test module reads for trigger action.
|
PropertyResources.Load, PropertyResources.URLResource| Modifier and Type | Field and Description |
|---|---|
private static int |
CLOSEMASK
The bits masking to the close-roof switches.
|
private static int |
DEFCHANNEL
The defalt input channel to read.
|
private static int |
DEFFAILURE
The default failure return.
|
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 int |
DEFREADLENGTH
The default number of chars in the retruned read string.
|
private static String |
DEFREADSWITCH
The default read switch string.
|
private static int |
DEFSKIP
The default number of chars to skip on digital input.
|
static String |
KEY_CHANNEL
The key pointing to the digital input word to interpret.
|
static String |
KEY_FAILURE
This is the return integer in case of switch unreadable.
|
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_READLENGTH
The key linked to the length of the read string.
|
static String |
KEY_READSWITCH
The key linked to the string sent to the serial port before reading.
|
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.
|
KEY_INITBOOLEANKEY_FORMAT, KEY_NAME, KEY_PRESERVE, UNKNOWNKEY_NOINITONCREATE, POSTFIX_ALPHABET, POSTFIX_BYTES, POSTFIX_DIR, POSTFIX_EXT, POSTFIX_FILE, POSTFIX_LIST, POSTFIX_MODTIME, POSTFIX_URLKEY_LISTSEPARATOR, KEY_MAPKEYVALUECHAR, KEY_MAPSEPARATORCONFIG, KEY_CLASSKEY_URLRESOURCES, KEY_URLUSECONFIG, KEY_URLUSECURRENT, KEY_URLUSEHOME| Constructor and Description |
|---|
SwitchTrigger(Map prop)
Constructs a new switch trigger.
|
| Modifier and Type | Method and Description |
|---|---|
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:
|
void |
newValue(CacheChangedEvent cce)
The run method of the switch-trigger thread.
|
boolean |
registerDriver(Driver server)
Registers the serial server to this switch trigger.
|
Boolean |
setTrigger(Boolean val)
Sets the switch trigger value.
|
getMonitor, registerMonitor, toggleTriggergetLastToggleTime, getTrigger, init, rescannedget, getElapsedToggleTime, isTrue, setcreateParameter, delivers, exit, getFormatted, getFormatted, getName, getPreserveFile, getString, getString, overrideDefaultName, register, setName, toStringclone, 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, reload, removeProperty, requires, setObject, setProperties, setProperty, stringPropertiesequals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitreloadgetFormatted, getName, getStringdefaultBoolean, 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_READSWITCH
public static final String KEY_READLENGTH
public static final String KEY_SKIP
public static final String KEY_CHANNEL
public static final String KEY_MASK
public static final String KEY_INVERSE
public static final String KEY_FAILURE
private static final String DEFREADSWITCH
private static final int DEFREADLENGTH
private static final int DEFSKIP
private static final int DEFCHANNEL
private static final int DEFMASK
private static final boolean DEFINVERSE
private static final int DEFFAILURE
private static final int OPENMASK
private static final int CLOSEMASK
public SwitchTrigger(Map prop)
PollingRS485Server must be assigned to this trigger.public Boolean setTrigger(Boolean val)
setTrigger in interface TriggeringsetTrigger in class SimpleEventTriggerpublic boolean registerDriver(Driver server)
PollingRS485Server drivers.registerDriver in interface DriverDependingpublic void newValue(CacheChangedEvent cce)
newValue in interface CacheChangedListenerprotected Boolean getBooleanFromResponse(String read)
KEY_MASK and
returns true if the result is equal to the trigger mask.protected int getDigiatlIOChannelsFromResponse(String read)
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: