|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcz.cuni.pogamut.experiments.AbstractExperimentHandle
cz.cuni.pogamut.experiments.Experiment
public abstract class Experiment
Provides common infrastructure for creating new types of experiments. You have to override three stage* methods to write your own type of experiment. These methods will be called by the framework, don't call them by yourself as it may result in unpredictable behaviour. Call setResult() to finish your experiment when the result was computed otherwise call handleException() exit without returning the result. Don't call stageThreeFinis() to quit your experiment. Framework will call this method from the two mentioned above.
Possible orders of execution states:
Field Summary | |
---|---|
private ExperimentDescriptor |
descriptor
Descriptor used to initialize this experiment. |
protected Flag<ExperimentExecutionState> |
experimentState
Flag with actual state of experiment. |
private java.lang.Thread |
experimentThread
Note that this thread usually terminates after the experiment is started, this serves only for the startup phase to complete in separate thread. |
private java.util.logging.Logger |
log
Log of the experiment. |
private UTServer |
server
Interface to the world of UT2004. |
(package private) FlagListener<UTServerState> |
serverStateListener
UTServer state listener, if server state is switched to PAUSED then pause the experiment as well and vice versa. |
protected TimeProvider |
timeProvider
Object for retrieving actual time of sim. |
protected Timer |
timer
Timer used to schedule events in experiment. |
Fields inherited from class cz.cuni.pogamut.experiments.AbstractExperimentHandle |
---|
exception, experimentRunningLatch, result, stateFlag |
Constructor Summary | |
---|---|
protected |
Experiment(ExperimentDescriptor descriptor,
UTServer server)
Creates a new instance of Experiment |
Method Summary | |
---|---|
ExperimentDescriptor |
getDescriptor()
|
Experiment |
getExperiment()
Returns this. |
Flag<ExperimentExecutionState> |
getExperimentExecutionFlag()
Execution state of the experiment. |
java.util.logging.Logger |
getLogger()
|
java.lang.String |
getName()
Return name of the experiment. |
UTServer |
getServer()
|
TimeProvider |
getTimeProvider()
|
protected void |
handleException(java.lang.Exception e)
Writes exception to the log and stops experiment (sets state to FAILED). |
protected void |
handleReplay()
Starts replay recording if it is set in the descriptor. |
void |
runExperiment()
Starts the experiment. |
private void |
setExperimentState(ExperimentExecutionState state)
|
void |
setResultAndTerminate(ExperimentResult result)
Sets result of this experiment and TERMINATE the experiment. |
void |
schedule(TimerTask task,
long delay)
Schedules task for execution. |
protected abstract void |
stageOneInit()
Initializes all resources that the experiment may need (eg. rule engine). |
protected abstract void |
stageThreeFinish()
Release resources used by the experiment, should stop running threads etc. |
protected abstract void |
stageTwoStart()
Runs the experiment, always called after stageOneInit(). |
void |
stop()
Aborts execution of the experiment, disconnect all bot and calls stageThreeFinish(). |
Methods inherited from class cz.cuni.pogamut.experiments.AbstractExperimentHandle |
---|
getException, getResult |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface cz.cuni.pogamut.experiments.ExperimentHandle |
---|
getException, getResult |
Field Detail |
---|
protected TimeProvider timeProvider
protected Timer timer
private UTServer server
private ExperimentDescriptor descriptor
FlagListener<UTServerState> serverStateListener
private java.lang.Thread experimentThread
private java.util.logging.Logger log
protected Flag<ExperimentExecutionState> experimentState
Constructor Detail |
---|
protected Experiment(ExperimentDescriptor descriptor, UTServer server)
Method Detail |
---|
protected abstract void stageOneInit() throws java.lang.Exception
java.lang.Exception
protected abstract void stageTwoStart() throws java.lang.Exception
java.lang.Exception
protected abstract void stageThreeFinish()
public final void runExperiment()
protected void handleReplay() throws PogamutException
PogamutException
public void setResultAndTerminate(ExperimentResult result)
public void schedule(TimerTask task, long delay)
public Experiment getExperiment()
getExperiment
in interface LocalExperimentHandle
public Flag<ExperimentExecutionState> getExperimentExecutionFlag()
getExperimentExecutionFlag
in interface ExperimentHandle
getExperimentExecutionFlag
in class AbstractExperimentHandle
public java.util.logging.Logger getLogger()
getLogger
in interface LocalExperimentHandle
private void setExperimentState(ExperimentExecutionState state)
public void stop()
stop
in interface ExperimentHandle
protected void handleException(java.lang.Exception e)
public TimeProvider getTimeProvider()
public java.lang.String getName()
getName
in interface ExperimentHandle
public UTServer getServer()
public ExperimentDescriptor getDescriptor()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |