Class LoopDetector.LoopDetectorMeasurement<C,A>

java.lang.Object
org.opentrafficsim.road.network.object.detector.LoopDetector.LoopDetectorMeasurement<C,A>
Type Parameters:
C - accumulated type
A - aggregated type
Direct Known Subclasses:
LoopDetector.PlatoonSizes
Enclosing class:
LoopDetector

public abstract static class LoopDetector.LoopDetectorMeasurement<C,A> extends Object
Interface for what detectors measure.

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
  • Constructor Details

    • LoopDetectorMeasurement

      public LoopDetectorMeasurement(String name, String description, Supplier<C> identity, Class<?> valueType, boolean periodic)
      Constructor.
      Parameters:
      name - name
      description - description
      identity - identity supplier
      valueType - value type, either same as A, or e.g. T when A is List<T>
      periodic - periodic measurement (or non-periodic)
  • Method Details

    • identity

      public C identity()
      Returns the initial value before accumulation.
      Returns:
      initial value before accumulation
    • accumulateEntry

      protected abstract C accumulateEntry(C cumulative, LaneBasedGtu gtu, LoopDetector loopDetector)
      Returns an accumulated value for when the front reaches the detector. GTU's may trigger an exit without having triggered an entry due to a lane change. Reversely, GTU's may not trigger an exit while they did trigger an entry.
      Parameters:
      cumulative - accumulated value
      gtu - gtu
      loopDetector - loop detector
      Returns:
      accumulated value
    • accumulateExit

      protected abstract C accumulateExit(C cumulative, LaneBasedGtu gtu, LoopDetector loopDetector)
      Returns an accumulated value for when the rear leaves the detector. GTU's may trigger an exit without having triggered an entry due to a lane change. Reversely, GTU's may not trigger an exit while they did trigger an entry.
      Parameters:
      cumulative - accumulated value
      gtu - gtu
      loopDetector - loop detector
      Returns:
      accumulated value
    • isPeriodic

      public boolean isPeriodic()
      Returns whether the measurement aggregates every aggregation period (or only over the entire simulation).
      Returns:
      whether the measurement aggregates every aggregation period (or only over the entire simulation)
    • aggregate

      protected abstract A aggregate(C cumulative, int gtuCount, org.djunits.value.vdouble.scalar.Duration aggregation)
      Returns an aggregated value.
      Parameters:
      cumulative - accumulated value
      gtuCount - GTU gtuCount
      aggregation - aggregation period
      Returns:
      aggregated value
    • getName

      public String getName()
      Returns the value name.
      Returns:
      value name
    • getDescription

      public String getDescription()
      Measurement description.
      Returns:
      measurement description.
    • getUnit

      public String getUnit()
      Returns the unit string, default is null.
      Returns:
      unit string.
    • getValueType

      public Class<?> getValueType()
      Returns the data type.
      Returns:
      data type.
    • toString

      public String toString()
      Overrides:
      toString in class Object