Class TrafficLightSensor
- java.lang.Object
-
- org.djutils.event.EventProducer
-
- org.opentrafficsim.road.network.lane.object.sensor.TrafficLightSensor
-
- All Implemented Interfaces:
Serializable
,EventListener
,Locatable
,EventListenerInterface
,EventProducerInterface
,org.opentrafficsim.base.Identifiable
,NonDirectionalOccupancySensor
,Sensor
public class TrafficLightSensor extends EventProducer implements EventListenerInterface, NonDirectionalOccupancySensor, EventProducerInterface, Locatable, Sensor
This traffic light sensor reports whether it whether any GTUs are within its area. The area is a sub-section of a Lane. This traffic sensor does not report the total number of GTUs within the area; only whether that number is zero or non-zero.Copyright (c) 2013-2022 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 Oct 27, 2016
- Author:
- Alexander Verbraeck, Peter Knoppers, Wouter Schakel
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class org.djutils.event.EventProducer
eventProducerImpl
-
Fields inherited from interface org.djutils.event.EventProducerInterface
FIRST_POSITION, LAST_POSITION
-
Fields inherited from interface org.opentrafficsim.road.network.lane.object.sensor.NonDirectionalOccupancySensor
NON_DIRECTIONAL_OCCUPANCY_SENSOR_TRIGGER_ENTRY_EVENT, NON_DIRECTIONAL_OCCUPANCY_SENSOR_TRIGGER_EXIT_EVENT
-
-
Constructor Summary
Constructors Constructor Description TrafficLightSensor(String id, Lane laneA, Length positionA, Lane laneB, Length positionB, List<Lane> intermediateLanes, RelativePosition.TYPE entryPosition, RelativePosition.TYPE exitPosition, OTSSimulatorInterface simulator, Compatible compatible)
Construct a new traffic light sensor.
TODO Possibly provide the GTUTypes that trigger the sensor as an argument for the constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addGTU(LaneBasedGTU gtu)
Add a GTU to the set.Bounds
getBounds()
String
getId()
Length
getLanePositionA()
Return the A position of this NonDirectionalOccupancySensor.Length
getLanePositionB()
Return the B position of this NonDirectionalOccupancySensor.DirectedPoint
getLocation()
boolean
getOccupancy()
Return the state of this traffic light sensor.OTSLine3D
getPath()
Return the path of this traffic light sensor.RelativePosition.TYPE
getPositionTypeEntry()
RelativePosition.TYPE
getPositionTypeExit()
OTSSimulatorInterface
getSimulator()
Serializable
getSourceId()
void
notify(EventInterface event)
protected void
removeGTU(LaneBasedGTU gtu)
Remove a GTU from the set.void
signalDetection(FlankSensor sensor, LaneBasedGTU gtu)
One of our flank sensors has triggered.String
toString()
-
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, hasListeners, numberOfListeners, removeListener
-
-
-
-
Constructor Detail
-
TrafficLightSensor
public TrafficLightSensor(String id, Lane laneA, Length positionA, Lane laneB, Length positionB, List<Lane> intermediateLanes, RelativePosition.TYPE entryPosition, RelativePosition.TYPE exitPosition, OTSSimulatorInterface simulator, Compatible compatible) throws NetworkException
Construct a new traffic light sensor.
TODO Possibly provide the GTUTypes that trigger the sensor as an argument for the constructor- Parameters:
id
- String; id of this sensorlaneA
- Lane; the lane of the A detection point of this traffic light sensorpositionA
- Length; the position of the A detection point of this traffic light sensorlaneB
- Lane; the lane of the B detection point of this traffic light sensorpositionB
- Length; the position of the B detection point of this traffic light sensorintermediateLanes
- List<Lane>; list of intermediate lanesentryPosition
- TYPE; the position on the GTUs that trigger the entry eventsexitPosition
- TYPE; the position on the GTUs that trigger the exit eventssimulator
- OTSSimulatorInterface; the simulatorcompatible
- Compatible; object that checks that the detector detects a GTU.- Throws:
NetworkException
- when the network is inconsistent.
-
-
Method Detail
-
addGTU
protected final void addGTU(LaneBasedGTU gtu)
Add a GTU to the set.- Parameters:
gtu
- LaneBasedGTU; the GTU that must be added
-
removeGTU
protected final void removeGTU(LaneBasedGTU gtu)
Remove a GTU from the set.- Parameters:
gtu
- LaneBasedGTU; the GTU that must be removed
-
notify
public final void notify(EventInterface event) throws RemoteException
- Specified by:
notify
in interfaceEventListenerInterface
- Throws:
RemoteException
-
getPositionTypeEntry
public final RelativePosition.TYPE getPositionTypeEntry()
- Specified by:
getPositionTypeEntry
in interfaceNonDirectionalOccupancySensor
- Returns:
- the relative position type of the vehicle (e.g., FRONT, BACK) that triggers the sensor.
-
getPositionTypeExit
public final RelativePosition.TYPE getPositionTypeExit()
- Specified by:
getPositionTypeExit
in interfaceNonDirectionalOccupancySensor
- Returns:
- the relative position type of the vehicle (e.g., FRONT, BACK) that triggers the sensor.
-
getLanePositionA
public final Length getLanePositionA()
Return the A position of this NonDirectionalOccupancySensor.- Specified by:
getLanePositionA
in interfaceNonDirectionalOccupancySensor
- Returns:
- Length; the lane and position on the lane where GTU entry is detected
-
getLanePositionB
public final Length getLanePositionB()
Return the B position of this NonDirectionalOccupancySensor.- Specified by:
getLanePositionB
in interfaceNonDirectionalOccupancySensor
- Returns:
- Length; the lane and position on the lane where GTU exit is detected
-
signalDetection
public final void signalDetection(FlankSensor sensor, LaneBasedGTU gtu)
One of our flank sensors has triggered.- Parameters:
sensor
- FlankSensor; the sensor that was triggeredgtu
- LaneBasedGTU; the gtu that triggered the flank sensor
-
getId
public final String getId()
- Specified by:
getId
in interfaceorg.opentrafficsim.base.Identifiable
- Specified by:
getId
in interfaceNonDirectionalOccupancySensor
- Returns:
- The id of the sensor.
-
getSimulator
public final OTSSimulatorInterface getSimulator()
- Specified by:
getSimulator
in interfaceNonDirectionalOccupancySensor
- Returns:
- The simulator.
-
getLocation
public final DirectedPoint getLocation()
- Specified by:
getLocation
in interfaceLocatable
-
getBounds
public final Bounds getBounds() throws RemoteException
- Specified by:
getBounds
in interfaceLocatable
- Throws:
RemoteException
-
getPath
public final OTSLine3D getPath()
Return the path of this traffic light sensor.- Returns:
- OTSLine3D; the path of this traffic light sensor
-
getOccupancy
public final boolean getOccupancy()
Return the state of this traffic light sensor.- Returns:
- boolean; true if one or more GTUs are currently detected; false of no GTUs are currently detected
-
getSourceId
public Serializable getSourceId()
- Specified by:
getSourceId
in interfaceEventProducerInterface
- Specified by:
getSourceId
in classEventProducer
-
-