Orion
high-rate readout
enccore.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  OutputCallback() {
21  log.trace("dummy.OutputCallback()");
22  }
23 
24  void out_init() override {
25  log.trace("out_init()");
26  }
27 
28  void out_next(uint8_t nbits) override {
29  log.trace("out_next(nbits: {})", nbits);
30  }
31 
32  void out_done(uint8_t nbits) override {
33  log.trace("out_done(nbits: {})", nbits);
34  }
35 
36  void out_data(uint64_t data) override {
37  log.trace("out_data(data: 0x{:016x})", data);
38  }
39 
40  uint8_t on_error(OutputError error) override {
41  log.error("on_error(code: {})", error.code);
42  return 0;
43  }
44 
45 }; // OutputCallback
46 
47 
48 template<typename T>
49 class EncCore {
50 public:
51  using OutputCallback = T;
52 
53  EncCore(Options opt, OutputCallback& cb_out) : opt(opt), cb_out(cb_out) {
54  log.trace("dummy.EncCore(opt, cb_out)");
55  }
56 
57  inline void initialize() {
58  log.trace("initialize()");
59  }
60  inline void finalize() {
61  log.trace("finalize()");
62  }
63 
64  inline void evt_init(uint8_t tag) {
65  log.trace("evt_init(tag: 0x{:02x})", tag);
66  cb_out.out_init();
67  cb_out.out_data(tag);
68  }
69  inline void evt_next(uint8_t tag) {
70  log.trace("evt_next(tag: 0x{:02x})", tag);
71  cb_out.out_next(16);
72  cb_out.out_data(tag);
73  }
74  inline void evt_done() {
75  log.trace("evt_done()");
76  cb_out.out_done(16);
77  }
78  inline void add_hit(uint16_t col, uint16_t row, uint16_t tot) {
79  log.trace("add_hit(col: {}, row: {}, tot: {})", col, row, tot);
80  cb_out.out_data(uint64_t(col) << 32 | row << 16 | tot);
81  }
82  inline void add_hmap(uint8_t qcol, uint8_t qrow, uint16_t hmap, uint64_t tots) {
83  log.trace("add_hmap(qcol: {}, qrow: {}, hmap: 0x{:04x}, tots: 0x{:x})", qcol, qrow, hmap, tots);
84  cb_out.out_data(uint64_t(qcol) << 32 | qrow << 16 | hmap);
85  cb_out.out_data(tots);
86  }
87  inline void add_qcore(uint8_t qcol, uint8_t qrow, uint64_t qtot) {
88  log.trace("add_qcore(qcol: {}, qrow: {}, tots: 0x{:016x})", qcol, qrow, qtot);
89  cb_out.out_data(qcol << 16 | qrow);
90  cb_out.out_data(qtot);
91  }
92 
93  Options opt;
94  OutputCallback& cb_out;
95 
96 }; // EncCore
97 
98 
100 
101 } // itk::itkpix::endec::dummy
Definition: enccore.hpp:49
void out_init() override
Create a new stream and start a new event.
Definition: enccore.hpp:24
void out_next(uint8_t nbits) override
Complete the event and start the next one.
Definition: enccore.hpp:28
uint8_t on_error(OutputError error) override
Callback on encoding error.
Definition: enccore.hpp:40
void out_done(uint8_t nbits) override
Complete the event and finalize the stream.
Definition: enccore.hpp:32
void out_data(uint64_t data) override
Output 64-bit data word for current event.
Definition: enccore.hpp:36
Callback interface for output.
Definition: outcallback.hpp:39
Definition: enccore.hpp:121
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 trace(fmt::format_string< Args... > fmt, Args &&...args)
Logs a message with trace level.
Definition: logger.hpp:132
Templates for ITkPix Encoder Core.
Logger definitions.
Common encoder/decoder options.
Definition: options.hpp:10
Callback on event decoding error.
Definition: outcallback.hpp:15
error_t code
error code
Definition: outcallback.hpp:27