Orion
high-rate readout
evtcallback.hpp
Go to the documentation of this file.
1 
5 #pragma once
6 
7 #include <cstdint>
8 
9 namespace itk::itkpix::endec {
10 
15 struct EventError {
16 
18  enum error_t {
19  UNDEFINED = 0,
29  TOT_NOHIT_ERROR = 10
30  };
31 
33  uint8_t qcol;
34  uint8_t qrow;
35 
36 };
37 
38 
39 namespace intf {
40 
46 public:
48  virtual ~EventCallback() = default;
49 
52  virtual void evt_init(uint8_t tag) = 0;
53 
56  virtual void evt_next(uint8_t tag) = 0;
57 
59  virtual void evt_done() = 0;
60 
65  virtual void add_hit(uint16_t col, uint16_t row, uint16_t tot) = 0;
66 
72  virtual void add_hmap(uint8_t qcol, uint8_t qrow, uint16_t hmap, uint64_t tots) = 0;
73 
78  virtual void add_qcore(uint8_t qcol, uint8_t qrow, uint64_t qtot) = 0;
79 
83  virtual uint8_t on_error(EventError error) = 0;
84 };
85 
86 } // intf
87 
88 
89 namespace concepts {
90 
91 template<typename T>
92 concept EventCallback =
93  std::destructible<T> and
94  requires(T self, uint8_t tag) {
95  { self.evt_init(tag) } -> std::same_as<void>;
96  { self.evt_next(tag) } -> std::same_as<void>;
97  } and
98  requires(T self) {
99  { self.evt_done() } -> std::same_as<void>;
100  } and
101  requires(T self, uint16_t col, uint16_t row, uint16_t tot) {
102  { self.add_hit(col, row, tot) } -> std::same_as<void>;
103  } and
104  requires(T self, uint8_t qcol, uint8_t qrow, uint16_t hmap, uint64_t tots) {
105  { self.add_hmap(qcol, qrow, hmap, tots) } -> std::same_as<void>;
106  } and
107  requires(T self, uint8_t qcol, uint8_t qrow, uint64_t qtot) {
108  { self.add_qcore(qcol, qrow, qtot) } -> std::same_as<void>;
109  } and
110  requires(T self, EventError error) {
111  { self.on_error(error) } -> std::same_as<uint8_t>;
112  };
113 
114 } // concepts
115 
116 } // itk::itkpix::decoder
Definition: test_fragment.cpp:183
Callback interface for event.
Definition: evtcallback.hpp:45
virtual void evt_done()=0
Complete the event and finalize the stream.
virtual void add_hit(uint16_t col, uint16_t row, uint16_t tot)=0
Add hit.
virtual uint8_t on_error(EventError error)=0
Callback on decoding error.
virtual void add_qcore(uint8_t qcol, uint8_t qrow, uint64_t qtot)=0
Add quarter core: tots are decoded to 64 bit qtot, no-hit marked as 0xF.
virtual ~EventCallback()=default
Destructor.
virtual void evt_init(uint8_t tag)=0
Initialize a new stream and create a new event.
virtual void add_hmap(uint8_t qcol, uint8_t qrow, uint16_t hmap, uint64_t tots)=0
Add quarter core: rawmap is decoded, tots are not decoded.
virtual void evt_next(uint8_t tag)=0
Complete the event and start the next one.
Callback on event decoding error.
Definition: evtcallback.hpp:15
error_t code
error code
Definition: evtcallback.hpp:32
uint8_t qrow
error qrow
Definition: evtcallback.hpp:34
error_t
Decoding errors.
Definition: evtcallback.hpp:18
@ DATA_AFTER_EOS
dropping data after EOS
Definition: evtcallback.hpp:28
@ UNDEFINED
undefined
Definition: evtcallback.hpp:19
@ NO_ZERO_CCOL
no ccol = '000000' at the end of stream
Definition: evtcallback.hpp:21
@ QROW_RANGE_ERROR
qrow out of range
Definition: evtcallback.hpp:24
@ TOT_NOHIT_ERROR
appeared "no hit" ToT = 0xF, which should never appear
Definition: evtcallback.hpp:29
@ TRUNCATED_STREAM
truncated stream
Definition: evtcallback.hpp:22
@ QROW_ORDER_ERROR
incorrect order of qrow
Definition: evtcallback.hpp:26
@ QROW_NOT_ASSIGNED
qrow is not assigned
Definition: evtcallback.hpp:25
@ QCOL_RANGE_ERROR
qcol out of range
Definition: evtcallback.hpp:23
@ DROPPED_FRAMES
dropped 64 bit words
Definition: evtcallback.hpp:20
@ WRONG_STATE_ERROR
wrong state
Definition: evtcallback.hpp:27
uint8_t qcol
error qcol
Definition: evtcallback.hpp:33