public abstract class Event<E extends Entity> extends EventAbstract
For events changing the state of two or three entities,
refer to EventOf2Entities
and EventOf3Entities
.
Events not associated to a specific entity are based on ExternalEvent
.
For type safety it is recommended to generically assign the entity type an
Event operates on by using the generic type
Event<E>
where
E
is derived from Entity
.
All event object should be used only once. Implement the changes of state for the
specific entity associated with this event by overriding the abstract method
eventRoutine(E who)
.
Entity
,
ExternalEvent
,
EventOf2Entities
,
EventOf3Entities
,
TimeInstant
,
TimeSpan
Constructor and Description |
---|
Event(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 |
---|---|
Event<E> |
clone()
Creates and returns a copy of this event.
|
abstract void |
eventRoutine(E who)
Implement this abstract method to express the changes of state this event
does to a single entity.
|
void |
schedule(E who)
Schedules this event to act on the given Entity now.
|
void |
schedule(E who,
NumericalDist<?> dist)
Schedules this event to act on the given Entity at a point in
simulation time determined by a sample from the distribution provided
to the method.
|
void |
schedule(E who,
TimeInstant instant)
Schedules this event to act on the given entity at a certain point in
simulation time.
|
void |
schedule(E who,
TimeSpan dt)
Schedules this event to act on the given Entity at the specified point in
simulation time.
|
void |
scheduleAfter(Schedulable after,
E who)
Schedules this event to act on the given Entity directly after the given
Schedulable is already set to be activated.
|
void |
scheduleBefore(Schedulable before,
E who)
Schedules this event to act on the given Entity directly before the given
Schedulable is already set to be activated.
|
void |
schedulePreempt(E who)
Schedules this event to be executed immediately, preempting the
process lifecycle executed at the moment.
|
getNumberOfEntities, getRealTimeConstraint, getSchedulingPriority, isExternal, setRealTimeConstraint, setSchedulingPriority
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 Event(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 abstract void eventRoutine(E who) throws SuspendExecution
SimProcess
inherits from class Entity
, an event
can also be given a process to operate on. In this case, the process is
scheduled and manipulated by this event just like an entity.
Implement this abstract method to express the changes of state this event
does to an entity (as SimProcess
is a subclass of
Entity
, a process can be passed as well).
For type safety, it is recommended to derive your events from the generic
type Event<EntityOperatingOn>
where
EntityOperatingOn
(which is derived from class
Entity
) represents the entity type your event is supposed to
operate on.
Should you decide to derive your event from the raw type
Event
(which is not recommended), please take extra care in
checking the given Entity parameter to your special eventRoutine since
any subtype of Entity will be accepted! If your model uses several
different entity types, chances are that while developing the model,
wrong entity types might be passed.
who
- Entity : The Entity associated to this event.SuspendExecution
- Marker exception for Quasar.public void schedule(E who, TimeInstant instant)
who
- E : The first entity to be manipulated by this eventinstant
- TimeInstant : The point in simulation time this event is
scheduled to happen.public void schedule(E who, TimeSpan dt)
who
- E : The Entity this event happens todt
- TimeSpan : The offset to the current simulation time this
Event is to happenSimClock
public void schedule(E who)
who
- E : The Entity this event happens toSimClock
public void schedulePreempt(E who) throws SuspendExecution
who
- E : The Entity this event happens toSuspendExecution
public void schedule(E who, NumericalDist<?> dist)
who
- E : The Entity this event happens todist
- NumericalDist> : Numerical distribution to sample the
offset to the current simulation time fromSimClock
public void scheduleAfter(Schedulable after, E who)
after
- Schedulable : The Schedulable this entity should be scheduled
afterwho
- E : The Entity to be manipulated by this eventpublic void scheduleBefore(Schedulable before, E who)
before
- Schedulable : The Schedulable this entity should be scheduled
beforewho
- E : The Entity to be manipulated by this eventpublic Event<E> clone() throws java.lang.CloneNotSupportedException
java.lang.Cloneable
to actually use this method as
otherwise, a CloneNotSupportedException
will be thrown.java.lang.CloneNotSupportedException