BufferingPeriodicStreamProbe class abstract

A type of probe which buffers data from an underlying stream for a period of time and then return a measurement from this collected data.

Probes of this type uses a PeriodicSamplingConfiguration that specify the interval of starting sampling, and the duration of the sampling window. Once this sampling window is over, the final measurement is collected from the getMeasurement method and send to the main measurements stream.

Sub-classes must implement the

Stream<dynamic> get bufferingStream => ...

method in order to provide the stream to be buffered from.

When sampling starts, the onSamplingStart handle is called. When the sampling window ends, the onSamplingEnd handle is called.

The difference between this BufferingPeriodicStreamProbe and the BufferingIntervalStreamProbe is that this type of probe starts and stops the underlying bufferingStream in the sampling windows specified by the interval and duration parameters of the samplingConfiguration, whereas the latter BufferingIntervalStreamProbe keeps the underlying bufferingStream running continuously.

See LightProbe for an example. This probe listens to the light sensor every interval for duration and buffers the reading during this period into an overall measurement for light, calculated in the getMeasurement method.

Inheritance
Implementers

Properties

bufferingStream Stream
The stream of events to be buffered. Must be specified by sub-classes.
no setter
configuration → Measure?
The configuration of this executor as set when initialized.
no setterinherited
controller StreamController<Measurement>
A stream controller to add Measurements to.
getter/setter pairinherited
deployment SmartphoneDeployment?
The deployment that this executor is part of executing.
no setterinherited
deviceManager DeviceManager<DeviceConfiguration<DeviceRegistration>>
The device that this probes uses to collect data.
getter/setter pairinherited
enabled bool
Is this probe enabled, i.e. available for collection of data using the start method.
getter/setter pairinherited
hashCode int
The hash code for this object.
no setterinherited
isStarting bool
Is this executor in the process of being started?
no setterinherited
measure → Measure?
The Measure that configures this probe.
no setterinherited
measurements Stream<Measurement>
The stream of Measurement collected by this executor.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
samplingConfiguration PeriodicSamplingConfiguration?
The sampling configuration for this probe.
no setterinherited
state ExecutorState
The runtime state of this executor.
no setterinherited
stateEvents Stream<ExecutorState>
The runtime state changes of this executor.
no setterinherited
stream Stream<Measurement>
The stream of Measurement objects for this StreamProbe. Must be implemented by sub-classes.
no setteroverride
timer Timer?
getter/setter pairinherited
type String?
The data type this probe is collecting.
no setterinherited

Methods

addError(Object error) → void
Add an error to the measurements stream.
inherited
addMeasurement(Measurement measurement) → void
Add a data point to the measurements stream.
inherited
error() → void
inherited
getMeasurement() Future<Measurement?>
Subclasses should implement / override this method to collect the Measurement. This method will be called every time data has been buffered for a duration and should return the final measurement for the buffered data.
initialize(Measure configuration, [SmartphoneDeployment? deployment]) → void
Configure and initialize the executor before starting it.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onData(Measurement measurement) → void
inherited
onDone() → void
inherited
onError(Object error) → void
inherited
onInitialize() bool
Callback when this executor is initialized. Returns true if successfully initialized, false otherwise.
inherited
onRestart() Future<bool>
Callback when this executor is to be restarted. Returns true if the executor is ready to restart (default), false otherwise.
inherited
onSamplingData(dynamic event) → void
Handler for handling onData events from the buffering stream.
onSamplingEnd() → void
Handler called when sampling period ends.
onSamplingStart() → void
Handler called when sampling period starts.
onStart() Future<bool>
Callback when this executor is started. Returns true if successfully started, false otherwise.
override
onStop() Future<bool>
Callback when this executor is stopped. Returns true if successfully stopped, false otherwise.
override
restart() → void
Restart the executor.
inherited
start() → void
Start the executor.
inherited
stop() → void
Stop the executor. Stopped until start or restart is called.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited