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-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
- See Also:
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionRoadSampler(Set<ExtendedDataType<?, ?, ?, ? super GtuDataRoad>> extendedDataTypes, Set<FilterDataType<?, ? super GtuDataRoad>> filterDataTypes, RoadNetwork network) Constructor which uses the operational plan updates of GTU's as sampling interval.RoadSampler(Set<ExtendedDataType<?, ?, ?, ? super GtuDataRoad>> extendedDataTypes, Set<FilterDataType<?, ? super GtuDataRoad>> filterDataTypes, RoadNetwork network, org.djunits.value.vdouble.scalar.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, org.djunits.value.vdouble.scalar.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, boolean scheduleNext) Samples a gtu and schedules the next sampling event.final org.djunits.value.vdouble.scalar.Timenow()final voidscheduleStartRecording(org.djunits.value.vdouble.scalar.Time time, LaneDataRoad lane) final voidscheduleStopRecording(org.djunits.value.vdouble.scalar.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<?, ?, ?, ? super GtuDataRoad>> extendedDataTypes, Set<FilterDataType<?, ? super GtuDataRoad>> filterDataTypes, RoadNetwork network) Constructor which uses the operational plan updates of GTU's as sampling interval.- Parameters:
extendedDataTypes- Set<ExtendedDataType<?, ?, ?, ? super GtuDataRoad>>; extended data typesfilterDataTypes- Set<FilterDataType<?, ? super GtuDataRoad>>; 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<?, ?, ?, ? super GtuDataRoad>> extendedDataTypes, Set<FilterDataType<?, ? super GtuDataRoad>> filterDataTypes, RoadNetwork network, org.djunits.value.vdouble.scalar.Frequency frequency) Constructor which uses the given frequency to determine the sampling interval.- Parameters:
extendedDataTypes- Set<ExtendedDataType<?, ?, ?, ? super GtuDataRoad>>; extended data typesfilterDataTypes- Set<FilterDataType<?, ? super GtuDataRoad>>; filter data typesnetwork- RoadNetwork; the networkfrequency- Frequency; sampling frequency- Throws:
NullPointerException- if an input isnullIllegalArgumentException- if frequency is negative or zero
-
-
Method Details
-
now
public final org.djunits.value.vdouble.scalar.Time now()- Specified by:
nowin classSampler<GtuDataRoad,LaneDataRoad>
-
scheduleStartRecording
public final void scheduleStartRecording(org.djunits.value.vdouble.scalar.Time time, LaneDataRoad lane) - Specified by:
scheduleStartRecordingin classSampler<GtuDataRoad,LaneDataRoad>
-
scheduleStopRecording
public final void scheduleStopRecording(org.djunits.value.vdouble.scalar.Time time, LaneDataRoad lane) - 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 atscheduleNext- boolean; whether to schedule the next event
-
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
-