DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
Application.hpp
Go to the documentation of this file.
1
9#ifndef APPFWK_SRC_APPLICATION_HPP_
10#define APPFWK_SRC_APPLICATION_HPP_
11
12// appfwk Includes
14#include "DAQModuleManager.hpp"
16
17// DUNE-DAQ includes
20#include "logging/Logging.hpp" // NOTE: if ISSUES ARE DECLARED BEFORE include logging/Logging.hpp, TLOG_DEBUG<<issue wont work.
24
25// External libraries
26#include "nlohmann/json.hpp"
27
28// C++ includes
29#include <atomic>
30#include <chrono>
31#include <memory>
32#include <mutex>
33#include <string>
34
35namespace dunedaq {
36
37// Disable coverage collection LCOV_EXCL_START
38
40 ApplicationNotInitialized,
41 "Application " << name << " has not been initialized yet.",
42 ((std::string)name))
43
46 "Command " << cmdid << " not allowed at this time. state: " << state << ", error: " << err
47 << ", busy: " << busy,
48 ((std::string)cmdid)((std::string)state)((bool)err)((bool)busy)) // NOLINT
49
51 ApplicationFailure,
52 "Application " << application << " in session " << session << " failed",
53 ((std::string)session)((std::string)application))
54
55// Re-enable coverage collection LCOV_EXCL_STOP
56
57namespace appfwk {
58
59class Application
60 : public ConfigurationManagerOwner
64{
65public:
66 using dataobj_t = nlohmann::json;
67
68 Application(std::string app_name,
69 std::string session_name,
70 std::string cmdlibimpl,
71 std::string confimpl,
72 std::string configuration_id);
73
74 void init();
75
76 void run(std::atomic<bool>& end_marker);
77
78 void execute(const dataobj_t& cmd_data) override;
79
80 bool check_state_for_cmd(const dataobj_t& cmd_data) const;
81
82 void generate_opmon_data() override;
83
84 void set_state(std::string s)
85 {
86 const std::lock_guard<std::mutex> lock(m_mutex);
87 m_state = s;
88 }
89 std::string get_state() const
90 {
91 const std::lock_guard<std::mutex> lock(m_mutex);
92 return m_state;
93 }
94
95private:
96 DAQModuleManager m_mod_mgr;
97 mutable std::mutex m_mutex;
98 std::string m_state;
99 std::atomic<bool> m_busy;
100 std::atomic<bool> m_error;
101 bool m_initialized;
102 std::chrono::time_point<std::chrono::steady_clock> m_run_start_time;
104 std::shared_ptr<cmdlib::CommandFacility> m_cmd_fac;
105};
106
107} // namespace appfwk
108} // namespace dunedaq
109
110#endif // APPFWK_SRC_APPLICATION_HPP_
#define ERS_DECLARE_ISSUE(namespace_name, class_name, message, attributes)
Interface needed by commanded objects in the DAQ.
Implements the Named interface.
void init(unordered_map< std::string, std::string > params)
static volatile sig_atomic_t run
Including Qt Headers.
InvalidStateForCommand