tof_control/helper/
pa_type.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
use serde::{Deserialize, Serialize};

/// PA Data Type
// All PA Monitoring Types
#[derive(Debug, Serialize, Deserialize)]
pub struct PAMoniData {
    pub pa_temp: PATemp,
    pub pa_bias: PAReadBias,
}
// PA Temperature Data Type
#[derive(Debug, Serialize, Deserialize)]
pub struct PATemp {
    pub pa_temps: [f32; 16],
}
// PA Read SiPM Bias Voltages
#[derive(Debug, Serialize, Deserialize)]
pub struct PAReadBias {
    pub read_biases: [f32; 16],
}
// PA Set SiPM Bias Voltages
#[derive(Debug, Serialize, Deserialize)]
pub struct PASetBias {
    pub set_biases: [f32; 16],
}

/// PA Error Type
#[derive(Debug)]
pub enum PAError {
    // I2C Error
    I2C(i2cdev::linux::LinuxI2CError),
    // PB Error
    PBError(crate::helper::pb_type::PBError),
}

impl std::fmt::Display for PAError {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        write!(f, "PAError")
    }
}

impl From<i2cdev::linux::LinuxI2CError> for PAError {
    fn from(e: i2cdev::linux::LinuxI2CError) -> Self {
        PAError::I2C(e)
    }
}

impl From<crate::helper::pb_type::PBError> for PAError {
    fn from(e: crate::helper::pb_type::PBError) -> Self {
        PAError::PBError(e)
    }
}