deviceDeployed method

  1. @override
Future<StudyDeploymentStatus?> deviceDeployed(
  1. String studyDeploymentId,
  2. String primaryDeviceRoleName,
  3. DateTime? deviceDeploymentLastUpdatedOn
)
override

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

Returns null when:

  • a deployment with studyDeploymentId does not exist
  • primaryDeviceRoleName is not present in the deployment
  • the deviceDeploymentLastUpdatedOn 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?> deviceDeployed(
  String studyDeploymentId,
  String primaryDeviceRoleName,
  DateTime? deviceDeploymentLastUpdatedOn,
) async {
  if (_repository[studyDeploymentId] == null) return null;

  deviceDeploymentLastUpdatedOn ??= DateTime.now();
  StudyDeployment deployment = _repository[studyDeploymentId]!;
  DeviceConfiguration device = deployment.registeredDevices.keys.firstWhere(
      (configuration) => configuration.roleName == primaryDeviceRoleName);

  if (device is! PrimaryDeviceConfiguration) {
    warning(
        "The specified device with role name '$primaryDeviceRoleName' is not a primary device.");
    return null;
  }
  deployment.deviceDeployed(device, deviceDeploymentLastUpdatedOn);

  return deployment.status;
}