public class ExperimentRunner extends java.lang.Object implements java.util.Observer, java.lang.Runnable, Parameterizable
Modifier and Type | Class and Description |
---|---|
static class |
ExperimentRunner.ReportProvider
An inner class providing the experiment runner's report.
|
Modifier and Type | Field and Description |
---|---|
static int |
CREATED
Status: model not connected to experiment
|
static java.lang.String |
EXP_D_OUTTYPE
Experiment setting "debugOutputType"
|
static java.lang.String |
EXP_E_OUTTYPE
Experiment setting "errorOutputType"
|
static java.lang.String |
EXP_EPSILON
Experiment setting "referenceTime"
|
static java.lang.String |
EXP_NAME
Experiment setting "name"
|
static java.lang.String |
EXP_OUTPUT_PATH
Experiment setting "outputPath"
|
static java.lang.String |
EXP_R_OUTTYPE
Experiment setting "reportOutputType"
|
static java.lang.String |
EXP_RAND_EVENTS
Experiment setting "randomizeConcurrentEvents"
|
static java.lang.String |
EXP_REF_TIME
Experiment setting "referenceTime"
|
static java.lang.String |
EXP_REF_UNIT
Experiment setting "referenceUnit"
|
static java.lang.String |
EXP_SHOW_PROG_BAR
Experiment setting "showProgressBar"
|
static java.lang.String |
EXP_START_TIME
Experiment setting "startTime"
|
static java.lang.String |
EXP_STOP_TIME
Experiment setting "stopTime"
|
static java.lang.String |
EXP_T_OUTTYPE
Experiment setting "traceOutputType"
|
static java.lang.String |
EXP_TRACE_START
Experiment setting "traceStartTime"
|
static java.lang.String |
EXP_TRACE_STOP
Experiment setting "traceStopTime"
|
static int |
INITIALIZED
Status: Model created an connected but experiment not started yet
|
static int |
PAUSED
Status: Experiment temporarily paused
|
static int |
RUNNING
Status: Experiment currently running
|
static int |
STOPPED
Status: Experiment finally stopped
|
Constructor and Description |
---|
ExperimentRunner()
Creates a new experiment runner that is not connected to a model yet.
|
ExperimentRunner(Model model)
Creates a new experiment runner for the given model
|
Modifier and Type | Method and Description |
---|---|
void |
addExperimentListener(ExperimentListener l)
Adds a listener to the contained experiment's running status
|
void |
addSimClockListener(SimClockListener l)
Adds a listener to the contained experiment's sim clock
|
void |
addSimRunListener(SimRunListener l)
adds a new SimRunListener.
|
java.util.Map<java.lang.String,AccessPoint> |
createParameters()
Creates a map of parameters
|
SimRunListener[] |
createSimRunListeners(GraphicalObserverContext c)
Should return a new set of listeners to the experiment run represented by
the given experiment runner in an array.
|
void |
finishExperiment()
Lets the experiment report (if desired) and closes all output streams by
calling
Experiment.finish() |
long |
getDelayMillis()
Returns the millisecond part of the delay between each step of the
scheduler
|
int |
getDelayNanos()
Returns the nanosecond part of the delay between each step of the
scheduler
|
Experiment |
getExperiment() |
java.util.Map<java.lang.String,AccessPoint> |
getExperimentSettings() |
java.lang.Object[][] |
getExperimentSettingsArray()
Returns an array of experiment settings for this experiment run The first
row contains names, the second row contains values.
|
Model |
getModel() |
java.lang.Object[][] |
getModelParameterArray()
Returns an array of model parameters for this experiment run The first
row contains names, the second row contains values.
|
java.util.Map<java.lang.String,AccessPoint> |
getModelParameters() |
TimeInstant |
getStartTime() |
TimeInstant |
getStopTime() |
java.lang.Thread |
getThread() |
void |
init()
Initializes the experiment before it is run in the thread
|
void |
initParameters(java.util.Map<java.lang.String,AccessPoint> expSettingsMap,
java.util.Map<java.lang.String,AccessPoint> modelParamMap)
Inits the experiment runner from a map of model and experiment
settings
|
void |
registerMessageReceivers()
Registers new message receivers as output channels of the experiment
|
void |
removeExperimentListener(ExperimentListener l)
Removes an experiment listener
|
void |
removeSimClockListener(SimClockListener l)
Removes a SimClock listener
|
void |
run()
Runs the contained experiment by calling it's appropriate start method
|
void |
setDelay(long millis,
int nanos)
Sets the delay between each step of the scheduler.
|
void |
setModel(Model model)
Sets the current model
|
void |
setPaused(boolean pause)
(Un)pauses running the assigned experiment by requiring and releasing the
semaphore tested in the experiments proceed loop.
|
void |
start()
Starts this thread and the contained experiment with start time 0.0
|
void |
stopExperiment()
Stops the experiment running in this experiment runner (forever).
|
void |
update(java.util.Observable o,
java.lang.Object value)
This method is implemented for interface observer.
|
public static final int CREATED
public static final int INITIALIZED
public static final int RUNNING
public static final int PAUSED
public static final int STOPPED
public static final java.lang.String EXP_NAME
public static final java.lang.String EXP_OUTPUT_PATH
public static final java.lang.String EXP_EPSILON
public static final java.lang.String EXP_REF_TIME
public static final java.lang.String EXP_REF_UNIT
public static final java.lang.String EXP_START_TIME
public static final java.lang.String EXP_STOP_TIME
public static final java.lang.String EXP_SHOW_PROG_BAR
public static final java.lang.String EXP_TRACE_START
public static final java.lang.String EXP_TRACE_STOP
public static final java.lang.String EXP_RAND_EVENTS
public static final java.lang.String EXP_R_OUTTYPE
public static final java.lang.String EXP_T_OUTTYPE
public static final java.lang.String EXP_E_OUTTYPE
public static final java.lang.String EXP_D_OUTTYPE
public ExperimentRunner(Model model)
public ExperimentRunner()
setModel()
method.public void setModel(Model model)
model
- a desmoj.Modelpublic Model getModel()
public void init()
public void initParameters(java.util.Map<java.lang.String,AccessPoint> expSettingsMap, java.util.Map<java.lang.String,AccessPoint> modelParamMap)
expSettingsMap
- map of experiment settingsmodelParamMap
- map of model parameterspublic Experiment getExperiment()
public TimeInstant getStartTime()
public TimeInstant getStopTime()
public void start()
public void stopExperiment()
public void run()
run
in interface java.lang.Runnable
public void finishExperiment()
Experiment.finish()
public void update(java.util.Observable o, java.lang.Object value)
update
in interface java.util.Observer
o
- an observable objectvalue
- the updated valuepublic void setPaused(boolean pause)
pause
- boolean value indicating pause (true
) or
restart (false
).public long getDelayMillis()
public int getDelayNanos()
public void setDelay(long millis, int nanos)
delay:
- Delay time in milliseconds as a long valuepublic void addExperimentListener(ExperimentListener l)
public void removeExperimentListener(ExperimentListener l)
public void addSimClockListener(SimClockListener l)
public void removeSimClockListener(SimClockListener l)
public void addSimRunListener(SimRunListener l)
public java.lang.Object[][] getModelParameterArray()
public java.lang.Object[][] getExperimentSettingsArray()
public java.util.Map<java.lang.String,AccessPoint> getModelParameters()
public java.util.Map<java.lang.String,AccessPoint> getExperimentSettings()
public java.lang.Thread getThread()
public java.util.Map<java.lang.String,AccessPoint> createParameters()
Parameterizable
createParameters
in interface Parameterizable
public void registerMessageReceivers()
public SimRunListener[] createSimRunListeners(GraphicalObserverContext c)