From 63bb532451e66d3587ad1813ff8006c8342dedfa Mon Sep 17 00:00:00 2001 From: bardram Date: Wed, 4 Dec 2024 15:11:01 +0100 Subject: [PATCH 1/4] implementation of #453 --- .../example/lib/trigger_example.g.dart | 23 +- .../lib/carp_mobile_sensing.json.dart | 3 +- carp_mobile_sensing/lib/domain.g.dart | 819 +++++++----------- carp_mobile_sensing/lib/domain/triggers.dart | 22 + .../sampling_packages/device.g.dart | 114 +-- .../sampling_packages/sensors.g.dart | 132 ++- carp_mobile_sensing/lib/runtime.g.dart | 36 +- .../runtime/executors/executor_factory.dart | 4 +- .../executors/task_control_executors.dart | 6 +- .../runtime/executors/trigger_executors.dart | 27 + .../lib/runtime/user_tasks.dart | 2 +- 11 files changed, 490 insertions(+), 698 deletions(-) diff --git a/carp_mobile_sensing/example/lib/trigger_example.g.dart b/carp_mobile_sensing/example/lib/trigger_example.g.dart index 3ea2a150..57fc0270 100644 --- a/carp_mobile_sensing/example/lib/trigger_example.g.dart +++ b/carp_mobile_sensing/example/lib/trigger_example.g.dart @@ -16,18 +16,11 @@ RemoteTrigger _$RemoteTriggerFromJson(Map json) => ..$type = json['__type'] as String? ..sourceDeviceRoleName = json['sourceDeviceRoleName'] as String?; -Map _$RemoteTriggerToJson(RemoteTrigger instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - writeNotNull('sourceDeviceRoleName', instance.sourceDeviceRoleName); - val['uri'] = instance.uri; - val['interval'] = instance.interval.inMicroseconds; - return val; -} +Map _$RemoteTriggerToJson(RemoteTrigger instance) => + { + if (instance.$type case final value?) '__type': value, + if (instance.sourceDeviceRoleName case final value?) + 'sourceDeviceRoleName': value, + 'uri': instance.uri, + 'interval': instance.interval.inMicroseconds, + }; diff --git a/carp_mobile_sensing/lib/carp_mobile_sensing.json.dart b/carp_mobile_sensing/lib/carp_mobile_sensing.json.dart index 0a9b543d..d9b01c40 100644 --- a/carp_mobile_sensing/lib/carp_mobile_sensing.json.dart +++ b/carp_mobile_sensing/lib/carp_mobile_sensing.json.dart @@ -41,7 +41,8 @@ void _registerFromJsonFunctions() { UserTaskTrigger( taskName: 'ignored', triggerCondition: UserTaskState.done, - ) + ), + NoUserTaskTrigger(taskName: 'ignored') ]); // Data classes diff --git a/carp_mobile_sensing/lib/domain.g.dart b/carp_mobile_sensing/lib/domain.g.dart index a9c1698c..7cb59ab7 100644 --- a/carp_mobile_sensing/lib/domain.g.dart +++ b/carp_mobile_sensing/lib/domain.g.dart @@ -21,21 +21,16 @@ SmartphoneApplicationData _$SmartphoneApplicationDataFromJson( ); Map _$SmartphoneApplicationDataToJson( - SmartphoneApplicationData instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('studyDescription', instance.studyDescription?.toJson()); - writeNotNull('dataEndPoint', instance.dataEndPoint?.toJson()); - writeNotNull('privacySchemaName', instance.privacySchemaName); - writeNotNull('applicationData', instance.applicationData); - return val; -} + SmartphoneApplicationData instance) => + { + if (instance.studyDescription?.toJson() case final value?) + 'studyDescription': value, + if (instance.dataEndPoint?.toJson() case final value?) + 'dataEndPoint': value, + if (instance.privacySchemaName case final value?) + 'privacySchemaName': value, + if (instance.applicationData case final value?) 'applicationData': value, + }; SmartphoneStudyProtocol _$SmartphoneStudyProtocolFromJson( Map json) => @@ -84,39 +79,35 @@ SmartphoneStudyProtocol _$SmartphoneStudyProtocolFromJson( .toSet(); Map _$SmartphoneStudyProtocolToJson( - SmartphoneStudyProtocol instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('applicationData', instance.applicationData); - val['id'] = instance.id; - val['createdOn'] = instance.createdOn.toIso8601String(); - val['version'] = instance.version; - val['description'] = instance.description; - val['ownerId'] = instance.ownerId; - val['name'] = instance.name; - writeNotNull('participantRoles', - instance.participantRoles?.map((e) => e.toJson()).toList()); - val['primaryDevices'] = - instance.primaryDevices.map((e) => e.toJson()).toList(); - writeNotNull('connectedDevices', - instance.connectedDevices?.map((e) => e.toJson()).toList()); - writeNotNull( - 'connections', instance.connections?.map((e) => e.toJson()).toList()); - writeNotNull('assignedDevices', - instance.assignedDevices?.map((k, e) => MapEntry(k, e.toList()))); - val['tasks'] = instance.tasks.map((e) => e.toJson()).toList(); - val['triggers'] = instance.triggers.map((k, e) => MapEntry(k, e.toJson())); - val['taskControls'] = instance.taskControls.map((e) => e.toJson()).toList(); - writeNotNull('expectedParticipantData', - instance.expectedParticipantData?.map((e) => e.toJson()).toList()); - return val; -} + SmartphoneStudyProtocol instance) => + { + if (instance.applicationData case final value?) 'applicationData': value, + 'id': instance.id, + 'createdOn': instance.createdOn.toIso8601String(), + 'version': instance.version, + 'description': instance.description, + 'ownerId': instance.ownerId, + 'name': instance.name, + if (instance.participantRoles?.map((e) => e.toJson()).toList() + case final value?) + 'participantRoles': value, + 'primaryDevices': instance.primaryDevices.map((e) => e.toJson()).toList(), + if (instance.connectedDevices?.map((e) => e.toJson()).toList() + case final value?) + 'connectedDevices': value, + if (instance.connections?.map((e) => e.toJson()).toList() + case final value?) + 'connections': value, + if (instance.assignedDevices?.map((k, e) => MapEntry(k, e.toList())) + case final value?) + 'assignedDevices': value, + 'tasks': instance.tasks.map((e) => e.toJson()).toList(), + 'triggers': instance.triggers.map((k, e) => MapEntry(k, e.toJson())), + 'taskControls': instance.taskControls.map((e) => e.toJson()).toList(), + if (instance.expectedParticipantData?.map((e) => e.toJson()).toList() + case final value?) + 'expectedParticipantData': value, + }; StudyDescription _$StudyDescriptionFromJson(Map json) => StudyDescription( @@ -131,24 +122,19 @@ StudyDescription _$StudyDescriptionFromJson(Map json) => json['responsible'] as Map), )..$type = json['__type'] as String?; -Map _$StudyDescriptionToJson(StudyDescription instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - val['title'] = instance.title; - writeNotNull('description', instance.description); - writeNotNull('purpose', instance.purpose); - writeNotNull('studyDescriptionUrl', instance.studyDescriptionUrl); - writeNotNull('privacyPolicyUrl', instance.privacyPolicyUrl); - writeNotNull('responsible', instance.responsible?.toJson()); - return val; -} +Map _$StudyDescriptionToJson(StudyDescription instance) => + { + if (instance.$type case final value?) '__type': value, + 'title': instance.title, + if (instance.description case final value?) 'description': value, + if (instance.purpose case final value?) 'purpose': value, + if (instance.studyDescriptionUrl case final value?) + 'studyDescriptionUrl': value, + if (instance.privacyPolicyUrl case final value?) + 'privacyPolicyUrl': value, + if (instance.responsible?.toJson() case final value?) + 'responsible': value, + }; StudyResponsible _$StudyResponsibleFromJson(Map json) => StudyResponsible( @@ -160,44 +146,28 @@ StudyResponsible _$StudyResponsibleFromJson(Map json) => address: json['address'] as String?, )..$type = json['__type'] as String?; -Map _$StudyResponsibleToJson(StudyResponsible instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - val['id'] = instance.id; - val['name'] = instance.name; - writeNotNull('title', instance.title); - writeNotNull('email', instance.email); - writeNotNull('address', instance.address); - writeNotNull('affiliation', instance.affiliation); - return val; -} +Map _$StudyResponsibleToJson(StudyResponsible instance) => + { + if (instance.$type case final value?) '__type': value, + 'id': instance.id, + 'name': instance.name, + if (instance.title case final value?) 'title': value, + if (instance.email case final value?) 'email': value, + if (instance.address case final value?) 'address': value, + if (instance.affiliation case final value?) 'affiliation': value, + }; DataEndPoint _$DataEndPointFromJson(Map json) => DataEndPoint( type: json['type'] as String, dataFormat: json['dataFormat'] as String? ?? NameSpace.CARP, )..$type = json['__type'] as String?; -Map _$DataEndPointToJson(DataEndPoint instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - val['type'] = instance.type; - val['dataFormat'] = instance.dataFormat; - return val; -} +Map _$DataEndPointToJson(DataEndPoint instance) => + { + if (instance.$type case final value?) '__type': value, + 'type': instance.type, + 'dataFormat': instance.dataFormat, + }; FileDataEndPoint _$FileDataEndPointFromJson(Map json) => FileDataEndPoint( @@ -209,24 +179,16 @@ FileDataEndPoint _$FileDataEndPointFromJson(Map json) => publicKey: json['publicKey'] as String?, )..$type = json['__type'] as String?; -Map _$FileDataEndPointToJson(FileDataEndPoint instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - val['type'] = instance.type; - val['dataFormat'] = instance.dataFormat; - val['bufferSize'] = instance.bufferSize; - val['zip'] = instance.zip; - val['encrypt'] = instance.encrypt; - writeNotNull('publicKey', instance.publicKey); - return val; -} +Map _$FileDataEndPointToJson(FileDataEndPoint instance) => + { + if (instance.$type case final value?) '__type': value, + 'type': instance.type, + 'dataFormat': instance.dataFormat, + 'bufferSize': instance.bufferSize, + 'zip': instance.zip, + 'encrypt': instance.encrypt, + if (instance.publicKey case final value?) 'publicKey': value, + }; SQLiteDataEndPoint _$SQLiteDataEndPointFromJson(Map json) => SQLiteDataEndPoint( @@ -234,20 +196,12 @@ SQLiteDataEndPoint _$SQLiteDataEndPointFromJson(Map json) => dataFormat: json['dataFormat'] as String? ?? NameSpace.CARP, )..$type = json['__type'] as String?; -Map _$SQLiteDataEndPointToJson(SQLiteDataEndPoint instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - val['type'] = instance.type; - val['dataFormat'] = instance.dataFormat; - return val; -} +Map _$SQLiteDataEndPointToJson(SQLiteDataEndPoint instance) => + { + if (instance.$type case final value?) '__type': value, + 'type': instance.type, + 'dataFormat': instance.dataFormat, + }; PersistentSamplingConfiguration _$PersistentSamplingConfigurationFromJson( Map json) => @@ -258,19 +212,12 @@ PersistentSamplingConfiguration _$PersistentSamplingConfigurationFromJson( : DateTime.parse(json['lastTime'] as String); Map _$PersistentSamplingConfigurationToJson( - PersistentSamplingConfiguration instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - writeNotNull('lastTime', instance.lastTime?.toIso8601String()); - return val; -} + PersistentSamplingConfiguration instance) => + { + if (instance.$type case final value?) '__type': value, + if (instance.lastTime?.toIso8601String() case final value?) + 'lastTime': value, + }; HistoricSamplingConfiguration _$HistoricSamplingConfigurationFromJson( Map json) => @@ -288,21 +235,14 @@ HistoricSamplingConfiguration _$HistoricSamplingConfigurationFromJson( : DateTime.parse(json['lastTime'] as String); Map _$HistoricSamplingConfigurationToJson( - HistoricSamplingConfiguration instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - writeNotNull('lastTime', instance.lastTime?.toIso8601String()); - val['past'] = instance.past.inMicroseconds; - val['future'] = instance.future.inMicroseconds; - return val; -} + HistoricSamplingConfiguration instance) => + { + if (instance.$type case final value?) '__type': value, + if (instance.lastTime?.toIso8601String() case final value?) + 'lastTime': value, + 'past': instance.past.inMicroseconds, + 'future': instance.future.inMicroseconds, + }; IntervalSamplingConfiguration _$IntervalSamplingConfigurationFromJson( Map json) => @@ -315,20 +255,13 @@ IntervalSamplingConfiguration _$IntervalSamplingConfigurationFromJson( : DateTime.parse(json['lastTime'] as String); Map _$IntervalSamplingConfigurationToJson( - IntervalSamplingConfiguration instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - writeNotNull('lastTime', instance.lastTime?.toIso8601String()); - val['interval'] = instance.interval.inMicroseconds; - return val; -} + IntervalSamplingConfiguration instance) => + { + if (instance.$type case final value?) '__type': value, + if (instance.lastTime?.toIso8601String() case final value?) + 'lastTime': value, + 'interval': instance.interval.inMicroseconds, + }; PeriodicSamplingConfiguration _$PeriodicSamplingConfigurationFromJson( Map json) => @@ -342,21 +275,14 @@ PeriodicSamplingConfiguration _$PeriodicSamplingConfigurationFromJson( : DateTime.parse(json['lastTime'] as String); Map _$PeriodicSamplingConfigurationToJson( - PeriodicSamplingConfiguration instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - writeNotNull('lastTime', instance.lastTime?.toIso8601String()); - val['interval'] = instance.interval.inMicroseconds; - val['duration'] = instance.duration.inMicroseconds; - return val; -} + PeriodicSamplingConfiguration instance) => + { + if (instance.$type case final value?) '__type': value, + if (instance.lastTime?.toIso8601String() case final value?) + 'lastTime': value, + 'interval': instance.interval.inMicroseconds, + 'duration': instance.duration.inMicroseconds, + }; OnlineService _$OnlineServiceFromJson< TRegistration extends DeviceRegistration>(Map json) => @@ -373,24 +299,16 @@ OnlineService _$OnlineServiceFromJson< Map _$OnlineServiceToJson( - OnlineService instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - val['roleName'] = instance.roleName; - writeNotNull('isOptional', instance.isOptional); - writeNotNull( - 'defaultSamplingConfiguration', - instance.defaultSamplingConfiguration - ?.map((k, e) => MapEntry(k, e.toJson()))); - return val; -} + OnlineService instance) => + { + if (instance.$type case final value?) '__type': value, + 'roleName': instance.roleName, + if (instance.isOptional case final value?) 'isOptional': value, + if (instance.defaultSamplingConfiguration + ?.map((k, e) => MapEntry(k, e.toJson())) + case final value?) + 'defaultSamplingConfiguration': value, + }; SmartphoneDeployment _$SmartphoneDeploymentFromJson( Map json) => @@ -447,35 +365,29 @@ SmartphoneDeployment _$SmartphoneDeploymentFromJson( ..status = $enumDecode(_$StudyStatusEnumMap, json['status']); Map _$SmartphoneDeploymentToJson( - SmartphoneDeployment instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('applicationData', instance.applicationData); - val['deviceConfiguration'] = instance.deviceConfiguration.toJson(); - val['registration'] = instance.registration.toJson(); - val['connectedDevices'] = - instance.connectedDevices.map((e) => e.toJson()).toList(); - val['connectedDeviceRegistrations'] = instance.connectedDeviceRegistrations - .map((k, e) => MapEntry(k, e?.toJson())); - val['tasks'] = instance.tasks.map((e) => e.toJson()).toList(); - val['triggers'] = instance.triggers.map((k, e) => MapEntry(k, e.toJson())); - val['taskControls'] = instance.taskControls.map((e) => e.toJson()).toList(); - val['expectedParticipantData'] = - instance.expectedParticipantData.map((e) => e.toJson()).toList(); - writeNotNull('studyId', instance.studyId); - val['studyDeploymentId'] = instance.studyDeploymentId; - writeNotNull('participantId', instance.participantId); - writeNotNull('participantRoleName', instance.participantRoleName); - writeNotNull('deployed', instance.deployed?.toIso8601String()); - val['status'] = _$StudyStatusEnumMap[instance.status]!; - return val; -} + SmartphoneDeployment instance) => + { + if (instance.applicationData case final value?) 'applicationData': value, + 'deviceConfiguration': instance.deviceConfiguration.toJson(), + 'registration': instance.registration.toJson(), + 'connectedDevices': + instance.connectedDevices.map((e) => e.toJson()).toList(), + 'connectedDeviceRegistrations': instance.connectedDeviceRegistrations + .map((k, e) => MapEntry(k, e?.toJson())), + 'tasks': instance.tasks.map((e) => e.toJson()).toList(), + 'triggers': instance.triggers.map((k, e) => MapEntry(k, e.toJson())), + 'taskControls': instance.taskControls.map((e) => e.toJson()).toList(), + 'expectedParticipantData': + instance.expectedParticipantData.map((e) => e.toJson()).toList(), + if (instance.studyId case final value?) 'studyId': value, + 'studyDeploymentId': instance.studyDeploymentId, + if (instance.participantId case final value?) 'participantId': value, + if (instance.participantRoleName case final value?) + 'participantRoleName': value, + if (instance.deployed?.toIso8601String() case final value?) + 'deployed': value, + 'status': _$StudyStatusEnumMap[instance.status]!, + }; const _$StudyStatusEnumMap = { StudyStatus.DeploymentNotStarted: 'DeploymentNotStarted', @@ -508,27 +420,20 @@ AppTask _$AppTaskFromJson(Map json) => AppTask( notification: json['notification'] as bool? ?? false, )..$type = json['__type'] as String?; -Map _$AppTaskToJson(AppTask instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - val['name'] = instance.name; - writeNotNull('measures', instance.measures?.map((e) => e.toJson()).toList()); - val['type'] = instance.type; - val['title'] = instance.title; - val['description'] = instance.description; - val['instructions'] = instance.instructions; - writeNotNull('minutesToComplete', instance.minutesToComplete); - writeNotNull('expire', instance.expire?.inMicroseconds); - val['notification'] = instance.notification; - return val; -} +Map _$AppTaskToJson(AppTask instance) => { + if (instance.$type case final value?) '__type': value, + 'name': instance.name, + if (instance.measures?.map((e) => e.toJson()).toList() case final value?) + 'measures': value, + 'type': instance.type, + 'title': instance.title, + 'description': instance.description, + 'instructions': instance.instructions, + if (instance.minutesToComplete case final value?) + 'minutesToComplete': value, + if (instance.expire?.inMicroseconds case final value?) 'expire': value, + 'notification': instance.notification, + }; FunctionTask _$FunctionTaskFromJson(Map json) => FunctionTask( name: json['name'] as String?, @@ -539,58 +444,37 @@ FunctionTask _$FunctionTaskFromJson(Map json) => FunctionTask( ?.map((e) => Measure.fromJson(e as Map)) .toList(); -Map _$FunctionTaskToJson(FunctionTask instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - val['name'] = instance.name; - writeNotNull('measures', instance.measures?.map((e) => e.toJson()).toList()); - writeNotNull('description', instance.description); - return val; -} +Map _$FunctionTaskToJson(FunctionTask instance) => + { + if (instance.$type case final value?) '__type': value, + 'name': instance.name, + if (instance.measures?.map((e) => e.toJson()).toList() case final value?) + 'measures': value, + if (instance.description case final value?) 'description': value, + }; NoOpTrigger _$NoOpTriggerFromJson(Map json) => NoOpTrigger() ..$type = json['__type'] as String? ..sourceDeviceRoleName = json['sourceDeviceRoleName'] as String?; -Map _$NoOpTriggerToJson(NoOpTrigger instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - writeNotNull('sourceDeviceRoleName', instance.sourceDeviceRoleName); - return val; -} +Map _$NoOpTriggerToJson(NoOpTrigger instance) => + { + if (instance.$type case final value?) '__type': value, + if (instance.sourceDeviceRoleName case final value?) + 'sourceDeviceRoleName': value, + }; ImmediateTrigger _$ImmediateTriggerFromJson(Map json) => ImmediateTrigger() ..$type = json['__type'] as String? ..sourceDeviceRoleName = json['sourceDeviceRoleName'] as String?; -Map _$ImmediateTriggerToJson(ImmediateTrigger instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - writeNotNull('sourceDeviceRoleName', instance.sourceDeviceRoleName); - return val; -} +Map _$ImmediateTriggerToJson(ImmediateTrigger instance) => + { + if (instance.$type case final value?) '__type': value, + if (instance.sourceDeviceRoleName case final value?) + 'sourceDeviceRoleName': value, + }; OneTimeTrigger _$OneTimeTriggerFromJson(Map json) => OneTimeTrigger() @@ -600,40 +484,26 @@ OneTimeTrigger _$OneTimeTriggerFromJson(Map json) => ? null : DateTime.parse(json['triggerTimestamp'] as String); -Map _$OneTimeTriggerToJson(OneTimeTrigger instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - writeNotNull('sourceDeviceRoleName', instance.sourceDeviceRoleName); - writeNotNull( - 'triggerTimestamp', instance.triggerTimestamp?.toIso8601String()); - return val; -} +Map _$OneTimeTriggerToJson(OneTimeTrigger instance) => + { + if (instance.$type case final value?) '__type': value, + if (instance.sourceDeviceRoleName case final value?) + 'sourceDeviceRoleName': value, + if (instance.triggerTimestamp?.toIso8601String() case final value?) + 'triggerTimestamp': value, + }; PassiveTrigger _$PassiveTriggerFromJson(Map json) => PassiveTrigger() ..$type = json['__type'] as String? ..sourceDeviceRoleName = json['sourceDeviceRoleName'] as String?; -Map _$PassiveTriggerToJson(PassiveTrigger instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - writeNotNull('sourceDeviceRoleName', instance.sourceDeviceRoleName); - return val; -} +Map _$PassiveTriggerToJson(PassiveTrigger instance) => + { + if (instance.$type case final value?) '__type': value, + if (instance.sourceDeviceRoleName case final value?) + 'sourceDeviceRoleName': value, + }; DelayedTrigger _$DelayedTriggerFromJson(Map json) => DelayedTrigger( @@ -642,20 +512,13 @@ DelayedTrigger _$DelayedTriggerFromJson(Map json) => ..$type = json['__type'] as String? ..sourceDeviceRoleName = json['sourceDeviceRoleName'] as String?; -Map _$DelayedTriggerToJson(DelayedTrigger instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - writeNotNull('sourceDeviceRoleName', instance.sourceDeviceRoleName); - val['delay'] = instance.delay.inMicroseconds; - return val; -} +Map _$DelayedTriggerToJson(DelayedTrigger instance) => + { + if (instance.$type case final value?) '__type': value, + if (instance.sourceDeviceRoleName case final value?) + 'sourceDeviceRoleName': value, + 'delay': instance.delay.inMicroseconds, + }; PeriodicTrigger _$PeriodicTriggerFromJson(Map json) => PeriodicTrigger( @@ -664,20 +527,13 @@ PeriodicTrigger _$PeriodicTriggerFromJson(Map json) => ..$type = json['__type'] as String? ..sourceDeviceRoleName = json['sourceDeviceRoleName'] as String?; -Map _$PeriodicTriggerToJson(PeriodicTrigger instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - writeNotNull('sourceDeviceRoleName', instance.sourceDeviceRoleName); - val['period'] = instance.period.inMicroseconds; - return val; -} +Map _$PeriodicTriggerToJson(PeriodicTrigger instance) => + { + if (instance.$type case final value?) '__type': value, + if (instance.sourceDeviceRoleName case final value?) + 'sourceDeviceRoleName': value, + 'period': instance.period.inMicroseconds, + }; DateTimeTrigger _$DateTimeTriggerFromJson(Map json) => DateTimeTrigger( @@ -686,20 +542,13 @@ DateTimeTrigger _$DateTimeTriggerFromJson(Map json) => ..$type = json['__type'] as String? ..sourceDeviceRoleName = json['sourceDeviceRoleName'] as String?; -Map _$DateTimeTriggerToJson(DateTimeTrigger instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - writeNotNull('sourceDeviceRoleName', instance.sourceDeviceRoleName); - val['schedule'] = instance.schedule.toIso8601String(); - return val; -} +Map _$DateTimeTriggerToJson(DateTimeTrigger instance) => + { + if (instance.$type case final value?) '__type': value, + if (instance.sourceDeviceRoleName case final value?) + 'sourceDeviceRoleName': value, + 'schedule': instance.schedule.toIso8601String(), + }; RecurrentScheduledTrigger _$RecurrentScheduledTriggerFromJson( Map json) => @@ -718,28 +567,22 @@ RecurrentScheduledTrigger _$RecurrentScheduledTriggerFromJson( ..period = Duration(microseconds: (json['period'] as num).toInt()); Map _$RecurrentScheduledTriggerToJson( - RecurrentScheduledTrigger instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - writeNotNull('sourceDeviceRoleName', instance.sourceDeviceRoleName); - val['type'] = _$RecurrentTypeEnumMap[instance.type]!; - val['time'] = instance.time.toJson(); - writeNotNull('end', instance.end?.toIso8601String()); - val['separationCount'] = instance.separationCount; - writeNotNull('maxNumberOfSampling', instance.maxNumberOfSampling); - writeNotNull('dayOfWeek', instance.dayOfWeek); - writeNotNull('weekOfMonth', instance.weekOfMonth); - writeNotNull('dayOfMonth', instance.dayOfMonth); - val['period'] = instance.period.inMicroseconds; - return val; -} + RecurrentScheduledTrigger instance) => + { + if (instance.$type case final value?) '__type': value, + if (instance.sourceDeviceRoleName case final value?) + 'sourceDeviceRoleName': value, + 'type': _$RecurrentTypeEnumMap[instance.type]!, + 'time': instance.time.toJson(), + if (instance.end?.toIso8601String() case final value?) 'end': value, + 'separationCount': instance.separationCount, + if (instance.maxNumberOfSampling case final value?) + 'maxNumberOfSampling': value, + if (instance.dayOfWeek case final value?) 'dayOfWeek': value, + if (instance.weekOfMonth case final value?) 'weekOfMonth': value, + if (instance.dayOfMonth case final value?) 'dayOfMonth': value, + 'period': instance.period.inMicroseconds, + }; const _$RecurrentTypeEnumMap = { RecurrentType.daily: 'daily', @@ -755,20 +598,13 @@ CronScheduledTrigger _$CronScheduledTriggerFromJson( ..cronExpression = json['cronExpression'] as String; Map _$CronScheduledTriggerToJson( - CronScheduledTrigger instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - writeNotNull('sourceDeviceRoleName', instance.sourceDeviceRoleName); - val['cronExpression'] = instance.cronExpression; - return val; -} + CronScheduledTrigger instance) => + { + if (instance.$type case final value?) '__type': value, + if (instance.sourceDeviceRoleName case final value?) + 'sourceDeviceRoleName': value, + 'cronExpression': instance.cronExpression, + }; SamplingEventTrigger _$SamplingEventTriggerFromJson( Map json) => @@ -782,21 +618,15 @@ SamplingEventTrigger _$SamplingEventTriggerFromJson( ..sourceDeviceRoleName = json['sourceDeviceRoleName'] as String?; Map _$SamplingEventTriggerToJson( - SamplingEventTrigger instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - writeNotNull('sourceDeviceRoleName', instance.sourceDeviceRoleName); - val['measureType'] = instance.measureType; - writeNotNull('triggerCondition', instance.triggerCondition?.toJson()); - return val; -} + SamplingEventTrigger instance) => + { + if (instance.$type case final value?) '__type': value, + if (instance.sourceDeviceRoleName case final value?) + 'sourceDeviceRoleName': value, + 'measureType': instance.measureType, + if (instance.triggerCondition?.toJson() case final value?) + 'triggerCondition': value, + }; ConditionalSamplingEventTrigger _$ConditionalSamplingEventTriggerFromJson( Map json) => @@ -807,20 +637,13 @@ ConditionalSamplingEventTrigger _$ConditionalSamplingEventTriggerFromJson( ..sourceDeviceRoleName = json['sourceDeviceRoleName'] as String?; Map _$ConditionalSamplingEventTriggerToJson( - ConditionalSamplingEventTrigger instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - writeNotNull('sourceDeviceRoleName', instance.sourceDeviceRoleName); - val['measureType'] = instance.measureType; - return val; -} + ConditionalSamplingEventTrigger instance) => + { + if (instance.$type case final value?) '__type': value, + if (instance.sourceDeviceRoleName case final value?) + 'sourceDeviceRoleName': value, + 'measureType': instance.measureType, + }; ConditionalPeriodicTrigger _$ConditionalPeriodicTriggerFromJson( Map json) => @@ -831,20 +654,13 @@ ConditionalPeriodicTrigger _$ConditionalPeriodicTriggerFromJson( ..sourceDeviceRoleName = json['sourceDeviceRoleName'] as String?; Map _$ConditionalPeriodicTriggerToJson( - ConditionalPeriodicTrigger instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - writeNotNull('sourceDeviceRoleName', instance.sourceDeviceRoleName); - val['period'] = instance.period.inMicroseconds; - return val; -} + ConditionalPeriodicTrigger instance) => + { + if (instance.$type case final value?) '__type': value, + if (instance.sourceDeviceRoleName case final value?) + 'sourceDeviceRoleName': value, + 'period': instance.period.inMicroseconds, + }; RandomRecurrentTrigger _$RandomRecurrentTriggerFromJson( Map json) => @@ -861,25 +677,18 @@ RandomRecurrentTrigger _$RandomRecurrentTriggerFromJson( : DateTime.parse(json['lastTriggerTimestamp'] as String); Map _$RandomRecurrentTriggerToJson( - RandomRecurrentTrigger instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - writeNotNull('sourceDeviceRoleName', instance.sourceDeviceRoleName); - val['startTime'] = instance.startTime.toJson(); - val['endTime'] = instance.endTime.toJson(); - val['minNumberOfTriggers'] = instance.minNumberOfTriggers; - val['maxNumberOfTriggers'] = instance.maxNumberOfTriggers; - writeNotNull( - 'lastTriggerTimestamp', instance.lastTriggerTimestamp?.toIso8601String()); - return val; -} + RandomRecurrentTrigger instance) => + { + if (instance.$type case final value?) '__type': value, + if (instance.sourceDeviceRoleName case final value?) + 'sourceDeviceRoleName': value, + 'startTime': instance.startTime.toJson(), + 'endTime': instance.endTime.toJson(), + 'minNumberOfTriggers': instance.minNumberOfTriggers, + 'maxNumberOfTriggers': instance.maxNumberOfTriggers, + if (instance.lastTriggerTimestamp?.toIso8601String() case final value?) + 'lastTriggerTimestamp': value, + }; UserTaskTrigger _$UserTaskTriggerFromJson(Map json) => UserTaskTrigger( @@ -890,21 +699,14 @@ UserTaskTrigger _$UserTaskTriggerFromJson(Map json) => ..$type = json['__type'] as String? ..sourceDeviceRoleName = json['sourceDeviceRoleName'] as String?; -Map _$UserTaskTriggerToJson(UserTaskTrigger instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - writeNotNull('sourceDeviceRoleName', instance.sourceDeviceRoleName); - val['taskName'] = instance.taskName; - val['triggerCondition'] = _$UserTaskStateEnumMap[instance.triggerCondition]!; - return val; -} +Map _$UserTaskTriggerToJson(UserTaskTrigger instance) => + { + if (instance.$type case final value?) '__type': value, + if (instance.sourceDeviceRoleName case final value?) + 'sourceDeviceRoleName': value, + 'taskName': instance.taskName, + 'triggerCondition': _$UserTaskStateEnumMap[instance.triggerCondition]!, + }; const _$UserTaskStateEnumMap = { UserTaskState.initialized: 'initialized', @@ -918,6 +720,21 @@ const _$UserTaskStateEnumMap = { UserTaskState.undefined: 'undefined', }; +NoUserTaskTrigger _$NoUserTaskTriggerFromJson(Map json) => + NoUserTaskTrigger( + taskName: json['taskName'] as String, + ) + ..$type = json['__type'] as String? + ..sourceDeviceRoleName = json['sourceDeviceRoleName'] as String?; + +Map _$NoUserTaskTriggerToJson(NoUserTaskTrigger instance) => + { + if (instance.$type case final value?) '__type': value, + if (instance.sourceDeviceRoleName case final value?) + 'sourceDeviceRoleName': value, + 'taskName': instance.taskName, + }; + FileData _$FileDataFromJson(Map json) => FileData( filename: json['filename'] as String, upload: json['upload'] as bool? ?? true, @@ -928,22 +745,13 @@ FileData _$FileDataFromJson(Map json) => FileData( (k, e) => MapEntry(k, e as String), ); -Map _$FileDataToJson(FileData instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - writeNotNull('path', instance.path); - val['filename'] = instance.filename; - val['upload'] = instance.upload; - writeNotNull('metadata', instance.metadata); - return val; -} +Map _$FileDataToJson(FileData instance) => { + if (instance.$type case final value?) '__type': value, + if (instance.path case final value?) 'path': value, + 'filename': instance.filename, + 'upload': instance.upload, + if (instance.metadata case final value?) 'metadata': value, + }; Heartbeat _$HeartbeatFromJson(Map json) => Heartbeat( period: (json['period'] as num).toInt(), @@ -951,18 +759,9 @@ Heartbeat _$HeartbeatFromJson(Map json) => Heartbeat( deviceRoleName: json['deviceRoleName'] as String, )..$type = json['__type'] as String?; -Map _$HeartbeatToJson(Heartbeat instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - val['period'] = instance.period; - val['deviceType'] = instance.deviceType; - val['deviceRoleName'] = instance.deviceRoleName; - return val; -} +Map _$HeartbeatToJson(Heartbeat instance) => { + if (instance.$type case final value?) '__type': value, + 'period': instance.period, + 'deviceType': instance.deviceType, + 'deviceRoleName': instance.deviceRoleName, + }; diff --git a/carp_mobile_sensing/lib/domain/triggers.dart b/carp_mobile_sensing/lib/domain/triggers.dart index e9a4eeee..3af06345 100644 --- a/carp_mobile_sensing/lib/domain/triggers.dart +++ b/carp_mobile_sensing/lib/domain/triggers.dart @@ -602,3 +602,25 @@ class UserTaskTrigger extends TriggerConfiguration { @override Map toJson() => _$UserTaskTriggerToJson(this); } + +/// A trigger that triggers only if a [UserTask] with [taskName] is NOT already +/// on the task list. +/// +/// Typically used to make sure that a specific task is always on the task list. +/// Note that the [NoUserTaskTriggerExecutor] only checks the task list once pr +/// minute, so a minute may pass before this trigger triggers. +@JsonSerializable(includeIfNull: false, explicitToJson: true) +class NoUserTaskTrigger extends TriggerConfiguration { + /// The name of the task to look for, matching [TaskConfiguration.name]. + String taskName; + + /// Create a [NoUserTaskTrigger] that trigger is [taskName] is not on the task list. + NoUserTaskTrigger({required this.taskName}) : super(); + + @override + Function get fromJsonFunction => _$NoUserTaskTriggerFromJson; + factory NoUserTaskTrigger.fromJson(Map json) => + FromJsonFactory().fromJson(json); + @override + Map toJson() => _$NoUserTaskTriggerToJson(this); +} diff --git a/carp_mobile_sensing/lib/infrastructure/sampling_packages/device.g.dart b/carp_mobile_sensing/lib/infrastructure/sampling_packages/device.g.dart index a0df2ceb..65238187 100644 --- a/carp_mobile_sensing/lib/infrastructure/sampling_packages/device.g.dart +++ b/carp_mobile_sensing/lib/infrastructure/sampling_packages/device.g.dart @@ -21,101 +21,63 @@ DeviceInformation _$DeviceInformationFromJson(Map json) => ..sdk = json['sdk'] as String? ..release = json['release'] as String?; -Map _$DeviceInformationToJson(DeviceInformation instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - writeNotNull('platform', instance.platform); - writeNotNull('deviceId', instance.deviceId); - writeNotNull('hardware', instance.hardware); - writeNotNull('deviceName', instance.deviceName); - writeNotNull('deviceManufacturer', instance.deviceManufacturer); - writeNotNull('deviceModel', instance.deviceModel); - writeNotNull('operatingSystem', instance.operatingSystem); - writeNotNull('sdk', instance.sdk); - writeNotNull('release', instance.release); - val['deviceData'] = instance.deviceData; - return val; -} +Map _$DeviceInformationToJson(DeviceInformation instance) => + { + if (instance.$type case final value?) '__type': value, + if (instance.platform case final value?) 'platform': value, + if (instance.deviceId case final value?) 'deviceId': value, + if (instance.hardware case final value?) 'hardware': value, + if (instance.deviceName case final value?) 'deviceName': value, + if (instance.deviceManufacturer case final value?) + 'deviceManufacturer': value, + if (instance.deviceModel case final value?) 'deviceModel': value, + if (instance.operatingSystem case final value?) 'operatingSystem': value, + if (instance.sdk case final value?) 'sdk': value, + if (instance.release case final value?) 'release': value, + 'deviceData': instance.deviceData, + }; BatteryState _$BatteryStateFromJson(Map json) => BatteryState( (json['batteryLevel'] as num?)?.toInt(), json['batteryStatus'] as String?, )..$type = json['__type'] as String?; -Map _$BatteryStateToJson(BatteryState instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - writeNotNull('batteryLevel', instance.batteryLevel); - writeNotNull('batteryStatus', instance.batteryStatus); - return val; -} +Map _$BatteryStateToJson(BatteryState instance) => + { + if (instance.$type case final value?) '__type': value, + if (instance.batteryLevel case final value?) 'batteryLevel': value, + if (instance.batteryStatus case final value?) 'batteryStatus': value, + }; FreeMemory _$FreeMemoryFromJson(Map json) => FreeMemory( (json['freePhysicalMemory'] as num?)?.toInt(), (json['freeVirtualMemory'] as num?)?.toInt(), )..$type = json['__type'] as String?; -Map _$FreeMemoryToJson(FreeMemory instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - writeNotNull('freePhysicalMemory', instance.freePhysicalMemory); - writeNotNull('freeVirtualMemory', instance.freeVirtualMemory); - return val; -} +Map _$FreeMemoryToJson(FreeMemory instance) => + { + if (instance.$type case final value?) '__type': value, + if (instance.freePhysicalMemory case final value?) + 'freePhysicalMemory': value, + if (instance.freeVirtualMemory case final value?) + 'freeVirtualMemory': value, + }; ScreenEvent _$ScreenEventFromJson(Map json) => ScreenEvent( json['screenEvent'] as String?, )..$type = json['__type'] as String?; -Map _$ScreenEventToJson(ScreenEvent instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - writeNotNull('screenEvent', instance.screenEvent); - return val; -} +Map _$ScreenEventToJson(ScreenEvent instance) => + { + if (instance.$type case final value?) '__type': value, + if (instance.screenEvent case final value?) 'screenEvent': value, + }; Timezone _$TimezoneFromJson(Map json) => Timezone( json['timezone'] as String, )..$type = json['__type'] as String?; -Map _$TimezoneToJson(Timezone instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - val['timezone'] = instance.timezone; - return val; -} +Map _$TimezoneToJson(Timezone instance) => { + if (instance.$type case final value?) '__type': value, + 'timezone': instance.timezone, + }; diff --git a/carp_mobile_sensing/lib/infrastructure/sampling_packages/sensors.g.dart b/carp_mobile_sensing/lib/infrastructure/sampling_packages/sensors.g.dart index 7abf4263..1490039e 100644 --- a/carp_mobile_sensing/lib/infrastructure/sampling_packages/sensors.g.dart +++ b/carp_mobile_sensing/lib/infrastructure/sampling_packages/sensors.g.dart @@ -17,23 +17,16 @@ AmbientLight _$AmbientLightFromJson(Map json) => AmbientLight( ? null : Data.fromJson(json['sensorSpecificData'] as Map); -Map _$AmbientLightToJson(AmbientLight instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - writeNotNull('sensorSpecificData', instance.sensorSpecificData?.toJson()); - val['meanLux'] = instance.meanLux; - val['stdLux'] = instance.stdLux; - val['minLux'] = instance.minLux; - val['maxLux'] = instance.maxLux; - return val; -} +Map _$AmbientLightToJson(AmbientLight instance) => + { + if (instance.$type case final value?) '__type': value, + if (instance.sensorSpecificData?.toJson() case final value?) + 'sensorSpecificData': value, + 'meanLux': instance.meanLux, + 'stdLux': instance.stdLux, + 'minLux': instance.minLux, + 'maxLux': instance.maxLux, + }; AccelerationFeatures _$AccelerationFeaturesFromJson( Map json) => @@ -86,58 +79,53 @@ AccelerationFeatures _$AccelerationFeaturesFromJson( ..signalMagnitudeArea = json['signalMagnitudeArea'] as num?; Map _$AccelerationFeaturesToJson( - AccelerationFeatures instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - writeNotNull('sensorSpecificData', instance.sensorSpecificData?.toJson()); - val['count'] = instance.count; - writeNotNull('xMean', instance.xMean); - writeNotNull('yMean', instance.yMean); - writeNotNull('zMean', instance.zMean); - writeNotNull('xStd', instance.xStd); - writeNotNull('yStd', instance.yStd); - writeNotNull('zStd', instance.zStd); - writeNotNull('xAad', instance.xAad); - writeNotNull('yAad', instance.yAad); - writeNotNull('zAad', instance.zAad); - writeNotNull('xMin', instance.xMin); - writeNotNull('yMin', instance.yMin); - writeNotNull('zMin', instance.zMin); - writeNotNull('xMax', instance.xMax); - writeNotNull('yMax', instance.yMax); - writeNotNull('zMax', instance.zMax); - writeNotNull('xMaxMinDiff', instance.xMaxMinDiff); - writeNotNull('yMaxMinDiff', instance.yMaxMinDiff); - writeNotNull('zMaxMinDiff', instance.zMaxMinDiff); - writeNotNull('xMedian', instance.xMedian); - writeNotNull('yMedian', instance.yMedian); - writeNotNull('zMedian', instance.zMedian); - writeNotNull('xMad', instance.xMad); - writeNotNull('yMad', instance.yMad); - writeNotNull('zMad', instance.zMad); - writeNotNull('xIqr', instance.xIqr); - writeNotNull('yIqr', instance.yIqr); - writeNotNull('zIqr', instance.zIqr); - writeNotNull('xNegCount', instance.xNegCount); - writeNotNull('yNegCount', instance.yNegCount); - writeNotNull('zNegCount', instance.zNegCount); - writeNotNull('xPosCount', instance.xPosCount); - writeNotNull('yPosCount', instance.yPosCount); - writeNotNull('zPosCount', instance.zPosCount); - writeNotNull('xAboveMean', instance.xAboveMean); - writeNotNull('yAboveMean', instance.yAboveMean); - writeNotNull('zAboveMean', instance.zAboveMean); - writeNotNull('xEnergy', instance.xEnergy); - writeNotNull('yEnergy', instance.yEnergy); - writeNotNull('zEnergy', instance.zEnergy); - writeNotNull('avgResultAcceleration', instance.avgResultAcceleration); - writeNotNull('signalMagnitudeArea', instance.signalMagnitudeArea); - return val; -} + AccelerationFeatures instance) => + { + if (instance.$type case final value?) '__type': value, + if (instance.sensorSpecificData?.toJson() case final value?) + 'sensorSpecificData': value, + 'count': instance.count, + if (instance.xMean case final value?) 'xMean': value, + if (instance.yMean case final value?) 'yMean': value, + if (instance.zMean case final value?) 'zMean': value, + if (instance.xStd case final value?) 'xStd': value, + if (instance.yStd case final value?) 'yStd': value, + if (instance.zStd case final value?) 'zStd': value, + if (instance.xAad case final value?) 'xAad': value, + if (instance.yAad case final value?) 'yAad': value, + if (instance.zAad case final value?) 'zAad': value, + if (instance.xMin case final value?) 'xMin': value, + if (instance.yMin case final value?) 'yMin': value, + if (instance.zMin case final value?) 'zMin': value, + if (instance.xMax case final value?) 'xMax': value, + if (instance.yMax case final value?) 'yMax': value, + if (instance.zMax case final value?) 'zMax': value, + if (instance.xMaxMinDiff case final value?) 'xMaxMinDiff': value, + if (instance.yMaxMinDiff case final value?) 'yMaxMinDiff': value, + if (instance.zMaxMinDiff case final value?) 'zMaxMinDiff': value, + if (instance.xMedian case final value?) 'xMedian': value, + if (instance.yMedian case final value?) 'yMedian': value, + if (instance.zMedian case final value?) 'zMedian': value, + if (instance.xMad case final value?) 'xMad': value, + if (instance.yMad case final value?) 'yMad': value, + if (instance.zMad case final value?) 'zMad': value, + if (instance.xIqr case final value?) 'xIqr': value, + if (instance.yIqr case final value?) 'yIqr': value, + if (instance.zIqr case final value?) 'zIqr': value, + if (instance.xNegCount case final value?) 'xNegCount': value, + if (instance.yNegCount case final value?) 'yNegCount': value, + if (instance.zNegCount case final value?) 'zNegCount': value, + if (instance.xPosCount case final value?) 'xPosCount': value, + if (instance.yPosCount case final value?) 'yPosCount': value, + if (instance.zPosCount case final value?) 'zPosCount': value, + if (instance.xAboveMean case final value?) 'xAboveMean': value, + if (instance.yAboveMean case final value?) 'yAboveMean': value, + if (instance.zAboveMean case final value?) 'zAboveMean': value, + if (instance.xEnergy case final value?) 'xEnergy': value, + if (instance.yEnergy case final value?) 'yEnergy': value, + if (instance.zEnergy case final value?) 'zEnergy': value, + if (instance.avgResultAcceleration case final value?) + 'avgResultAcceleration': value, + if (instance.signalMagnitudeArea case final value?) + 'signalMagnitudeArea': value, + }; diff --git a/carp_mobile_sensing/lib/runtime.g.dart b/carp_mobile_sensing/lib/runtime.g.dart index f2a0fac4..26bbf76f 100644 --- a/carp_mobile_sensing/lib/runtime.g.dart +++ b/carp_mobile_sensing/lib/runtime.g.dart @@ -21,27 +21,21 @@ UserTaskSnapshot _$UserTaskSnapshotFromJson(Map json) => json['deviceRoleName'] as String?, )..$type = json['__type'] as String?; -Map _$UserTaskSnapshotToJson(UserTaskSnapshot instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - val['id'] = instance.id; - val['task'] = instance.task.toJson(); - val['state'] = _$UserTaskStateEnumMap[instance.state]!; - val['enqueued'] = instance.enqueued.toIso8601String(); - val['triggerTime'] = instance.triggerTime.toIso8601String(); - writeNotNull('doneTime', instance.doneTime?.toIso8601String()); - val['hasNotificationBeenCreated'] = instance.hasNotificationBeenCreated; - writeNotNull('studyDeploymentId', instance.studyDeploymentId); - writeNotNull('deviceRoleName', instance.deviceRoleName); - return val; -} +Map _$UserTaskSnapshotToJson(UserTaskSnapshot instance) => + { + if (instance.$type case final value?) '__type': value, + 'id': instance.id, + 'task': instance.task.toJson(), + 'state': _$UserTaskStateEnumMap[instance.state]!, + 'enqueued': instance.enqueued.toIso8601String(), + 'triggerTime': instance.triggerTime.toIso8601String(), + if (instance.doneTime?.toIso8601String() case final value?) + 'doneTime': value, + 'hasNotificationBeenCreated': instance.hasNotificationBeenCreated, + if (instance.studyDeploymentId case final value?) + 'studyDeploymentId': value, + if (instance.deviceRoleName case final value?) 'deviceRoleName': value, + }; const _$UserTaskStateEnumMap = { UserTaskState.initialized: 'initialized', diff --git a/carp_mobile_sensing/lib/runtime/executors/executor_factory.dart b/carp_mobile_sensing/lib/runtime/executors/executor_factory.dart index 78541214..d52d16ff 100644 --- a/carp_mobile_sensing/lib/runtime/executors/executor_factory.dart +++ b/carp_mobile_sensing/lib/runtime/executors/executor_factory.dart @@ -137,7 +137,8 @@ class SmartphoneTriggerFactory implements TriggerFactory { UserTaskTrigger( taskName: 'ignored', triggerCondition: UserTaskState.done, - ) + ), + NoUserTaskTrigger(taskName: 'ignored') }; @override @@ -180,6 +181,7 @@ class SmartphoneTriggerFactory implements TriggerFactory { } if (trigger is PassiveTrigger) return PassiveTriggerExecutor(); if (trigger is UserTaskTrigger) return UserTaskTriggerExecutor(); + if (trigger is NoUserTaskTrigger) return NoUserTaskTriggerExecutor(); warning( "Unknown trigger used - cannot find a TriggerExecutor for the trigger of type '${trigger.runtimeType}'. " diff --git a/carp_mobile_sensing/lib/runtime/executors/task_control_executors.dart b/carp_mobile_sensing/lib/runtime/executors/task_control_executors.dart index 46b18e64..b4ff924d 100644 --- a/carp_mobile_sensing/lib/runtime/executors/task_control_executors.dart +++ b/carp_mobile_sensing/lib/runtime/executors/task_control_executors.dart @@ -82,7 +82,11 @@ class TaskControlExecutor extends AbstractExecutor { @override Future onStart() async { - if (triggerExecutor?.state != ExecutorState.started && + if (triggerExecutor == null) { + warning( + '$runtimeType - no TriggerExecutor defined - cannot start this task control executor.'); + return false; + } else if (triggerExecutor?.state != ExecutorState.started && !triggerExecutor!.isStarting) { triggerExecutor?.start(); } diff --git a/carp_mobile_sensing/lib/runtime/executors/trigger_executors.dart b/carp_mobile_sensing/lib/runtime/executors/trigger_executors.dart index 489fe9ef..25746b65 100644 --- a/carp_mobile_sensing/lib/runtime/executors/trigger_executors.dart +++ b/carp_mobile_sensing/lib/runtime/executors/trigger_executors.dart @@ -504,3 +504,30 @@ class UserTaskTriggerExecutor extends TriggerExecutor { return super.onStop(); } } + +/// Executes an [NoUserTaskTrigger]. +/// Runs once pr minute. +class NoUserTaskTriggerExecutor extends TriggerExecutor { + Timer? _timer; + + @override + Future onStart() async { + _timer = Timer.periodic(Duration(minutes: 1), (_) { + print(AppTaskController().userTaskQueue); + if (!AppTaskController() + .userTaskQueue + .where((task) => task.state == UserTaskState.enqueued) + .any((task) => task.name == configuration!.taskName)) { + onTrigger(); + } + }); + + return true; + } + + @override + Future onStop() async { + _timer?.cancel(); + return super.onStop(); + } +} diff --git a/carp_mobile_sensing/lib/runtime/user_tasks.dart b/carp_mobile_sensing/lib/runtime/user_tasks.dart index 1aad8a86..dcbc8e13 100644 --- a/carp_mobile_sensing/lib/runtime/user_tasks.dart +++ b/carp_mobile_sensing/lib/runtime/user_tasks.dart @@ -197,7 +197,7 @@ abstract class UserTask { @override String toString() => - '$runtimeType - id: $id, type: $type, title: $title, state: $state, triggerTime: $triggerTime'; + '$runtimeType - id: $id, type: $type, name: $name, title: $title, state: $state, triggerTime: $triggerTime'; } /// The states of a [UserTask]. From 2130aadf831edd567fbdffd115189624a36a5eb3 Mon Sep 17 00:00:00 2001 From: bardram Date: Wed, 4 Dec 2024 15:46:54 +0100 Subject: [PATCH 2/4] fix of #452 --- carp_core/example/lib/example.dart | 2 +- carp_core/lib/common/carp_core_common.g.dart | 1135 ++++++----------- carp_core/lib/data/carp_core_data.g.dart | 129 +- .../deployment/carp_core_deployment.g.dart | 448 +++---- .../deployment/domain/study_deployment.dart | 13 +- .../lib/protocols/carp_core_protocols.g.dart | 239 ++-- carp_core/test/carp_core_kotlin_rpc_test.dart | 3 +- carp_mobile_sensing/CHANGELOG.md | 4 + 8 files changed, 669 insertions(+), 1304 deletions(-) diff --git a/carp_core/example/lib/example.dart b/carp_core/example/lib/example.dart index 1463450c..cad11d30 100644 --- a/carp_core/example/lib/example.dart +++ b/carp_core/example/lib/example.dart @@ -110,7 +110,7 @@ void carpCoreDeploymentExample() async { // Now that all devices have been registered and deployed, the deployment is ready. status = await deploymentService?.getStudyDeploymentStatus(studyDeploymentId); - var isReady = status?.status == StudyDeploymentStatusTypes.DeploymentReady; + var isReady = status?.status == StudyDeploymentStatusTypes.Running; } /// Example of how to use the **data** sub-system domain models. diff --git a/carp_core/lib/common/carp_core_common.g.dart b/carp_core/lib/common/carp_core_common.g.dart index 73509a37..be53b295 100644 --- a/carp_core/lib/common/carp_core_common.g.dart +++ b/carp_core/lib/common/carp_core_common.g.dart @@ -20,18 +20,10 @@ Map _$AccountToJson(Account instance) => { AccountIdentity _$AccountIdentityFromJson(Map json) => AccountIdentity()..$type = json['__type'] as String?; -Map _$AccountIdentityToJson(AccountIdentity instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - return val; -} +Map _$AccountIdentityToJson(AccountIdentity instance) => + { + if (instance.$type case final value?) '__type': value, + }; EmailAccountIdentity _$EmailAccountIdentityFromJson( Map json) => @@ -40,19 +32,11 @@ EmailAccountIdentity _$EmailAccountIdentityFromJson( )..$type = json['__type'] as String?; Map _$EmailAccountIdentityToJson( - EmailAccountIdentity instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - val['emailAddress'] = instance.emailAddress; - return val; -} + EmailAccountIdentity instance) => + { + if (instance.$type case final value?) '__type': value, + 'emailAddress': instance.emailAddress, + }; UsernameAccountIdentity _$UsernameAccountIdentityFromJson( Map json) => @@ -61,19 +45,11 @@ UsernameAccountIdentity _$UsernameAccountIdentityFromJson( )..$type = json['__type'] as String?; Map _$UsernameAccountIdentityToJson( - UsernameAccountIdentity instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - val['username'] = instance.username; - return val; -} + UsernameAccountIdentity instance) => + { + if (instance.$type case final value?) '__type': value, + 'username': instance.username, + }; ParticipantRole _$ParticipantRoleFromJson(Map json) => ParticipantRole( @@ -100,19 +76,11 @@ ExpectedParticipantData _$ExpectedParticipantDataFromJson( ); Map _$ExpectedParticipantDataToJson( - ExpectedParticipantData instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('attribute', instance.attribute?.toJson()); - val['assignedTo'] = instance.assignedTo.toJson(); - return val; -} + ExpectedParticipantData instance) => + { + if (instance.attribute?.toJson() case final value?) 'attribute': value, + 'assignedTo': instance.assignedTo.toJson(), + }; ParticipantAttribute _$ParticipantAttributeFromJson( Map json) => @@ -121,19 +89,11 @@ ParticipantAttribute _$ParticipantAttributeFromJson( )..$type = json['__type'] as String?; Map _$ParticipantAttributeToJson( - ParticipantAttribute instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - val['inputDataType'] = instance.inputDataType; - return val; -} + ParticipantAttribute instance) => + { + if (instance.$type case final value?) '__type': value, + 'inputDataType': instance.inputDataType, + }; AssignedTo _$AssignedToFromJson(Map json) => AssignedTo( roleNames: (json['roleNames'] as List?) @@ -141,19 +101,11 @@ AssignedTo _$AssignedToFromJson(Map json) => AssignedTo( .toSet(), )..$type = json['__type'] as String?; -Map _$AssignedToToJson(AssignedTo instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - writeNotNull('roleNames', instance.roleNames?.toList()); - return val; -} +Map _$AssignedToToJson(AssignedTo instance) => + { + if (instance.$type case final value?) '__type': value, + if (instance.roleNames?.toList() case final value?) 'roleNames': value, + }; Measure _$MeasureFromJson(Map json) => Measure( type: json['type'] as String, @@ -165,21 +117,12 @@ Measure _$MeasureFromJson(Map json) => Measure( : SamplingConfiguration.fromJson( json['overrideSamplingConfiguration'] as Map); -Map _$MeasureToJson(Measure instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - val['type'] = instance.type; - writeNotNull('overrideSamplingConfiguration', - instance.overrideSamplingConfiguration?.toJson()); - return val; -} +Map _$MeasureToJson(Measure instance) => { + if (instance.$type case final value?) '__type': value, + 'type': instance.type, + if (instance.overrideSamplingConfiguration?.toJson() case final value?) + 'overrideSamplingConfiguration': value, + }; TaskConfiguration _$TaskConfigurationFromJson(Map json) => TaskConfiguration( @@ -190,21 +133,14 @@ TaskConfiguration _$TaskConfigurationFromJson(Map json) => .toList(), )..$type = json['__type'] as String?; -Map _$TaskConfigurationToJson(TaskConfiguration instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - val['name'] = instance.name; - writeNotNull('measures', instance.measures?.map((e) => e.toJson()).toList()); - writeNotNull('description', instance.description); - return val; -} +Map _$TaskConfigurationToJson(TaskConfiguration instance) => + { + if (instance.$type case final value?) '__type': value, + 'name': instance.name, + if (instance.measures?.map((e) => e.toJson()).toList() case final value?) + 'measures': value, + if (instance.description case final value?) 'description': value, + }; BackgroundTask _$BackgroundTaskFromJson(Map json) => BackgroundTask( @@ -216,22 +152,16 @@ BackgroundTask _$BackgroundTaskFromJson(Map json) => duration: _$IsoDurationFromJson(json['duration'] as String?), )..$type = json['__type'] as String?; -Map _$BackgroundTaskToJson(BackgroundTask instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - val['name'] = instance.name; - writeNotNull('measures', instance.measures?.map((e) => e.toJson()).toList()); - writeNotNull('description', instance.description); - writeNotNull('duration', _$IsoDurationToJson(instance.duration)); - return val; -} +Map _$BackgroundTaskToJson(BackgroundTask instance) => + { + if (instance.$type case final value?) '__type': value, + 'name': instance.name, + if (instance.measures?.map((e) => e.toJson()).toList() case final value?) + 'measures': value, + if (instance.description case final value?) 'description': value, + if (_$IsoDurationToJson(instance.duration) case final value?) + 'duration': value, + }; CustomProtocolTask _$CustomProtocolTaskFromJson(Map json) => CustomProtocolTask( @@ -244,22 +174,15 @@ CustomProtocolTask _$CustomProtocolTaskFromJson(Map json) => ?.map((e) => Measure.fromJson(e as Map)) .toList(); -Map _$CustomProtocolTaskToJson(CustomProtocolTask instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - val['name'] = instance.name; - writeNotNull('measures', instance.measures?.map((e) => e.toJson()).toList()); - writeNotNull('description', instance.description); - val['studyProtocol'] = instance.studyProtocol; - return val; -} +Map _$CustomProtocolTaskToJson(CustomProtocolTask instance) => + { + if (instance.$type case final value?) '__type': value, + 'name': instance.name, + if (instance.measures?.map((e) => e.toJson()).toList() case final value?) + 'measures': value, + if (instance.description case final value?) 'description': value, + 'studyProtocol': instance.studyProtocol, + }; WebTask _$WebTaskFromJson(Map json) => WebTask( name: json['name'] as String?, @@ -270,22 +193,14 @@ WebTask _$WebTaskFromJson(Map json) => WebTask( url: json['url'] as String, )..$type = json['__type'] as String?; -Map _$WebTaskToJson(WebTask instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - val['name'] = instance.name; - writeNotNull('measures', instance.measures?.map((e) => e.toJson()).toList()); - writeNotNull('description', instance.description); - val['url'] = instance.url; - return val; -} +Map _$WebTaskToJson(WebTask instance) => { + if (instance.$type case final value?) '__type': value, + 'name': instance.name, + if (instance.measures?.map((e) => e.toJson()).toList() case final value?) + 'measures': value, + if (instance.description case final value?) 'description': value, + 'url': instance.url, + }; TaskControl _$TaskControlFromJson(Map json) => TaskControl( triggerId: (json['triggerId'] as num).toInt(), @@ -298,24 +213,16 @@ TaskControl _$TaskControlFromJson(Map json) => TaskControl( ? null : DateTime.parse(json['hasBeenScheduledUntil'] as String); -Map _$TaskControlToJson(TaskControl instance) { - final val = { - 'triggerId': instance.triggerId, - 'taskName': instance.taskName, - }; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('destinationDeviceRoleName', instance.destinationDeviceRoleName); - val['control'] = _$ControlEnumMap[instance.control]!; - writeNotNull('hasBeenScheduledUntil', - instance.hasBeenScheduledUntil?.toIso8601String()); - return val; -} +Map _$TaskControlToJson(TaskControl instance) => + { + 'triggerId': instance.triggerId, + 'taskName': instance.taskName, + if (instance.destinationDeviceRoleName case final value?) + 'destinationDeviceRoleName': value, + 'control': _$ControlEnumMap[instance.control]!, + if (instance.hasBeenScheduledUntil?.toIso8601String() case final value?) + 'hasBeenScheduledUntil': value, + }; const _$ControlEnumMap = { Control.Start: 'Start', @@ -337,24 +244,16 @@ DeviceConfiguration _$DeviceConfigurationFromJson< Map _$DeviceConfigurationToJson( - DeviceConfiguration instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - val['roleName'] = instance.roleName; - writeNotNull('isOptional', instance.isOptional); - writeNotNull( - 'defaultSamplingConfiguration', - instance.defaultSamplingConfiguration - ?.map((k, e) => MapEntry(k, e.toJson()))); - return val; -} + DeviceConfiguration instance) => + { + if (instance.$type case final value?) '__type': value, + 'roleName': instance.roleName, + if (instance.isOptional case final value?) 'isOptional': value, + if (instance.defaultSamplingConfiguration + ?.map((k, e) => MapEntry(k, e.toJson())) + case final value?) + 'defaultSamplingConfiguration': value, + }; DefaultDeviceConfiguration _$DefaultDeviceConfigurationFromJson( Map json) => @@ -370,24 +269,16 @@ DefaultDeviceConfiguration _$DefaultDeviceConfigurationFromJson( ); Map _$DefaultDeviceConfigurationToJson( - DefaultDeviceConfiguration instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - val['roleName'] = instance.roleName; - writeNotNull('isOptional', instance.isOptional); - writeNotNull( - 'defaultSamplingConfiguration', - instance.defaultSamplingConfiguration - ?.map((k, e) => MapEntry(k, e.toJson()))); - return val; -} + DefaultDeviceConfiguration instance) => + { + if (instance.$type case final value?) '__type': value, + 'roleName': instance.roleName, + if (instance.isOptional case final value?) 'isOptional': value, + if (instance.defaultSamplingConfiguration + ?.map((k, e) => MapEntry(k, e.toJson())) + case final value?) + 'defaultSamplingConfiguration': value, + }; PrimaryDeviceConfiguration _$PrimaryDeviceConfigurationFromJson< TRegistration extends DeviceRegistration>(Map json) => @@ -404,26 +295,18 @@ PrimaryDeviceConfiguration _$PrimaryDeviceConfigurationFromJson< ..isPrimaryDevice = json['isPrimaryDevice'] as bool; Map _$PrimaryDeviceConfigurationToJson< - TRegistration extends DeviceRegistration>( - PrimaryDeviceConfiguration instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - val['roleName'] = instance.roleName; - writeNotNull('isOptional', instance.isOptional); - writeNotNull( - 'defaultSamplingConfiguration', - instance.defaultSamplingConfiguration - ?.map((k, e) => MapEntry(k, e.toJson()))); - val['isPrimaryDevice'] = instance.isPrimaryDevice; - return val; -} + TRegistration extends DeviceRegistration>( + PrimaryDeviceConfiguration instance) => + { + if (instance.$type case final value?) '__type': value, + 'roleName': instance.roleName, + if (instance.isOptional case final value?) 'isOptional': value, + if (instance.defaultSamplingConfiguration + ?.map((k, e) => MapEntry(k, e.toJson())) + case final value?) + 'defaultSamplingConfiguration': value, + 'isPrimaryDevice': instance.isPrimaryDevice, + }; CustomProtocolDevice _$CustomProtocolDeviceFromJson( Map json) => @@ -441,25 +324,17 @@ CustomProtocolDevice _$CustomProtocolDeviceFromJson( ..isPrimaryDevice = json['isPrimaryDevice'] as bool; Map _$CustomProtocolDeviceToJson( - CustomProtocolDevice instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - val['roleName'] = instance.roleName; - writeNotNull('isOptional', instance.isOptional); - writeNotNull( - 'defaultSamplingConfiguration', - instance.defaultSamplingConfiguration - ?.map((k, e) => MapEntry(k, e.toJson()))); - val['isPrimaryDevice'] = instance.isPrimaryDevice; - return val; -} + CustomProtocolDevice instance) => + { + if (instance.$type case final value?) '__type': value, + 'roleName': instance.roleName, + if (instance.isOptional case final value?) 'isOptional': value, + if (instance.defaultSamplingConfiguration + ?.map((k, e) => MapEntry(k, e.toJson())) + case final value?) + 'defaultSamplingConfiguration': value, + 'isPrimaryDevice': instance.isPrimaryDevice, + }; DeviceRegistration _$DeviceRegistrationFromJson(Map json) => DeviceRegistration( @@ -530,25 +405,17 @@ Smartphone _$SmartphoneFromJson(Map json) => Smartphone( ) ..isPrimaryDevice = json['isPrimaryDevice'] as bool; -Map _$SmartphoneToJson(Smartphone instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - val['roleName'] = instance.roleName; - writeNotNull('isOptional', instance.isOptional); - writeNotNull( - 'defaultSamplingConfiguration', - instance.defaultSamplingConfiguration - ?.map((k, e) => MapEntry(k, e.toJson()))); - val['isPrimaryDevice'] = instance.isPrimaryDevice; - return val; -} +Map _$SmartphoneToJson(Smartphone instance) => + { + if (instance.$type case final value?) '__type': value, + 'roleName': instance.roleName, + if (instance.isOptional case final value?) 'isOptional': value, + if (instance.defaultSamplingConfiguration + ?.map((k, e) => MapEntry(k, e.toJson())) + case final value?) + 'defaultSamplingConfiguration': value, + 'isPrimaryDevice': instance.isPrimaryDevice, + }; SmartphoneDeviceRegistration _$SmartphoneDeviceRegistrationFromJson( Map json) => @@ -599,25 +466,17 @@ PersonalComputer _$PersonalComputerFromJson(Map json) => ) ..isPrimaryDevice = json['isPrimaryDevice'] as bool; -Map _$PersonalComputerToJson(PersonalComputer instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - val['roleName'] = instance.roleName; - writeNotNull('isOptional', instance.isOptional); - writeNotNull( - 'defaultSamplingConfiguration', - instance.defaultSamplingConfiguration - ?.map((k, e) => MapEntry(k, e.toJson()))); - val['isPrimaryDevice'] = instance.isPrimaryDevice; - return val; -} +Map _$PersonalComputerToJson(PersonalComputer instance) => + { + if (instance.$type case final value?) '__type': value, + 'roleName': instance.roleName, + if (instance.isOptional case final value?) 'isOptional': value, + if (instance.defaultSamplingConfiguration + ?.map((k, e) => MapEntry(k, e.toJson())) + case final value?) + 'defaultSamplingConfiguration': value, + 'isPrimaryDevice': instance.isPrimaryDevice, + }; PersonalComputerRegistration _$PersonalComputerRegistrationFromJson( Map json) => @@ -662,25 +521,17 @@ WebBrowser _$WebBrowserFromJson(Map json) => WebBrowser( ) ..isPrimaryDevice = json['isPrimaryDevice'] as bool; -Map _$WebBrowserToJson(WebBrowser instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - val['roleName'] = instance.roleName; - writeNotNull('isOptional', instance.isOptional); - writeNotNull( - 'defaultSamplingConfiguration', - instance.defaultSamplingConfiguration - ?.map((k, e) => MapEntry(k, e.toJson()))); - val['isPrimaryDevice'] = instance.isPrimaryDevice; - return val; -} +Map _$WebBrowserToJson(WebBrowser instance) => + { + if (instance.$type case final value?) '__type': value, + 'roleName': instance.roleName, + if (instance.isOptional case final value?) 'isOptional': value, + if (instance.defaultSamplingConfiguration + ?.map((k, e) => MapEntry(k, e.toJson())) + case final value?) + 'defaultSamplingConfiguration': value, + 'isPrimaryDevice': instance.isPrimaryDevice, + }; WebBrowserRegistration _$WebBrowserRegistrationFromJson( Map json) => @@ -724,24 +575,15 @@ AltBeacon _$AltBeaconFromJson(Map json) => AltBeacon( k, SamplingConfiguration.fromJson(e as Map)), ); -Map _$AltBeaconToJson(AltBeacon instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - val['roleName'] = instance.roleName; - writeNotNull('isOptional', instance.isOptional); - writeNotNull( - 'defaultSamplingConfiguration', - instance.defaultSamplingConfiguration - ?.map((k, e) => MapEntry(k, e.toJson()))); - return val; -} +Map _$AltBeaconToJson(AltBeacon instance) => { + if (instance.$type case final value?) '__type': value, + 'roleName': instance.roleName, + if (instance.isOptional case final value?) 'isOptional': value, + if (instance.defaultSamplingConfiguration + ?.map((k, e) => MapEntry(k, e.toJson())) + case final value?) + 'defaultSamplingConfiguration': value, + }; AltBeaconDeviceRegistration _$AltBeaconDeviceRegistrationFromJson( Map json) => @@ -784,24 +626,16 @@ BLEHeartRateDevice _$BLEHeartRateDeviceFromJson(Map json) => k, SamplingConfiguration.fromJson(e as Map)), ); -Map _$BLEHeartRateDeviceToJson(BLEHeartRateDevice instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - val['roleName'] = instance.roleName; - writeNotNull('isOptional', instance.isOptional); - writeNotNull( - 'defaultSamplingConfiguration', - instance.defaultSamplingConfiguration - ?.map((k, e) => MapEntry(k, e.toJson()))); - return val; -} +Map _$BLEHeartRateDeviceToJson(BLEHeartRateDevice instance) => + { + if (instance.$type case final value?) '__type': value, + 'roleName': instance.roleName, + if (instance.isOptional case final value?) 'isOptional': value, + if (instance.defaultSamplingConfiguration + ?.map((k, e) => MapEntry(k, e.toJson())) + case final value?) + 'defaultSamplingConfiguration': value, + }; TriggerConfiguration _$TriggerConfigurationFromJson( Map json) => @@ -810,19 +644,12 @@ TriggerConfiguration _$TriggerConfigurationFromJson( )..$type = json['__type'] as String?; Map _$TriggerConfigurationToJson( - TriggerConfiguration instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - writeNotNull('sourceDeviceRoleName', instance.sourceDeviceRoleName); - return val; -} + TriggerConfiguration instance) => + { + if (instance.$type case final value?) '__type': value, + if (instance.sourceDeviceRoleName case final value?) + 'sourceDeviceRoleName': value, + }; ElapsedTimeTrigger _$ElapsedTimeTriggerFromJson(Map json) => ElapsedTimeTrigger( @@ -830,20 +657,14 @@ ElapsedTimeTrigger _$ElapsedTimeTriggerFromJson(Map json) => elapsedTime: _$IsoDurationFromJson(json['elapsedTime'] as String?), )..$type = json['__type'] as String?; -Map _$ElapsedTimeTriggerToJson(ElapsedTimeTrigger instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - writeNotNull('sourceDeviceRoleName', instance.sourceDeviceRoleName); - writeNotNull('elapsedTime', _$IsoDurationToJson(instance.elapsedTime)); - return val; -} +Map _$ElapsedTimeTriggerToJson(ElapsedTimeTrigger instance) => + { + if (instance.$type case final value?) '__type': value, + if (instance.sourceDeviceRoleName case final value?) + 'sourceDeviceRoleName': value, + if (_$IsoDurationToJson(instance.elapsedTime) case final value?) + 'elapsedTime': value, + }; ManualTrigger _$ManualTriggerFromJson(Map json) => ManualTrigger( @@ -852,21 +673,14 @@ ManualTrigger _$ManualTriggerFromJson(Map json) => description: json['description'] as String?, )..$type = json['__type'] as String?; -Map _$ManualTriggerToJson(ManualTrigger instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - writeNotNull('sourceDeviceRoleName', instance.sourceDeviceRoleName); - writeNotNull('label', instance.label); - writeNotNull('description', instance.description); - return val; -} +Map _$ManualTriggerToJson(ManualTrigger instance) => + { + if (instance.$type case final value?) '__type': value, + if (instance.sourceDeviceRoleName case final value?) + 'sourceDeviceRoleName': value, + if (instance.label case final value?) 'label': value, + if (instance.description case final value?) 'description': value, + }; ScheduledTrigger _$ScheduledTriggerFromJson(Map json) => ScheduledTrigger( @@ -876,21 +690,14 @@ ScheduledTrigger _$ScheduledTriggerFromJson(Map json) => json['recurrenceRule'] as Map), )..$type = json['__type'] as String?; -Map _$ScheduledTriggerToJson(ScheduledTrigger instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - writeNotNull('sourceDeviceRoleName', instance.sourceDeviceRoleName); - val['time'] = instance.time.toJson(); - val['recurrenceRule'] = instance.recurrenceRule.toJson(); - return val; -} +Map _$ScheduledTriggerToJson(ScheduledTrigger instance) => + { + if (instance.$type case final value?) '__type': value, + if (instance.sourceDeviceRoleName case final value?) + 'sourceDeviceRoleName': value, + 'time': instance.time.toJson(), + 'recurrenceRule': instance.recurrenceRule.toJson(), + }; TimeOfDay _$TimeOfDayFromJson(Map json) => TimeOfDay( hour: (json['hour'] as num?)?.toInt() ?? 0, @@ -938,21 +745,12 @@ End _$EndFromJson(Map json) => End( count: (json['count'] as num?)?.toInt(), ); -Map _$EndToJson(End instance) { - final val = { - 'type': _$EndTypeEnumMap[instance.type]!, - }; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('elapsedTime', instance.elapsedTime?.inMicroseconds); - writeNotNull('count', instance.count); - return val; -} +Map _$EndToJson(End instance) => { + 'type': _$EndTypeEnumMap[instance.type]!, + if (instance.elapsedTime?.inMicroseconds case final value?) + 'elapsedTime': value, + if (instance.count case final value?) 'count': value, + }; const _$EndTypeEnumMap = { EndType.UNTIL: 'UNTIL', @@ -965,36 +763,20 @@ SamplingConfiguration _$SamplingConfigurationFromJson( SamplingConfiguration()..$type = json['__type'] as String?; Map _$SamplingConfigurationToJson( - SamplingConfiguration instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - return val; -} + SamplingConfiguration instance) => + { + if (instance.$type case final value?) '__type': value, + }; NoOptionsSamplingConfiguration _$NoOptionsSamplingConfigurationFromJson( Map json) => NoOptionsSamplingConfiguration()..$type = json['__type'] as String?; Map _$NoOptionsSamplingConfigurationToJson( - NoOptionsSamplingConfiguration instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - return val; -} + NoOptionsSamplingConfiguration instance) => + { + if (instance.$type case final value?) '__type': value, + }; BatteryAwareSamplingConfiguration _$BatteryAwareSamplingConfigurationFromJson( Map json) => @@ -1009,21 +791,13 @@ BatteryAwareSamplingConfiguration _$BatteryAwareSamplingConfigurationFromJson( )..$type = json['__type'] as String?; Map _$BatteryAwareSamplingConfigurationToJson( - BatteryAwareSamplingConfiguration instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - val['normal'] = instance.normal.toJson(); - val['low'] = instance.low.toJson(); - writeNotNull('critical', instance.critical?.toJson()); - return val; -} + BatteryAwareSamplingConfiguration instance) => + { + if (instance.$type case final value?) '__type': value, + 'normal': instance.normal.toJson(), + 'low': instance.low.toJson(), + if (instance.critical?.toJson() case final value?) 'critical': value, + }; GranularitySamplingConfiguration _$GranularitySamplingConfigurationFromJson( Map json) => @@ -1057,18 +831,9 @@ Map _$DataTypeToJson(DataType instance) => { Data _$DataFromJson(Map json) => Data()..$type = json['__type'] as String?; -Map _$DataToJson(Data instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - return val; -} +Map _$DataToJson(Data instance) => { + if (instance.$type case final value?) '__type': value, + }; Acceleration _$AccelerationFromJson(Map json) => Acceleration( x: (json['x'] as num?)?.toDouble() ?? 0, @@ -1080,22 +845,15 @@ Acceleration _$AccelerationFromJson(Map json) => Acceleration( ? null : Data.fromJson(json['sensorSpecificData'] as Map); -Map _$AccelerationToJson(Acceleration instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - writeNotNull('sensorSpecificData', instance.sensorSpecificData?.toJson()); - val['x'] = instance.x; - val['y'] = instance.y; - val['z'] = instance.z; - return val; -} +Map _$AccelerationToJson(Acceleration instance) => + { + if (instance.$type case final value?) '__type': value, + if (instance.sensorSpecificData?.toJson() case final value?) + 'sensorSpecificData': value, + 'x': instance.x, + 'y': instance.y, + 'z': instance.z, + }; Rotation _$RotationFromJson(Map json) => Rotation( x: (json['x'] as num?)?.toDouble() ?? 0, @@ -1107,22 +865,14 @@ Rotation _$RotationFromJson(Map json) => Rotation( ? null : Data.fromJson(json['sensorSpecificData'] as Map); -Map _$RotationToJson(Rotation instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - writeNotNull('sensorSpecificData', instance.sensorSpecificData?.toJson()); - val['x'] = instance.x; - val['y'] = instance.y; - val['z'] = instance.z; - return val; -} +Map _$RotationToJson(Rotation instance) => { + if (instance.$type case final value?) '__type': value, + if (instance.sensorSpecificData?.toJson() case final value?) + 'sensorSpecificData': value, + 'x': instance.x, + 'y': instance.y, + 'z': instance.z, + }; MagneticField _$MagneticFieldFromJson(Map json) => MagneticField( @@ -1135,22 +885,15 @@ MagneticField _$MagneticFieldFromJson(Map json) => ? null : Data.fromJson(json['sensorSpecificData'] as Map); -Map _$MagneticFieldToJson(MagneticField instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - writeNotNull('sensorSpecificData', instance.sensorSpecificData?.toJson()); - val['x'] = instance.x; - val['y'] = instance.y; - val['z'] = instance.z; - return val; -} +Map _$MagneticFieldToJson(MagneticField instance) => + { + if (instance.$type case final value?) '__type': value, + if (instance.sensorSpecificData?.toJson() case final value?) + 'sensorSpecificData': value, + 'x': instance.x, + 'y': instance.y, + 'z': instance.z, + }; Geolocation _$GeolocationFromJson(Map json) => Geolocation( latitude: (json['latitude'] as num?)?.toDouble() ?? 0, @@ -1161,21 +904,14 @@ Geolocation _$GeolocationFromJson(Map json) => Geolocation( ? null : Data.fromJson(json['sensorSpecificData'] as Map); -Map _$GeolocationToJson(Geolocation instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - writeNotNull('sensorSpecificData', instance.sensorSpecificData?.toJson()); - val['latitude'] = instance.latitude; - val['longitude'] = instance.longitude; - return val; -} +Map _$GeolocationToJson(Geolocation instance) => + { + if (instance.$type case final value?) '__type': value, + if (instance.sensorSpecificData?.toJson() case final value?) + 'sensorSpecificData': value, + 'latitude': instance.latitude, + 'longitude': instance.longitude, + }; SignalStrength _$SignalStrengthFromJson(Map json) => SignalStrength( @@ -1186,20 +922,13 @@ SignalStrength _$SignalStrengthFromJson(Map json) => ? null : Data.fromJson(json['sensorSpecificData'] as Map); -Map _$SignalStrengthToJson(SignalStrength instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - writeNotNull('sensorSpecificData', instance.sensorSpecificData?.toJson()); - val['rssi'] = instance.rssi; - return val; -} +Map _$SignalStrengthToJson(SignalStrength instance) => + { + if (instance.$type case final value?) '__type': value, + if (instance.sensorSpecificData?.toJson() case final value?) + 'sensorSpecificData': value, + 'rssi': instance.rssi, + }; StepCount _$StepCountFromJson(Map json) => StepCount( steps: (json['steps'] as num?)?.toInt() ?? 0, @@ -1209,20 +938,12 @@ StepCount _$StepCountFromJson(Map json) => StepCount( ? null : Data.fromJson(json['sensorSpecificData'] as Map); -Map _$StepCountToJson(StepCount instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - writeNotNull('sensorSpecificData', instance.sensorSpecificData?.toJson()); - val['steps'] = instance.steps; - return val; -} +Map _$StepCountToJson(StepCount instance) => { + if (instance.$type case final value?) '__type': value, + if (instance.sensorSpecificData?.toJson() case final value?) + 'sensorSpecificData': value, + 'steps': instance.steps, + }; HeartRate _$HeartRateFromJson(Map json) => HeartRate( bpm: (json['bpm'] as num?)?.toInt() ?? 0, @@ -1232,20 +953,12 @@ HeartRate _$HeartRateFromJson(Map json) => HeartRate( ? null : Data.fromJson(json['sensorSpecificData'] as Map); -Map _$HeartRateToJson(HeartRate instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - writeNotNull('sensorSpecificData', instance.sensorSpecificData?.toJson()); - val['bpm'] = instance.bpm; - return val; -} +Map _$HeartRateToJson(HeartRate instance) => { + if (instance.$type case final value?) '__type': value, + if (instance.sensorSpecificData?.toJson() case final value?) + 'sensorSpecificData': value, + 'bpm': instance.bpm, + }; ECG _$ECGFromJson(Map json) => ECG( milliVolt: (json['milliVolt'] as num?)?.toDouble() ?? 0, @@ -1255,20 +968,12 @@ ECG _$ECGFromJson(Map json) => ECG( ? null : Data.fromJson(json['sensorSpecificData'] as Map); -Map _$ECGToJson(ECG instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - writeNotNull('sensorSpecificData', instance.sensorSpecificData?.toJson()); - val['milliVolt'] = instance.milliVolt; - return val; -} +Map _$ECGToJson(ECG instance) => { + if (instance.$type case final value?) '__type': value, + if (instance.sensorSpecificData?.toJson() case final value?) + 'sensorSpecificData': value, + 'milliVolt': instance.milliVolt, + }; EDA _$EDAFromJson(Map json) => EDA( microSiemens: (json['microSiemens'] as num?)?.toDouble() ?? 0, @@ -1278,20 +983,12 @@ EDA _$EDAFromJson(Map json) => EDA( ? null : Data.fromJson(json['sensorSpecificData'] as Map); -Map _$EDAToJson(EDA instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - writeNotNull('sensorSpecificData', instance.sensorSpecificData?.toJson()); - val['microSiemens'] = instance.microSiemens; - return val; -} +Map _$EDAToJson(EDA instance) => { + if (instance.$type case final value?) '__type': value, + if (instance.sensorSpecificData?.toJson() case final value?) + 'sensorSpecificData': value, + 'microSiemens': instance.microSiemens, + }; CompletedTask _$CompletedTaskFromJson(Map json) => CompletedTask( @@ -1301,20 +998,12 @@ CompletedTask _$CompletedTaskFromJson(Map json) => : Data.fromJson(json['taskData'] as Map), )..$type = json['__type'] as String?; -Map _$CompletedTaskToJson(CompletedTask instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - val['taskName'] = instance.taskName; - writeNotNull('taskData', instance.taskData?.toJson()); - return val; -} +Map _$CompletedTaskToJson(CompletedTask instance) => + { + if (instance.$type case final value?) '__type': value, + 'taskName': instance.taskName, + if (instance.taskData?.toJson() case final value?) 'taskData': value, + }; TriggeredTask _$TriggeredTaskFromJson(Map json) => TriggeredTask( @@ -1327,77 +1016,44 @@ TriggeredTask _$TriggeredTaskFromJson(Map json) => : Data.fromJson(json['triggerData'] as Map), )..$type = json['__type'] as String?; -Map _$TriggeredTaskToJson(TriggeredTask instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - val['triggerId'] = instance.triggerId; - val['taskName'] = instance.taskName; - val['destinationDeviceRoleName'] = instance.destinationDeviceRoleName; - val['control'] = _$ControlEnumMap[instance.control]!; - writeNotNull('triggerData', instance.triggerData?.toJson()); - return val; -} +Map _$TriggeredTaskToJson(TriggeredTask instance) => + { + if (instance.$type case final value?) '__type': value, + 'triggerId': instance.triggerId, + 'taskName': instance.taskName, + 'destinationDeviceRoleName': instance.destinationDeviceRoleName, + 'control': _$ControlEnumMap[instance.control]!, + if (instance.triggerData?.toJson() case final value?) + 'triggerData': value, + }; Error _$ErrorFromJson(Map json) => Error( message: json['message'] as String, )..$type = json['__type'] as String?; -Map _$ErrorToJson(Error instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - val['message'] = instance.message; - return val; -} +Map _$ErrorToJson(Error instance) => { + if (instance.$type case final value?) '__type': value, + 'message': instance.message, + }; CustomInput _$CustomInputFromJson(Map json) => CustomInput( value: json['value'], )..$type = json['__type'] as String?; -Map _$CustomInputToJson(CustomInput instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - writeNotNull('value', instance.value); - return val; -} +Map _$CustomInputToJson(CustomInput instance) => + { + if (instance.$type case final value?) '__type': value, + if (instance.value case final value?) 'value': value, + }; SexInput _$SexInputFromJson(Map json) => SexInput( value: $enumDecode(_$SexEnumMap, json['value']), )..$type = json['__type'] as String?; -Map _$SexInputToJson(SexInput instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - val['value'] = _$SexEnumMap[instance.value]!; - return val; -} +Map _$SexInputToJson(SexInput instance) => { + if (instance.$type case final value?) '__type': value, + 'value': _$SexEnumMap[instance.value]!, + }; const _$SexEnumMap = { Sex.Male: 'Male', @@ -1413,21 +1069,13 @@ PhoneNumberInput _$PhoneNumberInputFromJson(Map json) => ..$type = json['__type'] as String? ..isoCode = json['isoCode'] as String?; -Map _$PhoneNumberInputToJson(PhoneNumberInput instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - val['countryCode'] = instance.countryCode; - writeNotNull('isoCode', instance.isoCode); - val['number'] = instance.number; - return val; -} +Map _$PhoneNumberInputToJson(PhoneNumberInput instance) => + { + if (instance.$type case final value?) '__type': value, + 'countryCode': instance.countryCode, + if (instance.isoCode case final value?) 'isoCode': value, + 'number': instance.number, + }; SocialSecurityNumberInput _$SocialSecurityNumberInputFromJson( Map json) => @@ -1437,20 +1085,12 @@ SocialSecurityNumberInput _$SocialSecurityNumberInputFromJson( )..$type = json['__type'] as String?; Map _$SocialSecurityNumberInputToJson( - SocialSecurityNumberInput instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - val['socialSecurityNumber'] = instance.socialSecurityNumber; - val['country'] = instance.country; - return val; -} + SocialSecurityNumberInput instance) => + { + if (instance.$type case final value?) '__type': value, + 'socialSecurityNumber': instance.socialSecurityNumber, + 'country': instance.country, + }; FullNameInput _$FullNameInputFromJson(Map json) => FullNameInput( @@ -1459,21 +1099,13 @@ FullNameInput _$FullNameInputFromJson(Map json) => lastName: json['lastName'] as String?, )..$type = json['__type'] as String?; -Map _$FullNameInputToJson(FullNameInput instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - writeNotNull('firstName', instance.firstName); - writeNotNull('middleName', instance.middleName); - writeNotNull('lastName', instance.lastName); - return val; -} +Map _$FullNameInputToJson(FullNameInput instance) => + { + if (instance.$type case final value?) '__type': value, + if (instance.firstName case final value?) 'firstName': value, + if (instance.middleName case final value?) 'middleName': value, + if (instance.lastName case final value?) 'lastName': value, + }; InformedConsentInput _$InformedConsentInputFromJson( Map json) => @@ -1489,24 +1121,16 @@ InformedConsentInput _$InformedConsentInputFromJson( )..$type = json['__type'] as String?; Map _$InformedConsentInputToJson( - InformedConsentInput instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - val['signedTimestamp'] = instance.signedTimestamp.toIso8601String(); - writeNotNull('signedLocation', instance.signedLocation); - val['userId'] = instance.userId; - val['name'] = instance.name; - val['consent'] = instance.consent; - val['signatureImage'] = instance.signatureImage; - return val; -} + InformedConsentInput instance) => + { + if (instance.$type case final value?) '__type': value, + 'signedTimestamp': instance.signedTimestamp.toIso8601String(), + if (instance.signedLocation case final value?) 'signedLocation': value, + 'userId': instance.userId, + 'name': instance.name, + 'consent': instance.consent, + 'signatureImage': instance.signatureImage, + }; AddressInput _$AddressInputFromJson(Map json) => AddressInput( address1: json['address1'] as String?, @@ -1517,24 +1141,16 @@ AddressInput _$AddressInputFromJson(Map json) => AddressInput( country: json['country'] as String?, )..$type = json['__type'] as String?; -Map _$AddressInputToJson(AddressInput instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - writeNotNull('address1', instance.address1); - writeNotNull('address2', instance.address2); - writeNotNull('street', instance.street); - writeNotNull('city', instance.city); - writeNotNull('postalCode', instance.postalCode); - writeNotNull('country', instance.country); - return val; -} +Map _$AddressInputToJson(AddressInput instance) => + { + if (instance.$type case final value?) '__type': value, + if (instance.address1 case final value?) 'address1': value, + if (instance.address2 case final value?) 'address2': value, + if (instance.street case final value?) 'street': value, + if (instance.city case final value?) 'city': value, + if (instance.postalCode case final value?) 'postalCode': value, + if (instance.country case final value?) 'country': value, + }; DiagnosisInput _$DiagnosisInputFromJson(Map json) => DiagnosisInput( @@ -1546,19 +1162,12 @@ DiagnosisInput _$DiagnosisInputFromJson(Map json) => conclusion: json['conclusion'] as String?, )..$type = json['__type'] as String?; -Map _$DiagnosisInputToJson(DiagnosisInput instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - writeNotNull('effectiveDate', instance.effectiveDate?.toIso8601String()); - writeNotNull('diagnosis', instance.diagnosis); - val['icd11Code'] = instance.icd11Code; - writeNotNull('conclusion', instance.conclusion); - return val; -} +Map _$DiagnosisInputToJson(DiagnosisInput instance) => + { + if (instance.$type case final value?) '__type': value, + if (instance.effectiveDate?.toIso8601String() case final value?) + 'effectiveDate': value, + if (instance.diagnosis case final value?) 'diagnosis': value, + 'icd11Code': instance.icd11Code, + if (instance.conclusion case final value?) 'conclusion': value, + }; diff --git a/carp_core/lib/data/carp_core_data.g.dart b/carp_core/lib/data/carp_core_data.g.dart index 9fdffb88..70f028d5 100644 --- a/carp_core/lib/data/carp_core_data.g.dart +++ b/carp_core/lib/data/carp_core_data.g.dart @@ -75,21 +75,12 @@ Measurement _$MeasurementFromJson(Map json) => Measurement( data: Data.fromJson(json['data'] as Map), ); -Map _$MeasurementToJson(Measurement instance) { - final val = { - 'sensorStartTime': instance.sensorStartTime, - }; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('sensorEndTime', instance.sensorEndTime); - val['data'] = instance.data.toJson(); - return val; -} +Map _$MeasurementToJson(Measurement instance) => + { + 'sensorStartTime': instance.sensorStartTime, + if (instance.sensorEndTime case final value?) 'sensorEndTime': value, + 'data': instance.data.toJson(), + }; OpenDataStreams _$OpenDataStreamsFromJson(Map json) => OpenDataStreams( @@ -99,20 +90,12 @@ OpenDataStreams _$OpenDataStreamsFromJson(Map json) => ..$type = json['__type'] as String? ..apiVersion = json['apiVersion'] as String; -Map _$OpenDataStreamsToJson(OpenDataStreams instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - val['apiVersion'] = instance.apiVersion; - val['configuration'] = instance.configuration.toJson(); - return val; -} +Map _$OpenDataStreamsToJson(OpenDataStreams instance) => + { + if (instance.$type case final value?) '__type': value, + 'apiVersion': instance.apiVersion, + 'configuration': instance.configuration.toJson(), + }; AppendToDataStreams _$AppendToDataStreamsFromJson(Map json) => AppendToDataStreams( @@ -124,21 +107,14 @@ AppendToDataStreams _$AppendToDataStreamsFromJson(Map json) => ..$type = json['__type'] as String? ..apiVersion = json['apiVersion'] as String; -Map _$AppendToDataStreamsToJson(AppendToDataStreams instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - val['apiVersion'] = instance.apiVersion; - val['studyDeploymentId'] = instance.studyDeploymentId; - val['batch'] = instance.batch.map((e) => e.toJson()).toList(); - return val; -} +Map _$AppendToDataStreamsToJson( + AppendToDataStreams instance) => + { + if (instance.$type case final value?) '__type': value, + 'apiVersion': instance.apiVersion, + 'studyDeploymentId': instance.studyDeploymentId, + 'batch': instance.batch.map((e) => e.toJson()).toList(), + }; GetDataStream _$GetDataStreamFromJson(Map json) => GetDataStream( @@ -149,22 +125,15 @@ GetDataStream _$GetDataStreamFromJson(Map json) => ..$type = json['__type'] as String? ..apiVersion = json['apiVersion'] as String; -Map _$GetDataStreamToJson(GetDataStream instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - val['apiVersion'] = instance.apiVersion; - val['dataStream'] = instance.dataStream.toJson(); - val['fromSequenceId'] = instance.fromSequenceId; - writeNotNull('toSequenceIdInclusive', instance.toSequenceIdInclusive); - return val; -} +Map _$GetDataStreamToJson(GetDataStream instance) => + { + if (instance.$type case final value?) '__type': value, + 'apiVersion': instance.apiVersion, + 'dataStream': instance.dataStream.toJson(), + 'fromSequenceId': instance.fromSequenceId, + if (instance.toSequenceIdInclusive case final value?) + 'toSequenceIdInclusive': value, + }; CloseDataStreams _$CloseDataStreamsFromJson(Map json) => CloseDataStreams( @@ -175,20 +144,12 @@ CloseDataStreams _$CloseDataStreamsFromJson(Map json) => ..$type = json['__type'] as String? ..apiVersion = json['apiVersion'] as String; -Map _$CloseDataStreamsToJson(CloseDataStreams instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - val['apiVersion'] = instance.apiVersion; - val['studyDeploymentIds'] = instance.studyDeploymentIds; - return val; -} +Map _$CloseDataStreamsToJson(CloseDataStreams instance) => + { + if (instance.$type case final value?) '__type': value, + 'apiVersion': instance.apiVersion, + 'studyDeploymentIds': instance.studyDeploymentIds, + }; RemoveDataStreams _$RemoveDataStreamsFromJson(Map json) => RemoveDataStreams( @@ -199,17 +160,9 @@ RemoveDataStreams _$RemoveDataStreamsFromJson(Map json) => ..$type = json['__type'] as String? ..apiVersion = json['apiVersion'] as String; -Map _$RemoveDataStreamsToJson(RemoveDataStreams instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - val['apiVersion'] = instance.apiVersion; - val['studyDeploymentIds'] = instance.studyDeploymentIds; - return val; -} +Map _$RemoveDataStreamsToJson(RemoveDataStreams instance) => + { + if (instance.$type case final value?) '__type': value, + 'apiVersion': instance.apiVersion, + 'studyDeploymentIds': instance.studyDeploymentIds, + }; diff --git a/carp_core/lib/deployment/carp_core_deployment.g.dart b/carp_core/lib/deployment/carp_core_deployment.g.dart index 9992bf76..0271b9f9 100644 --- a/carp_core/lib/deployment/carp_core_deployment.g.dart +++ b/carp_core/lib/deployment/carp_core_deployment.g.dart @@ -52,30 +52,21 @@ PrimaryDeviceDeployment _$PrimaryDeviceDeploymentFromJson( )..applicationData = json['applicationData'] as Map?; Map _$PrimaryDeviceDeploymentToJson( - PrimaryDeviceDeployment instance) { - final val = { - 'deviceConfiguration': instance.deviceConfiguration.toJson(), - 'registration': instance.registration.toJson(), - 'connectedDevices': - instance.connectedDevices.map((e) => e.toJson()).toList(), - 'connectedDeviceRegistrations': instance.connectedDeviceRegistrations - .map((k, e) => MapEntry(k, e?.toJson())), - 'tasks': instance.tasks.map((e) => e.toJson()).toList(), - 'triggers': instance.triggers.map((k, e) => MapEntry(k, e.toJson())), - 'taskControls': instance.taskControls.map((e) => e.toJson()).toList(), - 'expectedParticipantData': - instance.expectedParticipantData.map((e) => e.toJson()).toList(), - }; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('applicationData', instance.applicationData); - return val; -} + PrimaryDeviceDeployment instance) => + { + 'deviceConfiguration': instance.deviceConfiguration.toJson(), + 'registration': instance.registration.toJson(), + 'connectedDevices': + instance.connectedDevices.map((e) => e.toJson()).toList(), + 'connectedDeviceRegistrations': instance.connectedDeviceRegistrations + .map((k, e) => MapEntry(k, e?.toJson())), + 'tasks': instance.tasks.map((e) => e.toJson()).toList(), + 'triggers': instance.triggers.map((k, e) => MapEntry(k, e.toJson())), + 'taskControls': instance.taskControls.map((e) => e.toJson()).toList(), + 'expectedParticipantData': + instance.expectedParticipantData.map((e) => e.toJson()).toList(), + if (instance.applicationData case final value?) 'applicationData': value, + }; DeviceDeploymentStatus _$DeviceDeploymentStatusFromJson( Map json) => @@ -96,24 +87,17 @@ DeviceDeploymentStatus _$DeviceDeploymentStatusFromJson( .toList(); Map _$DeviceDeploymentStatusToJson( - DeviceDeploymentStatus instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - val['device'] = instance.device.toJson(); - writeNotNull('canBeDeployed', instance.canBeDeployed); - writeNotNull('remainingDevicesToRegisterToObtainDeployment', - instance.remainingDevicesToRegisterToObtainDeployment); - writeNotNull('remainingDevicesToRegisterBeforeDeployment', - instance.remainingDevicesToRegisterBeforeDeployment); - return val; -} + DeviceDeploymentStatus instance) => + { + if (instance.$type case final value?) '__type': value, + 'device': instance.device.toJson(), + if (instance.canBeDeployed case final value?) 'canBeDeployed': value, + if (instance.remainingDevicesToRegisterToObtainDeployment + case final value?) + 'remainingDevicesToRegisterToObtainDeployment': value, + if (instance.remainingDevicesToRegisterBeforeDeployment case final value?) + 'remainingDevicesToRegisterBeforeDeployment': value, + }; AssignedPrimaryDevice _$AssignedPrimaryDeviceFromJson( Map json) => @@ -127,20 +111,12 @@ AssignedPrimaryDevice _$AssignedPrimaryDeviceFromJson( ); Map _$AssignedPrimaryDeviceToJson( - AssignedPrimaryDevice instance) { - final val = { - 'device': instance.device.toJson(), - }; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('registration', instance.registration?.toJson()); - return val; -} + AssignedPrimaryDevice instance) => + { + 'device': instance.device.toJson(), + if (instance.registration?.toJson() case final value?) + 'registration': value, + }; StudyDeploymentStatus _$StudyDeploymentStatusFromJson( Map json) => @@ -162,25 +138,18 @@ StudyDeploymentStatus _$StudyDeploymentStatusFromJson( : DateTime.parse(json['startedOn'] as String); Map _$StudyDeploymentStatusToJson( - StudyDeploymentStatus instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - val['createdOn'] = instance.createdOn.toIso8601String(); - val['studyDeploymentId'] = instance.studyDeploymentId; - val['deviceStatusList'] = - instance.deviceStatusList.map((e) => e.toJson()).toList(); - val['participantStatusList'] = - instance.participantStatusList.map((e) => e.toJson()).toList(); - writeNotNull('startedOn', instance.startedOn?.toIso8601String()); - return val; -} + StudyDeploymentStatus instance) => + { + if (instance.$type case final value?) '__type': value, + 'createdOn': instance.createdOn.toIso8601String(), + 'studyDeploymentId': instance.studyDeploymentId, + 'deviceStatusList': + instance.deviceStatusList.map((e) => e.toJson()).toList(), + 'participantStatusList': + instance.participantStatusList.map((e) => e.toJson()).toList(), + if (instance.startedOn?.toIso8601String() case final value?) + 'startedOn': value, + }; ParticipantData _$ParticipantDataFromJson(Map json) => ParticipantData( @@ -259,21 +228,12 @@ StudyInvitation _$StudyInvitationFromJson(Map json) => json['applicationData'] as String?, ); -Map _$StudyInvitationToJson(StudyInvitation instance) { - final val = { - 'name': instance.name, - }; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('description', instance.description); - writeNotNull('applicationData', instance.applicationData); - return val; -} +Map _$StudyInvitationToJson(StudyInvitation instance) => + { + 'name': instance.name, + if (instance.description case final value?) 'description': value, + if (instance.applicationData case final value?) 'applicationData': value, + }; ActiveParticipationInvitation _$ActiveParticipationInvitationFromJson( Map json) => @@ -285,22 +245,14 @@ ActiveParticipationInvitation _$ActiveParticipationInvitationFromJson( .toList(); Map _$ActiveParticipationInvitationToJson( - ActiveParticipationInvitation instance) { - final val = { - 'participation': instance.participation.toJson(), - 'invitation': instance.invitation.toJson(), - }; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('assignedDevices', - instance.assignedDevices?.map((e) => e.toJson()).toList()); - return val; -} + ActiveParticipationInvitation instance) => + { + 'participation': instance.participation.toJson(), + 'invitation': instance.invitation.toJson(), + if (instance.assignedDevices?.map((e) => e.toJson()).toList() + case final value?) + 'assignedDevices': value, + }; ParticipantStatus _$ParticipantStatusFromJson(Map json) => ParticipantStatus( @@ -336,25 +288,17 @@ CreateStudyDeployment _$CreateStudyDeploymentFromJson( ..apiVersion = json['apiVersion'] as String; Map _$CreateStudyDeploymentToJson( - CreateStudyDeployment instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - val['apiVersion'] = instance.apiVersion; - val['protocol'] = instance.protocol.toJson(); - val['invitations'] = instance.invitations.map((e) => e.toJson()).toList(); - writeNotNull( - 'connectedDevicePreregistrations', - instance.connectedDevicePreregistrations - ?.map((k, e) => MapEntry(k, e.toJson()))); - return val; -} + CreateStudyDeployment instance) => + { + if (instance.$type case final value?) '__type': value, + 'apiVersion': instance.apiVersion, + 'protocol': instance.protocol.toJson(), + 'invitations': instance.invitations.map((e) => e.toJson()).toList(), + if (instance.connectedDevicePreregistrations + ?.map((k, e) => MapEntry(k, e.toJson())) + case final value?) + 'connectedDevicePreregistrations': value, + }; GetStudyDeploymentStatus _$GetStudyDeploymentStatusFromJson( Map json) => @@ -365,20 +309,13 @@ GetStudyDeploymentStatus _$GetStudyDeploymentStatusFromJson( ..apiVersion = json['apiVersion'] as String; Map _$GetStudyDeploymentStatusToJson( - GetStudyDeploymentStatus instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - val['apiVersion'] = instance.apiVersion; - writeNotNull('studyDeploymentId', instance.studyDeploymentId); - return val; -} + GetStudyDeploymentStatus instance) => + { + if (instance.$type case final value?) '__type': value, + 'apiVersion': instance.apiVersion, + if (instance.studyDeploymentId case final value?) + 'studyDeploymentId': value, + }; GetStudyDeploymentStatusList _$GetStudyDeploymentStatusListFromJson( Map json) => @@ -392,21 +329,14 @@ GetStudyDeploymentStatusList _$GetStudyDeploymentStatusListFromJson( ..studyDeploymentId = json['studyDeploymentId'] as String?; Map _$GetStudyDeploymentStatusListToJson( - GetStudyDeploymentStatusList instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - val['apiVersion'] = instance.apiVersion; - writeNotNull('studyDeploymentId', instance.studyDeploymentId); - val['studyDeploymentIds'] = instance.studyDeploymentIds; - return val; -} + GetStudyDeploymentStatusList instance) => + { + if (instance.$type case final value?) '__type': value, + 'apiVersion': instance.apiVersion, + if (instance.studyDeploymentId case final value?) + 'studyDeploymentId': value, + 'studyDeploymentIds': instance.studyDeploymentIds, + }; RegisterDevice _$RegisterDeviceFromJson(Map json) => RegisterDevice( @@ -417,22 +347,15 @@ RegisterDevice _$RegisterDeviceFromJson(Map json) => ..$type = json['__type'] as String? ..apiVersion = json['apiVersion'] as String; -Map _$RegisterDeviceToJson(RegisterDevice instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - val['apiVersion'] = instance.apiVersion; - writeNotNull('studyDeploymentId', instance.studyDeploymentId); - val['deviceRoleName'] = instance.deviceRoleName; - val['registration'] = instance.registration.toJson(); - return val; -} +Map _$RegisterDeviceToJson(RegisterDevice instance) => + { + if (instance.$type case final value?) '__type': value, + 'apiVersion': instance.apiVersion, + if (instance.studyDeploymentId case final value?) + 'studyDeploymentId': value, + 'deviceRoleName': instance.deviceRoleName, + 'registration': instance.registration.toJson(), + }; UnregisterDevice _$UnregisterDeviceFromJson(Map json) => UnregisterDevice( @@ -442,21 +365,14 @@ UnregisterDevice _$UnregisterDeviceFromJson(Map json) => ..$type = json['__type'] as String? ..apiVersion = json['apiVersion'] as String; -Map _$UnregisterDeviceToJson(UnregisterDevice instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - val['apiVersion'] = instance.apiVersion; - writeNotNull('studyDeploymentId', instance.studyDeploymentId); - val['deviceRoleName'] = instance.deviceRoleName; - return val; -} +Map _$UnregisterDeviceToJson(UnregisterDevice instance) => + { + if (instance.$type case final value?) '__type': value, + 'apiVersion': instance.apiVersion, + if (instance.studyDeploymentId case final value?) + 'studyDeploymentId': value, + 'deviceRoleName': instance.deviceRoleName, + }; GetDeviceDeploymentFor _$GetDeviceDeploymentForFromJson( Map json) => @@ -468,21 +384,14 @@ GetDeviceDeploymentFor _$GetDeviceDeploymentForFromJson( ..apiVersion = json['apiVersion'] as String; Map _$GetDeviceDeploymentForToJson( - GetDeviceDeploymentFor instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - val['apiVersion'] = instance.apiVersion; - writeNotNull('studyDeploymentId', instance.studyDeploymentId); - val['primaryDeviceRoleName'] = instance.primaryDeviceRoleName; - return val; -} + GetDeviceDeploymentFor instance) => + { + if (instance.$type case final value?) '__type': value, + 'apiVersion': instance.apiVersion, + if (instance.studyDeploymentId case final value?) + 'studyDeploymentId': value, + 'primaryDeviceRoleName': instance.primaryDeviceRoleName, + }; DeviceDeployed _$DeviceDeployedFromJson(Map json) => DeviceDeployed( @@ -493,23 +402,16 @@ DeviceDeployed _$DeviceDeployedFromJson(Map json) => ..$type = json['__type'] as String? ..apiVersion = json['apiVersion'] as String; -Map _$DeviceDeployedToJson(DeviceDeployed instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - val['apiVersion'] = instance.apiVersion; - writeNotNull('studyDeploymentId', instance.studyDeploymentId); - val['primaryDeviceRoleName'] = instance.primaryDeviceRoleName; - val['deviceDeploymentLastUpdatedOn'] = - instance.deviceDeploymentLastUpdatedOn.toIso8601String(); - return val; -} +Map _$DeviceDeployedToJson(DeviceDeployed instance) => + { + if (instance.$type case final value?) '__type': value, + 'apiVersion': instance.apiVersion, + if (instance.studyDeploymentId case final value?) + 'studyDeploymentId': value, + 'primaryDeviceRoleName': instance.primaryDeviceRoleName, + 'deviceDeploymentLastUpdatedOn': + instance.deviceDeploymentLastUpdatedOn.toIso8601String(), + }; Stop _$StopFromJson(Map json) => Stop( json['studyDeploymentId'] as String?, @@ -517,20 +419,12 @@ Stop _$StopFromJson(Map json) => Stop( ..$type = json['__type'] as String? ..apiVersion = json['apiVersion'] as String; -Map _$StopToJson(Stop instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - val['apiVersion'] = instance.apiVersion; - writeNotNull('studyDeploymentId', instance.studyDeploymentId); - return val; -} +Map _$StopToJson(Stop instance) => { + if (instance.$type case final value?) '__type': value, + 'apiVersion': instance.apiVersion, + if (instance.studyDeploymentId case final value?) + 'studyDeploymentId': value, + }; GetActiveParticipationInvitations _$GetActiveParticipationInvitationsFromJson( Map json) => @@ -541,20 +435,12 @@ GetActiveParticipationInvitations _$GetActiveParticipationInvitationsFromJson( ..apiVersion = json['apiVersion'] as String; Map _$GetActiveParticipationInvitationsToJson( - GetActiveParticipationInvitations instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - val['apiVersion'] = instance.apiVersion; - val['accountId'] = instance.accountId; - return val; -} + GetActiveParticipationInvitations instance) => + { + if (instance.$type case final value?) '__type': value, + 'apiVersion': instance.apiVersion, + 'accountId': instance.accountId, + }; GetParticipantData _$GetParticipantDataFromJson(Map json) => GetParticipantData( @@ -563,20 +449,13 @@ GetParticipantData _$GetParticipantDataFromJson(Map json) => ..$type = json['__type'] as String? ..apiVersion = json['apiVersion'] as String; -Map _$GetParticipantDataToJson(GetParticipantData instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - writeNotNull('studyDeploymentId', instance.studyDeploymentId); - val['apiVersion'] = instance.apiVersion; - return val; -} +Map _$GetParticipantDataToJson(GetParticipantData instance) => + { + if (instance.$type case final value?) '__type': value, + if (instance.studyDeploymentId case final value?) + 'studyDeploymentId': value, + 'apiVersion': instance.apiVersion, + }; GetParticipantDataList _$GetParticipantDataListFromJson( Map json) => @@ -590,21 +469,14 @@ GetParticipantDataList _$GetParticipantDataListFromJson( ..apiVersion = json['apiVersion'] as String; Map _$GetParticipantDataListToJson( - GetParticipantDataList instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - writeNotNull('studyDeploymentId', instance.studyDeploymentId); - val['apiVersion'] = instance.apiVersion; - val['studyDeploymentIds'] = instance.studyDeploymentIds; - return val; -} + GetParticipantDataList instance) => + { + if (instance.$type case final value?) '__type': value, + if (instance.studyDeploymentId case final value?) + 'studyDeploymentId': value, + 'apiVersion': instance.apiVersion, + 'studyDeploymentIds': instance.studyDeploymentIds, + }; SetParticipantData _$SetParticipantDataFromJson(Map json) => SetParticipantData( @@ -618,19 +490,15 @@ SetParticipantData _$SetParticipantDataFromJson(Map json) => ..$type = json['__type'] as String? ..apiVersion = json['apiVersion'] as String; -Map _$SetParticipantDataToJson(SetParticipantData instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - writeNotNull('studyDeploymentId', instance.studyDeploymentId); - val['apiVersion'] = instance.apiVersion; - writeNotNull('inputByParticipantRole', instance.inputByParticipantRole); - writeNotNull('data', instance.data?.map((k, e) => MapEntry(k, e?.toJson()))); - return val; -} +Map _$SetParticipantDataToJson(SetParticipantData instance) => + { + if (instance.$type case final value?) '__type': value, + if (instance.studyDeploymentId case final value?) + 'studyDeploymentId': value, + 'apiVersion': instance.apiVersion, + if (instance.inputByParticipantRole case final value?) + 'inputByParticipantRole': value, + if (instance.data?.map((k, e) => MapEntry(k, e?.toJson())) + case final value?) + 'data': value, + }; diff --git a/carp_core/lib/deployment/domain/study_deployment.dart b/carp_core/lib/deployment/domain/study_deployment.dart index 7349bff9..ed0d72a3 100644 --- a/carp_core/lib/deployment/domain/study_deployment.dart +++ b/carp_core/lib/deployment/domain/study_deployment.dart @@ -195,7 +195,7 @@ class StudyDeployment { Map? usedTriggers = _protocol.triggers; Set? triggeredTasks = _protocol.taskControls; - _status.status = StudyDeploymentStatusTypes.DeploymentReady; + _status.status = StudyDeploymentStatusTypes.Running; return PrimaryDeviceDeployment( deviceConfiguration: device, @@ -215,7 +215,7 @@ class StudyDeployment { ) { // assert(_protocol.primaryDevices.contains(device), // 'The specified primary device is not part of the protocol of this deployment.'); - _status.status = StudyDeploymentStatusTypes.DeploymentReady; + _status.status = StudyDeploymentStatusTypes.Running; _startTime = deviceDeploymentLastUpdateDate; } @@ -237,8 +237,9 @@ enum StudyDeploymentStatusTypes { /// devices still need to be deployed. DeployingDevices, - /// The study deployment is ready to be used. - DeploymentReady, + /// All primary devices have been successfully deployed and data collection + /// has started on the time specified by [StudyDeploymentStatus.startedOn]. + Running, /// The study deployment has been stopped and no more data should be collected. Stopped, @@ -312,8 +313,8 @@ class StudyDeploymentStatus extends Serializable { case 'DeployingDevices': status.status = StudyDeploymentStatusTypes.DeployingDevices; break; - case 'DeploymentReady': - status.status = StudyDeploymentStatusTypes.DeploymentReady; + case 'Running': + status.status = StudyDeploymentStatusTypes.Running; break; case 'Stopped': status.status = StudyDeploymentStatusTypes.Stopped; diff --git a/carp_core/lib/protocols/carp_core_protocols.g.dart b/carp_core/lib/protocols/carp_core_protocols.g.dart index 11effe4a..4892ca05 100644 --- a/carp_core/lib/protocols/carp_core_protocols.g.dart +++ b/carp_core/lib/protocols/carp_core_protocols.g.dart @@ -51,40 +51,35 @@ StudyProtocol _$StudyProtocolFromJson(Map json) => .toSet() ..applicationData = json['applicationData'] as Map?; -Map _$StudyProtocolToJson(StudyProtocol instance) { - final val = { - 'id': instance.id, - 'createdOn': instance.createdOn.toIso8601String(), - 'version': instance.version, - 'ownerId': instance.ownerId, - 'name': instance.name, - }; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('description', instance.description); - writeNotNull('participantRoles', - instance.participantRoles?.map((e) => e.toJson()).toList()); - val['primaryDevices'] = - instance.primaryDevices.map((e) => e.toJson()).toList(); - writeNotNull('connectedDevices', - instance.connectedDevices?.map((e) => e.toJson()).toList()); - writeNotNull( - 'connections', instance.connections?.map((e) => e.toJson()).toList()); - writeNotNull('assignedDevices', - instance.assignedDevices?.map((k, e) => MapEntry(k, e.toList()))); - val['tasks'] = instance.tasks.map((e) => e.toJson()).toList(); - val['triggers'] = instance.triggers.map((k, e) => MapEntry(k, e.toJson())); - val['taskControls'] = instance.taskControls.map((e) => e.toJson()).toList(); - writeNotNull('expectedParticipantData', - instance.expectedParticipantData?.map((e) => e.toJson()).toList()); - writeNotNull('applicationData', instance.applicationData); - return val; -} +Map _$StudyProtocolToJson(StudyProtocol instance) => + { + 'id': instance.id, + 'createdOn': instance.createdOn.toIso8601String(), + 'version': instance.version, + 'ownerId': instance.ownerId, + 'name': instance.name, + if (instance.description case final value?) 'description': value, + if (instance.participantRoles?.map((e) => e.toJson()).toList() + case final value?) + 'participantRoles': value, + 'primaryDevices': instance.primaryDevices.map((e) => e.toJson()).toList(), + if (instance.connectedDevices?.map((e) => e.toJson()).toList() + case final value?) + 'connectedDevices': value, + if (instance.connections?.map((e) => e.toJson()).toList() + case final value?) + 'connections': value, + if (instance.assignedDevices?.map((k, e) => MapEntry(k, e.toList())) + case final value?) + 'assignedDevices': value, + 'tasks': instance.tasks.map((e) => e.toJson()).toList(), + 'triggers': instance.triggers.map((k, e) => MapEntry(k, e.toJson())), + 'taskControls': instance.taskControls.map((e) => e.toJson()).toList(), + if (instance.expectedParticipantData?.map((e) => e.toJson()).toList() + case final value?) + 'expectedParticipantData': value, + if (instance.applicationData case final value?) 'applicationData': value, + }; DeviceConnection _$DeviceConnectionFromJson(Map json) => DeviceConnection( @@ -92,19 +87,12 @@ DeviceConnection _$DeviceConnectionFromJson(Map json) => json['connectedToRoleName'] as String?, ); -Map _$DeviceConnectionToJson(DeviceConnection instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('roleName', instance.roleName); - writeNotNull('connectedToRoleName', instance.connectedToRoleName); - return val; -} +Map _$DeviceConnectionToJson(DeviceConnection instance) => + { + if (instance.roleName case final value?) 'roleName': value, + if (instance.connectedToRoleName case final value?) + 'connectedToRoleName': value, + }; ProtocolVersion _$ProtocolVersionFromJson(Map json) => ProtocolVersion( @@ -124,21 +112,12 @@ Add _$AddFromJson(Map json) => Add( ..$type = json['__type'] as String? ..apiVersion = json['apiVersion'] as String; -Map _$AddToJson(Add instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - val['apiVersion'] = instance.apiVersion; - val['protocol'] = instance.protocol.toJson(); - writeNotNull('versionTag', instance.versionTag); - return val; -} +Map _$AddToJson(Add instance) => { + if (instance.$type case final value?) '__type': value, + 'apiVersion': instance.apiVersion, + 'protocol': instance.protocol.toJson(), + if (instance.versionTag case final value?) 'versionTag': value, + }; AddVersion _$AddVersionFromJson(Map json) => AddVersion( StudyProtocol.fromJson(json['protocol'] as Map), @@ -147,21 +126,13 @@ AddVersion _$AddVersionFromJson(Map json) => AddVersion( ..$type = json['__type'] as String? ..apiVersion = json['apiVersion'] as String; -Map _$AddVersionToJson(AddVersion instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - val['apiVersion'] = instance.apiVersion; - val['protocol'] = instance.protocol.toJson(); - writeNotNull('versionTag', instance.versionTag); - return val; -} +Map _$AddVersionToJson(AddVersion instance) => + { + if (instance.$type case final value?) '__type': value, + 'apiVersion': instance.apiVersion, + 'protocol': instance.protocol.toJson(), + if (instance.versionTag case final value?) 'versionTag': value, + }; UpdateParticipantDataConfiguration _$UpdateParticipantDataConfigurationFromJson( Map json) => @@ -177,23 +148,16 @@ UpdateParticipantDataConfiguration _$UpdateParticipantDataConfigurationFromJson( ..apiVersion = json['apiVersion'] as String; Map _$UpdateParticipantDataConfigurationToJson( - UpdateParticipantDataConfiguration instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - val['apiVersion'] = instance.apiVersion; - val['protocolId'] = instance.protocolId; - writeNotNull('versionTag', instance.versionTag); - writeNotNull('expectedParticipantData', - instance.expectedParticipantData?.map((e) => e.toJson()).toList()); - return val; -} + UpdateParticipantDataConfiguration instance) => + { + if (instance.$type case final value?) '__type': value, + 'apiVersion': instance.apiVersion, + 'protocolId': instance.protocolId, + if (instance.versionTag case final value?) 'versionTag': value, + if (instance.expectedParticipantData?.map((e) => e.toJson()).toList() + case final value?) + 'expectedParticipantData': value, + }; GetBy _$GetByFromJson(Map json) => GetBy( json['protocolId'] as String, @@ -202,21 +166,12 @@ GetBy _$GetByFromJson(Map json) => GetBy( ..$type = json['__type'] as String? ..apiVersion = json['apiVersion'] as String; -Map _$GetByToJson(GetBy instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - val['apiVersion'] = instance.apiVersion; - val['protocolId'] = instance.protocolId; - writeNotNull('versionTag', instance.versionTag); - return val; -} +Map _$GetByToJson(GetBy instance) => { + if (instance.$type case final value?) '__type': value, + 'apiVersion': instance.apiVersion, + 'protocolId': instance.protocolId, + if (instance.versionTag case final value?) 'versionTag': value, + }; GetAllForOwner _$GetAllForOwnerFromJson(Map json) => GetAllForOwner( @@ -225,20 +180,12 @@ GetAllForOwner _$GetAllForOwnerFromJson(Map json) => ..$type = json['__type'] as String? ..apiVersion = json['apiVersion'] as String; -Map _$GetAllForOwnerToJson(GetAllForOwner instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - val['apiVersion'] = instance.apiVersion; - val['ownerId'] = instance.ownerId; - return val; -} +Map _$GetAllForOwnerToJson(GetAllForOwner instance) => + { + if (instance.$type case final value?) '__type': value, + 'apiVersion': instance.apiVersion, + 'ownerId': instance.ownerId, + }; GetVersionHistoryFor _$GetVersionHistoryForFromJson( Map json) => @@ -249,20 +196,12 @@ GetVersionHistoryFor _$GetVersionHistoryForFromJson( ..apiVersion = json['apiVersion'] as String; Map _$GetVersionHistoryForToJson( - GetVersionHistoryFor instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - val['apiVersion'] = instance.apiVersion; - val['protocolId'] = instance.protocolId; - return val; -} + GetVersionHistoryFor instance) => + { + if (instance.$type case final value?) '__type': value, + 'apiVersion': instance.apiVersion, + 'protocolId': instance.protocolId, + }; CreateCustomProtocol _$CreateCustomProtocolFromJson( Map json) => @@ -276,20 +215,12 @@ CreateCustomProtocol _$CreateCustomProtocolFromJson( ..apiVersion = json['apiVersion'] as String; Map _$CreateCustomProtocolToJson( - CreateCustomProtocol instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('__type', instance.$type); - val['apiVersion'] = instance.apiVersion; - val['ownerId'] = instance.ownerId; - val['name'] = instance.name; - val['description'] = instance.description; - val['customProtocol'] = instance.customProtocol; - return val; -} + CreateCustomProtocol instance) => + { + if (instance.$type case final value?) '__type': value, + 'apiVersion': instance.apiVersion, + 'ownerId': instance.ownerId, + 'name': instance.name, + 'description': instance.description, + 'customProtocol': instance.customProtocol, + }; diff --git a/carp_core/test/carp_core_kotlin_rpc_test.dart b/carp_core/test/carp_core_kotlin_rpc_test.dart index be4d163b..51165e13 100644 --- a/carp_core/test/carp_core_kotlin_rpc_test.dart +++ b/carp_core/test/carp_core_kotlin_rpc_test.dart @@ -714,7 +714,6 @@ void main() { ); print(toJsonString(request)); - // expect(expected.toJson(), request.toJson()); expect(toJsonString(expected), toJsonString(request)); }); @@ -726,7 +725,7 @@ void main() { StudyDeploymentStatus status = StudyDeploymentStatus.fromJson( json.decode(plainJson) as Map); expect(status.studyDeploymentId, testDeploymentId); - expect(status.status, StudyDeploymentStatusTypes.Invited); + expect(status.status, StudyDeploymentStatusTypes.Running); print(toJsonString(status)); }); }); diff --git a/carp_mobile_sensing/CHANGELOG.md b/carp_mobile_sensing/CHANGELOG.md index d9387a18..6da1a309 100644 --- a/carp_mobile_sensing/CHANGELOG.md +++ b/carp_mobile_sensing/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.11.6 + +* Support for the `NoUserTaskTrigger` (issue [#453](https://github.com/cph-cachet/carp.sensing-flutter/issues/453)) + ## 1.11.5 * Fix of issue with restarting data collection on device reconnect (issue [#442](https://github.com/cph-cachet/carp.sensing-flutter/issues/442)) From 504386562e01e2a092f08fb65578acb15fe770b1 Mon Sep 17 00:00:00 2001 From: bardram Date: Wed, 4 Dec 2024 15:49:36 +0100 Subject: [PATCH 3/4] carp_core 1.8.4 published --- carp_core/CHANGELOG.md | 4 ++++ carp_core/pubspec.yaml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/carp_core/CHANGELOG.md b/carp_core/CHANGELOG.md index ce53fb08..bb84ee35 100644 --- a/carp_core/CHANGELOG.md +++ b/carp_core/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.8.4 + +* fix of issue [#452](https://github.com/cph-cachet/carp.sensing-flutter/issues/452) + ## 1.8.3 * upgrade to carp_serialization v. 2.0 diff --git a/carp_core/pubspec.yaml b/carp_core/pubspec.yaml index 0092d337..b8cdef15 100644 --- a/carp_core/pubspec.yaml +++ b/carp_core/pubspec.yaml @@ -1,6 +1,6 @@ name: carp_core description: The core domain model for the Copenhagen Research Platform (CARP) in Dart. -version: 1.8.3 +version: 1.8.4 homepage: https://github.com/cph-cachet/carp.sensing-flutter environment: From 3fe09ec286bee88c149ec183a67b83ce914a359c Mon Sep 17 00:00:00 2001 From: bardram Date: Wed, 4 Dec 2024 15:50:36 +0100 Subject: [PATCH 4/4] carp_mobile_sensing 1.11.6 published --- carp_mobile_sensing/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/carp_mobile_sensing/pubspec.yaml b/carp_mobile_sensing/pubspec.yaml index 12ea7bcd..938ed17d 100644 --- a/carp_mobile_sensing/pubspec.yaml +++ b/carp_mobile_sensing/pubspec.yaml @@ -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.11.5 +version: 1.11.6 homepage: https://github.com/cph-cachet/carp.sensing-flutter environment: