public class BadSensor extends WeatherSensor implements ParameterDepending
KEY_GOODPERIOD: The average good-weather period in ms.KEY_BADPERIOD: The average bad-weather period in ms.KEY_BADFRACTION: The long-aim fraction of bad to good weather
periods.KEY_GAUSSSIGMA gauss sigma. After
the initial bad weather, we calculate the fraction of the accumulated bad
to good weather phases. This fraction is compared to the target bad fraction
and a normal random pick determines whether the weather changes or not.
Any weather change will produce only sensor readings
(KEY_GOODREADING or KEY_BADREADING) until the next change
commences. To allow this sensor to work seamless
Default mappings are for a typical humidity sensor at a bad level of 0.2, and a good period of 4 days, a bad period of one day, if started with the default respawn rate of 1 second.
| Modifier and Type | Class and Description |
|---|---|
static class |
BadSensor.Randomize
Class for testing.
|
TimerTaskSensor.SensorReadPropertyResources.Load, PropertyResources.URLResource| Modifier and Type | Field and Description |
|---|---|
private long |
badcount
Cumulated bad period.
|
private static double |
DEFBADFRACTION
The default bad weather period.
|
private static long |
DEFBADPERIOD
The default bad weather period.
|
private static double |
DEFBADREADING
The default good reading.
|
private static double |
DEFGAUSSSIGMA
The default sigma.
|
private static long |
DEFGOODPERIOD
The default good weather period.
|
private static double |
DEFGOODREADING
The default good reading.
|
private static long |
DEFMAXPERIOD
The default maximum period.
|
private static long |
DEFMINPERIOD
The default minimum period.
|
private static String |
DEFTIME
The default time parameter.
|
private long |
goodcount
Cumulated good period.
|
static String |
KEY_BADFRACTION
The key to standard bad weather fraction.
|
static String |
KEY_BADPERIOD
The key to standard bad weather period.
|
static String |
KEY_BADREADING
The key to standard bad reading.
|
static String |
KEY_GAUSSSIGMA
The key to the standard deviation of the weather periods.
|
static String |
KEY_GOODPERIOD
The key to standard good weather period.
|
static String |
KEY_GOODREADING
The key to standard good reading.
|
static String |
KEY_MAXPERIOD
The key to maximum weather period.
|
static String |
KEY_MINPERIOD
The key to minimum weather period.
|
static String |
KEY_TIME
The key giving the name of the time parameter.
|
private long |
period
Current active period.
|
private static Random |
random
My random number generator.
|
private CurrentTime |
time
A special time grabbed from the parameter cluster.
|
private long |
toggled
Last time of weather change.
|
private boolean |
weather
Current active weather.
|
KEY_DERIVATIVEINVALID, KEY_DERIVATIVEPARAMETER, KEY_INVERSE, KEY_INVERSEDERIVATIVE, KEY_JUDGEDERIVATIVE, KEY_JUDGEPREDICT, KEY_JUDGERAW, KEY_JUDGESMOOTH, KEY_PREDICTINVALID, KEY_PREDICTPARAMETER, KEY_RAWINVALID, KEY_RAWPARAMETER, KEY_RETARDBADDERIVATIVE, KEY_RETARDBADPREDICT, KEY_RETARDBADRAW, KEY_RETARDBADSMOOTH, KEY_RETARDGOODDERIVATIVE, KEY_RETARDGOODPREDICT, KEY_RETARDGOODRAW, KEY_RETARDGOODSMOOTH, KEY_SMOOTHINVALID, KEY_SMOOTHPARAMETERDEFRAWDERIVATIVE, 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| Constructor and Description |
|---|
BadSensor(Map prop)
Constructs a new fake sensor.
|
| Modifier and Type | Method and Description |
|---|---|
private long |
getWeatherPeriod(long stdperiod,
double sigma)
Returns a new weather period.
|
TimerTask |
initSensorTimerTask()
Starts the sensor.
|
protected double |
readSensor()
Returns the current weather depending reading.
|
void |
registerParameter(Parameter systime)
If we have a time, use it.
|
boolean |
validReading()
A bad sensor is always valid.
|
addWeatherListener, conductOneMeasure, currentlyClear, currentlyRetarding, generateDataEvent, getMinClearUpTime, getSensorInitInfo, goodFromDerivative, goodFromPredict, goodFromRaw, goodFromSmooth, isDerivativeRetard, isPredictRetard, isRawRetard, isSmoothRetard, judgeWeather, notifyWeatherListener, removeWeatherListener, statusderiveAt, 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, isReady, 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, 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_MINPERIOD
public static final String KEY_MAXPERIOD
public static final String KEY_GOODPERIOD
public static final String KEY_BADPERIOD
public static final String KEY_BADFRACTION
public static final String KEY_GAUSSSIGMA
public static final String KEY_GOODREADING
public static final String KEY_BADREADING
public static final String KEY_TIME
private static final long DEFMINPERIOD
private static final long DEFMAXPERIOD
private static final long DEFGOODPERIOD
private static final long DEFBADPERIOD
private static final double DEFBADFRACTION
private static final double DEFGAUSSSIGMA
private static final double DEFGOODREADING
private static final double DEFBADREADING
private static final String DEFTIME
private long goodcount
private long badcount
private long period
private boolean weather
private long toggled
private CurrentTime time
private static Random random
public BadSensor(Map prop) throws RemoteException
RemoteExceptionpublic TimerTask initSensorTimerTask()
initSensorTimerTask in interface TelemeteringinitSensorTimerTask in class TimerTaskSensorTelemetering.getRespawn()public void registerParameter(Parameter systime)
registerParameter in interface ParameterDependingpublic boolean validReading()
validReading in interface Telemeteringprotected double readSensor()
readSensor in class TimerTaskSensorConvertToPhysicalprivate long getWeatherPeriod(long stdperiod,
double sigma)