Class AbstractGTUGeneratorOld

  • All Implemented Interfaces:
    java.io.Serializable, Locatable, EventProducerInterface, GtuGeneratorQueue
    Direct Known Subclasses:
    GTUGeneratorIndividualOld

    public abstract class AbstractGTUGeneratorOld
    extends EventProducer
    implements java.io.Serializable, GtuGeneratorQueue
    Common code for LaneBasedGTU generators that may have to postpone putting a GTU on the road due to congestion growing into the generator.
    Generally, these generators will discover that there is not enough room AFTER having decided what kind (particular length) of GTU will be constructed next. When this happens, the generator must remember the properties of the GTU, but postpone actual generation until there is enough room.

    Copyright (c) 2013-2020 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
    BSD-style license. See OpenTrafficSim License.

    Version:
    $Revision: 1401 $, $LastChangedDate: 2015-09-14 01:33:02 +0200 (Mon, 14 Sep 2015) $, by $Author: averbraeck $, initial version Feb 2, 2015
    Author:
    Alexander Verbraeck, Peter Knoppers
    See Also:
    Serialized Form
    • Field Detail

      • numberGTUs

        protected long numberGTUs
        Number of generated GTUs.
    • Constructor Detail

      • AbstractGTUGeneratorOld

        public AbstractGTUGeneratorOld​(java.lang.String name,
                                       DEVSSimulatorInterface.TimeDoubleUnit simulator,
                                       GTUType gtuType,
                                       java.lang.Class<?> gtuClass,
                                       ContinuousDistDoubleScalar.Rel<Speed,​SpeedUnit> initialSpeedDist,
                                       ContinuousDistDoubleScalar.Rel<Duration,​DurationUnit> interarrivelTimeDist,
                                       long maxGTUs,
                                       Time startTime,
                                       Time endTime,
                                       Lane lane,
                                       Length position,
                                       GTUDirectionality direction,
                                       LaneBasedStrategicalPlannerFactory<? extends LaneBasedStrategicalPlanner> strategicalPlannerFactory,
                                       Generator<Route> routeGenerator,
                                       OTSRoadNetwork network)
                                throws SimRuntimeException
        Parameters:
        name - String; the name of the generator
        simulator - DEVSSimulatorInterface.TimeDoubleUnit; the simulator to schedule the start of the generation
        gtuType - GTUType; the type of GTU to generate
        gtuClass - Class<?>; the GTU class to instantiate
        initialSpeedDist - ContinuousDistDoubleScalar.Rel<Speed,SpeedUnit>; distribution of the initial speed of the GTU
        interarrivelTimeDist - ContinuousDistDoubleScalar.Rel<Duration,DurationUnit>; distribution of the interarrival time
        maxGTUs - long; maximum number of GTUs to generate
        startTime - Time; start time of generation (delayed start)
        endTime - Time; end time of generation
        lane - Lane; the lane to generate the GTU on
        position - Length; position on the lane, relative to the design line of the link
        direction - GTUDirectionality; the direction on the lane in which the GTU has to be generated (DIR_PLUS, or DIR_MINUS)
        strategicalPlannerFactory - LaneBasedStrategicalPlannerFactory<? extends LaneBasedStrategicalPlanner>; the lane-based strategical planner factory to use
        routeGenerator - Generator<Route>; route generator
        network - OTSRoadNetwork; the network to register the generated GTUs into
        Throws:
        SimRuntimeException - when simulation scheduling fails
    • Method Detail

      • generate

        protected final void generate()
                               throws java.lang.Exception
        Generate a GTU.
        Throws:
        java.lang.Exception - when something in the generation fails.
      • enoughSpace

        protected final boolean enoughSpace​(LaneBasedIndividualGTU.LaneBasedIndividualCarBuilder carBuilder)
                                     throws NetworkException,
                                            GTUException
        Check if the car to be built is not overlapping with another GTU on the same lane, and if it has enough headway to be generated safely.
        Parameters:
        carBuilder - LaneBasedIndividualCarBuilder; the car to be generated
        Returns:
        true if car can be safely built, false otherwise.
        Throws:
        NetworkException - when the speed limit of the lane is not known
        GTUException - if GTU does not have a position on the lane where it is registered
      • headway

        public final Headway headway​(Length maxDistance,
                                     Lane generatorLane)
                              throws GTUException
        Check the available headway for GTU that is about to be constructed.
        Parameters:
        maxDistance - Length; the maximum distance to look for a leader
        generatorLane - Lane; the lane on which the GTU is generated
        Returns:
        HeadwayGTU; the available headway and the GTU at that headway
        Throws:
        GTUException - on network inconsistency
      • checkCarBuilderList

        protected final void checkCarBuilderList()
                                          throws java.lang.Exception
        Check if car can be generated.
        Throws:
        java.lang.Exception - on any problem
      • getName

        public final java.lang.String getName()
        Returns:
        name.
      • getGtuType

        public final GTUType getGtuType()
        Returns:
        gtuType.
      • getGtuClass

        public final java.lang.Class<?> getGtuClass()
        Returns:
        gtuClass.
      • getMaxGTUs

        public final long getMaxGTUs()
        Returns:
        maxGTUs.
      • getStartTime

        public final Time getStartTime()
        Returns:
        startTime.
      • getEndTime

        public final Time getEndTime()
        Returns:
        endTime.
      • getLocation

        public DirectedPoint getLocation()
                                  throws java.rmi.RemoteException
        Specified by:
        getLocation in interface Locatable
        Throws:
        java.rmi.RemoteException
      • getBounds

        public javax.media.j3d.Bounds getBounds()
                                         throws java.rmi.RemoteException
        Specified by:
        getBounds in interface Locatable
        Throws:
        java.rmi.RemoteException
      • getQueueLengths

        public java.util.Map<DirectedPoint,​java.lang.Integer> getQueueLengths()
        Returns the locations and lengths of generation queues. Note that the provided location may differ from the generator location, as one generator may generate GTU's at different points.
        Specified by:
        getQueueLengths in interface GtuGeneratorQueue
        Returns:
        Map<DirectedPoint, Integer>; locations and lengths of generation queues