From c215d3cea114de91dae30a6fe7ed4883b028230e Mon Sep 17 00:00:00 2001 From: "Ryan@WorkStation" Date: Wed, 25 Oct 2023 15:06:33 -0400 Subject: [PATCH] add CupVer protection for Input Delay setting --- ClassDigitizer2Gen.cpp | 39 ++++++++++++++++++++++----------------- ClassDigitizer2Gen.h | 2 ++ digiSettingsPanel.cpp | 8 +++++--- 3 files changed, 29 insertions(+), 20 deletions(-) diff --git a/ClassDigitizer2Gen.cpp b/ClassDigitizer2Gen.cpp index 4de19cf..f463505 100644 --- a/ClassDigitizer2Gen.cpp +++ b/ClassDigitizer2Gen.cpp @@ -26,6 +26,7 @@ void Digitizer2Gen::Initialization(){ FPGAType = ""; nChannels = 0; ch2ns = 0; + CupVer = 0; outFileIndex = 0; FinishedOutFilesSize = 0; @@ -235,6 +236,7 @@ int Digitizer2Gen::OpenDigitizer(const char * url){ FPGAVer = atoi(ReadValue(PHA::DIG::CupVer).c_str()); nChannels = atoi(ReadValue(PHA::DIG::NumberOfChannel).c_str()); ModelName = ReadValue(PHA::DIG::ModelName); + CupVer = atoi(ReadValue(PHA::DIG::CupVer).c_str()); int adcRate = atoi(ReadValue(PHA::DIG::ADC_SampleRate).c_str()); ch2ns = 1000/adcRate; @@ -1079,10 +1081,12 @@ void Digitizer2Gen::PrintBoardSettings(){ } } - for(int idx = 0; idx < 16 ; idx ++ ){ - printf("%-45s %d %s\n", InputDelay[idx].GetFullPara(idx).c_str(), - InputDelay[idx].ReadWrite(), - InputDelay[idx].GetValue().c_str()); + if( CupVer >= 2023091800 ){ + for(int idx = 0; idx < 16 ; idx ++ ){ + printf("%-45s %d %s\n", InputDelay[idx].GetFullPara(idx).c_str(), + InputDelay[idx].ReadWrite(), + InputDelay[idx].GetValue().c_str()); + } } for( int i = 0; i < (int) LVDSSettings[0].size(); i++){ @@ -1144,7 +1148,7 @@ void Digitizer2Gen::ReadAllSettings(){ if( ModelName == "VX2745") for(int i = 0; i < 4 ; i ++) ReadValue(VGASetting[i], i); - for( int idx = 0; idx < 16; idx++) ReadValue(InputDelay[idx], idx, false); + if( CupVer >= 2023091800 ) for( int idx = 0; idx < 16; idx++) ReadValue(InputDelay[idx], idx, false); for( int index = 0; index < 4; index++){ for( int i = 0; i < (int) LVDSSettings[index].size(); i++){ @@ -1202,18 +1206,19 @@ int Digitizer2Gen::SaveSettingsToFile(const char * saveFileName, bool setReadOnl count ++; } - for( int idx = 0; idx < 16; idx ++){ - totCount ++; - if( InputDelay[idx].GetValue() == "" ) { - printf(" No value for %s \n", InputDelay[idx].GetPara().c_str()); - continue; + if( CupVer >= 2023091800 ){ + for( int idx = 0; idx < 16; idx ++){ + totCount ++; + if( InputDelay[idx].GetValue() == "" ) { + printf(" No value for %s \n", InputDelay[idx].GetPara().c_str()); + continue; + } + fprintf(saveFile, "%-45s!%d!%4d!%s\n", InputDelay[idx].GetFullPara(idx).c_str(), + InputDelay[idx].ReadWrite(), + 9050 + idx, + InputDelay[idx].GetValue().c_str()); + count ++; } - fprintf(saveFile, "%-45s!%d!%4d!%s\n", InputDelay[idx].GetFullPara(idx).c_str(), - InputDelay[idx].ReadWrite(), - 9050 + idx, - InputDelay[idx].GetValue().c_str()); - count ++; - } if( ModelName == "VX2745" && FPGAType == DPPType::PHA) { @@ -1350,7 +1355,7 @@ bool Digitizer2Gen::LoadSettingsFromFile(const char * loadFileName){ }else if ( 9000 <= id && id < 9050){ // vga VGASetting[id - 9000].SetValue(value); }else{ // group - InputDelay[id - 9050].SetValue(value); + if( CupVer >= 2023091800 ) InputDelay[id - 9050].SetValue(value); } //printf("%s|%s|%d|%s|\n", para, readWrite, id, value); if( std::strcmp(readWrite, "2") == 0 && isConnected) WriteValue(para, value, false); diff --git a/ClassDigitizer2Gen.h b/ClassDigitizer2Gen.h index e883228..4bf647a 100644 --- a/ClassDigitizer2Gen.h +++ b/ClassDigitizer2Gen.h @@ -33,6 +33,7 @@ class Digitizer2Gen { char retValue[256]; unsigned short serialNumber; + unsigned int CupVer; std::string FPGAType; // look the DigitiParameter.h::PHA::DIG::FirwareType, DPP_PHA, DPP_ZLE, DPP_PSD, DPP_DAW, DPP_OPEN, and Scope unsigned int FPGAVer; // for checking copy setting unsigned short nChannels; @@ -77,6 +78,7 @@ class Digitizer2Gen { std::string GetFPGAType() const {return FPGAType;} std::string GetModelName() const {return ModelName;} unsigned int GetFPGAVersion() const {return FPGAVer;} + unsigned int GetCupVer() const {return CupVer;} void SetDummy(unsigned short sn); bool IsDummy() const {return isDummy;} diff --git a/digiSettingsPanel.cpp b/digiSettingsPanel.cpp index ce8de87..576cfee 100644 --- a/digiSettingsPanel.cpp +++ b/digiSettingsPanel.cpp @@ -788,7 +788,8 @@ DigiSettingsPanel::DigiSettingsPanel(Digitizer2Gen ** digi, unsigned short nDigi } - {//^====================== Group = InputDelay + if( digi[iDigi]->GetCupVer() >= 2023091800 ){ + //^====================== Group = InputDelay bdGroup[iDigi] = new QWidget(this); bdTab->addTab(bdGroup[iDigi], "Input Delay"); QGridLayout * groupLayout = new QGridLayout(bdGroup[iDigi]); @@ -799,8 +800,9 @@ DigiSettingsPanel::DigiSettingsPanel(Digitizer2Gen ** digi, unsigned short nDigi SetupSpinBox(spbInputDelay[iDigi][k], PHA::GROUP::InputDelay, k, false, "ch : " + QString::number(4*k) + " - " + QString::number(4*k+3) + " [s] ", groupLayout, k/4, 2*(k%4)); spbInputDelay[iDigi][k]->setDecimals(6); } - - + + }else{ + bdGroup[iDigi] = nullptr; } }