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