- datalog_session.dart: DatalogSession model with toMap/fromMap, duration helpers - datalog_db.dart: SQLite schema (sessions + frames tables), batch insertFrames, getSessions, getFrames, deleteSession, closeSession - datalog_recorder.dart: listens to raw frame stream, buffers PendingFrames, flushes to DB every 500ms via Timer, finalises session on stop() - datalog_player.dart: loads StoredFrames from DB, replays at original timing adjusted by speed multiplier (0.25x–8x), play/pause/stop/seek, onProgress cb - datalog_provider.dart: datalogDbProvider, datalogRecorderProvider, datalogPlayerProvider singletons; RecordingNotifier (idle/recording state); sessionListProvider FutureProvider; PlaybackNotifier with full playback state - pubspec.yaml: added path ^1.9.0 dependency
63 lines
1.7 KiB
Dart
63 lines
1.7 KiB
Dart
/// Metadata for a single recorded ECU datalog session.
|
|
class DatalogSession {
|
|
final int? id;
|
|
final String ecuType;
|
|
final DateTime startTime;
|
|
final DateTime? endTime;
|
|
final int frameCount;
|
|
|
|
const DatalogSession({
|
|
this.id,
|
|
required this.ecuType,
|
|
required this.startTime,
|
|
this.endTime,
|
|
this.frameCount = 0,
|
|
});
|
|
|
|
Duration get duration {
|
|
final end = endTime ?? DateTime.now();
|
|
return end.difference(startTime);
|
|
}
|
|
|
|
String get durationLabel {
|
|
final d = duration;
|
|
final m = d.inMinutes.remainder(60).toString().padLeft(2, '0');
|
|
final s = d.inSeconds.remainder(60).toString().padLeft(2, '0');
|
|
return '$m:$s';
|
|
}
|
|
|
|
DatalogSession copyWith({
|
|
int? id,
|
|
String? ecuType,
|
|
DateTime? startTime,
|
|
DateTime? endTime,
|
|
int? frameCount,
|
|
}) =>
|
|
DatalogSession(
|
|
id: id ?? this.id,
|
|
ecuType: ecuType ?? this.ecuType,
|
|
startTime: startTime ?? this.startTime,
|
|
endTime: endTime ?? this.endTime,
|
|
frameCount: frameCount ?? this.frameCount,
|
|
);
|
|
|
|
Map<String, dynamic> toMap() => {
|
|
'id': id,
|
|
'ecu_type': ecuType,
|
|
'start_time': startTime.millisecondsSinceEpoch,
|
|
'end_time': endTime?.millisecondsSinceEpoch,
|
|
'frame_count': frameCount,
|
|
};
|
|
|
|
factory DatalogSession.fromMap(Map<String, dynamic> m) => DatalogSession(
|
|
id: m['id'] as int?,
|
|
ecuType: m['ecu_type'] as String,
|
|
startTime:
|
|
DateTime.fromMillisecondsSinceEpoch(m['start_time'] as int),
|
|
endTime: m['end_time'] == null
|
|
? null
|
|
: DateTime.fromMillisecondsSinceEpoch(m['end_time'] as int),
|
|
frameCount: m['frame_count'] as int? ?? 0,
|
|
);
|
|
}
|