public abstract class CumulativeSensor extends DataSensor implements Cumulating
Shelf to store a predefined number of measurements. Further
subclasses may use this history to either conduct smoothing, predicting, or
judging tasks.This sensor adds the following properties if they are not set already:
ShelfTimerTaskSensor.SensorReadPropertyResources.Load, PropertyResources.URLResource| Modifier and Type | Field and Description |
|---|---|
private static boolean |
DEFAVERAGE
Act on average per default.
|
private static int |
DEFMEMORY
The default number of readings to keep, if property is not given.
|
private static int |
DEFPACK
The default number of readings to pack, if property is not given.
|
static String |
KEY_AVERAGE
The name of the key that points to true on average, median if false.
|
static String |
KEY_MEMORY
The key in the Map list referring to the number of measurements
to keep.
|
static String |
KEY_PACK
The name of the key for the pack rate in this sensors properties.
|
private Shelf<Double> |
raw
Stores the raw readings of this sensor.
|
private Shelf<Date> |
time
Stores the times of the readings.
|
DEFRAWFORMAT, 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 |
CumulativeSensor(Map<String,String> qualify)
Constructs a fully-qualified cumulative sensor, with a given size
of measurements to keep.
Use of this constructor guarantees that the Map key memory is always set. |
| Modifier and Type | Method and Description |
|---|---|
void |
cumulateOne(double r,
Date when)
The interface method for storing one raw data point and its time
of measure.
|
protected DataEvent |
generateDataEvent()
Takes the last sensor reading and produces a
CumulativeDataEvent out of it. |
List<Double> |
getLastRaw(int nr)
The interface method for retrieving the last nr raw measures.
|
List<Date> |
getLastTime(int nr)
The interface method for retrieving the last nr
measurement times.
|
int |
getMaxSize()
Returns the maximum number of datas in the data buffer.
|
int |
getMemory()
Returns the memory property as an Integer.
|
int |
getSize()
Returns the number of datas in the data buffer.
|
protected void |
newData(double raw,
Date time)
Called as new data is available.
|
addDataListener, addRmiDataListener, conductOneMeasure, exit, getRawFormat, getSigmaFormat, removeDataListener, removeRmiDataListener, reportcancel, equals, getRawToggleInfo, getReading, getRespawn, getTimeOfRead, hashCode, initSensorTimerTask, isReady, readSensor, regetRaw, setTimeOfRead, validReadingaddRmiErrorListener, createSensor, getBindName, getConvert, getSensorDescription, getSensorInitInfo, getSensorName, init, notifyErrorListener, removeRmiErrorListener, setConvert, status, 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, waitgetTimeOfRead, 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_MEMORY
public static final String KEY_PACK
public static final String KEY_AVERAGE
private static final int DEFMEMORY
private static final int DEFPACK
private static final boolean DEFAVERAGE
protected CumulativeSensor(Map<String,String> qualify)
group - The ThreadGroup this thread belongs to.name - The name of this thread (sensor).qualify - The Map object describing this sensor.protected void newData(double raw,
Date time)
cumulateOne(double, java.util.Date) method.newData in class TimerTaskSensorpublic void cumulateOne(double r,
Date when)
newData(double, java.util.Date).cumulateOne in interface Cumulatingraw - The raw measured value.Cumulatingpublic List<Double> getLastRaw(int nr)
getLastRaw in interface CumulatingCumulatingpublic List<Date> getLastTime(int nr)
getLastTime in interface CumulatingCumulatingpublic int getSize()
getSize in interface CumulatingCumulatingpublic int getMaxSize()
getMaxSize in interface CumulatingCumulatingpublic int getMemory()
protected DataEvent generateDataEvent()
CumulativeDataEvent out of it. If the KEY_PACK property
points to a value greater than one, the data event produced is the
average of the last measurments. If the DataSensor.KEY_REPORT and the
KEY_PACK keys both point to the same integer, all data
produced is somehow used. However, if KEY_PACK is bigger than
DataSensor.KEY_REPORT, some data point are used twice, so care should be
taken in handling those keys.generateDataEvent in class DataSensorCumulativeDataEvent