public abstract class GenericSimulator extends ReceiverTorso
KEY_ACCELERATE time acceleration key. Together with the
sleepFor(long) method this defines the real-time sleep for command
processing.getCompletionTime(stella.CommandEvent, int). To do this, the properties are scanned at startup
for keys starting with ACKNOWLEDGEPREFIX. These keys are considered
to link command types to expected acknowledge times which are given as the
key values as a comma-separated list of longs. During startup, a look-up
table is constructed linking command types to lists of Integers giving the
acknowledge times. If a command is received that is unknown, the value of the
KEY_GENERICACKNOWLEDGE property is used.KEY_ERRORCLASSES that might happen
at any time, not necessarily within a command cycle. This error should be
very general, back-reaction of the current state of the system is only
possible via the abstract isAllowed(stella.ErrorEvent) method.KEY_ERRORCLASSES list, a list of probabilities of
error occurance KEY_ERRORPROBABILITIES. Must be of the same size as
the KEY_ERRORCLASSES list.KEY_ERRORINTERVAL key. After one error intervall, one of
the errors from the list is randomly picked. A random number is generated and
a concrete error class instance is thrown if the random number generated is
smaller then the error probability. An error-occurence intervall of zero
means no errors (besides command-realted errors).sleepFor(long) method to allow acceleration.ExposeAdapter). Note that
these status events and the error events generated during command processing
may require special treatment depending on device state.ReceiverTorso.CommandHandlerPropertyResources.Load, PropertyResources.URLResource| Modifier and Type | Field and Description |
|---|---|
private Map |
acknowledge
A look-up table linking command types to acknowledge times.
|
static String |
ACKNOWLEDGEPREFIX
The prefix for properties defining acknowledge times for commands.
|
private static double |
DEFACCELERATE
The default time-acceleration factor.
|
private static long |
DEFERRORINTERVAL
The default error-occurence intervall.
|
private static long |
DEFGENERICACKNOWLEDGE
The default generic acknoledge time.
|
private static double |
DEFGENERICDEVIATE
The default generic time deviation.
|
private static long |
DEFGENERICDONE
The default generic done time.
|
private static long |
DEFSHUTDOWNDELAY
The default shutdown delay time, 5 sec.
|
static String |
DEFUNIQUE
The default name of the unique name identifier string.
|
private static String |
DEFURLRESOURCES
For convenience, a default URL-resource.
|
private Map |
deviate
A look-up table linking command types to completion time deviations.
|
static String |
DEVIATEPREFIX
The prefix for properties defining complete time deviations.
|
private Map |
done
A look-up table linking command types to 'real' completion times.
|
static String |
DONEPREFIX
The prefix for properties defining complete times for commands.
|
private List |
errors
A list of Classes generated from
KEY_ERRORCLASSES. |
static String |
KEY_ACCELERATE
The key to a time acceleration.
|
static String |
KEY_ERRORCLASSES
A list of error-class names that may occur outside of a command cycle.
|
static String |
KEY_ERRORINTERVAL
The generic error interval.
|
static String |
KEY_ERRORPROBABILITIES
A list of probabilities for the errors in
KEY_ERRORCLASSES. |
static String |
KEY_GENERICACKNOWLEDGE
The key to a default acknowledge time for unknown commands.
|
static String |
KEY_GENERICDEVIATE
The key to a default completion time deviation.
|
static String |
KEY_GENERICDONE
The key to a default completion time for unknown commands.
|
static String |
KEY_SET
The key to the parameteres served by the simulator.
|
static String |
KEY_UNIQUE
The unique name identifier string for acquire and guiding.
|
private String |
lastdate
For naming of acquire/guide frames.
|
private Timer |
occur
A timer scheduling out-of-command-cycle errors.
|
private List |
probs
A list of Doubles generated from
KEY_ERRORPROBABILITIES. |
protected static Random |
random
A pseudo-random number generator.
|
private ParameterClustering |
set
Parameter cluster for all subclasses.
|
private static int |
SETPRIORITY
The priority of the set exit.
|
private int |
targetcount
The target acquired at this date.
|
KEY_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| Modifier | Constructor and Description |
|---|---|
protected |
GenericSimulator(Map prop)
Constructs a new generic simulator.
|
| Modifier and Type | Method and Description |
|---|---|
protected static Map<String,String> |
augmentProperties(Map<String,String> target,
String prefix,
String[] keys,
String[] values)
Puts additional properties to the properties handed over.
|
void |
exit()
Exits the generic set.
|
protected String |
formatWithGlobals(String fill,
Map<String,Object> extern)
Formatting a fits file name from a place-holder supplied.
|
int |
getAcknowledgeNumber(CommandEvent ce)
Returns the expected acknowledge number.
|
protected long |
getCompletionTime(CommandEvent cmd,
int acknr)
Returns the acknowledge time for the argumental command, with given
acknowledge-cycle number.
|
protected long |
getNoisyTime(long base,
double divert)
Calculates a simulated command execution time.
|
protected Parameter |
getParameter(String name)
Returns the paramter named as stated or null.
|
Parameter |
getParameterByKey(String key)
Access to a parameter from its property key.
|
Parameter |
getParameterByName(String name)
Access to a paramter by its name.
|
protected ParameterClustering |
getParameterCluster()
Returns the generic parameter cluster.
|
Object |
getParameterValueByKey(String key)
Access to a parameter value by the parameter key.
|
Object |
getParameterValueByName(String name)
Access to a parameter value by the parameter name.
|
protected long |
getSimulationTime(CommandEvent cmd,
int acknr)
Returns the completion time actually used by the simulator, e.g.
|
protected Boolean |
getTrigger(String name)
Returns the trigger named as stated or null.
|
String |
getUnique()
Returns the value of the unique parameter, or, if this is not accessible
a 'home-made' version of it.
|
protected Number |
getValue(String name)
Returns the value named as stated or null.
|
private void |
init1()
Initialization, second step.
|
private void |
init4()
Creates the error scheduler.
|
void |
initStep(int curstep)
Initializes the generic simulator.
|
protected abstract boolean |
isAllowed(ErrorEvent ee)
Checks if the current state of the system allows the generic error handed
over to be cast to an error handler.
|
protected boolean |
processCommand(CommandEvent cmd,
int acknr)
Processes the given command.
|
protected Object |
setParameter(String name,
Object value)
Sets a parameter of the generic set to the given value.
|
Object |
setParameterValueByKey(String key,
Object newval)
Set a parameter value with the parameter key.
|
Object |
setParameterValueByName(String name,
Object newval)
Set a parameter value with the parameter name.
|
protected Boolean |
setTrigger(String name,
Boolean value)
Sets a trigger of the generic set to the given value.
|
protected Number |
setValue(String name,
Number value)
Sets a value of the generic set to the given value.
|
protected void |
shutdown()
Quits the currently running java VM with a System.exit call.
|
protected void |
sleepFor(long ms)
Sleeps for the specified amount of time.
|
String |
statusSimulator()
A default status implementation.
|
addRmiAcknowledgeListener, 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, removeErrorListeneracceptsgetListenerNamedisconnect, 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_UNIQUE
public static final String KEY_SET
public static final String KEY_ACCELERATE
public static final String KEY_GENERICACKNOWLEDGE
public static final String KEY_GENERICDONE
public static final String KEY_GENERICDEVIATE
public static final String KEY_ERRORCLASSES
public static final String KEY_ERRORPROBABILITIES
KEY_ERRORCLASSES.public static final String KEY_ERRORINTERVAL
public static final String ACKNOWLEDGEPREFIX
public static final String DONEPREFIX
public static final String DEVIATEPREFIX
public static final String DEFUNIQUE
private static final String DEFURLRESOURCES
private static final double DEFACCELERATE
private static final long DEFGENERICACKNOWLEDGE
private static final long DEFGENERICDONE
private static final double DEFGENERICDEVIATE
private static final long DEFERRORINTERVAL
private static final long DEFSHUTDOWNDELAY
private ParameterClustering set
private Map acknowledge
private Map done
private Map deviate
private List errors
KEY_ERRORCLASSES.private List probs
KEY_ERRORPROBABILITIES.private Timer occur
private static final int SETPRIORITY
protected static Random random
private String lastdate
private int targetcount
protected GenericSimulator(Map prop)
KEY_ACCELERATE and
KEY_ERRORINTERVAL.public void initStep(int curstep)
throws InitException
initStep in interface StepInitializableinitStep in class ReceiverTorsoInitExceptionpublic void exit()
exit in interface ExitCleaningexit in class ReceiverTorsoprivate void init1()
private void init4()
protected ParameterClustering getParameterCluster()
protected Parameter getParameter(String name)
protected Object setParameter(String name, Object value)
protected Number setValue(String name, Number value)
protected Boolean setTrigger(String name, Boolean value)
public Parameter getParameterByName(String name)
public Parameter getParameterByKey(String key)
public Object getParameterValueByName(String name)
public Object getParameterValueByKey(String key)
public Object setParameterValueByName(String name, Object newval)
public Object setParameterValueByKey(String key, Object newval)
protected static Map<String,String> augmentProperties(Map<String,String> target, String prefix, String[] keys, String[] values)
This method is used in conjuncture with construction of non-abstract daugther simulators.
target - The properties that need additional mappings.prefix - A String to prefix before any key.keys - The individual keys.values - The mapping values to the keysprotected boolean processCommand(CommandEvent cmd, int acknr)
The method returns true if the (sub)task was executed without an error.
If it returns false the appropriate error event must be ready for
retrival using the #getLastError() method.
processCommand in class ReceiverTorsoprotected void shutdown()
public String statusSimulator()
public int getAcknowledgeNumber(CommandEvent ce)
getAcknowledgeNumber in class ReceiverTorsoprotected long getCompletionTime(CommandEvent cmd, int acknr)
acknowledge
map whether the command type can be found. If so, the matching list is
queried for the cycle-number element, which is a Long carrying the
required acknowledge time-out. If the command handed over is not found, a
generic acknowledge time, KEY_GENERICACKNOWLEDGE is returned.getCompletionTime in class ReceiverTorsocmd - The command to process.acknr - The number of the acknowledge that will be sent back.protected long getSimulationTime(CommandEvent cmd, int acknr)
This method does not delay program execution, daughter classes must call
the sleepFor(long) method explicetly.
protected void sleepFor(long ms)
ms - The sleeping time in ms.protected long getNoisyTime(long base,
double divert)
KEY_GENERICDEVIATE or the command-based DEVIATEPREFIX
property.protected String formatWithGlobals(String fill, Map<String,Object> extern)
If unmatched parenthesis are encountered, the input string is returned.
public String getUnique()
protected abstract boolean isAllowed(ErrorEvent ee)