carp_mobile_sensing library
This library contains the software architecture for the CARP Mobile Sensing (CAMS) framework implemented in Flutter. Supports cross-platform (iOS and Android) mobile sensing.
The CAMS software architecture is a domain-drive design (DDD) model using an onion-based layout with the following onion layers:
- domain - contains the core domain model for CAMS which extends the domain model of the carp_core domain model. This also include definition of service interfaces.
- runtime - contains the business logic for executing a sensing study (normally called 'application' in DDD).
- infrastructure - contains specific implementation of the services used.
- sampling_packages - contains the build-in sampling packages.
Domain-driven design (DDD) is a software design approach that focuses on modeling the software to match the domain, or the subject area, that the software is intended for. DDD helps developers create software that is aligned with the business needs and terminology of the domain experts, users, and stakeholders. From Domain-Driven Design (DDD): A Guide to Building Scalable, High-Performance Systems by Roman Glushach.
Classes
- AbstractDataManager
- An abstract DataManager implementation useful for extension.
-
AbstractExecutor<
TConfig> - An abstract implementation of a Executor to extend from.
- AccelerationFeatures
- A set of acceleration (non-gravitational) features collected over a specific sampling period.
- AccelerometerFeaturesProbe
- A probe collecting accelerometer data over a sampling period and calculates a set of features based on the samplings, as represented by a AccelerationFeatures data point.
- AccelerometerProbe
- A probe collecting raw data from the accelerometer.
-
AggregateExecutor<
TConfig> - An abstract class used to implement aggregated executors (i.e., executors with a set of underlying executors).
- AmbientLight
- Ambient light intensity in Lux. Typically collected from the light sensor on the front of the phone.
- ApplicationInformation
- Holds basic information about the app from where the data is collected.
- ApplicationProbe
- A probe that collects the device info about this device.
- AppLifecycleEvent
- Holds information about AppLifecycleState events collected from the phone.
- AppLifecycleProbe
- A probe that collects app lifecycle events.
- AppLifecycleTrigger
- A trigger that triggers when the life cycle of an app changes.
- AppLifecycleTriggerExecutor
- Executes an AppLifecycleTrigger.
- AppTask
- A task that notifies the app when it is triggered.
- AppTaskControlExecutor
-
Responsible for handling the execution of a
TaskControlwhich contains an AppTask. - AppTaskController
- A controller of UserTasks which is accessible in the userTaskQueue.
-
AppTaskExecutor<
TConfig extends AppTask> - Executes an AppTask.
- BackgroundSensingUserTask
- A non-UI sensing task that collects sensor data in the background. For example noise.
- BackgroundService
- A service for managing background execution on Android.
- BackgroundTaskExecutor
-
Executes a
BackgroundTask. - BatteryProbe
- Collects battery information (charging state and battery level) on a regular basis as specified by the IntervalSamplingConfiguration.interval.
- BatteryState
- Holds battery level and charging status collected from the phone.
-
BLEDevice<
TRegistration extends BLEDeviceRegistration> - A Bluetooth Low Energy (BLE) device configuration.
-
BLEDeviceManager<
TDeviceConfiguration extends BLEDevice< TRegistration> , TRegistration extends BLEDeviceRegistration> - A device manager for a connectable Bluetooth Low Energy (BLE) device.
- BLEDeviceRegistration
-
A
DeviceRegistrationfor Bluetooth Low Energy (BLE) devices which can connect to the smartphone via BLE, e.g., a heart rate monitor or a BLE beacon. - BLEHeartRateDevice
- A Bluetooth Low Energy (BLE) device which implements a GATT Heart Rate service (https://www.bluetooth.com/specifications/gatt/services/).
- BufferingIntervalStreamProbe
- A type of probe which buffers data from an underlying stream and on a regular interval return a measurement based on this collected data.
- BufferingPeriodicProbe
- An type of probe which collects data for a period of time and then return a measurement from this collected data.
- BufferingPeriodicStreamProbe
- A type of probe which buffers data from an underlying stream for a period of time and then return a measurement from this collected data.
- CamsDataTypeMetaData
- Contains CAMS-specific meta data about a specific data type to be collected.
- CamsDataTypes
-
Contains CAMS data type definitions similar to CARP Core
CarpDataTypes. -
CamsDevice<
TRegistration extends DeviceRegistration> - Root class for all CAMS device configurations.
- CamsDeviceRegistration
- Root class for all CAMS device registrations.
- CarpMobileSensing
- Base class for the carp_mobile_sensing library.
- CARPTransformerSchema
- A default DataTransformerSchema for CARP no-operation transformers
- CompletedAppTask
- Data about a completed AppTask.
- ConditionalPeriodicTrigger
- A trigger that periodically checks if an application-specific triggering condition is met.
- ConditionalPeriodicTriggerExecutor
- Executes a ConditionalPeriodicTrigger.
- ConditionalSamplingEventTrigger
- A trigger that triggers when some (other) sampling event occurs and a application-specific condition is meet.
- ConditionalSamplingEventTriggerExecutor
- Executes a ConditionalSamplingEventTrigger.
- ConsoleDataManager
- A very simple data manager that just "uploads" the data to the console (i.e., prints it). Used mainly for testing and debugging purposes.
- ConsoleDataManagerFactory
- Cron
- CronScheduledTrigger
- A trigger that triggers based on a cron job specification.
- CronScheduledTriggerExecutor
- Executes a CronScheduledTrigger based on the specified cron job.
- DataEndPoint
- Specify an endpoint where a DataManager can upload data.
- DataEndPointTypes
- A enumeration of known (but not necessarily implemented) endpoint API types.
- DataManager
-
The DataManager interface is used to upload
Measurementobjects to any data manager that implements this interface. - DataManagerEvent
- An event for a data manager.
- DataManagerEventTypes
- An enumeration of data manager event types.
- DataManagerFactory
-
A factory which can create a DataManager based on the
typeof an DataEndPoint. - DataManagerRegistry
- A registry of DataManagerFactorys.
- DataTransformerFactory
- A factory which can create a DataTransformer.
- DataTransformerSchema
- An abstract class defining a transformer schema, which hold a set of DataTransformers that can map from the native CARP namespace to another namespace. A DataTransformerSchema must be implemented for each supported namespace.
- DataTransformerSchemaRegistry
- A registry of DataTransformerSchemas which hold a set of DataTransformers.
- DateTimeTrigger
- A trigger that triggers on a specific date and time.
- DateTimeTriggerExecutor
- Executes a DateTimeTrigger on the specified date and time.
- DelayedTrigger
- A trigger that triggers after delay from the (re)start of the app.
- DelayedTriggerExecutor
- Executes a DelayedTrigger, i.e. triggers after the specified delay.
- DeviceController
- A DeviceController handles runtime management of all devices and services available to this phone, including the phone itself.
- DeviceInformation
- Holds basic information about the mobile device from where the data is collected.
- DeviceInfoService
- Provides (static) information about the local device.
-
DeviceManager<
TDeviceConfiguration extends DeviceConfiguration< TRegistration> , TRegistration extends DeviceRegistration> - A DeviceManager handles the runtime of any type of device or service used for data collection.
- DeviceProbe
- A probe that collects the device info about this device.
- DeviceSamplingPackage
- A SamplingPackage containing data types, sampling schemas and probes for collecting information from the device hardware:
- ElapsedTimeTriggerExecutor
-
Executes a
ElapsedTimeTrigger, i.e. triggers after the specified delay after deployment start on this phone. -
Executor<
TConfig> -
A Executor is responsible for executing data collection based on a
configuration
TConfig. - ExecutorFactory
-
A factory that holds the set of trigger and task executors used in all
deployments. Accessed as a singleton using
ExecutorFactory(). - FHIRTransformerSchema
- A default DataTransformerSchema for HL7 FHIR transformers
- FileData
-
A
Dataobject holding a link to a file. - FileDataEndPoint
- Specify an endpoint where a file-based data manager can store JSON data as files on the local device.
- FileDataManager
-
Stores
Measurementobjects on the device's local storage media. Supports compression (zip) and encryption. - FileDataManagerEvent
- A status event for this file data manager. See FileDataManagerEventTypes for a list of possible event types.
- FileDataManagerEventTypes
- An enumeration of file data manager event types
- FileDataManagerFactory
- FileStudyProtocolManager
-
Retrieve and store
StudyProtocoljson definitions on the device's local file system. - FlutterLocalNotificationManager
- A NotificationManager based on the flutter_local_notifications Flutter plugin.
- FreeMemory
- Holds information about free memory on the phone.
- FunctionTask
- A task that can run a custom Dart function.
- FunctionTaskExecutor
- Executes a FunctionTask.
- GyroscopeProbe
- A probe collecting raw data from the gyroscope.
-
HardwareDeviceManager<
TDeviceConfiguration extends DeviceConfiguration< TRegistration> , TRegistration extends DeviceRegistration> - A DeviceManager for a hardware device.
- HardwareDeviceRegistration
-
A
DeviceRegistrationfor a hardware device. -
HasNext<
E> -
HasPrevious<
E> - Heartbeat
-
Reflects a heart beat data send every
periodminute. Useful for calculating sampling coverage over time. - HeartbeatProbe
-
A probe that collects heartbeat info about the master device on a regular basis
as specified in
PeriodicMeasure.frequency. - HistoricSamplingConfiguration
- A sampling configuration which allows configuring the time back in the past and into the future to collect data.
- ImmediateTrigger
- A trigger that starts sampling immediately and never stops.
- ImmediateTriggerExecutor
- Executes an ImmediateTrigger, i.e. starts sampling immediately.
- IntervalProbe
- A probe which is triggered at regular intervals, specified by the interval property in an IntervalSamplingConfiguration. When triggered, the probe collect a measurement using the getMeasurement method.
- IntervalSamplingConfiguration
- A sampling configuration that allows configuring the time interval in between subsequent measurements.
- LightProbe
- The LightProbe listens to the phone's light sensor typically located near the front camera. Every value is in the SI unit Lux and is stored in a AmbientLight object.
- MagnetometerProbe
- A probe collecting raw data from the magnetometer.
- MeasurementProbe
-
This probe collects a single
Measurementwhen started, send its to the measurements stream, and then stops. - MemoryProbe
- A probe that collects free virtual memory on a regular basis as specified by the IntervalSamplingConfiguration.interval.
- MonitoringSamplingPackage
- A SamplingPackage containing data types, sampling schemas and probes for monitoring data sampling:
- NoOpNotificationManager
- A no-operation notification manager that does nothing.
- NoOpTrigger
- A trigger that does nothing.
- NoOpTriggerExecutor
- Executes an NoOpTrigger, i.e. does nothing.
- NotificationManager
- Manages user notifications, including creating, scheduling, and canceling notifications.
- NoUserTaskTrigger
- A trigger that triggers only if a UserTask with taskName is NOT already on the task list.
- NoUserTaskTriggerExecutor
- Executes an NoUserTaskTrigger. Runs once pr minute.
- OMHTransformerSchema
- A default DataTransformerSchema for Open mHealth (OMH) transformers
- OneTimeTrigger
- A trigger that triggers only once during a deployment.
- OneTimeTriggerExecutor
- Executes a OneTimeTrigger, i.e. a trigger that only runs once during a study deployment.
- PassiveTrigger
- A trigger that trigger when the trigger method is called from Dart code.
- PassiveTriggerExecutor
- Executes a PassiveTrigger.
- PedometerProbe
- The pedometer probe listens to the hardware step counter sensor.
- PeriodicSamplingConfiguration
- A sampling configuration specifying how to collect data on a regular basis for a specific period.
- PeriodicStreamProbe
-
A periodic probe listening on a stream. Listening is done periodically as
specified in a PeriodicSamplingConfiguration listening on intervals every
intervalfor a period ofduration. During this period, all data are forwarded to this probes measurements stream. - PeriodicTrigger
- A trigger that triggers every period.
- PeriodicTriggerExecutor
- Executes a PeriodicTrigger.
- PersistenceService
- The PersistenceService class is a singleton which handles persistence of study runtime information to a SQLite database on the phone. Used to store information across app re-start on:
- PersistentSamplingConfiguration
- A sampling configuration that saves the last time it was sampled.
-
PrimaryDevice<
TRegistration extends DeviceRegistration> - Root class for all CAMS primary device configurations.
- PrivacySchema
- A default DataTransformerSchema for privacy transformers
- Probe
-
A Probe is a specialized Executor responsible for collecting data from
the device sensors as configured in a
Measure. - RandomRecurrentTrigger
- A daily trigger that triggers a random number of times within a defined period of time of the day.
- RandomRecurrentTriggerExecutor
- Executes a RandomRecurrentTrigger triggering N times per day within a defined period of time.
- RecurrentScheduledTrigger
- A trigger that triggers based on a recurrent scheduled date and time.
- RecurrentScheduledTriggerExecutor
- Executes a RecurrentScheduledTrigger.
- SamplingEventTrigger
- A trigger that triggers when some sampling event occurs.
- SamplingEventTriggerExecutor
- Executes a SamplingEventTrigger based on the specified SamplingEventTrigger.measureType and SamplingEventTrigger.triggerCondition.
- SamplingPackage
- Interface for a sampling package.
- SamplingPackageRegistry
- A registry of SamplingPackage packages.
- SamplingState
-
SchedulableTriggerExecutor<
TConfig extends TriggerConfiguration> -
Abstract class for executors of triggers which can be scheduled
(i.e., implementing the
Schedulableinterface). - ScreenEvent
- Holds a screen event collected from the phone.
- ScreenProbe
- A probe collecting screen events:
- SensingUserTaskFactory
- A UserTaskFactory that can create a non-UI sensing task.
- SensorProbe
- An abstract sensor probe used by all sensor probes to get the samplingPeriod.
- SensorSamplingPackage
- A SamplingPackage containing data types, sampling schemas and probes for collecting information from the phone sensors:
-
ServiceConfiguration<
TRegistration extends ServiceRegistration> - An 'connected device' which is a service.
-
ServiceManager<
TDeviceConfiguration extends ServiceConfiguration< TRegistration> , TRegistration extends ServiceRegistration> - A DeviceManager for an onboard service, like a location service.
- ServiceRegistration
-
A
DeviceRegistrationfor a ServiceConfiguration. - Settings
- Handle settings for the CAMS infrastructure. This includes settings for debugging, file paths, and other settings related to the infrastructure layer.
- Smartphone
- Configuration of a smartphone that can be part of CAMS mobile sensing study protocols.
- SmartphoneApplicationData
- Holds application-specific configuration for a SmartphoneStudyProtocol.
- SmartPhoneClientManager
-
The singleton
SmartPhoneClientManager()is the main entry point for CARP Mobile Sensing. - SmartphoneClientRepository
-
A
ClientRepositorythat runs on a smartphone. Works as a singleton. Uses the PersistenceService infrastructure to store study information persistently across app restarts. - SmartphoneDeployment
- Contains the entire description and configuration for a study deployment on a smartphone.
- SmartphoneDeploymentExecutor
- A SmartphoneDeploymentExecutor is responsible for executing a SmartphoneDeployment. For each task control in this deployment, it starts a TaskControlExecutor.
- SmartphoneDeploymentExecutorSamplingState
- SmartphoneDeploymentService
-
A local (in-memory) implementation of a
DeploymentServiceuseful in CAMS studies to be deployed locally on this phone. - SmartphoneDeviceManager
- A device manager for a smartphone.
- SmartphoneRegistration
-
A
DeviceRegistrationfor a Smartphone specifying details of the phone. - SmartphoneSamplingPackage
- An abstract class for all sampling packages that run on the phone itself.
- SmartphoneStudy
- A study configured to run on a smartphone (i.e., on a SmartPhoneClientManager).
- SmartphoneStudyController
- Controls the runtime execution of a SmartphoneStudy.
- SmartphoneStudyProtocol
- A description of how a study is to be executed on a smartphone.
- SmartphoneStudyStatusEvent
-
An event related to a running
study, including its runtime state. - SmartphoneTriggerFactory
- A TriggerFactory for all triggers coming with CAMS.
- SQLiteDataEndPoint
- Specify an endpoint for using the SQLiteDataManager to store JSON data in a SQLite database locally on the phone.
- SQLiteDataManager
-
Stores all collected
Measurementjson objects in an SQLite database on the device's local storage media. Measurements are stored in themeasurementstable. - SQLiteDataManagerFactory
- StepEvent
- Step event data as sensed by the phone's built-in pedometer.
- StreamProbe
-
An abstract class used to create a probe that listen continuously to events
from the stream of
Measurementobjects. - StubProbe
- A simple no-op probe that does nothing.
- StudyDescription
- StudyProtocolManager
- An interface defining a manger of SmartphoneStudyProtocols.
- StudyResponsible
-
A person who is responsible for a
StudyProtocol. Typically the Principal Investigator (PI) who is responsible for the study. - TaskControlExecutor
-
Responsible for handling the execution of a
TaskControl. - TaskControlExecutorSamplingState
-
TaskExecutor<
TConfig extends TaskConfiguration> -
The TaskExecutor is responsible for executing a
TaskConfiguration. For each measure in the task, it looks up an appropriate Probe to collect data. - Timezone
- Holds timezone information about the mobile device.
- TimezoneProbe
- A probe that collects the device's current timezone.
- TriggerEvent
- An event streamed from a TriggerExecutor when it triggers.
-
TriggerExecutor<
TConfig extends TriggerConfiguration> - Responsible for handling the execution of a trigger.
- TriggerFactory
-
A factory which can create a TriggerExecutor based on the runtime type
of an
TriggerConfiguration. - UserAccelerometerProbe
- A probe collecting raw data from the user accelerometer.
- UserTask
- A task that the user of the app needs to attend to.
- UserTaskBufferItem
- UserTaskFactory
-
A factory which can create a UserTask based on the
typeof an AppTask. - UserTaskSnapshot
- A snapshot of a UserTask at any given time. Used for saving user tasks persistently across app restart.
- UserTaskTrigger
- A trigger that triggers based on the state of a UserTask.
- UserTaskTriggerExecutor
- Executes a UserTaskTrigger.
Enums
- BatteryChargingState
- The charging state of the device battery of a HardwareDeviceRegistration.
- ClientManagerState
- The possible states of the SmartPhoneClientManager.
- DataEventType
- Describes how a data type is collected (one-time or event-based).
- DebugLevel
- Debugging levels.
- DeviceStatus
- Runtime status for a DeviceManager.
- ExecutorState
- The state of an Executor.
- RecurrentType
- Type of recurrence for a RecurrentScheduledTrigger.
- UserTaskState
- The states of a UserTask.
Mixins
-
CronIterator<
E> - SmartphoneProtocolExtension
- A mixin holding smartphone-specific data for a SmartphoneStudyProtocol and SmartphoneDeployment.
Functions
-
debug(
String message) → void - Add a debug messages to the system log. Only logged if the Flutter app is in debug mode (kDebugMode).
-
info(
String message) → void - Add an information messages to the system log.
-
noop(
Data data) → Data - A no-operation transformer.
-
onDidReceiveNotificationResponse(
NotificationResponse response) → void - Callback method called when a notification is clicked in the operating system.
-
warning(
String message) → void - Add a warning messages to the system log.
Typedefs
- ConditionalEvaluator = bool Function()
-
Evaluates if a ConditionalPeriodicTrigger should trigger.
Returns
trueif triggering should happen,falseotherwise. - ConditionalEventEvaluator = bool Function(Measurement measurement)
-
Takes a
Measurementfrom a sampling stream and evaluates if an event has occurred. Returnstrueif the event has occurred,falseotherwise. - DataTransformer = Data Function(Data)
- Signature of a data transformer.
- VoidFunction = void Function()
- Signature of Dart function that have no arguments and returns no data.
Exceptions / Errors
- SensingException
- Generic sensing exception.