DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
dunedaq::opmonlib Namespace Reference

Namespaces

namespace  opmon

Classes

class  BackendOpMonFacility
class  JSonOpMonFacility
class  MonitorableObject
class  NullOpMonFacility
class  OpMonFacility
class  OpMonManager
class  TestOpMonManager

Typedefs

using OpMonLevel
using OptionalOrigin = std::optional<dunedaq::opmon::OpMonId>
using CustomOrigin = std::map<std::string, std::string>
using cr_map_type = std::invoke_result<decltype(&dunedaq::opmon::OpMonEntry::data), dunedaq::opmon::OpMonEntry>::type
using map_type = std::remove_const<std::remove_reference<cr_map_type>::type>::type

Enumerations

enum class  SystemOpMonLevel : OpMonLevel { kDisabled = std::numeric_limits<OpMonLevel>::min() , kAll = std::numeric_limits<OpMonLevel>::max() }
enum class  EntryOpMonLevel : OpMonLevel { kTopPriority = std::numeric_limits<OpMonLevel>::min() , kEventDriven = std::numeric_limits<OpMonLevel>::max() / 4 , kDefault = std::numeric_limits<OpMonLevel>::max() / 2 , kLowestPrioriry = std::numeric_limits<OpMonLevel>::max() - 1 }

Functions

template<class T>
constexpr auto to_level (T v)
std::shared_ptr< OpMonFacility > makeOpMonFacility (std::string const &facility, OptionalOrigin=OptionalOrigin())
template<class T>
void set_value (google::protobuf::Message &m, const std::string &name, T value)
template<class T>
void set_value (const google::protobuf::Reflection &, google::protobuf::Message &, const google::protobuf::FieldDescriptor *, T)
opmon::OpMonId make_origin (const std::string &session, const std::string &app)
dunedaq::opmon::OpMonEntry to_entry (const google::protobuf::Message &m, const CustomOrigin &co)
template<class M>
M from_entry (const dunedaq::opmon::OpMonEntry &)
void from_entry (google::protobuf::Message &m, const dunedaq::opmon::OpMonEntry &, std::string top_block="")
map_type to_map (const google::protobuf::Message &m, std::string top_block="")
std::string to_string (const dunedaq::opmon::OpMonId &)
const dunedaq::opmon::OpMonId & operator+= (dunedaq::opmon::OpMonId &, const std::string &element)
dunedaq::opmon::OpMonId operator+ (const dunedaq::opmon::OpMonId &, const std::string &element)

Typedef Documentation

◆ cr_map_type

Definition at line 47 of file Utils.hpp.

◆ CustomOrigin

using dunedaq::opmonlib::CustomOrigin = std::map<std::string, std::string>

Definition at line 46 of file Utils.hpp.

◆ map_type

using dunedaq::opmonlib::map_type = std::remove_const<std::remove_reference<cr_map_type>::type>::type

Definition at line 48 of file Utils.hpp.

◆ OpMonLevel

Initial value:
uint32_t get_level() const
Get "level" attribute value. SystemOpMonLevel.
Definition OpMonConf.hpp:98

Definition at line 46 of file MonitorableObject.hpp.

◆ OptionalOrigin

Definition at line 86 of file OpMonFacility.hpp.

Enumeration Type Documentation

◆ EntryOpMonLevel

Enumerator
kTopPriority 
kEventDriven 
kDefault 
kLowestPrioriry 

Definition at line 55 of file MonitorableObject.hpp.

56{
57 kTopPriority = std::numeric_limits<OpMonLevel>::min(),
58 kEventDriven = std::numeric_limits<OpMonLevel>::max() / 4,
59 kDefault = std::numeric_limits<OpMonLevel>::max() / 2,
60 kLowestPrioriry = std::numeric_limits<OpMonLevel>::max() - 1
61};

◆ SystemOpMonLevel

Enumerator
kDisabled 
kAll 

Definition at line 49 of file MonitorableObject.hpp.

