Class TrafficLightSensor
java.lang.Object
nl.tudelft.simulation.event.EventProducer
org.opentrafficsim.road.network.lane.object.sensor.TrafficLightSensor
- All Implemented Interfaces:
Serializable,EventListener,Locatable,EventListenerInterface,EventProducerInterface,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-2019 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 interface nl.tudelft.simulation.event.EventProducerInterface
FIRST_POSITION, LAST_POSITIONFields 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, DEVSSimulatorInterface.TimeDoubleUnit 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
Modifier and Type Method Description protected voidaddGTU(LaneBasedGTU gtu)Add a GTU to the set.javax.media.j3d.BoundsgetBounds()StringgetId()LengthgetLanePositionA()Return the A position of this NonDirectionalOccupancySensor.LengthgetLanePositionB()Return the B position of this NonDirectionalOccupancySensor.DirectedPointgetLocation()booleangetOccupancy()Return the state of this traffic light sensor.OTSLine3DgetPath()Return the path of this traffic light sensor.RelativePosition.TYPEgetPositionTypeEntry()RelativePosition.TYPEgetPositionTypeExit()DEVSSimulatorInterface.TimeDoubleUnitgetSimulator()voidnotify(EventInterface event)protected voidremoveGTU(LaneBasedGTU gtu)Remove a GTU from the set.voidsignalDetection(FlankSensor sensor, LaneBasedGTU gtu)One of our flank sensors has triggered.StringtoString()Methods inherited from class nl.tudelft.simulation.event.EventProducer
addListener, addListener, addListener, addListener, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, removeAllListeners, removeAllListeners, removeListenerMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface nl.tudelft.simulation.event.EventProducerInterface
addListener, addListener, addListener, addListener, removeListener
-
Constructor Details
-
TrafficLightSensor
public TrafficLightSensor(String id, Lane laneA, Length positionA, Lane laneB, Length positionB, List<Lane> intermediateLanes, RelativePosition.TYPE entryPosition, RelativePosition.TYPE exitPosition, DEVSSimulatorInterface.TimeDoubleUnit simulator, Compatible compatible) throws NetworkExceptionConstruct 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- DEVSSimulatorInterface.TimeDoubleUnit; the simulatorcompatible- Compatible; object that checks that the detector detects a GTU.- Throws:
NetworkException- when the network is inconsistent.
-
-
Method Details
-
addGTU
Add a GTU to the set.- Parameters:
gtu- LaneBasedGTU; the GTU that must be added
-
removeGTU
Remove a GTU from the set.- Parameters:
gtu- LaneBasedGTU; the GTU that must be removed
-
notify
- Specified by:
notifyin interfaceEventListenerInterface- Throws:
RemoteException
-
getPositionTypeEntry
- Specified by:
getPositionTypeEntryin interfaceNonDirectionalOccupancySensor- Returns:
- the relative position type of the vehicle (e.g., FRONT, BACK) that triggers the sensor.
-
getPositionTypeExit
- Specified by:
getPositionTypeExitin interfaceNonDirectionalOccupancySensor- Returns:
- the relative position type of the vehicle (e.g., FRONT, BACK) that triggers the sensor.
-
getLanePositionA
Return the A position of this NonDirectionalOccupancySensor.- Specified by:
getLanePositionAin interfaceNonDirectionalOccupancySensor- Returns:
- Length; the lane and position on the lane where GTU entry is detected
-
getLanePositionB
Return the B position of this NonDirectionalOccupancySensor.- Specified by:
getLanePositionBin interfaceNonDirectionalOccupancySensor- Returns:
- Length; the lane and position on the lane where GTU exit is detected
-
signalDetection
One of our flank sensors has triggered.- Parameters:
sensor- FlankSensor; the sensor that was triggeredgtu- LaneBasedGTU; the gtu that triggered the flank sensor
-
getId
- Specified by:
getIdin interfaceIdentifiable- Specified by:
getIdin interfaceNonDirectionalOccupancySensor- Returns:
- The id of the sensor.
-
getSimulator
- Specified by:
getSimulatorin interfaceNonDirectionalOccupancySensor- Returns:
- The simulator.
-
getLocation
- Specified by:
getLocationin interfaceLocatable- Throws:
RemoteException
-
getBounds
- Specified by:
getBoundsin interfaceLocatable- Throws:
RemoteException
-
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
-
toString
-