public abstract class SmoothingSensor extends PredictiveSensor implements Smoothing
registerSmoother(math.LinearSmoothing).
Linear smoothing algorithms require equally-stepped readings, which can
not be guaranteed with this low-priority daemon thread (ref.
TimerTaskSensor),
but the data spacing should occur regularely enough to
allow consistent use of a linear smoothing algorithm. If you in doubt,
refer to e.g. 'Numerical Recipes in C', p.654.
Note that the raw data is still accessible, this class adds an
additional Shelf, where it stores the smoothed data points.
Implementation note: This routine relies on heavy conversion from Double objects to double primitive types. If this turns out to be unacceptable slow, replace the Shelf with a double array.
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 String |
DEFSMOOTH
The default smoother.
|
private static boolean |
DEFSMOOTHADVISE
The default advisory behaviour.
|
(package private) double[] |
f
Two double arrays.
|
(package private) double[] |
g
Two double arrays.
|
static String |
KEY_PATH
The key pointing to the smoother filter dir.
|
static String |
KEY_SMOOTH
The key mapping to the smoothing filter file.
|
static String |
KEY_SMOOTHADVISE
The key defining only advisory functionality if set to true.
|
private Shelf<Double> |
smooth
Stores the smoothed readings.
|
private LinearSmoothing |
smoother
The smoothing algorithm to use.
|
KEY_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 |
SmoothingSensor(Map<String,String> qualify)
Constructs a fully-qualified smoothing sensor, with a given size
of measurements to keep.
Use of this constructor guarantees that the Map keys name, respawn, and memoery are always set. If the smoother input file stated in the properties cannot be found a default smoother is registered. |
| Modifier and Type | Method and Description |
|---|---|
protected DataEvent |
generateDataEvent()
Takes the last sensor smoothed data and adds it to the
PredictiveDataEvent produced by the parental method. |
List<Double> |
getLastSmooth(int nr)
Returns a list of the last nr smoothed values.
|
LinearSmoothing |
getSmoother()
Returns the smoother used with this sensor.
|
String |
getSmoothToggleInfo()
Returns extra info on a smooth toggle event.
|
boolean |
isSmoothAdvise()
Returns true if the smoothing functionality of this sensor is only
meant for advisory behaviour.
|
boolean |
isSmoothing()
Returns true if this sensor is really smoothing.
|
protected void |
newData(double raw,
Date time)
Conducts a single measure by calling this class's super method.
|
double |
regetSmooth()
Returns the most-recently added smoothened value as a primitive
double.
|
void |
registerSmoother(LinearSmoothing smoothit)
This method registers a linear smoothing algorithm for use with this
sensor.
|
void |
smoothOne(double raw)
The implementation of the smoothing interface.
|
getExtrapolation, getLastPredict, getPredictToggleInfo, init, isPredictAdvise, isPredicting, isReliable, predictFrom, regetPredictcumulateOne, getLastRaw, getLastTime, getMaxSize, getMemory, getSizeaddDataListener, 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, 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, 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_PATH
public static final String KEY_SMOOTH
public static final String KEY_SMOOTHADVISE
private static final String DEFSMOOTH
private static final boolean DEFSMOOTHADVISE
private LinearSmoothing smoother
double[] f
double[] g
protected SmoothingSensor(Map<String,String> qualify)
size - The maximum number of measurements to keep.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)
newData in class PredictiveSensorpublic void smoothOne(double raw)
public double regetSmooth()
regetSmooth in interface Smoothingpublic List<Double> getLastSmooth(int nr)
getLastSmooth in interface Smoothingnr - The number of smoothed values to be retrieved.public void registerSmoother(LinearSmoothing smoothit)
smoother - The linear smoothing algorithm to use.public LinearSmoothing getSmoother()
public boolean isSmoothing()
smoother.isSmoothing in interface Smoothingpublic boolean isSmoothAdvise()
public String getSmoothToggleInfo()
protected DataEvent generateDataEvent()
PredictiveDataEvent produced by the parental method. If no
smoother is specified, the undisturbed data event is returned.
If the CumulativeSensor.KEY_PACK property
points to a value greater than one, the data event produced carries the
average of the last smoothed.generateDataEvent in class PredictiveSensorSmoothDataEvent