Commit 21849d30 authored by Administrator's avatar Administrator

storing records and markers, next up: laps

parent 19ac33da
......@@ -50,7 +50,7 @@ const tableActivity = SqfEntityTable(
SqfEntityFieldRelationship(
parentTable: tableAthlete,
deleteRule: DeleteRule.CASCADE,
defaultValue: '0'),
defaultValue: 0),
],
);
......@@ -66,10 +66,25 @@ const tableEvent = SqfEntityTable(
SqfEntityField('eventGroup', DbType.integer),
SqfEntityField('timerTrigger', DbType.text),
SqfEntityField('timeStamp', DbType.datetime),
SqfEntityField('positionLat', DbType.real),
SqfEntityField('positionLong', DbType.real),
SqfEntityField('distance', DbType.real),
SqfEntityField('altitude', DbType.real),
SqfEntityField('speed', DbType.real),
SqfEntityField('heartRate', DbType.integer),
SqfEntityField('cadence', DbType.real),
SqfEntityField('fractionalCadence', DbType.real),
SqfEntityField('power', DbType.integer),
SqfEntityField('strydCadence', DbType.real),
SqfEntityField('groundTime', DbType.real),
SqfEntityField('verticalOscillation', DbType.real),
SqfEntityField('formPower', DbType.integer),
SqfEntityField('legSpringStiffness', DbType.real),
SqfEntityField('data', DbType.real),
SqfEntityFieldRelationship(
parentTable: tableActivity,
deleteRule: DeleteRule.CASCADE,
defaultValue: '0'),
defaultValue: 0),
],
);
......
This diff is collapsed.
......@@ -63,6 +63,7 @@ class Activity extends ChangeNotifier {
case 13:
case 22:
case 79:
case 104:
case 141:
case 147:
break; // Garmin uses global message numbers, which are not specified
......@@ -71,10 +72,13 @@ class Activity extends ChangeNotifier {
}
} else {
switch (dataMessage.definitionMessage.globalMessageName) {
case 'developer_data_id':
case "device_info":
case "device_settings":
case "field_description":
case "file_creator":
case "user_profile":
case "zones_target":
break; // we are currently not storing these kinds of messages
case "file_id":
......@@ -98,6 +102,15 @@ class Activity extends ChangeNotifier {
case "event":
Event(dataMessage: dataMessage, activity: this);
break;
case "record":
Event.fromRecord(dataMessage: dataMessage, activity: this);
break;
case "lap":
Event.fromLap(dataMessage: dataMessage, activity: this)
break;
default:
debugger();
}
......
......@@ -17,9 +17,11 @@ class Event {
return;
}
if (dataMessage.values.any(
(value) => value.fieldName == 'event_type' && value.value == 'start')) {
if (dataMessage.values.any((value) =>
value.fieldName == 'event_type' &&
['start', 'stop_all'].contains(value.value))) {
db = DbEvent()
..activitiesId = activity.db.id
..event = dataMessage.get('event')
..eventType = dataMessage.get('event_type')
..eventGroup = dataMessage.get('event_group').round()
......@@ -29,6 +31,47 @@ class Event {
return;
}
if (dataMessage.values.any((value) =>
value.fieldName == 'event_type' && ['marker'].contains(value.value))) {
db = DbEvent()
..activitiesId = activity.db.id
..event = dataMessage.get('event').toString()
..eventType = dataMessage.get('event_type')
..eventGroup = dataMessage.get('event_group').round()
..data = dataMessage.get('data')
..timeStamp = dateTimeFromStrava(dataMessage.get('timestamp'))
..save();
return;
}
debugger();
}
Event.fromRecord({DataMessage dataMessage, this.activity}) {
db = DbEvent()
..activitiesId = activity.db.id
..timeStamp = dateTimeFromStrava(dataMessage.get('timestamp'))
..positionLat = dataMessage.get('position_lat')
..positionLong = dataMessage.get('position_long')
..distance = dataMessage.get('distance')
..altitude = dataMessage.get('altitude')
..speed = dataMessage.get('speed')
..heartRate = dataMessage.get('heart_rate').round()
..cadence = dataMessage.get('cadence')
..fractionalCadence = dataMessage.get('fractional_cadence')
..power = dataMessage.get('Power').round()
..strydCadence = dataMessage.get('Cadence')
..groundTime = dataMessage.get('Ground Time')
..verticalOscillation = dataMessage.get('Vertical Oscillation')
..formPower = dataMessage.get('Form Power').round()
..legSpringStiffness = dataMessage.get('Leg Spring Stiffness')
..save();
}
Event.fromLap({DataMessage dataMessage, this.activity}) {
db = DbEvent()
..activitiesId = activity.db.id
// 40 values to add here ;-)
..save();
}
}
......@@ -559,14 +559,14 @@ packages:
name: sqfentity
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.2+12"
version: "1.2.3+1"
sqfentity_gen:
dependency: "direct main"
description:
name: sqfentity_gen
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.1+21"
version: "1.2.3+3"
sqflite:
dependency: transitive
description:
......
......@@ -12,8 +12,9 @@ dependencies:
flutter_launcher_icons: ^0.7.2
cupertino_icons: ^0.1.2
strava_flutter: ^1.1.0+40
sqfentity: ^1.2.2+8
sqfentity_gen: ^1.2.0+12
sqfentity: ^1.2.3+1
sqfentity_gen: ^1.2.1+13
dio: ^3.0.7
dio_cookie_manager: ^1.0.0
flutter_secure_storage: ^3.3.1+1
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment