Package org.opentrafficsim.kpi.sampling
Class Sampler<G extends GtuDataInterface>
- java.lang.Object
-
- org.opentrafficsim.kpi.sampling.Sampler<G>
-
- 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 Summary
Constructors Constructor Description Sampler(Set<ExtendedDataType<?,?,?,G>> extendedDataTypes, Set<FilterDataType<?>> filterDataTypes)
Constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description boolean
contains(ExtendedDataType<?,?,?,?> extendedDataType)
Whether this sampler has the given extended data type registered to it.abstract void
finalizeRecording(KpiLaneDirection kpiLaneDirection)
Remove listeners to stop recording.SamplerData<G>
getSamplerData()
Underlying sampler data.abstract void
initRecording(KpiLaneDirection kpiLaneDirection)
Adds listeners to start recording.abstract Time
now()
Returns the current simulation time.void
processGtuAddEvent(KpiLaneDirection kpiLaneDirection, Length position, Speed speed, Acceleration acceleration, Time time, G gtu)
Creates a trajectory with the current snapshot of a GTU.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.void
processGtuRemoveEvent(KpiLaneDirection kpiLaneDirection, G gtu)
Finalizes a trajectory.void
processGtuRemoveEvent(KpiLaneDirection kpiLaneDirection, Length position, Speed speed, Acceleration acceleration, Time time, G gtu)
Finalizes a trajectory with the current snapshot of a GTU.void
registerSpaceTimeRegion(SpaceTimeRegion spaceTimeRegion)
Registers a space-time region.abstract void
scheduleStartRecording(Time time, KpiLaneDirection kpiLaneDirection)
Schedules the start of recording for a given lane-direction.abstract void
scheduleStopRecording(Time time, KpiLaneDirection kpiLaneDirection)
Schedules the stop of recording for a given lane-direction.void
startRecording(KpiLaneDirection kpiLaneDirection)
Start recording at the given time (which should be the current time) on the given lane direction.void
stopRecording(KpiLaneDirection kpiLaneDirection)
Stop recording at given lane direction.
-
-
-
Constructor Detail
-
Sampler
public Sampler(Set<ExtendedDataType<?,?,?,G>> extendedDataTypes, Set<FilterDataType<?>> filterDataTypes)
Constructor.- Parameters:
extendedDataTypes
- Set<ExtendedDataType<?, ?, ?, G>>; extended data typesfilterDataTypes
- 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 recordingkpiLaneDirection
- 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 recordingkpiLaneDirection
- 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 atposition
- Length; position of the gtu on the lanespeed
- Speed; speed of the gtuacceleration
- Acceleration; acceleration of the gtutime
- Time; current timegtu
- 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 atposition
- Length; position of the gtu on the lanespeed
- Speed; speed of the gtuacceleration
- Acceleration; acceleration of the gtutime
- Time; current timegtu
- 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 atposition
- Length; position of the gtu on the lanespeed
- Speed; speed of the gtuacceleration
- Acceleration; acceleration of the gtutime
- Time; current timegtu
- G; gtu
-
processGtuRemoveEvent
public final void processGtuRemoveEvent(KpiLaneDirection kpiLaneDirection, G gtu)
Finalizes a trajectory.- Parameters:
kpiLaneDirection
- KpiLaneDirection; lane direction the gtu is atgtu
- G; gtu
-
-