initialize method

  1. @override
Future<void> initialize(
  1. DataEndPoint dataEndPoint,
  2. MasterDeviceDeployment deployment,
  3. Stream<DataPoint> data
)
override

Initialize the data manager by specifying the dataEndPoint, study deployment, and the stream of data events to handle.

Implementation

@override
Future<void> initialize(
  DataEndPoint dataEndPoint,
  MasterDeviceDeployment deployment,
  Stream<DataPoint> data,
) async {
  assert(dataEndPoint is FileDataEndPoint);
  await super.initialize(dataEndPoint, deployment, data);

  await Settings().getDeploymentBasePath(studyDeploymentId);

  if (fileDataEndPoint.encrypt) {
    assert(fileDataEndPoint.publicKey != null,
        'A public key is required if files are to be encrypted.');
    assert(fileDataEndPoint.publicKey!.isNotEmpty,
        'A non-empty public key is required if files are to be encrypted.');
  }

  // Initializing the the local study directory and file
  await path;
  await file;
  await sink;

  info('Initializing FileDataManager...');
  info('Data file path : $_path');
  info('Buffer size    : ${fileDataEndPoint.bufferSize.toString()} bytes');
}