1use crate::prelude::*;
5
6#[derive(Debug, Copy, Clone, PartialEq)]
8#[cfg_attr(feature="pybindings", pyclass)]
9pub struct GcuEvBldStatsMoniData {
10 pub num_bytes_190 : u32,
11 pub num_bytes_90 : u32,
12 pub num_bytes_191 : u32,
13 pub num_bytes_192 : u32,
14 pub num_events_in_queue : u32,
15 pub num_tracker_packets_all : u32,
16 pub num_tracker_packets_usable : u32,
17 pub num_tof_packets_all : u32,
18 pub num_tof_packets_usable : u32,
19 pub milliseconds : u16,
20 pub num_events_90 : u16, pub num_events_190 : u16, pub num_events_191 : u16, pub num_events_192 : u16, pub num_pack_fails : u16,
25 pub num_events_tof_only : u16,
26 pub num_events_tracker_only : u16,
27 pub num_events_tracker_and_tof : u16,
28 pub version : u8,
29 pub pad1 : u8,
30
31 pub timestamp : u64,
33 pub board_id : u8,
34}
35
36impl GcuEvBldStatsMoniData {
37
38 pub fn new() -> Self {
39 Self {
40 num_bytes_190 : 0,
41 num_bytes_90 : 0,
42 num_bytes_191 : 0,
43 num_bytes_192 : 0,
44 num_events_in_queue : 0,
45 num_tracker_packets_all : 0,
46 num_tracker_packets_usable : 0,
47 num_tof_packets_all : 0,
48 num_tof_packets_usable : 0,
49 milliseconds : 0,
50 num_events_90 : 0, num_events_190 : 0, num_events_191 : 0, num_events_192 : 0, num_pack_fails : 0,
55 num_events_tof_only : 0,
56 num_events_tracker_only : 0,
57 num_events_tracker_and_tof : 0,
58 version : 1,
59 pad1 : 0,
60 timestamp : 0,
61 board_id : 0
62 }
63 }
64}
65
66impl fmt::Display for GcuEvBldStatsMoniData {
67 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
68 let mut repr = String::from("<GcuEvBldStatsMoniData:");
69 repr += &(format!("\n num_bytes_190 : {}", self.num_bytes_190 ));
70 repr += &(format!("\n num_bytes_90 : {}", self.num_bytes_90 ));
71 repr += &(format!("\n num_bytes_191 : {}", self.num_bytes_191 ));
72 repr += &(format!("\n num_bytes_192 : {}", self.num_bytes_192 ));
73 repr += &(format!("\n num_events_in_queue : {}", self.num_events_in_queue ));
74 repr += &(format!("\n num_tracker_packets_all : {}", self.num_tracker_packets_all ));
75 repr += &(format!("\n num_tracker_packets_usable : {}", self.num_tracker_packets_usable));
76 repr += &(format!("\n num_tof_packets_all : {}", self.num_tof_packets_all ));
77 repr += &(format!("\n num_tof_packets_usable : {}", self.num_tof_packets_usable ));
78 repr += &(format!("\n milliseconds : {}", self.milliseconds ));
79 repr += &(format!("\n num_events_90 : {}", self.num_events_90 ));
80 repr += &(format!("\n num_events_190 : {}", self.num_events_190 ));
81 repr += &(format!("\n num_events_191 : {}", self.num_events_191 ));
82 repr += &(format!("\n num_events_192 : {}", self.num_events_192 ));
83 repr += &(format!("\n num_pack_fails : {}", self.num_pack_fails ));
84 repr += &(format!("\n num_events_tof_only : {}", self.num_events_tof_only ));
85 repr += &(format!("\n num_events_tracker_only : {}", self.num_events_tracker_only ));
86 repr += &(format!("\n num_events_tracker_and_tof : {}", self.num_events_tracker_and_tof));
87 repr += &(format!("\n version : {}", self.version ));
88 repr += &(format!("\n pad1 : {}", self.pad1 ));
89 write!(f, "{}", repr)
90 }
91}
92
93#[cfg(feature = "random")]
94impl FromRandom for GcuEvBldStatsMoniData {
95
96 fn from_random() -> Self {
97 let mut moni = Self::new();
98 let mut rng = rand::rng();
99 moni.num_bytes_190 = rng.random::<u32>();
100 moni.num_bytes_90 = rng.random::<u32>();
101 moni.num_bytes_191 = rng.random::<u32>();
102 moni.num_bytes_192 = rng.random::<u32>();
103 moni.num_events_in_queue = rng.random::<u32>();
104 moni.num_tracker_packets_all = rng.random::<u32>();
105 moni.num_tracker_packets_usable = rng.random::<u32>();
106 moni.num_tof_packets_all = rng.random::<u32>();
107 moni.num_tof_packets_usable = rng.random::<u32>();
108 moni.milliseconds = rng.random::<u16>();
109 moni.num_events_90 = rng.random::<u16>(); moni.num_events_190 = rng.random::<u16>(); moni.num_events_191 = rng.random::<u16>(); moni.num_events_192 = rng.random::<u16>(); moni.num_pack_fails = rng.random::<u16>();
114 moni.num_events_tof_only = rng.random::<u16>();
115 moni.num_events_tracker_only = rng.random::<u16>();
116 moni.num_events_tracker_and_tof = rng.random::<u16>();
117 moni.pad1 = rng.random::<u8>();
119 moni.timestamp = rng.random::<u64>();
120 moni
121 }
122}
123
124impl Default for GcuEvBldStatsMoniData {
125 fn default() -> Self {
126 Self::new()
127 }
128}
129
130impl Serialization for GcuEvBldStatsMoniData {
131
132 const SIZE : usize = 18;
133
134 fn from_bytestream(stream : &Vec<u8>,
135 pos : &mut usize)
136 -> Result<Self, SerializationError> {
137 if stream.len() < Self::SIZE {
138 return Err(SerializationError::StreamTooShort);
139 };
140 let mut moni = Self::new();
141 moni.num_bytes_190 = parse_u32(stream, pos);
142 moni.num_bytes_90 = parse_u32(stream, pos);
143 moni.num_bytes_191 = parse_u32(stream, pos);
144 moni.num_bytes_192 = parse_u32(stream, pos);
145 moni.num_events_in_queue = parse_u32(stream, pos);
146 moni.num_tracker_packets_all = parse_u32(stream, pos);
147 moni.num_tracker_packets_usable = parse_u32(stream, pos);
148 moni.num_tof_packets_all = parse_u32(stream, pos);
149 moni.num_tof_packets_usable = parse_u32(stream, pos);
150 moni.milliseconds = parse_u16(stream, pos);
151 moni.num_events_90 = parse_u16(stream, pos);
152 moni.num_events_190 = parse_u16(stream, pos);
153 moni.num_events_191 = parse_u16(stream, pos);
154 moni.num_events_192 = parse_u16(stream, pos);
155 moni.num_pack_fails = parse_u16(stream, pos);
156 moni.num_events_tof_only = parse_u16(stream, pos);
157 moni.num_events_tracker_only = parse_u16(stream, pos);
158 moni.num_events_tracker_and_tof = parse_u16(stream, pos);
159 moni.version = parse_u8(stream, pos);
160 moni.pad1 = parse_u8(stream, pos);
161 Ok(moni)
162 }
163}
164
165impl MoniData for GcuEvBldStatsMoniData {
166
167 fn get_board_id(&self) -> u8 {
168 return self.board_id;
169 }
170
171 fn get_timestamp(&self) -> u64 {
172 self.timestamp
173 }
174
175 fn set_timestamp(&mut self, ts: u64) {
176 self.timestamp = ts;
177 }
178
179 fn keys() -> Vec<&'static str> {
180 vec!["board_id", "sip_id",
181 "num_bytes_190" , "num_bytes_90" , "num_bytes_191" , "num_bytes_192" ,
182 "num_events_in_queue" , "num_tracker_packets_all" , "num_tracker_packets_usable", "num_tof_packets_all",
183 "num_tof_packets_usable" , "milliseconds" , "num_events_90" , "num_events_190" ,
184 "num_events_191" , "num_events_192" , "num_pack_fails" , "num_events_tof_only",
185 "num_events_tracker_only", "num_events_tracker_and_tof" , "version" , "pad1" ,
186 "timestamp"]
187 }
188
189
190
191
192
193 fn get(&self, varname : &str) -> Option<f32> {
194 match varname {
195 "board_id" => Some(self.board_id as f32),
196 "num_bytes_190" => Some(self.num_bytes_190 as f32),
197 "num_bytes_90" => Some(self.num_bytes_90 as f32),
198 "num_bytes_191" => Some(self.num_bytes_191 as f32),
199 "num_bytes_192" => Some(self.num_bytes_192 as f32),
200 "num_events_in_queue" => Some(self.num_events_in_queue as f32),
201 "num_tracker_packets_all" => Some(self.num_tracker_packets_all as f32),
202 "num_tracker_packets_usable" => Some(self.num_tracker_packets_usable as f32),
203 "num_tof_packets_all" => Some(self.num_tof_packets_all as f32),
204 "num_tof_packets_usable" => Some(self.num_tof_packets_usable as f32),
205 "milliseconds" => Some(self.milliseconds as f32),
206 "num_events_90" => Some(self.num_events_90 as f32),
207 "num_events_190" => Some(self.num_events_190 as f32),
208 "num_events_191" => Some(self.num_events_191 as f32),
209 "num_events_192" => Some(self.num_events_192 as f32),
210 "num_pack_fails" => Some(self.num_pack_fails as f32),
211 "num_events_tof_only" => Some(self.num_events_tof_only as f32),
212 "num_events_tracker_only" => Some(self.num_events_tracker_only as f32),
213 "num_events_tracker_and_tof" => Some(self.num_events_tracker_and_tof as f32),
214 "version" => Some(self.version as f32),
215 "pad1" => Some(self.pad1 as f32),
216 "timestamp" => Some(self.timestamp as f32),
217 _ => None
218 }
219 }
220}
221
222impl TelemetryPackable for GcuEvBldStatsMoniData {
223 const TEL_PACKET_TYPE : TelemetryPacketType = TelemetryPacketType::GcuEvtBuilderStats;
224}
225
226moniseries_telemetry!(GcuEvBldStatsMoniDataSeries, GcuEvBldStatsMoniData);
227
228#[cfg(feature="pybindings")]
229pythonize_monidata!(GcuEvBldStatsMoniData);
230
231#[cfg(feature="pybindings")]
232pythonize_telemetry_only!(GcuEvBldStatsMoniData);
233