use jt808::models::{Jt808, Jt808BodySerialize, Jt808BodyTrans, Ver808};
use jt_util::{bytes::{IBuffRead, IBuffWrite}, timer_helper::TimeHelper};
use chrono::{Local, TimeZone};
#[derive(Debug, Default)]
pub struct Jt0x9202 {
pub channel: u8,
pub playback_control: u8,
pub multiple: u8,
pub drag_playback_position: i64,
}
impl Jt808BodySerialize for Jt0x9202 {
fn write(&mut self, _ver: &Ver808, buf: &mut dyn IBuffWrite) {
buf.put_u8(self.channel);
buf.put_u8(self.playback_control);
buf.put_u8(self.multiple);
buf.put_slice(&TimeHelper::datetime_to_bcd6(&Local.timestamp(self.drag_playback_position, 0)));
}
fn len(&self, _ver: &Ver808) -> usize {
9
}
}
impl Jt808BodyTrans for Jt0x9202 {
fn fill_new<T>(buf: &mut T, _jt808: &Jt808) -> Self
where
T: IBuffRead,
{
Self {
channel: buf.get_u8(),
playback_control: buf.get_u8(),
multiple: buf.get_u8(),
drag_playback_position: buf.get_dt_bcd6_timestamp()
}
}
}