#![allow(missing_copy_implementations)]
pub mod alpide_word;
pub struct AlpideFrameChipData {
pub(crate) chip_id: u8,
pub(crate) bunch_counter: Option<u8>,
}
impl AlpideFrameChipData {
pub fn from_id(chip_id: u8) -> Self {
Self {
chip_id,
bunch_counter: None,
}
}
pub fn from_id_no_data(chip_id: u8) -> Self {
Self {
chip_id,
bunch_counter: None,
}
}
pub fn store_bc(&mut self, bc: u8) -> Result<(), String> {
if self.bunch_counter.is_some() {
return Err(format!(
"Bunch counter already set for chip {id}, is {current_bc}, tried to set to {new_bc}",
id = self.chip_id,
current_bc = self.bunch_counter.unwrap(),
new_bc = bc
));
}
self.bunch_counter = Some(bc);
Ok(())
}
}