public abstract class WeatherSensor extends DerivativeSensor implements WeatherJudging, WeatherCaster
WeatherListener are registered to this sensor, they recive
a WeatherEvent whenever the weather situation on this sensor
changes. Note that a combination of individual weather sensors to a
weather station should handle this events via registering itself to all
its comprising weather sensors as a weather event listener, and passing a
combined event to its registered listeners.
True weather sensors, like a rain sensor, should subclass this method and provide bodies for this methods:
Telemetering): This method reads and
returns the raw sensor value (of the primitive double type).WeatherJudging): Returns true, if this sensor reports good weather
from its raw reading.WeatherJudging): Returns true, if this sensor reports good weather
from its smoothened raw reading.WeatherJudging): Returns true, if this sensor reports good weather
from its first derivative of its raw sensor readings.ConvertToPhysical or
PhysicalDerivative, add the methods that convert raw values to the
appropriate physical quantities (like raw volts to degrees Centigrade).WeatherJudging which return
false for all values, indicating good weather. This is useful, if
your non-abstract subclass can judge the weather only by, say, considering
smoothened values. In such a case, you only have to override the
badFromSmooth method, while the default implementations will never
spoil the overall judging from this sensor.
Note also that this class produces DataEvents with a principal
measurement reflecting the current weather conditions.
TimerTaskSensor.SensorReadPropertyResources.Load, PropertyResources.URLResource| Modifier and Type | Field and Description |
|---|---|
private static boolean |
DEFDERIVATIVEINVALID
The default raw-vote if raw reading is invalid.
|
private static boolean |
DEFINVERSE
The default inverse property.
|
private static boolean |
DEFINVERSEDERIVATIVE
The default inverse-derivative property.
|
private static boolean |
DEFPREDICTINVALID
The default raw-vote if raw reading is invalid.
|
private static boolean |
DEFRAWINVALID
The default raw-vote if raw reading is invalid.
|
private static long |
DEFRETARD
The default retard time for all cases in ms.
|
private static boolean |
DEFSMOOTHINVALID
The default raw-vote if raw reading is invalid.
|
private boolean |
derivativeretard
An indicator weather is on retard because of a derivative toggle.
|
private Toggling |
derivativetoggle
The
Toggling instance for derivative-value judgement. |
private long |
derivtime
The actual retard time intervall for derivative retards.
|
private boolean |
invert
True if toggling value is inverse of weather value.
|
private boolean |
invertderivative
True if toggling value is inverse for derivative judgement.
|
static String |
KEY_DERIVATIVEINVALID
The key pointing to the deriv.-vote in case of non-valid readings.
|
static String |
KEY_DERIVATIVEPARAMETER
The key pointing to the parameters of the derivative judgement.
|
static String |
KEY_INVERSE
The key defining if good weather inverses the toggle value.
|
static String |
KEY_INVERSEDERIVATIVE
Defines if good weather inverses the toggle value from the deriv..
|
static String |
KEY_JUDGEDERIVATIVE
The key pointing to the instance for the derivative-value judgement.
|
static String |
KEY_JUDGEPREDICT
The key pointing to the instance for the predicted-value judgement.
|
static String |
KEY_JUDGERAW
The key pointing to the judging-instance for the raw-value judgement.
|
static String |
KEY_JUDGESMOOTH
The key pointing to the instance for the smooth-value judgement.
|
static String |
KEY_PREDICTINVALID
The predictive-vote in case of non-valid readings.
|
static String |
KEY_PREDICTPARAMETER
The key pointing to the parameters of the predicted-value judgement.
|
static String |
KEY_RAWINVALID
The key pointing to the raw-vote in case of non-valid readings.
|
static String |
KEY_RAWPARAMETER
The key pointing to the parameters of the raw-value judgement.
|
static String |
KEY_RETARDBADDERIVATIVE
The key pointing to a retard time for weather changes good->bad.
|
static String |
KEY_RETARDBADPREDICT
The key pointing to a retard time for weather changes good->bad.
|
static String |
KEY_RETARDBADRAW
The key pointing to a retard time for weather changes good->bad.
|
static String |
KEY_RETARDBADSMOOTH
The key pointing to a retard time for weather changes good->bad.
|
static String |
KEY_RETARDGOODDERIVATIVE
The key pointing to a retard time for weather changes bad->good.
|
static String |
KEY_RETARDGOODPREDICT
The key pointing to a retard time for weather changes bad->good.
|
static String |
KEY_RETARDGOODRAW
The key pointing to a retard time for weather changes bad->good.
|
static String |
KEY_RETARDGOODSMOOTH
The key pointing to a retard time for weather changes bad->good.
|
static String |
KEY_SMOOTHINVALID
The key pointing to the smooth-vote in case of non-valid readings.
|
static String |
KEY_SMOOTHPARAMETER
The key pointing to the parameters of the smooth-value judgement.
|
private Triggering |
lastDerivative
A trigger holding this sensors last derivative judge.
|
private Triggering |
lastPredict
A trigger holding this sensors last predictive judge.
|
private Triggering |
lastRaw
A trigger holding this sensors last raw judge.
|
private Triggering |
lastSmooth
A trigger holding this sensors last smooth judge.
|
private boolean |
predictretard
An indicator weather is on retard because of a prediction toggle.
|
private long |
predicttime
The actual retard time intervall for prediction retards.
|
private Toggling |
predicttoggle
The
Toggling instance for predicted-value judgement. |
private boolean |
rawretard
An indicator weather is on retard because of a raw toggle.
|
private long |
rawtime
The actual retard time intervall for raw retards.
|
private Toggling |
rawtoggle
The
Toggling instance for raw-value judgement. |
private boolean |
smoothretard
An indicator weather is on retard because of a smooth toggle.
|
private long |
smoothtime
The actual retard time intervall for smooth retards.
|
private Toggling |
smoothtoggle
The
Toggling instance for smooth-value judgement. |
private Vector<WeatherListener> |
weatherlist
The list of WeatherListeners.
|
DEFRAWDERIVATIVE, derive, KEY_DERIVATIVEADVISE, KEY_DERIVE, KEY_PATH, KEY_RAWDERIVATIVE, zf, g, KEY_SMOOTH, KEY_SMOOTHADVISEKEY_CHI, KEY_EXTRAPOLATE, KEY_FUTURE, KEY_PREDICTADVISE, predictKEY_AVERAGE, KEY_MEMORY, KEY_PACKDEFRAWFORMAT, DEFREPORT, DEFSIGMAFORMAT, KEY_RAWFORMAT, KEY_REPORT, KEY_SIGMAFORMATKEY_LOGRAWABOVE, KEY_LOGRAWBELOW, KEY_LOGREADLAG, KEY_RESPAWNKEY_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| Modifier | Constructor and Description |
|---|---|
protected |
WeatherSensor(Map<String,String> qualify)
Constructs a fully-qualified weather sensor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addWeatherListener(WeatherListener ear)
Adds a
WeatherListener to the registered listeners. |
protected void |
conductOneMeasure()
Adds the judging capabilities to the readout of this sensor.
|
boolean |
currentlyClear()
Returns true if the weather is currently good.
|
boolean |
currentlyRetarding()
Are we in a retarding phase?
|
private boolean |
derivativeChange()
True if a weather event generation should be possible considering the
derivative sensor.
|
protected DataEvent |
generateDataEvent()
Converts the conventional data event into a
DataEvent,
where the
principal measurement reflects the current weather situation. |
long |
getMinClearUpTime()
If clear, we return zero.
|
String |
getSensorInitInfo()
Returns a string description of this sensor.
|
protected boolean |
goodFromDerivative(double derive)
A default implementation of the method in
WeatherJudging. |
protected boolean |
goodFromPredict(double predict)
A default implementation of the method in
WeatherJudging. |
protected boolean |
goodFromRaw(double raw)
A default implementation of the method in
WeatherJudging. |
protected boolean |
goodFromSmooth(double smooth)
A default implementation of the method in
WeatherJudging. |
boolean |
isDerivativeRetard()
Returns true if this weather sensor is derivative retarding.
|
boolean |
isPredictRetard()
Returns true if this weather sensor is predict retarding.
|
boolean |
isRawRetard()
Returns true if this weather sensor is raw retarding.
|
boolean |
isSmoothRetard()
Returns true if this weather sensor is smooth retarding.
|
protected void |
judgeWeather()
This method generates the actual judging of the weather situation.
|
protected void |
notifyWeatherListener(WeatherEvent we)
Parses through the list of registered weather listeners and passes
the argumental weather event to all of them.
|
private boolean |
predictChange()
True if a weather event generation should be possible considering the
predictive sensor.
|
private boolean |
rawChange()
True if a weather event generation should be possible considering the
raw sensor.
|
void |
removeWeatherListener(WeatherListener ear)
Removes a
WeatherListener from the registered listeners. |
private boolean |
smoothChange()
True if a weather event generation should be possible considering the
smooth sensor.
|
String |
status()
Adds the current vote to the status message.
|
deriveAt, getDerivativeFormat, getDerivativeToggleInfo, getDerivator, getLastDerivative, isDerivativeAdvise, isDeriving, newData, regetDerive, registerDerivatorgetLastSmooth, getSmoother, getSmoothToggleInfo, isSmoothAdvise, isSmoothing, regetSmooth, registerSmoother, smoothOnegetExtrapolation, getLastPredict, getPredictToggleInfo, init, isPredictAdvise, isPredicting, isReliable, predictFrom, regetPredictcumulateOne, getLastRaw, getLastTime, getMaxSize, getMemory, getSizeaddDataListener, addRmiDataListener, exit, getRawFormat, getSigmaFormat, removeDataListener, removeRmiDataListener, reportcancel, equals, getRawToggleInfo, getReading, getRespawn, getTimeOfRead, hashCode, initSensorTimerTask, isReady, readSensor, regetRaw, setTimeOfRead, validReadingaddRmiErrorListener, createSensor, getBindName, getConvert, getSensorDescription, getSensorName, 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, stringPropertiesfinalize, getClass, notify, notifyAll, wait, wait, waitcumulateOne, getLastRaw, getLastTime, getMaxSize, getSize, getTimeOfRead, regetRawbindToRegistry, isValid, unbindFromRegistryvalidReadingdefaultBoolean, 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_JUDGERAW
public static final String KEY_RAWPARAMETER
public static final String KEY_RETARDBADRAW
public static final String KEY_RETARDGOODRAW
public static final String KEY_JUDGESMOOTH
public static final String KEY_SMOOTHPARAMETER
public static final String KEY_RETARDBADSMOOTH
public static final String KEY_RETARDGOODSMOOTH
public static final String KEY_JUDGEDERIVATIVE
public static final String KEY_DERIVATIVEPARAMETER
public static final String KEY_RETARDBADDERIVATIVE
public static final String KEY_RETARDGOODDERIVATIVE
public static final String KEY_JUDGEPREDICT
public static final String KEY_PREDICTPARAMETER
public static final String KEY_RETARDBADPREDICT
public static final String KEY_RETARDGOODPREDICT
public static final String KEY_INVERSE
public static final String KEY_INVERSEDERIVATIVE
public static final String KEY_RAWINVALID
public static final String KEY_SMOOTHINVALID
public static final String KEY_DERIVATIVEINVALID
public static final String KEY_PREDICTINVALID
private static final long DEFRETARD
private static final boolean DEFINVERSE
private static final boolean DEFINVERSEDERIVATIVE
private static final boolean DEFRAWINVALID
private static final boolean DEFSMOOTHINVALID
private static final boolean DEFDERIVATIVEINVALID
private static final boolean DEFPREDICTINVALID
private Triggering lastRaw
private Triggering lastSmooth
private Triggering lastDerivative
private Triggering lastPredict
private boolean rawretard
private long rawtime
private boolean smoothretard
private long smoothtime
private boolean derivativeretard
private long derivtime
private boolean predictretard
private long predicttime
private Toggling derivativetoggle
Toggling instance for derivative-value judgement.private final boolean invert
private final boolean invertderivative
private final Vector<WeatherListener> weatherlist
protected WeatherSensor(Map<String,String> qualify)
qualify - The Map object describing this sensor.protected void conductOneMeasure()
WeatherStations combine more than one sensor and should be used
for combining weather events from different sources.
conductOneMeasure in class DataSensorpublic String getSensorInitInfo()
getSensorInitInfo in interface TelemeteringgetSensorInitInfo in class AbstractSensorprotected void judgeWeather()
A weather event is generated, if one of these conditions is met.
WeatherEvent.RAWTHRESHOLD is
generated.WeatherEvent.SMOOTHTHRESHOLD is
generated.WeatherEvent.DERIVATIVETHRESHOLD
is generated.WeatherEvent.PREDICTIVETHRESHOLD is
generated.private boolean rawChange()
private boolean smoothChange()
private boolean derivativeChange()
private boolean predictChange()
protected void notifyWeatherListener(WeatherEvent we)
public boolean currentlyClear()
goodFromRaw(double), goodFromSmooth(double), and
goodFromDerivative(double) with the last measurements to derive an
overall vote.
Note that this method is intended to be used only at startup.
currentlyClear in interface WeatherJudgingpublic boolean currentlyRetarding()
currentlyRetarding in interface WeatherJudgingpublic long getMinClearUpTime()
getMinClearUpTime in interface WeatherJudgingprotected boolean goodFromRaw(double raw)
WeatherJudging.
Subclasses should override this method.protected boolean goodFromSmooth(double smooth)
WeatherJudging.
Subclasses should override this method.protected boolean goodFromDerivative(double derive)
WeatherJudging.
Subclasses should override this method.protected boolean goodFromPredict(double predict)
WeatherJudging.
Subclasses should override this method.
Prediciting is more difficult than smoothing or raw-reading. Therefore,
this method not only adds the last predicted value to the
Toggling instance, but also checks if the prediction is reliable.
If not, true is returned.
public boolean isRawRetard()
public boolean isSmoothRetard()
public boolean isDerivativeRetard()
public boolean isPredictRetard()
protected DataEvent generateDataEvent()
DataEvent,
where the
principal measurement reflects the current weather situation.
Calls the superclass method and produces a new weather data event out
of it, with the additional information whether the measured values are
within the allowed thresholds. Note that this routine does
use the current weather situation, not the average of the data event,
to judge the weather situation.generateDataEvent in class DerivativeSensorpublic 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 String status()
status in interface Telemeteringstatus in class AbstractSensor