DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
OpMonManager.hpp
Go to the documentation of this file.
1
9#ifndef OPMONLIB_INCLUDE_OPMONLIB_OPMONMANAGER_HPP_
10#define OPMONLIB_INCLUDE_OPMONLIB_OPMONMANAGER_HPP_
11
12#include <cstddef>
13#include <thread>
14
16#include "opmonlib/Utils.hpp"
17
19#include "logging/Logging.hpp" // NOTE: if ISSUES ARE DECLARED BEFORE include logging/Logging.hpp, TLOG_DEBUG<<issue wont work.
20
21namespace dunedaq {
22
24 ThreadNameTooLong,
25 "The name " << name << " is too long for a thread name",
26 ((std::string)name)
27 )
28
31 "Monitoring thread not set",
32 ERS_EMPTY )
33
35 FailedMonitoringThread,
36 "Monitoring thread failed to start",
37 ERS_EMPTY )
38
41 "Confiration is not set",
42 ERS_EMPTY )
43}
44
45
46
47namespace dunedaq::opmonlib {
48
50{
51
52 friend class TestOpMonManager;
53
54public:
55
56 /*
57 * Construtor expected to be used for standard operations,
58 * yet, general developers should not concern themselves with this as the framework handles this for them
59 */
60 explicit OpMonManager(std::string session,
61 std::string name,
62 std::string opmon_facility_uri = "stdout") :
63 OpMonManager( session, name, makeOpMonFacility(opmon_facility_uri, make_origin(session, name)) ){;}
64
65 virtual ~OpMonManager() = default;
66
67 using MonitorableObject::get_opmon_id;
68 using MonitorableObject::get_opmon_level;
69 using MonitorableObject::register_node;
70 using MonitorableObject::set_opmon_level;
71
72 // data collecting loop
73 void start_monitoring();
74 // The stop command is not necessary.
75 // The stop is invoked during the destruction of the thread
76 // the method requires a valid configuration because the time period is taken from there
77
79 m_cfg.store(c);
80 set_opmon_level( m_cfg.load()->get_level() );
81 }
82
83protected:
84 using MonitorableObject::collect;
85
86 //obtain the opmon facility
87 auto get_opmon_facility() const { return m_facility.load(); }
88
89 OpMonManager(std::string session,
90 std::string name,
91 facility_ptr_t );
92
93 void run( std::stop_token ); // function used by the jthread
94
95private:
96
97 std::jthread m_thread;
98 std::atomic<const confmodel::OpMonConf*> m_cfg{nullptr};
99
100};
101
102
103} // namespace dunedaq::opmonlib
104
105#endif // OPMONLIB_INCLUDE_OPMONLIB_OPMONMANAGER_HPP_
#define ERS_DECLARE_ISSUE(namespace_name, class_name, message, attributes)
#define ERS_EMPTY
virtual ~OpMonManager()=default
OpMonManager(std::string session, std::string name, std::string opmon_facility_uri="stdout")
void set_opmon_conf(const confmodel::OpMonConf *c)
static volatile sig_atomic_t run
std::shared_ptr< OpMonFacility > makeOpMonFacility(std::string const &facility, OptionalOrigin=OptionalOrigin())
opmon::OpMonId make_origin(const std::string &session, const std::string &app)
Definition Utils.cpp:12
Including Qt Headers.
Unsupported std::string uri Execution of command failed
Definition Issues.hpp:69
Monitoring thread not ERS_EMPTY MissingConfiguration
Monitoring thread not set