Skip to content

TaskControlExecutor

Runs a TaskControl: starts or stops a task each time its trigger fires.

Created by the SmartphoneDeploymentExecutor. It gets its TriggerExecutor and TaskExecutor from the ExecutorFactory. On each trigger event, it adds a TriggeredTask measurement and resumes or pauses the task executor, depending on TaskControl.control.

Key points:

  • Runs in real time using timers, so tasks only trigger while the app runs, in the foreground or in a background process.
  • Resuming fails while the targetDevice is not connected. The DeviceManager of the target device resumes it once connected.
  • Every measurement it emits has Measurement.taskControl set.

See AppTaskControlExecutor for app tasks with schedulable triggers.

Inheritance
Implementers

Constructors

TaskControlExecutor

TaskControlExecutor(
  1. TaskControl taskControl,
  2. TriggerConfiguration trigger,
  3. TaskConfiguration task,
  4. DeviceConfiguration<DeviceRegistration> targetDevice,
)

Creates an executor for taskControl.

It links trigger and task on targetDevice.

Properties

measurements

Stream<Measurement> get measurements
override

The stream of Measurement collected by this executor.

probes

List<Probe> get probes

The probes of the taskExecutor. Empty if there is none.

samplingState

SamplingState get samplingState
override

The runtime sampling state of this executor.

studyDeploymentId

String get studyDeploymentId

targetDevice

targetDeviceManager

The DeviceManager of targetDevice, or null if none is available.

task

taskControl

TaskControl get taskControl

taskExecutor

TaskExecutor<TaskConfiguration>? get taskExecutor

trigger

TriggerConfiguration get trigger

triggerExecutor

TriggerExecutor<TriggerConfiguration>? get triggerExecutor

Methods

onDispose

Future<void> onDispose()
override

Callback when this executor is disposed.

Subclasses should override this, to implement any cleanup to be done before disposing.

onInitialize

bool onInitialize()
override

Called by initialize. Returns true if successfully initialized.

If false, the executor stays in ExecutorState.Created. This is a synchronous method and must be light-weight.

onPause

Future<bool> onPause()
override

Called by pause. Returns true if successfully paused.

If false, the state is not changed.

onResume

Future<bool> onResume()
override

Called by resume. Returns true if successfully resumed.

If false, the executor moves to ExecutorState.PausedButShouldBeResumed.

onTrigger

void onTrigger()

Called when the triggerExecutor fires.

Adds a TriggeredTask measurement, then resumes the taskExecutor for Control.Start or pauses it for Control.Stop.