Buffered Sensor Collector
Base class for buffered sensor collectors. A buffered collector allows proper synchronization of events from multiple collectors by colling getMeasurementsBeforeTimestamp or getMeasurementsBeforePosition periodically to obtain measurements in the buffer prior to a certain timestamp or buffer position.
Parameters
type of measurement.
type of collector.
Throws
if provided capacity is zero or negative.
Inheritors
Constructors
Types
Interface to notify when sensor accuracy changes.
Interface to notify when buffer gets completely filled. When buffer completely fills, collector will stop if stopWhenFilledBuffer is true. If stopWhenFilledBuffer is false, collector will continue collection at the expense of loosing old data. Consumers of this listener should decide what to do at this point.
Interface to notify when a new measurement is available. Notice that notified measurements from multiple collectors of different sensors, might be out of order. Calling getMeasurementsBeforeTimestamp or getMeasurementsBeforePosition periodically will help to synchronize measurements among collectors. Notice that notified measurement is reused for memory efficiency and security purposes.
Properties
listener to notify changes in accuracy.
Gets a copy of the buffer containing ordered measurements by ascending timestamp.
listener to notify that buffer has been filled. This usually happens when consumer of measurements cannot keep up with the rate at which measurements are generated.
listener to notify new measurements. It must be noticed that measurements notification might be delayed.
Gets most recent timestamp of all measurements processed so far. Timestamp is expressed in nanoseconds by a monotonic clock based on SystemClock.elapsedRealtimeNanos.
Gets number of processed measurements since this collector started.
Gets oldest timestamp within buffered measurements, if any is available. Timestamp is expressed in nanoseconds by a monotonic clock based on SystemClock.elapsedRealtimeNanos.
Indicates whether collector is processing a measurement.
Indicates whether requested sensor is available or not.
Delay of sensor between samples.
true to skip new measurements when processing a measurement.
Initial offset expressed in nano seconds between first received measurement timestamp and start time expressed in the monotonically increasing system clock obtained by SystemClock.elapsedRealtimeNanos.
indicates whether startOffset will be computed when first measurement is received or not. True indicates that offset is computed, false assumes that offset is null.
Timestamp when collector started expressed as a monotonically increasing timestamp in nanoseconds as indicated by SystemClock.elapsedRealtimeNanos.
true to stop collector when buffer completely fills, false to continue collection at the expense of loosing old data. This will be notified using bufferFilledListener.
Gets current usage of this collector as a value between 0.0 and 1.0. 0.0 indicates that buffer is empty and no measurement has yet been received. 1.0 indicates that buffer is full and getMeasurementsBeforeTimestamp or getMeasurementsBeforePosition must be called to release some measurements from buffer or otherwise collector will stop or old measurements will be lost.
Functions
Method to be called periodically to remove from buffer measurements matching requested buffer position. Failing to call this method or getMeasurementsBeforeTimestamp with required frequency, will result in a full buffer, which will be notified and stop this sensor collector or lead to loss of oldest measurements. Notice that returned list and measurements will be reused for memory efficiency purposes.
Method to be called periodically to remove from buffer measurements matching requested timestamp. Failing to call this method or getMeasurementsBeforePosition with required frequency, will result in a full buffer, which will be notified and stop this sensor collector or lead to loss of oldest measurements. Notice that returned list and measurements will be reused for memory efficiency purposes.