fix: helios status trace time

This commit is contained in:
alban 2023-06-12 21:56:21 +02:00
parent 0f3ee7c54a
commit 9b9e04ad63

View File

@ -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(())
}