DUNE-DAQ
DUNE Trigger and Data Acquisition software
Toggle main menu visibility
Loading...
Searching...
No Matches
dunedaq
sourcecode
opmonlib
include
opmonlib
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
15
#include "
opmonlib/MonitorableObject.hpp
"
16
#include "
opmonlib/Utils.hpp
"
17
18
#include "
confmodel/OpMonConf.hpp
"
19
#include "
logging/Logging.hpp
"
// NOTE: if ISSUES ARE DECLARED BEFORE include logging/Logging.hpp, TLOG_DEBUG<<issue wont work.
20
21
namespace
dunedaq
{
22
23
ERS_DECLARE_ISSUE
(
opmonlib
,
24
ThreadNameTooLong,
25
"The name "
<< name <<
" is too long for a thread name"
,
26
((std::string)name))
27
28
ERS_DECLARE_ISSUE
(
opmonlib
, MonitoringThreadNotSet,
"Monitoring thread not set"
,
ERS_EMPTY
)
29
30
ERS_DECLARE_ISSUE
(
opmonlib
, FailedMonitoringThread,
"Monitoring thread failed to start"
,
ERS_EMPTY
)
31
32
ERS_DECLARE_ISSUE
(
opmonlib
, MissingConfiguration,
"Confiration is not set"
,
ERS_EMPTY
)
33
}
34
35
namespace
dunedaq::opmonlib
{
36
37
class
OpMonManager
:
protected
MonitorableObject
38
{
39
40
friend
class
TestOpMonManager
;
41
42
public
:
43
/*
44
* Construtor expected to be used for standard operations,
45
* yet, general developers should not concern themselves with this as the framework handles this for them
46
*/
47
explicit
OpMonManager
(std::string
session
, std::string name, std::string opmon_facility_uri =
"stdout"
)
48
:
OpMonManager
(
session
, name,
makeOpMonFacility
(opmon_facility_uri,
make_origin
(
session
, name)))
49
{
50
;
51
}
52
53
virtual
~OpMonManager
() =
default
;
54
55
using
MonitorableObject::get_opmon_id
;
56
using
MonitorableObject::get_opmon_level
;
57
using
MonitorableObject::register_node
;
58
using
MonitorableObject::set_opmon_level
;
59
60
// data collecting loop
61
void
start_monitoring
();
62
// The stop command is not necessary, although it is provided to facilitate complex object behaviour
63
// The stop is invoked during the destruction of the thread
64
// the method requires a valid configuration because the time period is taken from there
65
66
void
stop_monitoring
();
67
// on top of stopping the monitorin thread, this method will also join the thread
68
69
void
set_opmon_conf
(
const
confmodel::OpMonConf
* c)
70
{
71
m_cfg
.store(c);
72
set_opmon_level
(
m_cfg
.load()->get_level());
73
}
74
75
protected
:
76
using
MonitorableObject::collect
;
77
78
// obtain the opmon facility
79
auto
get_opmon_facility
()
const
{
return
m_facility
.load(); }
80
81
OpMonManager
(std::string
session
, std::string name,
facility_ptr_t
);
82
83
void
run
(std::stop_token);
// function used by the jthread
84
85
private
:
86
std::jthread
m_thread
;
87
std::atomic<const confmodel::OpMonConf*>
m_cfg
{
nullptr
};
88
};
89
90
}
// namespace dunedaq::opmonlib
91
92
#endif
// OPMONLIB_INCLUDE_OPMONLIB_OPMONMANAGER_HPP_
ERS_EMPTY
#define ERS_EMPTY
Definition
IssueDeclarationMacro.hpp:23
MonitorableObject.hpp
dunedaq::confmodel::OpMonConf
Definition
OpMonConf.hpp:24
dunedaq::opmonlib::MonitorableObject::get_opmon_level
auto get_opmon_level() const noexcept
Definition
MonitorableObject.hpp:91
dunedaq::opmonlib::MonitorableObject::facility_ptr_t
std::shared_ptr< opmonlib::OpMonFacility > facility_ptr_t
Definition
MonitorableObject.hpp:162
dunedaq::opmonlib::MonitorableObject::collect
opmon::MonitoringTreeInfo collect() noexcept
Definition
MonitorableObject.cpp:100
dunedaq::opmonlib::MonitorableObject::get_opmon_id
auto get_opmon_id() const noexcept
Definition
MonitorableObject.hpp:89
dunedaq::opmonlib::MonitorableObject::set_opmon_level
void set_opmon_level(OpMonLevel) noexcept
Definition
MonitorableObject.cpp:178
dunedaq::opmonlib::MonitorableObject::m_facility
std::atomic< facility_ptr_t > m_facility
Definition
MonitorableObject.hpp:163
dunedaq::opmonlib::MonitorableObject::register_node
void register_node(ElementId name, NewNodePtr)
Definition
MonitorableObject.cpp:33
dunedaq::opmonlib::MonitorableObject::MonitorableObject
MonitorableObject(const MonitorableObject &)=delete
dunedaq::opmonlib::MonitorableObject::OpMonManager
friend class OpMonManager
Definition
MonitorableObject.hpp:77
dunedaq::opmonlib::OpMonManager::m_cfg
std::atomic< const confmodel::OpMonConf * > m_cfg
Definition
OpMonManager.hpp:87
dunedaq::opmonlib::OpMonManager::TestOpMonManager
friend class TestOpMonManager
Definition
OpMonManager.hpp:40
dunedaq::opmonlib::OpMonManager::~OpMonManager
virtual ~OpMonManager()=default
dunedaq::opmonlib::OpMonManager::run
void run(std::stop_token)
Definition
OpMonManager.cpp:54
dunedaq::opmonlib::OpMonManager::OpMonManager
OpMonManager(std::string session, std::string name, std::string opmon_facility_uri="stdout")
Definition
OpMonManager.hpp:47
dunedaq::opmonlib::OpMonManager::start_monitoring
void start_monitoring()
Definition
OpMonManager.cpp:24
dunedaq::opmonlib::OpMonManager::stop_monitoring
void stop_monitoring()
Definition
OpMonManager.cpp:44
dunedaq::opmonlib::OpMonManager::m_thread
std::jthread m_thread
Definition
OpMonManager.hpp:86
dunedaq::opmonlib::OpMonManager::get_opmon_facility
auto get_opmon_facility() const
Definition
OpMonManager.hpp:79
dunedaq::opmonlib::OpMonManager::set_opmon_conf
void set_opmon_conf(const confmodel::OpMonConf *c)
Definition
OpMonManager.hpp:69
OpMonConf.hpp
Logging.hpp
dunedaq::opmonlib
Definition
BackendOpMonFacility.hpp:11
dunedaq::opmonlib::makeOpMonFacility
std::shared_ptr< OpMonFacility > makeOpMonFacility(std::string const &facility, OptionalOrigin=OptionalOrigin())
Definition
OpMonFacility.cpp:15
dunedaq::opmonlib::make_origin
opmon::OpMonId make_origin(const std::string &session, const std::string &app)
Definition
Utils.cpp:12
dunedaq
The DUNE-DAQ namespace.
Definition
cib_utilities.cpp:5
dunedaq::ERS_DECLARE_ISSUE
ERS_DECLARE_ISSUE(cibmodules, CIBCommunicationError, " CIB Hardware Communication Error: "<< descriptor,((std::string) descriptor)) ERS_DECLARE_ISSUE(cibmodules
session
Definition
session.py:1
Utils.hpp
Generated on
for DUNE-DAQ by
1.18.0