stella.parameter
Class SensorValue
java.lang.Object
util.PropertyContainer
util.PropertyResources
util.PropertyBundles
stella.parameter.AbstractParameter
stella.parameter.AbstractValue
stella.parameter.DataValue
stella.parameter.SensorValue
- All Implemented Interfaces:
- Cloneable, EventListener, DataListener, Parameter, Value, WeatherDependingParameter, ExitCleaning, Initializable, LocalizedSupplying, PropertySupplying, Reloadable, ResourceSupplying
public class SensorValue
- extends DataValue
- implements WeatherDependingParameter, Reloadable
A parameter that represents a sensor that is running locally on the same
host. It is therefore weather-depending to allow proper registration at
initialization.
|
Field Summary |
static String |
KEY_SENSOR
The key to the sensor this global wraps. |
private DataSensor |
sensor
A reference to the data sensor we listen to for proper exiting. |
|
Constructor Summary |
SensorValue(Map info)
Constructs a new sensor global. |
|
Method Summary |
void |
exit()
Deregisters from the sensor. |
Object |
getForWeather(WeatherSurveying weather)
Receiving the sensor value directly from the weather station without
registering is not possible. |
void |
registerWeather(WeatherSurveying weather)
Tells the sensor global to which sensor it should register itself as
a data listener. |
double |
rescanned(String key,
String old,
String newval)
As any parameter depending instance we fail if the parameter we depend
on is now a different one. |
| Methods inherited from class stella.parameter.AbstractParameter |
createParameter, delivers, getFormatted, getFormatted, getName, getPreserveFile, getString, init, register, setName, 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, 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_SENSOR
public static final String KEY_SENSOR
- The key to the sensor this global wraps.
- See Also:
- Constant Field Values
sensor
private DataSensor sensor
- A reference to the data sensor we listen to for proper exiting.
SensorValue
public SensorValue(Map info)
- Constructs a new sensor global. If the sensor this global should wrap
could not be found in the properties, the construction fails with an
IllegalArgumentException. Additionally, the properties are
scanned for the data source key. If this key is not present or maps to
an illegal value, it is (re)mapped to
DataValue.RAW. This guarantees
that this key is present and points to a allowed value once the
construction phase is finished. Note that a successful construction of
the sensor global does not mean this global can be querried
right away. It must register to the sensor it should listen to via
a call to registerWeather(stella.sensor.WeatherSurveying).
rescanned
public double rescanned(String key,
String old,
String newval)
- As any parameter depending instance we fail if the parameter we depend
on is now a different one.
- Specified by:
rescanned in interface Reloadable- Overrides:
rescanned in class AbstractParameter
registerWeather
public void registerWeather(WeatherSurveying weather)
- Tells the sensor global to which sensor it should register itself as
a data listener. This method must always be called once before querying
results. Note that due to the sensor-packing delay, even some time after
registering the right data sensor, no data will be available. To
clearly distinguish between pre-registered and no-data-available cases,
this method already asigns a value to the sensor global's
{#link #sensorValue}. This default is a representation of NaN
(not a number).
- Specified by:
registerWeather in interface WeatherDependingParameter
exit
public void exit()
- Deregisters from the sensor.
- Specified by:
exit in interface ExitCleaning- Overrides:
exit in class AbstractParameter
getForWeather
public Object getForWeather(WeatherSurveying weather)
- Receiving the sensor value directly from the weather station without
registering is not possible.
- Specified by:
getForWeather in interface WeatherDependingParameter