onTrigger method
void
onTrigger()
Callback when the triggerExecutor triggers.
Implementation
void onTrigger() {
// first, add the trigger task measurement to the measurements stream
_controller.add(
Measurement.fromData(
TriggeredTask(
triggerId: taskControl.triggerId,
taskName: taskControl.taskName,
destinationDeviceRoleName: taskControl.destinationDeviceRoleName!,
control: taskControl.control,
),
),
);
// then "control" the task by either resuming or pausing it
if (taskControl.control == Control.Start) {
taskExecutor?.resume();
} else if (taskControl.control == Control.Stop) {
taskExecutor?.pause();
}
}