gondola_core/tof/
thread_control.rs1use crate::prelude::*;
7
8#[derive(Default, Debug)]
12pub struct ThreadControl {
13 pub stop_flag : bool,
15 pub sigint_recvd : bool,
17 pub end_all_rb_threads : bool,
19 pub calibration_active : bool,
21 pub finished_calibrations : HashMap<u8,bool>,
24 pub calibrations : HashMap<u8, RBCalibrations>,
26 pub holdoff_mtb_thread : bool,
29 pub thread_cmd_dispatch_active : bool,
31 pub thread_data_sink_active : bool,
33 pub thread_runner_active : bool,
35 pub thread_event_bldr_active : bool,
37 pub thread_master_trg_active : bool,
39 pub thread_monitoring_active : bool,
41 pub thread_rbcomm_active : HashMap<u8, bool>,
43 pub thread_signal_hdlr_active : bool,
45 pub run_id : u32,
47 pub n_rbs : u32,
49 #[cfg(feature = "database")]
50 pub rb_list : Vec<ReadoutBoard>,
52 pub verification_active : bool,
54 pub detector_status : TofDetectorStatus,
56 pub write_data_to_disk : bool,
58 pub new_run_start_flag : bool,
62 pub reset_mtb_daq : bool,
64 pub liftof_settings : LiftofSettings,
65}
66
67impl ThreadControl {
68 pub fn new() -> Self {
69 Self {
70 stop_flag : false,
71 calibration_active : false,
72 finished_calibrations : HashMap::<u8,bool>::new(),
73 calibrations : HashMap::<u8, RBCalibrations>::new(),
74 sigint_recvd : false,
75 end_all_rb_threads : false,
76 holdoff_mtb_thread : false,
77 thread_cmd_dispatch_active : false,
78 thread_data_sink_active : false,
79 thread_runner_active : false,
80 thread_event_bldr_active : false,
81 thread_master_trg_active : false,
82 thread_monitoring_active : false,
83 thread_rbcomm_active : HashMap::<u8,bool>::new(),
84 thread_signal_hdlr_active : true,
86 run_id : 0,
87 n_rbs : 0,
88 #[cfg(feature = "database")]
89 rb_list : Vec::<ReadoutBoard>::new(),
90 verification_active : false,
91 detector_status : TofDetectorStatus::new(),
92 write_data_to_disk : false,
93 new_run_start_flag : false,
94 reset_mtb_daq : false,
95 liftof_settings : LiftofSettings::new(),
96 }
97 }
98}
99
100impl fmt::Display for ThreadControl {
101 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
102 let mut repr = String::from("<ThreadControl:");
103 repr += &(format!("\n Run ID : {}", self.run_id));
104 repr += &(format!("\n N RBs : {}", self.n_rbs));
105 repr += &(format!("\n wr to disk : {}", self.write_data_to_disk));
106 repr += "\n -- reported RB calibration activity:";
107 repr += &(format!("\n RB cali active : {}", self.calibration_active));
108 for k in self.finished_calibrations.keys() {
109 repr += &(format!("\n -- finished {} : {}", k, self.finished_calibrations.get(k).unwrap()));
110 }
111 repr += &(format!("\n -- verification run: {}", self.verification_active));
112 repr += "\n -- program status:";
113 repr += &(format!("\n stop flag : {}", self.stop_flag));
114 repr += "\n -- reported thread activity:";
115 repr += &(format!("\n holdoff mtb thr. : {}", self.holdoff_mtb_thread));
116 repr += &(format!("\n cmd dispatcher : {}", self.thread_cmd_dispatch_active));
117 repr += &(format!("\n runner : {}", self.thread_runner_active));
118 repr += &(format!("\n data sink : {}", self.thread_data_sink_active));
119 repr += &(format!("\n monitoring : {}", self.thread_monitoring_active));
120 repr += &(format!("\n evt builder : {}", self.thread_event_bldr_active));
121 repr += &(format!("\n master_trigger : {}", self.thread_master_trg_active));
122 if self.thread_rbcomm_active.len() > 0 {
123 repr += "\n -- active RB threads";
124 for k in self.thread_rbcomm_active.keys() {
125 repr += &(format!("\n -- -- {} : {}", k, self.thread_rbcomm_active.get(k).unwrap()));
126 }
127 }
128 repr += &(format!("\n master trig : {}>", self.thread_master_trg_active));
129 write!(f, "{}", repr)
130 }
131}
132