LCOV - code coverage report
Current view: top level - timinglibs/src - TimingHardwareInterface.cpp (source / functions) Coverage Total Hit
Test: code.result Lines: 0.0 % 35 0
Test Date: 2026-02-16 10:18:04 Functions: 0.0 % 4 0

            Line data    Source code
       1              : /**
       2              :  * @file TimingHardwareInterface.cpp TimingHardwareInterface class
       3              :  * implementation
       4              :  *
       5              :  * This is part of the DUNE DAQ Software Suite, copyright 2020.
       6              :  * Licensing/copyright details are in the COPYING file that you should have
       7              :  * received with this code.
       8              :  */
       9              : 
      10              : #include "timinglibs/TimingHardwareInterface.hpp"
      11              : 
      12              : #include "timinglibs/TimingIssues.hpp"
      13              : #include "confmodel/Connection.hpp"
      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              : 
      26              : namespace dunedaq {
      27              : namespace timinglibs {
      28              : 
      29              : inline void
      30              : resolve_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              : 
      41            0 : TimingHardwareInterface::TimingHardwareInterface()
      42            0 :   : m_connections_file("")
      43            0 :   , m_connection_manager(nullptr)
      44              : {
      45            0 : }
      46              : 
      47              : void
      48            0 : TimingHardwareInterface::configure_uhal(const std::string& uhal_log_level, const std::string& connections_file)
      49              : {
      50            0 :   m_uhal_log_level = uhal_log_level;
      51              : 
      52            0 :   if (!m_uhal_log_level.compare("debug")) {
      53            0 :     uhal::setLogLevelTo(uhal::Debug());
      54            0 :   } else if (!m_uhal_log_level.compare("info")) {
      55            0 :     uhal::setLogLevelTo(uhal::Info());
      56            0 :   } else if (!m_uhal_log_level.compare("notice")) {
      57            0 :     uhal::setLogLevelTo(uhal::Notice());
      58            0 :   } else if (!m_uhal_log_level.compare("warning")) {
      59            0 :     uhal::setLogLevelTo(uhal::Warning());
      60            0 :   } else if (!m_uhal_log_level.compare("error")) {
      61            0 :     uhal::setLogLevelTo(uhal::Error());
      62            0 :   } else if (!m_uhal_log_level.compare("fatal")) {
      63            0 :     uhal::setLogLevelTo(uhal::Fatal());
      64              :   } else {
      65            0 :     throw InvalidUHALLogLevel(ERS_HERE, m_uhal_log_level);
      66              :   }
      67              : 
      68            0 :   m_connections_file = connections_file;
      69            0 :   try {
      70            0 :     m_connection_manager = std::make_unique<uhal::ConnectionManager>("file://" + m_connections_file);
      71            0 :   } catch (const uhal::exception::FileNotFound& excpt) {
      72            0 :     std::stringstream message;
      73            0 :     message << m_connections_file << " not found. Has TIMING_SHARE been set?";
      74            0 :     throw UHALConnectionsFileIssue(ERS_HERE, message.str(), excpt);
      75            0 :   }
      76            0 : }
      77              : 
      78              : void
      79            0 : TimingHardwareInterface::configure_uhal(const dunedaq::timinglibs::dal::TimingHardwareInterfaceConf* mdal)
      80              : {
      81            0 :   TimingHardwareInterface::configure_uhal(mdal->get_uhal_log_level(), mdal->get_connections_file());
      82            0 : }
      83              : 
      84              : void
      85            0 : TimingHardwareInterface::scrap_uhal()
      86              : {
      87            0 :   m_connection_manager.reset(nullptr);
      88            0 :   m_connections_file="";
      89            0 : }
      90              : 
      91              : } // namespace timinglibs
      92              : } // namespace dunedaq
      93              : 
      94              : // Local Variables:
      95              : // c-basic-offset: 2
      96              : // End:
        

Generated by: LCOV version 2.0-1