java.lang.Object
nl.tudelft.simulation.dsol.formalisms.eventscheduling.AbstractSimEvent<T>
nl.tudelft.simulation.dsol.formalisms.eventscheduling.SimEvent<T>
Type Parameters:
T - the type of simulation time, e.g. Double, Long or Duration.
All Implemented Interfaces:
Serializable, Comparable<SimEventInterface<T>>, SimEventInterface<T>

public class SimEvent<T extends Number & Comparable<T>> extends AbstractSimEvent<T>
The SimEvent forms the essential scheduling mechanism for D-SOL. Objects do not invoke methods directly on eachother; they bundle the object on which the method is planned to be invoked together with the arguments and the name of the method in a simEvent. The SimEvent is then stored in the eventList and executed.

Copyright (c) 2002-2024 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See for project information https://simulation.tudelft.nl. The DSOL project is distributed under a three-clause BSD-style license, which can be found at https://https://simulation.tudelft.nl/dsol/docs/latest/license.html.

Since:
1.5
Author:
Peter Jacobs
See Also:
  • Field Details

    • target

      protected Object target
      target the target on which a state change is scheduled.
    • methodName

      protected String methodName
      method is the method which embodies the state change.
    • args

      protected Object[] args
      args are the arguments that are used to invoke the method with.
  • Constructor Details

    • SimEvent

      public SimEvent(T executionTime, Object target, String method, Object[] args)
      The constructor of the event stores the time the event must be executed and the object and method to invoke.
      Parameters:
      executionTime - T; the absolute time the event has to be executed.
      target - Object; the object on which the method must be invoked.
      method - String; the method to invoke
      args - Object[]; the arguments the method to invoke with
    • SimEvent

      public SimEvent(T executionTime, short priority, Object target, String method, Object[] args)
      The constructor of the event stores the time the event must be executed and the object and method to invoke.
      Parameters:
      executionTime - T; the time the event has to be executed.
      priority - short; the priority of the event
      target - Object; the object on which the method must be invoked.
      method - String; the method to invoke
      args - Object[]; the arguments the method to invoke with
  • Method Details

    • execute

      public void execute() throws SimRuntimeException
      Executes the simEvent.
      Specified by:
      execute in interface SimEventInterface<T extends Number & Comparable<T>>
      Specified by:
      execute in class AbstractSimEvent<T extends Number & Comparable<T>>
      Throws:
      SimRuntimeException - on execution failure
    • getArgs

      public Object[] getArgs()
      Returns:
      Returns the args.
    • getMethod

      public String getMethod()
      Returns:
      Returns the method.
    • getTarget

      public Object getTarget()
      Returns:
      Returns the target.
    • printTarget

      public String printTarget()
      Retrieve the target in a human readable way.
      Returns:
      String; the target in a human readable way
    • printArgs

      public String printArgs()
      Retrieve the arguments in a human readable way.
      Returns:
      String; the arguments in a human readable way
    • toString

      public String toString()
      Overrides:
      toString in class Object