Skip to content

Commit

Permalink
feat: add location timestamp to export (#91)
Browse files Browse the repository at this point in the history
  • Loading branch information
matejglejtek authored Oct 8, 2024
2 parents ab86b70 + 825607f commit 721fd59
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions lib/utils/csvlogger.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import '../models/unit_value.dart';
import '../services/unit_conversion_service.dart';

class CSVLogger {
static const locationFields = 15;
static const locationFields = 16;
static const basicFields = 3;
static const operatorFields = 1;
static const authFields = 0;
Expand Down Expand Up @@ -51,6 +51,7 @@ class CSVLogger {

List<dynamic> _logLocationMessage(LocationMessage loc) {
final row = <dynamic>[];
row.add(_logLocationTimestamp(loc.timestamp) ?? '');
row.add(loc.status.asString() ?? '');
row.add(loc.location?.latitude ?? '');
row.add(loc.location?.longitude ?? '');
Expand Down Expand Up @@ -253,9 +254,10 @@ class CSVLogger {
// common
'Message Type',
'Message Source',
'Timestamp',
'Received Timestamp',
'Mac Address',
// location
'Location Timestamp',
'Status',
'Latitude',
'Longitude',
Expand Down Expand Up @@ -293,4 +295,12 @@ class CSVLogger {
'Category',
'Class Value',
];

// log in format hh:mm:ss.sss
String? _logLocationTimestamp(Duration? duration) {
if (duration == null) return null;
// toString uses format H:MM:SS.mmmmmm, remove last 3 digits
final durationString = duration.toString();
return durationString.substring(0, durationString.length - 3);
}
}

0 comments on commit 721fd59

Please sign in to comment.