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 @Override
156 public final CarFollowingModel getCarFollowingModel()
157 {
158 return this.carFollowingModel;
159 }
160
161 @Override
162 public final Parameters getParameters()
163 {
164 return this.parameters;
165 }
166
167 @Override
168 public final SpeedLimitInfo getSpeedLimitInfo()
169 {
170 return this.speedLimitInfo;
171 }
172
173 @Override
174 public final Route getRoute()
175 {
176 return this.route;
177 }
178
179 @Override
180 public final AbstractHeadwayGtu moved(final Length headway, final Speed speed, final Acceleration acceleration)
181 {
182 try
183 {
184 return new HeadwayGtuRealCopy(getId(), getGtuType(), headway, getLength(), getWidth(), speed, acceleration,
185 getCarFollowingModel(), getParameters(), getSpeedLimitInfo(), getRoute(), getDesiredSpeed(),
186 getGtuStatus());
187 }
188 catch (GtuException exception)
189 {
190
191 throw new RuntimeException("Exception while copying Headway GTU.", exception);
192 }
193 }
194
195 @Override
196 public final String toString()
197 {
198 return "HeadwayGtuRealCopy [carFollowingModel=" + this.carFollowingModel + ", parameters=" + this.parameters
199 + ", speedLimitInfo=" + this.speedLimitInfo + ", route=" + this.route + "]";
200 }
201
202 }