Skip to content

TaskControl

Links a trigger to a task: when the trigger fires, start or stop the task.

Once the condition of the trigger with triggerId applies, the task with taskName on destinationDeviceRoleName is started or stopped (as specified by control). Task controls are created by StudyProtocol.addTaskControl; you rarely create one yourself.

The JSON holds the trigger id, task name, target device role name, control and hasBeenScheduledUntil; task and targetDevice are runtime references that are not part of the JSON.

Annotations

Constructors

TaskControl.fromJson

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

TaskControl

TaskControl({
  1. required int triggerId,
  2. TaskConfiguration? task,
  3. DeviceConfiguration<DeviceRegistration>? targetDevice,
  4. Control control = Control.Start,
})

Create a TaskControl.

taskName and destinationDeviceRoleName are taken from task and targetDevice when given. control defaults to Control.Start.

Properties

control

Control control
getter/setter pair

What to do with a task once the condition of a trigger is met.

destinationDeviceRoleName

String? destinationDeviceRoleName
getter/setter pair

The role name of the device to which to send the task with taskName when the trigger condition is met.

hasBeenScheduledUntil

DateTime? hasBeenScheduledUntil
getter/setter pair

The time the task have been scheduled until. Mainly used when scheduling a series of tasks for this trigger.

targetDevice

  1. @JsonKey(includeFromJson: false, includeToJson: false)
DeviceConfiguration<DeviceRegistration>? targetDevice
getter/setter pair

The device to send the task to. Not serialized; may be null after deserialization.

task

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

The task to control. Not serialized; may be null after deserialization.

taskName

String taskName
getter/setter pair

The name of the task to send to destinationDeviceRoleName when the trigger condition is met.

triggerId

int triggerId
getter/setter pair

The id of the TriggerConfiguration; its key in StudyProtocol.triggers.

Methods

toJson

Map<String, dynamic> toJson()

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.