Class Event

java.lang.Object
microsim.event.Event
All Implemented Interfaces:
Comparable<Event>
Direct Known Subclasses:
CollectionTargetEvent, EventGroup, SingleTargetEvent, SystemEvent

public abstract class Event extends Object implements Comparable<Event>
An abstract class that describes the structure of a simulation event.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected double
    Get the loop length.
    protected int
    If two events have time fields with equal value, their ordering fields will determine the order in which the events are fired, with lower ordering values fired before high ordering values.
    protected double
    Get the next firing absolute time.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    compareTo(@NonNull Event e)
    Determines the natural ordering of events.
    abstract void
     
    void
    Schedule event at the next loop time.
    void
    setTimeOrderingAndLoopPeriod(double atTime, int withOrdering, double withLoop)
    Set the time, ordering and loop period of the event

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • time

      protected double time
      Get the next firing absolute time.
    • ordering

      protected int ordering
      If two events have time fields with equal value, their ordering fields will determine the order in which the events are fired, with lower ordering values fired before high ordering values. If ordering fields are also equal, the event that was scheduled first will be fired first in the schedule (determined comparing the eventNumber field).
    • loop

      protected double loop
      Get the loop length.
  • Constructor Details

    • Event

      public Event()
  • Method Details

    • setTimeOrderingAndLoopPeriod

      public void setTimeOrderingAndLoopPeriod(double atTime, int withOrdering, double withLoop)
      Set the time, ordering and loop period of the event
      Parameters:
      atTime - The absolute time for the event to be fired.
      withOrdering - The ordering of the event to be fired. If two or more events share an absolute time, their order can be specified using the ordering integer - an event with a lower ordering value will be fired earlier. If two or more events have equal absolute time and ordering, the first event that was scheduled will be fired first.
      withLoop - The time period between repeated firing of the event. If this parameter is set to 0, this event will not be fired more than once.
    • fireEvent

      public abstract void fireEvent() throws SimulationException
      Throws:
      SimulationException
    • compareTo

      public int compareTo(@NonNull @NonNull Event e)
      Determines the natural ordering of events. As such it determines the order in which events are fired from the schedule. If two events have different time fields, the event with the lower time field is fired before the event with the higher time field. If two events have time fields with equal value, their ordering fields will determine the order in which the events are fired, with lower ordering values fired before high ordering values. If ordering fields are also equal, the first event that was scheduled will be fired first.
      Specified by:
      compareTo in interface Comparable<Event>
      Parameters:
      e - Another object of the same type to compare to.
      Throws:
      NullPointerException - when e is null.
    • setTimeAtNextLoop

      public void setTimeAtNextLoop()
      Schedule event at the next loop time.
      Implementation Note:
      This method does not change the ordering of the event. Use the setOrdering(int) method if this is necessary.