Class Sampler<G extends GtuDataInterface>

  • Type Parameters:
    G - gtu data type

    public abstract class Sampler<G extends GtuDataInterface>
    extends Object
    Sampler is the highest level organizer for sampling.

    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.

    Version:
    $Revision$, $LastChangedDate$, by $Author$, initial version Sep 22, 2016
    Author:
    Alexander Verbraeck, Peter Knoppers, Wouter Schakel
    • Constructor Detail

      • Sampler

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

      • 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 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; space-time region
        Throws:
        IllegalStateException - if data is not available from the requested start time
      • now

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

        public abstract void scheduleStartRecording​(Time time,
                                                    KpiLaneDirection kpiLaneDirection)
        Schedules the start of recording for a given lane-direction.
        Parameters:
        time - Time; time to start recording
        kpiLaneDirection - KpiLaneDirection; lane-direction to start recording
      • scheduleStopRecording

        public abstract void scheduleStopRecording​(Time time,
                                                   KpiLaneDirection kpiLaneDirection)
        Schedules the stop of recording for a given lane-direction.
        Parameters:
        time - Time; time to stop recording
        kpiLaneDirection - KpiLaneDirection; lane-direction to stop recording
      • startRecording

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

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

        public final void stopRecording​(KpiLaneDirection kpiLaneDirection)
        Stop recording at given lane direction.
        Parameters:
        kpiLaneDirection - KpiLaneDirection; lane direction
      • finalizeRecording

        public abstract void finalizeRecording​(KpiLaneDirection kpiLaneDirection)
        Remove listeners to stop recording.
        Parameters:
        kpiLaneDirection - KpiLaneDirection; lane direction to finalize recording for
      • processGtuAddEvent

        public final void processGtuAddEvent​(KpiLaneDirection kpiLaneDirection,
                                             Length position,
                                             Speed speed,
                                             Acceleration acceleration,
                                             Time time,
                                             G gtu)
        Creates a trajectory with the current snapshot of a GTU.
        Parameters:
        kpiLaneDirection - KpiLaneDirection; lane direction 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
      • processGtuMoveEvent

        public final void processGtuMoveEvent​(KpiLaneDirection kpiLaneDirection,
                                              Length position,
                                              Speed speed,
                                              Acceleration acceleration,
                                              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:
        kpiLaneDirection - KpiLaneDirection; lane direction 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​(KpiLaneDirection kpiLaneDirection,
                                                Length position,
                                                Speed speed,
                                                Acceleration acceleration,
                                                Time time,
                                                G gtu)
        Finalizes a trajectory with the current snapshot of a GTU.
        Parameters:
        kpiLaneDirection - KpiLaneDirection; lane direction 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​(KpiLaneDirection kpiLaneDirection,
                                                G gtu)
        Finalizes a trajectory.
        Parameters:
        kpiLaneDirection - KpiLaneDirection; lane direction the gtu is at
        gtu - G; gtu