configure method
Future<void>
configure({
- required DataEndPoint dataEndPoint,
- required SmartphoneDeployment deployment,
- required Stream<
Measurement> measurements,
override
Configure the data manager by specifying the study deployment, the
dataEndPoint, and the stream of measurements events to handle.
Implementation
@override
Future<void> configure({
required DataEndPoint dataEndPoint,
required SmartphoneDeployment deployment,
required Stream<Measurement> measurements,
}) async {
assert(dataEndPoint is SQLiteDataEndPoint);
await super.configure(
dataEndPoint: dataEndPoint,
deployment: deployment,
measurements: measurements,
);
info('Initializing $runtimeType...');
_databasePath ??= await getDatabasesPath();
// Open the database - make sure to use the same database across app (re)start
database = await openDatabase(
databaseName,
version: 1,
singleInstance: true,
onCreate: (Database db, int version) async {
// when creating the database, create the measurements table
debug("$runtimeType - Creating '$MEASUREMENT_TABLE_NAME' table");
await db.execute(
'CREATE TABLE $MEASUREMENT_TABLE_NAME ('
'$ID_COLUMN INTEGER PRIMARY KEY AUTOINCREMENT, '
// SQLite does not have a separate Boolean storage class. Instead,
// boolean values are stored as integers 0 (false) and 1 (true).
'$UPLOADED_COLUMN INTEGER, '
'$DEPLOYMENT_ID_COLUMN TEXT, '
'$TRIGGER_ID_COLUMN INTEGER, '
'$DEVICE_ROLE_NAME_COLUMN TEXT, '
'$DATATYPE_COLUMN TEXT, '
'$MEASUREMENT_COLUMN TEXT)',
);
debug("$runtimeType - '$databaseName' DB created");
},
);
}