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
18
20#include "logging/Logging.hpp" // NOTE: if ISSUES ARE DECLARED BEFORE include logging/Logging.hpp, TLOG_DEBUG<<issue wont work.
22
23#include <map>
24#include <memory>
25#include <string>
26#include <vector>
27
28namespace dunedaq {
29
30// Disable coverage collection LCOV_EXCL_START
32 DAQModuleManagerNotInitialized,
33 "Command " << cmdid << " received before initialization",
34 ((std::string)cmdid))
35
38 "\"init\" Command received when already initialized",
40
42 CommandDispatchingFailed,
43 "Command " << cmdid << " was not executed correctly by: " << modules,
44 ((std::string)cmdid)((std::string)modules))
45
48 "Command " << cmdid << " matches multiple times modules: " << modules,
49 ((std::string)cmdid)((std::string)modules))
50
51ERS_DECLARE_ISSUE(appfwk, FailedInfoGathering, "Info gathering failed for module: " << module, ((std::string)module))
52
54 ExceptionWhileInfoGathering,
55 FailedInfoGathering,
56 module << " threw exception while info gathering: " << message,
57 ((std::string)module),
58 ((std::string)message))
59
61 ActionPlanNotFound,
62 "No action plan found for command " << cmd << ", taking the following action: " << message,
63 ((std::string)cmd)((std::string)message))
64
65// Re-enable coverage collection LCOV_EXCL_STOP
66
67namespace appfwk {
68
69constexpr int ACTION_PLANS_REQUIRED = 0;
70constexpr int ACTION_PLANS_REQUIRED_WARNING = 0;
71
72class DAQModule;
73
74class DAQModuleManager
75{
76public:
77 using dataobj_t = nlohmann::json;
78
79 explicit DAQModuleManager(const std::string& session_name);
80
81 void initialize(std::shared_ptr<ConfigurationManager> mgr, opmonlib::OpMonManager&);
82 bool initialized() const { return m_initialized; }
83 void cleanup();
84
85 // Execute a properly structured command
86 void execute(const std::string& cmd, const dataobj_t& cmd_data);
87
88private:
89 typedef std::map<std::string, std::shared_ptr<DAQModule>> DAQModuleMap_t;
90
91 void init_modules(const std::vector<const dunedaq::confmodel::DaqModule*>& modules, opmonlib::OpMonManager&);
92
93 void check_cmd_data(const std::string& id, const dataobj_t& cmd_data);
94 dataobj_t get_dataobj_for_module(const std::string& mod_name, const dataobj_t& cmd_data);
95 bool execute_action(const std::string& mod_name, const std::string& action, const dataobj_t& data_obj);
96 void execute_action_plan_step(const std::string& cmd,
98 const dataobj_t& cmd_data,
99 bool execution_mode_is_serial);
100
101 void check_mod_has_cmd(const std::string& cmd,
102 const std::string& mod_class,
103 bool is_optional,
104 const std::string& mod_id = "");
105
106 std::vector<std::string> get_modnames_by_cmdid(cmdlib::cmd::CmdId id);
107 std::shared_ptr<ConfigurationManager> m_configuration_mgr;
108
109 std::string m_session_name;
110 bool m_initialized;
111
112 DAQModuleMap_t m_module_map;
113 std::map<std::string, std::vector<std::string>> m_modules_by_type;
114};
115
116} // namespace appfwk
117} // namespace dunedaq
118
119#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.
Definition DataStore.hpp:57
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