DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
toolbox.hpp
Go to the documentation of this file.
1
11#ifndef TIMING_INCLUDE_TIMING_TOOLBOX_HPP_
12#define TIMING_INCLUDE_TIMING_TOOLBOX_HPP_
13
14#include "definitions.hpp"
15
16#include "TimingIssues.hpp"
17
18#include "ers/Issue.hpp"
19#include "logging/Logging.hpp"
20
21// uHAL Headers
22#include <uhal/Node.hpp>
23
24// Boost Headers
25#include <boost/format.hpp>
26#include <boost/format/group.hpp>
27#include <boost/static_assert.hpp>
28#include <boost/type_traits/is_signed.hpp>
29#include <boost/type_traits/is_unsigned.hpp>
30#include <boost/unordered_map.hpp>
31
32// C++ Headers
33#include <chrono>
34#include <cstdint>
35#include <cstdlib>
36#include <iomanip>
37#include <istream>
38#include <string>
39#include <vector>
40
41namespace dunedaq {
42namespace timing {
43
44// Wrappers to be used by lexical_cast
45template<typename T>
46struct stol;
47template<typename T>
48struct stoul;
49
50template<typename T>
51std::string
52to_string(const T&);
53
54template<typename M>
55bool
56map_value_comparator(typename M::value_type& p1, typename M::value_type& p2);
57
58template<typename T>
59std::vector<T>
60sanitize(const std::vector<T>& vec);
61
62template<typename T, typename U>
63T
64safe_enum_cast(const U& value, const std::vector<T>& valid);
65
68snapshot(const uhal::Node& node);
69
72snapshot(const uhal::Node& node, const std::string& regex);
73
79void
80millisleep(const double& time_in_milliseconds);
81
90std::string
91strprintf(const char* fmt, ...); // NOLINT
92
98std::vector<std::string>
99shell_expand_paths(const std::string& path);
100
106std::string
107shellExpandPath(const std::string& path);
108
114void
115throw_if_not_file(const std::string& path);
116
127template<typename C>
128std::string
129join(const C& strings, const std::string& delimiter = " ");
130
136uint8_t // NOLINT(build/unsigned)
137dec_rng(uint8_t word, uint8_t ibit, uint8_t nbits = 1); // NOLINT(build/unsigned)
138
143uint64_t // NOLINT(build/unsigned)
144tstamp2int(uhal::ValVector<uint32_t> raw_timestamp); // NOLINT(build/unsigned)
145
150template<class T>
151std::string
152format_reg_value(T reg_value, uint32_t base = 16); // NOLINT(build/unsigned)
153
158template<class T>
159std::string
160format_reg_table(T data, std::string title = "", std::vector<std::string> headers = { "Register", "Value" });
161
166int64_t
168
173int64_t
175
180std::string
181format_timestamp(uhal::ValVector<uint32_t> raw_timestamp, uint32_t clock_frequency_hz); // NOLINT(build/unsigned)
182
187std::string
188format_timestamp(uint64_t raw_timestamp, uint32_t clock_frequency_hz); // NOLINT(build/unsigned)
189
194template<class T>
195std::string
196format_counters_table(std::vector<T> counters,
197 std::vector<std::string> counter_node_titles = {},
198 std::string table_title = "",
199 std::vector<std::string> counter_labels = {},
200 std::string counter_labels_header = "Cmd");
201
206double
207convert_bits_to_float(uint64_t bits, bool is_double_precision = false); // NOLINT(build/unsigned)
208
210convert_value_to_board_type(uint32_t Board_type); // NOLINT(build/unsigned)
212convert_value_to_carrier_type(uint32_t darrier_type); // NOLINT(build/unsigned)
214convert_value_to_design_type(uint32_t design_type); // NOLINT(build/unsigned)
215
216template<typename T>
217std::string
218vec_fmt(const std::vector<T>& vec);
219
220template<typename T>
221std::string
222short_vec_fmt(const std::vector<T>& vec);
223
224std::string
225format_firmware_version(uint32_t firmware_version); // NOLINT(build/unsigned)
226
227} // namespace timing
228} // namespace dunedaq
229
230#include "detail/toolbox.hxx"
231
232#endif // TIMING_INCLUDE_TIMING_TOOLBOX_HPP_
int64_t get_seconds_since_epoch()
Definition toolbox.cpp:183
CarrierType convert_value_to_carrier_type(uint32_t darrier_type)
Definition toolbox.cpp:287
bool map_value_comparator(typename M::value_type &p1, typename M::value_type &p2)
Definition toolbox.hxx:58
int64_t get_milliseconds_since_epoch()
Definition toolbox.cpp:201
std::string format_firmware_version(uint32_t firmware_version)
Definition toolbox.cpp:352
BoardType convert_value_to_board_type(uint32_t Board_type)
Definition toolbox.cpp:274
std::string format_reg_table(T data, std::string title, std::vector< std::string > headers)
Format reg-value table.
Definition toolbox.hxx:166
std::string vec_fmt(const std::vector< T > &vec)
Definition toolbox.hxx:382
std::string format_timestamp(uhal::ValVector< uint32_t > raw_timestamp, uint32_t clock_frequency_hz)
Definition toolbox.cpp:233
std::string strprintf(const char *fmt,...)
Definition toolbox.cpp:99
double convert_bits_to_float(uint64_t bits, bool is_double_precision=false)
Definition toolbox.cpp:242
std::vector< T > sanitize(const std::vector< T > &vec)
Definition toolbox.hxx:67
std::vector< std::string > shell_expand_paths(const std::string &path)
Definition toolbox.cpp:114
DesignType convert_value_to_design_type(uint32_t design_type)
Definition toolbox.cpp:300
std::string to_string(const T &v)
Definition toolbox.hxx:49
uint64_t tstamp2int(uhal::ValVector< uint32_t > raw_timestamp)
Definition toolbox.cpp:175
std::string format_counters_table(std::vector< T > counter_nodes, std::vector< std::string > counter_node_titles, std::string table_title, std::vector< std::string > counter_labels, std::string counter_labels_header)
Format reg-value table.
Definition toolbox.hxx:216
uint8_t dec_rng(uint8_t word, uint8_t ibit, uint8_t nbits=1)
Definition toolbox.cpp:167
std::map< std::string, uint32_t > Snapshot
std::string join(const C &strings, const std::string &delimiter)
Converts a vector of strings in a delimiter-separated string.
Definition toolbox.hxx:95
std::string shellExpandPath(const std::string &path)
Definition toolbox.cpp:134
T safe_enum_cast(const U &value, const std::vector< T > &valid, const T &def)
Definition toolbox.hxx:85
void throw_if_not_file(const std::string &path)
Definition toolbox.cpp:147
std::string short_vec_fmt(const std::vector< T > &vec)
Definition toolbox.hxx:399
std::string format_reg_value(T reg_value, uint32_t base)
Definition toolbox.hxx:117
void millisleep(const double &time_in_milliseconds)
Definition toolbox.cpp:83
Snapshot snapshot(const uhal::Node &node)
Walk & read the node structure.
Definition toolbox.cpp:42
Including Qt Headers.