Line data Source code
1 : /**
2 : * @file ElinkConcept.hpp ElinkConcept for constructors and
3 : * forwarding command args. Enforces the implementation to
4 : * queue in block_addresses
5 : *
6 : * This is part of the DUNE DAQ , copyright 2020.
7 : * Licensing/copyright details are in the COPYING file that you should have
8 : * received with this code.
9 : */
10 : #ifndef FLXLIBS_SRC_ELINKCONCEPT_HPP_
11 : #define FLXLIBS_SRC_ELINKCONCEPT_HPP_
12 :
13 : #include "DefaultParserImpl.hpp"
14 :
15 : #include "appfwk/DAQModule.hpp"
16 : #include "packetformat/detail/block_parser.hpp"
17 :
18 :
19 : #include <memory>
20 : #include <sstream>
21 : #include <string>
22 :
23 : namespace dunedaq {
24 : namespace flxlibs {
25 :
26 : class ElinkConcept : public opmonlib::MonitorableObject
27 : {
28 : public:
29 0 : ElinkConcept()
30 0 : : m_parser_impl()
31 0 : , m_card_id(0)
32 0 : , m_logical_unit(0)
33 0 : , m_link_id(0)
34 0 : , m_link_tag(0)
35 0 : , m_elink_str("")
36 0 : , m_elink_source_tid("")
37 : {
38 0 : m_parser = std::make_unique<felix::packetformat::BlockParser<DefaultParserImpl>>(m_parser_impl);
39 0 : }
40 0 : virtual ~ElinkConcept() {}
41 :
42 : ElinkConcept(const ElinkConcept&) = delete; ///< ElinkConcept is not copy-constructible
43 : ElinkConcept& operator=(const ElinkConcept&) = delete; ///< ElinkConcept is not copy-assginable
44 : ElinkConcept(ElinkConcept&&) = delete; ///< ElinkConcept is not move-constructible
45 : ElinkConcept& operator=(ElinkConcept&&) = delete; ///< ElinkConcept is not move-assignable
46 :
47 : virtual void init(const size_t block_queue_capacity) = 0;
48 : virtual void set_sink(const std::string& sink_name) = 0;
49 : virtual void conf(size_t block_size, bool is_32b_trailers) = 0;
50 : virtual void start() = 0;
51 : virtual void stop() = 0;
52 :
53 : virtual bool queue_in_block_address(uint64_t block_addr) = 0; // NOLINT
54 :
55 0 : DefaultParserImpl& get_parser() { return std::ref(m_parser_impl); }
56 :
57 0 : void set_ids(int card, int slr, int id, int tag)
58 : {
59 0 : m_card_id = card;
60 0 : m_logical_unit = slr;
61 0 : m_link_id = id;
62 0 : m_link_tag = tag;
63 :
64 0 : std::ostringstream lidstrs;
65 0 : lidstrs << "Elink["
66 0 : << "cid:" << std::to_string(m_card_id) << "|"
67 0 : << "slr:" << std::to_string(m_logical_unit) << "|"
68 0 : << "lid:" << std::to_string(m_link_id) << "|"
69 0 : << "tag:" << std::to_string(m_link_tag) << "]";
70 0 : m_elink_str = lidstrs.str();
71 :
72 0 : std::ostringstream tidstrs;
73 0 : tidstrs << "ept-" << std::to_string(m_card_id) << "-" << std::to_string(m_logical_unit);
74 0 : m_elink_source_tid = tidstrs.str();
75 :
76 0 : }
77 :
78 : protected:
79 : // Block Parser
80 : DefaultParserImpl m_parser_impl;
81 : std::unique_ptr<felix::packetformat::BlockParser<DefaultParserImpl>> m_parser;
82 :
83 : int m_card_id;
84 : int m_logical_unit;
85 : int m_link_id;
86 : int m_link_tag;
87 : std::string m_elink_str;
88 : std::string m_elink_source_tid;
89 : std::chrono::time_point<std::chrono::high_resolution_clock> m_t0;
90 :
91 : private:
92 : };
93 :
94 : } // namespace flxlibs
95 : } // namespace dunedaq
96 :
97 : #endif // FLXLIBS_SRC_ELINKCONCEPT_HPP_
|