View Javadoc
1   package org.opentrafficsim.core.gtu.lane;
2   
3   import java.rmi.RemoteException;
4   import java.util.Map;
5   
6   import nl.tudelft.simulation.dsol.SimRuntimeException;
7   
8   import org.opentrafficsim.core.dsol.OTSDEVSSimulatorInterface;
9   import org.opentrafficsim.core.gtu.TemplateGTUType;
10  import org.opentrafficsim.core.gtu.following.GTUFollowingModel;
11  import org.opentrafficsim.core.network.NetworkException;
12  import org.opentrafficsim.core.network.lane.Lane;
13  import org.opentrafficsim.core.unit.LengthUnit;
14  import org.opentrafficsim.core.unit.SpeedUnit;
15  import org.opentrafficsim.core.value.vdouble.scalar.DoubleScalar;
16  
17  /**
18   * <p>
19   * Copyright (c) 2013-2014 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights
20   * reserved. <br>
21   * BSD-style license. See <a href="http://opentrafficsim.org/node/13">OpenTrafficSim License</a>.
22   * <p>
23   * @version Jan 1, 2015 <br>
24   * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
25   * @author <a href="http://www.tudelft.nl/pknoppers">Peter Knoppers</a>
26   * @param <ID> The type of ID, e.g., String or Integer
27   */
28  public abstract class AbstractLaneBasedTemplateGTU<ID> extends AbstractLaneBasedGTU<ID>
29  {
30      /** */
31      private static final long serialVersionUID = 20140822L;
32  
33      /**
34       * @param id the id of the GTU, could be String or Integer.
35       * @param gtuType the type of GTU, e.g. TruckType, CarType, BusType.
36       * @param gtuFollowingModel the following model, including a reference to the simulator.
37       * @param initialLongitudinalPositions the initial positions of the car on one or more lanes.
38       * @param initialSpeed the initial speed of the car on the lane.
39       * @throws RemoteException when the simulator cannot be reached.
40       * @throws NetworkException when the GTU cannot be placed on the given lane.
41       * @throws SimRuntimeException when the move method cannot be scheduled.
42       */
43      public AbstractLaneBasedTemplateGTU(final ID id, final TemplateGTUType<?> gtuType,
44              final GTUFollowingModel gtuFollowingModel,
45              final Map<Lane, DoubleScalar.Rel<LengthUnit>> initialLongitudinalPositions,
46              final DoubleScalar.Abs<SpeedUnit> initialSpeed) throws RemoteException, NetworkException,
47              SimRuntimeException
48      {
49          super(id, gtuType, gtuFollowingModel, null /* LaneChangeModel */, initialLongitudinalPositions, initialSpeed,
50                  gtuType.getSimulator());
51      }
52  
53      /** {@inheritDoc} */
54      @SuppressWarnings("checkstyle:designforextension")
55      @Override
56      public TemplateGTUType<?> getGTUType()
57      {
58          return getGTUType();
59      }
60  
61      /** {@inheritDoc} */
62      @Override
63      public final DoubleScalar.Rel<LengthUnit> getLength()
64      {
65          return getGTUType().getLength();
66      }
67  
68      /** {@inheritDoc} */
69      @Override
70      public final DoubleScalar.Rel<LengthUnit> getWidth()
71      {
72          return getGTUType().getWidth();
73      }
74  
75      /** {@inheritDoc} */
76      @Override
77      public final DoubleScalar.Abs<SpeedUnit> getMaximumVelocity()
78      {
79          return getGTUType().getMaximumVelocity();
80      }
81  
82      /** {@inheritDoc} */
83      @Override
84      public final OTSDEVSSimulatorInterface getSimulator()
85      {
86          return getGTUType().getSimulator();
87      }
88  
89  }