Class LoopDetector
java.lang.Object
org.djutils.event.LocalEventProducer
org.opentrafficsim.core.object.StaticObject
org.opentrafficsim.road.network.object.AbstractLaneBasedObject
org.opentrafficsim.road.network.object.detector.LaneDetector
org.opentrafficsim.road.network.object.detector.LoopDetector
- All Implemented Interfaces:
Comparable<LaneDetector>,nl.tudelft.simulation.dsol.animation.Locatable,Identifiable,EventProducer,OtsShape,HierarchicallyTyped<DetectorType,,Detector> Detector,LocatedObject,LaneBasedObject
Detector, measuring a dynamic set of measurements typical for single- or dual-loop detectors. A subsidiary detector is placed
at a position downstream based on the detector length, that triggers when the rear leaves the detector.
Copyright (c) 2013-2026 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.
- Author:
- Alexander Verbraeck, Peter Knoppers, Wouter Schakel
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classInterface for what detectors measure.static classMeasurement of platoon sizes based on time between previous GTU exit and GTU entry. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final LoopDetector.LoopDetectorMeasurement<Double,org.djunits.value.vdouble.scalar.Speed> Harmonic mean speed measurement.static final EventTypeAggregation event.static final EventTypeTrigger event.static final LoopDetector.LoopDetectorMeasurement<Double,org.djunits.value.vdouble.scalar.Speed> Mean speed measurement.static final LoopDetector.LoopDetectorMeasurement<Double,Double> Occupancy measurement.static final LoopDetector.LoopDetectorMeasurement<List<org.djunits.value.vdouble.scalar.Duration>,List<org.djunits.value.vdouble.scalar.Duration>> Passages measurement.Fields inherited from class org.opentrafficsim.road.network.object.detector.LaneDetector
DEFAULT_DETECTOR_ELEVATION, DETECTOR_TRIGGER_EVENTFields inherited from interface org.djutils.event.EventProducer
FIRST_POSITION, LAST_POSITIONFields inherited from interface org.opentrafficsim.base.geometry.OtsShape
DEFAULT_POLYGON_SEGMENTS, WORLD_MARGIN_LINE -
Constructor Summary
ConstructorsConstructorDescriptionLoopDetector(String id, LanePosition position, org.djunits.value.vdouble.scalar.Length length, DetectorType detectorType, org.djunits.value.vdouble.scalar.Duration firstAggregation, org.djunits.value.vdouble.scalar.Duration aggregation, LoopDetector.LoopDetectorMeasurement<?, ?>... measurements) Constructor.LoopDetector(String id, Lane lane, org.djunits.value.vdouble.scalar.Length longitudinalPosition, DetectorType detectorType) Constructor for regular Dutch dual-loop detectors measuring flow and mean speed aggregated over 60s. -
Method Summary
Modifier and TypeMethodDescriptionstatic TableasTableNonPeriodicData(RoadNetwork network, GtuType... gtuTypes) Returns a Table with all non-periodic data, such as vehicle passage times or platoon counts.static TableasTablePeriodicData(RoadNetwork network, GtuType... gtuTypes) Returns a Table with all periodic data, such as flow and speed per minute.static TableasTablePositions(RoadNetwork network) Returns a Table with loop detector positions.org.djunits.value.vdouble.scalar.FrequencyReturns the last flow.<A> AgetLastValue(LoopDetector.LoopDetectorMeasurement<?, A> detectorMeasurement) Returns the last value of the detector measurement.org.djunits.value.vdouble.scalar.LengthReturns the length of the object.<T> TgetNonPeriodicData(LoopDetector.LoopDetectorMeasurement<?, T> measurement) Return non-periodic data for the measurement for all GTU types.<T> TgetNonPeriodicData(LoopDetector.LoopDetectorMeasurement<?, T> measurement, GtuType gtuType) Return non-periodic data for the measurement and GTU type.<T> List<T>getPeriodicData(LoopDetector.LoopDetectorMeasurement<?, T> measurement) Return aggregated data for the measurement for all GTU types.<T> List<T>getPeriodicData(LoopDetector.LoopDetectorMeasurement<?, T> measurement, GtuType gtuType) Return aggregated data for the measurement and GTU type.booleanReturns whether the detector has aggregated data available.voidspecificDataFor(GtuType... gtuTypes) Store data specific to GTU type.protected voidImplementation of the response to a trigger of this detector by a GTU.Methods inherited from class org.opentrafficsim.road.network.object.detector.LaneDetector
compareTo, equals, getPositionType, getType, hashCode, isCompatible, toString, triggerMethods inherited from class org.opentrafficsim.road.network.object.AbstractLaneBasedObject
getFullId, getLane, getLine, getLongitudinalPosition, initMethods inherited from class org.opentrafficsim.core.object.StaticObject
create, create, getAbsoluteContour, getHeight, getId, getLocation, getRelativeBounds, getRelativeContourMethods inherited from class org.djutils.event.LocalEventProducer
getEventListenerMapMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.djutils.event.EventProducer
addListener, addListener, addListener, addListener, fireEvent, fireEvent, fireEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireUnverifiedEvent, fireUnverifiedEvent, fireUnverifiedTimedEvent, fireUnverifiedTimedEvent, getEventListenerMap, getEventTypesWithListeners, getListenerReferences, hasListeners, numberOfListeners, removeAllListeners, removeAllListeners, removeListenerMethods inherited from interface org.opentrafficsim.base.HierarchicallyTyped
isOfTypeMethods inherited from interface org.djutils.base.Identifiable
getIdMethods inherited from interface org.opentrafficsim.road.network.object.LaneBasedObject
getLane, getLine, getLocation, getLongitudinalPosition, getSimulatorMethods inherited from interface nl.tudelft.simulation.dsol.animation.Locatable
getZMethods inherited from interface org.opentrafficsim.core.object.LocatedObject
getFullId, getHeightMethods inherited from interface org.opentrafficsim.base.geometry.OtsShape
contains, contains, getAbsoluteBounds, getAbsoluteContour, getAbsoluteContour, getDirZ, getRelativeBounds, getRelativeContour, signedDistance, signedDistance
-
Field Details
-
LOOP_DETECTOR_TRIGGERED
Trigger event. Payload: [Id of LaneBasedGtu]. -
LOOP_DETECTOR_AGGREGATE
Aggregation event. Payload: [Frequency, measurement...]/ -
MEAN_SPEED
public static final LoopDetector.LoopDetectorMeasurement<Double,org.djunits.value.vdouble.scalar.Speed> MEAN_SPEEDMean speed measurement. -
HARMONIC_MEAN_SPEED
public static final LoopDetector.LoopDetectorMeasurement<Double,org.djunits.value.vdouble.scalar.Speed> HARMONIC_MEAN_SPEEDHarmonic mean speed measurement. -
OCCUPANCY
Occupancy measurement. -
PASSAGES
public static final LoopDetector.LoopDetectorMeasurement<List<org.djunits.value.vdouble.scalar.Duration>,List<org.djunits.value.vdouble.scalar.Duration>> PASSAGESPassages measurement.
-
-
Constructor Details
-
LoopDetector
public LoopDetector(String id, Lane lane, org.djunits.value.vdouble.scalar.Length longitudinalPosition, DetectorType detectorType) throws NetworkException Constructor for regular Dutch dual-loop detectors measuring flow and mean speed aggregated over 60s.- Parameters:
id- detector idlane- lanelongitudinalPosition- positiondetectorType- detector type.- Throws:
NetworkException- on network exception
-
LoopDetector
public LoopDetector(String id, LanePosition position, org.djunits.value.vdouble.scalar.Length length, DetectorType detectorType, org.djunits.value.vdouble.scalar.Duration firstAggregation, org.djunits.value.vdouble.scalar.Duration aggregation, LoopDetector.LoopDetectorMeasurement<?, ?>... measurements) throws NetworkExceptionConstructor.- Parameters:
id- detector idposition- lane positionlength- lengthfirstAggregation- time of first aggregationaggregation- aggregation periodmeasurements- measurements to obtaindetectorType- detector type.- Throws:
NetworkException- on network exceptionIllegalArgumentException- when aggregation times are negative
-
-
Method Details
-
specificDataFor
Store data specific to GTU type.- Parameters:
gtuTypes- GTU type
-
getLength
public org.djunits.value.vdouble.scalar.Length getLength()Description copied from interface:LaneBasedObjectReturns the length of the object. The default value is zero.- Returns:
- length of the object
-
triggerResponse
Description copied from class:LaneDetectorImplementation of the response to a trigger of this detector by a GTU.- Specified by:
triggerResponsein classLaneDetector- Parameters:
gtu- the lane based GTU that triggered this detector.
-
hasLastValue
public boolean hasLastValue()Returns whether the detector has aggregated data available.- Returns:
- whether the detector has aggregated data available
-
getLastFlow
public org.djunits.value.vdouble.scalar.Frequency getLastFlow()Returns the last flow.- Returns:
- last flow
-
getLastValue
Returns the last value of the detector measurement.- Type Parameters:
A- aggregate value type of the detector measurement- Parameters:
detectorMeasurement- detector measurement- Returns:
- last value of the detector measurement
-
getPeriodicData
Return aggregated data for the measurement for all GTU types.- Type Parameters:
T- measurement value type, usenullto obtain flow data which is measured by default- Parameters:
measurement- measurement- Returns:
- aggregated data for the measurement for all GTU types
- Throws:
IllegalArgumentException- when the measurement is not periodic
-
getPeriodicData
public <T> List<T> getPeriodicData(LoopDetector.LoopDetectorMeasurement<?, T> measurement, GtuType gtuType) Return aggregated data for the measurement and GTU type.- Type Parameters:
T- measurement value type, usenullto obtain flow data which is measured by default- Parameters:
measurement- measurementgtuType- GTU type- Returns:
- aggregated data for the measurement and GTU type
- Throws:
IllegalArgumentException- when there is no data for the GTU type, or the measurement is not periodic
-
getNonPeriodicData
Return non-periodic data for the measurement for all GTU types.- Type Parameters:
T- measurement value type- Parameters:
measurement- measurement- Returns:
- non-periodic data for the measurement for all GTU types
- Throws:
IllegalArgumentException- when the measurement is not non-periodic
-
getNonPeriodicData
public <T> T getNonPeriodicData(LoopDetector.LoopDetectorMeasurement<?, T> measurement, GtuType gtuType) Return non-periodic data for the measurement and GTU type.- Type Parameters:
T- measurement value type- Parameters:
measurement- measurementgtuType- GTU type- Returns:
- non-periodic data for the measurement and GTU type
- Throws:
IllegalArgumentException- when there is no data for the GTU type, or the measurement is not non-periodic
-
asTablePositions
Returns a Table with loop detector positions.- Parameters:
network- network from which all detectors are found.- Returns:
- with loop detector positions.
-
asTablePeriodicData
Returns a Table with all periodic data, such as flow and speed per minute.- Parameters:
network- network from which all detectors are found.gtuTypes- GTU types to include. When left empty, data for all is exported without GTU type column. To include data for all GTU types among data for specific GTU types, includenullvalue.- Returns:
- with all periodic data, such as flow and speed per minute.
-
asTableNonPeriodicData
Returns a Table with all non-periodic data, such as vehicle passage times or platoon counts.- Parameters:
network- network from which all detectors are found.gtuTypes- GTU types to include. When left empty, data for all is exported without GTU type column. To include data for all GTU types among data for specific GTU types, includenullvalue.- Returns:
- with all non-periodic data, such as vehicle passage times or platoon counts.
-