getDeviceDeploymentFor method

  1. @override
Future<SmartphoneDeployment> getDeviceDeploymentFor(
  1. String studyDeploymentId,
  2. String masterDeviceRoleName
)
override

Get the deployment configuration for the master device with masterDeviceRoleName in the study deployment with studyDeploymentId.

Implementation

@override
Future<SmartphoneDeployment> getDeviceDeploymentFor(
  String studyDeploymentId,
  String masterDeviceRoleName,
) async {
  StudyDeployment deployment = _repository[studyDeploymentId]!;
  DeviceDescriptor device = deployment.registeredDevices.keys.firstWhere(
      (descriptor) => descriptor.roleName == masterDeviceRoleName);

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

  MasterDeviceDeployment deviceDeployment =
      deployment.getDeviceDeploymentFor(device as MasterDeviceDescriptor);

  return SmartphoneDeployment
      .fromMasterDeviceDeploymentAndSmartphoneStudyProtocol(
    studyDeploymentId: studyDeploymentId,
    deployment: deviceDeployment,
    protocol: deployment.protocol as SmartphoneStudyProtocol,
  );
}