Orion
high-rate readout
enccore.hpp
Go to the documentation of this file.
1 // ╭─╮╭─╴╷╭─╮┌─╮
2 // ╰─╯╵ ╵╰─╯╵ ╵
8 #pragma once
9 
10 #include <functional>
11 
12 #include "itk/logger.hpp"
14 
15 // #include "orion/itkpix/endec.hpp"
16 
17 
18 
19 namespace itk::itkpix::endec::orion {
20 
21 extern factory::EncCore makeEncCore;
22 
23 extern itk::Logger log;
24 
25 template<typename T>
27 public:
28  OutputCallback(T& cb) : cb(cb) {}
29 
30  void out_init() override { cb.out_init(); }
31  void out_next(uint8_t nbits) override { cb.out_next(nbits); }
32  void out_done(uint8_t nbits) override { cb.out_done(nbits); }
33  void out_data(uint64_t data) override { cb.out_data(data); }
34  uint8_t on_error(OutputError error) override { return cb.on_error(error); }
35 
36 private:
37  T& cb;
38 };
39 
40 
41 template<typename T>
42 class EncCore {
43 public:
44  using OutputCallback = T;
45 
46  Options opt;
48  intf::EncCore* enc;
49 
50  EncCore(Options opt, OutputCallback& cb_out) : opt(opt), cb(cb_out) {
51  log.debug("orion.EncCore(opt, out)");
52  enc = makeEncCore(opt, cb);
53  }
54 
55  ~EncCore() {
56  delete enc;
57  }
58 
59  inline void initialize() {
60  log.debug("initialize()");
61  enc->initialize();
62  }
63  inline void finalize() {
64  log.debug("finalize()");
65  enc->finalize();
66  }
67 
68  inline void evt_init(uint8_t tag) { enc->evt_init(tag); }
69  inline void evt_next(uint8_t tag) { enc->evt_next(tag); }
70  inline void evt_done() { enc->evt_done(); }
71 
72  inline void add_hit(uint16_t col, uint16_t row, uint16_t tot) {
73  enc->add_hit(col, row, tot);
74  }
75  inline void add_hmap(uint8_t qcol, uint8_t qrow, uint16_t hmap, uint64_t tots) {
76  enc->add_hmap(qcol, qrow, hmap, tots);
77  }
78  inline void add_qcore(uint8_t qcol, uint8_t qrow, uint64_t qtot) {
79  enc->add_qcore(qcol, qrow, qtot);
80  }
81 
82 };
83 
84 
85 } // itk::itkpix::endec::orion
Definition: enccore.hpp:16
virtual void evt_next(uint8_t tag)=0
Complete the event and start the next one.
virtual void evt_init(uint8_t tag)=0
Init a new event.
virtual void finalize()=0
Finalise encoder core.
virtual void evt_done()=0
Done event.
virtual void add_qcore(uint8_t qcol, uint8_t qrow, uint64_t qtot)=0
Add qcore: tots are decoded to 64 bit qtot, no-hit marked as 0xF.
virtual void add_hmap(uint8_t qcol, uint8_t qrow, uint16_t hmap, uint64_t tots)=0
Add hitmap: hitmap is decoded, tots are not decoded.
virtual void initialize()=0
Initialise encoder core.
virtual void add_hit(uint16_t col, uint16_t row, uint16_t tot)=0
Add hit.
Callback interface for output.
Definition: outcallback.hpp:39
Definition: enccore.hpp:42
void out_next(uint8_t nbits) override
Complete the event and start the next one.
Definition: enccore.hpp:31
void out_init() override
Create a new stream and start a new event.
Definition: enccore.hpp:30
uint8_t on_error(OutputError error) override
Callback on encoding error.
Definition: enccore.hpp:34
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:33
Logger class definition, wrapper around CoreLogger, adds templated methods for different logging leve...
Definition: logger.hpp:108
void debug(fmt::format_string< Args... > fmt, Args &&...args)
Logs a message with debug level.
Definition: logger.hpp:140
Templates for ITkPix Encoder Core.
Logger definitions.
Common encoder/decoder options.
Definition: options.hpp:10
Callback on event decoding error.
Definition: outcallback.hpp:15