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 pub lost_event_ids : f32,
67}
68
69impl ThreadControl {
70 pub fn new() -> Self {
71 Self {
72 stop_flag : false,
73 calibration_active : false,
74 finished_calibrations : HashMap::<u8,bool>::new(),
75 calibrations : HashMap::<u8, RBCalibrations>::new(),
76 sigint_recvd : false,
77 end_all_rb_threads : false,
78 holdoff_mtb_thread : false,
79 thread_cmd_dispatch_active : false,
80 thread_data_sink_active : false,
81 thread_runner_active : false,
82 thread_event_bldr_active : false,
83 thread_master_trg_active : false,
84 thread_monitoring_active : false,
85 thread_rbcomm_active : HashMap::<u8,bool>::new(),
86 thread_signal_hdlr_active : true,
88 run_id : 0,
89 n_rbs : 0,
90 #[cfg(feature = "database")]
91 rb_list : Vec::<ReadoutBoard>::new(),
92 verification_active : false,
93 detector_status : TofDetectorStatus::new(),
94 write_data_to_disk : false,
95 new_run_start_flag : false,
96 reset_mtb_daq : false,
97 liftof_settings : LiftofSettings::new(),
98 lost_event_ids : 0.0,
99 }
100 }
101}
102
103impl fmt::Display for ThreadControl {
104 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
105 let mut repr = String::from("<ThreadControl:");
106 repr += &(format!("\n Run ID : {}", self.run_id));
107 repr += &(format!("\n N RBs : {}", self.n_rbs));
108 repr += &(format!("\n wr to disk : {}", self.write_data_to_disk));
109 repr += "\n -- reported RB calibration activity:";
110 repr += &(format!("\n RB cali active : {}", self.calibration_active));
111 for k in self.finished_calibrations.keys() {
112 repr += &(format!("\n -- finished {} : {}", k, self.finished_calibrations.get(k).unwrap()));
113 }
114 repr += &(format!("\n -- verification run: {}", self.verification_active));
115 repr += "\n -- program status:";
116 repr += &(format!("\n stop flag : {}", self.stop_flag));
117 repr += "\n -- reported thread activity:";
118 repr += &(format!("\n holdoff mtb thr. : {}", self.holdoff_mtb_thread));
119 repr += &(format!("\n cmd dispatcher : {}", self.thread_cmd_dispatch_active));
120 repr += &(format!("\n runner : {}", self.thread_runner_active));
121 repr += &(format!("\n data sink : {}", self.thread_data_sink_active));
122 repr += &(format!("\n monitoring : {}", self.thread_monitoring_active));
123 repr += &(format!("\n evt builder : {}", self.thread_event_bldr_active));
124 repr += &(format!("\n master_trigger : {}", self.thread_master_trg_active));
125 if self.thread_rbcomm_active.len() > 0 {
126 repr += "\n -- active RB threads";
127 for k in self.thread_rbcomm_active.keys() {
128 repr += &(format!("\n -- -- {} : {}", k, self.thread_rbcomm_active.get(k).unwrap()));
129 }
130 }
131 repr += &(format!("\n master trig : {}>", self.thread_master_trg_active));
132 write!(f, "{}", repr)
133 }
134}
135