50{
51 kDisabled = std::numeric_limits<OpMonLevel>::min(),
52 kAll = std::numeric_limits<OpMonLevel>::max()
53};

Function Documentation

◆ from_entry() [1/2]

template<class M>
M dunedaq::opmonlib::from_entry ( const dunedaq::opmon::OpMonEntry & e)

Definition at line 3 of file Utils.hxx.

4{
5
6 M ret;
7
8 if (ret.GetTypeName() != e.measurement()) {
9 throw opmonlib::NameMismatch(ERS_HERE, ret.GetTypeName(), e.measurement());
10 }
11
12 from_entry(ret, e);
13
14 return ret;
15}
#define ERS_HERE
const std::string & measurement() const
M from_entry(const dunedaq::opmon::OpMonEntry &)
Definition Utils.hxx:3

◆ from_entry() [2/2]

void dunedaq::opmonlib::from_entry ( google::protobuf::Message & m,
const dunedaq::opmon::OpMonEntry & e,
std::string top_block = "" )

Definition at line 105 of file Utils.cpp.

106{
107
108 const auto* descriptor_p = m.GetDescriptor();
109 const auto& des = *descriptor_p;
110
111 const auto* reflection_p = m.GetReflection();
112 const auto& ref = *reflection_p;
113
114 using namespace google::protobuf;
115
116 auto count = des.field_count();
117 for (int i = 0; i < count; ++i) {
118 const auto* field_p = des.field(i);
119 if (field_p->is_repeated())
120 continue;
121
122 auto name = top_block.empty() ? field_p->name() : top_block + '.' + field_p->name();
123
124 auto type = field_p->cpp_type();
125
126 if (type == FieldDescriptor::CppType::CPPTYPE_MESSAGE) {
127 auto message = ref.MutableMessage(&m, field_p);
128 from_entry(*message, e, name);
129 } else {
130
131 auto value = e.data().find(name)->second;
132
133 switch (type) {
134 case FieldDescriptor::CppType::CPPTYPE_INT32:
135 ref.SetInt32(&m, field_p, value.int4_value());
136 break;
137 case FieldDescriptor::CppType::CPPTYPE_INT64:
138 ref.SetInt64(&m, field_p, value.int8_value());
139 break;
140 case FieldDescriptor::CppType::CPPTYPE_UINT32:
141 ref.SetUInt32(&m, field_p, value.uint4_value());
142 break;
143 case FieldDescriptor::CppType::CPPTYPE_UINT64:
144 ref.SetUInt64(&m, field_p, value.uint8_value());
145 break;
146 case FieldDescriptor::CppType::CPPTYPE_DOUBLE:
147 ref.SetDouble(&m, field_p, value.double_value());
148 break;
149 case FieldDescriptor::CppType::CPPTYPE_FLOAT:
150 ref.SetFloat(&m, field_p, value.float_value());
151 break;
152 case FieldDescriptor::CppType::CPPTYPE_BOOL:
153 ref.SetBool(&m, field_p, value.boolean_value());
154 break;
155 case FieldDescriptor::CppType::CPPTYPE_STRING:
156 ref.SetString(&m, field_p, value.string_value());
157 break;
158 default:
159 break;
160 } // switch on the cpp type
161 } // else if it's a message
162 } // loop over the fields
163}
const ::google::protobuf::Map< std::string, ::dunedaq::opmon::OpMonValue > & data() const

◆ make_origin()

dunedaq::opmon::OpMonId dunedaq::opmonlib::make_origin ( const std::string & session,
const std::string & app )

Definition at line 12 of file Utils.cpp.

13{
14 opmon::OpMonId origin;
15 origin.set_session(session);
16 origin.set_application(app);
17 return origin;
18}
void set_session(Arg_ &&arg, Args_... args)
void set_application(Arg_ &&arg, Args_... args)

◆ makeOpMonFacility()

std::shared_ptr< OpMonFacility > dunedaq::opmonlib::makeOpMonFacility ( std::string const & facility,
OptionalOrigin o = OptionalOrigin() )

