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
andz
fields should be compatible with the metrics attribute of this object. This means that, for each Point3point
passed either to the list parameter of the SensorData.sync method or the stream parameter of the SensorData.async method,point.x
,point.y
andpoint.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
-
- Collector<
SensorValue< S, X, Y> >
- Collector<
- Implementers
Constructors
-
SensorData(Collection<
SensorValue< _values, {required Set<S, X, Y> >Metric< metrics})S> > -
const
Properties
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< stream, {required Set<S, X, Y> >Metric< metrics}) → AsyncSensorData<S> >S, X, Y> -
Creates a SensorData backed by a
stream
. -
sync<
S extends Sensor, X, Y> (List< SensorValue< list, {required Set<S, X, Y> >Metric< metrics}) → SyncSensorData<S> >S, X, Y> -
Creates a SensorData backed by a
list
.