Skip to content

Commit

Permalink
carp_movisens_package 1.4.0 published
Browse files Browse the repository at this point in the history
  • Loading branch information
bardram committed Nov 26, 2023
1 parent 392d17d commit b096d33
Show file tree
Hide file tree
Showing 11 changed files with 92 additions and 88 deletions.
3 changes: 2 additions & 1 deletion carp_mobile_sensing/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## 1.4.0
## 1.4.0+1

* upgrade to Dart 3.2
* update to README

## 1.3.5

Expand Down
2 changes: 1 addition & 1 deletion carp_mobile_sensing/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: carp_mobile_sensing
description: Mobile Sensing Framework for Flutter. A software framework for collecting sensor data from the phone and attached wearable devices via probes. Can be extended.
version: 1.4.0
version: 1.4.0+1
homepage: https://github.com/cph-cachet/carp.sensing-flutter

environment:
Expand Down
1 change: 1 addition & 0 deletions packages/carp_movisens_package/analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ linter:
cancel_subscriptions: true
constant_identifier_names: false
depend_on_referenced_packages: false
use_string_in_part_of_directives: false
16 changes: 9 additions & 7 deletions packages/carp_movisens_package/example/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
name: carp_movisens_package_example
description: Examples of how to use the CANS Movisens Package.
version: 0.40.0
version: 1.4.0
publish_to: none

environment:
sdk: '>=2.17.0 <3.0.0'
flutter: ">=3.0.0"
sdk: ">=3.2.0 <4.0.0"
flutter: ">=3.6.0"

dependencies:
flutter:
sdk: flutter
carp_core:
path: ../../../carp_core
carp_mobile_sensing:
path: ../../../carp_mobile_sensing
carp_core: ^1.4.0
carp_mobile_sensing: ^1.4.0
# carp_core:
# path: ../../../carp_core
# carp_mobile_sensing:
# path: ../../../carp_mobile_sensing
carp_movisens_package:
path: ../

