SensorData<S extends Sensor, X, Y> class abstract

Represents data with range X and domain Y returned by a sensor S.

This represents a collection of points returned by the sensor. SensorData.async represents points from a stream (e.g. read real-time from the device's accelerometer) while SensorData.sync represents points from a list (e.g. read from a in-memory file).

Considering the following fake accelerometer data:

              Timestamp,Acc X,Acc Y,Acc Z,AngA X,AngA Y,AngA Z
2021-12-10 22:06:10.200, 0.13, 0.20, 9.81,  0.00,  0.00, 89.75
2021-12-10 22:06:10.400, 0.16, 0.12, 9.80,  0.20,  0.10, 89.20
...

an object of this class can be built programmatically by

final SensorData<Accelerometer, Duration, double> data = SensorData.sync(
  [
    Point3(
      Duration.parse("2021-12-10 22:06:10.200"),
      x: {Metric.acceleration: 0.13, Metric.accelerometerAngle: 0.00},
      y: {Metric.acceleration: 0.20, Metric.accelerometerAngle: 0.00},
      z: {Metric.acceleration: 9.81, Metric.accelerometerAngle: 89.75},
    ),
    Point3(
      Duration.parse("2021-12-10 22:06:10.400"),
      x: {Metric.acceleration: 0.16, Metric.accelerometerAngle: 0.20},
      y: {Metric.acceleration: 0.12, Metric.accelerometerAngle: 0.10},
      z: {Metric.acceleration: 9.80, Metric.accelerometerAngle: 89.20},
    ),
    // ...
  ],
  metrics: {Metric.acceleration, Metric.accelerometerAngle},
);

This class has the following contracts, meaning that building an object disrespecting any of these contracts will not throw any errors, but the caller may face unexpected behaviour:

  • the metric values passed to the inner x, y and z fields should be compatible with the metrics attribute of this object. This means that, for each Point3 point passed either to the list parameter of the SensorData.sync method or the stream parameter of the SensorData.async method, point.x, point.y and point.z keys should be exactly equal to metrics.

A transposed version of this data, which allows easier metric filtering, can be accessed using the transpose method.

Implemented types
Implementers

Constructors

SensorData(Collection<SensorValue<S, X, Y>> _values, {required Set<Metric<S>> metrics})
const

Properties

hashCode int
The hash code for this object.
no setterinherited
metrics Set<Metric<S>>
The metrics available by this data.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

collect() Collection<SensorValue<S, X, Y>>
Returns the collection wrapped by this object.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited
transpose() TransposedSensorData<S, X, Y>
Creates a transposed version of this data.

Operators

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

Static Methods

async<S extends Sensor, X, Y>(Stream<SensorValue<S, X, Y>> stream, {required Set<Metric<S>> metrics}) AsyncSensorData<S, X, Y>
Creates a SensorData backed by a stream.
sync<S extends Sensor, X, Y>(List<SensorValue<S, X, Y>> list, {required Set<Metric<S>> metrics}) SyncSensorData<S, X, Y>
Creates a SensorData backed by a list.