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

            Line data    Source code
       1              : #include "timing/MasterDesign.hpp"
       2              : 
       3              : #include <sstream>
       4              : #include <string>
       5              : 
       6              : namespace dunedaq::timing {
       7              : 
       8            0 : UHAL_REGISTER_DERIVED_NODE(MasterDesign)
       9              : 
      10              : //-----------------------------------------------------------------------------
      11            0 : MasterDesign::MasterDesign(const uhal::Node& node)
      12              :   : TopDesignInterface(node)
      13              :   , MasterDesignInterface(node)
      14            0 :   , TopDesign(node)
      15            0 : {}
      16              : //-----------------------------------------------------------------------------
      17              : 
      18              : //-----------------------------------------------------------------------------
      19            0 : MasterDesign::~MasterDesign()
      20            0 : {}
      21              : //-----------------------------------------------------------------------------
      22              : 
      23              : //-----------------------------------------------------------------------------
      24              : std::string
      25            0 : MasterDesign::get_status(bool print_out) const
      26              : {
      27            0 :   std::stringstream status;
      28            0 :   status << this->get_io_node_plain()->get_pll_status();
      29            0 :   status << get_master_node_plain()->get_status();
      30              : 
      31            0 :   if (print_out)
      32            0 :     TLOG() << status.str();
      33            0 :   return status.str();
      34            0 : }
      35              : //-----------------------------------------------------------------------------
      36              : 
      37              : //-----------------------------------------------------------------------------
      38              : void
      39            0 : MasterDesign::configure(ClockSource clock_source, TimestampSource ts_source) const
      40              : {
      41              :   // Hard resets
      42            0 :   TopDesign::configure(clock_source);
      43              : 
      44            0 :   this->sync_timestamp(ts_source); // keep previous behaviour for now, TODO: pass through correct parameter
      45            0 : }
      46              : //-----------------------------------------------------------------------------
      47              : 
      48              : //-----------------------------------------------------------------------------
      49              : uint64_t
      50            0 : MasterDesign::read_master_timestamp() const
      51              : {
      52            0 :   return get_master_node_plain()->read_timestamp();
      53              : }
      54              : //-----------------------------------------------------------------------------
      55              : 
      56              : //-----------------------------------------------------------------------------
      57              : void
      58            0 : MasterDesign::sync_timestamp(TimestampSource source) const
      59              : {
      60            0 :   get_master_node_plain()->sync_timestamp(source);
      61            0 : }
      62              : //-----------------------------------------------------------------------------
      63              : 
      64              : //-----------------------------------------------------------------------------
      65              : uint32_t
      66            0 : MasterDesign::measure_endpoint_rtt(uint32_t address, bool control_sfp, int /*sfp_mux*/) const
      67              : {
      68            0 :   return get_master_node_plain()->measure_endpoint_rtt(address, control_sfp);
      69              : }
      70              : //-----------------------------------------------------------------------------
      71              : 
      72              : //-----------------------------------------------------------------------------
      73              : void
      74            0 : MasterDesign::apply_endpoint_delay(uint32_t address,
      75              :                                             uint32_t coarse_delay,
      76              :                                             uint32_t fine_delay,
      77              :                                             uint32_t phase_delay,
      78              :                                             bool measure_rtt,
      79              :                                             bool control_sfp,
      80              :                                             int /*sfp_mux*/) const
      81              : {
      82            0 :   get_master_node_plain()->apply_endpoint_delay(address, coarse_delay, fine_delay, phase_delay, measure_rtt, control_sfp);
      83            0 : }
      84              : //-----------------------------------------------------------------------------
      85              : 
      86              : //-----------------------------------------------------------------------------
      87              : void
      88            0 : MasterDesign::enable_periodic_fl_cmd(uint32_t channel, double rate, bool poisson) const // NOLINT(build/unsigned)
      89              : {
      90            0 :   auto dts_clock_frequency = this->get_io_node_plain()->read_firmware_frequency();
      91            0 :   get_master_node_plain()->enable_periodic_fl_cmd(channel, rate, poisson, dts_clock_frequency);
      92            0 : }
      93              : //-----------------------------------------------------------------------------
      94              : 
      95              : //-----------------------------------------------------------------------------
      96              : void
      97            0 : MasterDesign::enable_periodic_fl_cmd(uint32_t command, uint32_t channel, double rate, bool poisson) const // NOLINT(build/unsigned)
      98              : {
      99            0 :   auto dts_clock_frequency = this->get_io_node_plain()->read_firmware_frequency();
     100            0 :   get_master_node_plain()->enable_periodic_fl_cmd(command, channel, rate, poisson, dts_clock_frequency);
     101            0 : }
     102              : //-----------------------------------------------------------------------------
     103              : 
     104              : //-----------------------------------------------------------------------------
     105              : uint32_t
     106            0 : MasterDesign::read_firmware_version() const // NOLINT(build/unsigned)
     107              : {
     108            0 :   auto firmware_version = this->get_master_node_plain()->getNode("global.version").read();
     109            0 :   uhal::Node::getClient().dispatch();
     110              : 
     111            0 :   return firmware_version.value();
     112            0 : }
     113              : //-----------------------------------------------------------------------------
     114              : 
     115              : //-----------------------------------------------------------------------------
     116              : void
     117            0 : MasterDesign::validate_firmware_version() const
     118              : {
     119            0 :   auto firmware_version = read_firmware_version();
     120              : 
     121            0 :   uint32_t major_firmware_version = (firmware_version >> 16) & 0xff;
     122            0 :   uint32_t minor_firmware_version = (firmware_version >> 8) & 0xff;
     123            0 :   uint32_t patch_firmware_version = (firmware_version >> 0) & 0xff;
     124              : 
     125            0 :   if (major_firmware_version != get_master_node_plain()->get_required_major_firmware_version())
     126            0 :     ers::error(IncompatibleMajorMasterFirmwareVersion(ERS_HERE, major_firmware_version, get_master_node_plain()->get_required_major_firmware_version()));
     127            0 :   if (minor_firmware_version != get_master_node_plain()->get_required_minor_firmware_version())
     128            0 :     ers::warning(IncompatibleMinorMasterFirmwareVersion(ERS_HERE, minor_firmware_version, get_master_node_plain()->get_required_minor_firmware_version()));
     129            0 :   if (patch_firmware_version != get_master_node_plain()->get_required_patch_firmware_version())
     130            0 :     ers::warning(IncompatiblePatchMasterFirmwareVersion(ERS_HERE, patch_firmware_version, get_master_node_plain()->get_required_patch_firmware_version()));
     131            0 : }
     132              : //-----------------------------------------------------------------------------
     133              : 
     134              : //-----------------------------------------------------------------------------
     135              : void
     136            0 : MasterDesign::get_info(timingfirmwareinfo::TimingDeviceInfo& mon_data) const
     137              : {
     138            0 :   TopDesign::get_info(mon_data);
     139            0 :   get_info(mon_data.master_info);
     140            0 : }
     141              : //-----------------------------------------------------------------------------
     142              : }
        

Generated by: LCOV version 2.0-1