Class OTSAnimator

All Implemented Interfaces:
Serializable, Runnable, Remote, AnimatorInterface, DEVSSimulatorInterface<Time,​Duration,​SimTimeDoubleUnit>, DEVSSimulatorInterface.TimeDoubleUnit, SimulatorInterface<Time,​Duration,​SimTimeDoubleUnit>, SimulatorInterface.TimeDoubleUnit, nl.tudelft.simulation.event.EventProducerInterface, OTSAnimatorInterface, OTSSimulatorInterface
Direct Known Subclasses:
OTSLoggingAnimator

public class OTSAnimator
extends DEVSRealTimeClock.TimeDoubleUnit
implements OTSAnimatorInterface, Serializable
Construct a DSOL DEVSRealTimeClock the easy way.

Copyright (c) 2013-2020 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.

$LastChangedDate: 2018-10-30 14:03:57 +0100 (Tue, 30 Oct 2018) $, @version $Revision: 4727 $, by $Author: pknoppers $, initial version 11 mei 2015

Author:
Alexander Verbraeck, Peter Knoppers
See Also:
Serialized Form
  • Constructor Details

    • OTSAnimator

      public OTSAnimator()
      Construct an OTSAnimator.
  • Method Details

    • initialize

      public void initialize​(Time startTime, Duration warmupPeriod, Duration runLength, OTSModelInterface model) throws SimRuntimeException, NamingException
      Initialize a simulation engine without animation; the easy way. PauseOnError is set to true;
      Specified by:
      initialize in interface OTSSimulatorInterface
      Parameters:
      startTime - Time; the start time of the simulation
      warmupPeriod - Duration; the warm up period of the simulation (use new Duration(0, SECOND) if you don't know what this is)
      runLength - Duration; the duration of the simulation
      model - OTSModelInterface; the simulation to execute
      Throws:
      SimRuntimeException - when e.g., warmupPeriod is larger than runLength
      NamingException - when the context for the replication cannot be created
    • initialize

      public void initialize​(Time startTime, Duration warmupPeriod, Duration runLength, OTSModelInterface model, Map<String,​StreamInterface> streams) throws SimRuntimeException, NamingException
      Initialize a simulation engine without animation; the easy way. PauseOnError is set to true;
      Parameters:
      startTime - Time; the start time of the simulation
      warmupPeriod - Duration; the warm up period of the simulation (use new Duration(0, SECOND) if you don't know what this is)
      runLength - Duration; the duration of the simulation
      model - OTSModelInterface; the simulation to execute
      streams - Map<String, StreamInterface>; streams
      Throws:
      SimRuntimeException - when e.g., warmupPeriod is larger than runLength
      NamingException - when the context for the replication cannot be created
    • initialize

      public void initialize​(Time startTime, Duration warmupPeriod, Duration runLength, OTSModelInterface model, int replicationnr) throws SimRuntimeException, NamingException
      Initialize a simulation engine without animation and prescribed replication number; the easy way. PauseOnError is set to true;
      Specified by:
      initialize in interface OTSSimulatorInterface
      Parameters:
      startTime - Time; the start time of the simulation
      warmupPeriod - Duration; the warm up period of the simulation (use new Duration(0, SECOND) if you don't know what this is)
      runLength - Duration; the duration of the simulation
      model - OTSModelInterface; the simulation to execute
      replicationnr - int; the replication number
      Throws:
      SimRuntimeException - when e.g., warmupPeriod is larger than runLength
      NamingException - when context for the animation cannot be created
    • scheduleEvent

      public final SimEvent<SimTimeDoubleUnit> scheduleEvent​(Time executionTime, short priority, Object source, Object target, String method, Object[] args) throws SimRuntimeException
      Construct and schedule a SimEvent using a Time to specify the execution time.
      Specified by:
      scheduleEvent in interface OTSSimulatorInterface
      Parameters:
      executionTime - Time; the time at which the event must happen
      priority - short; should be between SimEventInterface.MAX_PRIORITY and SimEventInterface.MIN_PRIORITY; most normal events should use SimEventInterface.NORMAL_PRIORITY
      source - Object; the object that creates/schedules the event
      target - Object; the object that must execute the event
      method - String; the name of the method of target that must execute the event
      args - Object[]; the arguments of the method that must execute the event
      Returns:
      SimEvent<SimTimeDoubleUnit>; the event that was scheduled (the caller should save this if a need to cancel the event may arise later)
      Throws:
      SimRuntimeException - when the executionTime is in the past
    • getReplication

      public final OTSReplication getReplication()
      Specified by:
      getReplication in interface OTSSimulatorInterface
      Specified by:
      getReplication in interface SimulatorInterface<Time,​Duration,​SimTimeDoubleUnit>
      Overrides:
      getReplication in class DEVSRealTimeClock.TimeDoubleUnit
    • toString

      public String toString()
      Overrides:
      toString in class Object