View Javadoc
1   package org.opentrafficsim.core.dsol;
2   
3   import javax.naming.NamingException;
4   
5   import org.djunits.value.vdouble.scalar.Duration;
6   import org.djunits.value.vdouble.scalar.Time;
7   
8   import nl.tudelft.simulation.dsol.SimRuntimeException;
9   import nl.tudelft.simulation.dsol.formalisms.eventscheduling.SimEvent;
10  import nl.tudelft.simulation.dsol.simtime.SimTimeDoubleUnit;
11  import nl.tudelft.simulation.dsol.simulators.DEVSSimulatorInterface;
12  
13  /**
14   * <p>
15   * Copyright (c) 2013-2019 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
16   * BSD-style license. See <a href="http://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
17   * <p>
18   * $LastChangedDate: 2019-01-06 01:35:05 +0100 (Sun, 06 Jan 2019) $, @version $Revision: 4831 $, by $Author: averbraeck $,
19   * initial version 11 mei 2015 <br>
20   * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
21   * @author <a href="http://www.tudelft.nl/pknoppers">Peter Knoppers</a>
22   */
23  public interface OTSSimulatorInterface extends DEVSSimulatorInterface.TimeDoubleUnit
24  {
25      /**
26       * Initialize a simulation engine without animation; the easy way. PauseOnError is set to true;
27       * @param startTime Time; the start time of the simulation
28       * @param warmupPeriod Duration; the warm up period of the simulation (use new Duration(0, SECOND) if you don't know what
29       *            this is)
30       * @param runLength Duration; the duration of the simulation
31       * @param model OTSModelInterface; the simulation to execute
32       * @throws SimRuntimeException when e.g., warmupPeriod is larger than runLength
33       * @throws NamingException when the context for the replication cannot be created
34       */
35      void initialize(Time startTime, Duration warmupPeriod, Duration runLength, OTSModelInterface model)
36              throws SimRuntimeException, NamingException;
37  
38      /**
39       * Initialize a simulation engine without animation and prescribed replication number; the easy way. PauseOnError is set to
40       * true;
41       * @param startTime Time; the start time of the simulation
42       * @param warmupPeriod Duration; the warm up period of the simulation (use new Duration(0, SECOND) if you don't know what
43       *            this is)
44       * @param runLength Duration; the duration of the simulation
45       * @param model OTSModelInterface; the simulation to execute
46       * @param replicationNr int; the replication number
47       * @throws SimRuntimeException when e.g., warmupPeriod is larger than runLength
48       * @throws NamingException when context for the animation cannot be created
49       */
50      void initialize(Time startTime, Duration warmupPeriod, Duration runLength, OTSModelInterface model, int replicationNr)
51              throws SimRuntimeException, NamingException;
52  
53      /**
54       * Construct and schedule a SimEvent using a Time to specify the execution time.
55       * @param executionTime Time; the time at which the event must happen
56       * @param priority short; should be between <cite>SimEventInterface.MAX_PRIORITY</cite> and
57       *            <cite>SimEventInterface.MIN_PRIORITY</cite>; most normal events should use
58       *            <cite>SimEventInterface.NORMAL_PRIORITY</cite>
59       * @param source Object; the object that creates/schedules the event
60       * @param target Object; the object that must execute the event
61       * @param method String; the name of the method of <code>target</code> that must execute the event
62       * @param args Object[]; the arguments of the <code>method</code> that must execute the event
63       * @return SimEvent&lt;SimTimeDoubleUnit&gt;; the event that was scheduled (the caller should save this if a need to cancel
64       *         the event may arise later)
65       * @throws SimRuntimeException when the <code>executionTime</code> is in the past
66       */
67      SimEvent<SimTimeDoubleUnit> scheduleEvent(Time executionTime, short priority, Object source, Object target, String method,
68              Object[] args) throws SimRuntimeException;
69  
70      /** {@inheritDoc} */
71      @Override
72      OTSReplication getReplication();
73  
74  }