getDeviceDeploymentFor method

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

Get the deployment configuration for the primary device with primaryDeviceRoleName in the study deployment with studyDeploymentId. Returns null if studyDeploymentId is not found.

Implementation

@override
Future<SmartphoneDeployment?> getDeviceDeploymentFor(
  String studyDeploymentId,
  String primaryDeviceRoleName,
) async {
  if (_repository[studyDeploymentId] == null) return null;

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

  assert(device is PrimaryDeviceConfiguration,
      "The specified '$primaryDeviceRoleName' device is not registered as a primary device");

  PrimaryDeviceDeployment deviceDeployment =
      deployment.getDeviceDeploymentFor(device as PrimaryDeviceConfiguration);

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