Definition at line 15 of file OpMonFacility.cpp.

16{
17
18 TLOG() << "FACILITY = " << facility;
19
20 const std::string hook = "://";
21 auto sep = facility.find(hook);
22 std::string scheme;
23 if (sep == std::string::npos) { // simple path
24 scheme = "stdout";
25 } else { // with scheme
26 scheme = facility.substr(0, sep);
27 }
28
29 std::string plugin_name = scheme + "OpMonFacility";
30 static cet::BasicPluginFactory bpf("duneOpMonFacility", "make");
31 std::shared_ptr<OpMonFacility> os_ptr;
32
33 try {
34 os_ptr = bpf.makePlugin<std::shared_ptr<OpMonFacility>>(plugin_name, facility, o);
35 } catch (const ers::Issue& iexpt) {
36 throw OpMonFacilityCreationFailed(ERS_HERE, plugin_name, iexpt);
37 } catch (const cet::exception& cexpt) {
38 throw OpMonFacilityCreationFailedWithCause(ERS_HERE, plugin_name, cexpt.what());
39 } catch (...) { // NOLINT JCF Jan-27-2021 violates letter of the law but not the spirit
40 throw OpMonFacilityCreationFailed(ERS_HERE, plugin_name);
41 }
42 return os_ptr;
43}
#define TLOG(...)
Definition macro.hpp:21

◆ operator+()

dunedaq::opmon::OpMonId dunedaq::opmonlib::operator+ ( const dunedaq::opmon::OpMonId & id,
const std::string & element )

Definition at line 206 of file Utils.cpp.

207{
208
209 auto ret = id;
210 ret += element;
211 return ret;
212}

◆ operator+=()

const dunedaq::opmon::OpMonId & dunedaq::opmonlib::operator+= ( dunedaq::opmon::OpMonId & id,
const std::string & element )

Definition at line 185 of file Utils.cpp.

186{
187
188 if (element.empty())
189 return id;
190
191 if (id.session().empty()) {
192 id.set_session(element);
193 return id;
194 }
195
196 if (id.application().empty()) {
197 id.set_application(element);
198 return id;
199 }
200
201 id.add_substructure(element);
202 return id;
203}
std::string * add_substructure()

◆ set_value() [1/2]

template<class T>
void dunedaq::opmonlib::set_value ( const google::protobuf::Reflection & ,
google::protobuf::Message & ,
const google::protobuf::FieldDescriptor * ,
T  )

◆ set_value() [2/2]

template<class T>
void dunedaq::opmonlib::set_value ( google::protobuf::Message & m,
const std::string & name,
T value )

sets the field called "name" in the message m to the value of "value" This is essentially allows us to use any schema generated message as if it was dynamic object

Definition at line 19 of file Utils.hxx.

20{
21
22 const auto* descriptor_p = m.GetDescriptor();
23 const auto& des = *descriptor_p;
24
25 auto field_p = des.FindFieldByName(name);
26 if (!field_p) {
27 throw MissingField(ERS_HERE, name, m.GetTypeName());
28 }
29
30 const auto* reflection_p = m.GetReflection();
31 const auto& ref = *reflection_p;
32
33 set_value(ref, m, field_p, value);
34}
void set_value(google::protobuf::Message &m, const std::string &name, T value)
Definition Utils.hxx:19

◆ to_entry()

dunedaq::opmon::OpMonEntry dunedaq::opmonlib::to_entry ( const google::protobuf::Message & m,
const CustomOrigin & co )

Definition at line 21 of file Utils.cpp.

22{
23
25 entry.set_measurement(m.GetTypeName());
26
28
29 for (const auto& [tag, value] : co) {
30 (*entry.mutable_custom_origin())[tag] = value;
31 }
32
33 return entry;
34}
::google::protobuf::Map< std::string, ::dunedaq::opmon::OpMonValue > * mutable_data()
void set_measurement(Arg_ &&arg, Args_... args)
::google::protobuf::Map< std::string, std::string > * mutable_custom_origin()
map_type to_map(const google::protobuf::Message &m, std::string top_block="")
Definition Utils.cpp:37

