Skip to content

C. Data Managers

Jakob E. Bardram edited this page Jan 18, 2024 · 7 revisions

The CAMS Framework contains the following data managers:

  • ConsoleDataManager - prints data to the Dart console.
  • FileDataManager - a data manager that stores data to a local file as zipped JSON.
  • SQLiteDataManager - a data manager that stores data to a local SQLite database.
  • carp_firebase_backend supporting upload of data both as raw JSON to the Firebase database as well as (zipped) files to the Firebase Storage endpoint.
  • carp_backend supporting data streaming to the CARP Web Service (CAWS) backend.

Files

The FileDataEndPoint allows sensing data to be stored in a JSON file on the local device. A FileDataEndPoint endpoint can be created and added to a study protocol, like this:

    var protocol = SmartphoneStudyProtocol(
        ownerId: 'AB',
        name: 'Track patient movement',
        dataEndPoint: FileDataEndPoint(bufferSize: 500 * 1000, zip: true));

CARP sensing data is stored in a subfolder called

<local_application_path>/carp/deployments/<study_deployment_id>/data

where local_application_path is the folder where an application can place files that are private to the application.

  • On iOS, this is the NSDocumentsDirectory and this can be accessed like accessing files on iOS via the Finder.

  • On Android, Flutter files are stored in the AppData directory, which is located in the data/data/<<package_name>>/app_flutter folder. Files can be accessed via AndroidStudio.

Data files follow the schema of carp-data-yyyy-mm-dd-hh-mm-ss-ms.json. .zip is added, if the JSON file is zipped.

SQLite

This endpoint is very similar to the file endpoint, except that data is stored in an SQLite database instead of a file. This endpoint takes no configuration and can be added to a protocol like this:

    var protocol = SmartphoneStudyProtocol(
        ownerId: 'AB',
        name: 'Track patient movement',
        dataEndPoint: SQLiteDataEndPoint());

The database files can be accessed like other files (see above).

  • On Android, the SQLite db file is located in the data/data/<<package_name>>/databases folder.

Firebase

The carp_firebase_backend package is a separate Flutter package for supporting Google Firebase as a backend. It supports uploading of data both as files in Storage as well as raw JSON in Firestore. Full documentation is provided as part of the plugin.

NOTE - The Firebase data manager has not (yet) been updated to API level 1.x.

CARP Web Services

The carp_backend package is a separate Flutter package supporting the CARP Web Service (CAWS) backend. It supports:

  • user authentication and setting up a connection to CAWS.
  • download of a study deployment configuration from CAWS
  • streaming of sensing data from CAMS to CAWS
  • upload/download of data like files and JSON documents from/to CAWS

Full documentation is provided as part of the plugin, and an example of how this is used is part of the CAMS Demo App.