LCOV - code coverage report
Current view: top level - timing/src - MasterMuxDesign.cpp (source / functions) Coverage Total Hit
Test: code.result Lines: 0.0 % 49 0
Test Date: 2025-12-21 13:07:08 Functions: 0.0 % 14 0

            Line data    Source code
       1              : #include "timing/MasterMuxDesign.hpp"
       2              : 
       3              : #include <sstream>
       4              : #include <string>
       5              : 
       6              : namespace dunedaq::timing {
       7              : 
       8            0 : UHAL_REGISTER_DERIVED_NODE(MasterMuxDesign)
       9              : 
      10              : //-----------------------------------------------------------------------------
      11            0 : MasterMuxDesign::MasterMuxDesign(const uhal::Node& node)
      12              :   : TopDesignInterface(node)
      13              :   , MuxDesignInterface(node)
      14              :   , MasterDesignInterface(node)
      15              :   , SFPMuxDesignInterface(node)
      16            0 :   , MasterDesign(node)
      17            0 : {}
      18              : //-----------------------------------------------------------------------------
      19              : 
      20              : //-----------------------------------------------------------------------------
      21            0 : MasterMuxDesign::~MasterMuxDesign()
      22            0 : {}
      23              : //-----------------------------------------------------------------------------
      24              : 
      25              : //-----------------------------------------------------------------------------
      26              : std::string
      27            0 : MasterMuxDesign::get_status(bool print_out) const
      28              : {
      29            0 :   std::stringstream status;
      30            0 :   status << get_io_node_plain()->get_pll_status();
      31            0 :   status << get_master_node_plain()->get_status();
      32              :   // TODO mux specific status
      33            0 :   if (print_out)
      34            0 :     TLOG() << status.str();
      35            0 :   return status.str();
      36            0 : }
      37              : //-----------------------------------------------------------------------------
      38              : 
      39              : //-----------------------------------------------------------------------------
      40              : uint32_t
      41            0 : MasterMuxDesign::measure_endpoint_rtt(uint32_t address, bool control_sfp, int sfp_mux) const
      42              : {
      43              : 
      44            0 :   if (sfp_mux > -1) {
      45            0 :     if (control_sfp) 
      46              :     {
      47              :       // set fanout rtt mux channel, and do not wait for fanout rtt ept to be in a good state
      48            0 :       switch_mux(sfp_mux);
      49              :     }
      50              :     // gets master rtt ept in a good state, and sends echo command
      51            0 :     uint32_t rtt = get_master_node_plain()->measure_endpoint_rtt(address, control_sfp);
      52            0 :     return rtt;
      53              :   } else {
      54            0 :     return get_master_node_plain()->measure_endpoint_rtt(address, control_sfp);
      55              :   }
      56              : }
      57              : //-----------------------------------------------------------------------------
      58              : 
      59              : //-----------------------------------------------------------------------------
      60              : void
      61            0 : MasterMuxDesign::apply_endpoint_delay(uint32_t address,
      62              :                                                uint32_t coarse_delay,
      63              :                                                uint32_t fine_delay,
      64              :                                                uint32_t phase_delay,
      65              :                                                bool measure_rtt,
      66              :                                                bool control_sfp,
      67              :                                                int sfp_mux) const
      68              : {
      69            0 :   if (sfp_mux > -1)
      70              :   {
      71            0 :     if (control_sfp && measure_rtt)
      72              :     {
      73              :       // set fanout rtt mux channel, and do not wait for fanout rtt ept to be in a good state
      74            0 :       switch_mux(sfp_mux);
      75              :     }
      76              :     // gets master rtt ept in a good state, and sends echo command
      77            0 :     get_master_node_plain()->apply_endpoint_delay(address, coarse_delay, fine_delay, phase_delay, measure_rtt, control_sfp);
      78              :   }
      79              :   else
      80              :   {
      81            0 :     get_master_node_plain()->apply_endpoint_delay(address, coarse_delay, fine_delay, phase_delay, measure_rtt, control_sfp);
      82              :   }
      83            0 : }
      84              : //-----------------------------------------------------------------------------
      85              : 
      86              : //-----------------------------------------------------------------------------
      87              : std::vector<uint32_t>
      88            0 : MasterMuxDesign::scan_sfp_mux() const 
      89              : {
      90            0 :   std::vector<uint32_t> locked_channels;
      91              : 
      92              :   // TODO will this be right for every fanout board, need to check the IO board
      93            0 :   uint32_t number_of_mux_channels = 8;
      94            0 :   for (uint32_t i = 0; i < number_of_mux_channels; ++i)
      95              :   {
      96            0 :     TLOG_DEBUG(0) << "Scanning slot " << i;
      97              : 
      98            0 :     try
      99              :     {
     100            0 :       switch_mux(i);
     101            0 :       this->get_master_node_plain()->enable_upstream_endpoint();
     102            0 :     } catch (...) {
     103            0 :       TLOG_DEBUG(0) << "Slot " << i << " not locked";
     104            0 :     }
     105              :     // TODO catch right except
     106              : 
     107            0 :     TLOG_DEBUG(0) << "Slot " << i << " locked";
     108            0 :     locked_channels.push_back(i);
     109              :   }
     110              : 
     111            0 :   if (locked_channels.size()) {
     112            0 :     TLOG() << "Slots locked: " << vec_fmt(locked_channels);
     113              :   } else {
     114            0 :     TLOG() << "No slots locked";
     115              :   }
     116            0 :   return locked_channels;
     117            0 : }
     118              : //-----------------------------------------------------------------------------
     119              : 
     120              : //-----------------------------------------------------------------------------
     121              : void
     122            0 : MasterMuxDesign::resync_active_cdr() const
     123              : {
     124            0 :   this->get_master_node_plain()->enable_upstream_endpoint();
     125            0 : }
     126              : //-----------------------------------------------------------------------------
     127              : }
        

Generated by: LCOV version 2.0-1