stella.sensor
Class HumiditySwitch

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.parameter.AbstractSwitch
                              extended by stella.parameter.RS485Switch
                                  extended by stella.sensor.HumiditySwitch
All Implemented Interfaces:
DriverDepending, Cloneable, Remote, EventListener, DataListener, Parameter, ParameterDepending, Switch, Trigger, WeatherDependingParameter, ExitCleaning, Initializable, LocalizedSupplying, PropertySupplying, Reloadable, ResourceSupplying, RmiStatusProviding, StatusProviding

public class HumiditySwitch
extends RS485Switch
implements ParameterDepending, WeatherDependingParameter, DataListener, StatusProviding, RmiStatusProviding

A switch that listens to a sensor and, based on the reading, switches an RS485-relay on and off. This switch implements dehumidification of the STELLA bay. The humidity switch has the following properties:

Per default, the dehumidifier is switched with a NuDam module on 34. Its trigger state is true, if the dehumidifier is working.


Nested Class Summary
 
Nested classes/interfaces inherited from class util.PropertyResources
PropertyResources.URLResource
 
Field Summary
private  DataCaster bayhumidity
          The data caster that delivers the humidity measurements.
private static boolean DEFBIND
          The default auto-binding as a RemoteParameter.
private static String DEFBINDNAME
          Default bind name.
private static String DEFHUMIDITY
          The default humidity sensor to watch.
private static String DEFJUDGE
          The class name of the default toggling instance.
private static String DEFJUDGEPARAMETERS
          The default toggling instance parameters.
static String DEFNAME
          The default parameter name.
private static long DEFRETARDOFF
          The default time-out after which turn-off is again allowed.
private static long DEFRETARDON
          The default time-out after which turn-on is again allowed.
private static String DEFSERIAL
          The default serial driver name.
private static String DEFSWITCHOFF
          The default serial command to switch on the light.
private static String DEFSWITCHON
          The default serial command to switch on the light.
private static long DEFTIMEOUT
          The default time out after which dehumidifier is turned off again.
static String KEY_BIND
          The default binding behaviour.
static String KEY_HUMIDITY
          The name of the humidity switch.
static String KEY_JUDGE
          The class-name of the Toggling instance.
static String KEY_JUDGEPARAMETERS
          The parameters to the Toggling instance.
static String KEY_RETARDOFF
          The retard time for switching on again.
static String KEY_RETARDON
          The retard time for switching on again.
static String KEY_TIMEOUT
          The default time out for light switch off.
private  long lastoff
          The last time we successfully switched the dehumidifier off.
private  long laston
          The last time we successfully switched the dehumidifier on.
private  double lastraw
          The last valid raw humidity received.
private  Trigger shut
          The status of the roof.
private  Toggling toggle
          The Toggling instance to judge for dehumidification-on.
 
Fields inherited from class stella.parameter.RS485Switch
KEY_INITOFF, KEY_SERIAL, KEY_SWITCHOFF, KEY_SWITCHON
 
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
HumiditySwitch(Map prop)
          Constructs a new living reference of a cabinet switch.
 
Method Summary
 boolean bindToRegistry()
          Binds to registry.
 void dataAvailable(DataEvent de)
          Registers a new data event.
 void exit()
          We deregister from the humidity sensor prior to exiting.
 Object getForWeather(WeatherSurveying weather)
          Defined by the weather-depending interface, but not used here.
 void init()
          Initializes the Toggling instance.
 Object provideStatus()
          As a stust, we provide also info on current weather etc.
 void registerParameter(Parameter roof)
          Registers the roof.
 void registerWeather(WeatherSurveying sensors)
          Registers a weather surveyor permanently to this parameter.
 Object rmiProvideStatus()
          As a stust, we provide also info on current weather etc.
 boolean turnOff()
          Additionally to turning the switch off, we must record the time for proper retarding.
 boolean turnOn(long timeout)
          Additionally to turning the switch on, we must record the time for proper retarding.
 boolean unbindFromRegistry()
          Unbinds from registry.
 
Methods inherited from class stella.parameter.RS485Switch
off, on, registerDriver, rescanned
 
Methods inherited from class stella.parameter.SimpleTrigger
getLastToggleTime, getTrigger, setTrigger
 
Methods inherited from class stella.parameter.AbstractTrigger
get, getElapsedToggleTime, isTrue, set, toggleTrigger
 
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 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.Reloadable
reload
 
Methods inherited from interface stella.Trigger
getElapsedToggleTime, getLastToggleTime, getTrigger, isTrue, setTrigger, toggleTrigger
 
Methods inherited from interface util.ResourceSupplying
getResource, getResourceAsStream, getResources
 

Field Detail

KEY_HUMIDITY

public static final String KEY_HUMIDITY
The name of the humidity switch.

See Also:
Constant Field Values

KEY_JUDGE

public static final String KEY_JUDGE
The class-name of the Toggling instance.

See Also:
Constant Field Values

