Class AbstractGTUGeneratorOld
- java.lang.Object
-
- org.djutils.event.EventProducer
-
- org.opentrafficsim.road.gtu.generator.AbstractGTUGeneratorOld
-
- All Implemented Interfaces:
Serializable
,Locatable
,EventProducerInterface
,GtuGeneratorQueue
- Direct Known Subclasses:
GTUGeneratorIndividualOld
public abstract class AbstractGTUGeneratorOld extends EventProducer implements 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 Summary
Fields Modifier and Type Field Description protected long
numberGTUs
Number of generated GTUs.-
Fields inherited from class org.djutils.event.EventProducer
eventProducerImpl
-
Fields inherited from interface org.djutils.event.EventProducerInterface
FIRST_POSITION, LAST_POSITION
-
-
Constructor Summary
Constructors Constructor Description AbstractGTUGeneratorOld(String name, DEVSSimulatorInterface.TimeDoubleUnit simulator, GTUType gtuType, 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)
-
Method Summary
-
Methods inherited from class org.djutils.event.EventProducer
addListener, addListener, addListener, addListener, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireUnverifiedEvent, fireUnverifiedEvent, fireUnverifiedEvent, fireUnverifiedEvent, fireUnverifiedEvent, fireUnverifiedEvent, fireUnverifiedEvent, fireUnverifiedEvent, fireUnverifiedEvent, fireUnverifiedEvent, fireUnverifiedEvent, fireUnverifiedTimedEvent, fireUnverifiedTimedEvent, fireUnverifiedTimedEvent, fireUnverifiedTimedEvent, fireUnverifiedTimedEvent, fireUnverifiedTimedEvent, fireUnverifiedTimedEvent, fireUnverifiedTimedEvent, fireUnverifiedTimedEvent, fireUnverifiedTimedEvent, fireUnverifiedTimedEvent, getEventTypesWithListeners, getListenerReferences, getSourceId, hasListeners, numberOfListeners, removeAllListeners, removeAllListeners, removeListener
-
-
-
-
Constructor Detail
-
AbstractGTUGeneratorOld
public AbstractGTUGeneratorOld(String name, DEVSSimulatorInterface.TimeDoubleUnit simulator, GTUType gtuType, 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 generatorsimulator
- DEVSSimulatorInterface.TimeDoubleUnit; the simulator to schedule the start of the generationgtuType
- GTUType; the type of GTU to generategtuClass
- Class<?>; the GTU class to instantiateinitialSpeedDist
- ContinuousDistDoubleScalar.Rel<Speed,SpeedUnit>; distribution of the initial speed of the GTUinterarrivelTimeDist
- ContinuousDistDoubleScalar.Rel<Duration,DurationUnit>; distribution of the interarrival timemaxGTUs
- long; maximum number of GTUs to generatestartTime
- Time; start time of generation (delayed start)endTime
- Time; end time of generationlane
- Lane; the lane to generate the GTU onposition
- Length; position on the lane, relative to the design line of the linkdirection
- 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 userouteGenerator
- Generator<Route>; route generatornetwork
- OTSRoadNetwork; the network to register the generated GTUs into- Throws:
SimRuntimeException
- when simulation scheduling fails
-
-
Method Detail
-
generate
protected final void generate() throws Exception
Generate a GTU.- Throws:
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 knownGTUException
- 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 leadergeneratorLane
- 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 Exception
Check if car can be generated.- Throws:
Exception
- on any problem
-
getSimulator
public abstract OTSSimulatorInterface getSimulator()
- Returns:
- simulator.
-
getLengthDist
public abstract ContinuousDistDoubleScalar.Rel<Length,LengthUnit> getLengthDist()
- Returns:
- lengthDist.
-
getWidthDist
public abstract ContinuousDistDoubleScalar.Rel<Length,LengthUnit> getWidthDist()
- Returns:
- widthDist.
-
getMaximumSpeedDist
public abstract ContinuousDistDoubleScalar.Rel<Speed,SpeedUnit> getMaximumSpeedDist()
- Returns:
- maximumSpeedDist.
-
getName
public final String getName()
- Returns:
- name.
-
getGtuType
public final GTUType getGtuType()
- Returns:
- gtuType.
-
getGtuClass
public final Class<?> getGtuClass()
- Returns:
- gtuClass.
-
getInitialSpeedDist
public final ContinuousDistDoubleScalar.Rel<Speed,SpeedUnit> getInitialSpeedDist()
- Returns:
- initialSpeedDist.
-
getInterarrivelTimeDist
public final ContinuousDistDoubleScalar.Rel<Duration,DurationUnit> getInterarrivelTimeDist()
- Returns:
- interarrivelTimeDist.
-
getMaxGTUs
public final long getMaxGTUs()
- Returns:
- maxGTUs.
-
getStartTime
public final Time getStartTime()
- Returns:
- startTime.
-
getEndTime
public final Time getEndTime()
- Returns:
- endTime.
-
getStrategicalPlannerFactory
public final LaneBasedStrategicalPlannerFactory<? extends LaneBasedStrategicalPlanner> getStrategicalPlannerFactory()
- Returns:
- strategicalPlanner
-
getLocation
public DirectedPoint getLocation() throws RemoteException
- Specified by:
getLocation
in interfaceLocatable
- Throws:
RemoteException
-
getBounds
public javax.media.j3d.Bounds getBounds() throws RemoteException
- Specified by:
getBounds
in interfaceLocatable
- Throws:
RemoteException
-
getQueueLengths
public Map<DirectedPoint,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 interfaceGtuGeneratorQueue
- Returns:
- Map<DirectedPoint, Integer>; locations and lengths of generation queues
-
-