initialize method

Future<void> initialize(
  1. Study study,
  2. DeviceRegistration deviceRegistration
)

Initialize this study runtime by specifying its study and deviceRegistration.

deviceRegistration is the device configuration for the device this study runtime runs on, identified by deviceRoleName in the study deployment with studyDeploymentId.

Call tryDeployment to subsequently deploy the study.

Implementation

Future<void> initialize(
  Study study,
  DeviceRegistration deviceRegistration,
) async {
  _study = study;
  _status = StudyStatus.DeploymentReceived;

  // Register the master device this study runs on for the given study deployment.
  deploymentStatus = await deploymentService.registerDevice(
    study.studyDeploymentId,
    study.deviceRoleName,
    deviceRegistration,
  );

  // Initialize runtime.
  // this.studyDeploymentId = studyDeploymentId;
  device =
      deploymentStatus.masterDeviceStatus!.device as MasterDeviceDescriptor?;
}