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 Details

    • Sampler

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

    • getSamplerData

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

      public boolean contains(ExtendedDataType<?,?,?,?> extendedDataType)
      Whether this sampler has the given extended data type registered to it.
      Parameters:
      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 - space-time region
      Throws:
      IllegalStateException - if data is not available from the requested start time
    • now

      public abstract Duration now()
      Returns the current simulation time.
      Returns:
      current simulation time
    • scheduleStartRecording

      public abstract void scheduleStartRecording(Duration 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 to start recording
      lane - lane to start recording
    • scheduleStopRecording

      public abstract void scheduleStopRecording(Duration 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 later end time than any before.
      Parameters:
      time - time to stop recording
      lane - 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 - lane
    • initRecording

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

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

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

      public final void addGtuWithSnapshot(L lane, Length position, Speed speed, Acceleration acceleration, Duration time, G gtu)
      Creates a trajectory with the current snapshot of a GTU.
      Parameters:
      lane - lane the gtu is at
      position - position of the gtu on the lane
      speed - speed of the gtu
      acceleration - acceleration of the gtu
      time - current time
      gtu - gtu
    • addGtu

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

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

      public final void removeGtuWithSnapshot(L lane, Length position, Speed speed, Acceleration acceleration, Duration time, G gtu)
      Finalizes a trajectory with the current snapshot of a GTU.
      Parameters:
      lane - lane the gtu is at
      position - position of the gtu on the lane
      speed - speed of the gtu
      acceleration - acceleration of the gtu
      time - current time
      gtu - gtu
    • removeGtu

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

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

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