From 3a0e9eba380639c94bda8aba1c4b711d1abc59c9 Mon Sep 17 00:00:00 2001 From: datdenkikniet Date: Sun, 12 May 2024 21:48:31 +0200 Subject: [PATCH] feat(sdr): log some info about Event-Only sensors in Loggable impl --- src/storage/sdr/record/mod.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/storage/sdr/record/mod.rs b/src/storage/sdr/record/mod.rs index a115abb..178ffc8 100644 --- a/src/storage/sdr/record/mod.rs +++ b/src/storage/sdr/record/mod.rs @@ -738,6 +738,14 @@ impl Record { } } + pub fn event_only(&self) -> Option<&EventOnlySensorRecord> { + if let RecordContents::EventOnlySensor(event) = &self.contents { + Some(event) + } else { + None + } + } + pub fn parse(data: &[u8]) -> Result { if data.len() < 5 { return Err(ParseError::NotEnoughData); @@ -887,6 +895,7 @@ impl Loggable for Record { fn as_log(&self) -> Vec { let full = self.full_sensor(); let compact = self.compact_sensor(); + let event_only = self.event_only(); let mut log = Vec::new(); @@ -894,6 +903,8 @@ impl Loggable for Record { log.push((0, "SDR Record (Full)").into()); } else if compact.is_some() { log.push((0, "SDR Record (Compact)").into()); + } else if event_only.is_some() { + log.push((0, "SDR Record (Event-only)").into()) } else { log.push((0, "Cannot log unknown sensor type").into()); return log; @@ -933,6 +944,9 @@ impl Loggable for Record { } else if let Some(compact) = compact { compact.key_data().log_into(1, &mut log); log.push((1, "Sensor ID", compact.id_string()).into()); + } else if let Some(event_only) = event_only { + event_only.key_data().log_into(1, &mut log); + log.push((1, "Sensor ID", event_only.id_string()).into()); } log