◆ to_level()

template<class T>
auto dunedaq::opmonlib::to_level ( T v)
constexpr

Definition at line 65 of file MonitorableObject.hpp.

66{
67 return static_cast<typename std::underlying_type<T>::type>(v);
68}
default char v[0]

◆ to_map()

dunedaq::opmonlib::map_type dunedaq::opmonlib::to_map ( const google::protobuf::Message & m,
std::string top_block = "" )

Definition at line 37 of file Utils.cpp.

38{
39
41
42 const auto* descriptor_p = m.GetDescriptor();
43 const auto& des = *descriptor_p;
44
45 const auto* reflection_p = m.GetReflection();
46 const auto& ref = *reflection_p;
47
48 using namespace google::protobuf;
49
50 auto count = des.field_count();
51 for (int i = 0; i < count; ++i) {
52 const auto* field_p = des.field(i);
53 if (field_p->is_repeated())
54 continue;
55
56 auto name = top_block.empty() ? field_p->name() : top_block + '.' + field_p->name();
57
58 auto type = field_p->cpp_type();
60 bool success = true;
61 switch (type) {
62 case FieldDescriptor::CppType::CPPTYPE_INT32:
63 value.set_int4_value(ref.GetInt32(m, field_p));
64 break;
65 case FieldDescriptor::CppType::CPPTYPE_INT64:
66 value.set_int8_value(ref.GetInt64(m, field_p));
67 break;
68 case FieldDescriptor::CppType::CPPTYPE_UINT32:
69 value.set_uint4_value(ref.GetUInt32(m, field_p));
70 break;
71 case FieldDescriptor::CppType::CPPTYPE_UINT64:
72 value.set_uint8_value(ref.GetUInt64(m, field_p));
73 break;
74 case FieldDescriptor::CppType::CPPTYPE_DOUBLE:
75 value.set_double_value(ref.GetDouble(m, field_p));
76 break;
77 case FieldDescriptor::CppType::CPPTYPE_FLOAT:
78 value.set_float_value(ref.GetFloat(m, field_p));
79 break;
80 case FieldDescriptor::CppType::CPPTYPE_BOOL:
81 value.set_boolean_value(ref.GetBool(m, field_p));
82 break;
83 case FieldDescriptor::CppType::CPPTYPE_STRING:
84 value.set_string_value(ref.GetString(m, field_p));
85 break;
86 case FieldDescriptor::CppType::CPPTYPE_MESSAGE: {
87 auto data = dunedaq::opmonlib::to_map(ref.GetMessage(m, field_p), name);
88 ret.insert(data.begin(), data.end());
89 success = false;
90 break;
91 }
92 default:
93 success = false;
94 break;
95 } // switch on the cpp type
96
97 if (success)
98 ret[name] = value;
99 }
100
101 return ret;
102}
void set_int4_value(::int32_t value)
void set_uint4_value(::uint32_t value)
void set_boolean_value(bool value)
void set_string_value(Arg_ &&arg, Args_... args)
void set_uint8_value(::uint64_t value)
void set_int8_value(::int64_t value)
void set_float_value(float value)
void set_double_value(double value)
std::remove_const< std::remove_reference< cr_map_type >::type >::type map_type
Definition Utils.hpp:48

◆ to_string()

std::string dunedaq::opmonlib::to_string ( const dunedaq::opmon::OpMonId & id)

Definition at line 166 of file Utils.cpp.

167{
168
169 std::string ret(id.session());
170
171 if (!id.application().empty()) {
172 ret += '.';
173 ret += id.application();
174 }
175
176 for (int i = 0; i < id.substructure().size(); ++i) {
177 ret += '.';
178 ret += id.substructure()[i];
179 }
180
181 return ret;
182}
FELIX Initialization std::string initerror FELIX queue timed std::string queuename Unexpected chunk size