
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 nca:u8,
    pub ncb:u8,
    pub ncc: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,
            nca:0,
            ncb:0,
            ncc: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,
            nca:self.nca,
            ncb:self.ncb,
            ncc:self.ncc,

            shutter_time: self.shutter_time,
            index: self.index,
            temprature: self.temprature,
            data: self.data,
        }
    }
    
}
