Class Conflict
- java.lang.Object
-
- org.djutils.event.EventProducer
-
- org.opentrafficsim.core.object.StaticObject
-
- org.opentrafficsim.road.network.lane.object.AbstractLaneBasedObject
-
- org.opentrafficsim.road.network.lane.conflict.Conflict
-
- All Implemented Interfaces:
Serializable
,EventListener
,Locatable
,EventListenerInterface
,EventProducerInterface
,Identifiable
,Drawable
,ObjectInterface
,LaneBasedObject
public final class Conflict extends AbstractLaneBasedObject implements EventListenerInterface
Conflicts deal with traffic on different links/roads that need to consider each other as their paths may be in conflict spatially. A singleConflict
represents the one-sided consideration of a conflicting situation. I.e., what is considered a single conflict in traffic theory, is represented by twoConflict
s, one on each of the conflictingLane
s.
This class provides easy access to upstream and downstream GTUs throughPerceptionIterable
s using methodsgetUpstreamGtus
andgetDownstreamGtus
. These methods are efficient in that they reuse underlying data structures if the GTUs are requested at the same time by another GTU.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$, $LastChangedDate$, by $Author$, initial version Sep 7, 2016
- Author:
- Alexander Verbraeck, Peter Knoppers, Wouter Schakel
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
Conflict.ConflictEnd
Light-weight lane based object to indicate the end of a conflict.
-
Field Summary
-
Fields inherited from class org.djutils.event.EventProducer
eventProducerImpl
-
Fields inherited from interface org.djutils.event.EventProducerInterface
FIRST_POSITION, LAST_POSITION
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Conflict
clone(CrossSectionElement newCSE, SimulatorInterface.TimeDoubleUnit newSimulator)
Clone the LaneBasedObject for e.g., copying a network.ConflictPriority
conflictPriority()
static void
generateConflictPair(ConflictType conflictType, ConflictRule conflictRule, boolean permitted, Lane lane1, Length longitudinalPosition1, Length length1, GTUDirectionality direction1, OTSLine3D geometry1, GTUType gtuType1, Lane lane2, Length longitudinalPosition2, Length length2, GTUDirectionality direction2, OTSLine3D geometry2, GTUType gtuType2, DEVSSimulatorInterface.TimeDoubleUnit simulator)
Creates a pair of conflicts.ConflictRule
getConflictRule()
ConflictType
getConflictType()
PerceptionCollectable<HeadwayGTU,LaneBasedGTU>
getDownstreamGtus(LaneBasedGTU perceivingGtu, HeadwayGtuType headwayGtuType, Length visibility)
Provides the downstream GTUs.GTUType
getGtuType()
Length
getLength()
Conflict
getOtherConflict()
Length
getTrafficLightDistance(Length maxDistance)
Returns the distance to an upstream traffic light.PerceptionCollectable<HeadwayGTU,LaneBasedGTU>
getUpstreamGtus(LaneBasedGTU perceivingGtu, HeadwayGtuType headwayGtuType, Length visibility)
Provides the upstream GTUs.boolean
isPermitted()
If permitted, traffic upstream of traffic lights may not be ignored, as these can have green light.void
notify(EventInterface event)
String
toString()
-
Methods inherited from class org.opentrafficsim.road.network.lane.object.AbstractLaneBasedObject
clone, getDirection, getFullId, getLane, getLocation, getLongitudinalPosition, init
-
Methods inherited from class org.opentrafficsim.core.object.StaticObject
create, create, getBounds, getGeometry, getHeight, getId, getSourceId
-
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, hasListeners, numberOfListeners, removeAllListeners, removeAllListeners, removeListener
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.djutils.event.EventProducerInterface
addListener, addListener, addListener, addListener, getEventTypesWithListeners, getSourceId, hasListeners, numberOfListeners, removeListener
-
Methods inherited from interface org.opentrafficsim.base.Identifiable
getId
-
Methods inherited from interface org.opentrafficsim.road.network.lane.object.LaneBasedObject
getBounds
-
Methods inherited from interface org.opentrafficsim.core.object.ObjectInterface
getGeometry, getHeight
-
-
-
-
Method Detail
-
getUpstreamGtus
public PerceptionCollectable<HeadwayGTU,LaneBasedGTU> getUpstreamGtus(LaneBasedGTU perceivingGtu, HeadwayGtuType headwayGtuType, Length visibility)
Provides the upstream GTUs.- Parameters:
perceivingGtu
- LaneBasedGTU; perceiving GTUheadwayGtuType
- HeadwayGtuType; headway GTU type to usevisibility
- Length; distance over which GTU's are provided- Returns:
- PerceptionIterable<HeadwayGtU>; iterable over the upstream GTUs
-
getDownstreamGtus
public PerceptionCollectable<HeadwayGTU,LaneBasedGTU> getDownstreamGtus(LaneBasedGTU perceivingGtu, HeadwayGtuType headwayGtuType, Length visibility)
Provides the downstream GTUs.- Parameters:
perceivingGtu
- LaneBasedGTU; perceiving GTUheadwayGtuType
- HeadwayGtuType; headway GTU type to usevisibility
- Length; distance over which GTU's are provided- Returns:
- PerceptionIterable<HeadwayGtU>; iterable over the downstream GTUs
-
notify
public void notify(EventInterface event) throws RemoteException
- Specified by:
notify
in interfaceEventListenerInterface
- Throws:
RemoteException
-
getConflictType
public ConflictType getConflictType()
- Returns:
- conflictType.
-
getConflictRule
public ConflictRule getConflictRule()
- Returns:
- conflictRule.
-
conflictPriority
public ConflictPriority conflictPriority()
- Returns:
- conflictPriority.
-
getLength
public Length getLength()
- Returns:
- length.
-
getOtherConflict
public Conflict getOtherConflict()
- Returns:
- otherConflict.
-
getGtuType
public GTUType getGtuType()
- Returns:
- gtuType.
-
isPermitted
public boolean isPermitted()
If permitted, traffic upstream of traffic lights may not be ignored, as these can have green light.- Returns:
- permitted.
-
getTrafficLightDistance
public Length getTrafficLightDistance(Length maxDistance)
Returns the distance to an upstream traffic light.- Parameters:
maxDistance
- Length; maximum distance of traffic light- Returns:
- Length; distance to upstream traffic light, infinite if beyond maximum distance
-
generateConflictPair
public static void generateConflictPair(ConflictType conflictType, ConflictRule conflictRule, boolean permitted, Lane lane1, Length longitudinalPosition1, Length length1, GTUDirectionality direction1, OTSLine3D geometry1, GTUType gtuType1, Lane lane2, Length longitudinalPosition2, Length length2, GTUDirectionality direction2, OTSLine3D geometry2, GTUType gtuType2, DEVSSimulatorInterface.TimeDoubleUnit simulator) throws NetworkException
Creates a pair of conflicts.- Parameters:
conflictType
- ConflictType; conflict type, i.e. crossing, merge or splitconflictRule
- ConflictRule; conflict rulepermitted
- boolean; whether the conflict is permitted in traffic light controllane1
- Lane; lane of conflict 1longitudinalPosition1
- Length; longitudinal position of conflict 1length1
- Length;Length
of conflict 1direction1
- GTUDirectionality; GTU direction of conflict 1geometry1
- OTSLine3D; geometry of conflict 1gtuType1
- GTUType; gtu type of conflict 1lane2
- Lane; lane of conflict 2longitudinalPosition2
- Length; longitudinal position of conflict 2length2
- Length;Length
of conflict 2direction2
- GTUDirectionality; GTU direction of conflict 2geometry2
- OTSLine3D; geometry of conflict 2gtuType2
- GTUType; gtu type of conflict 2simulator
- DEVSSimulatorInterface.TimeDoubleUnit; the simulator for animation and timed events- Throws:
NetworkException
- if the combination of conflict type and both conflict rules is not correct
-
toString
public String toString()
- Overrides:
toString
in classAbstractLaneBasedObject
-
clone
public Conflict clone(CrossSectionElement newCSE, SimulatorInterface.TimeDoubleUnit newSimulator) throws NetworkException
Clone the LaneBasedObject for e.g., copying a network.- Specified by:
clone
in classAbstractLaneBasedObject
- Parameters:
newCSE
- CrossSectionElement; the new cross section element to which the clone belongsnewSimulator
- SimulatorInterface.TimeDoubleUnit; the new simulator for this network- Returns:
- AbstractLaneBasedObject; a clone of this object
- Throws:
NetworkException
- in case the cloning fails
-
-