1 package org.opentrafficsim.road.gtu.generator.characteristics;
2
3 import org.djunits.value.vdouble.scalar.Length;
4 import org.djunits.value.vdouble.scalar.Speed;
5 import org.djutils.exceptions.Throw;
6 import org.opentrafficsim.base.parameters.ParameterException;
7 import org.opentrafficsim.core.distributions.Generator;
8 import org.opentrafficsim.core.distributions.ProbabilityException;
9 import org.opentrafficsim.core.gtu.GTUType;
10 import org.opentrafficsim.core.gtu.TemplateGTUType;
11 import org.opentrafficsim.core.network.route.Route;
12 import org.opentrafficsim.road.gtu.lane.VehicleModel;
13 import org.opentrafficsim.road.gtu.strategical.LaneBasedStrategicalPlannerFactory;
14
15
16
17
18
19
20
21
22
23
24
25
26 public class LaneBasedTemplateGTUType extends TemplateGTUType implements LaneBasedGTUCharacteristicsGenerator
27 {
28
29 private static final long serialVersionUID = 20160101L;
30
31
32 private final LaneBasedStrategicalPlannerFactory<?> strategicalPlannerFactory;
33
34
35 private final Generator<Route> routeGenerator;
36
37
38 private Generator<Speed> initialSpeedGenerator;
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53 @SuppressWarnings("checkstyle:parameternumber")
54 public LaneBasedTemplateGTUType(final GTUType gtuType, final Generator<Length> lengthGenerator,
55 final Generator<Length> widthGenerator, final Generator<Speed> maximumSpeedGenerator,
56 final LaneBasedStrategicalPlannerFactory<?> strategicalPlannerFactory, final Generator<Route> routeGenerator)
57 throws NullPointerException
58 {
59 super(gtuType, lengthGenerator, widthGenerator, maximumSpeedGenerator);
60 Throw.whenNull(strategicalPlannerFactory, "strategicalPlannerFactory is null");
61 Throw.whenNull(routeGenerator, "Route generator is null");
62 this.strategicalPlannerFactory = strategicalPlannerFactory;
63 this.routeGenerator = routeGenerator;
64 }
65
66
67
68
69
70
71
72 @Override
73 public final LaneBasedGTUCharacteristics draw() throws ProbabilityException, ParameterException
74 {
75 return new LaneBasedGTUCharacteristics(super.draw(), this.strategicalPlannerFactory, this.routeGenerator.draw(), null,
76 null, VehicleModel.MINMAX);
77 }
78
79
80 @Override
81 @SuppressWarnings("checkstyle:designforextension")
82 public String toString()
83 {
84 return String.format("LaneBasedGTUTemplate [%s, %s, %s]", this.strategicalPlannerFactory, this.initialSpeedGenerator,
85 super.toString());
86 }
87
88 }