1 package org.opentrafficsim.road.gtu.lane.perception.headway;
2
3 import org.djunits.value.vdouble.scalar.Acceleration;
4 import org.djunits.value.vdouble.scalar.Length;
5 import org.djunits.value.vdouble.scalar.Speed;
6 import org.opentrafficsim.base.parameters.ParameterSet;
7 import org.opentrafficsim.base.parameters.Parameters;
8 import org.opentrafficsim.core.gtu.GTUException;
9 import org.opentrafficsim.core.gtu.GTUType;
10 import org.opentrafficsim.core.network.route.Route;
11 import org.opentrafficsim.road.gtu.lane.LaneBasedGTU;
12 import org.opentrafficsim.road.gtu.lane.tactical.following.CarFollowingModel;
13 import org.opentrafficsim.road.network.speed.SpeedLimitInfo;
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41 public class HeadwayGTURealCopy extends AbstractHeadwayGTU
42 {
43
44 private static final long serialVersionUID = 20160527L;
45
46
47 private final CarFollowingModel carFollowingModel;
48
49
50 private final Parameters parameters;
51
52
53 private final SpeedLimitInfo speedLimitInfo;
54
55
56 private final Route route;
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75 @SuppressWarnings("checkstyle:parameternumber")
76 HeadwayGTURealCopy(final String id, final GTUType gtuType, final Length distance, final Length length, final Length width,
77 final Speed speed, final Acceleration acceleration, final CarFollowingModel carFollowingModel,
78 final Parameters parameters, final SpeedLimitInfo speedLimitInfo, final Route route, final Speed desiredSpeed,
79 final GTUStatus... gtuStatus) throws GTUException
80 {
81 super(id, gtuType, distance, true, length, width, speed, acceleration, desiredSpeed, gtuStatus);
82 this.carFollowingModel = carFollowingModel;
83 this.parameters = parameters;
84 this.speedLimitInfo = speedLimitInfo;
85 this.route = route;
86 }
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107 @SuppressWarnings("checkstyle:parameternumber")
108 HeadwayGTURealCopy(final String id, final GTUType gtuType, final Length overlapFront, final Length overlap,
109 final Length overlapRear, final Length length, final Length width, final Speed speed,
110 final Acceleration acceleration, final CarFollowingModel carFollowingModel, final Parameters parameters,
111 final SpeedLimitInfo speedLimitInfo, final Route route, final Speed desiredSpeed, final GTUStatus... gtuStatus)
112 throws GTUException
113 {
114 super(id, gtuType, overlapFront, overlap, overlapRear, true, length, width, speed, acceleration, desiredSpeed,
115 gtuStatus);
116 this.carFollowingModel = carFollowingModel;
117 this.parameters = parameters;
118 this.speedLimitInfo = speedLimitInfo;
119 this.route = route;
120 }
121
122
123
124
125
126
127
128 public HeadwayGTURealCopy(final LaneBasedGTU gtu, final Length distance) throws GTUException
129 {
130 super(gtu.getId(), gtu.getGTUType(), distance, true, gtu.getLength(), gtu.getWidth(), gtu.getSpeed(),
131 gtu.getAcceleration(), gtu.getDesiredSpeed(),
132 getGTUStatuses(gtu, gtu.getSimulator().getSimulatorTime()));
133 this.carFollowingModel = gtu.getTacticalPlanner().getCarFollowingModel();
134 this.parameters = new ParameterSet(gtu.getParameters());
135 this.speedLimitInfo = getSpeedLimitInfo(gtu);
136 this.route = gtu.getStrategicalPlanner().getRoute();
137 }
138
139
140
141
142
143
144
145
146
147 public HeadwayGTURealCopy(final LaneBasedGTU gtu, final Length overlapFront, final Length overlap, final Length overlapRear)
148 throws GTUException
149 {
150 super(gtu.getId(), gtu.getGTUType(), overlapFront, overlap, overlapRear, true, gtu.getLength(), gtu.getWidth(),
151 gtu.getSpeed(), gtu.getAcceleration(), gtu.getDesiredSpeed(),
152 getGTUStatuses(gtu, gtu.getSimulator().getSimulatorTime()));
153 this.carFollowingModel = gtu.getTacticalPlanner().getCarFollowingModel();
154 this.parameters = new ParameterSet(gtu.getParameters());
155 this.speedLimitInfo = getSpeedLimitInfo(gtu);
156 this.route = gtu.getStrategicalPlanner().getRoute();
157 }
158
159
160 @Override
161 public final CarFollowingModel getCarFollowingModel()
162 {
163 return this.carFollowingModel;
164 }
165
166
167 @Override
168 public final Parameters getParameters()
169 {
170 return this.parameters;
171 }
172
173
174 @Override
175 public final SpeedLimitInfo getSpeedLimitInfo()
176 {
177 return this.speedLimitInfo;
178 }
179
180
181 @Override
182 public final Route getRoute()
183 {
184 return this.route;
185 }
186
187
188 @Override
189 public final AbstractHeadwayGTU moved(final Length headway, final Speed speed, final Acceleration acceleration)
190 {
191 try
192 {
193 return new HeadwayGTURealCopy(getId(), getGtuType(), headway, getLength(), getWidth(), speed, acceleration,
194 getCarFollowingModel(), getParameters(), getSpeedLimitInfo(), getRoute(), getDesiredSpeed(),
195 getGtuStatus());
196 }
197 catch (GTUException exception)
198 {
199
200 throw new RuntimeException("Exception while copying Headway GTU.", exception);
201 }
202 }
203
204
205 @Override
206 public final String toString()
207 {
208 return "HeadwayGTURealCopy [carFollowingModel=" + this.carFollowingModel + ", parameters=" + this.parameters
209 + ", speedLimitInfo=" + this.speedLimitInfo + ", route=" + this.route + "]";
210 }
211
212 }