initialize method

  1. @override
Future<void> initialize(
  1. DataEndPoint dataEndPoint,
  2. SmartphoneDeployment deployment,
  3. Stream<Measurement> measurements
)
override

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

Implementation

@override
Future<void> initialize(
  DataEndPoint dataEndPoint,
  SmartphoneDeployment deployment,
  Stream<Measurement> measurements,
) async {
  assert(dataEndPoint is FileDataEndPoint);
  await super.initialize(dataEndPoint, deployment, measurements);

  // _fileDataEndPoint = dataEndPoint as FileDataEndPoint;
  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 directory and file
  await path;
  await file;
  await sink;

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