stella.sensor
Class FakeSensor
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.FakeSensor
- All Implemented Interfaces:
- Cloneable, Remote, Caster, DataCaster, RmiDataCaster, RmiErrorCaster, Cumulating, Deriving, Predicting, Smoothing, Telemetering, WeatherJudging, WeatherCaster, ExitCleaning, Initializable, LocalizedSupplying, PropertySupplying, ResourceSupplying, RmiCaster, RmiPropertyBearing
public class FakeSensor
- extends WeatherSensor
A fake sensor does not generate data events based on reading a true sensor,
but generates it from reading a file. On start-up, the file given in the
properties with KEY_FILE is opened. Each measurement is derived
from a line in the ascii-file. The line is scanned for the stated column
number KEY_COLUMN, the ascii-String found there converted into
a double which is in turn returned as the measurement. Note that column
numbering starts with one, see LineExtract.
Fake sensors can be used to re-introduce recorded sensor data, e.g. from
a DailyDumpRepository output into a sensor-phalanx.
|
Field Summary |
private static int |
DEFCOLUMN
The default column number. |
private static boolean |
DEFVMEXIT
The default exit behaviour. |
private BufferedReader |
in
The stream to read from. |
static String |
KEY_COLUMN
The key to the column number that should be read. |
static String |
KEY_FILE
The key to a list of sensor that should be mapped. |
static String |
KEY_VMEXIT
The key to a java-VM exit if end-of-file is reached. |
| 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 |
|
Constructor Summary |
FakeSensor(Map prop)
Constructs a new fake sensor. |
|
Method Summary |
protected double |
readSensor()
Reads the specified column in the file. |
boolean |
validReading()
A fake sensor is always valid, if the data file can be read. |
| Methods inherited from class stella.sensor.WeatherSensor |
addWeatherListener, conductOneMeasure, currentlyClear, currentlyRetarding, generateDataEvent, getMinClearUpTime, getSensorInitInfo, 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_FILE
public static final String KEY_FILE
- The key to a list of sensor that should be mapped.
- See Also:
- Constant Field Values
KEY_COLUMN
public static final String KEY_COLUMN
- The key to the column number that should be read.
- See Also:
- Constant Field Values
KEY_VMEXIT
public static final String KEY_VMEXIT
- The key to a java-VM exit if end-of-file is reached.
- See Also:
- Constant Field Values
DEFCOLUMN
private static final int DEFCOLUMN
- The default column number.
- See Also:
- Constant Field Values
DEFVMEXIT
private static final boolean DEFVMEXIT
- The default exit behaviour.
- See Also:
- Constant Field Values
in
private BufferedReader in
- The stream to read from.
FakeSensor
public FakeSensor(Map prop)
throws RemoteException
- Constructs a new fake sensor. The file found in in the properties is
also opened here.
- Throws:
RemoteException
readSensor
protected double readSensor()
- Reads the specified column in the file. If the file-read extends over
the end-of-file mark, it is newly openened. If the input stream is
null, or an IOException is thrown on read, zero is returned.
- Specified by:
readSensor in class TimerTaskSensor
- See Also:
ConvertToPhysical
validReading
public boolean validReading()
- A fake sensor is always valid, if the data file can be read.