scorej
Class Scenario

java.lang.Object
  |
  +--scorej.Scenario
Direct Known Subclasses:
SimpleJiniNode, SimpleNode, TestResources, TestScenario

public abstract class Scenario
extends java.lang.Object

Abstract base class for all ScoreJ scenarios.


Field Summary
protected  double _realTimeFactor
           
protected  boolean _realTimeP
           
protected  boolean _reportP
           
protected  java.lang.String _scenarioName
           
 
Constructor Summary
Scenario()
          Default constructor creates an instance of Scenario class.
Scenario(java.lang.String name)
          Constructor taking name of the scenario as argument.
 
Method Summary
 java.lang.String getName()
          Getter for scenario name.
 void initializeScenario()
          Initializes the scenario.
 void initializeScenario(OmarClock clock, boolean isClockDaemonThread)
          Initializes the scenario at the node.
 void pauseScenario()
          Call this method to pause a currently running scenario.
 void resumeScenario()
          Call this method to resume a paused scenario.
 void scenarioInit()
          This handler is invoked as the last step of scenario initialization.
 void scenarioPause()
          This handler is invoked after scenario is paused.
abstract  void scenarioProcedure()
          This method gets called when startScenario is called.
 void scenarioResume()
          This handler is invoked after scenario is resumed after a pause.
 void scenarioStop()
          This handler is invoked after scenario is stopped.
 void setName(java.lang.String name)
          Setter for scenario name.
 void setRealTime(boolean rt, double rtF)
          Call this method to specify whether the node clock and, hence, this scenario should be run in the real time mode and the real time factor to speed up or slow down the clock and hence the scenario.
 void setReportP(boolean rp)
           
 void startLogger()
          Starts logging at the node.
 java.lang.Thread startScenario()
          Starts the scenario.
 void stopScenario()
          Call this method to stop a currently running or paused scenario.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_realTimeP

protected boolean _realTimeP

_realTimeFactor

protected double _realTimeFactor

_reportP

protected boolean _reportP

_scenarioName

protected java.lang.String _scenarioName
Constructor Detail

Scenario

public Scenario(java.lang.String name)
Constructor taking name of the scenario as argument.


Scenario

public Scenario()
Default constructor creates an instance of Scenario class. the name of the scenario is set to getClass().getName().

Method Detail

setName

public void setName(java.lang.String name)
Setter for scenario name.


getName

public java.lang.String getName()
Getter for scenario name.


setRealTime

public void setRealTime(boolean rt,
                        double rtF)
Call this method to specify whether the node clock and, hence, this scenario should be run in the real time mode and the real time factor to speed up or slow down the clock and hence the scenario.

Parameters:
rt - true if the clock is to be run in real time node, false otherwise.

setReportP

public void setReportP(boolean rp)

startLogger

public void startLogger()
Starts logging at the node.


initializeScenario

public void initializeScenario()
Initializes the scenario. This default implemtation causes the the default clock class in the node to be initialized and set to run as a daemon thread.


initializeScenario

public void initializeScenario(OmarClock clock,
                               boolean isClockDaemonThread)
Initializes the scenario at the node. This method also allows one to specify which clock to use at the node and whether the clock should be run as a daemon thread. This method invokes the scenarioInit() handler as the last step of scenario initialization.

Parameters:
clock - the clock object to use. Specifying a value of null causes the default clock at the node to be used.
isClockDaemonThread - whether the clock thread should be run as a daemon thread, so that it will stop when all non-daemon threads come to an end.

startScenario

public java.lang.Thread startScenario()
Starts the scenario. If scenario is not already running, this method starts the clock if not already started and then calls scenarioProcedure().


resumeScenario

public void resumeScenario()
Call this method to resume a paused scenario.


pauseScenario

public void pauseScenario()
Call this method to pause a currently running scenario. This method invokes the scenarioPause() handler after the scenario is paused.


stopScenario

public void stopScenario()
Call this method to stop a currently running or paused scenario. This method invokes the scenarioStop() handler after the scenario is stopped.


scenarioInit

public void scenarioInit()
This handler is invoked as the last step of scenario initialization. Base class implementation does nothing. Users should override this method to perform custom initialization.


scenarioPause

public void scenarioPause()
This handler is invoked after scenario is paused. Base class implementation does nothing. Users should override this method to perform custom actions after scenario is paused.


scenarioResume

public void scenarioResume()
This handler is invoked after scenario is resumed after a pause. Base class implementation does nothing. Users should override this method to perform custom actions after scenario is paused.


scenarioStop

public void scenarioStop()
This handler is invoked after scenario is stopped. Base class implementation does nothing. Users should override this method to perform custom clean up actions after scenario is stopped.


scenarioProcedure

public abstract void scenarioProcedure()
This method gets called when startScenario is called. Users should implement this method to construct the main body of the scenario.