public class RS485RainSensor extends AbstractSensor implements DataCaster, RmiDataCaster, WeatherCaster, WeatherJudging, CacheChangedListener, DriverDepending
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. On 2014, 21th Oct, 13:10 UTC, the digital measurements had been replaced by analog ones, 0.0175 corresponding roughly to digital 1.
| Modifier and Type | Class and Description |
|---|---|
static class |
RS485RainSensor.DigitalRainConversion |
private class |
RS485RainSensor.RainTimerTask
The timer task used for notification of good weather.
|
PropertyResources.Load, PropertyResources.URLResource| Modifier and Type | Field and Description |
|---|---|
private Timer |
data
The timer bound to data-event generating and weather reports.
|
private List<DataListener> |
datalist
The registered data-listeners.
|
private static int |
DEFCHANNEL
The default read channel.
|
private static long |
DEFDATARATE
The default read channel.
|
private static long |
DEFDELAY
The default retard time for changes to good weather.
|
private static DecimalFormat |
DEFFORMAT
The format string for value and raw reading.
|
private static boolean |
DEFINVERSE
The default inverse property.
|
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 Triggering |
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_DELAY
The key pointing to a retard time for weather changes good->bad.
|
static String |
KEY_FORMAT
The key to the value formatter.
|
static String |
KEY_INVERSE
The key defining if good weather inverses the toggle value.
|
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 List<RmiDataListener> |
rdatalist
The registered data-listeners.
|
private RS485RainSensor.RainTimerTask |
retard
The timer task for good-weather retards.
|
private PollingRS485Server |
serial
The poller this rain sensor listens to.
|
private List<WeatherListener> |
weatherlist
The registered weather-listeners.
|
KEY_BIND, KEY_BINDNAME, KEY_CONVERT, KEY_DESCRIPTION, KEY_SENSORNAMEALTERNATEHOST, ALTERNATEPORT, KEY_EXPORTPORT, KEY_REGISTRYHOST, KEY_REGISTRYPORTKEY_NOINITONCREATE, POSTFIX_ALPHABET, POSTFIX_BYTES, POSTFIX_DIR, POSTFIX_EXT, POSTFIX_FILE, POSTFIX_LIST, POSTFIX_MODTIME, POSTFIX_URLKEY_LISTSEPARATOR, KEY_MAPKEYVALUECHAR, KEY_MAPSEPARATORNAMING_EXTENSIONCONFIG, KEY_CLASSKEY_URLRESOURCES, KEY_URLUSECONFIG, KEY_URLUSECURRENT, KEY_URLUSEHOME| Constructor and Description |
|---|
RS485RainSensor(Map<String,String> prop)
Constructs a new RS485 sensor.
|
| Modifier and Type | Method and Description |
|---|---|
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.
|
addRmiErrorListener, createSensor, getBindName, getConvert, getRespawn, getSensorDescription, getSensorName, initSensorTimerTask, notifyErrorListener, removeRmiErrorListener, setConvert, toStringbindToRegistry, bindToRegistry, bindToRegistry, bindToRegistry, bindToRegistry, bindToRegistry, casterExit, casterExit, getBindName, isValid, unbindFromRegistry, unbindFromRegistrycontainsRemoteProperty, getRemoteProperties, getRemoteProperty, setRemotePropertyclone, 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, rescanned, setObject, setProperties, setProperty, stringPropertiesequals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitbindToRegistry, isValid, unbindFromRegistrydefaultBoolean, 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_INVERSE
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_DELAY
public static final String KEY_UNIT
public static final String KEY_FORMAT
private static final boolean DEFINVERSE
private static final long DEFDATARATE
private static final int DEFCHANNEL
private static final long DEFRETARD
private static final long DEFDELAY
private static final String DEFUNIT
private static final DecimalFormat DEFFORMAT
private String lastread
private Date lastchange
private Triggering goodweather
private final Timer data
private RS485RainSensor.RainTimerTask retard
private final NumberFormat format
private transient PollingRS485Server serial
private final List<DataListener> datalist
private final List<RmiDataListener> rdatalist
private final List<WeatherListener> weatherlist
public RS485RainSensor(Map<String,String> 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.RemoteExceptionpublic void init()
throws InitException
init in interface Initializableinit in class AbstractSensorInitExceptionpublic 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.RemoteExceptionpublic 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.