Skip to content

DeviceConfiguration

Describes a device that takes part in a study, as part of a protocol.

A device can be any electronic device, such as a sensor, video camera, desktop computer, or smartphone, that collects data which is incorporated into the platform after being processed by a primary device (potentially itself). Optionally, a device can present output and receive user input.

Key points:

CARP Mobile Sensing and its sampling packages add more device types, each handled at runtime by a DeviceManager.

Inheritance
Implementers
Annotations

Constructors

DeviceConfiguration.fromJson

DeviceConfiguration<TRegistration extends DeviceRegistration>.fromJson(
  1. Map<String, dynamic> json
)

DeviceConfiguration

DeviceConfiguration<TRegistration extends DeviceRegistration>({
  1. required String roleName,
  2. bool? isOptional,
})

Constants

DEVICE_NAMESPACE

String const DEVICE_NAMESPACE

The JSON namespace of the CARP Core device types.

Properties

dataTypeSamplingSchemes

DataTypeSamplingSchemeMap? get dataTypeSamplingSchemes

Sampling schemes for all the sensors available on this device.

Implementations of DeviceConfiguration should return a map of all supported sampling schemes here. Null in this base class.

defaultSamplingConfiguration

Map<String, SamplingConfiguration>? defaultSamplingConfiguration
getter/setter pair

Sampling configurations which override the default configurations for data types available on this device, mapped by data type.

fromJsonFunction

Function get fromJsonFunction
override

The function which can convert a JSON string to an object of this type.

isOptional

bool? isOptional
getter/setter pair

Determines whether device registration for this device is optional prior to starting a study, i.e., whether the study can run without this device or not.

jsonType

String get jsonType
override

Return the __type to be used for JSON serialization of this class. Default is runtimeType. Only specify this if you need another type.

roleName

String roleName
getter/setter pair

A name which describes how the device participates within the study protocol; its 'role'. For example, 'Parent's phone' or 'Child phone'. Must be unique within a protocol.

supportedDataTypes

Set<String>? get supportedDataTypes

The set of data types which can be collected on this device.

type

  1. @JsonKey(includeFromJson: false, includeToJson: false)
String get type

The device type identifier, i.e. its jsonType.

Methods

createRegistration

  1. @Deprecated('Use createRegistration on a DeviceManager instead, ' 'which allows for hardware-specific runtime registration options.')
TRegistration createRegistration({
  1. String? deviceId,
  2. String? deviceDisplayName,
})

Create a DeviceRegistration which can be used to configure this device for deployment.

Override this method to configure device-specific registration options, if any.

toJson

Map<String, dynamic> toJson()
override

Return a JSON encoding of this object.

toString

String toString()
override

A string representation of this object.

Some classes have a default textual representation, often paired with a static parse function (like int.parse). These classes will provide the textual representation as their string representation.

Other classes have no meaningful textual representation that a program will care about. Such classes will typically override toString to provide useful information when inspecting the object, mainly for debugging or logging.