|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectutil.PropertyContainer
util.PropertyResources
util.PropertyBundles
util.rmi.RmiPropertyContainer
util.rmi.AbstractRmiCaster
stella.sensor.AbstractWeatherSurveyor
stella.sensor.WeatherStation
public class WeatherStation
A class acting as a conductor of several WeatherSensors. Acts as a
weather event listener and weather event caster but consideres a whole
bunch of weather sensors for generating only a single weather events.
This changes the behaviour in a way that it
takes some burdon from classes that are interested in bad/good weather
conditions. Weather events are now only generated if the combined
vote of all sensor changes.
On construct the provided properties are scanned for the KEY_LIST.
This should point to a file in the users personal java configuration
directory Path where the names of the properties files
for all sensor that comprise this weather station should be
listed. Each entriy found
is then used to generated a new Map object and pass it to the
AbstractSensor.createSensor(java.util.Map) factory method. Additinally to the
normal
sensor construction the sensor properties are scanned for the necessity to
register additional (sensors) to allow the weather judging capabilities of
the newly generated sensor to unfold. Note that for RS485Sensors
a PollingRS485Server has to be passed to the weather station prior
to retrieving sensor data.
Note that this class is intended to use local sensors, but serves
remote weather listeners.
This class serves remote error listeners.
| Nested Class Summary | |
|---|---|
static class |
WeatherStation.Manage
Allows rmi-access to the add/remove sensor properties of the weather station. |
static class |
WeatherStation.Run
Test purpose. |
static class |
WeatherStation.WeatherStationData
Implementation of the WeatherSurveying.DataBlock class. |
| Nested classes/interfaces inherited from class util.PropertyResources |
|---|
PropertyResources.URLResource |
| Nested classes/interfaces inherited from interface stella.sensor.WeatherSurveying |
|---|
WeatherSurveying.DataBlock |
| Field Summary | |
|---|---|
private SimpleTrigger |
current
The remote parameter value reporting true for currently good weather. |
private static boolean |
DEFBIND
The default auto-binding as a RmiWeatherCaster. |
private static boolean |
DEFDAEMON
The default name of the thread group to put all sensors into. |
private static String |
DEFFILE
The name of the file containing the default weather sensor list. |
private List |
drivers
A list of all weather drivers registered to the weather station. |
private Vector |
errorList
The error listeners to report to. |
private boolean |
isWeatherCaster
The flag to indicate registering of the rmi weather event casting has already occured. |
static String |
KEY_BIND
The key referring to auto-binding of the weather station as an RmiWeatherCaster. |
static String |
KEY_DAEMON
The key referring to the thread group the sensors should run in. |
static String |
KEY_DUMP
The file where all parameter values should be stored on exit. |
static String |
KEY_FILE
The key to a file containing a (long) list of all sensors. |
static String |
KEY_LIST
The key to a comma-seperated list of all sensors. |
static String |
KEY_NAME
The key to the name of this weather station. |
static String |
KEY_REPOSITORY
The properties of the sensor repository. |
private WeatherEvent |
lastWeather
The last weather event sent. |
private HashMap |
lookup
The lookup table matching sensor to their votes. |
private SensorRepository |
repository
A repository if the KEY_REPOSITORY is set. |
private Vector |
rmiList
The weather listeners to report to. |
private Timer |
weatherSensors
The timer where all weather sensors run. |
| Fields inherited from class util.rmi.AbstractRmiCaster |
|---|
ALTERNATEHOST, ALTERNATEPORT, KEY_BINDNAME, KEY_EXPORTPORT, KEY_REGISTRYHOST, KEY_REGISTRYPORT |
| 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 stella.rmi.RmiWeatherCaster |
|---|
NAMING_EXTENSION |
| 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 | |
|---|---|
WeatherStation()
Constructs a new weather station. |
|
WeatherStation(Map qualify)
Constructs a new weather station. |
|
| Method Summary | |
|---|---|
private Telemetering |
addFromFile(String prop)
Scans the resources for the properties given by a file name. |
void |
addRmiWeatherListener(RmiWeatherListener add)
Adds a weather listener to this weather station. |
boolean |
addSensor(String properties)
Adds a new sensor to an already running weather station. |
private Collection |
allSensorNames()
Returns a collection of all sensors by name. |
private boolean |
check()
Checks if all weather sensor report clear weather. |
boolean |
containsRemoteProperty(String key)
Tests if this property container contains a certain property. |
private void |
crossRegister()
Go thru the entire list of sensor and cross-register them if they are sensor depending. |
void |
exit()
Exits the weather station and all sensors that are ExitCleaning
instances. |
Object |
get()
Serves the weather watching's remote parameter capability. |
Collection |
getAllSensorNames()
Returns a Collection of all running weather sensors. |
Collection |
getAllSensors()
Returns a collection of all sensors served by this weather station. |
int |
getCurrentlyRetarding()
Returns the number of currently retarding sensors. |
WeatherEvent |
getCurrentWeather()
Returns a weather event reflecting the current weather conditions. |
RmiDataCaster |
getDataSensor(String name)
Returns a reference to the running weather sensor with the given name. |
long |
getElapsedToggleTime()
Returns elapsed time since last toggle event. |
String |
getFormatted()
Diverts to simple trigger. |
Date |
getLastToggleTime()
Returns the last toggle time of the weather. |
String |
getName()
Returns the name of this weather station. |
long |
getRemainsBadMaximum()
throws UnsupportedOperationException(); |
long |
getRemainsBadMinimum()
Returns the time in ms the weather will stay bad for sure. |
long |
getRemainsGoodMaximum()
Returns the time in ms the weather will stay good maximally (e.g until next sun rise). |
long |
getRemainsGoodMinimum()
throws UnsupportedOperationException(); Returns the time in ms the weather will stay good. |
Map |
getRemoteProperties()
Returns the entire properties of this object as a map. |
String |
getRemoteProperty(String key)
Returns a special property of this property container. |
Telemetering |
getSensor(String name)
Returns the sensor with the given name. |
String |
getStatus()
Returns the status of the weather station. |
String |
getString()
Diverts to simple trigger. |
Boolean |
getTrigger()
Returns the combined status of all open-roof switches as a Boolean. |
void |
init()
Initializes this weather station. |
boolean |
isTrue()
Returns the combined status of all open-roof switches as a primitive boolean. |
protected void |
notifyWeatherListener(WeatherEvent we)
Notifies all registered WeatherListeners. |
Object |
provideStatus()
Returns a detailed description of the weather status. |
void |
registerCluster(ParameterClustering set)
Registers a ParameterClustering instance to this weather
station. |
void |
registerSensorDriver(Driver drv)
Registers an instance of a polling rs485 server to all sensors that are instances of RS485Sensor. |
void |
removeRmiWeatherListener(RmiWeatherListener remove)
Removes a weather listener from this weather station. |
boolean |
removeSensor(String name)
Removes the weather sensor with the given name fro the weather station. |
Object |
set(Object to)
Throws an unsupported exception. |
String |
setRemoteProperty(String key,
String val)
Sets a special property of this property container. |
Boolean |
setTrigger(Boolean to)
Throws an unsupported exception. |
void |
startSensors()
Starts all weather sensors. |
Boolean |
toggleTrigger()
Throws an unsupported exception. |
String |
toString()
Returns a very brief description of the weather station. |
void |
weatherChanged(WeatherEvent we)
The receiver method of weather events. |
| Methods inherited from class stella.sensor.AbstractWeatherSurveyor |
|---|
addWeatherListener, createWeatherSurveyor, removeWeatherListener, status |
| Methods inherited from class util.rmi.AbstractRmiCaster |
|---|
bindAlternate, bindToRegistry, bindToRegistry, bindToRegistry, casterExit, casterExit, getBindName, getBindName, isValid, unbindFromRegistry, unbindFromRegistry |
| 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, rescanned, setObject, setProperties, setProperty, stringProperties |
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface util.rmi.RmiCaster |
|---|
bindToRegistry, isValid, unbindFromRegistry |
| 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.ResourceSupplying |
|---|
getResource, getResourceAsStream, getResources |
| Field Detail |
|---|
public static final String KEY_NAME
public static final String KEY_BIND
RmiWeatherCaster.
public static final String KEY_DAEMON
public static final String KEY_LIST
public static final String KEY_FILE
public static final String KEY_DUMP
public static final String KEY_REPOSITORY
private static final String DEFFILE
private static final boolean DEFBIND
RmiWeatherCaster.
private static final boolean DEFDAEMON
private SensorRepository repository
KEY_REPOSITORY is set.
private List drivers
private Timer weatherSensors
private HashMap lookup
private WeatherEvent lastWeather
private boolean isWeatherCaster
private SimpleTrigger current
private Vector rmiList
private Vector errorList
| Constructor Detail |
|---|
public WeatherStation()
throws RemoteException
RemoteExceptionpublic WeatherStation(Map qualify)
KEY_LIST
is present it is used with higher priority as the KEY_FILE.
The latter one should only be used if the list of sensors is so
long that a comma-separated list is confusing.
The list of error listenerers and weather listeners is cleared.
To comprise all weather sensors into a distinct group a
ThreadGroup is created.
qualify - The properties of this weather station.| Method Detail |
|---|
public void init()
PropertySupplying.KEY_CLASS
entry is used by the factory
method AbstractSensor.createSensor(java.util.Map) to create new sensor
instances. All
entries are converted into weather sensors using a constructor that
takes a single properties file as an argument. This implies that
all subclasses of WeatherSensor must provide a constructor
with a Map object as the argument!.
init in interface Initializableinit in class PropertyResourceslist - of Files, holding all the weather sensor properties to
listen to.private Telemetering addFromFile(String prop)
private void crossRegister()
public void exit()
ExitCleaning
instances. If the KEY_DUMP property points to a file, the
exit values of all sensors are written into that file.
exit in interface ExitCleaningexit in class AbstractRmiCasterpublic void registerSensorDriver(Driver drv)
RS485Sensor. The method parses through the set
of weather sensors and registers the rs485 server to all sensors
that can be cast to the RS485Sensor type.RS485Sensors are served within this weather station this
method should be called before the sensors are started with
startSensors(). If at least one sensor is of the RS485-type and
the serial port is not already opened this method tries to open the
serial port.
registerSensorDriver in interface WeatherSurveyingpublic void startSensors()
startSensors in interface WeatherSurveyingpublic void registerCluster(ParameterClustering set)
ParameterClustering instance to this weather
station. If any sensor within the weather station is cluster depending,
it receives this cluster. If we have ParameterDepending
sensor in the station, they get all sensors within the cluster.This method should always be called after the sensors has been constructed, before actually starting the sensors.
registerCluster in interface ClusterDependingpublic void weatherChanged(WeatherEvent we)
weatherChanged in interface WeatherListenerpublic WeatherEvent getCurrentWeather()
The weather event returned leaves its WeatherEvent.getReason()
undefined.
getCurrentWeather in interface WeatherSurveyingpublic int getCurrentlyRetarding()
getCurrentlyRetarding in interface WeatherSurveyingpublic long getRemainsBadMinimum()
WeatherJudging instances, this method can return the
maximum of all WeatherJudging.getMinClearUpTime().
getRemainsBadMinimum in interface WeatherPredictingpublic long getRemainsBadMaximum()
getRemainsBadMaximum in interface WeatherPredictingpublic long getRemainsGoodMinimum()
getRemainsGoodMinimum in interface WeatherPredictingpublic long getRemainsGoodMaximum()
getRemainsGoodMaximum in interface WeatherPredictingprivate boolean check()
This method notifies the weather listeners only on one occasion:
public Map getRemoteProperties()
throws RemoteException
PropertyContainer.getProperties().
getRemoteProperties in interface RmiPropertyBearinggetRemoteProperties in class RmiPropertyContainerRemoteException
public String getRemoteProperty(String key)
throws RemoteException
PropertyContainer.getProperty(java.lang.String).
getRemoteProperty in interface RmiPropertyBearinggetRemoteProperty in class RmiPropertyContainerkey - The key for the Map object.
PropertyContainer.getProperty(java.lang.String)
call.
RemoteException
public String setRemoteProperty(String key,
String val)
throws RemoteException
PropertyContainer.setProperty(java.lang.String, java.lang.String).
setRemoteProperty in interface RmiPropertyBearingsetRemoteProperty in class RmiPropertyContainerkey - The key for this Property.value - The value of this Property.
RemoteException
public boolean containsRemoteProperty(String key)
throws RemoteException
PropertyContainer.has(java.lang.String).
containsRemoteProperty in interface RmiPropertyBearingcontainsRemoteProperty in class RmiPropertyContainerRemoteExceptionpublic Telemetering getSensor(String name)
WeatherSurveying interface.
getSensor in interface WeatherSurveyingname - The unique name of the sensor.public Collection getAllSensors()
WeatherSurveying interface.
getAllSensors in interface WeatherSurveying
public RmiDataCaster getDataSensor(String name)
throws RemoteException
getDataSensor in interface RmiWeatherReportingRemoteException
public Collection getAllSensorNames()
throws RemoteException
getAllSensorNames in interface RmiWeatherReportingRemoteExceptionprivate Collection allSensorNames()
public boolean removeSensor(String name)
throws RemoteException
removeSensor in interface RmiWeatherReportingRemoteException
public boolean addSensor(String properties)
throws RemoteException
addSensor in interface RmiWeatherReportingproperties - The name of the properties file of the sensor.
RemoteExceptionpublic String getName()
getName in interface Parameterpublic Object get()
get in interface Parameterpublic Boolean getTrigger()
getTrigger in interface Triggerpublic boolean isTrue()
isTrue in interface Triggerpublic Date getLastToggleTime()
getLastToggleTime in interface Triggerpublic long getElapsedToggleTime()
getElapsedToggleTime in interface Triggerpublic String getFormatted()
getFormatted in interface Parameterpublic String getString()
getString in interface Parameterpublic Object set(Object to)
set in interface Parameterpublic Boolean setTrigger(Boolean to)
setTrigger in interface Triggerpublic Boolean toggleTrigger()
toggleTrigger in interface Trigger
public String getStatus()
throws RemoteException
AbstractWeatherSurveyor.status().
getStatus in interface RmiWeatherReportingRemoteExceptionpublic Object provideStatus()
provideStatus in interface StatusProvidingpublic String toString()
toString in class PropertyContainer
public void addRmiWeatherListener(RmiWeatherListener add)
throws RemoteException
RmiWeatherReporting instance, thus we notify all registering
listeners about the current weather.
addRmiWeatherListener in interface RmiWeatherCasterRemoteException
public void removeRmiWeatherListener(RmiWeatherListener remove)
throws RemoteException
removeRmiWeatherListener in interface RmiWeatherCasterRemoteExceptionprotected void notifyWeatherListener(WeatherEvent we)
WeatherEvent.isGood() flag.
notifyWeatherListener in class AbstractWeatherSurveyorwe - The WeatherEvent to pass to the Listeners.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||