|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.mitre.sim.api3.flow.threads.ThreadData
org.mitre.sim.api3.exec.LogicalProcess
org.mitre.sim.api3.Entity
Abstract class from which all entities in a simulation are derived.
Entities are the source of autonomous action in a simulation.
They embody both
proactive and reactive behavior. The agenda
usually contains
the proactive part of a Entity
. The reactive behavior
can be coded in
action methods
that respond to other Entity
initiatives.
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
Entity
or
register
in class
Simulation
.
Copyright © 2003-2004 The MITRE Corporation
Field Summary |
Fields inherited from class org.mitre.sim.api3.flow.threads.ThreadData |
elaborated, launched, stop, thread |
Constructor Summary | |
Entity(java.lang.String myName)
Construct a new instance of class Entity with a user-supplied name. |
Method Summary | |
void |
actionMethodNotifier()
Deprecated. Designates a method on Entity
subclasses as an
action method.
If an Entity subclass method includes an
invocation of actionMethodNotifier
anytime during the execution of the method,
that method is known as an
action method.
Action methods are the reactive portion of
an entity's behavior. (The proactive hehavior is in the
agenda .)
The use of actionMethodNotifier has been replaced by a method
naming convention.
Methods of the form "actionX" where X is one or more characters are now
recognized by the Executive as
action methods. |
void |
agenda()
Overloading this method gives the entity proactive behavior. |
Population |
createPopulation(java.lang.Class c)
Create a Population of Class c entities. |
void |
displayEntities(java.lang.String message)
Display a table of the simulation Entities catagorized by state. |
void |
entityComplete()
Overload if entity completion notification is desired. |
boolean |
entityIsAlive(Entity target)
Test the target entity and determine if it is in ready to
receive an action method invocation. |
void |
exceptionHandler(java.lang.Exception e)
Overload if a custom exception handler is desired. |
java.util.logging.Logger |
getLogger()
Return the Entity logger. |
java.lang.String |
getName()
|
double |
getTimeLast()
Last value of simulation time before the simulation stops. |
double |
getTimeNow()
Returns the current simulation time. |
void |
info(java.lang.String message)
Convenience method that concatenates the current simulation time, entity name, and the supplied message string then logges them to the Entity
logger as an info level message. |
void |
msg(java.lang.String message)
Deprecated. Please see info(String) . |
Entity |
register(Entity e)
Affiliate a new entity with this simulation. |
void |
schedule(java.lang.String methodName,
double eventDelay)
Schedule a parameterless method for execution after a specifed delay. |
void |
schedule(java.lang.String methodName,
double eventDelay,
java.lang.Object[] arguments)
Schedule a method for execution after a specifed delay. |
void |
setTimeLast(double t)
Specify the last value of time to be simulated before the simulation stops. |
void |
stopSimulation()
Stops the entire simulation. |
java.lang.String |
toString()
Return the name, state, and simulation time as a comma separated string. |
WaitResult |
waitForAction(double backStop)
Place the entity in a waitingForEvent
state until either
the specified amount of simulation time has passed or
an action method is invoked. |
WaitResult |
waitForActionOrTrigger(Trigger trigger)
Convenient version of waitForActionOrTrigger(Trigger[], double)
that accepts a single condition and assumes
an infinite backstop time. |
WaitResult |
waitForActionOrTrigger(Trigger[] triggers,
double backStop)
Place the entity in a waitingForEvent
state until either
the specified amount of simulation time has passed,
an action method is invoked, or
one of the supplied conditions is true. |
WaitResult |
waitForActionOrTrigger(Trigger trigger1,
Trigger trigger2)
Convenient version of waitForActionOrTrigger(Trigger[], double)
that accepts a single condition and assumes
an infinite backstop time. |
WaitResult |
waitForTime(double delay)
Place the entity in a waitingForTime
state until the specified amount of simulation time has passed. |
Methods inherited from class org.mitre.sim.api3.exec.LogicalProcess |
getActionOccurred, getCurrentTriggers, getExec, getExecutive, getNextTime, getSelectedTrigger, getState, getTriggerOccurred, isWaiting, run, setActionOccurred, setCurrentTriggers, setExecutive, setLogger, setNextTime, setSelectedTrigger, setState, setTriggerOccurred, stateEquals |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public Entity(java.lang.String myName)
msg
and toString
.
If the supplied name string is null or less than one charater long,
then entity name is set to "Entity".
myName
- Any string value that is useful to identify this entity.msg(String)
,
toString()
Method Detail |
public final java.lang.String getName()
getName
in class LogicalProcess
public void agenda()
agenda
method is invoked by the simulation executive on each instance
of class Entity. An entity's agenda
is often a loop where the entity
examines and/or modifies the simulation state then waits for external
events to occur. Before the simulation executive invokes the agenda
method, the entity is in a dormant
state. During execution of the agenda
method, the entity is in one of
these states: ready
,
active
,
waitingForTime
, or
waitingForEvent
.
When the agenda
method returns, the entity is in a
complete
state and has no
further proactive or reactive behavior.
agenda
in class LogicalProcess
public void entityComplete()
entityComplete
method
gives the entity developer a place
to put code that will be executed unconditionally at the end of the entity's life.
entityComplete
in class LogicalProcess
Simulation.simulationComplete()
public void exceptionHandler(java.lang.Exception e)
agenda
is invoked by the simulation executive. If the agenda
throws
an exception, that exception will be caught by the executive and passed to this
method before execution of the entity is abandoned. Exceptions thrown by
the exceptionHandler
method itself are ignored. The default behavior
for this method is to invoke e.printStackTrace()
where
e
is the exception thrown
by the agenda
.
exceptionHandler
in class LogicalProcess
public final void stopSimulation()
agendas
are
complete or the last value of simulation time is reached.
This method is used if an entity needs to stop the simulation
before then.
getTimeLast()
,
Executive.stopSimulation(LogicalProcess)
public final double getTimeNow()
Executive.getTimeNow()
public final double getTimeLast()
setTimeLast(double t)
,
Executive.getTimeLast()
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.getTimeLast()
,
Simulation.setTimeLast(double)
,
Executive.setTimeLast(double)
public final void actionMethodNotifier() throws java.lang.IllegalStateException
Entity
subclasses as an
action method.
If an Entity
subclass method includes an
invocation of actionMethodNotifier
anytime during the execution of the method,
that method is known as an
action method.
Action methods are the reactive portion of
an entity's behavior. (The proactive hehavior is in the
agenda
.)
The use of actionMethodNotifier
has been replaced by a method
naming convention.
Methods of the form "actionX" where X is one or more characters are now
recognized by the Executive as
action methods.
java.lang.IllegalStateException
Executive.actionMethodInvoked(LogicalProcess)
public final boolean entityIsAlive(Entity target)
target
entity and determine if it is in ready to
receive an action method invocation.
Entities cannot receive action method invocations when they are in
either the Dormant
or
Complete
states.
target
- Entity instance to be tested.
true:
Entity is active and can receive action method
invocations. false:
The target
entity is null,
or in either a Dormant
or
Complete
state.public final Entity register(Entity e)
Simulation.register(Entity)
method.
e
- Entity instance being registered
Entity
supplied by parameter e
.Simulation.register(Entity)
public void msg(java.lang.String message)
info(String)
.
public final void info(java.lang.String message)
Entity
logger as an info level message.
Simulation.info(String)
public java.lang.String toString()
public final void displayEntities(java.lang.String message)
Entities
catagorized by state.
Used to test Executive
implementations and is not needed
by simulation developers.
message
- Text message display at the top of the Entity
table.public final java.util.logging.Logger getLogger()
Entity
logger.
getLogger
in class LogicalProcess
Entity
logger.public WaitResult waitForTime(double delay)
waitingForTime
state until the specified amount of simulation time has passed.
Zero or more action methods
may be invoked by other entities
during the invocation of this method but control will not return until
the specified amount of simulation time as passed.
This method is similar to the HLA Time Advance Request service.
delay
- Amount of simulation time that must pass before this entity
is ready
to run.
WaitResult
Executive.waitForTime(double, LogicalProcess)
public WaitResult waitForAction(double backStop)
waitingForEvent
state until either
backStop
- Maximum amount of simulation time that will pass before this
entity is ready
to run.
WaitResult
Executive.waitForEvent(Trigger[], double, LogicalProcess)
public WaitResult waitForActionOrTrigger(Trigger[] triggers, double backStop)
waitingForEvent
state until either
conditions
is true.
triggers
- Array of zero or more conditions
or null.backStop
- Maximum amount of simulation time that will pass before this
entity is ready to run.
WaitResult
Trigger
,
Executive.waitForEvent(Trigger[], double, LogicalProcess)
public WaitResult waitForActionOrTrigger(Trigger trigger)
waitForActionOrTrigger(Trigger[], double)
that accepts a single condition
and assumes
an infinite backstop time.
This method is equivalent to:
waitForActionOrTrigger(new Trigger[] {trigger}, Double.POSITIVE_INFINITY)
waitForActionOrTrigger(Trigger[], double)
public WaitResult waitForActionOrTrigger(Trigger trigger1, Trigger trigger2)
waitForActionOrTrigger(Trigger[], double)
that accepts a single condition
and assumes
an infinite backstop time.
This method is equivalent to:
waitForActionOrTrigger(new Trigger[] {trigger1, trigger2}, Double.POSITIVE_INFINITY)
waitForActionOrTrigger(Trigger[], double)
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)
public void schedule(java.lang.String methodName, double eventDelay) throws java.lang.IllegalArgumentException
methodName
will be invoked by the executive after
eventDelay
units of simulation time have passed.
The specified method must belong to the
Entity
instance making the schedule
invocation.
Entity
methods scheduled for execution using
schedule
should take no parameters and have a return type of void
.
The agenda
method cannnot be scheduled for execution.
methodName
- String representation of the method name being scheduled.eventDelay
- Amount of simulation time that must pass before the method is invoked by the executive.
java.lang.IllegalArgumentException
schedule(String, double, Object[])
public void schedule(java.lang.String methodName, double eventDelay, java.lang.Object[] arguments) throws java.lang.IllegalArgumentException
methodName
will be invoked by the executive after
eventDelay
units of simulation time have passed.
The specified method must belong to the
Entity
instance making the schedule
invocation.
Entity
methods scheduled for execution using
schedule
should have a return type of void
.
The agenda
method cannnot be scheduled for execution.
methodName
- String representation of the method name being scheduled.eventDelay
- Amount of simulation time that must pass before the method is invoked by the executive.arguments
- Array of argument supplied when methodName
is executed.
java.lang.IllegalArgumentException
schedule(String, double)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |