stella.parameter
Class SensorValue

java.lang.Object
  extended by util.PropertyContainer
      extended by util.PropertyResources
          extended by util.PropertyBundles
              extended by stella.parameter.AbstractParameter
                  extended by stella.parameter.AbstractValue
                      extended by stella.parameter.DataValue
                          extended by 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.


Nested Class Summary
 
Nested classes/interfaces inherited from class util.PropertyResources
PropertyResources.URLResource
 
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.
 
Fields inherited from class stella.parameter.DataValue
DERIVATIVE, DERIVATIVEVALUE, KEY_BLOCK, KEY_DATA, PREDICT, PREDICTVALUE, RAW, SMOOTH, SMOOTHVALUE, VALUE
 
Fields inherited from class stella.parameter.AbstractParameter
KEY_FORMAT, KEY_NAME, KEY_PRESERVE, UNKNOWN
 
Fields inherited from class util.PropertyBundles
KEY_LOCALECOUNTRY, KEY_LOCALELANGUAGE, KEY_RESOURCEBUNDLES
 
Fields inherited from class util.PropertyResources
KEY_NOINITONCREATE, localurl, locate, POSTFIX_DIR, POSTFIX_EXT, POSTFIX_FILE, POSTFIX_LIST, POSTFIX_URL, urlset
 
Fields inherited from class util.PropertyContainer
KEY_LISTSEPARATOR, KEY_MAPKEYVALUECHAR, KEY_MAPSEPARATOR
 
Fields inherited from interface util.PropertySupplying
CONFIG, KEY_CLASS
 
Fields inherited from interface util.ResourceSupplying
KEY_URLRESOURCES, KEY_URLUSECONFIG, KEY_URLUSECURRENT, KEY_URLUSEHOME
 
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.DataValue
dataAvailable, getString, getValue, setValue
 
Methods inherited from class stella.parameter.AbstractValue
get, set
 
Methods inherited from class stella.parameter.AbstractParameter
createParameter, delivers, getFormatted, getFormatted, getName, getPreserveFile, getString, init, register, setName, toString
 
Methods inherited from class util.PropertyBundles
clone, getLocalized, getLocalized, getLocalizedString, getLocalizedString, loadResource
 
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 class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface stella.Parameter
get, getFormatted, getName, getString, set
 
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
 
Methods inherited from interface util.Initializable
init
 
Methods inherited from interface util.Reloadable
reload
 
Methods inherited from interface util.ResourceSupplying
getResource, getResourceAsStream, getResources
 

Field Detail

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.

Constructor Detail

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).

Method Detail

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