From abc0c99d6ef85709677288b87c5c73b6c33c36c3 Mon Sep 17 00:00:00 2001 From: "Ryan@WorkStation" Date: Thu, 26 Oct 2023 16:37:29 -0400 Subject: [PATCH] improved the Input Delay --- ClassDigitizer2Gen.cpp | 6 ++--- ClassDigitizer2Gen.h | 4 ++-- DigiParameters.h | 2 +- README.md | 14 +++++++++++- digiSettingsPanel.cpp | 51 +++++++++++++++++++++++++++++++----------- makeTest | 4 ++-- test.cpp | 27 ++++++++++++++++++---- 7 files changed, 82 insertions(+), 26 deletions(-) diff --git a/ClassDigitizer2Gen.cpp b/ClassDigitizer2Gen.cpp index f463505..438a9fa 100644 --- a/ClassDigitizer2Gen.cpp +++ b/ClassDigitizer2Gen.cpp @@ -25,7 +25,7 @@ void Digitizer2Gen::Initialization(){ serialNumber = 0; FPGAType = ""; nChannels = 0; - ch2ns = 0; + tick2ns = 0; CupVer = 0; outFileIndex = 0; @@ -238,7 +238,7 @@ int Digitizer2Gen::OpenDigitizer(const char * url){ 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; + tick2ns = 1000/adcRate; printf(" IP address : %s\n", ReadValue(PHA::DIG::IPAddress).c_str()); printf(" Net Mask : %s\n", ReadValue(PHA::DIG::NetMask).c_str()); @@ -247,7 +247,7 @@ int Digitizer2Gen::OpenDigitizer(const char * url){ printf(" DPP Type : %s (%d)\n", FPGAType.c_str(), FPGAVer); printf("Serial number : %d\n", serialNumber); printf(" ADC bits : %s\n", ReadValue(PHA::DIG::ADC_bit).c_str()); - printf(" ADC rate : %d Msps, ch2ns : %d ns\n", adcRate, ch2ns); + printf(" ADC rate : %d Msps, tick2ns : %d ns\n", adcRate, tick2ns); printf(" Channels : %d\n", nChannels); if( FPGAType == DPPType::PHA) { diff --git a/ClassDigitizer2Gen.h b/ClassDigitizer2Gen.h index 4bf647a..e86a930 100644 --- a/ClassDigitizer2Gen.h +++ b/ClassDigitizer2Gen.h @@ -37,7 +37,7 @@ class Digitizer2Gen { 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; - unsigned short ch2ns; + unsigned short tick2ns; std::string ModelName; void Initialization(); @@ -126,7 +126,7 @@ class Digitizer2Gen { void PrintChannelSettings(unsigned short ch); unsigned short GetNChannels() const {return nChannels;} - unsigned short GetCh2ns() const {return ch2ns;} + unsigned short GetTick2ns() const {return tick2ns;} uint64_t GetHandle() const {return handle;} Hit *hit; // should be hit[MaxNumber], when full or stopACQ, save into file diff --git a/DigiParameters.h b/DigiParameters.h index f33e4c8..3fc74f4 100644 --- a/DigiParameters.h +++ b/DigiParameters.h @@ -404,7 +404,7 @@ namespace PHA{ } namespace GROUP{ - const Reg InputDelay ("InputDelay", RW::ReadWrite, TYPE::GROUP, {{"0",""}, {"100", ""}, {"0.000001", ""}}, ANSTYPE::INTEGER, "sec"); + const Reg InputDelay ("InputDelay", RW::ReadWrite, TYPE::GROUP, {{"0",""}, {"32768", ""}, {"8", ""}}, ANSTYPE::INTEGER, "ns"); } namespace VGA{ diff --git a/README.md b/README.md index 84d7a51..c4a8db0 100644 --- a/README.md +++ b/README.md @@ -94,10 +94,22 @@ run ` qmake6 *.pro` it will generate Makefile then ` make` +# Using the CAENDig2.h + +The CAENDig2.h is not copied to system include path as the CAEN+FELib.h. But we can copy it from the source. In the caen_dig2-vXXXX folder, go to the include folder, copy the CAENDig2.h to /usr/local/include/. + +This enable us to compile code with -lCAEN_Dig2. For example, we can use the following to get the CAEN Dig2 Library version. +``` + char version[16]; + CAENDig2_GetLibVersion(version); + puts(version); +``` + # Known Issues - The "Trig." Rate in the Scaler does not included the coincident condition. This is related to the ChSavedEventCnt from the firmware. - LVDSTrgMask cannot acess. - The CoincidenceLengthT not loaded. - Sometime, the digitizer halt after sent the /cmd/armacquisition command. This is CAEN library problem. -- Event/Wave trig. Source cannot set as SWTrigger. \ No newline at end of file +- Event/Wave trig. Source cannot set as SWTrigger. +- After update to CAEN_FELIB_v1.2.5 and CAEN_DIG2_v1.5.10, old firmware version before 202309XXXX is not supported. \ No newline at end of file diff --git a/digiSettingsPanel.cpp b/digiSettingsPanel.cpp index 576cfee..55617b8 100644 --- a/digiSettingsPanel.cpp +++ b/digiSettingsPanel.cpp @@ -111,8 +111,7 @@ DigiSettingsPanel::DigiSettingsPanel(Digitizer2Gen ** digi, unsigned short nDigi Reg reg = infoIndex[j].second; QString text = QString::fromStdString(digi[iDigi]->ReadValue(reg)); if( reg.GetPara() == PHA::DIG::ADC_SampleRate.GetPara() ) { - short tick2ns = 1000/ text.toInt(); - text += " = " + QString::number(tick2ns, 'f', 1) + " ns" ; + text += " = " + QString::number(digi[iDigi]->GetTick2ns(), 'f', 1) + " ns" ; } leInfo[iDigi][j]->setText(text); infoLayout->addWidget(lab, j%nRow, 2*(j/nRow)); @@ -797,8 +796,7 @@ DigiSettingsPanel::DigiSettingsPanel(Digitizer2Gen ** digi, unsigned short nDigi //LVDSLayout->setSpacing(2); for(int k = 0; k < MaxNumberOfGroup; k ++){ - 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); + SetupSpinBox(spbInputDelay[iDigi][k], PHA::GROUP::InputDelay, k, false, "ch : " + QString::number(4*k) + " - " + QString::number(4*k+3) + " [ns] ", groupLayout, k/4, 2*(k%4)); } }else{ @@ -2524,7 +2522,12 @@ void DigiSettingsPanel::UpdatePanelFromMemory(bool onlyStatus){ } for (unsigned short j = 0; j < (unsigned short) infoIndex.size(); j++){ - leInfo[ID][j]->setText(QString::fromStdString(digi[ID]->GetSettingValue(infoIndex[j].second))); + Reg reg = infoIndex[j].second; + QString text = QString::fromStdString(digi[ID]->ReadValue(reg)); + if( reg.GetPara() == PHA::DIG::ADC_SampleRate.GetPara() ) { + text += " = " + QString::number(digi[ID]->GetTick2ns(), 'f', 1) + " ns" ; + } + leInfo[ID][j]->setText(text); } //-------- board settings @@ -2983,14 +2986,31 @@ void DigiSettingsPanel::SetupSpinBox(RSpinBox *&spb, const Reg para, int ch_inde msg = "DIG:"+ QString::number(digi[ID]->GetSerialNumber()) + "|" + QString::fromStdString(para.GetPara()) ; if( para.GetType() == TYPE::CH ) msg += ",CH:" + (index == -1 ? "All" : QString::number(index)); msg += " = " + QString::number(spb->value()); - if( digi[ID]->WriteValue(para, std::to_string(spb->value()), index)){ - SendLogMsg(msg + "|OK."); - spb->setStyleSheet(""); - UpdatePanelFromMemory(); - UpdateOtherPanels(); + + if( para.GetPara() == PHA::GROUP::InputDelay.GetPara() ){ + + if( digi[ID]->WriteValue(para, std::to_string(spb->value()/8), index)){ + SendLogMsg(msg + "|OK."); + spb->setStyleSheet(""); + UpdatePanelFromMemory(); + UpdateOtherPanels(); + }else{ + SendLogMsg(msg + "|Fail."); + spb->setStyleSheet("color:red;"); + } + + + }else{ - SendLogMsg(msg + "|Fail."); - spb->setStyleSheet("color:red;"); + if( digi[ID]->WriteValue(para, std::to_string(spb->value()), index)){ + SendLogMsg(msg + "|OK."); + spb->setStyleSheet(""); + UpdatePanelFromMemory(); + UpdateOtherPanels(); + }else{ + SendLogMsg(msg + "|Fail."); + spb->setStyleSheet("color:red;"); + } } }); } @@ -3093,7 +3113,12 @@ void DigiSettingsPanel::FillComboBoxValueFromMemory(RComboBox *&cbb, const Reg p void DigiSettingsPanel::FillSpinBoxValueFromMemory(RSpinBox *&spb, const Reg para, int ch_index){ QString result = QString::fromStdString(digi[ID]->GetSettingValue(para, ch_index)); //printf("%s === %s, %d, %p\n", __func__, result.toStdString().c_str(), ID, spb); - spb->setValue(result.toDouble()); + + if( para.GetPara() == PHA::GROUP::InputDelay.GetPara()) { + spb->setValue(result.toInt()*8); + }else{ + spb->setValue(result.toDouble()); + } } void DigiSettingsPanel::ReadBoardSetting(int cbIndex){ diff --git a/makeTest b/makeTest index 3789401..3b3fe81 100644 --- a/makeTest +++ b/makeTest @@ -1,6 +1,6 @@ CC = g++ COPTS = -fPIC -DLINUX -O2 -std=c++17 -lpthread -g -CAENLIBS = -lCAEN_FELib +CAENLIBS = -lCAEN_FELib -lCAEN_Dig2 CURLLIBS = -lcurl OBJS= ClassDigitizer2Gen.o influxdb.o @@ -8,7 +8,7 @@ OBJS= ClassDigitizer2Gen.o influxdb.o # # ################################################################ -all : test windowID +all : test # test : test.cpp ClassDigitizer2Gen.o influxdb.o diff --git a/test.cpp b/test.cpp index 802fb87..be08716 100644 --- a/test.cpp +++ b/test.cpp @@ -11,7 +11,6 @@ #include "ClassDigitizer2Gen.h" #include "influxdb.h" - #define maxRead 400 std::mutex digiMTX; @@ -78,6 +77,9 @@ static void StatLoop(){ } +#include + +int CAENDig2_GetLibVersion(char* version); int main(int argc, char* argv[]){ @@ -87,8 +89,20 @@ int main(int argc, char* argv[]){ remove("haha_000.sol"); - //const char * url = "dig2://192.168.0.100/"; - const char * url = "dig2://192.168.0.254/"; + char version[16]; + CAENDig2_GetLibVersion(version); + puts(version); + + char haha[100]; + CAEN_FELib_GetLibInfo(haha, 100); + puts(haha); + + CAEN_FELib_GetLibVersion(version); + puts(version); + +/* + const char * url = "dig2://192.168.0.100/"; + //const char * url = "dig2://192.168.0.254/"; digi->OpenDigitizer(url); //digi->Reset(); @@ -100,7 +114,8 @@ int main(int argc, char* argv[]){ digi->PrintChannelSettings(0); - + digi->ReadValue(PHA::CH::ADCToVolts, 0, true); + digi->SetDataFormat(DataFormat::ALL); digi->OpenOutFile("haha"); @@ -135,9 +150,13 @@ int main(int argc, char* argv[]){ digi->CloseOutFile(); + + digi->CloseDigitizer(); delete digi; +*/ + delete influx; }