feat: add use-case session management, analysis algorithms, and REST API (v0.5.0)
- Add session layer with UseCaseSession, SessionRun, SessionManager for use-case driven telemetry analysis (shift points, track mapping) - Add analysis module with shift point detection (gear RPM ranges, upshift events, recommended shift RPM) and track map reconstruction (spline-aligned interpolation for center line from boundary runs) - Add 9 REST API endpoints for session CRUD, run management, and analysis triggers under /api/sessions/* - Add RecordingManager with always-on ring buffers (5 min, 18k frames) replacing raw binary file dumps - Wire SessionManager in main.rs with Arc<Mutex> shared state - Add TelemetryFrame Serialize derives for JSON API output - Fix stop_recording race: hold active lock across flush I/O - Fix flush: separate ring buffer lock from JSON serialization - Fix flush failure propagation: errors prevent Stopped status - Add data_truncated flag on SessionRun for ring buffer wrap detection - Deduplicate gear_display into shared free function - Deduplicate session_display into closure - Mutex poisoning recovery on all session API handlers
This commit is contained in:
parent
56d3169033
commit
47a0896134
10 changed files with 2333 additions and 91 deletions
|
|
@ -3,8 +3,10 @@
|
|||
//! Both the KSUDP (port 9996) and Telemetry Tool (port 10101) parsers produce
|
||||
//! `TelemetryFrame` instances from their raw binary data.
|
||||
|
||||
use serde::Serialize;
|
||||
|
||||
/// Identifies which feed source produced this frame.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize)]
|
||||
pub enum FeedSource {
|
||||
Ksudp,
|
||||
TelemetryTool,
|
||||
|
|
@ -18,7 +20,7 @@ pub const NUM_WHEELS: usize = 4;
|
|||
///
|
||||
/// Fields present in both feeds are stored directly; fields unique to one feed
|
||||
/// are wrapped in `Option`.
|
||||
#[derive(Debug, Clone)]
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct TelemetryFrame {
|
||||
// ── Speed ──────────────────────────────────────────────────────
|
||||
pub speed_kmh: f32,
|
||||
|
|
@ -233,10 +235,15 @@ impl TelemetryFrame {
|
|||
|
||||
/// Gear display: 0=Reverse, 1=Neutral, 2+=Gear N-1
|
||||
pub fn gear_display(&self) -> String {
|
||||
match self.gear {
|
||||
0 => "R".to_string(),
|
||||
1 => "N".to_string(),
|
||||
n => format!("{}", n - 1),
|
||||
}
|
||||
gear_display(self.gear)
|
||||
}
|
||||
}
|
||||
|
||||
/// AC gear encoding: 0=Reverse, 1=Neutral, 2+=Gear N-1.
|
||||
pub fn gear_display(gear: i32) -> String {
|
||||
match gear {
|
||||
0 => "R".to_string(),
|
||||
1 => "N".to_string(),
|
||||
n => format!("{}", n - 1),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue