View Javadoc
1   package org.opentrafficsim.core.dsol;
2   
3   import java.rmi.RemoteException;
4   
5   import nl.tudelft.simulation.dsol.SimRuntimeException;
6   import nl.tudelft.simulation.dsol.experiment.Replication;
7   import nl.tudelft.simulation.dsol.experiment.ReplicationMode;
8   import nl.tudelft.simulation.dsol.simulators.DEVSRealTimeClock;
9   
10  import org.djunits.unit.TimeUnit;
11  import org.djunits.value.vdouble.scalar.DoubleScalar;
12  import org.djunits.value.vdouble.scalar.Duration;
13  import org.djunits.value.vdouble.scalar.Time;
14  
15  /**
16   * <p>
17   * Copyright (c) 2013-2016 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
18   * BSD-style license. See <a href="http://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
19   * <p>
20   * @version $Revision: 2051 $, $LastChangedDate: 2016-05-28 11:33:31 +0200 (Sat, 28 May 2016) $, by $Author: averbraeck $,
21   *          initial version Aug 15, 2014 <br>
22   * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
23   */
24  public class OTSDEVSRealTimeClock extends
25      DEVSRealTimeClock<DoubleScalar.Abs<TimeUnit>, DoubleScalar.Rel<TimeUnit>, OTSSimTimeDouble> implements
26      OTSDEVSSimulatorInterface, OTSAnimatorInterface
27  {
28      /** */
29      private static final long serialVersionUID = 20140909L;
30  
31      /**
32       * Create a new OTSRealTimeClock.
33       */
34      public OTSDEVSRealTimeClock()
35      {
36          super();
37      }
38  
39      /** {@inheritDoc} */
40      @Override
41      public final void initialize(
42          final Replication<DoubleScalar.Abs<TimeUnit>, DoubleScalar.Rel<TimeUnit>, OTSSimTimeDouble> initReplication,
43          final ReplicationMode replicationMode) throws SimRuntimeException
44      {
45          try
46          {
47              super.initialize(initReplication, replicationMode);
48          }
49          catch (RemoteException exception)
50          {
51              throw new SimRuntimeException(exception);
52          }
53      }
54  
55      /** {@inheritDoc} */
56      @Override
57      public final void scheduleEventRel(final Duration relativeDelay, final short priority, final Object source,
58          final Object target, final String method, final Object[] args) throws SimRuntimeException
59      {
60          super.scheduleEventRel(relativeDelay, priority, source, target, method, args);
61      }
62  
63      /** {@inheritDoc} */
64      @Override
65      public final void scheduleEventRel(final Duration relativeDelay, final Object source, final Object target,
66          final String method, final Object[] args) throws SimRuntimeException
67      {
68          super.scheduleEventRel(relativeDelay, source, target, method, args);
69      }
70  
71      /** {@inheritDoc} */
72      @Override
73      public final void scheduleEventAbs(final Time absoluteTime, final Object source, final Object target,
74          final String method, final Object[] args) throws SimRuntimeException
75      {
76          super.scheduleEventAbs(absoluteTime, source, target, method, args);
77      }
78  
79      /** {@inheritDoc} */
80      @Override
81      public final void scheduleEventAbs(final Time absoluteTime, final short priority, final Object source,
82          final Object target, final String method, final Object[] args) throws SimRuntimeException
83      {
84          super.scheduleEventAbs(absoluteTime, priority, source, target, method, args);
85      }
86  
87      /** {@inheritDoc} */
88      @Override
89      public final void runUpTo(final Time when) throws SimRuntimeException
90      {
91          super.runUpTo(when);
92      }
93  
94      /** {@inheritDoc} */
95      @Override
96      protected final Duration relativeMillis(final double factor)
97      {
98          return new Duration(factor, TimeUnit.MILLISECOND);
99      }
100 
101     /** {@inheritDoc} */
102     @Override
103     public final String toString()
104     {
105         return "OTSDEVSRealTimeClock [time=" + getSimulatorTime().getTime() + "]";
106     }
107 
108 }