Orion
high-rate readout
deccore.hpp
Go to the documentation of this file.
1 // ╭─╮╭─╴╷╭─╮┌─╮
2 // ╰─╯╵ ╵╰─╯╵ ╵
8 #pragma once
9 
10 #include "itk/logger.hpp"
12 
13 
14 namespace itk::itkpix::endec::dummy {
15 
16 extern itk::Logger log;
17 
19 public:
20 
21  EventCallback() = default;
22 
23  void evt_init(uint8_t tag) override {
24  log.debug("evt_init(tag: 0x{:02x})", tag);
25  }
26  void evt_next(uint8_t tag) override {
27  log.debug("evt_next(tag: 0x{:02x})", tag);
28  }
29  void evt_done() override {
30  log.debug("evt_done");
31  }
32  void add_hit(uint16_t col, uint16_t row, uint16_t tot) override {
33  log.trace("add_hit(col: {}, row: {}, tot: {})", col, row, tot);
34  }
35  void add_hmap(uint8_t qcol, uint8_t qrow, uint16_t hmap, uint64_t tots) override {
36  log.trace("add_hit(qcol: {}, qrow: {}, hmap: 0x{:04x}, tot: 0x{:016x})", qcol, qrow, hmap, tots);
37  }
38  void add_qcore(uint8_t qcol, uint8_t qrow, uint64_t qtot) override {
39  log.trace("add_qcore(qcol: {}, qrow: {}, tot: 0x{:016x})", qcol, qrow, qtot);
40  }
41  uint8_t on_error(EventError error) override {
42  log.error("evt_error(code: {})", error.code);
43  return 0;
44  }
45 };
46 
47 
48 template<typename T, int cb_type = 0>
49 class DecCore {
50 public:
51  using EventCallback = T;
52 
53  DecCore(Options opt, EventCallback& cb_evt) : opt(opt), cb_evt(cb_evt) {
54  log.info("dummy.DecCore(opt, evt, type: {})", cb_type);
55  }
56 
57  inline void initialize() {
58  log.debug("initialize()");
59  }
60  inline void finalize() {
61  log.debug("finalize()");
62  }
63  inline void decode(uint64_t data64) {
64  log.debug("decode(data64: 0x{:016x})", data64);
65  }
66  inline void decode(const uint8_t *buff, size_t size) {
67  log.debug("decode(buff) | size64: {}", size);
68  for (uint i = 0; i < size; i++) {
69  log.trace(" 0x{:02x}", buff[i]);
70  }
71  }
72  inline void decode(const uint64_t *buff64, size_t size64) {
73  log.debug("decode(buff64) | size64: {}", size64);
74  for (uint i = 0; i < size64; i++) {
75  log.trace(" 0x{:016x}", buff64[i]);
76  }
77  log.debug("example of cb_evt callbacks:");
78  cb_evt.evt_init(0x10);
79  cb_evt.add_hit(1, 2, 3);
80  cb_evt.evt_done();
81  }
82 
83  Options opt;
84  EventCallback& cb_evt;
85 };
86 
87 template<int cb_type>
89 
90 } // itk::decoder::decoder::dummy
Definition: test_enc_dec.cpp:117
Definition: deccore.hpp:49
void add_hmap(uint8_t qcol, uint8_t qrow, uint16_t hmap, uint64_t tots) override
Add quarter core: rawmap is decoded, tots are not decoded.
Definition: deccore.hpp:35
uint8_t on_error(EventError error) override
Callback on decoding error.
Definition: deccore.hpp:41
void evt_init(uint8_t tag) override
Initialize a new stream and create a new event.
Definition: deccore.hpp:23
void evt_next(uint8_t tag) override
Complete the event and start the next one.
Definition: deccore.hpp:26
void evt_done() override
Complete the event and finalize the stream.
Definition: deccore.hpp:29
void add_hit(uint16_t col, uint16_t row, uint16_t tot) override
Add hit.
Definition: deccore.hpp:32
void add_qcore(uint8_t qcol, uint8_t qrow, uint64_t qtot) override
Add quarter core: tots are decoded to 64 bit qtot, no-hit marked as 0xF.
Definition: deccore.hpp:38
Callback interface for event.
Definition: evtcallback.hpp:45
Definition: deccore.hpp:128
Logger class definition, wrapper around CoreLogger, adds templated methods for different logging leve...
Definition: logger.hpp:108
void error(fmt::format_string< Args... > fmt, Args &&...args)
Logs a message with error level.
Definition: logger.hpp:164
void debug(fmt::format_string< Args... > fmt, Args &&...args)
Logs a message with debug level.
Definition: logger.hpp:140
void info(fmt::format_string< Args... > fmt, Args &&...args)
Logs a message with information level.
Definition: logger.hpp:148
void trace(fmt::format_string< Args... > fmt, Args &&...args)
Logs a message with trace level.
Definition: logger.hpp:132
uint16_t size
Definition: fragheader.hpp:5
Templates for ITkPix Decoder.
Logger definitions.
Callback on event decoding error.
Definition: evtcallback.hpp:15
error_t code
error code
Definition: evtcallback.hpp:32
Common encoder/decoder options.
Definition: options.hpp:10