tof_control/helper/
pa_type.rs

1use serde::{Deserialize, Serialize};
2
3/// PA Data Type
4// All PA Monitoring Types
5#[derive(Debug, Serialize, Deserialize)]
6pub struct PAMoniData {
7    pub pa_temp: PATemp,
8    pub pa_bias: PAReadBias,
9}
10// PA Temperature Data Type
11#[derive(Debug, Serialize, Deserialize)]
12pub struct PATemp {
13    pub pa_temps: [f32; 16],
14}
15// PA Read SiPM Bias Voltages
16#[derive(Debug, Serialize, Deserialize)]
17pub struct PAReadBias {
18    pub read_biases: [f32; 16],
19}
20// PA Set SiPM Bias Voltages
21#[derive(Debug, Serialize, Deserialize)]
22pub struct PASetBias {
23    pub set_biases: [f32; 16],
24}
25
26/// PA Error Type
27#[derive(Debug)]
28pub enum PAError {
29    // I2C Error
30    I2C(i2cdev::linux::LinuxI2CError),
31    // PB Error
32    PBError(crate::helper::pb_type::PBError),
33}
34
35impl std::fmt::Display for PAError {
36    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
37        write!(f, "PAError")
38    }
39}
40
41impl From<i2cdev::linux::LinuxI2CError> for PAError {
42    fn from(e: i2cdev::linux::LinuxI2CError) -> Self {
43        PAError::I2C(e)
44    }
45}
46
47impl From<crate::helper::pb_type::PBError> for PAError {
48    fn from(e: crate::helper::pb_type::PBError) -> Self {
49        PAError::PBError(e)
50    }
51}