restart method

  1. @nonVirtual
void restart()

Restart sampling of the measures using this device.

This entails that all task control executors using this device are resumed, if they are supposed to be resumed, e.g., if they were paused due to a temporary disconnection (via isDisconnecting) of the device, but not if they were paused due to a manual stop of the sampling.

Implementation

@nonVirtual
void restart() {
  info('$runtimeType - Restarting sampling...');

  for (var executor in executors) {
    debug(
      '$runtimeType - Restarting executor: $executor, state: ${executor.state}',
    );
    if (executor.state == ExecutorState.PausedButShouldBeResumed) {
      // resume data sampling with a delay to give the device some time to fully reconnect
      Future.delayed(const Duration(seconds: 15), () => executor.resume());
    }
  }
}