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