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   import org.djutils.exceptions.Throw;
8   import org.opentrafficsim.core.perception.HistoryManager;
9   
10  import nl.tudelft.simulation.dsol.experiment.SingleReplication;
11  
12  /**
13   * <p>
14   * Copyright (c) 2013-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
15   * BSD-style license. See <a href="https://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
16   * </p>
17   * @author <a href="https://github.com/averbraeck">Alexander Verbraeck</a>
18   */
19  public class OtsReplication extends SingleReplication<Duration>
20  {
21      /** History manager. */
22      private final HistoryManager historyManager;
23  
24      /** the (absolute) start time of the replication. */
25      private final Time startTimeAbs;
26  
27      /**
28       * Create a new OtsReplication.
29       * @param id id of the new OtsReplication
30       * @param startTime the start time of the new OtsReplication
31       * @param warmupPeriod the warmup period of the new OtsReplication
32       * @param runLength the run length of the new OtsReplication
33       * @param historyManager history manager
34       * @throws NamingException when the context for the replication cannot be created
35       */
36      public OtsReplication(final String id, final Time startTime, final Duration warmupPeriod, final Duration runLength,
37              final HistoryManager historyManager) throws NamingException
38      {
39          super(id, Duration.ZERO, warmupPeriod, runLength);
40          Throw.whenNull(historyManager, "historyManager");
41          this.startTimeAbs = startTime;
42          this.historyManager = historyManager;
43      }
44  
45      /**
46       * Returns the history manager.
47       * @param simulator simulator
48       * @return history manager
49       */
50      public HistoryManager getHistoryManager(final OtsSimulatorInterface simulator)
51      {
52          return this.historyManager;
53      }
54  
55      /**
56       * Return the absolute start time of the simulation.
57       * @return the absolute start time of the simulation
58       */
59      public Time getStartTimeAbs()
60      {
61          return this.startTimeAbs;
62      }
63  
64      /** */
65      private static final long serialVersionUID = 20140815L;
66  
67      @Override
68      public final String toString()
69      {
70          return "OtsReplication []";
71      }
72  }