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.network.NetworkException;
11  import org.opentrafficsim.road.gtu.following.GTUFollowingModel;
12  import org.opentrafficsim.road.gtu.lane.changing.LaneChangeModel;
13  import org.opentrafficsim.road.network.lane.Lane;
14  import org.opentrafficsim.road.network.route.LaneBasedRouteNavigator;
15  
16  /**
17   * Specific type of LaneBasedGTU. This class adds length, width, maximum velocity and a reference to the simulator to the
18   * AbstractLaneBasedGTU.
19   * <p>
20   * Copyright (c) 2013-2015 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
21   * BSD-style license. See <a href="http://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
22   * <p>
23   * @version $Revision: 1401 $, $LastChangedDate: 2015-09-14 01:33:02 +0200 (Mon, 14 Sep 2015) $, by $Author: averbraeck $,
24   *          initial version Jan 1, 2015 <br>
25   * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
26   * @author <a href="http://www.tudelft.nl/pknoppers">Peter Knoppers</a>
27   */
28  public abstract class AbstractLaneBasedIndividualGTU extends AbstractLaneBasedGTU
29  {
30      /** */
31      private static final long serialVersionUID = 20140822L;
32  
33      /** the maximum length of the GTU (parallel with driving direction). */
34      private final Length.Rel length;
35  
36      /** the maximum width of the GTU (perpendicular to driving direction). */
37      private final Length.Rel width;
38  
39      /** the maximum speed of the GTU (in the driving direction). */
40      private final Speed.Abs maximumVelocity;
41  
42      /** the simulator. */
43      private final OTSDEVSSimulatorInterface simulator;
44  
45      /**
46       * Construct a new AbstractLaneBasedIndividualGTU.
47       * @param id the id of the GTU
48       * @param gtuType the type of GTU, e.g. TruckType, CarType, BusType
49       * @param gtuFollowingModel the following model, including a reference to the simulator
50       * @param laneChangeModel LaneChangeModel; the lane change model
51       * @param initialLongitudinalPositions the initial positions of the car on one or more lanes
52       * @param initialSpeed the initial speed of the car on the lane
53       * @param length the maximum length of the GTU (parallel with driving direction)
54       * @param width the maximum width of the GTU (perpendicular to driving direction)
55       * @param maximumVelocity the maximum speed of the GTU (in the driving direction)
56       * @param routeNavigator RouteNavigator; the individual route that the GTU will take
57       * @param simulator the simulator
58       * @throws NetworkException when the GTU cannot be placed on the given lane
59       * @throws SimRuntimeException when the move method cannot be scheduled
60       * @throws GTUException when a parameter is invalid
61       */
62      @SuppressWarnings("checkstyle:parameternumber")
63      public AbstractLaneBasedIndividualGTU(final String id, final GTUType gtuType, final GTUFollowingModel gtuFollowingModel,
64          final LaneChangeModel laneChangeModel, final Map<Lane, Length.Rel> initialLongitudinalPositions,
65          final Speed.Abs initialSpeed, final Length.Rel length, final Length.Rel width, final Speed.Abs maximumVelocity,
66          final LaneBasedRouteNavigator routeNavigator, final OTSDEVSSimulatorInterface simulator) throws
67          NetworkException, SimRuntimeException, GTUException
68      {
69          super(id, gtuType, gtuFollowingModel, laneChangeModel, initialLongitudinalPositions, initialSpeed, routeNavigator,
70              simulator);
71          this.length = length;
72          this.width = width;
73          if (null == maximumVelocity)
74          {
75              throw new GTUException("maximumVelocity may not be null");
76          }
77          this.maximumVelocity = maximumVelocity;
78          this.simulator = simulator;
79      }
80  
81      /** {@inheritDoc} */
82      @Override
83      public final Length.Rel getLength()
84      {
85          return this.length;
86      }
87  
88      /** {@inheritDoc} */
89      @Override
90      public final Length.Rel getWidth()
91      {
92          return this.width;
93      }
94  
95      /** {@inheritDoc} */
96      @Override
97      public final Speed.Abs getMaximumVelocity()
98      {
99          return this.maximumVelocity;
100     }
101 
102     /** {@inheritDoc} */
103     @Override
104     public final OTSDEVSSimulatorInterface getSimulator()
105     {
106         return this.simulator;
107     }
108 
109 }