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.gtu.GTUException;
6 import org.opentrafficsim.core.gtu.GTUType;
7 import org.opentrafficsim.core.network.OTSNetwork;
8
9 import nl.tudelft.simulation.dsol.simulators.DEVSSimulatorInterface;
10
11
12
13
14
15
16
17
18
19
20
21
22
23 public abstract class AbstractLaneBasedIndividualGTU extends AbstractLaneBasedGTU
24 {
25
26 private static final long serialVersionUID = 20140822L;
27
28
29 private final Length length;
30
31
32 private final Length width;
33
34
35 private final Speed maximumSpeed;
36
37
38 private Length noLaneChangeDistance;
39
40
41
42
43
44
45
46
47
48
49
50
51 @SuppressWarnings("checkstyle:parameternumber")
52 public AbstractLaneBasedIndividualGTU(final String id, final GTUType gtuType, final Length length, final Length width,
53 final Speed maximumSpeed, final DEVSSimulatorInterface.TimeDoubleUnit simulator, final OTSNetwork network) throws GTUException
54 {
55 super(id, gtuType, simulator, network);
56 this.length = length;
57 this.width = width;
58 if (null == maximumSpeed)
59 {
60 throw new GTUException("maximumSpeed may not be null");
61 }
62 this.maximumSpeed = maximumSpeed;
63 }
64
65
66 @Override
67 public final Length getLength()
68 {
69 return this.length;
70 }
71
72
73 @Override
74 public final Length getWidth()
75 {
76 return this.width;
77 }
78
79
80 @Override
81 public final Speed getMaximumSpeed()
82 {
83 return this.maximumSpeed;
84 }
85
86
87 @Override
88 public final void setNoLaneChangeDistance(final Length distance)
89 {
90 this.noLaneChangeDistance = distance;
91 }
92
93
94 @Override
95 public final boolean laneChangeAllowed()
96 {
97 return this.noLaneChangeDistance == null ? true : getOdometer().gt(this.noLaneChangeDistance);
98 }
99
100 }