getDeviceDeploymentFor method
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,
);
}