tof_control/
rb_control.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
pub mod rb_clk;
pub mod rb_config;
pub mod rb_dac;
pub mod rb_gpioe;
pub mod rb_info;
pub mod rb_init;
pub mod rb_input;
pub mod rb_mag;
pub mod rb_mode;
pub mod rb_ph;
pub mod rb_temp;
pub mod rb_vcp;
pub mod rb_reset;

// RBMoniData Implementation
use serde_json;
use crate::helper::rb_type::{RBMoniData, RBInfo, RBTemp, RBVcp, RBPh, RBMag};

impl RBMoniData {
    pub fn new() -> Self {
        Self {
            rb_info: RBInfo::new(),
            rb_temp: RBTemp::new(),
            rb_vcp: RBVcp::new(),
            rb_ph: RBPh::new(),
            rb_mag: RBMag::new(),
        }
    }
    pub fn print(&self) {
        println!("RB Information:");
        println!("{:?}", self.rb_info);
        println!("RB Temperature:");
        println!("{:?}", self.rb_temp);
        println!("RB Voltage, Current and Power:");
        println!("{:?}", self.rb_vcp);
        println!("RB Humidity and Pressure:");
        println!("{:?}", self.rb_ph);
        println!("RB Magnetic Field:");
        println!("{:?}", self.rb_mag);
    }
    pub fn print_json(&self) {
        match serde_json::to_string(self) {
            Ok(rb_moni_json) => {
                println!("{}", rb_moni_json);
            }
            Err(e) => {
                eprintln!("RBMoniData JSON Error: {}", e);
            }
        }
    }
}