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.GtuTemplate;
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 public class LaneBasedGtuTemplate extends GtuTemplate implements LaneBasedGtuCharacteristicsGenerator
25 {
26
27 private static final long serialVersionUID = 20160101L;
28
29
30 private final LaneBasedStrategicalPlannerFactory<?> strategicalPlannerFactory;
31
32
33 private final Generator<Route> routeGenerator;
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48 @SuppressWarnings("checkstyle:parameternumber")
49 public LaneBasedGtuTemplate(final GtuType gtuType, final Generator<Length> lengthGenerator,
50 final Generator<Length> widthGenerator, final Generator<Speed> maximumSpeedGenerator,
51 final LaneBasedStrategicalPlannerFactory<?> strategicalPlannerFactory, final Generator<Route> routeGenerator)
52 throws NullPointerException
53 {
54 super(gtuType, lengthGenerator, widthGenerator, maximumSpeedGenerator);
55 Throw.whenNull(strategicalPlannerFactory, "strategicalPlannerFactory is null");
56 Throw.whenNull(routeGenerator, "Route generator is null");
57 this.strategicalPlannerFactory = strategicalPlannerFactory;
58 this.routeGenerator = routeGenerator;
59 }
60
61
62
63
64
65
66
67 @Override
68 public final LaneBasedGtuCharacteristics draw() throws ProbabilityException, ParameterException
69 {
70 return new LaneBasedGtuCharacteristics(super.draw(), this.strategicalPlannerFactory, this.routeGenerator.draw(), null,
71 null, VehicleModel.MINMAX);
72 }
73
74
75 @Override
76 @SuppressWarnings("checkstyle:designforextension")
77 public String toString()
78 {
79 return String.format("LaneBasedGtuTemplate [%s, %s]", this.strategicalPlannerFactory,
80 super.toString());
81 }
82
83 }