Skip to content

Measurement

A piece of collected data with the time it was measured.

A probe or task produces Data; the client wraps it in a Measurement with a timestamp and passes it on for storage and upload, e.g. in a DataStreamBatch. This is the unit of data collected in CARP. When sensorEndTime is set, the data pertains to an interval in time; otherwise, a point in time.

The unit of sensorStartTime and sensorEndTime is either determined by the sensor that collected the data, or, in case the sensor does not provide this information, by the phone. For example, the timestamps could be a simple clock increment since the device powered up. Note that in CARP we prefer microseconds over milliseconds for higher precision.

// Timestamp is now, in microseconds since epoch.
var measurement = Measurement.fromData(StepCount(steps: 12));
Annotations

Constructors

Measurement.fromData

Measurement.fromData(
  1. Data data, [
  2. int? sensorStartTime
])

Create a measurement from data based on the sensorStartTime provided by the sensor. If sensorStartTime is not specified, the phones current time stamp as microseconds since epoch is used.

Measurement.fromJson

Measurement.fromJson(
  1. Map<String, dynamic> json
)

Measurement

Measurement({
  1. required int sensorStartTime,
  2. int? sensorEndTime,
  3. required Data data,
})

Create a new measurement based on data.

Properties

data

Data data
getter/setter pair

The Data collected in this measurement.

dataType

  1. @JsonKey(includeFromJson: false, includeToJson: false)
DataType get dataType

The type of the data.

sensorEndTime

int? sensorEndTime
getter/setter pair

End time as set by the sensor, if available.

sensorStartTime

int sensorStartTime
getter/setter pair

Start time as set by the sensor.

If this timestamp has been provided by the sensor, the unit is determined by the sensor. If this timestamp is provided by the phone (e.g., by using the Measurement.fromData method), this timestamp is in microseconds since epoch.

taskControl

  1. @JsonKey(includeFromJson: false, includeToJson: false)
TaskControl? taskControl
getter/setter pair

The TaskControl which triggered the collection of this measurement. Set at runtime only; not serialized.

Methods

toJson

Map<String, dynamic> toJson()