stop method

  1. @mustCallSuper
Future<void> stop(
  1. Study<PrimaryDeviceDeployment> study
)

Permanently stop this study.

Marks the study as stopped in the deployment service. Once stopped, a study cannot be restarted. Does nothing if already stopped; errors are printed, not thrown.

Implementation

@mustCallSuper
Future<void> stop(Study study) async {
  // Early out in case study has already been stopped.
  if (study.deploymentStatus?.status == StudyDeploymentStatusTypes.Stopped) {
    return;
  }

  try {
    final deploymentStatus = await deploymentService.stop(study.studyDeploymentId);
    if (deploymentStatus != null) {
      study.deploymentStatusReceived(deploymentStatus);
    }
  } catch (error) {
    _debugPrint(
      "$runtimeType - failed to stop study for study deployment '${study.studyDeploymentId}' "
      "at deployment service '$deploymentService'.\n"
      "Error: $error",
    );
  }
}