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
28 : << ") don't match",
29 : ((uint16_t)cfg_n_links)((uint16_t)fw_n_links));
30 :
31 0 : ERS_DECLARE_ISSUE(hermesmodules,
32 : DuplicatedLinkIDs,
33 : "Duplicated link ids detected ( number of links in config: " << cfg_n_links << " but only "
34 : << cfg_n_links_unique << ") are uniqe)",
35 : ((uint16_t)cfg_n_links)((uint16_t)cfg_n_links_unique));
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 0 : ERS_DECLARE_ISSUE(hermesmodules,
43 : InvalidSourceStream,
44 : "Configuration for " << what << " does not contain a detector stream",
45 : ((std::string)what));
46 :
47 0 : ERS_DECLARE_ISSUE(hermesmodules,
48 : MultipleIPAddressConfigurationError,
49 : "Found " << n_ips << " ip addresses found in devcie " << dev_id << " configuration while expecting 1",
50 : ((std::string)dev_id)((uint16_t)n_ips));
51 :
52 0 : ERS_DECLARE_ISSUE(hermesmodules,
53 : LinkIDConfigurationError,
54 : "Last link id found " << last_link_id << " does not match expected " << last_link_exp,
55 : ((uint16_t)last_link_id)((uint16_t)last_link_exp));
56 :
57 : namespace appmodel {
58 : class HermesCoreController;
59 : }
60 : namespace confmodel {
61 : class Session;
62 : }
63 :
64 : namespace hermesmodules {
65 :
66 : class HermesModule : public dunedaq::appfwk::DAQModule
67 : {
68 : public:
69 : explicit HermesModule(const std::string& name);
70 :
71 : void init(std::shared_ptr<appfwk::ConfigurationManager>) override;
72 :
73 : HermesModule(const HermesModule&) = delete;
74 : HermesModule& operator=(const HermesModule&) = delete;
75 : HermesModule(HermesModule&&) = delete;
76 : HermesModule& operator=(HermesModule&&) = delete;
77 :
78 0 : ~HermesModule() = default;
79 :
80 : protected:
81 : void generate_opmon_data() override;
82 :
83 : private:
84 : // Commands HermesModule can receive
85 :
86 : void do_conf(const CommandData_t&);
87 : void do_start(const CommandData_t&);
88 : void do_stop(const CommandData_t&);
89 :
90 : std::unique_ptr<HermesCoreController> m_core_controller;
91 : const appmodel::HermesModule* m_dal;
92 : const confmodel::Session* m_session;
93 : std::vector<uint32_t> m_enabled_link_ids;
94 :
95 : std::atomic<int64_t> m_total_amount{ 0 };
96 : std::atomic<int> m_amount_since_last_get_info_call{ 0 };
97 : };
98 :
99 : } // namespace hermesmodules
100 : } // namespace dunedaq
101 :
102 : #endif // HERMESMODULES_PLUGINS_HERMESCORECONTROLLER_HPP_
|