gondola_core/monitoring/
run_statistics.rs1use crate::prelude::*;
5
6#[derive(Debug, Copy, Clone)]
8#[cfg_attr(feature="pybindings",pyclass)]
9pub struct RunStatistics {
10 pub n_events_rec : usize,
12 pub evproc_npack : usize,
15 pub first_evid : u32,
17 pub last_evid : u32,
19 pub n_err_deser : usize,
22 pub n_err_zmq_send : usize,
25 pub n_err_chid_wrong : usize,
28 pub n_err_tail_wrong : usize,
31 pub n_err_crc32_wrong : usize,
33}
34
35impl RunStatistics {
36
37 pub fn new() -> Self {
38 Self {
39 n_events_rec : 0,
40 evproc_npack : 0,
41 first_evid : 0,
42 last_evid : 0,
43 n_err_deser : 0,
44 n_err_zmq_send : 0,
45 n_err_chid_wrong : 0,
46 n_err_tail_wrong : 0,
47 n_err_crc32_wrong : 0,
48 }
49 }
50
51 pub fn get_n_anticipated(&self) -> i32 {
52 self.last_evid as i32 - self.first_evid as i32
53 }
54}
55
56impl fmt::Display for RunStatistics {
57 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
58 let mut resp = String::from("<RunStatistics:\n");
59 resp += &(format!(" first event id : {}\n", self.first_evid));
60 resp += &(format!(" last event id : {}\n", self.last_evid));
61 resp += &(format!(" --> expected {} event (ids)\n", self.get_n_anticipated()));
62 resp += &(format!(" event_processing #packets : {}\n", self.evproc_npack));
63 if self.get_n_anticipated() != self.evproc_npack as i32 {
64 resp += &(format!(" --> discrepancy of {} event (ids)\n", self.get_n_anticipated() - self.evproc_npack as i32))
65 }
66 resp += &(format!(" event_processing n tail err : {}\n", self.n_err_tail_wrong));
67 resp += &(format!(" event_processing n chid err : {}\n", self.n_err_chid_wrong));
68 write!(f, "{}", resp)
69 }
70}
71
72#[cfg(feature="pybindings")]
73pythonize!(RunStatistics);