SimExec
Class Executive

java.lang.Object
  |
  +--SimExec.Executive

public class Executive
extends java.lang.Object

Executive class to control a 3 phase simulation in which entity records are held in a Vector (details) and from which a temporary Vector (dueList) is created at each time beat to contain those entities with events due at the current event time. Entities are added to the details Vector before the start of an aPhase and unwanted entities are also deleted then. Bs are assumed part of application entity classes, represented by integers & Cs as belonging to the application alone Revised August 2000, consistent syntax


Constructor Summary
Executive()
          Simple constructor, sets trace and traceEverOn fields to false so that no debug.txt file is created unless it is required.
 
Method Summary
static void addC(Activity thisC)
          Adds a new C to the end of the CList
static void addNewEntity(GEntity thisEnt)
          Called in user program when a new entity is to be added.
static void cPhase()
          Causes Cs to be attempted until none succeed.
static void destroyEntity(GEntity thisEnt)
          Called in user program when an entity is to be destroyed.
static long getClock()
          Returns with the current value of the simulation time.
static GEntity getCurrEnt()
          Returns with the current entity - that is, the entity whose B is about to be processed or is being processed currently.
static long getRunDuration()
          Returns with the intended duration of the simulation
static boolean getTrace()
          Returns with the boolean value of trace.
static boolean getTraceEverOn()
          Returns with the boolean value of traceEverOn.
static void schedule(GEntity thisEnt, Activity nextActivity, long time)
          Used when an entity needs to be committed to a B at some future time.
static void setCStarted()
          Sets CStarted as true to indicate that a C has been executed during the current C phase.
static void setRunDuration(long duration)
          Allows the user to set the planned duration of the simulation.
static void setTrace(boolean thisState)
          Sets the current value of trace to the indicated boolean state.
static void simulate()
          Executes a complete 3 phase cycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Executive

public Executive()
Simple constructor, sets trace and traceEverOn fields to false so that no debug.txt file is created unless it is required.
Method Detail

getClock

public static long getClock()
Returns with the current value of the simulation time.

setRunDuration

public static void setRunDuration(long duration)
Allows the user to set the planned duration of the simulation.

getRunDuration

public static long getRunDuration()
Returns with the intended duration of the simulation

setTrace

public static void setTrace(boolean thisState)
Sets the current value of trace to the indicated boolean state. If this is true, then a debug.txt file will be created. It's probably best only to set this at the start of a simulation run. The variable traceEverOn will be true if the value of trace has ever been true during a simulation run.

getTraceEverOn

public static boolean getTraceEverOn()
Returns with the boolean value of traceEverOn.

getTrace

public static boolean getTrace()
Returns with the boolean value of trace.

getCurrEnt

public static GEntity getCurrEnt()
Returns with the current entity - that is, the entity whose B is about to be processed or is being processed currently. GEntity is defined as part of the SimObs package.

destroyEntity

public static void destroyEntity(GEntity thisEnt)
Called in user program when an entity is to be destroyed. Places the entity on an temporary Vector, toBeKilled. The entities in toBeKilled are actually killed just before the start of the next aPhase.

addNewEntity

public static void addNewEntity(GEntity thisEnt)
Called in user program when a new entity is to be added. Places the entity on an temporary Vector, NewEntities, from which the new entities are added just before the start of the aPhase.

schedule

public static void schedule(GEntity thisEnt,
                            Activity nextActivity,
                            long time)
Used when an entity needs to be committed to a B at some future time. Checks whether the entity is currently available. If not, this means that it is already committed to a B and so there is a fatal error thrown. Checks whether the interval between the current simulation clock time and the due time of the B is within range, corrects it if not. Calls the commit method of the entity to update its values in the details Vector. Declared as static, permits only a single executive.

addC

public static void addC(Activity thisC)
Adds a new C to the end of the CList

setCStarted

public static void setCStarted()
Sets CStarted as true to indicate that a C has been executed during the current C phase.

cPhase

public static void cPhase()
Causes Cs to be attempted until none succeed. Works down cList, firing each C in turn. Any successful C causes cStarted to be set to true, leading to a re-scan.

simulate

public static void simulate()
Executes a complete 3 phase cycle