Package org.opentrafficsim.kpi.sampling
Class Sampler<G extends GtuData,L extends LaneData>
java.lang.Object
org.opentrafficsim.kpi.sampling.Sampler<G,L>
- Type Parameters:
G- gtu data typeL- lane data type
Sampler is the highest level organizer for sampling.
Copyright (c) 2013-2023 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
ConstructorsConstructorDescriptionSampler(Set<ExtendedDataType<?, ?, ?, G>> extendedDataTypes, Set<FilterDataType<?>> filterDataTypes) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionbooleancontains(ExtendedDataType<?, ?, ?, ?> extendedDataType) Whether this sampler has the given extended data type registered to it.booleanabstract voidfinalizeRecording(L lane) Remove listeners to stop recording.Underlying sampler data.inthashCode()abstract voidinitRecording(L lane) Adds listeners to start recording.abstract Timenow()Returns the current simulation time.final voidprocessGtuAddEvent(L lane, G gtu) Creates a trajectory, including filter data.final voidprocessGtuAddEventWithMove(L lane, Length position, Speed speed, Acceleration acceleration, Time time, G gtu) Creates a trajectory with the current snapshot of a GTU.final voidprocessGtuMoveEvent(L lane, Length position, Speed speed, Acceleration acceleration, Time time, G gtu) Adds a new snapshot of a GTU to its recording trajectory, if recorded.final voidprocessGtuRemoveEvent(L lane, G gtu) Finalizes a trajectory.final voidprocessGtuRemoveEventWithMove(L lane, Length position, Speed speed, Acceleration acceleration, Time time, G gtu) Finalizes a trajectory with the current snapshot of a GTU.final voidregisterSpaceTimeRegion(SpaceTimeRegion<L> spaceTimeRegion) Registers a space-time region.abstract voidscheduleStartRecording(Time time, L lane) Schedules the start of recording for a given lane, i.e.abstract voidscheduleStopRecording(Time time, L lane) Schedules the stop of recording for a given lane, i.e.final voidstartRecording(L lane) Start recording at the given time (which should be the current time) on the given lane.final voidstopRecording(L lane) Stop recording at given lane.
-
Constructor Details
-
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 Details
-
getSamplerData
Underlying sampler data.- Returns:
- SamplerData<G>; underlying sampler data
-
contains
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
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
Returns the current simulation time.- Returns:
- current simulation time
-
scheduleStartRecording
Schedules the start of recording for a given lane, i.e. the implementation has to invokestartRecordingat 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 recordinglane- L; lane to start recording
-
scheduleStopRecording
Schedules the stop of recording for a given lane, i.e. the implementation has to invokestopRecordingat 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 recordinglane- L; lane to stop recording
-
startRecording
Start recording at the given time (which should be the current time) on the given lane.- Parameters:
lane- L; lane
-
initRecording
Adds listeners to start recording.- Parameters:
lane- L; lane to initialize recording for
-
stopRecording
Stop recording at given lane.- Parameters:
lane- L; lane
-
finalizeRecording
Remove listeners to stop recording.- Parameters:
lane- L; lane
-
processGtuAddEventWithMove
public final void processGtuAddEventWithMove(L lane, Length position, Speed speed, Acceleration acceleration, Time time, G gtu) Creates a trajectory with the current snapshot of a GTU.- Parameters:
lane- L; lane 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
-
processGtuAddEvent
Creates a trajectory, including filter data.- Parameters:
lane- L; lane the gtu is atgtu- G; gtu
-
processGtuMoveEvent
public final void processGtuMoveEvent(L lane, 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:
lane- L; lane 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
-
processGtuRemoveEventWithMove
public final void processGtuRemoveEventWithMove(L lane, Length position, Speed speed, Acceleration acceleration, Time time, G gtu) Finalizes a trajectory with the current snapshot of a GTU.- Parameters:
lane- L; lane 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
Finalizes a trajectory.- Parameters:
lane- L; lane the gtu is atgtu- G; gtu
-
hashCode
public int hashCode() -
equals
-