1 package org.opentrafficsim.core.dsol;
2
3 import java.rmi.RemoteException;
4
5 import org.djunits.unit.TimeUnit;
6 import org.djunits.value.vdouble.scalar.Duration;
7 import org.djunits.value.vdouble.scalar.Time;
8
9 import nl.tudelft.simulation.dsol.SimRuntimeException;
10 import nl.tudelft.simulation.dsol.experiment.Replication;
11 import nl.tudelft.simulation.dsol.experiment.ReplicationMode;
12 import nl.tudelft.simulation.dsol.simulators.DEVSRealTimeClock;
13
14
15
16
17
18
19
20
21
22
23 public class OTSDEVSRealTimeClock extends DEVSRealTimeClock<Time, Duration, OTSSimTimeDouble>
24 implements OTSDEVSSimulatorInterface, OTSAnimatorInterface
25 {
26
27 private static final long serialVersionUID = 20140909L;
28
29
30
31
32 public OTSDEVSRealTimeClock()
33 {
34 super();
35 }
36
37
38 @Override
39 public final void initialize(final Replication<Time, Duration, OTSSimTimeDouble> initReplication,
40 final ReplicationMode replicationMode) throws SimRuntimeException
41 {
42 try
43 {
44 super.initialize(initReplication, replicationMode);
45 }
46 catch (RemoteException exception)
47 {
48 throw new SimRuntimeException(exception);
49 }
50 }
51
52
53 @Override
54 public final void runUpTo(final Time when) throws SimRuntimeException
55 {
56 super.runUpTo(when);
57 }
58
59
60 @Override
61 protected final Duration relativeMillis(final double factor)
62 {
63 return new Duration(factor, TimeUnit.MILLISECOND);
64 }
65
66
67 @Override
68 public final String toString()
69 {
70 return "OTSDEVSRealTimeClock [time=" + getSimulatorTime().getTime() + "]";
71 }
72
73 }