Class RoadSampler
java.lang.Object
org.opentrafficsim.kpi.sampling.Sampler<GtuDataRoad,LaneDataRoad>
org.opentrafficsim.road.network.sampling.RoadSampler
- All Implemented Interfaces:
Serializable,Remote,EventListener,org.djutils.event.EventListener
public class RoadSampler
extends Sampler<GtuDataRoad,LaneDataRoad>
implements org.djutils.event.EventListener
Implementation of kpi sampler for OTS.
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
- See Also:
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionRoadSampler(Set<ExtendedDataType<?, ?, ?, GtuDataRoad>> extendedDataTypes, Set<FilterDataType<?>> filterDataTypes, RoadNetwork network) Constructor which uses the operational plan updates of GTU's as sampling interval.RoadSampler(Set<ExtendedDataType<?, ?, ?, GtuDataRoad>> extendedDataTypes, Set<FilterDataType<?>> filterDataTypes, RoadNetwork network, Frequency frequency) Constructor which uses the given frequency to determine the sampling interval.RoadSampler(RoadNetwork network) Constructor which uses the operational plan updates of GTU's as sampling interval.RoadSampler(RoadNetwork network, Frequency frequency) Constructor which uses the given frequency to determine the sampling interval. -
Method Summary
Modifier and TypeMethodDescriptionstatic RoadSampler.Factorybuild(RoadNetwork network) Returns a factory to create a sampler.final booleanfinal voidfinal inthashCode()final voidinitRecording(LaneDataRoad lane) final voidnotify(org.djutils.event.Event event) final voidnotifySample(LaneBasedGtu gtu, Lane lane) Samples a gtu and schedules the next sampling event.final Timenow()final voidscheduleStartRecording(Time time, LaneDataRoad lane) final voidscheduleStopRecording(Time time, LaneDataRoad lane) final StringtoString()Methods inherited from class org.opentrafficsim.kpi.sampling.Sampler
contains, getSamplerData, processGtuAddEvent, processGtuAddEventWithMove, processGtuMoveEvent, processGtuRemoveEvent, processGtuRemoveEventWithMove, registerSpaceTimeRegion, startRecording, stopRecording
-
Constructor Details
-
RoadSampler
Constructor which uses the operational plan updates of GTU's as sampling interval.- Parameters:
network- RoadNetwork; the network- Throws:
NullPointerException- if the simulator isnull
-
RoadSampler
public RoadSampler(Set<ExtendedDataType<?, ?, ?, GtuDataRoad>> extendedDataTypes, Set<FilterDataType<?>> filterDataTypes, RoadNetwork network) Constructor which uses the operational plan updates of GTU's as sampling interval.- Parameters:
extendedDataTypes- Set<ExtendedDataType<?, ?, ?, GtuData>>; extended data typesfilterDataTypes- Set<FilterDataType<?>>; filter data typesnetwork- RoadNetwork; the network- Throws:
NullPointerException- if the simulator isnull
-
RoadSampler
Constructor which uses the given frequency to determine the sampling interval.- Parameters:
network- RoadNetwork; the networkfrequency- Frequency; sampling frequency- Throws:
NullPointerException- if an input isnullIllegalArgumentException- if frequency is negative or zero
-
RoadSampler
public RoadSampler(Set<ExtendedDataType<?, ?, ?, GtuDataRoad>> extendedDataTypes, Set<FilterDataType<?>> filterDataTypes, RoadNetwork network, Frequency frequency) Constructor which uses the given frequency to determine the sampling interval.- Parameters:
extendedDataTypes- Set<ExtendedDataType<?, ?, ?, GtuData>>; extended data typesfilterDataTypes- Set<FilterDataType<?>>; filter data typesnetwork- RoadNetwork; the networkfrequency- Frequency; sampling frequency- Throws:
NullPointerException- if an input isnullIllegalArgumentException- if frequency is negative or zero
-
-
Method Details
-
now
- Specified by:
nowin classSampler<GtuDataRoad,LaneDataRoad>
-
scheduleStartRecording
- Specified by:
scheduleStartRecordingin classSampler<GtuDataRoad,LaneDataRoad>
-
scheduleStopRecording
- Specified by:
scheduleStopRecordingin classSampler<GtuDataRoad,LaneDataRoad>
-
initRecording
- Specified by:
initRecordingin classSampler<GtuDataRoad,LaneDataRoad>
-
finalizeRecording
- Specified by:
finalizeRecordingin classSampler<GtuDataRoad,LaneDataRoad>
-
notify
- Specified by:
notifyin interfaceorg.djutils.event.EventListener- Throws:
RemoteException
-
notifySample
Samples a gtu and schedules the next sampling event. This is used for interval-based sampling.- Parameters:
gtu- LaneBasedGtu; gtu to samplelane- Lane; lane direction where the gtu is at
-
hashCode
public final int hashCode()- Overrides:
hashCodein classSampler<GtuDataRoad,LaneDataRoad>
-
equals
- Overrides:
equalsin classSampler<GtuDataRoad,LaneDataRoad>
-
toString
-
build
Returns a factory to create a sampler.- Parameters:
network- RoadNetwork; network- Returns:
- Factory; factory to create a sampler
-