DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
OpMonManager.hpp
Go to the documentation of this file.
1
8
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
71
72 // data collecting loop
73 void start_monitoring();
74 // The stop command is not necessary, although it is provided to facilitate complex object behaviour
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
78 void stop_monitoring();
79 // on top of stopping the monitorin thread, this method will also join the thread
80
82 m_cfg.store(c);
83 set_opmon_level( m_cfg.load()->get_level() );
84 }
85
86protected:
88
89 //obtain the opmon facility
90 auto get_opmon_facility() const { return m_facility.load(); }
91
92 OpMonManager(std::string session,
93 std::string name,
94 facility_ptr_t );
95
96 void run( std::stop_token ); // function used by the jthread
97
98private:
99
100 std::jthread m_thread;
101 std::atomic<const confmodel::OpMonConf*> m_cfg{nullptr};
102
103};
104
105
106} // namespace dunedaq::opmonlib
107
108#endif // OPMONLIB_INCLUDE_OPMONLIB_OPMONMANAGER_HPP_
#define ERS_EMPTY
opmon::MonitoringTreeInfo collect() noexcept
void set_opmon_level(OpMonLevel) noexcept
std::atomic< facility_ptr_t > m_facility
void register_node(ElementId name, NewNodePtr)
MonitorableObject(const MonitorableObject &)=delete
std::atomic< const confmodel::OpMonConf * > m_cfg
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
#define ERS_DECLARE_ISSUE( namespace_name, class_name, message_, attributes)
Definition macro.hpp:65
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.
Definition module.cpp:16
ERS_DECLARE_ISSUE(snbmodules, InvalidGroupTransferIDError, "InvalidGroupTransferIDError: Transfer ID "<< transfer_id<< " not found in "<< location,((std::string) transfer_id)((std::string) location)) ERS_DECLARE_ISSUE(snbmodules
Monitoring thread not ERS_EMPTY MissingConfiguration