View Javadoc
1   package org.opentrafficsim.core.dsol;
2   
3   import java.rmi.RemoteException;
4   
5   import org.djunits.unit.DurationUnit;
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   * <p>
16   * Copyright (c) 2013-2017 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
17   * BSD-style license. See <a href="http://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
18   * <p>
19   * @version $Revision: 3570 $, $LastChangedDate: 2017-04-29 12:51:08 +0200 (Sat, 29 Apr 2017) $, by $Author: averbraeck $,
20   *          initial version Aug 15, 2014 <br>
21   * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
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       * Create a new OTSRealTimeClock.
31       */
32      public OTSDEVSRealTimeClock()
33      {
34          super();
35      }
36  
37      /** {@inheritDoc} */
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      /** {@inheritDoc} */
53      @Override
54      public final void runUpTo(final Time when) throws SimRuntimeException
55      {
56          super.runUpTo(when);
57      }
58  
59      /** {@inheritDoc} */
60      @Override
61      protected final Duration relativeMillis(final double factor)
62      {
63          return new Duration(factor, DurationUnit.MILLISECOND);
64      }
65  
66      /** {@inheritDoc} */
67      @Override
68      public final String toString()
69      {
70          return "OTSDEVSRealTimeClock [time=" + getSimulatorTime().getTime() + "]";
71      }
72  
73  }