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
-
Constructor Summary
ConstructorDescriptionRoadSampler
(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.Factory
build
(RoadNetwork network) Returns a factory to create a sampler.final boolean
final void
final int
hashCode()
final void
initRecording
(LaneDataRoad lane) final void
notify
(org.djutils.event.Event event) final void
notifySample
(LaneBasedGtu gtu, Lane lane, boolean scheduleNext) Samples a gtu and schedules the next sampling event.final org.djunits.value.vdouble.scalar.Time
now()
final void
scheduleStartRecording
(org.djunits.value.vdouble.scalar.Time time, LaneDataRoad lane) final void
scheduleStopRecording
(org.djunits.value.vdouble.scalar.Time time, LaneDataRoad lane) final String
toString()
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 isnull
IllegalArgumentException
- 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 isnull
IllegalArgumentException
- if frequency is negative or zero
-
-
Method Details
-
now
public final org.djunits.value.vdouble.scalar.Time now()- Specified by:
now
in classSampler<GtuDataRoad,
LaneDataRoad>
-
scheduleStartRecording
public final void scheduleStartRecording(org.djunits.value.vdouble.scalar.Time time, LaneDataRoad lane) - Specified by:
scheduleStartRecording
in classSampler<GtuDataRoad,
LaneDataRoad>
-
scheduleStopRecording
public final void scheduleStopRecording(org.djunits.value.vdouble.scalar.Time time, LaneDataRoad lane) - Specified by:
scheduleStopRecording
in classSampler<GtuDataRoad,
LaneDataRoad>
-
initRecording
- Specified by:
initRecording
in classSampler<GtuDataRoad,
LaneDataRoad>
-
finalizeRecording
- Specified by:
finalizeRecording
in classSampler<GtuDataRoad,
LaneDataRoad>
-
notify
- Specified by:
notify
in 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:
hashCode
in classSampler<GtuDataRoad,
LaneDataRoad>
-
equals
- Overrides:
equals
in classSampler<GtuDataRoad,
LaneDataRoad>
-
toString
-
build
Returns a factory to create a sampler.- Parameters:
network
- RoadNetwork; network- Returns:
- Factory; factory to create a sampler
-