Line data Source code
1 : /**
2 : * @file HermesModule.hpp
3 : *
4 : * Developer(s) of this DAQModule have yet to replace this line with a brief description of the DAQModule.
5 : *
6 : * This is part of the DUNE DAQ Software Suite, copyright 2020.
7 : * Licensing/copyright details are in the COPYING file that you should have
8 : * received with this code.
9 : */
10 :
11 : #ifndef HERMESMODULES_PLUGINS_HERMESCORECONTROLLER_HPP_
12 : #define HERMESMODULES_PLUGINS_HERMESCORECONTROLLER_HPP_
13 :
14 : #include "appfwk/DAQModule.hpp"
15 : #include "logging/Logging.hpp" // NOTE: if ISSUES ARE DECLARED BEFORE include logging/Logging.hpp, TLOG_DEBUG<<issue wont work.
16 :
17 : #include "hermesmodules/HermesCoreController.hpp"
18 :
19 : #include <atomic>
20 : #include <limits>
21 : #include <string>
22 :
23 : namespace dunedaq {
24 :
25 0 : ERS_DECLARE_ISSUE(hermesmodules,
26 : FirmwareConfigLinkMismatch,
27 : "Number of links in configuration ("<< cfg_n_links << ") and firmware (" << fw_n_links << ") don't match",
28 : ((uint16_t)cfg_n_links)((uint16_t)fw_n_links)
29 : );
30 :
31 0 : ERS_DECLARE_ISSUE(hermesmodules,
32 : DuplicatedLinkIDs,
33 : "Duplicated link ids detected ( number of links in config: "<< cfg_n_links << " but only " << cfg_n_links_unique << ") are uniqe)",
34 : ((uint16_t)cfg_n_links)((uint16_t)cfg_n_links_unique)
35 : );
36 :
37 0 : ERS_DECLARE_ISSUE(hermesmodules,
38 : FailedToRetrieveStats,
39 : "Failed to retrieve hermes code stats for link " << link,
40 : ((uint16_t)link)
41 : );
42 :
43 0 : ERS_DECLARE_ISSUE(hermesmodules,
44 : InvalidSourceStream,
45 : "Configuration for " << what << " does not contain a detector stream",
46 : ((std::string)what)
47 : );
48 :
49 0 : ERS_DECLARE_ISSUE(hermesmodules,
50 : MultipleIPAddressConfigurationError,
51 : "Found " << n_ips << " ip addresses found in devcie " << dev_id << " configuration while expecting 1" ,
52 : ((std::string)dev_id)((uint16_t)n_ips)
53 : );
54 :
55 :
56 0 : ERS_DECLARE_ISSUE(hermesmodules,
57 : LinkIDConfigurationError,
58 : "Last link id found " << last_link_id << " does not match expected " << last_link_exp,
59 : ((uint16_t)last_link_id)((uint16_t)last_link_exp)
60 : );
61 :
62 : namespace appmodel {
63 : class HermesCoreController;
64 : }
65 : namespace confmodel {
66 : class Session;
67 : }
68 :
69 : namespace hermesmodules {
70 :
71 : class HermesModule : public dunedaq::appfwk::DAQModule
72 : {
73 : public:
74 : explicit HermesModule(const std::string& name);
75 :
76 : void init(std::shared_ptr<appfwk::ConfigurationManager>) override;
77 :
78 : HermesModule(const HermesModule&) = delete;
79 : HermesModule& operator=(const HermesModule&) = delete;
80 : HermesModule(HermesModule&&) = delete;
81 : HermesModule& operator=(HermesModule&&) = delete;
82 :
83 0 : ~HermesModule() = default;
84 :
85 : protected:
86 : void generate_opmon_data() override;
87 : private:
88 :
89 : // Commands HermesModule can receive
90 :
91 : void do_conf(const CommandData_t&);
92 : void do_start(const CommandData_t&);
93 : void do_stop(const CommandData_t&);
94 :
95 : std::unique_ptr<HermesCoreController> m_core_controller;
96 : const appmodel::HermesModule* m_dal;
97 : const confmodel::Session* m_session;
98 : std::vector<uint32_t> m_enabled_link_ids;
99 :
100 : std::atomic<int64_t> m_total_amount {0};
101 : std::atomic<int> m_amount_since_last_get_info_call {0};
102 : };
103 :
104 :
105 : } // namespace hermesmodules
106 : } // namespace dunedaq
107 :
108 : #endif // HERMESMODULES_PLUGINS_HERMESCORECONTROLLER_HPP_
|