use epics_macros::EpicsRecord;

#[derive(EpicsRecord)]
#[record(type = "bi")]
pub struct BiRecord {
    #[field(type = "Enum")]
    pub val: u16,
    #[field(type = "String")]
    pub znam: String,
    #[field(type = "String")]
    pub onam: String,
    #[field(type = "Short")]
    pub zsv: i16,
    #[field(type = "Short")]
    pub osv: i16,
    #[field(type = "Short")]
    pub cosv: i16,
    #[field(type = "Short")]
    pub simm: i16,
    #[field(type = "String")]
    pub siml: String,
    #[field(type = "String")]
    pub siol: String,
    #[field(type = "Short")]
    pub sims: i16,
}

impl Default for BiRecord {
    fn default() -> Self {
        Self {
            val: 0,
            znam: String::new(),
            onam: String::new(),
            zsv: 0,
            osv: 0,
            cosv: 0,
            simm: 0,
            siml: String::new(),
            siol: String::new(),
            sims: 0,
        }
    }
}

impl BiRecord {
    pub fn new(val: u16) -> Self {
        Self {
            val,
            ..Default::default()
        }
    }
}
