View Javadoc
1   package org.opentrafficsim.road.gtu.lane;
2   
3   import org.djunits.value.vdouble.scalar.Length;
4   import org.djunits.value.vdouble.scalar.Speed;
5   import org.opentrafficsim.core.dsol.OTSDEVSSimulatorInterface;
6   import org.opentrafficsim.core.gtu.GTUException;
7   import org.opentrafficsim.core.gtu.GTUType;
8   import org.opentrafficsim.core.network.OTSNetwork;
9   
10  /**
11   * Specific type of LaneBasedGTU. This class adds length, width, maximum speed and a reference to the simulator to the
12   * AbstractLaneBasedGTU.
13   * <p>
14   * Copyright (c) 2013-2016 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
15   * BSD-style license. See <a href="http://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
16   * <p>
17   * @version $Revision: 1401 $, $LastChangedDate: 2015-09-14 01:33:02 +0200 (Mon, 14 Sep 2015) $, by $Author: averbraeck $,
18   *          initial version Jan 1, 2015 <br>
19   * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
20   * @author <a href="http://www.tudelft.nl/pknoppers">Peter Knoppers</a>
21   */
22  public abstract class AbstractLaneBasedIndividualGTU extends AbstractLaneBasedGTU
23  {
24      /** */
25      private static final long serialVersionUID = 20140822L;
26  
27      /** The maximum length of the GTU (parallel with driving direction). */
28      private final Length length;
29  
30      /** The maximum width of the GTU (perpendicular to driving direction). */
31      private final Length width;
32  
33      /** The maximum speed of the GTU (in the driving direction). */
34      private final Speed maximumSpeed;
35  
36      /**
37       * Construct a new AbstractLaneBasedIndividualGTU.
38       * @param id the id of the GTU
39       * @param gtuType the type of GTU, e.g. TruckType, CarType, BusType
40       * @param length the maximum length of the GTU (parallel with driving direction)
41       * @param width the maximum width of the GTU (perpendicular to driving direction)
42       * @param maximumSpeed the maximum speed of the GTU (in the driving direction)
43       * @param simulator the simulator
44       * @param network the network that the GTU is initially registered in
45       * @throws GTUException when a parameter is invalid
46       */
47      @SuppressWarnings("checkstyle:parameternumber")
48      public AbstractLaneBasedIndividualGTU(final String id, final GTUType gtuType, final Length length, final Length width,
49              final Speed maximumSpeed, final OTSDEVSSimulatorInterface simulator, final OTSNetwork network) throws GTUException
50      {
51          super(id, gtuType, simulator, network);
52          this.length = length;
53          this.width = width;
54          if (null == maximumSpeed)
55          {
56              throw new GTUException("maximumSpeed may not be null");
57          }
58          this.maximumSpeed = maximumSpeed;
59      }
60  
61      /** {@inheritDoc} */
62      @Override
63      public final Length getLength()
64      {
65          return this.length;
66      }
67  
68      /** {@inheritDoc} */
69      @Override
70      public final Length getWidth()
71      {
72          return this.width;
73      }
74  
75      /** {@inheritDoc} */
76      @Override
77      public final Speed getMaximumSpeed()
78      {
79          return this.maximumSpeed;
80      }
81  
82  }