Class AbstractSensor
- java.lang.Object
-
- org.djutils.event.EventProducer
-
- org.opentrafficsim.core.object.StaticObject
-
- org.opentrafficsim.road.network.lane.object.AbstractLaneBasedObject
-
- org.opentrafficsim.road.network.lane.object.sensor.AbstractSensor
-
- All Implemented Interfaces:
Serializable
,Comparable<SingleSensor>
,Locatable
,EventProducerInterface
,org.opentrafficsim.base.Identifiable
,Drawable
,Compatible
,ObjectInterface
,LaneBasedObject
,Sensor
,SingleSensor
- Direct Known Subclasses:
DestinationSensor
,Detector
,FlankSensor
,SimpleReportingSensor
,SinkSensor
public abstract class AbstractSensor extends AbstractLaneBasedObject implements SingleSensor
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.$LastChangedDate: 2015-09-14 01:33:02 +0200 (Mon, 14 Sep 2015) $, @version $Revision: 1401 $, by $Author: averbraeck $, initial version Dec 31, 2014
- Author:
- Alexander Verbraeck, Peter Knoppers
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class org.djutils.event.EventProducer
eventProducerImpl
-
Fields inherited from interface org.opentrafficsim.core.compatibility.Compatible
EVERYTHING, MINUS, PLUS
-
Fields inherited from interface org.djutils.event.EventProducerInterface
FIRST_POSITION, LAST_POSITION
-
Fields inherited from interface org.opentrafficsim.road.network.lane.object.sensor.SingleSensor
DEFAULT_SENSOR_ELEVATION, SENSOR_TRIGGER_EVENT
-
-
Constructor Summary
Constructors Constructor Description AbstractSensor(String id, Lane lane, Length longitudinalPosition, RelativePosition.TYPE positionType, OTSSimulatorInterface simulator, Compatible detectedGTUTypes)
Create a new AbstractSensor on a lane at a position on that lane at elevationSensor.DEFAULT_SENSOR_ELEVATION
and default geometry.AbstractSensor(String id, Lane lane, Length longitudinalPosition, RelativePosition.TYPE positionType, OTSSimulatorInterface simulator, OTSLine3D geometry, Length elevation, Compatible detectedGTUTypes)
Create a sensor on a lane at a position on that lane.AbstractSensor(String id, Lane lane, Length longitudinalPosition, RelativePosition.TYPE positionType, OTSSimulatorInterface simulator, OTSLine3D geometry, Compatible detectedGTUTypes)
Create a sensor on a lane at a position on that lane at elevationSensor.DEFAULT_SENSOR_ELEVATION
.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract AbstractSensor
clone(CrossSectionElement newCSE, OTSSimulatorInterface newSimulator)
Clone the LaneBasedObject for e.g., copying a network.int
compareTo(SingleSensor o)
boolean
equals(Object obj)
Compatible
getDetectedGTUTypes()
Retrieve the object that decides if a particular GTU type is detected when passing in a particular direction.RelativePosition.TYPE
getPositionType()
OTSSimulatorInterface
getSimulator()
int
hashCode()
boolean
isCompatible(GTUType gtuType, GTUDirectionality directionality)
protected static OTSLine3D
makeGeometry(Lane lane, Length longitudinalPosition, double relativeWidth)
Make a geometry perpendicular to the center line of the lane with a length of 90% of the width of the lane.String
toString()
void
trigger(LaneBasedGTU gtu)
Trigger an action on the GTU.protected abstract void
triggerResponse(LaneBasedGTU gtu)
Implementation of the response to a trigger of this sensor by a GTU.-
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, finalize, getClass, 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.road.network.lane.object.LaneBasedObject
getBounds, getDirection, getLane, getLocation, getLongitudinalPosition
-
Methods inherited from interface org.opentrafficsim.core.object.ObjectInterface
getFullId, getGeometry, getHeight
-
-
-
-
Constructor Detail
-
AbstractSensor
public AbstractSensor(String id, Lane lane, Length longitudinalPosition, RelativePosition.TYPE positionType, OTSSimulatorInterface simulator, OTSLine3D geometry, Length elevation, Compatible detectedGTUTypes) throws NetworkException
Create a sensor on a lane at a position on that lane.- Parameters:
id
- String; the id of the sensor.lane
- Lane; the lane for which this is a sensor.longitudinalPosition
- Length; the position (between 0.0 and the length of the Lane) of the sensor on the design line of the lane.positionType
- RelativePosition.TYPE; the relative position type (e.g., FRONT, BACK) of the vehicle that triggers the sensor.simulator
- OTSSimulatorInterface; the simulator (needed to generate the animation).geometry
- OTSLine3D; the geometry of the object, which provides its location and bounds as wellelevation
- Length; elevation of the sensordetectedGTUTypes
- Compatible; The GTU types will trigger this sensor- Throws:
NetworkException
- when the position on the lane is out of bounds
-
AbstractSensor
public AbstractSensor(String id, Lane lane, Length longitudinalPosition, RelativePosition.TYPE positionType, OTSSimulatorInterface simulator, OTSLine3D geometry, Compatible detectedGTUTypes) throws NetworkException
Create a sensor on a lane at a position on that lane at elevationSensor.DEFAULT_SENSOR_ELEVATION
.- Parameters:
id
- String; the id of the sensor.lane
- Lane; the lane for which this is a sensor.longitudinalPosition
- Length; the position (between 0.0 and the length of the Lane) of the sensor on the design line of the lane.positionType
- RelativePosition.TYPE; the relative position type (e.g., FRONT, BACK) of the vehicle that triggers the sensor.simulator
- OTSSimulatorInterface; the simulator (needed to generate the animation).geometry
- OTSLine3D; the geometry of the object, which provides its location and bounds as welldetectedGTUTypes
- Compatible; The GTU types will trigger this sensor- Throws:
NetworkException
- when the position on the lane is out of bounds
-
AbstractSensor
public AbstractSensor(String id, Lane lane, Length longitudinalPosition, RelativePosition.TYPE positionType, OTSSimulatorInterface simulator, Compatible detectedGTUTypes) throws NetworkException
Create a new AbstractSensor on a lane at a position on that lane at elevationSensor.DEFAULT_SENSOR_ELEVATION
and default geometry.- Parameters:
id
- String; the id of the new AbstractSensorlane
- Lane; the lane on which the new AbstractSensor is positionedlongitudinalPosition
- Length; the position (between 0.0 and the length of the Lane) of the sensor on the design line of the lanepositionType
- RelativePosition.TYPE; the relative position type (e.g., FRONT, BACK) of the vehicle that triggers the sensor.simulator
- OTSSimulatorInterface; the simulator (needed to generate the animation).detectedGTUTypes
- Compatible; The GTU types will trigger this sensor- Throws:
NetworkException
- when the position on the lane is out of bounds
-
-
Method Detail
-
makeGeometry
protected static OTSLine3D makeGeometry(Lane lane, Length longitudinalPosition, double relativeWidth) throws NetworkException
Make a geometry perpendicular to the center line of the lane with a length of 90% of the width of the lane.- Parameters:
lane
- Lane; the lane for which to make a perpendicular geometrylongitudinalPosition
- Length; the position on the lanerelativeWidth
- double; lane width to use- Returns:
- an OTSLine3D that describes the line
- Throws:
NetworkException
- in case the sensor point on the center line of the lane cannot be found
-
trigger
public final void trigger(LaneBasedGTU gtu)
Trigger an action on the GTU. Normally this is the GTU that triggered the sensor. The typical call therefore issensor.trigger(this);
.- Specified by:
trigger
in interfaceSingleSensor
- Parameters:
gtu
- LaneBasedGTU; the GTU for which to carry out the trigger action.
-
triggerResponse
protected abstract void triggerResponse(LaneBasedGTU gtu)
Implementation of the response to a trigger of this sensor by a GTU.- Parameters:
gtu
- LaneBasedGTU; the lane based GTU that triggered this sensor.
-
getPositionType
public final RelativePosition.TYPE getPositionType()
- Specified by:
getPositionType
in interfaceSingleSensor
- Returns:
- the relative position type of the vehicle (e.g., FRONT, BACK) that triggers the sensor.
-
getSimulator
public final OTSSimulatorInterface getSimulator()
- Specified by:
getSimulator
in interfaceSingleSensor
- Returns:
- The simulator.
-
compareTo
public int compareTo(SingleSensor o)
- Specified by:
compareTo
in interfaceComparable<SingleSensor>
-
toString
public String toString()
- Overrides:
toString
in classAbstractLaneBasedObject
-
clone
public abstract AbstractSensor clone(CrossSectionElement newCSE, OTSSimulatorInterface 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
- OTSSimulatorInterface; the new simulator for this network- Returns:
- AbstractLaneBasedObject; a clone of this object
- Throws:
NetworkException
- in case the cloning fails
-
isCompatible
public final boolean isCompatible(GTUType gtuType, GTUDirectionality directionality)
- Specified by:
isCompatible
in interfaceCompatible
-
getDetectedGTUTypes
public final Compatible getDetectedGTUTypes()
Retrieve the object that decides if a particular GTU type is detected when passing in a particular direction.- Returns:
- Compatible; the object that decides if a particular GTU type is detected when passing in a particular direction
-
-