View Javadoc
1   package org.opentrafficsim.road.gtu.generator;
2   
3   import java.io.Serializable;
4   
5   import nl.tudelft.simulation.dsol.SimRuntimeException;
6   
7   import org.djunits.unit.LengthUnit;
8   import org.djunits.unit.SpeedUnit;
9   import org.djunits.unit.TimeUnit;
10  import org.djunits.value.vdouble.scalar.Duration;
11  import org.djunits.value.vdouble.scalar.Length;
12  import org.djunits.value.vdouble.scalar.Speed;
13  import org.djunits.value.vdouble.scalar.Time;
14  import org.opentrafficsim.core.dsol.OTSDEVSSimulatorInterface;
15  import org.opentrafficsim.core.gtu.GTUDirectionality;
16  import org.opentrafficsim.core.gtu.GTUType;
17  import org.opentrafficsim.core.gtu.animation.GTUColorer;
18  import org.opentrafficsim.core.network.OTSNetwork;
19  import org.opentrafficsim.core.units.distributions.ContinuousDistDoubleScalar;
20  import org.opentrafficsim.road.gtu.strategical.LaneBasedStrategicalPlanner;
21  import org.opentrafficsim.road.gtu.strategical.LaneBasedStrategicalPlannerFactory;
22  import org.opentrafficsim.road.network.lane.Lane;
23  
24  /**
25   * Generate GTUs.
26   * <p>
27   * Copyright (c) 2013-2016 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
28   * BSD-style license. See <a href="http://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
29   * <p>
30   * @version $Revision: 1401 $, $LastChangedDate: 2015-09-14 01:33:02 +0200 (Mon, 14 Sep 2015) $, by $Author: averbraeck $,
31   *          initial version Feb 2, 2015 <br>
32   * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
33   * @author <a href="http://www.tudelft.nl/pknoppers">Peter Knoppers</a>
34   */
35  public class GTUGeneratorIndividual extends AbstractGTUGenerator implements Serializable
36  {
37      /** */
38      private static final long serialVersionUID = 20160000L;
39  
40      /** Simulator to schedule next arrival events. */
41      private final OTSDEVSSimulatorInterface simulator;
42  
43      /** Distribution of the length of the GTU. */
44      private final ContinuousDistDoubleScalar.Rel<Length, LengthUnit> lengthDist;
45  
46      /** Distribution of the width of the GTU. */
47      private final ContinuousDistDoubleScalar.Rel<Length, LengthUnit> widthDist;
48  
49      /** Distribution of the maximum speed of the GTU. */
50      private final ContinuousDistDoubleScalar.Rel<Speed, SpeedUnit> maximumSpeedDist;
51  
52      /**
53       * @param name the name of the generator
54       * @param gtuType the type of GTU to generate
55       * @param gtuClass the gtu class to instantiate
56       * @param initialSpeedDist distribution of the initial speed of the GTU
57       * @param interarrivelTimeDist distribution of the interarrival time
58       * @param maxGTUs maximum number of GTUs to generate
59       * @param startTime start time of generation (delayed start)
60       * @param endTime end time of generation
61       * @param simulator simulator to schedule next arrival events
62       * @param lengthDist distribution of the length of the GTU
63       * @param widthDist distribution of the width of the GTU
64       * @param maximumSpeedDist distribution of the maximum speed of the GTU
65       * @param lane Lane on which newly GTUs are placed
66       * @param position position on the lane, relative to the design line of the link
67       * @param direction the direction on the lane in which the GTU has to be generated (DIR_PLUS, or DIR_MINUS)
68       * @param gtuColorer the GTUColorer to use
69       * @param strategicalPlannerFactory the lane-based strategical planner factory to use
70       * @param network the network to register the GTU into
71       * @throws SimRuntimeException when simulation scheduling fails
72       */
73      @SuppressWarnings("checkstyle:parameternumber")
74      public GTUGeneratorIndividual(final String name, final OTSDEVSSimulatorInterface simulator, final GTUType gtuType,
75          final Class<?> gtuClass, final ContinuousDistDoubleScalar.Rel<Speed, SpeedUnit> initialSpeedDist,
76          final ContinuousDistDoubleScalar.Rel<Duration, TimeUnit> interarrivelTimeDist,
77          final ContinuousDistDoubleScalar.Rel<Length, LengthUnit> lengthDist,
78          final ContinuousDistDoubleScalar.Rel<Length, LengthUnit> widthDist,
79          final ContinuousDistDoubleScalar.Rel<Speed, SpeedUnit> maximumSpeedDist, final long maxGTUs,
80          final Time startTime, final Time endTime, final Lane lane, final Length position,
81          final GTUDirectionality direction, final GTUColorer gtuColorer,
82          final LaneBasedStrategicalPlannerFactory<? extends LaneBasedStrategicalPlanner> strategicalPlannerFactory,
83          final OTSNetwork network) throws SimRuntimeException
84      {
85          super(name, simulator, gtuType, gtuClass, initialSpeedDist, interarrivelTimeDist, maxGTUs, startTime, endTime,
86              lane, position, direction, gtuColorer, strategicalPlannerFactory, network);
87          this.simulator = simulator;
88          this.lengthDist = lengthDist;
89          this.widthDist = widthDist;
90          this.maximumSpeedDist = maximumSpeedDist;
91      }
92  
93      /** {@inheritDoc} */
94      @Override
95      public final OTSDEVSSimulatorInterface getSimulator()
96      {
97          return this.simulator;
98      }
99  
100     /**
101      * @return lengthDist.
102      */
103     public final ContinuousDistDoubleScalar.Rel<Length, LengthUnit> getLengthDist()
104     {
105         return this.lengthDist;
106     }
107 
108     /**
109      * @return widthDist.
110      */
111     public final ContinuousDistDoubleScalar.Rel<Length, LengthUnit> getWidthDist()
112     {
113         return this.widthDist;
114     }
115 
116     /**
117      * @return maximumSpeedDist.
118      */
119     public final ContinuousDistDoubleScalar.Rel<Speed, SpeedUnit> getMaximumSpeedDist()
120     {
121         return this.maximumSpeedDist;
122     }
123 
124     /** {@inheritDoc} */
125     @Override
126     public final String toString()
127     {
128         return "GTUGeneratorIndividual [lengthDist=" + this.lengthDist + ", widthDist=" + this.widthDist
129                 + ", maximumSpeedDist=" + this.maximumSpeedDist + "]";
130     }
131 
132 }