public class SensorRepository extends AbstractRmiCaster implements RmiParameterClustering, RmiDataDepositing, Initializable, DataListener
| Modifier and Type | Class and Description |
|---|---|
protected class |
SensorRepository.Averager
This class collects all data events generated during the averaging
interval.
|
PropertyResources.Load, PropertyResources.URLResource| Modifier and Type | Field and Description |
|---|---|
private Map<String,List<DataEvent>> |
average
The hash map used for buffering the data events.
|
private SensorRepository.Averager |
averagethread
The average thread for notification of data listeners.
|
private List<Object> |
collect
The data-collector classes to use for processing the averages.
|
private static boolean |
DEFBIND
The default auto-binding.
|
static String |
DEFBINDNAME
The default binding name.
|
static long |
DEFTIMERINTERVAL
The default sampling intervall.
|
private boolean |
isScheduled
Averager scheduling may not start before the first data event.
|
static String |
KEY_BIND
The referring to auto-binding of the sensor repository.
|
static String |
KEY_DATACOLLECTOR
The key linked to the properties of the data collector class.
|
static String |
KEY_IGNORE
The key linked to the sensor that should not be monitored.
|
static String |
KEY_TIMERINTERVAL
The key linked to the scheduling intervall of the timer, in ms.
|
private Shelf<Map<String,DataEvent>> |
longterm
Stores a number of averaged data events mappings.
|
private Map<String,DataEvent> |
lookup
The look-up table matching sensor names to actual data events.
|
private Timer |
schedule
The timer class used for scheduling the data collector.
|
private WeatherSurveying |
station
A reference to the weather station for deregistering on exit.
|
private Map<String,Boolean> |
valid
The last data event received was valid.
|
ALTERNATEHOST, ALTERNATEPORT, KEY_BINDNAME, KEY_EXPORTPORT, KEY_REGISTRYHOST, KEY_REGISTRYPORTKEY_NOINITONCREATE, POSTFIX_ALPHABET, POSTFIX_BYTES, POSTFIX_DIR, POSTFIX_EXT, POSTFIX_FILE, POSTFIX_LIST, POSTFIX_MODTIME, POSTFIX_URLKEY_LISTSEPARATOR, KEY_MAPKEYVALUECHAR, KEY_MAPSEPARATORNAMING_EXTENSIONKEY_URLRESOURCES, KEY_URLUSECONFIG, KEY_URLUSECURRENT, KEY_URLUSEHOMECONFIG, KEY_CLASS| Constructor and Description |
|---|
SensorRepository(Map<String,String> prop)
Constructs a new readout-repository.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
addRmiDataCollector(RmiDataCollecting rmicollect)
Registers late-comming rmi data-collectors.
|
void |
dataAvailable(DataEvent de)
Receives an incoming
DataEvent. |
void |
exit()
Exits the read-out repository.
|
DataEvent |
getActualData(String name)
Returns the last data event received from the sensor with the given
name.
|
long |
getBaseInterval()
For convenience, return the base timer interval.
|
void |
init()
Initializes the read-out repository.
|
protected void |
initTimer(List<String> files)
Initializes the timer class scheduler and the
DataCollecting
classes for use with this short-average repository. |
boolean |
isValidData(String name)
Returns true, if the last data event received for the given sensor
name was a valid one.
|
void |
registerSensors(WeatherSurveying caller)
Initalizes the repository sensors.
|
boolean |
removeRmiDataCollector(RmiDataCollecting rmicollect)
Deregisters an rmi data-collector.
|
void |
rmiAddParameter(URL info)
Throws an unsupported operation exception-sensors are read-only.
|
Object |
rmiGet(String name)
Returns the actual value of the stated sensor.
|
Set<String> |
rmiGetAllParameterNames()
Returns the names of all sensors observed by this repository as a
set.
|
void |
rmiRemoveParameter(String info)
Throws an unsupported operation exception-sensors are read-only.
|
Object |
rmiSet(String name,
Object to)
Throws an unsupported operation exception-sensors are read-only.
|
String |
toString()
Returns the list of served sensor names.
|
bindToRegistry, bindToRegistry, bindToRegistry, bindToRegistry, bindToRegistry, bindToRegistry, casterExit, casterExit, getBindName, getBindName, isValid, unbindFromRegistry, unbindFromRegistrycontainsRemoteProperty, getRemoteProperties, getRemoteProperty, setRemotePropertyclone, createFrom, createFrom, createFrom, createInstance, getApplet, getAsResources, getLocate, getPropertiesToKey, getPropertiesToKey, getResource, getResourceAsStream, getResourceFromKey, getResources, hasLocalURLs, initProperties, keyCreate, keyCreate, reload, setAppletaugment, augment, 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, parseObject, reload, removeProperty, requires, rescanned, setObject, setProperties, setProperty, stringPropertiesequals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitbindToRegistry, isValid, unbindFromRegistrydefaultBoolean, 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, stringPropertiespublic static final String KEY_IGNORE
public static final String KEY_BIND
public static final String KEY_DATACOLLECTOR
public static final String KEY_TIMERINTERVAL
private static final boolean DEFBIND
public static final String DEFBINDNAME
public static final long DEFTIMERINTERVAL
private WeatherSurveying station
private Map<String,DataEvent> lookup
private Map<String,List<DataEvent>> average
private Shelf<Map<String,DataEvent>> longterm
private Timer schedule
private SensorRepository.Averager averagethread
private boolean isScheduled
public SensorRepository(Map<String,String> prop) throws RemoteException
#KEY_LIST or the #KEY_FILE keys
are given. registerSensors(stella.sensor.WeatherSurveying) method must
be called.RemoteExceptionpublic void init()
KEY_BIND key.init in interface Initializablepublic void exit()
KEY_BIND key.exit in interface ExitCleaningexit in class AbstractRmiCasterpublic void registerSensors(WeatherSurveying caller)
WeatherSurveying for its list of sensors and registers to all of
them that are not explicetly forbidden in the KEY_IGNORE list.public void dataAvailable(DataEvent de)
DataEvent. This data event is stored in
the lookup-table, using its RmiEvent.getSourceName() method
as a key.dataAvailable in interface DataListenerpublic DataEvent getActualData(String name)
public boolean isValidData(String name)
public long getBaseInterval()
public Object rmiGet(String name) throws RemoteException
RawDataEvent.getPhysical(), the sensor's raw data,
as returned
by the RawDataEvent.getRaw() method is returned.rmiGet in interface RmiParameterClusteringRemoteExceptionpublic Object rmiSet(String name, Object to) throws RemoteException
rmiSet in interface RmiParameterClusteringRemoteExceptionpublic void rmiAddParameter(URL info) throws RemoteException
rmiAddParameter in interface RmiParameterClusteringRemoteExceptionpublic void rmiRemoveParameter(String info) throws RemoteException
rmiRemoveParameter in interface RmiParameterClusteringRemoteExceptionpublic Set<String> rmiGetAllParameterNames() throws RemoteException
rmiGetAllParameterNames in interface RmiParameterClusteringRemoteExceptionpublic boolean addRmiDataCollector(RmiDataCollecting rmicollect) throws RemoteException
addRmiDataCollector in interface RmiDataDepositingRemoteExceptionpublic boolean removeRmiDataCollector(RmiDataCollecting rmicollect) throws RemoteException
removeRmiDataCollector in interface RmiDataDepositingRemoteExceptionpublic String toString()
toString in class PropertyContainerprotected void initTimer(List<String> files)
DataCollecting
classes for use with this short-average repository. All valid
data collectors (non-null returns from
AbstractDataCollector.createDataCollector(java.util.Map<java.lang.String, java.lang.String>)) are than servered
within one timer task. Note that it is not possible to use one
short-average repository with different averaging intervalls, but the
registered listeners can define different multiples of the base
interval.