public abstract class DataSensor extends TimerTaskSensor implements RmiDataCaster, DataCaster
DataEvent to its registered listeners. On construct,
it scans its property argument for the availability of KEY_REPORT,
which should be mapped to an integer describing the number of
individual data points to omit on listener notification. A
value of zero means that data event generating is prohibited.
If this key is not present, it defaults to DEFREPORT
which is normally
10. As soon as the desired number of measurments is available, the
run methods fork to the report() subroutine, which generates
the data events and passes them to the registered listeners. Please ensure
that the listeners method return immediately, otherwise some measurements
will be lost. If a listener needs heavy processing of data, use a new
thread instead.
This sensor adds the following properties if they are not set already (needs updating!):
DataCaster functionality is automatically bound.TimerTaskSensor.SensorReadPropertyResources.Load, PropertyResources.URLResource| Modifier and Type | Field and Description |
|---|---|
private int |
count
An integer counting the execution number.
|
private Vector |
datalist
The list of DataListeners.
|
(package private) static DecimalFormat |
DEFRAWFORMAT
The default raw format String.
|
(package private) static int |
DEFREPORT
The default report rate.
|
(package private) static DecimalFormat |
DEFSIGMAFORMAT
The default format string for the values.
|
static String |
KEY_RAWFORMAT
The key in the Map referring to the raw data format.
|
static String |
KEY_REPORT
The name of the key for the report rate in this sensors properties.
|
static String |
KEY_SIGMAFORMAT
The key to the sigma-format string.
|
private NumberFormat |
rawform
The decimal format for the raw values.
|
private int |
reportrate
The packing rate.
|
private NumberFormat |
sigform
The decimal format for the raw sigma values.
|
KEY_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 |
DataSensor(Map qualify)
Constructs a fully-qualified data sensor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addDataListener(DataListener ear)
Adds a
DataListener to the registered listeners. |
void |
addRmiDataListener(RmiDataListener ear)
Adds a
DataListener to the registered listeners. |
protected void |
conductOneMeasure()
The modified version of the
conductOneMeasure() method. |
void |
exit()
Unbind from registry, if bound.
|
protected DataEvent |
generateDataEvent()
Takes the last sensor reading and produces a
RawDataEvent out of
it. |
NumberFormat |
getRawFormat()
Returns the decimal format of the raw value.
|
NumberFormat |
getSigmaFormat()
Returns the decimal format of the sigma of the raw value.
|
void |
removeDataListener(DataListener ear)
Removes a
DataListener from the registered listeners. |
void |
removeRmiDataListener(RmiDataListener ear)
Removes a
DataListener from the registered listeners. |
protected void |
report()
This method is called repeatedly within the normal execution of this
thread.
|
cancel, equals, getRawToggleInfo, getReading, getRespawn, getTimeOfRead, hashCode, initSensorTimerTask, isReady, newData, 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, waitbindToRegistry, 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_REPORT
public static final String KEY_RAWFORMAT
public static final String KEY_SIGMAFORMAT
static final int DEFREPORT
static final DecimalFormat DEFRAWFORMAT
static final DecimalFormat DEFSIGMAFORMAT
private transient Vector datalist
private int count
private final int reportrate
private final NumberFormat rawform
private final NumberFormat sigform
protected DataSensor(Map qualify)
size - The maximum number of measurments to keep.group - The ThreadGroup this thread belongs to.name - The name of this thread (sensor).qualify - The Map object describing this sensor.public void exit()
exit in interface ExitCleaningexit in class AbstractSensorpublic void addDataListener(DataListener ear)
DataListener to the registered listeners. If the
argument is null, nothing is changed.addDataListener in interface DataCasterear - The listener to add.public void removeDataListener(DataListener ear)
DataListener from the registered listeners. If the
argument is null, nothing is changed.removeDataListener in interface DataCasterear - The listener to remove.public void addRmiDataListener(RmiDataListener ear) throws RemoteException
DataListener to the registered listeners. If the
argument is null, nothing is changed.addRmiDataListener in interface RmiDataCasterear - The listener to add.RemoteExceptionpublic void removeRmiDataListener(RmiDataListener ear) throws RemoteException
DataListener from the registered listeners. If the
argument is null, nothing is changed.removeRmiDataListener in interface RmiDataCasterear - The listener to remove.RemoteExceptionpublic NumberFormat getRawFormat()
public NumberFormat getSigmaFormat()
protected void conductOneMeasure()
conductOneMeasure() method.
Additionally to
the readout of the sensor, the method report() is called as
soon as the desired number of data points is present. If the pack
rate is zero or negative this sensor does not export its reading as
data events.conductOneMeasure in class TimerTaskSensorprotected void report()
KEY_REPORT
property, this occurs on integer multiples of the readout time.
In the default behaviour, a RawDataEvent is generated and passed
to all registered listeners. Please note that it is important that the
listener's DataListener.dataAvailable(stella.DataEvent) returns immediately,
otherwise some reading cycles will be skipped. No data is reported if
the generateDataEvent() returns null.
protected DataEvent generateDataEvent()
RawDataEvent out of
it. The error of the measurement is set to zero.