public class EnvironmentSimulator extends GenericSimulator implements WeatherListener
NoRoof error that
may occur any time. The weather errors are cast by the weather station which
also serves the weather trigger. The weather station should use pre-recorded
'real' weather data, see FakeSensor.OpenRoof, CloseRoof, and
StatusEnvironment. All commands have a single acknowledge event. The
time sent back in the acknowledge is handled in the super class.OpenRoof and CloseRoof may fail with a
CannotOpenRoof or a CannotCloseRoof error, respectively. The
probabilities for failures are KEY_OPENFAIL and
KEY_CLOSEFAIL. If successfully conducted the roof-open trigger is
toggled.StatusEnvironment produces a random status event which
carries the correct weather condition, but has random numbers in the sensor
readings. It is always sent prior to method return.ReceiverTorso.CommandHandlerPropertyResources.Load, PropertyResources.URLResource| Modifier and Type | Field and Description |
|---|---|
private static String[] |
ACKTIMES
The acknowledge times for the known commands.
|
private static String[] |
COMMANDS
The known command types, used for acknowledges.
|
private static double |
DEFCLOSEFAIL
The default closinging failure probability .
|
private static String |
DEFERRORCLASSES
The default error list.
|
private static String |
DEFERRORPROBABILITIES
The default error probabilities.
|
private static String |
DEFFAKE
The default properties of the fake weather station.
|
private static String |
DEFISOPEN
The default name of the roof-is-open trigger.
|
private static double |
DEFOPENFAIL
The default opening failure probability .
|
private static double |
DEFPOWERFAIL
The default power-switching failure probability .
|
private static String |
DEFSET
The default properties of the parameter set of the simulator.
|
private static String[] |
DIVERT
The actual divert factors for the commands.
|
private static String[] |
DONETIMES
The 'true' command execution times.
|
private WeatherSurveying |
fake
The weather station.
|
static String |
KEY_CLOSEFAIL
The key to the sleep-time for an open-roof command.
|
static String |
KEY_FAKE
The key to the properties of the fake weather station.
|
static String |
KEY_ISOPEN
The key to the name of the is-open trigger.
|
static String |
KEY_OPENFAIL
The key to the sleep-time for an open-roof command.
|
static String |
KEY_POWERFAIL
The key to the probability of power-switch failure.
|
private ErrorEvent |
lasterror
The error event if command execution fails.
|
ACKNOWLEDGEPREFIX, DEFUNIQUE, DEVIATEPREFIX, DONEPREFIX, KEY_ACCELERATE, KEY_ERRORCLASSES, KEY_ERRORINTERVAL, KEY_ERRORPROBABILITIES, KEY_GENERICACKNOWLEDGE, KEY_GENERICDEVIATE, KEY_GENERICDONE, KEY_SET, KEY_UNIQUE, randomKEY_BIND, KEY_BINDNAME, KEY_COMMANDCASTER, KEY_ERRORCOOLKEY_ALIVE, KEY_EXPORTPORT, KEY_INIT, KEY_LISTENERNAME, KEY_RETRY, KEY_RETRYSLEEP, KEY_SHUTDOWNDELAYKEY_NOINITONCREATE, POSTFIX_ALPHABET, POSTFIX_BYTES, POSTFIX_DIR, POSTFIX_EXT, POSTFIX_FILE, POSTFIX_LIST, POSTFIX_MODTIME, POSTFIX_URLKEY_LISTSEPARATOR, KEY_MAPKEYVALUECHAR, KEY_MAPSEPARATORNAMING_EXTENSIONNAMING_EXTENSIONKEY_INITDEPTHKEY_URLRESOURCES, KEY_URLUSECONFIG, KEY_URLUSECURRENT, KEY_URLUSEHOMECONFIG, KEY_CLASS| Constructor and Description |
|---|
EnvironmentSimulator(Map prop)
Constructs a new environment simulator.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
accepts(CommandEvent ce)
Returns true if this receiver accepts commands of the type handed over as
an argument.
|
protected ErrorEvent |
getLastError()
Returns the last error that occured during command processing.
|
void |
init2()
Initializes the weather station.
|
void |
initStep(int curstep)
Initializes the weather station.
|
protected boolean |
isAllowed(ErrorEvent ee)
Checks if the error handed over is currently allowed to be thrown.
|
static void |
main(String[] arg)
Constructs a new environment simulator.
|
private static Map |
myAugment(Map def)
Augments the properties three times, for acknowledge and done times and
for divert factors.
|
protected boolean |
processCommand(CommandEvent ce,
int acknr)
Simulated command processing.
|
void |
weatherChanged(WeatherEvent we)
The weather event receiving edge of the environment master.
|
augmentProperties, exit, formatWithGlobals, getAcknowledgeNumber, getCompletionTime, getNoisyTime, getParameter, getParameterByKey, getParameterByName, getParameterCluster, getParameterValueByKey, getParameterValueByName, getSimulationTime, getTrigger, getUnique, getValue, setParameter, setParameterValueByKey, setParameterValueByName, setTrigger, setValue, shutdown, sleepFor, statusSimulatoraddRmiAcknowledgeListener, addRmiDoneListener, bindDefault, containsRemoteProperty, deregisterAtCaster, equals, getLastError, getRemoteProperties, getRemoteProperty, hashCode, notifyAcknowledgeListener, notifyDoneListener, registerAtCaster, removeRmiAcknowledgeListener, removeRmiDoneListener, rescanned, rmiCommand, sendAllPrematureDone, sendPrematureDone, setLastError, setRemoteProperty, toString, unbindDefaultaddErrorListener, addRmiErrorListener, bindToRegistry, getBindName, isValid, notifyErrorListener, removeErrorListener, removeRmiErrorListener, sendError, sendError, sendError, sendStatus, sendStatus, sendStatus, unbindFromRegistryallBound, blockBinding, blockBinding, disconnect, getIP, getListenerName, isConnected, listenerName, releaseBinding, releaseBinding, startBinding, startBindingclone, 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, setObject, setProperties, setProperty, stringPropertiesfinalize, getClass, notify, notifyAll, wait, wait, waitbindToRegistry, isValid, unbindFromRegistryaddErrorListener, removeErrorListenergetListenerNamedisconnect, isConnecteddefaultBoolean, 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_OPENFAIL
public static final String KEY_CLOSEFAIL
public static final String KEY_POWERFAIL
public static final String KEY_FAKE
public static final String KEY_ISOPEN
private static final double DEFOPENFAIL
private static final double DEFCLOSEFAIL
private static final double DEFPOWERFAIL
private static final String DEFFAKE
private static final String DEFSET
private static final String DEFISOPEN
private static final String DEFERRORCLASSES
private static final String DEFERRORPROBABILITIES
private static final String[] COMMANDS
private static final String[] ACKTIMES
private static final String[] DONETIMES
private static final String[] DIVERT
private WeatherSurveying fake
private ErrorEvent lasterror
public EnvironmentSimulator(Map prop) throws RemoteException
RemoteExceptionprivate static Map myAugment(Map def)
public void initStep(int curstep)
throws InitException
FakeSensor
sensors only.initStep in interface StepInitializableinitStep in class GenericSimulatorInitExceptionpublic void init2()
FakeSensor
sensors only.public boolean accepts(CommandEvent ce) throws RemoteException
EnvironmentCommands.accepts in interface RmiCommandListenerRemoteExceptionprotected boolean isAllowed(ErrorEvent ee)
NoRoof error is always allowed.isAllowed in class GenericSimulatorprotected ErrorEvent getLastError()
public void weatherChanged(WeatherEvent we)
#direct method. Here, the weather event is checked for bad
weather. If so, the roof operator gets directly a signal to close the
roof without waiting for a close-roof from the default command caster.
Note that closing of the roof is only allowed in robotic mode.weatherChanged in interface WeatherListenerprotected boolean processCommand(CommandEvent ce, int acknr)
StatusEnvironment, go to sleep, then
generate a status command from the weather station and the current
roof-open trigger, send it back and return true.GenericSimulator.getSimulationTime(stella.CommandEvent, int). Now, generate a random number and match it to
the failure probabilities of these commands, KEY_OPENFAIL and
KEY_CLOSEFAIL, respectively. If a failure is indicated, return
false and update the last-error which will be fetched by the
ReceiverTorso. If everything is correct, update the
roof-trigger and return true.processCommand in class GenericSimulatorpublic static void main(String[] arg) throws RemoteException
RemoteException