Class Sampler<G extends GtuData,L extends LaneData<L>>

java.lang.Object
org.opentrafficsim.kpi.sampling.Sampler<G,L>
Type Parameters:
G - gtu data type
L - lane data type

public abstract class Sampler<G extends GtuData,L extends LaneData<L>> extends Object
Sampler is the highest level organizer for sampling.

Copyright (c) 2013-2024 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 Summary

    Constructors
    Constructor
    Description
    Sampler(Set<ExtendedDataType<?,?,?,? super G>> extendedDataTypes, Set<FilterDataType<?,? super G>> filterDataTypes)
    Constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    contains(ExtendedDataType<?,?,?,?> extendedDataType)
    Whether this sampler has the given extended data type registered to it.
    boolean
    abstract void
    Remove listeners to stop recording.
    Underlying sampler data.
    int
    abstract void
    Adds listeners to start recording.
    abstract org.djunits.value.vdouble.scalar.Time
    now()
    Returns the current simulation time.
    final void
    processGtuAddEvent(L lane, G gtu)
    Creates a trajectory, including filter data.
    final void
    processGtuAddEventWithMove(L lane, org.djunits.value.vdouble.scalar.Length position, org.djunits.value.vdouble.scalar.Speed speed, org.djunits.value.vdouble.scalar.Acceleration acceleration, org.djunits.value.vdouble.scalar.Time time, G gtu)
    Creates a trajectory with the current snapshot of a GTU.
    final void
    processGtuMoveEvent(L lane, org.djunits.value.vdouble.scalar.Length position, org.djunits.value.vdouble.scalar.Speed speed, org.djunits.value.vdouble.scalar.Acceleration acceleration, org.djunits.value.vdouble.scalar.Time time, G gtu)
    Adds a new snapshot of a GTU to its recording trajectory, if recorded.
    final void
    Finalizes a trajectory.
    final void
    processGtuRemoveEventWithMove(L lane, org.djunits.value.vdouble.scalar.Length position, org.djunits.value.vdouble.scalar.Speed speed, org.djunits.value.vdouble.scalar.Acceleration acceleration, org.djunits.value.vdouble.scalar.Time time, G gtu)
    Finalizes a trajectory with the current snapshot of a GTU.
    final void
    Registers a space-time region.
    abstract void
    scheduleStartRecording(org.djunits.value.vdouble.scalar.Time time, L lane)
    Schedules the start of recording for a given lane, i.e. the implementation has to invoke startRecording at the specified time, with the given lane as input.
    abstract void
    scheduleStopRecording(org.djunits.value.vdouble.scalar.Time time, L lane)
    Schedules the stop of recording for a given lane, i.e. the implementation has to invoke stopRecording at the specified time, with the given lane as input.
    final void
    Start recording at the given time (which should be the current time) on the given lane.
    final void
    Stop recording at given lane.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Sampler

      public Sampler(Set<ExtendedDataType<?,?,?,? super G>> extendedDataTypes, Set<FilterDataType<?,? super G>> filterDataTypes)
      Constructor.
      Parameters:
      extendedDataTypes - Set<ExtendedDataType<?, ?, ?, ? super G>>; extended data types.
      filterDataTypes - Set<FilterDataType<?, ? super G>>; filter data types.
  • Method Details

    • getSamplerData

      public SamplerData<G> getSamplerData()
      Underlying sampler data.
      Returns:
      SamplerData<G>; underlying sampler data
    • contains

      public boolean contains(ExtendedDataType<?,?,?,?> extendedDataType)
      Whether this sampler has the given extended data type registered to it.
      Parameters:
      extendedDataType - ExtendedDataType<?,?,?,?>; extended data type
      Returns:
      whether this sampler has the given extended data type registered to it
    • registerSpaceTimeRegion

      public final void registerSpaceTimeRegion(SpaceTimeRegion<L> spaceTimeRegion)
      Registers a space-time region. Data will be recorded across the entire length of a lane, but only during specified time periods.
      Parameters:
      spaceTimeRegion - SpaceTimeRegion<L>; space-time region
      Throws:
      IllegalStateException - if data is not available from the requested start time
    • now

      public abstract org.djunits.value.vdouble.scalar.Time now()
      Returns the current simulation time.
      Returns:
      current simulation time
    • scheduleStartRecording

      public abstract void scheduleStartRecording(org.djunits.value.vdouble.scalar.Time time, L lane)
      Schedules the start of recording for a given lane, i.e. the implementation has to invoke startRecording at the specified time, with the given lane as input. In case multiple space time-regions are registered for the same lane, this method is invoked whenever the next space-time region that is added has an earlier start time than any before.
      Parameters:
      time - Time; time to start recording
      lane - L; lane to start recording
    • scheduleStopRecording

      public abstract void scheduleStopRecording(org.djunits.value.vdouble.scalar.Time time, L lane)
      Schedules the stop of recording for a given lane, i.e. the implementation has to invoke stopRecording at the specified time, with the given lane as input. In case multiple space time-regions are registered for the same lane, this method is invoked whenever the next space-time region that is added has a late end time than any before.
      Parameters:
      time - Time; time to stop recording
      lane - L; lane to stop recording
    • startRecording

      public final void startRecording(L lane)
      Start recording at the given time (which should be the current time) on the given lane.
      Parameters:
      lane - L; lane
    • initRecording

      public abstract void initRecording(L lane)
      Adds listeners to start recording.
      Parameters:
      lane - L; lane to initialize recording for
    • stopRecording

      public final void stopRecording(L lane)
      Stop recording at given lane.
      Parameters:
      lane - L; lane
    • finalizeRecording

      public abstract void finalizeRecording(L lane)
      Remove listeners to stop recording.
      Parameters:
      lane - L; lane
    • processGtuAddEventWithMove

      public final void processGtuAddEventWithMove(L lane, org.djunits.value.vdouble.scalar.Length position, org.djunits.value.vdouble.scalar.Speed speed, org.djunits.value.vdouble.scalar.Acceleration acceleration, org.djunits.value.vdouble.scalar.Time time, G gtu)
      Creates a trajectory with the current snapshot of a GTU.
      Parameters:
      lane - L; lane the gtu is at
      position - Length; position of the gtu on the lane
      speed - Speed; speed of the gtu
      acceleration - Acceleration; acceleration of the gtu
      time - Time; current time
      gtu - G; gtu
    • processGtuAddEvent

      public final void processGtuAddEvent(L lane, G gtu)
      Creates a trajectory, including filter data.
      Parameters:
      lane - L; lane the gtu is at
      gtu - G; gtu
    • processGtuMoveEvent

      public final void processGtuMoveEvent(L lane, org.djunits.value.vdouble.scalar.Length position, org.djunits.value.vdouble.scalar.Speed speed, org.djunits.value.vdouble.scalar.Acceleration acceleration, org.djunits.value.vdouble.scalar.Time time, G gtu)
      Adds a new snapshot of a GTU to its recording trajectory, if recorded. This method may be invoked on GTU that are not being recorded; the event will then be ignored.
      Parameters:
      lane - L; lane the gtu is at
      position - Length; position of the gtu on the lane
      speed - Speed; speed of the gtu
      acceleration - Acceleration; acceleration of the gtu
      time - Time; current time
      gtu - G; gtu
    • processGtuRemoveEventWithMove

      public final void processGtuRemoveEventWithMove(L lane, org.djunits.value.vdouble.scalar.Length position, org.djunits.value.vdouble.scalar.Speed speed, org.djunits.value.vdouble.scalar.Acceleration acceleration, org.djunits.value.vdouble.scalar.Time time, G gtu)
      Finalizes a trajectory with the current snapshot of a GTU.
      Parameters:
      lane - L; lane the gtu is at
      position - Length; position of the gtu on the lane
      speed - Speed; speed of the gtu
      acceleration - Acceleration; acceleration of the gtu
      time - Time; current time
      gtu - G; gtu
    • processGtuRemoveEvent

      public final void processGtuRemoveEvent(L lane, G gtu)
      Finalizes a trajectory.
      Parameters:
      lane - L; lane the gtu is at
      gtu - G; gtu
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object