DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
DAQModuleManager.hpp
Go to the documentation of this file.
1
9#ifndef APPFWK_SRC_DAQMODULEMANAGER_HPP_
10#define APPFWK_SRC_DAQMODULEMANAGER_HPP_
11
12#include "ers/Issue.hpp"
13#include "nlohmann/json.hpp"
14
15#include "appfwk/DAQModule.hpp"
19
21#include "logging/Logging.hpp" // NOTE: if ISSUES ARE DECLARED BEFORE include logging/Logging.hpp, TLOG_DEBUG<<issue wont work.
23
24#include <map>
25#include <memory>
26#include <string>
27#include <vector>
28
29namespace dunedaq {
30
31// Disable coverage collection LCOV_EXCL_START
33 DAQModuleManagerNotInitialized,
34 "Command " << cmdid << " received before initialization",
35 ((std::string)cmdid))
36
39 "\"init\" Command received when already initialized",
41
43 CommandDispatchingFailed,
44 "Command " << cmdid << " was not executed correctly by: " << modules,
45 ((std::string)cmdid)((std::string)modules))
46
49 "Command " << cmdid << " matches multiple times modules: " << modules,
50 ((std::string)cmdid)((std::string)modules))
51
52ERS_DECLARE_ISSUE(appfwk, FailedInfoGathering, "Info gathering failed for module: " << module, ((std::string)module))
53
55 ExceptionWhileInfoGathering,
56 FailedInfoGathering,
57 module << " threw exception while info gathering: " << message,
58 ((std::string)module),
59 ((std::string)message))
60
62 ActionPlanNotFound,
63 "No action plan found for command " << cmd << ", taking the following action: " << message,
64 ((std::string)cmd)((std::string)message))
65
66// Re-enable coverage collection LCOV_EXCL_STOP
67
68namespace appfwk {
69
70constexpr int ACTION_PLANS_REQUIRED = 0;
71constexpr int ACTION_PLANS_REQUIRED_WARNING = 0;
72
73class DAQModuleManager
74{
75public:
76 explicit DAQModuleManager(const std::string& session_name);
77
78 void initialize(std::shared_ptr<ConfigurationManager> mgr, opmonlib::OpMonManager&);
79 bool initialized() const { return m_initialized; }
80 void cleanup();
81
82 // Execute a properly structured command
83 void execute(const std::string& cmd, const DAQModule::CommandData_t& cmd_data);
84
85private:
86 typedef std::map<std::string, std::shared_ptr<DAQModule>> DAQModuleMap_t;
87
88 void init_modules(const std::vector<const dunedaq::confmodel::DaqModule*>& modules, opmonlib::OpMonManager&);
89
90 void check_command_data(const std::string& id, const DAQModule::CommandData_t& cmd_data);
91 DAQModule::CommandData_t get_command_data_for_module(const std::string& mod_name,
92 const DAQModule::CommandData_t& cmd_data);
93 bool execute_action(const std::string& mod_name, const std::string& action, const DAQModule::CommandData_t& data_obj);
94 void execute_action_plan_step(const std::string& cmd,
96 const DAQModule::CommandData_t& cmd_data,
97 bool execution_mode_is_serial);
98
99 void check_mod_has_cmd(const std::string& cmd,
100 const std::string& mod_class,
101 bool is_optional,
102 const std::string& mod_id = "");
103
104 std::vector<std::string> get_modnames_by_cmdid(cmdlib::cmd::CmdId id);
105 std::shared_ptr<ConfigurationManager> m_configuration_mgr;
106
107 std::string m_session_name;
108 bool m_initialized;
109
110 DAQModuleMap_t m_module_map;
111 std::map<std::string, std::vector<std::string>> m_modules_by_type;
112};
113
114} // namespace appfwk
115} // namespace dunedaq
116
117#endif // APPFWK_SRC_DAQMODULEMANAGER_HPP_
#define ERS_DECLARE_ISSUE_BASE(namespace_name, class_name, base_class_name, message, base_attributes, attributes)
#define ERS_DECLARE_ISSUE(namespace_name, class_name, message, attributes)
#define ERS_EMPTY
conffwk entry point
caught dunedaq::conffwk::Exception exception
std::string CmdId
Definition Structs.hpp:21
The DUNE-DAQ namespace.
Unsupported std::string uri Execution of command failed
Definition Issues.hpp:69
init Command received when already initialized
LED calibration failed to initialize
Definition SSPIssues.hpp:22
DAQModuleManagerAlreadyInitialized
init Command received when already ERS_EMPTY ConflictingCommandMatching