DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
FrameErrorRegistry.hpp
Go to the documentation of this file.
1
8#ifndef DATAHANDLINGLIBS_INCLUDE_DATAHANDLINGLIBS_FRAMEERRORREGISTRY_HPP_
9#define DATAHANDLINGLIBS_INCLUDE_DATAHANDLINGLIBS_FRAMEERRORREGISTRY_HPP_
10
12
13#include <cstdint> // uint_t types
14#include <map>
15#include <mutex>
16#include <utility>
17#include <string>
18
19namespace dunedaq {
20namespace datahandlinglibs {
21
23{
24public:
26 {
27 public:
28 ErrorInterval(uint64_t start_ts, uint64_t end_ts) // NOLINT(build/unsigned)
30 , end_ts(end_ts)
31 {}
32
33 uint64_t start_ts; // NOLINT(build/unsigned)
34 uint64_t end_ts; // NOLINT(build/unsigned)
35
36 bool operator<(const ErrorInterval& other) const { return end_ts < other.end_ts; }
37
38 bool operator>(const ErrorInterval& other) const { return end_ts > other.end_ts; }
39 };
40
44
45 void set_ers_metadata(const std::string& ers_metadata)
46 {
47 m_ers_metadata = ers_metadata;
48 }
49
50 void add_error(std::string error_name, ErrorInterval error)
51 {
52 std::lock_guard<std::mutex> guard(m_error_map_mutex);
53 m_errors.erase(error_name);
54 m_errors.insert(std::make_pair(error_name, error));
55 }
56
57 void remove_errors_until(uint64_t ts) // NOLINT(build/unsigned)
58 {
59 std::lock_guard<std::mutex> guard(m_error_map_mutex);
60 for (auto it = m_errors.begin(); it != m_errors.end();) {
61 if (ts > it->second.end_ts) {
62 std::string error_name = it->first;
63 it = m_errors.erase(it);
64 ers::info(ClearedError(ERS_HERE, m_ers_metadata.value_or(""), error_name));
65 } else {
66 it++;
67 }
68 }
69 }
70
72 std::lock_guard<std::mutex> guard(m_error_map_mutex);
73 for (const auto& [error_name, _] : m_errors) {
74 ers::warning(NewErrorRegistered(ERS_HERE, m_ers_metadata.value_or(""), error_name));
75 }
76 }
77
78 bool has_error(std::string error_name) { return m_errors.find(error_name) != m_errors.end(); }
79
80 bool has_error() { return !m_errors.empty(); }
81
82private:
83std::map<std::string, ErrorInterval> m_errors;
85std::optional<std::string> m_ers_metadata;
86};
87
88} // namespace datahandlinglibs
89} // namespace dunedaq
90
91#endif // DATAHANDLINGLIBS_INCLUDE_DATAHANDLINGLIBS_FRAMEERRORREGISTRY_HPP_
#define ERS_HERE
void set_ers_metadata(const std::string &ers_metadata)
void add_error(std::string error_name, ErrorInterval error)
std::map< std::string, ErrorInterval > m_errors
Including Qt Headers.
PDS Frame with unphysical timestamp detected with ts
void warning(const Issue &issue)
Definition ers.hpp:115
void info(const Issue &issue)
Definition ers.hpp:95
Factory couldn t std::string alg_name Invalid configuration error
Definition Issues.hpp:34