public abstract class DerivativeSensor extends SmoothingSensor implements Deriving
The properties are scanned for the file name to derive a Savitzky-Golay smoothing filter with the KEY_DERIVE. If the property is not set no derivator is registered. This is one exception to the general rule that the use of default constructors guarantees the proper key to be present in the properties after the construction phase. This is necessary because Map do not allow null keys or values.
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 boolean |
DEFDERIVATIVEADVISE
The default advisory behaviour.
|
private static String |
DEFDERIVE
The default smoother.
|
(package private) static DecimalFormat |
DEFRAWDERIVATIVE
The default format string for the values.
|
private SavitzkyGolaySmoothing |
derivator
The smoothing algorithm to use.
|
protected Shelf<Double> |
derive
Stores the first derivatives.
|
static String |
KEY_DERIVATIVEADVISE
The key defining only advisory functionality if set to true.
|
static String |
KEY_DERIVE
The key mapping to the derivative filter file.
|
static String |
KEY_PATH
The key pointing to the derivative filter dir.
|
static String |
KEY_RAWDERIVATIVE
The key to the raw derivative-data format string.
|
(package private) double[] |
z
A double arrays.
|
f, 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 |
DerivativeSensor(Map<String,String> qualify)
Constructs a fully-qualified derivative sensor, with a given size
of measurements to keep.
Use of this constructor guarantees that the Map keys name and respawn are always set. |
| Modifier and Type | Method and Description |
|---|---|
void |
deriveAt(double raw)
The implementation of the deriving interface.
|
protected DataEvent |
generateDataEvent()
Takes the last sensor derivative data and adds it to the
SmoothDataEvent produced by the parental method. |
NumberFormat |
getDerivativeFormat()
Returns the decimal format of the raw derivative value.
|
String |
getDerivativeToggleInfo()
Returns extra info on a derivative toggle event.
|
SavitzkyGolaySmoothing |
getDerivator()
Returns the derivator used.
|
List<Double> |
getLastDerivative(int nr)
The interface method for retrieving the last nr derivatives.
|
boolean |
isDerivativeAdvise()
Returns true if the derivative functionality of this sensor is only
meant for advisory behaviour.
|
boolean |
isDeriving()
Return true if the
derivator object is non-null. |
protected void |
newData(double raw,
Date time)
Conducts a single measure by calling this class's super method.
|
double |
regetDerive()
Returns the most-recently added first derivative as a primitive
double.
|
void |
registerDerivator(SavitzkyGolaySmoothing deriver)
This method registers a linear smoothing algorithm for use with this
sensor.
|
getLastSmooth, getSmoother, getSmoothToggleInfo, isSmoothAdvise, isSmoothing, regetSmooth, registerSmoother, smoothOnegetExtrapolation, 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_DERIVE
public static final String KEY_RAWDERIVATIVE
public static final String KEY_DERIVATIVEADVISE
private static final String DEFDERIVE
private static final boolean DEFDERIVATIVEADVISE
static final DecimalFormat DEFRAWDERIVATIVE
private SavitzkyGolaySmoothing derivator
double[] z
protected DerivativeSensor(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 SmoothingSensorpublic void deriveAt(double raw)
registerDerivator(math.SavitzkyGolaySmoothing) method.public double regetDerive()
regetDerive in interface Derivingpublic List<Double> getLastDerivative(int nr)
getLastDerivative in interface DerivingDerivingpublic void registerDerivator(SavitzkyGolaySmoothing deriver)
smoother - The linear smoothing algorithm to use.public SavitzkyGolaySmoothing getDerivator()
public boolean isDeriving()
derivator object is non-null.isDeriving in interface Derivingpublic boolean isDerivativeAdvise()
public NumberFormat getDerivativeFormat()
Deriving.getDerivativeFormat in interface Derivingpublic String getDerivativeToggleInfo()
protected DataEvent generateDataEvent()
SmoothDataEvent produced by the parental method. If no
derivator 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 derivative data.generateDataEvent in class SmoothingSensorDerivativeDataEvent