Orion
high-rate readout
cmddecoder.hpp
Go to the documentation of this file.
1 // ╭─╮╭─╴╷╭─╮┌─╮
2 // ╰─╯╵ ╵╰─╯╵ ╵
8 #pragma once
9 
10 #include <span>
11 
12 #include "itk/logger.hpp"
13 #include "itk/utils.hpp"
14 
16 
17 namespace itk::itkpix::cmd::dummy {
18 
19 extern itk::Logger log;
20 
25 template<typename Callback>
27 public:
28  using CommandCallback = Callback;
29 
30  CommandDecoder(CommandCallback& cb_cmd) : cb_cmd(cb_cmd) {
31  log.info("create CommandDecoder()");
32  }
33 
34  CommandDecoder(uint8_t chip_id, CommandCallback& cb_cmd) : cb_cmd(cb_cmd) {
35  log.info("create CommandDecoder(chip_id: 0x{:x})", chip_id);
36  }
37 
38  ~CommandDecoder() {
39  log.info("destroy CommandDecoder()");
40  }
41 
42  inline void reset() {
43  log.info("reset()");
44  }
45 
46  inline void decode(uint16_t cmd) {
47  if (cmd == 0x817e) cb_cmd.sync();
48  if (cmd == 0xAAAA) cb_cmd.idle();
49  }
50 
51  inline void decode(const std::span<const uint16_t> cmds) {
52  log.info("decode(cmds: [{}])", itk::utils::to_string(cmds));
53  for (auto cmd : cmds) decode(cmd);
54  }
55 
56  inline void decode(const uint16_t* cmds, size_t size) {
57  decode({ cmds, size });
58  }
59 
60 private:
61  CommandCallback& cb_cmd;
62 
63 }; // CommandDecoder
64 
65 } // itk::itkpix::cmd::dummy
Dummy command decoder implementation.
Definition: cmddecoder.hpp:26
Logger class definition, wrapper around CoreLogger, adds templated methods for different logging leve...
Definition: logger.hpp:108
void info(fmt::format_string< Args... > fmt, Args &&...args)
Logs a message with information level.
Definition: logger.hpp:148
Templates for ITkPix emulator.
uint16_t size
Definition: fragheader.hpp:5
Logger definitions.
ITk common utilites.