deploymentSuccessfulFor method

  1. @override
Future<StudyDeploymentStatus> deploymentSuccessfulFor(
  1. String studyDeploymentId,
  2. String masterDeviceRoleName,
  3. DateTime? deviceDeploymentLastUpdateDate
)
override

Indicate to stakeholders in the study deployment with studyDeploymentId that the device with masterDeviceRoleName was deployed successfully, using the deployment with the specified deviceDeploymentLastUpdateDate, i.e., that the study deployment was loaded on the device and that the necessary runtime is available to run it.

Throws an error when:

  • a deployment with studyDeploymentId does not exist
  • masterDeviceRoleName is not present in the deployment
  • the deviceDeploymentLastUpdateDate does not match the expected date. The deployment might be outdated.
  • the deployment cannot be deployed yet, or the deployment has stopped.

Implementation

@override
Future<StudyDeploymentStatus> deploymentSuccessfulFor(
  String studyDeploymentId,
  String masterDeviceRoleName,
  DateTime? deviceDeploymentLastUpdateDate,
) async {
  deviceDeploymentLastUpdateDate ??= DateTime.now();

  StudyDeployment deployment = _repository[studyDeploymentId]!;
  DeviceDescriptor device = deployment.registeredDevices.keys.firstWhere(
      (descriptor) => descriptor.roleName == masterDeviceRoleName);

  assert(device.isMasterDevice!,
      "The specified device with rolename '$masterDeviceRoleName' is not a master device.");

  deployment.deviceDeployed(
      (device as MasterDeviceDescriptor), deviceDeploymentLastUpdateDate);

  return deployment.status;
}