getDeviceDeploymentFor method
Get the deployment configuration for the master device with
masterDeviceRoleName
in the study deployment with studyDeploymentId
.
Implementation
@override
Future<MasterDeviceDeployment> getDeviceDeploymentFor(
String studyDeploymentId,
String masterDeviceRoleName,
) async {
SmartphoneDeployment? deployment;
if (isConfigured()) {
// get the protocol from the study protocol manager
protocol = await manager.getStudyProtocol(studyDeploymentId);
_eventController.add(CarpBackendEvents.ProtocolRetrieved);
// create the smartphone deployment
deployment = SmartphoneDeployment.fromSmartphoneStudyProtocol(
studyDeploymentId: studyDeploymentId,
masterDeviceRoleName: masterDeviceRoleName,
protocol: protocol,
);
// set the user id of the deployment to the account id of the logged in user
deployment.userId ??= CarpService().currentUser?.accountId;
info("Study deployment was read from CARP - id: $studyDeploymentId");
_eventController.add(CarpBackendEvents.DeploymentRetrieved);
}
// register a CARP data manager which can upload data back to CARP
DataManagerRegistry().register(CarpDataManagerFactory());
if (deployment != null) {
return deployment;
} else
throw CarpBackendException(
"Could not get deployment in $runtimeType - id: '$studyDeploymentId'");
}