Jpp 19.3.0-rc.2
the software that should make you happy
Loading...
Searching...
No Matches
JDAQFrameStatus.hh
Go to the documentation of this file.
1#ifndef __JDAQFRAMESTATUS__
2#define __JDAQFRAMESTATUS__
3
7
8
9/**
10 * \author mdejong
11 */
12namespace KM3NETDAQ {
13
14 /**
15 * DAQ frame status.
16 */
18 public:
19
22 friend JWriter& operator<<(JWriter&, const JDAQFrameStatus&);
23
24 /**
25 * Default constructor.
26 */
28 daq (0),
29 status (0),
30 fifo (0),
31 status_3(0),
32 status_4(0)
33 {}
34
35
36 /**
37 * Constructor.
38 *
39 * \param __daq DAQ status
40 * \param __status TDC status
41 * \param __fifo FIFO status
42 * \param __status_3 spare
43 * \param __status_4 spare
44 */
45 JDAQFrameStatus(const int __daq,
46 const int __status,
47 const int __fifo,
48 const int __status_3 = 0,
49 const int __status_4 = 0) :
50 daq (__daq),
51 status (__status),
52 fifo (__fifo),
53 status_3(__status_3),
54 status_4(__status_4)
55 {}
56
57
58 /**
59 * Get reference to unique instance of this class object.
60 *
61 * This instance has default values which correspond to a valid DAQ frame status.
62 *
63 * \return reference to this class object
64 */
73
74
75 /**
76 * Get DAQ frame status.
77 *
78 * \return DAQ frame status
79 */
81 {
82 return static_cast<const JDAQFrameStatus&>(*this);
83 }
84
85
86 /**
87 * Set DAQ frame status.
88 *
89 * \param status DAQ frame status
90 */
92 {
93 static_cast<JDAQFrameStatus&>(*this) = status;
94 }
95
96
97 /**
98 * Get DAQ status.
99 *
100 * \return DAQ status
101 */
102 int getDAQStatus() const
103 {
104 return this->daq;
105 }
106
107
108 /**
109 * Get TDC and White Rabbit status.
110 *
111 * \return status
112 */
113 int getStatus() const
114 {
115 return this->status;
116 }
117
118
119 /**
120 * Get FIFO status.
121 *
122 * \return FIFO status
123 */
124 int getFIFOStatus() const
125 {
126 return this->fifo;
127 }
128
129
130 /**
131 * Test DAQ status of packets.
132 *
133 * \return true if okay; else false
134 */
135 bool testDAQStatus() const
136 {
138 }
139
140
141 /**
142 * Test TDC and White Rabbit status.
143 *
144 * \return true if okay; else false
145 */
146 bool testStatus() const
147 {
149 }
150
151
152 /**
153 * Get number of received UDP packets.
154 *
155 * \return UDP received packets
156 */
158 {
159 return DAQ_UDP_RECEIVED_PACKETS.read(this->daq);
160 }
161
162
163 /**
164 * Get maximal sequence number of UDP packet.
165 *
166 * \return UDP sequence number
167 */
169 {
170 return DAQ_UDP_SEQUENCE_NUMBER.read(this->daq);
171 }
172
173
174 /**
175 * Test White Rabbit status.
176 *
177 * \return true if okay; else false
178 */
180 {
181 return DAQ_WHITE_RABBIT.has(this->status);
182 }
183
184
185 /**
186 * Test TDC status.
187 *
188 * \return true if okay; else false
189 */
190 bool testTDCStatus() const
191 {
192 return !testHighRateVeto();
193 }
194
195
196 /**
197 * Test high-rate veto status.
198 *
199 * \return true if one of the TDCs is high-rate vetoed; else false
200 */
201 bool testHighRateVeto() const
202 {
203 return DAQ_TDC.has(this->status);
204 }
205
206
207 /**
208 * Test high-rate veto status.
209 *
210 * \param tdc TDC
211 * \return true if TDC is high-rate vetoed; else false
212 */
213 bool testHighRateVeto(const int tdc) const
214 {
215 return JBit(tdc).has(this->status);
216 }
217
218
219 /**
220 * Count high-rate veto status.
221 *
222 * \return number of the TDCs with high-rate veto
223 */
225 {
226 int n = 0;
227
228 if (testHighRateVeto()) {
229 for (int pmt = 0; pmt != NUMBER_OF_PMTS; ++pmt) {
230 if (JBit(pmt).has(this->status)) {
231 ++n;
232 }
233 }
234 }
235
236 return n;
237 }
238
239
240 /**
241 * Test FIFO status.
242 *
243 * \return true if one of the TDCs has FIFO almost full; else false
244 */
245 bool testFIFOStatus() const
246 {
247 return DAQ_FIFO.has(this->fifo);
248 }
249
250
251 /**
252 * Test FIFO status.
253 *
254 * \param tdc TDC
255 * \return true if FIFO is almost full; else false
256 */
257 bool testFIFOStatus(const int tdc) const
258 {
259 return JBit(tdc).has(this->fifo);
260 }
261
262
263 /**
264 * Count FIFO status.
265 *
266 * \return number of the TDCs with FIFO almost full
267 */
268 int countFIFOStatus() const
269 {
270 int n = 0;
271
272 if (testFIFOStatus()) {
273 for (int pmt = 0; pmt != NUMBER_OF_PMTS; ++pmt) {
274 if (JBit(pmt).has(this->fifo)) {
275 ++n;
276 }
277 }
278 }
279
280 return n;
281 }
282
283 /**
284 * Count active channels.
285 * \return number of TDCs without high rate veto or FIFO almost full
286 */
288 {
289 int n = NUMBER_OF_PMTS;
290
291 if (testHighRateVeto() || testFIFOStatus()) {
292 for (int pmt = 0; pmt != NUMBER_OF_PMTS; ++pmt) {
293 if ( JBit(pmt).has(this->status) || JBit(pmt).has(this->fifo) ) {
294 --n;
295 }
296 }
297 }
298
299 return n;
300
301 }
302
303
304 /**
305 * Get UDP trailer status.
306 *
307 * \return true if UDP trailer present; else false
308 */
309 bool hasUDPTrailer() const
310 {
311 return DAQ_UDP_TRAILER.has(this->fifo);
312 }
313
314
315 /**
316 * Set high-rate veto.
317 *
318 * \param tdc TDC
319 * \param value value
320 */
321 void setHighRateVeto(const int tdc, const bool value)
322 {
323 JBit(tdc).set(this->status, value);
324 }
325
326
328
329 protected:
330 int daq; // DAQ status
331 int status; // TDC status
332 int fifo; // FIFO status
333 int status_3; // spare
334 int status_4; // spare
335 };
336
337
338 /**
339 * Equal operator for DAQ frame status.
340 *
341 * \param first frame status
342 * \param second frame status
343 * \result true if first frame status equal to second; else false
344 */
345 inline bool operator==(const JDAQFrameStatus& first,
346 const JDAQFrameStatus& second)
347 {
348 return (first.getDAQStatus() == second.getDAQStatus() &&
349 first.getStatus() == second.getStatus() &&
350 first.getFIFOStatus() == second.getFIFOStatus());
351 }
352
353
354 /**
355 * Not-equal operator for DAQ frame status.
356 *
357 * \param first frame status
358 * \param second frame status
359 * \result true if first frame status not equal to second; else false
360 */
361 inline bool operator!=(const JDAQFrameStatus& first,
362 const JDAQFrameStatus& second)
363 {
364 return !(first == second);
365 }
366}
367
368#endif
KM3NeT DAQ constants, bit handling, etc.
Interface for binary input.
Interface for binary output.
ClassDefNV(JDAQFrameStatus, 1)
JDAQFrameStatus()
Default constructor.
JDAQFrameStatus(const int __daq, const int __status, const int __fifo, const int __status_3=0, const int __status_4=0)
Constructor.
bool testTDCStatus() const
Test TDC status.
bool testFIFOStatus() const
Test FIFO status.
int countHighRateVeto() const
Count high-rate veto status.
int getUDPNumberOfReceivedPackets() const
Get number of received UDP packets.
bool testWhiteRabbitStatus() const
Test White Rabbit status.
const JDAQFrameStatus & getDAQFrameStatus() const
Get DAQ frame status.
int getFIFOStatus() const
Get FIFO status.
bool testFIFOStatus(const int tdc) const
Test FIFO status.
bool testStatus() const
Test TDC and White Rabbit status.
friend JReader & operator>>(JReader &, JDAQFrameStatus &)
Read DAQ frame status from input.
int getStatus() const
Get TDC and White Rabbit status.
static const JDAQFrameStatus & getInstance()
Get reference to unique instance of this class object.
friend JWriter & operator<<(JWriter &, const JDAQFrameStatus &)
Write DAQ frame status to output.
void setHighRateVeto(const int tdc, const bool value)
Set high-rate veto.
int countFIFOStatus() const
Count FIFO status.
bool hasUDPTrailer() const
Get UDP trailer status.
int countActiveChannels() const
Count active channels.
bool testHighRateVeto() const
Test high-rate veto status.
void setDAQFrameStatus(const JDAQFrameStatus &status)
Set DAQ frame status.
bool testDAQStatus() const
Test DAQ status of packets.
int getDAQStatus() const
Get DAQ status.
int getUDPMaximalSequenceNumber() const
Get maximal sequence number of UDP packet.
bool testHighRateVeto(const int tdc) const
Test high-rate veto status.
bool operator==(const Head &first, const Head &second)
Equal operator.
Definition JHead.hh:1801
bool operator!=(const JTag &first, const JTag &second)
Not equal operator for JTag.
Definition JTag.hh:291
const int n
Definition JPolint.hh:791
KM3NeT DAQ data structures and auxiliaries.
Definition DataQueue.cc:39
static const JBits DAQ_UDP_RECEIVED_PACKETS(0, 15)
Mask of UDP received packets.
static const JBits DAQ_TDC(0, 30)
TDC high-rate veto status.
static const JBits DAQ_UDP_SEQUENCE_NUMBER(16, 31)
Mask of UDP sequence number.
static const JBits DAQ_FIFO(0, 30)
FIFO almost full bits.
static const int NUMBER_OF_PMTS
Total number of PMTs in module.
Definition JDAQ.hh:26
static const JBit DAQ_WHITE_RABBIT(31)
White Rabbit status.
static const JBit DAQ_UDP_TRAILER(31)
UDP trailer.
size_t getSizeof< JDAQFrameStatus >()
Get size of type.
Auxiliary data structure for single bit.
Definition JDAQ.hh:36
int write(const int value) const
Write given value as bit mask.
Definition JDAQ.hh:115
void set(int &mask) const
Set bit in given bit mask.
Definition JDAQ.hh:77
bool has(const int mask) const
Test bit.
Definition JDAQ.hh:139
int write(const int value) const
Write given value as bit mask.
Definition JDAQ.hh:238
int read(const int mask) const
Read given bit mask as value.
Definition JDAQ.hh:250
bool has(const int mask) const
Test bit mask.
Definition JDAQ.hh:262