|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.lang.Thread
org.mitre.sim.api3.Simulation
Abstract class used to create a simulation.
An instance of a Simulation
subclass
is associated with a group of entities sharing a common
definition of simulation time.
When an instance of an
Entity
subclass is created,
it must be associated with an instance of a
Simulation
subclass.
This is done with the
register
method in class
Simulation
or
register
in class
Entity
.
Usually there is only one instance of a
Simulation
subclass but
more than one may exist.
If a program has more than one instance,
each will be a separate and independent simulation.
Copyright © 2003-2004 The MITRE Corporation
Field Summary |
Fields inherited from class java.lang.Thread |
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Constructor Summary | |
Simulation()
|
Method Summary | |
Population |
createPopulation(java.lang.Class c)
Create a Population of Class c entities. |
void |
displayEntities(java.lang.String message)
Deprecated. Display a table of the simulation Entities catagorized by
current state.
Used to test Executive implementations and not needed
by simulation developers. |
java.util.logging.Logger |
getEntityLogger()
Return the logger used by all Entity instances and subclasses. |
java.util.logging.Logger |
getExecLogger()
Return the logger used by the simulation executive. |
Executive |
getExecutive()
Deprecated. Used to test Executive implementations and is not needed
by simulation developers. |
java.util.logging.Logger |
getFlowLogger()
Return the logger used by the flow manager. |
java.util.logging.Logger |
getLogger(java.lang.String loggerName)
Return the logger of the specified name. |
long |
getPace()
Return the current pave setting. |
java.util.logging.Logger |
getSimLogger()
Return the logger used by the Simulation instance. |
java.util.Properties |
getSubProperties(java.lang.String prefix,
java.util.Properties origProps)
|
void |
info(java.lang.String message)
Convenience method that concatenates the current simulation time, Simulation
subclass name, and the supplied message
string before it is logged to the Simulation
logger as an info level message. |
abstract void |
initialize()
Create the initial simulation environment. |
void |
msg(java.lang.String message)
Deprecated. Please see info(String) . |
void |
pauseSimulation()
Used by an external thread to pause the Executive. |
Entity |
register(Entity e)
Affiliate a new entity with this simulation. |
void |
resumeSimulation()
Used by an external thread to resume the Executive. |
void |
run()
Execute the simulation. |
void |
setPace(long period)
Set the minimum amount of real time that must pass before the simulation advances one unit of simulation time. |
void |
setTimeLast(double t)
Specify the last value of time to be simulated before the simulation stops. |
void |
setVisible(boolean flag)
Enables/Disables the GUI for this simulation |
void |
simulationComplete()
Overload if simulation completion notification is desired. |
void |
start()
Execute the simulation using a new thread. |
java.lang.String |
version()
Returns the version of the classes implementing interface Executive and Flow. |
Methods inherited from class java.lang.Thread |
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, stop, stop, suspend, toString, yield |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public Simulation()
Method Detail |
public final Entity register(Entity e)
Entity.register(Entity)
method.
e
- Entity instance being registered
Entity
supplied by parameter e
.Entity.register(Entity)
public abstract void initialize()
initialize
is used to create and
register
the initial
set of entities.
Once the initialize
method returns, the executive
begins the advance of simulation time by selecting the first entity for activation.
public void simulationComplete()
simulationComplete
method
gives the simulation developer a place
to put code that will be executed unconditionally at the end of the simulation's life.
Entity.entityComplete()
public final void run()
run
performs the following three operations:
initialize
method.
agendas
or
until the timeLast
value of simulation time is reached.
simulationComplete
method.
run
blocks until the simulation is finished.
If blocking is not desired, use method start
to execute a simulation.
start()
,
setTimeLast(double)
,
Executive.startSimulation()
public final void start()
start
performs the following three operations:
initialize
method.
agendas
or
until the timeLast
value of simulation time is reached.
simulationComplete
method.
start
does not block until the
simulation is finished.
If blocking is desired, use method run
to execute a simulation.
run()
,
setTimeLast(double)
,
Executive.startSimulation()
public final void setTimeLast(double t)
timeLast
if all the entities reach the end of their agendas
before then.
If an entity agenda
is active when simulation
time reaches the timeLast
value, the executive will stop the simulation.
The default value of timeLast
is positive infinity.
t
- Last value of simulation time to be simulated.Entity.setTimeLast(double)
,
Executive.setTimeLast(double)
public final void setVisible(boolean flag)
flag
- true:
Create and display the controlling GUI for the simulation.
false:
Hide the controlling GUI.public void msg(java.lang.String message)
info(String)
.
public final void info(java.lang.String message)
Simulation
subclass name, and the supplied message
string before it is logged to the Simulation
logger as an info level message.
Entity.info(String)
public final Executive getExecutive()
Executive
implementations and is not needed
by simulation developers.
Executive
instance for this simulation.public final void displayEntities(java.lang.String message)
Entities
catagorized by
current state.
Used to test Executive
implementations and not needed
by simulation developers.
message
- Text message display at the top of the Entity
table.public final void setPace(long period)
To return the simulation to a state the computation proceeds as fast as possible, make the following invocation:setPace(60 * 1000 / 2)
setPace(0)
period
- Minimum number of real milliseconds that must pass before one
unit of simulation time passes.public long getPace()
public final void pauseSimulation()
public final void resumeSimulation()
public final java.lang.String version()
public java.util.Properties getSubProperties(java.lang.String prefix, java.util.Properties origProps)
public final java.util.logging.Logger getLogger(java.lang.String loggerName)
loggerName
- Name of the logger sought
public java.util.logging.Logger getExecLogger()
public java.util.logging.Logger getFlowLogger()
public java.util.logging.Logger getSimLogger()
public java.util.logging.Logger getEntityLogger()
public Population createPopulation(java.lang.Class c)
Population
of Class c entities.
The returned Population
will contain all instances of
the specified class (or subclass) that have been registered and which have not
yet completed.
c
- Class Entity
or subclass.
Population
.Executive.createPopulation(Class, LogicalProcess)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |