diff --git a/carp_core/lib/client/study.dart b/carp_core/lib/client/study.dart index f02a77406..443809dbe 100644 --- a/carp_core/lib/client/study.dart +++ b/carp_core/lib/client/study.dart @@ -63,6 +63,10 @@ enum StudyStatus { /// Deployment can complete after all devices have been registered. RegisteringDevices, + /// Device deployment for this primary device has completed, + /// but awaiting deployment of other devices in this study deployment. + AwaitingOtherDeviceDeployments, + /// Study runtime status when deployment has been successfully completed. /// The [PrimaryDeviceDeployment] has been retrieved and all necessary plugins /// to execute the study have been loaded. diff --git a/carp_mobile_sensing/lib/domain/study_protocol.dart b/carp_mobile_sensing/lib/domain/study_protocol.dart index eb2bac7cb..888d8959a 100644 --- a/carp_mobile_sensing/lib/domain/study_protocol.dart +++ b/carp_mobile_sensing/lib/domain/study_protocol.dart @@ -170,20 +170,24 @@ class SmartphoneStudyProtocol extends StudyProtocol return true; } - // Add the trigger, task completed, error, and heartbeat measures to the protocol - // since CAMS always collects and upload this data from any device. + /// Add the trigger, task completed, error, and heartbeat measures to the protocol + /// since CAMS always collects and upload this data from any device. + /// If the device is a primary device, also add the CompletedAppTask measure. void _addSamplingTaskControl(DeviceConfiguration device) { + var measures = [ + Measure(type: CarpDataTypes.ERROR_TYPE_NAME), + Measure(type: CarpDataTypes.TRIGGERED_TASK_TYPE_NAME), + Measure(type: CarpDataTypes.COMPLETED_TASK_TYPE_NAME), + Measure(type: Heartbeat.dataType), + ]; + if (device is PrimaryDeviceConfiguration) { + // For primary devices, also add the CompletedAppTask measure + measures.add(Measure(type: CompletedAppTask.dataType)); + } + addTaskControl( NoOpTrigger(), - BackgroundTask(measures: [ - // CARP Core measures - Measure(type: CarpDataTypes.ERROR_TYPE_NAME), - Measure(type: CarpDataTypes.TRIGGERED_TASK_TYPE_NAME), - Measure(type: CarpDataTypes.COMPLETED_TASK_TYPE_NAME), - // CAMS specific measures - Measure(type: Heartbeat.dataType), - Measure(type: CompletedAppTask.dataType), - ]), + BackgroundTask(measures: measures), device, Control.Start, ); diff --git a/packages/carp_movesense_package/lib/movesense_probes.dart b/packages/carp_movesense_package/lib/movesense_probes.dart index 59755d22d..535976ad7 100644 --- a/packages/carp_movesense_package/lib/movesense_probes.dart +++ b/packages/carp_movesense_package/lib/movesense_probes.dart @@ -25,8 +25,10 @@ abstract class _MovesenseStreamProbe extends StreamProbe { @override Stream? get stream => deviceManager.isConnected - ? _streamController.stream.map((event) => - Measurement.fromData(_converter.call(jsonDecode(event)) as Data)) + ? _streamController.stream + .map((event) => + Measurement.fromData(_converter.call(jsonDecode(event)) as Data)) + .skip(10) // skip first 10 measurements to allow sensor to stabilize : null; @override