|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectutil.PropertyContainer
util.PropertyResources
util.PropertyBundles
util.rmi.RmiPropertyContainer
util.rmi.AbstractRmiCaster
stella.sensor.AbstractSensor
stella.sensor.RS485RainSensor
public class RS485RainSensor
A representation of a digital rain sensor. This sensor does not
deliver a value like 'number of raindrops' but provides a simple yes/no
decision.
This class does not extend the RS485Sensor class but is a
thread-less sensor. It acts as a cache listener and is therefore more
immediate in its response. Additionally, as immediate response is always
intended, no retardation time in case of bad-weather events (i.e. rain)
is implemented.
This sensor is based on a
NuDam 6050 module. The command issued for reading digital input
reads as $(Add)6, the returned string has the form
!(DataOut)(DataIn)00, where the data section correspond to the
two-hex character string representing the status of the appropriate I/O
bits. In particular, for the weather station only the data input is
used, the channel number provided in the properties points to the
channel of the digital input (numbering starts with zero, as always).
| Nested Class Summary | |
|---|---|
private class |
RS485RainSensor.RainTimerTask
The timer task used for notification of good weather. |
| Nested classes/interfaces inherited from class util.PropertyResources |
|---|
PropertyResources.URLResource |
| Field Summary | |
|---|---|
private Timer |
data
The timer bound to data-event generating and weather reports. |
private List |
datalist
The registered data-listeners. |
private static int |
DEFCHANNEL
The default read channel. |
private static long |
DEFDATARATE
The default read channel. |
private static DecimalFormat |
DEFFORMAT
The format string for value and raw reading. |
private static long |
DEFRETARD
The default retard time for changes to good weather. |
private static String |
DEFUNIT
The unit string of the rain sensor. |
private NumberFormat |
format
The raw and value formatter. |
private Trigger |
goodweather
The weather toggle. |
static String |
KEY_CHANNEL
The key for the channel number this sensor link to on the module. |
static String |
KEY_DATARATE
The key linked to the data-event generating rate. |
static String |
KEY_FORMAT
The key to the value formatter. |
static String |
KEY_READ
The key linked to the channel-read command of the Nudam module. |
static String |
KEY_RETARD
The key pointing to a retard time for weather changes bad->good. |
static String |
KEY_SERVER
The key linked to the polling instance to read from. |
static String |
KEY_UNIT
The key to the 'unit' of the digital reain sensor. |
private Date |
lastchange
The last cache-changed event received date. |
private String |
lastread
The last cache-changed event, value key. |
private RS485RainSensor.RainTimerTask |
retard
The timer task for good-weather retards. |
private PollingRS485Server |
serial
The poller this rain sensor listens to. |
private List |
weatherlist
The registered weather-listeners. |
| Fields inherited from class stella.sensor.AbstractSensor |
|---|
KEY_BIND, KEY_BINDNAME, KEY_CONVERT, KEY_DESCRIPTION, KEY_SENSORNAME |
| Fields inherited from class util.rmi.AbstractRmiCaster |
|---|
ALTERNATEHOST, ALTERNATEPORT, KEY_EXPORTPORT, KEY_REGISTRYHOST, KEY_REGISTRYPORT |
| 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.rmi.RmiDataCaster |
|---|
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 | |
|---|---|
RS485RainSensor(Map prop)
Constructs a new RS485 sensor. |
|
| Method Summary | |
|---|---|
void |
addDataListener(DataListener ear)
Adds a DataListener to the registered listeners. |
void |
addRmiDataListener(RmiDataListener ear)
Adds a DataListener to the registered listeners. |
void |
addWeatherListener(WeatherListener ear)
Adds a WeatherListener to the registered listeners. |
void |
cancel()
Cancels the rain sensor. |
boolean |
currentlyClear()
The main functionality of the rain sensor is to act as a weather sensor. |
boolean |
currentlyRetarding()
Returns true, if we were bad and still recovering. |
void |
exit()
Exists the rain sensor. |
long |
getMinClearUpTime()
Estimates bad time. |
double |
getReading()
Reads the sensor value. |
String |
getSensorInitInfo()
Returns a string description of the sensor. |
Date |
getTimeOfRead()
Returns the date of the last received cache-changed event. |
void |
init()
Initializes the sensor. |
void |
newValue(CacheChangedEvent cce)
Indicates a new cache-reading on the rain sensor. |
protected void |
notifyDataListener(DataEvent de)
Parses through the list of registered weather listeners and passes the argumental weather event to all of them. |
protected void |
notifyWeatherListener(WeatherEvent we)
Parses through the list of registered weather listeners and passes the argumental weather event to all of them. |
boolean |
registerDriver(Driver poller)
Registers the serial server to this sensor. |
void |
removeDataListener(DataListener ear)
Removes a DataListener from the registered listeners. |
void |
removeRmiDataListener(RmiDataListener ear)
Removes a DataListener from the registered listeners. |
void |
removeWeatherListener(WeatherListener ear)
Removes a WeatherListener from the registered listeners. |
private double |
retrieveValue(String read)
Converts the input string into a sensor value. |
String |
status()
The current status of the rain sensor. |
boolean |
validReading()
The rain sensor is valid if the polling server was able to read the last rain-sensor switch. |
| Methods inherited from class stella.sensor.AbstractSensor |
|---|
addRmiErrorListener, createSensor, getBindName, getConvert, getRespawn, getSensorDescription, getSensorName, initSensorTimerTask, notifyErrorListener, removeRmiErrorListener, setConvert, toString |
| Methods inherited from class util.rmi.AbstractRmiCaster |
|---|
bindAlternate, bindToRegistry, bindToRegistry, bindToRegistry, casterExit, casterExit, getBindName, isValid, unbindFromRegistry, unbindFromRegistry |
| Methods inherited from class util.rmi.RmiPropertyContainer |
|---|
containsRemoteProperty, getRemoteProperties, getRemoteProperty, setRemoteProperty |
| 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, rescanned, 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.rmi.RmiCaster |
|---|
bindToRegistry, isValid, unbindFromRegistry |
| 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 |
|---|
public static final String KEY_DATARATE
public static final String KEY_SERVER
public static final String KEY_READ
public static final String KEY_CHANNEL
public static final String KEY_RETARD
public static final String KEY_UNIT
public static final String KEY_FORMAT
private static final long DEFDATARATE
private static final int DEFCHANNEL
private static final long DEFRETARD
private static final String DEFUNIT
private static final DecimalFormat DEFFORMAT
private String lastread
private Date lastchange
private Trigger goodweather
private Timer data
private RS485RainSensor.RainTimerTask retard
private NumberFormat format
private transient PollingRS485Server serial
private List datalist
private List weatherlist
| Constructor Detail |
|---|
public RS485RainSensor(Map prop)
throws RemoteException
KEY_READ and the KEY_CHANNEL keys.
Construction fails if these keys are not present.
IllegalArgumentException - If the necessary properties are not
set.
NumberFormatException - If the channel number is not an int.
RemoteException| Method Detail |
|---|
public void init()
init in interface Initializableinit in class AbstractSensorpublic boolean registerDriver(Driver poller)
CacheChangedListener to the driver, if the
driver is a PollingRS485Server and has the correct name.
Note that this method returns false only if the driver handed over is
not of the appropriate type, i.e. a PollingRS485Server.
registerDriver in interface DriverDependingpublic void cancel()
cancel in interface Telemeteringpublic void exit()
exit in interface ExitCleaningexit in class AbstractSensorpublic double getReading()
PollingRS485Server.readChannel(java.lang.String), whose return value is then
fed, along with the channel number, to the retrieveValue(java.lang.String)
method of the sensor.
If no cache-event has been received, 1 for bad weather is returned.
getReading in interface Telemeteringpublic boolean validReading()
validReading in interface Telemeteringpublic Date getTimeOfRead()
getTimeOfRead in interface Telemeteringpublic boolean currentlyClear()
currentlyClear in interface WeatherJudgingpublic void newValue(CacheChangedEvent cce)
newValue in interface CacheChangedListenerpublic boolean currentlyRetarding()
currentlyRetarding in interface WeatherJudgingpublic long getMinClearUpTime()
getMinClearUpTime in interface WeatherJudgingpublic String getSensorInitInfo()
getSensorInitInfo in interface TelemeteringgetSensorInitInfo in class AbstractSensorpublic String status()
status in interface Telemeteringstatus in class AbstractSensorpublic void addWeatherListener(WeatherListener ear)
WeatherListener to the registered listeners. If the
argument is null, nothing is changed.
addWeatherListener in interface WeatherCasterear - The listener to add.public void removeWeatherListener(WeatherListener ear)
WeatherListener from the registered listeners. If the
argument is null, nothing is changed.
removeWeatherListener in interface WeatherCasterear - The listener to remove.public void addDataListener(DataListener ear)
DataListener to the registered listeners. If the
argument is null, nothing is changed.
addDataListener in interface DataCasterear - The listener to add.public void removeDataListener(DataListener ear)
DataListener from the registered listeners. If the
argument is null, nothing is changed.
removeDataListener in interface DataCasterear - The listener to remove.
public void addRmiDataListener(RmiDataListener ear)
throws RemoteException
DataListener to the registered listeners. If the
argument is null, nothing is changed.
addRmiDataListener in interface RmiDataCasterear - The listener to add.
RemoteException
public void removeRmiDataListener(RmiDataListener ear)
throws RemoteException
DataListener from the registered listeners. If the
argument is null, nothing is changed.
removeRmiDataListener in interface RmiDataCasterear - The listener to remove.
RemoteExceptionprotected void notifyDataListener(DataEvent de)
protected void notifyWeatherListener(WeatherEvent we)
private double retrieveValue(String read)
read - The string read in from the serial linenr - The channel number (0-6) of the digital input.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||