KEY_JUDGEPARAMETERS

public static final String KEY_JUDGEPARAMETERS
The parameters to the Toggling instance.

See Also:
Constant Field Values

KEY_RETARDON

public static final String KEY_RETARDON
The retard time for switching on again.

See Also:
Constant Field Values

KEY_RETARDOFF

public static final String KEY_RETARDOFF
The retard time for switching on again.

See Also:
Constant Field Values

KEY_TIMEOUT

public static final String KEY_TIMEOUT
The default time out for light switch off.

See Also:
Constant Field Values

KEY_BIND

public static final String KEY_BIND
The default binding behaviour.

See Also:
Constant Field Values

DEFNAME

public static final String DEFNAME
The default parameter name.

See Also:
Constant Field Values

DEFSERIAL

private static final String DEFSERIAL
The default serial driver name.

See Also:
Constant Field Values

DEFSWITCHON

private static final String DEFSWITCHON
The default serial command to switch on the light.

See Also:
Constant Field Values

DEFSWITCHOFF

private static final String DEFSWITCHOFF
The default serial command to switch on the light.

See Also:
Constant Field Values

DEFHUMIDITY

private static final String DEFHUMIDITY
The default humidity sensor to watch.

See Also:
Constant Field Values

DEFJUDGE

private static final String DEFJUDGE
The class name of the default toggling instance.

See Also:
Constant Field Values

DEFJUDGEPARAMETERS

private static final String DEFJUDGEPARAMETERS
The default toggling instance parameters.

See Also:
Constant Field Values

DEFRETARDON

private static final long DEFRETARDON
The default time-out after which turn-on is again allowed.

See Also:
Constant Field Values

DEFRETARDOFF

private static final long DEFRETARDOFF
The default time-out after which turn-off is again allowed.

See Also:
Constant Field Values

DEFTIMEOUT

private static final long DEFTIMEOUT
The default time out after which dehumidifier is turned off again.

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 bind name.

See Also:
Constant Field Values

toggle

private Toggling toggle
The Toggling instance to judge for dehumidification-on.


shut

private Trigger shut
The status of the roof.


bayhumidity

private DataCaster bayhumidity
The data caster that delivers the humidity measurements.


lastraw

private double lastraw
The last valid raw humidity received.


laston

private long laston
The last time we successfully switched the dehumidifier on.


lastoff

private long lastoff
The last time we successfully switched the dehumidifier off.

Constructor Detail

HumiditySwitch

public HumiditySwitch(Map prop)
               throws RemoteException
Constructs a new living reference of a cabinet switch.

Throws:
RemoteException
Method Detail

init

public void init()
Initializes the Toggling instance.

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

registerParameter

public void registerParameter(Parameter roof)
Registers the roof. The roof is queried for the current roof-stae if we have a switch-signal to turn the dehumidifier on. Only if the roof is closed, the dehumidifier is turned on. Note that direct switches of the dehumidifier via the remote methods are not affected by the current roof status.

Specified by:
registerParameter in interface ParameterDepending

getForWeather

public Object getForWeather(WeatherSurveying weather)
Defined by the weather-depending interface, but not used here. Returns null.

Specified by:
getForWeather in interface WeatherDependingParameter

registerWeather

public void registerWeather(WeatherSurveying sensors)
Registers a weather surveyor permanently to this parameter. The Weather surveying instance is queried for the sensor with the name KEY_HUMIDITY

Specified by:
registerWeather in interface WeatherDependingParameter

dataAvailable

public void dataAvailable(DataEvent de)
Registers a new data event. If the toggling instance defines a change event, the dehumidifier is turned on if the roof is closed.

Specified by:
dataAvailable in interface DataListener

bindToRegistry

public boolean bindToRegistry()
                       throws RemoteException
Binds to registry.

Throws:
RemoteException

unbindFromRegistry

public boolean unbindFromRegistry()
                           throws RemoteException
Unbinds from registry.

Throws:
RemoteException

turnOn

public boolean turnOn(long timeout)
Additionally to turning the switch on, we must record the time for proper retarding.

Specified by:
turnOn in interface Switch
Overrides:
turnOn in class AbstractSwitch
Parameters:
timeout - The maximum time the switch should be on (ms), zero for unlimited.
Returns:
True, if switch was successfully turned on.

turnOff

public boolean turnOff()
Additionally to turning the switch off, we must record the time for proper retarding.

Specified by:
turnOff in interface Switch
Overrides:
turnOff in class AbstractSwitch
Returns:
True, if switch was successfully turned off.

exit

public void exit()
We deregister from the humidity sensor prior to exiting.

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

provideStatus

public Object provideStatus()
As a stust, we provide also info on current weather etc.

Specified by:
provideStatus in interface StatusProviding

rmiProvideStatus

public Object rmiProvideStatus()
                        throws RemoteException
As a stust, we provide also info on current weather etc.

Specified by:
rmiProvideStatus in interface RmiStatusProviding
Throws:
RemoteException