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 public class HeadwayGtuRealCopy extends AbstractHeadwayGtu
39 {
40
41 private static final long serialVersionUID = 20160527L;
42
43
44 private final CarFollowingModel carFollowingModel;
45
46
47 private final Parameters parameters;
48
49
50 private final SpeedLimitInfo speedLimitInfo;
51
52
53 private final Route route;
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72 @SuppressWarnings("checkstyle:parameternumber")
73 HeadwayGtuRealCopy(final String id, final GtuType gtuType, final Length distance, final Length length, final Length width,
74 final Speed speed, final Acceleration acceleration, final CarFollowingModel carFollowingModel,
75 final Parameters parameters, final SpeedLimitInfo speedLimitInfo, final Route route, final Speed desiredSpeed,
76 final GtuStatus... gtuStatus) throws GtuException
77 {
78 super(id, gtuType, distance, true, length, width, speed, acceleration, desiredSpeed, gtuStatus);
79 this.carFollowingModel = carFollowingModel;
80 this.parameters = parameters;
81 this.speedLimitInfo = speedLimitInfo;
82 this.route = route;
83 }
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104 @SuppressWarnings("checkstyle:parameternumber")
105 HeadwayGtuRealCopy(final String id, final GtuType gtuType, final Length overlapFront, final Length overlap,
106 final Length overlapRear, final Length length, final Length width, final Speed speed,
107 final Acceleration acceleration, final CarFollowingModel carFollowingModel, final Parameters parameters,
108 final SpeedLimitInfo speedLimitInfo, final Route route, final Speed desiredSpeed, final GtuStatus... gtuStatus)
109 throws GtuException
110 {
111 super(id, gtuType, overlapFront, overlap, overlapRear, true, length, width, speed, acceleration, desiredSpeed,
112 gtuStatus);
113 this.carFollowingModel = carFollowingModel;
114 this.parameters = parameters;
115 this.speedLimitInfo = speedLimitInfo;
116 this.route = route;
117 }
118
119
120
121
122
123
124
125 public HeadwayGtuRealCopy(final LaneBasedGtu gtu, final Length distance) throws GtuException
126 {
127 super(gtu.getId(), gtu.getType(), distance, true, gtu.getLength(), gtu.getWidth(), gtu.getSpeed(),
128 gtu.getAcceleration(), gtu.getDesiredSpeed(), getGtuStatuses(gtu, gtu.getSimulator().getSimulatorAbsTime()));
129 this.carFollowingModel = gtu.getTacticalPlanner().getCarFollowingModel();
130 this.parameters = new ParameterSet(gtu.getParameters());
131 this.speedLimitInfo = getSpeedLimitInfo(gtu);
132 this.route = gtu.getStrategicalPlanner().getRoute();
133 }
134
135
136
137
138
139
140
141
142
143 public HeadwayGtuRealCopy(final LaneBasedGtu gtu, final Length overlapFront, final Length overlap, final Length overlapRear)
144 throws GtuException
145 {
146 super(gtu.getId(), gtu.getType(), overlapFront, overlap, overlapRear, true, gtu.getLength(), gtu.getWidth(),
147 gtu.getSpeed(), gtu.getAcceleration(), gtu.getDesiredSpeed(),
148 getGtuStatuses(gtu, gtu.getSimulator().getSimulatorAbsTime()));
149 this.carFollowingModel = gtu.getTacticalPlanner().getCarFollowingModel();
150 this.parameters = new ParameterSet(gtu.getParameters());
151 this.speedLimitInfo = getSpeedLimitInfo(gtu);
152 this.route = gtu.getStrategicalPlanner().getRoute();
153 }
154
155
156 @Override
157 public final CarFollowingModel getCarFollowingModel()
158 {
159 return this.carFollowingModel;
160 }
161
162
163 @Override
164 public final Parameters getParameters()
165 {
166 return this.parameters;
167 }
168
169
170 @Override
171 public final SpeedLimitInfo getSpeedLimitInfo()
172 {
173 return this.speedLimitInfo;
174 }
175
176
177 @Override
178 public final Route getRoute()
179 {
180 return this.route;
181 }
182
183
184 @Override
185 public final AbstractHeadwayGtu moved(final Length headway, final Speed speed, final Acceleration acceleration)
186 {
187 try
188 {
189 return new HeadwayGtuRealCopy(getId(), getGtuType(), headway, getLength(), getWidth(), speed, acceleration,
190 getCarFollowingModel(), getParameters(), getSpeedLimitInfo(), getRoute(), getDesiredSpeed(),
191 getGtuStatus());
192 }
193 catch (GtuException exception)
194 {
195
196 throw new RuntimeException("Exception while copying Headway GTU.", exception);
197 }
198 }
199
200
201 @Override
202 public final String toString()
203 {
204 return "HeadwayGtuRealCopy [carFollowingModel=" + this.carFollowingModel + ", parameters=" + this.parameters
205 + ", speedLimitInfo=" + this.speedLimitInfo + ", route=" + this.route + "]";
206 }
207
208 }