Class LaneBasedGtuGenerator
java.lang.Object
org.djutils.event.LocalEventProducer
org.opentrafficsim.road.gtu.generator.LaneBasedGtuGenerator
- All Implemented Interfaces:
Serializable
,Remote
,org.djutils.base.Identifiable
,org.djutils.event.EventProducer
,Drawable
,GtuGenerator
,NonLocatedObject
public class LaneBasedGtuGenerator
extends org.djutils.event.LocalEventProducer
implements GtuGenerator
Lane based GTU generator. This generator generates lane based GTUs using a LaneBasedTemplateGTUType. The template is used to
generate a set of GTU characteristics at the times implied by the headway generator. These sets are queued until there is
sufficient room to construct a GTU at the specified lane locations. The speed of a construction GTU may be reduced to ensure
it does not run into its immediate leader GTU.
Copyright (c) 2013-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.
- Author:
- Alexander Verbraeck, Peter Knoppers, Wouter Schakel
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final class
Placement contains the information that aRoomChecker
returns.static interface
Interface for class that checks that there is sufficient room for a proposed new GTU and returns the maximum safe speed and position for the proposed new GTU.Nested classes/interfaces inherited from interface org.opentrafficsim.core.gtu.GtuGenerator
GtuGenerator.GtuGeneratorPosition
-
Field Summary
Modifier and TypeFieldDescriptionstatic final org.djutils.event.EventType
Event of a generated GTU.Fields inherited from interface org.djutils.event.EventProducer
FIRST_POSITION, LAST_POSITION
-
Constructor Summary
ConstructorDescriptionLaneBasedGtuGenerator
(String id, Generator<org.djunits.value.vdouble.scalar.Duration> interarrivelTimeGenerator, LaneBasedGtuCharacteristicsGenerator laneBasedGtuCharacteristicsGenerator, GeneratorPositions generatorPositions, RoadNetwork network, OtsSimulatorInterface simulator, LaneBasedGtuGenerator.RoomChecker roomChecker, Supplier<String> idGenerator) Construct a new lane base GTU generator. -
Method Summary
Modifier and TypeMethodDescriptionvoid
disable
(org.djunits.value.vdouble.scalar.Time start, org.djunits.value.vdouble.scalar.Time end, Lane lane) Disable the vehicle generator during the specific time.final long
final String
getId()
Retrieve the id of this LaneBasedGtuGenerator.final void
placeGtu
(LaneBasedGtuCharacteristics characteristics, LanePosition position, org.djunits.value.vdouble.scalar.Speed speed) Places a GTU, regardless of whether it has room.final void
queueGtu
(LaneBasedGtuCharacteristics characteristics, Lane lane) Adds a GTU to the generation queue.void
setErrorHandler
(GtuErrorHandler gtuErrorHandler) Sets the GTU error handler.void
setIdsInCharacteristicsOrder
(boolean idsInCharacteristicsOrder) Sets what order should be used for the ids.void
setInstantaneousLaneChange
(boolean instantaneous) Sets whether GTUs will change lane instantaneously.void
setNoLaneChangeDistance
(org.djunits.value.vdouble.scalar.Length noLaneChangeDistance) Sets the initial distance over which lane changes shouldn't be performed.final String
toString()
Methods inherited from class org.djutils.event.LocalEventProducer
addListener, addListener, addListener, addListener, fireEvent, fireEvent, fireEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireUnverifiedEvent, fireUnverifiedEvent, fireUnverifiedTimedEvent, fireUnverifiedTimedEvent, getEventListenerMap, getEventTypesWithListeners, getListenerReferences, hasListeners, numberOfListeners, removeAllListeners, removeAllListeners, removeListener
-
Field Details
-
GTU_GENERATED_EVENT
public static final org.djutils.event.EventType GTU_GENERATED_EVENTEvent of a generated GTU. Payload: LaneBasedGtu
-
-
Constructor Details
-
LaneBasedGtuGenerator
public LaneBasedGtuGenerator(String id, Generator<org.djunits.value.vdouble.scalar.Duration> interarrivelTimeGenerator, LaneBasedGtuCharacteristicsGenerator laneBasedGtuCharacteristicsGenerator, GeneratorPositions generatorPositions, RoadNetwork network, OtsSimulatorInterface simulator, LaneBasedGtuGenerator.RoomChecker roomChecker, Supplier<String> idGenerator) throws nl.tudelft.simulation.dsol.SimRuntimeException, ProbabilityException, org.opentrafficsim.base.parameters.ParameterException, NetworkException Construct a new lane base GTU generator.- Parameters:
id
- String; name of the new GTU generatorinterarrivelTimeGenerator
- Generator<Duration>; generator for the interval times between GTUslaneBasedGtuCharacteristicsGenerator
- LaneBasedGtuCharacteristicsGenerator; generator of the characteristics of each GTUgeneratorPositions
- GeneratorPositions; location and initial direction provider for all generated GTUsnetwork
- RoadNetwork; the OTS network that owns the generated GTUssimulator
- OtsSimulatorInterface; simulatorroomChecker
- RoomChecker; the way that this generator checks that there is sufficient room to place a new GTUidGenerator
- Supplier<String>; id generator- Throws:
nl.tudelft.simulation.dsol.SimRuntimeException
- when startTime lies before the current simulation timeProbabilityException
- peorg.opentrafficsim.base.parameters.ParameterException
- if drawing from the interarrival generator failsNetworkException
- if the object could not be added to the network
-
-
Method Details
-
setNoLaneChangeDistance
public void setNoLaneChangeDistance(org.djunits.value.vdouble.scalar.Length noLaneChangeDistance) Sets the initial distance over which lane changes shouldn't be performed.- Parameters:
noLaneChangeDistance
- Length; initial distance over which lane changes shouldn't be performed
-
setInstantaneousLaneChange
public void setInstantaneousLaneChange(boolean instantaneous) Sets whether GTUs will change lane instantaneously.- Parameters:
instantaneous
- boolean; whether GTUs will change lane instantaneously
-
setErrorHandler
Sets the GTU error handler.- Parameters:
gtuErrorHandler
- GTUErrorHandler; GTU error handler
-
setIdsInCharacteristicsOrder
public void setIdsInCharacteristicsOrder(boolean idsInCharacteristicsOrder) Sets what order should be used for the ids. By default this is in the order of successful GTU generation. If however the id generator is an instance ofInjections
with an id column, it is by default in the order of characteristics drawing.- Parameters:
idsInCharacteristicsOrder
- boolean; ids in order of drawing characteristics, or successful generation otherwise.
-
queueGtu
Adds a GTU to the generation queue. This method ignores whether vehicle generation is enabled at the location. This allows an external party to govern (over some time) what vehicles are generated.- Parameters:
characteristics
- LaneBasedGtuCharacteristics; characteristics of GTU to add to the queuelane
- Lane; position to generate the GTU at
-
placeGtu
public final void placeGtu(LaneBasedGtuCharacteristics characteristics, LanePosition position, org.djunits.value.vdouble.scalar.Speed speed) throws NamingException, GtuException, NetworkException, nl.tudelft.simulation.dsol.SimRuntimeException, OtsGeometryException Places a GTU, regardless of whether it has room. The user of this method should verify this is the case.- Parameters:
characteristics
- LaneBasedGtuCharacteristics; characteristicsposition
- LanePosition; positionspeed
- Speed; speed- Throws:
NamingException
- on exceptionGtuException
- on exceptionNetworkException
- on exceptionnl.tudelft.simulation.dsol.SimRuntimeException
- on exceptionOtsGeometryException
- on exception
-
toString
-
getGeneratedGTUs
public final long getGeneratedGTUs()- Returns:
- generatedGTUs.
-
getId
Retrieve the id of this LaneBasedGtuGenerator.- Specified by:
getId
in interfaceorg.djutils.base.Identifiable
- Returns:
- String; the id of this LaneBasedGtuGenerator
-
disable
public void disable(org.djunits.value.vdouble.scalar.Time start, org.djunits.value.vdouble.scalar.Time end, Lane lane) throws nl.tudelft.simulation.dsol.SimRuntimeException Disable the vehicle generator during the specific time. Underlying processes such as drawing characteristics and headways are continued, but simply will not result in the queuing of the GTU.- Parameters:
start
- Time; start timeend
- Time; end timelane
- Lane; lane to disable generation on- Throws:
nl.tudelft.simulation.dsol.SimRuntimeException
- if time is incorrect
-
getFullId
- Specified by:
getFullId
in interfaceNonLocatedObject
-
getPositions
- Specified by:
getPositions
in interfaceGtuGenerator
-