|
SSJ V. 2.6.2. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object umontreal.iro.lecuyer.simevents.Event
public abstract class Event
This abstract class provides event scheduling tools.
Each type of event should be defined as a subclass of the
class Event, and should provide an implementation of the method
actions
which is executed when an event of this type occurs.
The instances of these subclasses are the actual events.
Each event is linked to a simulator represented by an instance of
Simulator
before it can be scheduled and processed.
A default simulator, given by Simulator.getDefaultSimulator,
is used if no simulator is linked explicitly with an event.
When an event is constructed, it is not scheduled. It must be scheduled
separately by calling one of the scheduling methods schedule
,
scheduleNext
, scheduleBefore
, etc.
An event can also be cancelled before it occurs.
A scheduled event has an associated time at which it will happen and a priority,
which can be queried using the methods time
and priority
, respectively.
By default, events occur in ascending order of time, and have priority 1.
Events with the same time occur in ascending order of priority.
For example, if events e1 and e2 occur at the same time
with priority 2 and 1 respectively, then e2 will occur before e1.
Events with the same time and priority occur in the order they were scheduled.
Constructor Summary | |
---|---|
Event()
Constructs a new event instance, which can be placed afterwards into the event list of the default simulator. |
|
Event(Simulator sim)
Construct a new event instance associated with the given simulator. |
Method Summary | |
---|---|
abstract void |
actions()
This is the method that is executed when this event occurs. |
boolean |
cancel()
Cancels this event before it occurs. |
boolean |
cancel(String type)
Finds the first occurence of an event of class ``type'' in the event list, and cancels it. |
int |
compareTo(Event e)
Compares this object with the specified object e for order. |
int |
getRa()
|
double |
priority()
Returns the priority of this event. |
void |
reschedule(double delay)
Cancels this event and reschedules it to happen in delay time units. |
void |
schedule(double delay)
Schedules this event to happen in delay time units, i.e., at time sim.time() + delay, by inserting it in the event list. |
void |
scheduleAfter(Event other)
Schedules this event to happen just after, and at the same time, as the event other. |
void |
scheduleBefore(Event other)
Schedules this event to happen just before, and at the same time, as the event other. |
void |
scheduleNext()
Schedules this event as the first event in the event list, to be executed at the current time (as the next event). |
void |
setPriority(double priority)
Sets the priority of this event to inPriority. |
void |
setRa(int r)
|
void |
setSimulator(Simulator sim)
Sets the simulator associated with this event to sim. |
void |
setTime(double time)
Sets the (planned) time of occurence of this event to time. |
Simulator |
simulator()
Returns the simulator linked to this event. |
double |
time()
Returns the (planned) time of occurence of this event. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Event()
public Event(Simulator sim)
sim
- Instance of class Simulator associated with the new EventMethod Detail |
---|
public final int getRa()
public final void setRa(int r)
public void schedule(double delay)
setPriority
before it is scheduled.
delay
- simulation time that must pass before the event happenspublic void scheduleNext()
public void scheduleBefore(Event other)
other
- event before which this event will be scheduledpublic void scheduleAfter(Event other)
other
- event after which this event will be scheduledpublic void reschedule(double delay)
delay
- simulation time units that must elapse before the event happenspublic boolean cancel()
public final boolean cancel(String type)
type
- name of an event subclass
public final Simulator simulator()
public final void setSimulator(Simulator sim)
sim
- the Simulatorpublic final double time()
public final void setTime(double time)
time
- new time of occurence for the eventpublic final double priority()
public final void setPriority(double priority)
priority
- new priority for the eventpublic int compareTo(Event e)
compareTo
in interface Comparable<Event>
public abstract void actions()
|
SSJ V. 2.6.2. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |