再次提交

This commit is contained in:
2024-08-21 14:19:40 +08:00
parent fb3257bb75
commit 6d47134dac
46 changed files with 1170 additions and 468 deletions

View File

@ -0,0 +1,77 @@
use serde::{Deserialize, Serialize};
use serde_with::serde_as;
#[derive(Serialize, Deserialize)]
pub struct RetStruct {
/// 0x00 json 0x01 string 0x02 data binary
pub datatype: u8,
pub content: String,
pub data: IS11DataStruct,
}
#[serde_as]
#[derive(Serialize, Deserialize)]
#[repr(C)]
pub struct IS11DataStruct {
pub datatype: u8, // Using r# to allow the use of the keyword 'type'
pub direction: u8,
pub tuigan_stat: u8,
pub year:u8,
pub month:u8,
pub day:u8,
pub hour:u8,
pub minute:u8,
pub second:u8,
pub shutter_time: u32,
pub index: u64,
pub temprature: [f32; 8],
#[serde_as(as = "[_; 2048]")]
pub data: [f32; 2048],
}
impl Default for IS11DataStruct {
fn default() -> Self {
IS11DataStruct {
datatype: 0,
direction: 10,
tuigan_stat: 0,
year:24,
month:1,
day:1,
hour:0,
minute:0,
second:0,
shutter_time: 0,
index: 0,
temprature: [0.0; 8],
data: [0.0; 2048],
}
}
}
impl IS11DataStruct {
pub fn clone(&self) -> IS11DataStruct {
IS11DataStruct {
datatype: self.datatype,
direction: self.direction,
tuigan_stat: self.tuigan_stat,
year: self.year,
month: self.month,
day: self.day,
hour: self.hour,
minute: self.minute,
second: self.second,
shutter_time: self.shutter_time,
index: self.index,
temprature: self.temprature,
data: self.data,
}
}
}