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 % 57 0
Test Date: 2025-12-21 13:07:08 Functions: 0.0 % 5 0

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

Generated by: LCOV version 2.0-1