public abstract class EventAbstract extends Schedulable
an event with up to three entities, changing its state according to the entity's reaction to the specific Event in the system under inspection. So each type of Event acting on one certain type of Entity requires a new subclass to be derived from this class. Since events are associated to a single entity, the method executing the changes of state of a specific Entity gets that entity passed as a parameter. The scheduler takes care that this is done at the specified point of simulation time.
For type safety it is recommended to generically assign the entity type an
Event operates on by using the generic type
Event<EntityOperatingOn>
where
EntityOperatingOn
is derived from Entity
.
events should be used one time only. They are created to be scheduled
together with a specific Entity, change that entity's state at the scheduled
point of simulation time and are destroyed by Java's garbage collector after
use. They could be reused but at a certain risk of inconsistent states. Since
each object of a class that is derived from the class
Schedulable
has its unique identification number added as a
suffix to its name, reusing Event objects would make one event responsible
for several distinct changes in a model at different simulation times. This
comes with the danger of of confusing the model's trace and making it more
difficult to debug a faulty model implementation. Each type of Event needed
for a model requires a new subclass of Event to be derived by the user.
Embed the changes of state for the specific Entity associated with this event
by overriding the abstract method eventRoutine(Entity e)
. Events
that do not manipulate a single entity but act on the model's state on a more
general matter are defined by external events, a subclass of this class.
Entity
,
ExternalEvent
,
TimeInstant
,
TimeSpan
Constructor and Description |
---|
EventAbstract(Model owner,
java.lang.String name,
boolean showInTrace)
Creates a new event of the given model, with the given name and trace
option.
|
Modifier and Type | Method and Description |
---|---|
long |
getNumberOfEntities()
Returns the realTime deadline for this event (in nanoseconds).
|
long |
getRealTimeConstraint()
Returns the realTime deadline for this event (in nanoseconds).
|
int |
getSchedulingPriority()
Returns the event's scheduling priority.
|
boolean |
isExternal()
Tests if this event actually is an external event which is not used for
modelling but to control the experiment to act at certain points of
simulation time.
|
void |
setRealTimeConstraint(long realTimeConstraint)
Sets the realTime deadline for this event (in nanoseconds).
|
void |
setSchedulingPriority(int newPriority)
Sets the entity's scheduling priority to a given integer value.
|
assignReporter, cancel, getCorrespondingReportable, isCurrent, isScheduled, rename, reSchedule, reSchedule, reSchedulePreempt, scheduledNext, setCorrespondingReportable
current, currentEntity, currentEntityAll, currentEvent, currentModel, currentSimProcess, debugIsOn, debugOff, debugOn, getModel, isExperimentCompatible, isModelCompatible, presentTime, sendDebugNote, sendMessage, sendTraceNote, sendWarning, skipTraceNote, skipTraceNote, traceIsOn, traceOff, traceOn
getName, getQuotedName, toString
public EventAbstract(Model owner, java.lang.String name, boolean showInTrace)
name
- java.lang.String : The name of this eventowner
- Model : The model this event is associated toshowInTrace
- boolean : Flag for showing event in trace-files. Set it to
true
if event should show up in trace. Set it to
false
if event should not be shown in trace.public boolean isExternal()
true
if this is an instance of class
ExternalEvent
,false
otherwisepublic long getRealTimeConstraint()
public long getNumberOfEntities()
public void setRealTimeConstraint(long realTimeConstraint)
realTimeConstraint
- the realTimeConstraint in nanoseconds to setpublic int getSchedulingPriority()
public void setSchedulingPriority(int newPriority)
integer
data type [-2147483648, +2147483647].
An event's scheduling priority it used to determine which event is
executed first if scheduled for the same time instant.
Should the priority be the same, event execution depends on the
EventList
in use, e.g. scheduled first is executed
first (EventTreeList
) or random (RandomizingEventTreeList
).newPriority
- int : The new scheduling priority value