From 9b9e04ad6304f0e8b918cb4ecd9d9a9f94cdb034 Mon Sep 17 00:00:00 2001 From: alban Date: Mon, 12 Jun 2023 21:56:21 +0200 Subject: [PATCH] fix: helios status trace time --- src/device/helios.rs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/device/helios.rs b/src/device/helios.rs index deab194..eb59d16 100644 --- a/src/device/helios.rs +++ b/src/device/helios.rs @@ -14,13 +14,15 @@ use crate::conf::HeliosConf; use crate::device::{Device, Status, PlaybackState}; use crate::errors::{LJError, LJResult}; use crate::point::Point; +use chrono::Utc; pub struct HeliosDevice { pub conf: HeliosConf, dac: NativeHeliosDac, sent_points: u16, state: PlaybackState, - lack: String + lack: String, + last_traced_at : String } impl HeliosDevice { @@ -32,7 +34,14 @@ impl HeliosDevice { return Err(Box::new(LJError::HeliosDeviceMissing)); }; let dac = device.open()?; - Ok(Self { conf: (*conf).clone(), dac, sent_points: 0, state: PlaybackState::PREPARE, lack: "".to_string() }) + Ok(Self { + conf: (*conf).clone(), + dac, + sent_points: 0, + state: PlaybackState::PREPARE, + lack: "".to_string(), + last_traced_at: "1985-04-12T23:20:50.52Z".to_string() + }) } } @@ -41,7 +50,7 @@ impl Device for HeliosDevice { let lack = self.lack.clone(); Status { - last_traced_at: "now".to_string(), + last_traced_at: self.last_traced_at.clone(), properties: vec!["foo".to_string()], playback_state: self.state, capacity: self.sent_points, @@ -61,6 +70,7 @@ impl Device for HeliosDevice { let frame = Frame::new(speed, points.clone()); self.dac.write_frame(frame.clone())?; self.sent_points = points.len() as u16; + self.last_traced_at = Utc::now().to_rfc3339(); Ok(()) }