stella.parameter
Class RS485Switch
java.lang.Object
util.PropertyContainer
util.PropertyResources
util.PropertyBundles
stella.parameter.AbstractParameter
stella.parameter.AbstractTrigger
stella.parameter.SimpleTrigger
stella.parameter.AbstractSwitch
stella.parameter.RS485Switch
- All Implemented Interfaces:
- DriverDepending, Cloneable, Parameter, Switch, Trigger, ExitCleaning, Initializable, LocalizedSupplying, PropertySupplying, Reloadable, ResourceSupplying
- Direct Known Subclasses:
- CabinetSwitch, HumiditySwitch, LightSwitch
public class RS485Switch
- extends AbstractSwitch
- implements DriverDepending, Reloadable
A class providing access to a RS485-enabled switch. This means the
following:
- On construct, the name of the switch, the name of the serial server
and the command for turning the switch are specified.
- On the RS485 bus there is a relay that allows to switch
on and off. The two commands are given as
KEY_SWITCHON and
KEY_SWITCHOFF.
- On init, the switch binds to the registry, if
#KEY_BIND is true.
- The parameter cluster must take care of registering the RS485-driver.
For that, the switch implements the
DriverDepending
interface.
- During registering of the serial server, the switch is brought to a
defined state given with the
KEY_INITOFF key.
- Invoking the
#turnOnTimeout method switches on, but switches
off again after the stated period.
Note that this class should never be used directly.
|
Constructor Summary |
RS485Switch(Map prop)
Constructs a new light switch trigger. |
|
Method Summary |
void |
init()
Initializes the light switch. |
protected boolean |
off()
Turn the light off. |
protected boolean |
on()
Turns the switch on. |
boolean |
registerDriver(Driver rs485)
Registers the driver. |
double |
rescanned(String key,
String old,
String newval)
As any parameter depending instance we fail if the parameter we depend
on is now a different one. |
| Methods inherited from class stella.parameter.AbstractParameter |
createParameter, delivers, exit, getFormatted, getFormatted, getName, getPreserveFile, getString, getString, register, setName, toString |
| 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 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 |
KEY_SERIAL
public static final String KEY_SERIAL
- The name of the serial server to use.
- See Also:
- Constant Field Values
KEY_SWITCHON
public static final String KEY_SWITCHON
- The serial command for light on.
- See Also:
- Constant Field Values
KEY_SWITCHOFF
public static final String KEY_SWITCHOFF
- The serial command for light off.
- See Also:
- Constant Field Values
KEY_INITOFF
public static final String KEY_INITOFF
- The key defining initial off.
- See Also:
- Constant Field Values
DEFINITOFF
private static final boolean DEFINITOFF
- The initial state of the switch.
- See Also:
- Constant Field Values
serial
private RS485Server serial
- The serial server to send commands to.
RS485Switch
public RS485Switch(Map prop)
- Constructs a new light switch trigger. As a monitor for notification
of cache-cahnged events, this trigger registers itself in the init
section.
All additional properties have default values.
init
public void init()
- Initializes the light switch.
- Specified by:
init in interface Initializable- Overrides:
init in class SimpleTrigger
rescanned
public double rescanned(String key,
String old,
String newval)
- As any parameter depending instance we fail if the parameter we depend
on is now a different one.
- Specified by:
rescanned in interface Reloadable- Overrides:
rescanned in class SimpleTrigger
registerDriver
public boolean registerDriver(Driver rs485)
- Registers the driver. First, it is checked for instancy of
PollingRS485Server. If so, it's name is check to match the
KEY_SERIAL name. If this, too, is fulfilled, the server is
passed to the super-method, which does the necessary cache change
registration. Additionally an instance of this server is stored locally
to allow sending of commands to the serial server.
- Specified by:
registerDriver in interface DriverDepending
- Returns:
- True if registering at the driver was successful.
on
protected boolean on()
- Turns the switch on. Send the light-on command to the serial.
- Specified by:
on in class AbstractSwitch
- Returns:
- True if successful.
off
protected boolean off()
- Turn the light off. Sends the light-off command to the serial port.
- Specified by:
off in class AbstractSwitch
- Returns:
- True if successful.