|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectutil.PropertyContainer
util.PropertyResources
util.PropertyBundles
stella.parameter.AbstractParameter
stella.parameter.AbstractTrigger
stella.parameter.WeatherTrigger
public class WeatherTrigger
A weather trigger takes a list of SensorValues, named according to
KEY_WEATHERLIST. In principle it is also possible to incorporate
any Value, both mostly readings from wether sensor will be used.
In KEY_WEATHERTABLE, each of these
names is coupled to two values, a minimum and a maximum. If the minimum
is lower than the maximum, the allowed data range for this sensor is
between min/max, if ordered such that the first value is higher than the
second, the allowed range is outside min/max. The trigger is updated
every KEY_REFRESH ms - make this number not too small, otherwise
you will link to identical data events from the sensors. Toggling from
good (=true) weather to bad always occurs immediately, toggling from
bad to good is only effective, if stable for at least
KEY_GOODSTABLE refresh cycles. Toggle times are always counted
from true toggles, i.e. the toggling to good might be prolonged.
To allow immediate notification of bad weather event, this class also
implements the EventTrigger interface.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class util.PropertyResources |
|---|
PropertyResources.URLResource |
| Field Summary | |
|---|---|
private Map<String,Boolean> |
absent
For logging to avoid flooding. |
private static int |
DEFGOODSTABLE
Per default we toggle immediately. |
private static long |
DEFREFRESH
The default refresh interval. |
private Boolean |
good
The current vote. |
private int |
goodcount
Count consecuetive godds after a bad. |
static String |
KEY_GOODSTABLE
The required refresh intervals to toggle from bad to good. |
static String |
KEY_REFRESH
The refreshing intervall in ms. |
static String |
KEY_WEATHERLIST
Points to the list of data values we depend our vote on. |
static String |
KEY_WEATHERTABLE
Points to the min/max pairs for the allowed range of the sensors. |
private Map<String,Vector2D> |
minmax
The mapping of names to their min/max. |
private List<String> |
sensors
This are the parameters we need to register to. |
private Object |
sleeper
This object is notified in case of weather changes. |
private Date |
toggle
The time we realized a weather toggle. |
private Map<String,Value> |
weather
The mapping of value names to the Value objects. |
| 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 | |
|---|---|
WeatherTrigger(Map<String,String> prop)
Constructs a new weather trigger. |
|
| Method Summary | |
|---|---|
void |
afterAll()
We start ourself after one refresh cycle and yell if parameters are missing. |
Date |
getLastToggleTime()
Returns the last toggle time or null, if weather has never toggled. |
long |
getRefreshInterval()
Our refresh interval. |
Boolean |
getTrigger()
Returns the current weather vote. |
private Map<String,Boolean> |
getVotes()
We go through the list of all sesnors and derive a vote for each. |
void |
init()
On init, we create the parameter list we register to and initialize the minmax table. |
boolean |
isFixedRate()
False. |
private void |
notifyMonitor()
The weather has changed. |
Object |
provideStatus()
The status is a string version of the votes table. |
void |
refresh()
On refresh, we check all registered values if their reading are in the appropriate range. |
Object |
registerMonitor(Object waiter)
Sets or unsets the monitor to receive weather changes. |
void |
registerParameter(Parameter p)
Registers a parameter. |
Boolean |
setTrigger(Boolean no)
This is not allowed. |
| Methods inherited from class stella.parameter.AbstractTrigger |
|---|
get, getElapsedToggleTime, isTrue, set, toggleTrigger |
| Methods inherited from class stella.parameter.AbstractParameter |
|---|
createParameter, delivers, exit, getFormatted, getFormatted, getName, getPreserveFile, getString, getString, register, rescanned, 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.ResourceSupplying |
|---|
getResource, getResourceAsStream, getResources |
| Field Detail |
|---|
public static final String KEY_WEATHERLIST
public static final String KEY_WEATHERTABLE
public static final String KEY_REFRESH
public static final String KEY_GOODSTABLE
private static final long DEFREFRESH
private static final int DEFGOODSTABLE
private List<String> sensors
private Map<String,Value> weather
private Map<String,Boolean> absent
private Map<String,Vector2D> minmax
private Date toggle
private Boolean good
private int goodcount
private Object sleeper
| Constructor Detail |
|---|
public WeatherTrigger(Map<String,String> prop)
| Method Detail |
|---|
public void init()
init in interface Initializableinit in class AbstractParameterpublic void registerParameter(Parameter p)
registerParameter in interface ParameterDependingpublic void afterAll()
afterAll in interface AfterRegisteringpublic long getRefreshInterval()
getRefreshInterval in interface Refreshingpublic boolean isFixedRate()
isFixedRate in interface RefreshingTimerpublic Boolean getTrigger()
getTrigger in interface Triggerpublic Boolean setTrigger(Boolean no)
setTrigger in interface Triggerpublic Date getLastToggleTime()
getLastToggleTime in interface Triggerpublic void refresh()
KEY_GOODSTABLE, which in the default
implementation is also immediate. If no object has been registered
to receive notification events, the current state of the weather might
still be ascertainable by a getTrigger() call.
refresh in interface Refreshingpublic Object provideStatus()
provideStatus in interface StatusProvidingpublic Object registerMonitor(Object waiter)
registerMonitor in interface EventTriggerprivate void notifyMonitor()
private Map<String,Boolean> getVotes()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||