DUNE-DAQ
DUNE Trigger and Data Acquisition software
Toggle main menu visibility
Loading...
Searching...
No Matches
dunedaq
sourcecode
appfwk
include
appfwk
DAQModule.hpp
Go to the documentation of this file.
1
15
16
#ifndef APPFWK_INCLUDE_APPFWK_DAQMODULE_HPP_
17
#define APPFWK_INCLUDE_APPFWK_DAQMODULE_HPP_
18
19
#include "
appfwk/ConfigurationManager.hpp
"
20
21
#include "
logging/Logging.hpp
"
// NOTE: if ISSUES ARE DECLARED BEFORE include logging/Logging.hpp, TLOG_DEBUG<<issue wont work.
22
#include "
opmonlib/MonitorableObject.hpp
"
23
#include "
utilities/NamedObject.hpp
"
24
25
#include "cetlib/BasicPluginFactory.h"
26
#include "cetlib/compiler_macros.h"
27
#include "
ers/Issue.hpp
"
28
#include "nlohmann/json.hpp"
29
30
#include <functional>
31
#include <map>
32
#include <memory>
33
#include <set>
34
#include <string>
35
#include <utility>
36
#include <vector>
37
38
#ifndef EXTERN_C_FUNC_DECLARE_START
39
// NOLINTNEXTLINE(build/define_used)
40
#define EXTERN_C_FUNC_DECLARE_START \
41
extern "C" \
42
{
43
#endif
44
49
// NOLINTNEXTLINE(build/define_used)
50
#define DEFINE_DUNE_DAQ_MODULE(klass) \
51
EXTERN_C_FUNC_DECLARE_START \
52
std::shared_ptr<dunedaq::appfwk::DAQModule> make(std::string n) \
53
{ \
54
return std::shared_ptr<dunedaq::appfwk::DAQModule>(new klass(n)); \
55
} \
56
}
57
58
namespace
dunedaq
{
59
60
// Disable coverage collection LCOV_EXCL_START
64
ERS_DECLARE_ISSUE
(
appfwk
,
65
DAQModuleCreationFailed,
66
"Failed to create DAQModule "
<< instance_name <<
" of type "
<< plugin_name,
67
((std::string)plugin_name)((std::string)instance_name))
68
69
72
ERS_DECLARE_ISSUE
(
appfwk
,
GeneralDAQModuleIssue
,
" DAQModule: "
<< name, ((
std
::
string
)name))
73
77
ERS_DECLARE_ISSUE_BASE
(
appfwk
,
78
DAQModuleInitFailed,
79
appfwk
::
GeneralDAQModuleIssue
,
80
" init failed."
,
81
((
std
::
string
)name),
82
ERS_EMPTY
)
83
87
ERS_DECLARE_ISSUE_BASE
(
appfwk
,
88
CommandIssue
,
89
appfwk
::
GeneralDAQModuleIssue
,
90
" Command "
<< cmd,
91
((
std
::
string
)name),
92
((
std
::
string
)cmd))
93
97
ERS_DECLARE_ISSUE_BASE
(
appfwk
,
98
CommandRegistrationFailed,
99
appfwk
::
CommandIssue
,
100
"Command registration failed. "
,
101
((
std
::
string
)cmd)((
std
::
string
)name),
102
ERS_EMPTY
)
103
107
ERS_DECLARE_ISSUE_BASE
(
appfwk
,
108
CommandRegistrationFailedMessage,
109
appfwk
::
CommandIssue
,
110
"Command registration failed: "
<< message,
111
((
std
::
string
)cmd)((
std
::
string
)name),
112
((
std
::
string
)message))
113
117
ERS_DECLARE_ISSUE_BASE
(
appfwk
,
118
UnknownCommand,
119
appfwk
::
CommandIssue
,
120
"Command is not recognised"
,
121
((
std
::
string
)cmd)((
std
::
string
)name),
122
ERS_EMPTY
)
123
127
ERS_DECLARE_ISSUE_BASE
(
appfwk
,
128
CommandFailed,
129
appfwk
::
CommandIssue
,
130
"Command Failed. Reason "
<< reason,
131
((
std
::
string
)cmd)((
std
::
string
)name),
132
((
std
::
string
)reason))
133
137
ERS_DECLARE_ISSUE_BASE
(
appfwk
,
138
MissingConnection,
139
appfwk
::
GeneralDAQModuleIssue
,
140
"Required Connection Not Found. Type: "
<< type <<
", direction: "
<< direction,
141
((
std
::
string
)name),
142
((
std
::
string
)type)((
std
::
string
)direction))
143
144
// Re-enable coverage collection LCOV_EXCL_STOP
145
namespace
appfwk
{
146
158
class
DAQModule
159
:
public
utilities::NamedObject
160
,
public
opmonlib::MonitorableObject
161
{
162
public
:
168
class
CommandData_t :
public
nlohmann::json {};
169
170
explicit
DAQModule(std::string name)
171
:
utilities::NamedObject
(name)
172
{
173
}
174
175
virtual
~DAQModule()
noexcept
=
default
;
176
183
virtual
void
init
(std::shared_ptr<ConfigurationManager> mcfg) = 0;
184
193
void
execute_command(
const
std::string& name,
const
CommandData_t& data = {});
194
195
std::vector<std::string> get_commands()
const
;
196
197
bool
has_command(
const
std::string& name)
const
;
198
199
void
set_command_registration_allowed(
bool
allowed) { m_command_registration_allowed = allowed; }
200
201
protected
:
209
template
<
typename
Child>
210
void
register_command(
const
std::string& name,
void
(Child::*f)(
const
CommandData_t&));
211
212
DAQModule(DAQModule
const
&) =
delete
;
213
DAQModule(DAQModule&&) =
delete
;
214
DAQModule& operator=(DAQModule
const
&) =
delete
;
215
DAQModule& operator=(DAQModule&&) =
delete
;
216
217
private
:
218
using
CommandMap_t = std::map<std::string, std::function<void(
const
CommandData_t&)>>;
219
CommandMap_t m_commands;
220
std::atomic<bool> m_command_registration_allowed{
true
};
221
};
222
223
std::shared_ptr<DAQModule>
224
make_module(std::string
const
& plugin_name, std::string
const
& instance_name);
225
226
}
// namespace appfwk
227
228
}
// namespace dunedaq
229
230
#include "
detail/DAQModule.hxx
"
231
232
#endif
// APPFWK_INCLUDE_APPFWK_DAQMODULE_HPP_
ConfigurationManager.hpp
DAQModule.hxx
ERS_EMPTY
#define ERS_EMPTY
Definition
IssueDeclarationMacro.hpp:22
Issue.hpp
MonitorableObject.hpp
NamedObject.hpp
dunedaq::opmonlib::MonitorableObject
Definition
MonitorableObject.hpp:74
dunedaq::utilities::NamedObject
Implements the Named interface.
Definition
NamedObject.hpp:44
init
void init(unordered_map< std::string, std::string > params)
Definition
conversions-impl.hh:30
Logging.hpp
ERS_DECLARE_ISSUE
#define ERS_DECLARE_ISSUE( namespace_name, class_name, message_, attributes)
Definition
macro.hpp:65
appfwk
Definition
__init__.py:1
dunedaq
Including Qt Headers.
Definition
module.cpp:16
dunedaq::GeneralDAQModuleIssue
GeneralDAQModuleIssue
Definition
DAQModule.hpp:72
dunedaq::ERS_DECLARE_ISSUE_BASE
DAQModule std::string name ERS_DECLARE_ISSUE_BASE(appfwk, DAQModuleInitFailed, appfwk::GeneralDAQModuleIssue, " init failed.",((std::string) name), ERS_EMPTY) ERS_DECLARE_ISSUE_BASE(appfwk
Initialization failed ERS Issue (used by DAQModuleManager).
dunedaq::ERS_DECLARE_ISSUE
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
dunedaq::CommandIssue
DAQModule std::string name CommandIssue
Definition
DAQModule.hpp:88
std
Definition
SchemaUtils.hpp:118
Generated on
for DUNE-DAQ by
1.17.0