DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
TimingHardwareInterface.cpp
Go to the documentation of this file.
1
11
14
15#include "logging/Logging.hpp"
16#include "rcif/cmd/Nljs.hpp"
17
18#include <chrono>
19#include <cstdlib>
20#include <memory>
21#include <string>
22#include <thread>
23#include <vector>
24#include <regex>
25
26namespace dunedaq {
27namespace timinglibs {
28
29inline void
30resolve_environment_variables(std::string& input_string)
31{
32 static std::regex env_var_pattern("\\$\\{([^}]+)\\}");
33 std::smatch match;
34 while (std::regex_search(input_string, match, env_var_pattern)) {
35 const char* s = getenv(match[1].str().c_str());
36 const std::string env_var(s == nullptr ? "" : s);
37 input_string.replace(match[0].first, match[0].second, env_var);
38 }
39}
40
42 : m_connections_file("")
43 , m_connection_manager(nullptr)
44{
45}
46
47void
48TimingHardwareInterface::configure_uhal(const std::string& uhal_log_level, const std::string& connections_file)
49{
50 m_uhal_log_level = uhal_log_level;
51
52 if (!m_uhal_log_level.compare("debug")) {
53 uhal::setLogLevelTo(uhal::Debug());
54 } else if (!m_uhal_log_level.compare("info")) {
55 uhal::setLogLevelTo(uhal::Info());
56 } else if (!m_uhal_log_level.compare("notice")) {
57 uhal::setLogLevelTo(uhal::Notice());
58 } else if (!m_uhal_log_level.compare("warning")) {
59 uhal::setLogLevelTo(uhal::Warning());
60 } else if (!m_uhal_log_level.compare("error")) {
61 uhal::setLogLevelTo(uhal::Error());
62 } else if (!m_uhal_log_level.compare("fatal")) {
63 uhal::setLogLevelTo(uhal::Fatal());
64 } else {
65 throw InvalidUHALLogLevel(ERS_HERE, m_uhal_log_level);
66 }
67
68 m_connections_file = connections_file;
69 try {
70 m_connection_manager = std::make_unique<uhal::ConnectionManager>("file://" + m_connections_file);
71 } catch (const uhal::exception::FileNotFound& excpt) {
72 std::stringstream message;
73 message << m_connections_file << " not found. Has TIMING_SHARE been set?";
74 throw UHALConnectionsFileIssue(ERS_HERE, message.str(), excpt);
75 }
76}
77
78void
83
84void
90
91} // namespace timinglibs
92} // namespace dunedaq
93
94// Local Variables:
95// c-basic-offset: 2
96// End:
#define ERS_HERE
std::unique_ptr< uhal::ConnectionManager > m_connection_manager
TimingHardwareInterface()
TimingHardwareInterface Constructor.
void configure_uhal(const dunedaq::timinglibs::dal::TimingHardwareInterfaceConf *mdal)
const std::string & get_connections_file() const
Get "connections_file" attribute value. device connections file.
const std::string & get_uhal_log_level() const
Get "uhal_log_level" attribute value. Log level for uhal.
void resolve_environment_variables(std::string &input_string)
Including Qt Headers.
Unknown serialization Cannot deserialize message