Skip to content

TaskConfiguration

A named group of Measures that a device runs when a trigger fires.

A task is added to a protocol together with a TriggerConfiguration via StudyProtocol.addTaskControl, which creates a TaskControl. When the trigger fires, the client starts (or stops) all of the task's measures.

Key points:

  • The name identifies the task and must be unique within a protocol. If not given, a name like 'Task #3' is generated.
  • Duplicate measures (same type) are removed when the task is created.
  • Subclasses define how the task runs, e.g. BackgroundTask. CARP Mobile Sensing adds AppTask for tasks the user does in the app.
Inheritance
Implementers
Annotations

Constructors

TaskConfiguration.fromJson

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

TaskConfiguration

TaskConfiguration({
  1. String? name,
  2. String? description,
  3. List<Measure>? measures,
})

Create a task. The name uniquely identifies the task. If name is not specified, a name is generated.

Properties

description

String? description
getter/setter pair

A description of this task, emphasizing the reason why the data is collected.

fromJsonFunction

Function get fromJsonFunction
override

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

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.

measures

List<Measure>? measures
getter/setter pair

The data which needs to be collected/measured passively as part of this task.

name

String name
getter/setter pair

A name which uniquely identifies the task.

Methods

addMeasure

void addMeasure(
  1. Measure measure
)

Add measure to this task.

addMeasures

void addMeasures(
  1. Iterable<Measure> list
)

Add a list of measures to this task.

getAllExpectedDataTypes

Set<String> getAllExpectedDataTypes()

Get data types of all data which may be collected, either passively as part of task measures, or as the result of user interactions, for this task.

Always includes CarpDataTypes.COMPLETED_TASK.

removeMeasure

void removeMeasure(
  1. Measure measure
)

Remove measure from this task.

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.