Expand Down
77 changes: 45 additions & 32 deletions packages/carp_movisens_package/lib/carp_movisens_package.dart
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,15 @@ class MovisensSamplingPackage implements SamplingPackage {

// registering the transformers from CARP to OMH and FHIR for heart rate and step count.
// we assume that there are OMH and FHIR schemas created and registered already...
TransformerSchemaRegistry().lookup(NameSpace.OMH)?.add(
DataTransformerSchemaRegistry().lookup(NameSpace.OMH)?.add(
MovisensData.HR_MEAN,
OMHHeartRateDataPoint.transformer,
);
TransformerSchemaRegistry().lookup(NameSpace.OMH)?.add(
DataTransformerSchemaRegistry().lookup(NameSpace.OMH)?.add(
MovisensData.STEPS,
OMHStepCountDataPoint.transformer,
);
TransformerSchemaRegistry().lookup(NameSpace.FHIR)?.add(
DataTransformerSchemaRegistry().lookup(NameSpace.FHIR)?.add(
MovisensData.HR_MEAN,
FHIRHeartRateObservation.transformer,
);
Expand Down Expand Up @@ -160,41 +160,54 @@ class MovisensSamplingPackage implements SamplingPackage {
}

@override
List<DataTypeMetaData> get dataTypes => [
DataTypeMetaData(
type: ACTIVITY,
displayName: "Physical Activity",
timeType: DataTimeType.POINT,
List<DataTypeMetaData> get dataTypes => samplingSchemes.dataTypes;

@override
DataTypeSamplingSchemeMap get samplingSchemes =>
DataTypeSamplingSchemeMap.from([
DataTypeSamplingScheme(
DataTypeMetaData(
type: ACTIVITY,
displayName: "Physical Activity",
timeType: DataTimeType.POINT,
),
),
DataTypeMetaData(
type: HR,
displayName: "Heart Rate (HR) data",
timeType: DataTimeType.POINT,
DataTypeSamplingScheme(
DataTypeMetaData(
type: HR,
displayName: "Heart Rate (HR) data",
timeType: DataTimeType.POINT,
),
),
DataTypeMetaData(
type: EDA,
displayName: "Elecrodermal Activity (EDA)",
timeType: DataTimeType.POINT,
DataTypeSamplingScheme(
DataTypeMetaData(
type: EDA,
displayName: "Elecrodermal Activity (EDA)",
timeType: DataTimeType.POINT,
),
),
DataTypeMetaData(
type: SKIN_TEMPERATURE,
displayName: "Skin Temperature",
timeType: DataTimeType.POINT,
DataTypeSamplingScheme(
DataTypeMetaData(
type: SKIN_TEMPERATURE,
displayName: "Skin Temperature",
timeType: DataTimeType.POINT,
),
),
DataTypeMetaData(
type: RESPIRATION,
displayName: "Respiration",
timeType: DataTimeType.POINT,
DataTypeSamplingScheme(
DataTypeMetaData(
type: RESPIRATION,
displayName: "Respiration",
timeType: DataTimeType.POINT,
),
),
DataTypeMetaData(
type: TAP_MARKER,
displayName: "Tap markers by the user.",
timeType: DataTimeType.POINT,
DataTypeSamplingScheme(
DataTypeMetaData(
type: TAP_MARKER,
displayName: "Tap markers by the user.",
timeType: DataTimeType.POINT,
),
),
];

@override
SamplingSchema get samplingSchema => SamplingSchema();
]);
}

/// The location on the body where the Movisens device is placed.
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions packages/carp_movisens_package/lib/movisens_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ abstract class MovisensData extends Data {
}

/// Make a Movisens timestamp into UTC format
static String _movisensTimestampToUTC(String timestamp) {
List<String> splittedTimestamp = timestamp.split(" ");
return "${splittedTimestamp[0]}T${splittedTimestamp[1]}.000Z";
static String movisensTimestampToUTC(String timestamp) {
var split = timestamp.split(" ");
return "${split[0]}T${split[1]}.000Z";
}
}

Expand Down
23 changes: 7 additions & 16 deletions packages/carp_movisens_package/lib/movisens_device_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class MovisensDevice extends DeviceConfiguration {
'${DeviceConfiguration.DEVICE_NAMESPACE}.MovisensDevice';

/// The default role name for a Movisens device.
static const String DEFAULT_ROLENAME = 'movisens';
static const String DEFAULT_ROLE_NAME = 'movisens';

/// The name of the device used for connecting to the device.
///
Expand Down Expand Up @@ -55,15 +55,8 @@ class MovisensDevice extends DeviceConfiguration {
this.weight = 78,
this.age = 25,
}) : super(
roleName: roleName ?? DEFAULT_ROLENAME,
roleName: roleName ?? DEFAULT_ROLE_NAME,
isOptional: true,
supportedDataTypes: [
MovisensSamplingPackage.ACTIVITY,
MovisensSamplingPackage.HR,
MovisensSamplingPackage.EDA,
MovisensSamplingPackage.TAP_MARKER,
MovisensSamplingPackage.SKIN_TEMPERATURE,
],
);

@override
Expand All @@ -79,7 +72,7 @@ class MovisensDeviceManager extends BTLEDeviceManager<MovisensDevice> {
// the last known voltage level of the Movisens device
int _batteryLevel = -1;
String? _connectionStatus;
StreamSubscription<BluetoothDeviceState>? _subscription;
StreamSubscription<BluetoothConnectionState>? _subscription;

/// The [Movisens] device handler.
/// Only available after this device manger has been initialized via the
Expand Down Expand Up @@ -127,16 +120,14 @@ class MovisensDeviceManager extends BTLEDeviceManager<MovisensDevice> {
// listen for BTLE connection events
_subscription = device?.state?.listen((state) {
switch (state) {
case BluetoothDeviceState.connecting:
case BluetoothConnectionState.connecting:
status = DeviceStatus.connecting;

break;
case BluetoothDeviceState.connected:
case BluetoothConnectionState.connected:
status = DeviceStatus.connected;

break;
case BluetoothDeviceState.disconnecting:
case BluetoothDeviceState.disconnected:
case BluetoothConnectionState.disconnecting:
case BluetoothConnectionState.disconnected:
status = DeviceStatus.disconnected;
break;
}
Expand Down
4 changes: 2 additions & 2 deletions packages/carp_movisens_package/lib/movisens_transformers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class OMHHeartRateDataPoint extends OMHMovisensDataPoint
implements DataTransformerFactory {
static const String DEFAULT_HR_UNIT = "beats/min";

OMHHeartRateDataPoint(omh.DataPoint datapoint) : super(datapoint);
OMHHeartRateDataPoint(super.datapoint);

factory OMHHeartRateDataPoint.fromMovisensHRData(MovisensHR data) {
var hr = omh.HeartRate(
Expand Down Expand Up @@ -73,7 +73,7 @@ class OMHHeartRateDataPoint extends OMHMovisensDataPoint
/// A [Data] that holds an OMH [StepCount](https://pub.dev/documentation/openmhealth_schemas/latest/domain_omh_activity/StepCount-class.html)
class OMHStepCountDataPoint extends OMHMovisensDataPoint
implements DataTransformerFactory {
OMHStepCountDataPoint(omh.DataPoint datapoint) : super(datapoint);
OMHStepCountDataPoint(super.datapoint);

factory OMHStepCountDataPoint.fromMovisensStepCountData(
MovisensStepCount data) {
Expand Down
26 changes: 13 additions & 13 deletions packages/carp_movisens_package/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
name: carp_movisens_package
description: CARP Movisens sampling package. Samples movement, activity, HRV, MET-level, and ECG for the Movisens Move4 and EcgMove4 devices
version: 1.1.0
version: 1.4.0
homepage: https://github.com/cph-cachet/carp.sensing-flutter/tree/master/packages/carp_movisens_package

environment:
sdk: '>=2.17.0 <3.0.0'
flutter: ">=3.0.0"
sdk: ">=3.2.0 <4.0.0"
flutter: ">=3.6.0"

dependencies:
flutter:
sdk: flutter

carp_serializable: ^1.1.0
# carp_core: ^1.1.0
# carp_mobile_sensing: ^1.1.0
carp_core: ^1.4.0
carp_mobile_sensing: ^1.4.0

json_annotation: ^4.7.0
json_annotation: ^4.8.0
async: ^2.7.0
permission_handler: ^10.0.0
movisens_flutter: ^1.2.0
permission_handler: ^11.0.0
movisens_flutter: ^3.1.0
convert: ^3.0.1
openmhealth_schemas: ^0.2.1+1
flutter_blue_plus: any


# Overriding carp libraries to use the local copy
# Remove this before release of package
dependency_overrides:
# dependency_overrides:
# carp_serializable:
# path: ../../carp_serializable/
carp_core:
path: ../../carp_core/
carp_mobile_sensing:
path: ../../carp_mobile_sensing/
# carp_core:
# path: ../../carp_core/
# carp_mobile_sensing:
# path: ../../carp_mobile_sensing/


dev_dependencies:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ void main() {
expect(protocol.ownerId, '[email protected]');
expect(protocol.primaryDevice.roleName, Smartphone.DEFAULT_ROLENAME);
expect(protocol.connectedDevices?.first.roleName,
MovisensDevice.DEFAULT_ROLENAME);
MovisensDevice.DEFAULT_ROLE_NAME);

print(toJsonString(protocol));
});
Expand All @@ -108,7 +108,7 @@ void main() {
print(toJsonString(dp_1));
expect(dp_1.dataType.namespace, MovisensSamplingPackage.HR);

final omhHR = TransformerSchemaRegistry()
final omhHR = DataTransformerSchemaRegistry()
.lookup(NameSpace.OMH)!
.transform(hr) as OMHHeartRateDataPoint;
;
Expand All @@ -133,7 +133,7 @@ void main() {
print(toJsonString(m_1));
expect(m_1.dataType.namespace, MovisensSamplingPackage.ACTIVITY);

final omhSteps = TransformerSchemaRegistry()
final omhSteps = DataTransformerSchemaRegistry()
.lookup(NameSpace.OMH)!
.transform(steps) as OMHStepCountDataPoint;
final m_2 = Measurement.fromData(omhSteps);
Expand All @@ -156,7 +156,7 @@ void main() {
print(toJsonString(m_1));
expect(m_1.dataType.namespace, MovisensSamplingPackage.HR);

final fhirHR = TransformerSchemaRegistry()
final fhirHR = DataTransformerSchemaRegistry()
.lookup(NameSpace.FHIR)!
.transform(hr) as FHIRHeartRateObservation;
final m_2 = Measurement.fromData(fhirHR);
Expand All @@ -175,16 +175,16 @@ void main() {
);

var transformedData =
TransformerSchemaRegistry().lookup(NameSpace.OMH)!.transform(data);
DataTransformerSchemaRegistry().lookup(NameSpace.OMH)!.transform(data);

Stream<Data> dataStream = StreamController<Data>().stream;

Stream<Data> transformedDataStream = dataStream.map((data) => data =
TransformerSchemaRegistry().lookup(NameSpace.OMH)!.transform(data));
DataTransformerSchemaRegistry().lookup(NameSpace.OMH)!.transform(data));

Stream<Data> transformedPrivateDataStream = dataStream.map((data) => data =
TransformerSchemaRegistry().lookup(NameSpace.OMH)!.transform(
TransformerSchemaRegistry()
DataTransformerSchemaRegistry().lookup(NameSpace.OMH)!.transform(
DataTransformerSchemaRegistry()
.lookup("privacySchemaName")!
.transform(data)));
});
Expand Down

0 comments on commit b096d33

Please sign in to comment.