stella.sensor
Class AverageSensor
java.lang.Object
util.PropertyContainer
util.PropertyResources
util.PropertyBundles
util.rmi.RmiPropertyContainer
util.rmi.AbstractRmiCaster
stella.sensor.AbstractSensor
stella.sensor.TimerTaskSensor
stella.sensor.DataSensor
stella.sensor.CumulativeSensor
stella.sensor.PredictiveSensor
stella.sensor.SmoothingSensor
stella.sensor.DerivativeSensor
stella.sensor.WeatherSensor
stella.sensor.AverageSensor
- All Implemented Interfaces:
- Cloneable, Remote, Caster, DataCaster, RmiDataCaster, RmiErrorCaster, Cumulating, Deriving, Predicting, SensorDepending, Smoothing, Telemetering, WeatherJudging, WeatherCaster, ExitCleaning, Initializable, LocalizedSupplying, PropertySupplying, ResourceSupplying, RmiCaster, RmiPropertyBearing
public class AverageSensor
- extends WeatherSensor
- implements SensorDepending
A class that takes a list of individual sensors and returns the average
of their measurements as its measurement. Whenever this sensor is queried
for its reading it takes the most recent reading of its registered
(CumulativeSensor.KEY_AVERAGE) sensors and returns the average reading. Depending
on KEY_OFFSET all readings that are more than this value relatively
off the average are discarded. Additionally, readings below or equal
KEY_MINTHRESHOLD and readings above or equal
KEY_MAXTHRESHOLD are discarded.
|
Field Summary |
private Map |
average
The list of registered sensors that are used for averaging. |
static String |
KEY_AVERAGEOF
The list of the sensor names that are used for averaging. |
static String |
KEY_MAXTHRESHOLD
The maximum value that is considered valid of an individual sensor. |
static String |
KEY_MINTHRESHOLD
The minimum value that is considered valid of an individual sensor. |
static String |
KEY_OFFSET
The maximum offset allowed. |
private List |
names
The list of names of the sensors that should be averaged. |
private double |
wasread
Caches the last valid value. |
private boolean |
wasvalid
Gets true after startup and a first successful average calculation. |
| Fields inherited from class stella.sensor.WeatherSensor |
KEY_DERIVATIVEINVALID, KEY_DERIVATIVEPARAMETER, KEY_INVERSE, KEY_INVERSEDERIVATIVE, KEY_JUDGEDERIVATIVE, KEY_JUDGEPREDICT, KEY_JUDGERAW, KEY_JUDGESMOOTH, KEY_PREDICTINVALID, KEY_PREDICTPARAMETER, KEY_RAWINVALID, KEY_RAWPARAMETER, KEY_RETARDBADDERIVATIVE, KEY_RETARDBADPREDICT, KEY_RETARDBADRAW, KEY_RETARDBADSMOOTH, KEY_RETARDGOODDERIVATIVE, KEY_RETARDGOODPREDICT, KEY_RETARDGOODRAW, KEY_RETARDGOODSMOOTH, KEY_SMOOTHINVALID, KEY_SMOOTHPARAMETER |
|
Method Summary |
private double |
getAverage()
Calculates the average of the values mapped in the look-up table in a
recursive way. |
String |
getSensorInitInfo()
Returns the names of the sensors we use for averaging plus the super
information. |
protected double |
readSensor()
Reads the averaging sensor. |
void |
registerSensor(Telemetering add)
Adds sensor to this averaging sensor. |
boolean |
validReading()
Returns true if the reading of this averaging sensor is true. |
| Methods inherited from class stella.sensor.WeatherSensor |
addWeatherListener, conductOneMeasure, currentlyClear, currentlyRetarding, generateDataEvent, getMinClearUpTime, goodFromDerivative, goodFromPredict, goodFromRaw, goodFromSmooth, isDerivativeRetard, isPredictRetard, isRawRetard, isSmoothRetard, judgeWeather, notifyWeatherListener, removeWeatherListener, status |
| Methods inherited from class stella.sensor.TimerTaskSensor |
cancel, equals, getRawToggleInfo, getReading, getRespawn, getTimeOfRead, hashCode, initSensorTimerTask, isReady, regetRaw, setTimeOfRead, validReading |
| Methods inherited from class stella.sensor.AbstractSensor |
addRmiErrorListener, createSensor, getBindName, getConvert, getSensorDescription, getSensorName, init, notifyErrorListener, removeRmiErrorListener, setConvert, toString |
| Methods inherited from class util.PropertyResources |
createFrom, createFrom, createFrom, getApplet, getAsResources, getLocalClassLoader, getPropertiesToKey, getPropertiesToKey, getResource, getResourceAsStream, getResourceFromKey, getResources, keyCreate, keyCreate, reload, setApplet |
| Methods inherited from class util.PropertyContainer |
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, reload, removeProperty, rescanned, setObject, setProperties, setProperty, stringProperties |
| Methods inherited from interface util.PropertySupplying |
defaultBoolean, 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, stringProperties |
KEY_AVERAGEOF
public static final String KEY_AVERAGEOF
- The list of the sensor names that are used for averaging.
- See Also:
- Constant Field Values
KEY_OFFSET
public static final String KEY_OFFSET
- The maximum offset allowed.
- See Also:
- Constant Field Values
KEY_MINTHRESHOLD
public static final String KEY_MINTHRESHOLD
- The minimum value that is considered valid of an individual sensor.
- See Also:
- Constant Field Values
KEY_MAXTHRESHOLD
public static final String KEY_MAXTHRESHOLD
- The maximum value that is considered valid of an individual sensor.
- See Also:
- Constant Field Values
names
private List names
- The list of names of the sensors that should be averaged.
average
private Map average
- The list of registered sensors that are used for averaging.
wasvalid
private boolean wasvalid
- Gets true after startup and a first successful average calculation.
wasread
private double wasread
- Caches the last valid value.
AverageSensor
public AverageSensor(Map prop)
throws RemoteException
- Constructs a new averaging sensor. No keys are defaulted. If in the
map handed over the
KEY_OFFSET, the KEY_MINTHRESHOLD,
and the KEY_MAXTHRESHOLD are not defined, no exclusion of
readings is done.
- Throws:
RemoteException
registerSensor
public void registerSensor(Telemetering add)
- Adds sensor to this averaging sensor. If the
Telemetering
instance's name is found in the KEY_AVERAGEOF list, this sensor
is added to the sensors average map.
- Specified by:
registerSensor in interface SensorDepending
validReading
public boolean validReading()
- Returns true if the reading of this averaging sensor is true. In the
strict variant, this returns true only if all sensors we average over
are valid.
- Specified by:
validReading in interface Telemetering
getSensorInitInfo
public String getSensorInitInfo()
- Returns the names of the sensors we use for averaging plus the super
information.
- Specified by:
getSensorInitInfo in interface Telemetering- Overrides:
getSensorInitInfo in class WeatherSensor
readSensor
protected double readSensor()
- Reads the averaging sensor. All of the mapped sensors are traversed
average, their readings are updated and used for averaging.
- Specified by:
readSensor in class TimerTaskSensor
- See Also:
ConvertToPhysical
getAverage
private double getAverage()
- Calculates the average of the values mapped in the look-up table in a
recursive way. First, all mappings to null are ignored. From the
remaining values, an average is calculated. If the
KEY_OFFSET
key is given, all values are then again transversed and all values
outside the relative offset are discarded. If at least one value has
been discarded, the averaging is started again.