ContactCenters
V. 0.9.9.

umontreal.iro.lecuyer.contactcenters
Class SwitchEvent

java.lang.Object
  extended by umontreal.iro.lecuyer.simevents.Event
      extended by umontreal.iro.lecuyer.contactcenters.SwitchEvent
All Implemented Interfaces:
Comparable<Event>

public class SwitchEvent
extends Event

Represents an event that toggles an element on predefined simulation times. This differs from ToggleEvent that occurs only at a specific simulation time, and enables or disables the toggle element once. This event is constructed with a toggle element, and an array of simulation times. The constructors determines the first time, in the array, that is greater than the current simulation time, and schedules the event at that time. When the event happens, the element is toggled, and the event is scheduled again until all the times in the array have been used.


Field Summary
 
Fields inherited from class umontreal.iro.lecuyer.simevents.Event
eventTime, priority, sim
 
Constructor Summary
SwitchEvent(Simulator sim, ToggleElement el, double[] times)
          Equivalent to SwitchEvent(ToggleElement,double[]), with a user-defined simulator sim.
SwitchEvent(ToggleElement el, double[] times)
          Constructs a new switch event from the toggle element el, and the simulation times times.
 
Method Summary
 void actions()
           
 double getNextTime()
           
 int getNextTimeIndex()
           
 ToggleElement getToggleElement()
          Returns the toggle element affected with this event.
 double[] getToggleTimes()
          Returns an array containing the toggle times used by this event.
 void init()
           
 void schedule()
           
 void skipTime()
          Cancels this event if it is scheduled, and skips to the next toggle time.
 String toString()
           
 
Methods inherited from class umontreal.iro.lecuyer.simevents.Event
cancel, cancel, compareTo, getRa, priority, reschedule, schedule, scheduleAfter, scheduleBefore, scheduleNext, setPriority, setRa, setSimulator, setTime, simulator, time
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SwitchEvent

public SwitchEvent(ToggleElement el,
                   double[] times)
Constructs a new switch event from the toggle element el, and the simulation times times. The times in times must be sorted in ascending order.

Parameters:
el - the toggle element.
times - the simulation times the event will occur.
Throws:
NullPointerException - if el or times are null.

SwitchEvent

public SwitchEvent(Simulator sim,
                   ToggleElement el,
                   double[] times)
Equivalent to SwitchEvent(ToggleElement,double[]), with a user-defined simulator sim.

Parameters:
sim - the simulator attached to the new event.
el - the toggle element.
times - the simulation times the event will occur.
Throws:
NullPointerException - if sim, el, or times are null.
Method Detail

getToggleElement

public ToggleElement getToggleElement()
Returns the toggle element affected with this event.

Returns:
the affected toggle element.

getToggleTimes

public double[] getToggleTimes()
Returns an array containing the toggle times used by this event.

Returns:
the array of toggle times.

init

public void init()

getNextTimeIndex

public int getNextTimeIndex()

getNextTime

public double getNextTime()

schedule

public void schedule()

skipTime

public void skipTime()
Cancels this event if it is scheduled, and skips to the next toggle time.


actions

public void actions()
Specified by:
actions in class Event

toString

public String toString()
Overrides:
toString in class Object

ContactCenters
V. 0.9.9.

To submit a bug or ask questions, send an e-mail to Richard Simard.