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.opentrafficsim.core.perception.HistoryManager;
8 import org.opentrafficsim.core.perception.HistoryManagerDevs;
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 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 String; id of the new OTSReplication
30 * @param startTime Time; the start time of the new OTSReplication
31 * @param warmupPeriod Duration; the warmup period of the new OTSReplication
32 * @param runLength Duration; the run length of the new OTSReplication
33 * @throws NamingException when the context for the replication cannot be created
34 */
35 public OtsReplication(final String id, final Time startTime, final Duration warmupPeriod, final Duration runLength)
36 throws NamingException
37 {
38 super(id, Duration.ZERO, warmupPeriod, runLength);
39 this.startTimeAbs = startTime;
40 }
41
42 /**
43 * Returns the history manager. If none was set, one is created coupled to the simulator using 0s of history and 10s
44 * clean-up time.
45 * @param simulator OtsSimulatorInterface; simulator
46 * @return HistoryManager; history manager
47 */
48 public HistoryManager getHistoryManager(final OtsSimulatorInterface simulator)
49 {
50 if (this.historyManager == null)
51 {
52 this.historyManager = new HistoryManagerDevs(simulator, Duration.ZERO, Duration.instantiateSI(10.0));
53 }
54 return this.historyManager;
55 }
56
57 /**
58 * Set history manager.
59 * @param historyManager HistoryManager; history manager to set
60 */
61 public void setHistoryManager(final HistoryManager historyManager)
62 {
63 this.historyManager = historyManager;
64 }
65
66 /**
67 * Return the absolute start time of the simulation.
68 * @return Time; the absolute start time of the simulation
69 */
70 public Time getStartTimeAbs()
71 {
72 return this.startTimeAbs;
73 }
74
75 /** */
76 private static final long serialVersionUID = 20140815L;
77
78 /** {@inheritDoc} */
79 @Override
80 public final String toString()
81 {
82 return "OTSReplication []";
83 }
84 }