public abstract class SensorData extends java.lang.Object implements ISensorData
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
CFG_AVERAGING_INTERVAL_KEY
Averaging interval (milliseconds) configuration sensor-name.key suffix.
|
static java.lang.String |
CFG_OFFSET_KEY
Units offset configuration name.key suffix.
|
static java.lang.String |
CFG_SCALE_KEY
Units scaling configuration name.key suffix.
|
protected java.lang.Number |
constant
General purpose sensor-specific constant.
|
protected boolean |
dataReceived
Flag to indicate if sensor data was received.
|
protected long |
dataTime
Time of the last data received.
|
protected int |
index
Index into most recent data in the buffer.
|
protected java.lang.Number |
maximumValue
Maximum value.
|
protected java.lang.Number |
minimumValue
Minimum value.
|
protected java.lang.String |
name
Name of this data processor for configuration purposes.
|
protected boolean |
reset
Indicates if the data has been reset.
|
protected long |
resetTime
Time of the last reset.
|
protected java.lang.String |
sensorName
Name of the sensor posting data to this processor.
|
protected double[] |
values
Data buffer for rolling average.
|
Modifier | Constructor and Description |
---|---|
protected |
SensorData(java.lang.String name,
java.lang.String sensorName,
java.util.Properties config)
Creates a new instance of SensorData.
|
Modifier and Type | Method and Description |
---|---|
java.lang.Number |
averageValue()
Calculates the average of all values in the history buffer.
|
java.lang.Number |
currentValue()
Obtains the most recent new value.
|
boolean |
dataAvailable()
Indicates if this sensor has posted data since the last call.
|
boolean |
dataAvailable(long time)
Indicates if this sensor has posted data since the specified time.
|
java.lang.Number |
getConstant()
Pass-through constant for sensor-specific data.
|
java.lang.String |
getName()
Name property accessor.
|
long |
getResetTime()
Reset time property accessor.
|
java.lang.String |
getSensorName()
Sensor name property accessor.
|
boolean |
isReset()
Indicates if this data was reset.
|
java.lang.Number |
maximumValue(boolean reset)
Calculates the highest value since the last reset.
|
java.lang.Number |
minimumValue(boolean reset)
Calculates the lowest value since the last reset.
|
java.lang.Number |
peakValue()
Calculates the peak of all values in the history buffer.
|
protected void |
processValue(double value)
Default behavior applies the input value to the averaging buffer, then
applies the average to the minimum and maximum values.
|
void |
putData(java.lang.Number value)
Adds a new data value to the processor.
|
void |
reset(boolean reset)
Resets minimum and maximum values to implementation-specific value.
|
java.lang.Number |
sigmaValue()
Calculates the sum of all values in the history buffer.
|
public static final java.lang.String CFG_AVERAGING_INTERVAL_KEY
public static final java.lang.String CFG_SCALE_KEY
public static final java.lang.String CFG_OFFSET_KEY
protected java.lang.String name
protected java.lang.String sensorName
protected double[] values
protected int index
protected java.lang.Number maximumValue
protected java.lang.Number minimumValue
protected boolean reset
protected java.lang.Number constant
protected boolean dataReceived
protected long dataTime
protected long resetTime
protected SensorData(java.lang.String name, java.lang.String sensorName, java.util.Properties config)
name
- of this data processor.sensorName
- data source for this data processor.config
- properties for configuring this data.public java.lang.String getName()
ISensorData
getName
in interface ISensorData
public java.lang.String getSensorName()
ISensorData
getSensorName
in interface ISensorData
public java.lang.Number getConstant()
ISensorData
getConstant
in interface ISensorData
public boolean dataAvailable()
ISensorData
dataAvailable
in interface ISensorData
public boolean dataAvailable(long time)
ISensorData
dataAvailable
in interface ISensorData
time
- to check against. Set to zero to find out if this device has
ever posted data.public void reset(boolean reset)
ISensorData
reset
in interface ISensorData
reset
- if true, resets to implementation-specific value.public boolean isReset()
ISensorData
isReset
in interface ISensorData
public long getResetTime()
ISensorData
getResetTime
in interface ISensorData
public void putData(java.lang.Number value)
ISensorData
putData
in interface ISensorData
value
- new data to add to the processor.public java.lang.Number sigmaValue()
ISensorData
sigmaValue
in interface ISensorData
public java.lang.Number peakValue()
ISensorData
peakValue
in interface ISensorData
public java.lang.Number averageValue()
ISensorData
averageValue
in interface ISensorData
public java.lang.Number currentValue()
ISensorData
currentValue
in interface ISensorData
public java.lang.Number maximumValue(boolean reset)
ISensorData
maximumValue
in interface ISensorData
reset
- if true, to implementation-specific value.public java.lang.Number minimumValue(boolean reset)
ISensorData
minimumValue
in interface ISensorData
reset
- if true, to implementation-specific value.protected void processValue(double value)
value
- new value from sensor.