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,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-2020 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 interface org.opentrafficsim.core.compatibility.Compatible
EVERYTHING, MINUS, PLUSFields inherited from interface org.djutils.event.EventProducerInterface
FIRST_POSITION, LAST_POSITIONFields 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, DEVSSimulatorInterface.TimeDoubleUnit simulator, Compatible detectedGTUTypes)Create a new AbstractSensor on a lane at a position on that lane at elevationSensor.DEFAULT_SENSOR_ELEVATIONand default geometry.AbstractSensor(String id, Lane lane, Length longitudinalPosition, RelativePosition.TYPE positionType, DEVSSimulatorInterface.TimeDoubleUnit 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, DEVSSimulatorInterface.TimeDoubleUnit simulator, OTSLine3D geometry, Compatible detectedGTUTypes)Create a sensor on a lane at a position on that lane at elevationSensor.DEFAULT_SENSOR_ELEVATION. -
Method Summary
Modifier and Type Method Description abstract AbstractSensorclone(CrossSectionElement newCSE, SimulatorInterface.TimeDoubleUnit newSimulator)Clone the LaneBasedObject for e.g., copying a network.intcompareTo(SingleSensor o)booleanequals(Object obj)CompatiblegetDetectedGTUTypes()Retrieve the object that decides if a particular GTU type is detected when passing in a particular direction.RelativePosition.TYPEgetPositionType()DEVSSimulatorInterface.TimeDoubleUnitgetSimulator()inthashCode()booleanisCompatible(GTUType gtuType, GTUDirectionality directionality)protected static OTSLine3DmakeGeometry(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.StringtoString()voidtrigger(LaneBasedGTU gtu)Trigger an action on the GTU.protected abstract voidtriggerResponse(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, initMethods inherited from class org.opentrafficsim.core.object.StaticObject
create, create, getBounds, getGeometry, getHeight, getId, getSourceIdMethods inherited from class org.djutils.event.EventProducer
addListener, addListener, addListener, addListener, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, getEventTypesWithListeners, getListenerReferences, hasListeners, numberOfListeners, removeAllListeners, removeAllListeners, removeListenerMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.djutils.event.EventProducerInterface
addListener, addListener, addListener, addListener, getEventTypesWithListeners, getSourceId, hasListeners, numberOfListeners, removeListenerMethods inherited from interface org.opentrafficsim.road.network.lane.object.LaneBasedObject
getBounds, getDirection, getLane, getLocation, getLongitudinalPositionMethods inherited from interface org.opentrafficsim.core.object.ObjectInterface
getFullId, getGeometry, getHeight
-
Constructor Details
-
AbstractSensor
public AbstractSensor(String id, Lane lane, Length longitudinalPosition, RelativePosition.TYPE positionType, DEVSSimulatorInterface.TimeDoubleUnit simulator, OTSLine3D geometry, Length elevation, Compatible detectedGTUTypes) throws NetworkExceptionCreate 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- DEVSSimulatorInterface.TimeDoubleUnit; 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, DEVSSimulatorInterface.TimeDoubleUnit simulator, OTSLine3D geometry, Compatible detectedGTUTypes) throws NetworkExceptionCreate 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- DEVSSimulatorInterface.TimeDoubleUnit; 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, DEVSSimulatorInterface.TimeDoubleUnit simulator, Compatible detectedGTUTypes) throws NetworkExceptionCreate a new AbstractSensor on a lane at a position on that lane at elevationSensor.DEFAULT_SENSOR_ELEVATIONand 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- DEVSSimulatorInterface.TimeDoubleUnit; 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 Details
-
makeGeometry
protected static OTSLine3D makeGeometry(Lane lane, Length longitudinalPosition, double relativeWidth) throws NetworkExceptionMake 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
Trigger an action on the GTU. Normally this is the GTU that triggered the sensor. The typical call therefore issensor.trigger(this);.- Specified by:
triggerin interfaceSingleSensor- Parameters:
gtu- LaneBasedGTU; the GTU for which to carry out the trigger action.
-
triggerResponse
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
- Specified by:
getPositionTypein interfaceSingleSensor- Returns:
- the relative position type of the vehicle (e.g., FRONT, BACK) that triggers the sensor.
-
getSimulator
- Specified by:
getSimulatorin interfaceSingleSensor- Returns:
- The simulator.
-
hashCode
public int hashCode() -
equals
-
compareTo
- Specified by:
compareToin interfaceComparable<SingleSensor>
-
toString
- Overrides:
toStringin classAbstractLaneBasedObject
-
clone
public abstract AbstractSensor clone(CrossSectionElement newCSE, SimulatorInterface.TimeDoubleUnit newSimulator) throws NetworkExceptionClone the LaneBasedObject for e.g., copying a network.- Specified by:
clonein 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
-
isCompatible
- Specified by:
isCompatiblein interfaceCompatible
-
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
-