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
-
- Object
- AbstractExecutor<
TaskControl> - TaskControlExecutor
- Implementers
Constructors
TaskControlExecutor
- TaskControl taskControl,
- TriggerConfiguration trigger,
- TaskConfiguration task,
- DeviceConfiguration<
DeviceRegistration> targetDevice,
Creates an executor for taskControl.
It links trigger and task on targetDevice.
Properties
measurements
The stream of Measurement collected by this executor.
probes
The probes of the taskExecutor. Empty if there is none.
samplingState
The runtime sampling state of this executor.
studyDeploymentId
targetDevice
targetDeviceManager
The DeviceManager of targetDevice, or null if none is available.
task
taskControl
taskExecutor
trigger
triggerExecutor
Methods
onDispose
Callback when this executor is disposed.
Subclasses should override this, to implement any cleanup to be done before disposing.
onInitialize
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
Called by pause. Returns true if successfully paused.
If false, the state is not changed.
onResume
Called by resume. Returns true if successfully resumed.
If false, the executor moves to ExecutorState.PausedButShouldBeResumed.
onTrigger
Called when the triggerExecutor fires.
Adds a TriggeredTask measurement, then resumes the taskExecutor for Control.Start or pauses it for Control.Stop.