onInitialize method
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.
Implementation
@override
bool onInitialize() {
_group.add(_controller.stream);
// Get or create the trigger executor and initialize with this task control executor
_triggerExecutor = ExecutorFactory().getTriggerExecutor(studyDeploymentId, taskControl.triggerId);
if (_triggerExecutor == null) {
_triggerExecutor = ExecutorFactory().createTriggerExecutor(studyDeploymentId, taskControl.triggerId, trigger);
_triggerExecutor?.initialize(trigger, deployment);
}
// now start listening on the trigger and trigger events
_triggerExecutor?.triggerEvents.listen((_) => onTrigger());
// get the task executor and add the measurements it collects to the stream group
_taskExecutor = ExecutorFactory().getTaskExecutor(studyDeploymentId, task);
if (_taskExecutor == null) {
warning("$runtimeType - Cannot find a TaskExecutor for task type '${task.runtimeType}'.");
return false;
}
_taskExecutor?.initialize(task, deployment);
_group.add(_taskExecutor!.measurements);
return true;
}