public class PrecipitationTotal extends SensorData
Refer to
this internal default resource file
for property keys and default values used to configure this data processor.
To receive data, the variable sensor-name must map to the name of
a sensor task running on Service
. Default units 0.01 inch.
Modifier and Type | Class and Description |
---|---|
(package private) static class |
PrecipitationTotal.Interval
Enumeration of rainfall accumulation udpate intervals.
|
Modifier and Type | Field and Description |
---|---|
private java.lang.String |
fileName
File precipitation.total.name.
|
private PrecipitationTotal.Interval |
interval
Sample interval enum has all of the update parameters.
|
private static java.util.logging.Logger |
LOGGER
Logger for this class.
|
private static long |
MILLIS_DAY
Number of milliseconds in 24 hours.
|
private double |
reference
Rain gauge count.
|
private double |
scale
Multiplier for calibrating precipitation units.
|
CFG_AVERAGING_INTERVAL_KEY, CFG_OFFSET_KEY, CFG_SCALE_KEY, constant, dataReceived, dataTime, index, maximumValue, minimumValue, name, reset, resetTime, sensorName, values
Constructor and Description |
---|
PrecipitationTotal(java.lang.String name,
java.lang.String sensorName,
java.util.Properties config)
Creates a new instance of PrecipitationTotal.
|
Modifier and Type | Method and Description |
---|---|
java.lang.Number |
averageValue()
Average value is always the current value.
|
java.lang.Number |
currentValue()
Obtains the most recent new value.
|
private boolean |
isCounterReset(double value)
Determines if the counter has been reset.
|
private boolean |
isFileValid(java.io.File file,
java.util.Calendar calendar)
Determines if the file exists, and is still valid.
|
private boolean |
isFirstInterval(java.util.Calendar calendar,
long interval)
Checks if the current time is within the first sample interval of the
day.
|
boolean |
isReset()
Indicates if this data was reset.
|
private boolean |
isTrigger(java.util.Calendar calendar)
Determines if the current time triggers a reference update.
|
java.lang.Number |
maximumValue(boolean reset)
Maximum value is always the current value.
|
java.lang.Number |
minimumValue(boolean reset)
Maximum value is always zero.
|
protected void |
processValue(double value)
Converts the number of bucket tips into total accumulation, converted to
units.
|
private double |
readReference(double count,
java.util.Calendar calendar)
Deserializes the reference count from persistent storage.
|
void |
reset(boolean reset)
Resets total precipitation to zero.
|
java.lang.Number |
sigmaValue()
Sigma value is always the current value.
|
private double |
updateReference(double value)
Calculates precipitation since the last reference update from the new
value.
|
private double |
writeReference(double count)
Serializes the count to persistent storage for reference.
|
dataAvailable, dataAvailable, getConstant, getName, getResetTime, getSensorName, peakValue, putData
private static final long MILLIS_DAY
private static final java.util.logging.Logger LOGGER
private double scale
private double reference
private PrecipitationTotal.Interval interval
private java.lang.String fileName
public PrecipitationTotal(java.lang.String name, java.lang.String sensorName, java.util.Properties config)
name
- of this data processor.sensorName
- of the sensor associated with this data.config
- properties for configuring this data.public void reset(boolean reset)
reset
in interface ISensorData
reset
in class SensorData
reset
- if true, resets to zero.public boolean isReset()
isReset
in interface ISensorData
isReset
in class SensorData
public java.lang.Number currentValue()
currentValue
in interface ISensorData
currentValue
in class SensorData
public java.lang.Number maximumValue(boolean reset)
maximumValue
in interface ISensorData
maximumValue
in class SensorData
reset
- if true, resets data to zero.public java.lang.Number minimumValue(boolean reset)
minimumValue
in interface ISensorData
minimumValue
in class SensorData
reset
- if true, resets data to zero.public java.lang.Number sigmaValue()
sigmaValue
in interface ISensorData
sigmaValue
in class SensorData
public java.lang.Number averageValue()
averageValue
in interface ISensorData
averageValue
in class SensorData
protected void processValue(double value)
processValue
in class SensorData
value
- absolute number of bucket tips in the rain gauge.private double updateReference(double value)
value
- the new count from the rain gauge.private boolean isCounterReset(double value)
value
- the new count from the rain gauge.private boolean isTrigger(java.util.Calendar calendar)
calendar
- representing the current time.private boolean isFirstInterval(java.util.Calendar calendar, long interval)
calendar
- representing the current time.interval
- sampling interval to check.private double writeReference(double count)
count
- value to serialize.private double readReference(double count, java.util.Calendar calendar)
count
- default value to use if the file does not exist.calendar
- representing the current time.private boolean isFileValid(java.io.File file, java.util.Calendar calendar)
file
- to check for validity.calendar
- representing the current time.