BufferedMagnetometerSensorCollector

class BufferedMagnetometerSensorCollector(context: Context, val sensorType: MagnetometerSensorType = MagnetometerSensorType.MAGNETOMETER_UNCALIBRATED, sensorDelay: SensorDelay = SensorDelay.FASTEST, capacity: Int = DEFAULT_CAPACITY, startOffsetEnabled: Boolean = true, stopWhenFilledBuffer: Boolean = true, skipWhenProcessing: Boolean = true, accuracyChangedListener: BufferedSensorCollector.OnAccuracyChangedListener<MagnetometerSensorMeasurement, BufferedMagnetometerSensorCollector>? = null, bufferFilledListener: BufferedSensorCollector.OnBufferFilledListener<MagnetometerSensorMeasurement, BufferedMagnetometerSensorCollector>? = null, measurementListener: BufferedSensorCollector.OnMeasurementListener<MagnetometerSensorMeasurement, BufferedMagnetometerSensorCollector>? = null) : BufferedSensorCollector<MagnetometerSensorMeasurement, BufferedMagnetometerSensorCollector>

Manages and collects magnetometer sensor measurements using a buffer. A buffered collector allows proper synchronization of events from multiple collectors by colling getMeasurementsBeforeTimestamp periodically to obtain measurements in the buffer prior to a certain timestamp.

Throws

if provided capacity is zero or negative.

Constructors

Link copied to clipboard
constructor(context: Context, sensorType: MagnetometerSensorType = MagnetometerSensorType.MAGNETOMETER_UNCALIBRATED, sensorDelay: SensorDelay = SensorDelay.FASTEST, capacity: Int = DEFAULT_CAPACITY, startOffsetEnabled: Boolean = true, stopWhenFilledBuffer: Boolean = true, skipWhenProcessing: Boolean = true, accuracyChangedListener: BufferedSensorCollector.OnAccuracyChangedListener<MagnetometerSensorMeasurement, BufferedMagnetometerSensorCollector>? = null, bufferFilledListener: BufferedSensorCollector.OnBufferFilledListener<MagnetometerSensorMeasurement, BufferedMagnetometerSensorCollector>? = null, measurementListener: BufferedSensorCollector.OnMeasurementListener<MagnetometerSensorMeasurement, BufferedMagnetometerSensorCollector>? = null)

Properties

Link copied to clipboard

Gets a copy of the buffer containing ordered measurements by ascending timestamp.

Link copied to clipboard

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.

Link copied to clipboard

capacity of buffer.

Link copied to clipboard

Android context.

Link copied to clipboard

listener to notify new measurements. It must be noticed that measurements notification might be delayed.

Link copied to clipboard

Gets most recent timestamp of all measurements processed so far. Timestamp is expressed in nanoseconds by a monotonic clock based on SystemClock.elapsedRealtimeNanos.

Link copied to clipboard

Gets number of processed measurements since this collector started.

Link copied to clipboard

Gets oldest timestamp within buffered measurements, if any is available. Timestamp is expressed in nanoseconds by a monotonic clock based on SystemClock.elapsedRealtimeNanos.

Link copied to clipboard

Indicates whether collector is processing a measurement.

Link copied to clipboard

Indicates whether collector is running and collecting measurements.

Link copied to clipboard
open override val sensor: Sensor?

Sensor being used to obtain measurements or null if not available. This can be used to obtain additional information about the sensor.

Link copied to clipboard

Indicates whether requested sensor is available or not.

Link copied to clipboard

Delay of sensor between samples.

Link copied to clipboard

One of the supported magnetometer sensor types.

Link copied to clipboard

true to skip new measurements when processing a measurement.

Link copied to clipboard

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.

Link copied to clipboard

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.

Link copied to clipboard

Timestamp when collector started expressed as a monotonically increasing timestamp in nanoseconds as indicated by SystemClock.elapsedRealtimeNanos.

Link copied to clipboard

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.

Link copied to clipboard

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

Link copied to clipboard

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.

Link copied to clipboard

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.

Link copied to clipboard
fun start(startTimestamp: Long = SystemClock.elapsedRealtimeNanos()): Boolean

Starts collecting sensor measurements.

Link copied to clipboard
fun stop()

Stops collecting sensor measurements.