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  OpMonLink
 
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
 
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< OpMonFacilitymakeOpMonFacility (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 >
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::OpMonIdoperator+= (dunedaq::opmon::OpMonId &, const std::string &element)
 
dunedaq::opmon::OpMonId operator+ (const dunedaq::opmon::OpMonId &, const std::string &element)
 

Typedef Documentation

◆ cr_map_type

Initial value:
std::invoke_result<decltype(&dunedaq::opmon::OpMonEntry::data),
const ::google::protobuf::Map< std::string, ::dunedaq::opmon::OpMonValue > & data() const

Definition at line 54 of file Utils.hpp.

◆ CustomOrigin

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

Definition at line 53 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 56 of file Utils.hpp.

◆ OpMonLevel

Initial value:
std::invoke_result<decltype(&dunedaq::confmodel::OpMonConf::get_level),
uint32_t get_level() const
Get "level" attribute value. SystemOpMonLevel.
Definition OpMonConf.hpp:98

Definition at line 52 of file MonitorableObject.hpp.

◆ OptionalOrigin

Definition at line 84 of file OpMonFacility.hpp.

Enumeration Type Documentation

◆ EntryOpMonLevel

Enumerator
kTopPriority 
kEventDriven 
kDefault 
kLowestPrioriry 

Definition at line 60 of file MonitorableObject.hpp.

60 : OpMonLevel {
61 kTopPriority = std::numeric_limits<OpMonLevel>::min(),
62 kEventDriven = std::numeric_limits<OpMonLevel>::max()/4,
63 kDefault = std::numeric_limits<OpMonLevel>::max()/2,
64 kLowestPrioriry = std::numeric_limits<OpMonLevel>::max()-1
65 };
std::invoke_result< decltype(&dunedaq::confmodel::OpMonConf::get_level), dunedaq::confmodel::OpMonConf >::type OpMonLevel

◆ SystemOpMonLevel

Enumerator
kDisabled 
kAll 

Definition at line 55 of file MonitorableObject.hpp.

55 : OpMonLevel {
56 kDisabled = std::numeric_limits<OpMonLevel>::min(),
57 kAll = std::numeric_limits<OpMonLevel>::max()
58 };

Function Documentation

◆ from_entry() [1/2]

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

Definition at line 2 of file Utils.hxx.

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

◆ 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 106 of file Utils.cpp.

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

◆ 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.

12 {
13 opmon::OpMonId origin;
14 origin.set_session( session );
15 origin.set_application( app );
16 return origin;
17}
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 14 of file OpMonFacility.cpp.

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

◆ operator+()

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

Definition at line 205 of file Utils.cpp.

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

◆ 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() ) return id;
189
190 if ( id.session().empty() ) {
191 id.set_session(element);
192 return id;
193 }
194
195 if ( id.application().empty() ) {
196 id.set_application(element);
197 return id;
198 }
199
200 id.add_substructure(element);
201 return id;
202}
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 17 of file Utils.hxx.

17 {
18
19 const auto * descriptor_p = m.GetDescriptor();
20 const auto & des = *descriptor_p;
21
22 auto field_p = des.FindFieldByName(name);
23 if ( ! field_p ) {
24 throw MissingField(ERS_HERE, name, m.GetTypeName());
25 }
26
27 const auto * reflection_p = m.GetReflection();
28 const auto & ref = *reflection_p;
29
30 set_value( ref, m, field_p, value );
31
32}

◆ to_entry()

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

Definition at line 20 of file Utils.cpp.

21 {
22
24 entry.set_measurement( m.GetTypeName() );
25
27
28 for ( const auto & [tag, value] : co ) {
29 (*entry.mutable_custom_origin())[tag] = value;
30 }
31
32 return entry;
33}
::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:36

◆ to_level()

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

Definition at line 68 of file MonitorableObject.hpp.

68 {
69 return static_cast<typename std::underlying_type<T>::type>(v);
70 }

◆ to_map()

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

Definition at line 36 of file Utils.cpp.

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

◆ to_string()

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

Definition at line 167 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