stella.sensor
Class OneWireADSensor
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.OneWireADSensor
- All Implemented Interfaces:
- DriverDepending, Cloneable, Remote, Caster, DataCaster, RmiDataCaster, RmiErrorCaster, Cumulating, Deriving, Predicting, Smoothing, Telemetering, WeatherJudging, WeatherCaster, ExitCleaning, Initializable, LocalizedSupplying, PropertySupplying, ResourceSupplying, RmiCaster, RmiPropertyBearing
public class OneWireADSensor
- extends WeatherSensor
- implements DriverDepending
A sensor representation of analog input data read with a one-wire A/D
converter.
|
Field Summary |
private int |
channel
The integer equivalent of the channel key property. |
static String |
KEY_CHANNEL
The key for the channel number this sensor link to on the module. |
static String |
KEY_READ
The key linked to the channel-read command of the Nudam modlue. |
static String |
KEY_SERVER
The key linked to the polling instance to read from. |
private OneWireDriver |
serial
The instance of the polling rs485 server. |
private boolean |
valid
True for valid readings, false otherwise. |
| 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 |
String |
getSensorInitInfo()
Returns a string description of the sensor. |
protected double |
readSensor()
Reads the sensor value. |
boolean |
registerDriver(Driver poller)
Registers the serial server to this sensor. |
protected double |
retrieveValue(String read,
int nr)
Converts the input data string returned by the Nudam-module into a
double value. |
boolean |
validReading()
Returns true if the sensor reading is valid. |
| 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_SERVER
public static final String KEY_SERVER
- The key linked to the polling instance to read from.
- See Also:
- Constant Field Values
KEY_READ
public static final String KEY_READ
- The key linked to the channel-read command of the Nudam modlue.
- See Also:
- Constant Field Values
KEY_CHANNEL
public static final String KEY_CHANNEL
- The key for the channel number this sensor link to on the module.
- See Also:
- Constant Field Values
channel
private int channel
- The integer equivalent of the channel key property.
serial
private transient OneWireDriver serial
- The instance of the polling rs485 server.
valid
private boolean valid
- True for valid readings, false otherwise.
OneWireADSensor
public OneWireADSensor(Map prop)
throws RemoteException
- Constructs a new RS485 sensor. The properties are checked for the
presence of the
KEY_READ and the KEY_CHANNEL keys.
Construction fails if these keys are not present.
- Throws:
IllegalArgumentException - If the necessary properties are not
set.
NumberFormatException - If the channel number is not an int.
RemoteException
registerDriver
public boolean registerDriver(Driver poller)
- Registers the serial server to this sensor. This method must be called
at least once before data retrieval for an instance of this sensor
is possible. Note that a weather station can only register the serial
server by checking the sensor for the appropriate type and casting it.
Note that this method returns false only if the driver handed over is
not of the appropriate type, i.e. a
PollingRS485Server.
- Specified by:
registerDriver in interface DriverDepending
- Returns:
- True if registering at the driver was successful.
readSensor
protected double readSensor()
- Reads the sensor value. If no serial server was registered to this
sensor or the server is not reading the sensor's input,
NaN is returned. Otherwise the serial server is
queried for the value of its channel,
PollingRS485Server#readChannel, whose return value is then
fed, along with the channel number, to the retrieveValue(java.lang.String, int)
method of the sensor.
- Specified by:
readSensor in class TimerTaskSensor
- See Also:
ConvertToPhysical
validReading
public boolean validReading()
- Returns true if the sensor reading is valid. Shifts the decision to a
query to the polling server whether the last polling query was
succesful.
Might be flukey if the sensor respawn intervall is much higher than the
polling time.
- Specified by:
validReading in interface Telemetering
getSensorInitInfo
public String getSensorInitInfo()
- Returns a string description of the sensor. The name is returned plus
the serial server it listens to. The key properties of the switching
behaviour, i.e. the toggling instance is reported, too.
- Specified by:
getSensorInitInfo in interface Telemetering- Overrides:
getSensorInitInfo in class WeatherSensor
retrieveValue
protected double retrieveValue(String read,
int nr)
- Converts the input data string returned by the Nudam-module into a
double value. The channel number handed over is used to split the
modul's returned string into the correct substring.
The format of the string read in from the module always starts with
a > character, then, for each channel read, a 7-character long
double follows.
- Parameters:
read - The string read in from the serial linenr - The channel number (0-7) of the analog input.
- Returns:
- The formerly read value, if parsing was insuccessful.