LCOV - code coverage report
Current view: top level - wibmod/src/WIB1 - WIB_FAKE_CD.cpp (source / functions) Coverage Total Hit
Test: code.result Lines: 0.0 % 61 0
Test Date: 2026-10-11 15:05:20 Functions: 0.0 % 5 0

            Line data    Source code
       1              : #include "wibmod/WIB1/WIB.hh"
       2              : #include "wibmod/WIB1/WIBException.hh"
       3              : 
       4              : void
       5            0 : WIB::ConfigWIBFakeData(bool enableFakeFEMB1,
       6              :                        bool enableFakeFEMB2,
       7              :                        bool enableFakeFEMB3,
       8              :                        bool enableFakeFEMB4,
       9              :                        bool counter)
      10              : { // counter==true: counter instead of COLDATA frame, else samples in COLDATA frame
      11              : 
      12            0 :   if (DAQMode == FELIX) {
      13              :     // Don't allow fake mode on only half of a FELIX link
      14            0 :     if ((enableFakeFEMB1 ^ enableFakeFEMB2) || (enableFakeFEMB3 ^ enableFakeFEMB4)) {
      15            0 :       BUException::WIB_FAKE_DATA_ON_HALF_FELIX_LINK e;
      16            0 :       throw e;
      17            0 :     }
      18              :   }
      19              : 
      20              :   // Setup the FEMBs/Links
      21            0 :   for (size_t iFEMB = 1; iFEMB <= FEMBCount; iFEMB++) {
      22            0 :     for (size_t iCDA = 1; iCDA <= FEMBCDACount; iCDA++) {
      23            0 :       SetFEMBFakeCOLDATAMode(iFEMB, iCDA, counter);
      24              :     }
      25              :   }
      26              : 
      27            0 :   for (size_t iStream = 1; iStream <= FEMBStreamCount; iStream++) {
      28            0 :     SetFEMBStreamSource(1, iStream, !enableFakeFEMB1);
      29            0 :     SetFEMBStreamSource(2, iStream, !enableFakeFEMB2);
      30            0 :     SetFEMBStreamSource(3, iStream, !enableFakeFEMB3);
      31            0 :     SetFEMBStreamSource(4, iStream, !enableFakeFEMB4);
      32              :   }
      33              : 
      34            0 :   uint64_t enableWord1 = 0;
      35            0 :   uint64_t enableWord2 = 0;
      36            0 :   uint64_t enableWord3 = 0;
      37            0 :   uint64_t enableWord4 = 0;
      38            0 :   if (enableFakeFEMB1)
      39            0 :     enableWord1 = 0xF;
      40            0 :   if (enableFakeFEMB2)
      41            0 :     enableWord2 = 0xF;
      42            0 :   if (enableFakeFEMB3)
      43            0 :     enableWord3 = 0xF;
      44            0 :   if (enableFakeFEMB4)
      45            0 :     enableWord4 = 0xF;
      46            0 :   SourceFEMB(1, enableWord1);
      47            0 :   SourceFEMB(2, enableWord2);
      48            0 :   SourceFEMB(3, enableWord3);
      49            0 :   SourceFEMB(4, enableWord4);
      50            0 : }
      51              : 
      52              : uint8_t
      53            0 : WIB::GetFEMBStreamSource(uint8_t iFEMB, uint8_t iStream)
      54              : {
      55            0 :   CheckFEMBStreamInRange(iStream);
      56            0 :   std::string base = "FEMB0.DAQ.FAKE_CD.RX_DATA_SOURCE";
      57            0 :   base[4] = GetFEMBChar(iFEMB);
      58              :   // Read the current settings
      59            0 :   uint32_t data = Read(base);
      60            0 :   return (data >> (iStream - 1)) & 0x1;
      61            0 : }
      62              : void
      63            0 : WIB::SetFEMBStreamSource(uint8_t iFEMB, uint8_t iStream, bool real)
      64              : {
      65            0 :   CheckFEMBStreamInRange(iStream);
      66            0 :   std::string base = "FEMB0.DAQ.FAKE_CD.RX_DATA_SOURCE";
      67            0 :   base[4] = GetFEMBChar(iFEMB);
      68              :   // Read the current settings
      69            0 :   uint32_t data = Read(base);
      70              :   // update the mask
      71            0 :   iStream--; // iStream is 1-4, but we want bits 0 to 3
      72            0 :   if (real) {
      73            0 :     data &= ~(0x1 << iStream);
      74              :   } else {
      75            0 :     data |= 0x1 << iStream;
      76              :   }
      77            0 :   Write(base, data);
      78            0 : }
      79              : 
      80              : void
      81            0 : WIB::SetFEMBFakeCOLDATAMode(uint8_t iFEMB, uint8_t iCD, bool mode)
      82              : {
      83            0 :   std::string base("FEMB0.DAQ.FAKE_CD.CD0.");
      84            0 :   base[4] = GetFEMBChar(iFEMB);
      85            0 :   base[20] = GetFEMBCDChar(iCD);
      86              : 
      87              :   // Set this COLDATA ASIC
      88            0 :   Write(base + "FAKE_MODE", uint32_t(mode));
      89            0 : }
      90              : 
      91              : uint8_t
      92            0 : WIB::GetFEMBFakeCOLDATAMode(uint8_t iFEMB, uint8_t iCD)
      93              : {
      94            0 :   std::string base("FEMB0.DAQ.FAKE_CD.CD0.");
      95            0 :   base[4] = GetFEMBChar(iFEMB);
      96            0 :   base[20] = GetFEMBCDChar(iCD);
      97              : 
      98            0 :   return Read(base + "FAKE_MODE");
      99            0 : }
        

Generated by: LCOV version 2.0-1