From 29c8c95d0de03db907bd6bb917259f1947cd0be5 Mon Sep 17 00:00:00 2001 From: splitPoleDAQ Date: Fri, 12 May 2023 16:06:32 -0400 Subject: [PATCH] added inquiry tab in the digi panel --- ClassDigitizer.cpp | 100 ++++++++----- ClassDigitizer.h | 1 + CustomThreads.h | 25 +--- DigiSettingsPanel.cpp | 320 +++++++++++++++++++++++++++++++++++++++--- DigiSettingsPanel.h | 7 + FSUDAQ.cpp | 14 +- RegisterAddress.h | 34 ++--- Scope.cpp | 8 ++ Scope.h | 7 +- 9 files changed, 406 insertions(+), 110 deletions(-) diff --git a/ClassDigitizer.cpp b/ClassDigitizer.cpp index 45b90fd..d8fe6ae 100644 --- a/ClassDigitizer.cpp +++ b/ClassDigitizer.cpp @@ -317,7 +317,6 @@ int Digitizer::ProgramPHABoard(){ address = DPP::PHA::TriggerHoldOffWidth; ret |= CAEN_DGTZ_WriteRegister(handle, address + 0x7000 , 0x3E ); address = DPP::PHA::RiseTimeValidationWindow;ret |= CAEN_DGTZ_WriteRegister(handle, address + 0x7000 , 0x0 ); - ret |= CAEN_DGTZ_WriteRegister(handle, (uint32_t)(DPP::ChannelDCOffset) + 0x7000 , 0xEEEE ); ret |= CAEN_DGTZ_WriteRegister(handle, (uint32_t)(DPP::PreTrigger) + 0x7000 , 32 ); ret |= CAEN_DGTZ_WriteRegister(handle, (uint32_t)(DPP::InputDynamicRange) + 0x7000 , 0x0 ); @@ -335,6 +334,31 @@ int Digitizer::ProgramPHABoard(){ return ret; } +int Digitizer::ProgramPSDBoard(){ + + printf("===== Digitizer::%s\n", __func__); + + ret = CAEN_DGTZ_Reset(handle); + ret = CAEN_DGTZ_WriteRegister(handle, DPP::RecordLength_G + 0x7000, 62); + ret = CAEN_DGTZ_WriteRegister(handle, DPP::BoardConfiguration, 0x0F3911); /// has Extra2, dual trace, input and CFD + + ret = CAEN_DGTZ_SetAcquisitionMode(handle, CAEN_DGTZ_SW_CONTROLLED); /// software command + ret |= CAEN_DGTZ_SetIOLevel(handle, CAEN_DGTZ_IOLevel_NIM); + ret |= CAEN_DGTZ_SetExtTriggerInputMode(handle, CAEN_DGTZ_TRGMODE_ACQ_ONLY); + + ret = CAEN_DGTZ_SetChannelEnableMask(handle, 0xFFFF); + + ret |= CAEN_DGTZ_WriteRegister(handle, (uint32_t)(DPP::ChannelDCOffset) + 0x7000 , 0xEEEE ); + + ret |= CAEN_DGTZ_WriteRegister(handle, (uint32_t)(DPP::PreTrigger) + 0x7000 , 32 ); + ret |= CAEN_DGTZ_WriteRegister(handle, (uint32_t)(DPP::RecordLength_G) + 0x7000 , 128 ); + + if( ret != 0 ) { printf("==== set channels error.\n"); return 0;} + + ReadAllSettingsFromBoard(); + return ret; +} + //========================================================= ACQ control void Digitizer::StartACQ(){ if ( AcqRun ) return; @@ -344,6 +368,8 @@ void Digitizer::StartACQ(){ printf("============= buffer size bigger than 160 MB"); return; } + + if( DPPType == V1730_DPP_PSD_CODE) bufferSize = 80 * 1024 * 1024; //TODO allocate 80 MB for PSD data->AllocateMemory(bufferSize); ret = CAEN_DGTZ_SWStartAcquisition(handle); @@ -353,7 +379,7 @@ void Digitizer::StartACQ(){ return; } - printf("\e[1m\e[33m======= Acquisition Started for Board %d\e[0m\n", boardID); + printf("\e[1m\e[33m======= Acquisition Started for %d | Board %d, Port %d\e[0m\n", BoardInfo.SerialNumber, boardID, portID); AcqRun = true; data->ClearTriggerRate(); } @@ -363,7 +389,7 @@ void Digitizer::StopACQ(){ int ret = CAEN_DGTZ_SWStopAcquisition(handle); ret |= CAEN_DGTZ_ClearData(handle); if( ret != 0 ) ErrorMsg("something wrong when try to stop ACQ and clear buffer"); - printf("\n\e[1m\e[33m====== Acquisition STOPPED for Board %d\e[0m\n", boardID); + printf("\n\e[1m\e[33m====== Acquisition STOPPED for %d | Board %d, Port %d\e[0m\n", BoardInfo.SerialNumber, boardID, portID); AcqRun = false; data->ClearTriggerRate(); data->ClearBuffer(); @@ -827,40 +853,40 @@ std::string Digitizer::GetDPPString(int DPPType){ void Digitizer::ErrorMsg(std::string header){ switch (ret){ ///case CAEN_DGTZ_Success : /** 0 */ printf("%s | Operation completed successfully.\n", header.c_str()); break; - case CAEN_DGTZ_CommError : /** -1 */ printf("%s | Communication Error.\n", header.c_str()); break; - case CAEN_DGTZ_GenericError : /** -2 */ printf("%s | Unspecified error.\n", header.c_str()); break; - case CAEN_DGTZ_InvalidParam : /** -3 */ printf("%s | Invalid parameter.\n", header.c_str()); break; - case CAEN_DGTZ_InvalidLinkType : /** -4 */ printf("%s | Invalid Link Type.\n", header.c_str()); break; - case CAEN_DGTZ_InvalidHandle : /** -5 */ printf("%s | Invalid device handler.\n", header.c_str()); break; - case CAEN_DGTZ_MaxDevicesError : /** -6 */ printf("%s | Maximum number of devices exceeded.\n", header.c_str()); break; - case CAEN_DGTZ_BadBoardType : /** -7 */ printf("%s | Operation not allowed on this type of board.\n", header.c_str()); break; - case CAEN_DGTZ_BadInterruptLev : /** -8 */ printf("%s | The interrupt level is not allowed.\n", header.c_str()); break; - case CAEN_DGTZ_BadEventNumber : /** -9 */ printf("%s | The event number is bad.\n", header.c_str()); break; - case CAEN_DGTZ_ReadDeviceRegisterFail : /** -10 */ printf("%s | Unable to read the registry.\n", header.c_str()); break; - case CAEN_DGTZ_WriteDeviceRegisterFail : /** -11 */ printf("%s | Unable to write the registry.\n", header.c_str()); break; - case CAEN_DGTZ_InvalidChannelNumber : /** -13 */ printf("%s | The channel number is invalid.\n", header.c_str()); break; - case CAEN_DGTZ_ChannelBusy : /** -14 */ printf("%s | The channel is busy.\n", header.c_str()); break; - case CAEN_DGTZ_FPIOModeInvalid : /** -15 */ printf("%s | Invalid FPIO mode.\n", header.c_str()); break; - case CAEN_DGTZ_WrongAcqMode : /** -16 */ printf("%s | Wrong Acquistion mode.\n", header.c_str()); break; - case CAEN_DGTZ_FunctionNotAllowed : /** -17 */ printf("%s | This function is not allowed on this module.\n", header.c_str()); break; - case CAEN_DGTZ_Timeout : /** -18 */ printf("%s | Communication Timeout.\n", header.c_str()); break; - case CAEN_DGTZ_InvalidBuffer : /** -19 */ printf("%s | The buffer is invalid.\n", header.c_str()); break; - case CAEN_DGTZ_EventNotFound : /** -20 */ printf("%s | The event is not found.\n", header.c_str()); break; - case CAEN_DGTZ_InvalidEvent : /** -21 */ printf("%s | The event is invalid.\n", header.c_str()); break; - case CAEN_DGTZ_OutOfMemory : /** -22 */ printf("%s | Out of memory.\n", header.c_str()); break; - case CAEN_DGTZ_CalibrationError : /** -23 */ printf("%s | Unable to calibrate the board.\n", header.c_str()); break; - case CAEN_DGTZ_DigitizerNotFound : /** -24 */ printf("%s | Unbale to open the digitizer.\n", header.c_str()); break; - case CAEN_DGTZ_DigitizerAlreadyOpen : /** -25 */ printf("%s | The digitizer is already open.\n", header.c_str()); break; - case CAEN_DGTZ_DigitizerNotReady : /** -26 */ printf("%s | The digitizer is not ready.\n", header.c_str()); break; - case CAEN_DGTZ_InterruptNotConfigured : /** -27 */ printf("%s | The digitizer has no IRQ configured.\n", header.c_str()); break; - case CAEN_DGTZ_DigitizerMemoryCorrupted: /** -28 */ printf("%s | The digitizer flash memory is corrupted.\n", header.c_str()); break; - case CAEN_DGTZ_DPPFirmwareNotSupported : /** -29 */ printf("%s | The digitier DPP firmware is not supported in this lib version.\n", header.c_str()); break; - case CAEN_DGTZ_InvalidLicense : /** -30 */ printf("%s | Invalid firmware licence.\n", header.c_str()); break; - case CAEN_DGTZ_InvalidDigitizerStatus : /** -31 */ printf("%s | The digitizer is found in a corrupted status.\n", header.c_str()); break; - case CAEN_DGTZ_UnsupportedTrace : /** -32 */ printf("%s | The given trace is not supported.\n", header.c_str()); break; - case CAEN_DGTZ_InvalidProbe : /** -33 */ printf("%s | The given probe is not supported.\n", header.c_str()); break; - case CAEN_DGTZ_UnsupportedBaseAddress : /** -34 */ printf("%s | The base address is not supported.\n", header.c_str()); break; - case CAEN_DGTZ_NotYetImplemented : /** -99 */ printf("%s | The function is not yet implemented.\n", header.c_str()); break; + case CAEN_DGTZ_CommError : /** -1 */ printf("%s %d | Communication Error.\n", header.c_str(), BoardInfo.SerialNumber); break; + case CAEN_DGTZ_GenericError : /** -2 */ printf("%s %d | Unspecified error.\n", header.c_str(), BoardInfo.SerialNumber); break; + case CAEN_DGTZ_InvalidParam : /** -3 */ printf("%s %d | Invalid parameter.\n", header.c_str(), BoardInfo.SerialNumber); break; + case CAEN_DGTZ_InvalidLinkType : /** -4 */ printf("%s %d | Invalid Link Type.\n", header.c_str(), BoardInfo.SerialNumber); break; + case CAEN_DGTZ_InvalidHandle : /** -5 */ printf("%s %d | Invalid device handler.\n", header.c_str(), BoardInfo.SerialNumber); break; + case CAEN_DGTZ_MaxDevicesError : /** -6 */ printf("%s %d | Maximum number of devices exceeded.\n", header.c_str(), BoardInfo.SerialNumber); break; + case CAEN_DGTZ_BadBoardType : /** -7 */ printf("%s %d | Operation not allowed on this type of board.\n", header.c_str(), BoardInfo.SerialNumber); break; + case CAEN_DGTZ_BadInterruptLev : /** -8 */ printf("%s %d | The interrupt level is not allowed.\n", header.c_str(), BoardInfo.SerialNumber); break; + case CAEN_DGTZ_BadEventNumber : /** -9 */ printf("%s %d | The event number is bad.\n", header.c_str(), BoardInfo.SerialNumber); break; + case CAEN_DGTZ_ReadDeviceRegisterFail : /** -10 */ printf("%s %d | Unable to read the registry.\n", header.c_str(), BoardInfo.SerialNumber); break; + case CAEN_DGTZ_WriteDeviceRegisterFail : /** -11 */ printf("%s %d | Unable to write the registry.\n", header.c_str(), BoardInfo.SerialNumber); break; + case CAEN_DGTZ_InvalidChannelNumber : /** -13 */ printf("%s %d | The channel number is invalid.\n", header.c_str(), BoardInfo.SerialNumber); break; + case CAEN_DGTZ_ChannelBusy : /** -14 */ printf("%s %d | The channel is busy.\n", header.c_str(), BoardInfo.SerialNumber); break; + case CAEN_DGTZ_FPIOModeInvalid : /** -15 */ printf("%s %d | Invalid FPIO mode.\n", header.c_str(), BoardInfo.SerialNumber); break; + case CAEN_DGTZ_WrongAcqMode : /** -16 */ printf("%s %d | Wrong Acquistion mode.\n", header.c_str(), BoardInfo.SerialNumber); break; + case CAEN_DGTZ_FunctionNotAllowed : /** -17 */ printf("%s %d | This function is not allowed on this module.\n", header.c_str(), BoardInfo.SerialNumber); break; + case CAEN_DGTZ_Timeout : /** -18 */ printf("%s %d | Communication Timeout.\n", header.c_str(), BoardInfo.SerialNumber); break; + case CAEN_DGTZ_InvalidBuffer : /** -19 */ printf("%s %d | The buffer is invalid.\n", header.c_str(), BoardInfo.SerialNumber); break; + case CAEN_DGTZ_EventNotFound : /** -20 */ printf("%s %d | The event is not found.\n", header.c_str(), BoardInfo.SerialNumber); break; + case CAEN_DGTZ_InvalidEvent : /** -21 */ printf("%s %d | The event is invalid.\n", header.c_str(), BoardInfo.SerialNumber); break; + case CAEN_DGTZ_OutOfMemory : /** -22 */ printf("%s %d | Out of memory.\n", header.c_str(), BoardInfo.SerialNumber); break; + case CAEN_DGTZ_CalibrationError : /** -23 */ printf("%s %d | Unable to calibrate the board.\n", header.c_str(), BoardInfo.SerialNumber); break; + case CAEN_DGTZ_DigitizerNotFound : /** -24 */ printf("%s %d | Unbale to open the digitizer.\n", header.c_str(), BoardInfo.SerialNumber); break; + case CAEN_DGTZ_DigitizerAlreadyOpen : /** -25 */ printf("%s %d | The digitizer is already open.\n", header.c_str(), BoardInfo.SerialNumber); break; + case CAEN_DGTZ_DigitizerNotReady : /** -26 */ printf("%s %d | The digitizer is not ready.\n", header.c_str(), BoardInfo.SerialNumber); break; + case CAEN_DGTZ_InterruptNotConfigured : /** -27 */ printf("%s %d | The digitizer has no IRQ configured.\n", header.c_str(), BoardInfo.SerialNumber); break; + case CAEN_DGTZ_DigitizerMemoryCorrupted: /** -28 */ printf("%s %d | The digitizer flash memory is corrupted.\n", header.c_str(), BoardInfo.SerialNumber); break; + case CAEN_DGTZ_DPPFirmwareNotSupported : /** -29 */ printf("%s %d | The digitier DPP firmware is not supported in this lib version.\n", header.c_str(), BoardInfo.SerialNumber); break; + case CAEN_DGTZ_InvalidLicense : /** -30 */ printf("%s %d | Invalid firmware licence.\n", header.c_str(), BoardInfo.SerialNumber); break; + case CAEN_DGTZ_InvalidDigitizerStatus : /** -31 */ printf("%s %d | The digitizer is found in a corrupted status.\n", header.c_str(), BoardInfo.SerialNumber); break; + case CAEN_DGTZ_UnsupportedTrace : /** -32 */ printf("%s %d | The given trace is not supported.\n", header.c_str(), BoardInfo.SerialNumber); break; + case CAEN_DGTZ_InvalidProbe : /** -33 */ printf("%s %d | The given probe is not supported.\n", header.c_str(), BoardInfo.SerialNumber); break; + case CAEN_DGTZ_UnsupportedBaseAddress : /** -34 */ printf("%s %d | The base address is not supported.\n", header.c_str(), BoardInfo.SerialNumber); break; + case CAEN_DGTZ_NotYetImplemented : /** -99 */ printf("%s %d | The function is not yet implemented.\n", header.c_str(), BoardInfo.SerialNumber); break; } } diff --git a/ClassDigitizer.h b/ClassDigitizer.h index d914a44..14d1982 100644 --- a/ClassDigitizer.h +++ b/ClassDigitizer.h @@ -77,6 +77,7 @@ class Digitizer{ void PrintBoard() ; virtual int ProgramBoard() ; /// program a generic board, no program channel int ProgramPHABoard() ; /// program a default PHA board with dual trace + int ProgramPSDBoard() ; //^================ ACQ control void StopACQ(); diff --git a/CustomThreads.h b/CustomThreads.h index 47f6963..2d7f0e9 100644 --- a/CustomThreads.h +++ b/CustomThreads.h @@ -36,30 +36,9 @@ public: }else{ printf("ReadDataThread::%s------------ ret : %d \n", __func__, ret); - if( ret == CAEN_DGTZ_WrongAcqMode) break; + digi->StopACQ(); + break; } - - // // if( ret == CAEN_FELib_Success){ - // // if( isSaveData) digi->SaveDataToFile(); - // // }else if(ret == CAEN_FELib_Stop){ - // // digi->ErrorMsg("No more data"); - // // //emit endOfLastData(); - // // break; - // // }else{ - // // //digi->ErrorMsg("ReadDataLoop()"); - // // digi->evt->ClearTrace(); - // // } - - // // if( isSaveData ){ - // // clock_gettime(CLOCK_REALTIME, &tb); - // // if( tb.tv_sec - ta.tv_sec > 2 ) { - // // emit sendMsg("FileSize ("+ QString::number(digi->GetSerialNumber()) +"): " + QString::number(digi->GetTotalFilesSize()/1024./1024.) + " MB"); - // // //emit checkFileSize(); - // // //double duration = tb.tv_nsec-ta.tv_nsec + tb.tv_sec*1e+9 - ta.tv_sec*1e+9; - // // //printf("%4d, duration : %10.0f, %6.1f\n", readCount, duration, 1e9/duration); - // // ta = tb; - // // } - // // } } } signals: diff --git a/DigiSettingsPanel.cpp b/DigiSettingsPanel.cpp index 0ffec65..b33a240 100644 --- a/DigiSettingsPanel.cpp +++ b/DigiSettingsPanel.cpp @@ -6,7 +6,8 @@ #include #include #include - +#include +#include // bit = 0, bit = 1 std::vector, unsigned short>> ACQToolTip = {{{"ACQ STOP", "ACQ RUN"}, 2}, {{"No Event", "Has Events"}, 3}, @@ -110,6 +111,16 @@ DigiSettingsPanel::DigiSettingsPanel(Digitizer ** digi, unsigned int nDigi, QStr statusLayout->addWidget(bnACQStatus[ID][i], rowID, i + 1); } + leACQStatus[ID] = new QLineEdit(boardStatusBox); + leACQStatus[ID]->setAlignment(Qt::AlignCenter); + //leACQStatus[ID]->setFixedWidth(60); + leACQStatus[ID]->setReadOnly(true); + statusLayout->addWidget(leACQStatus[ID], rowID, 10); + + QPushButton * bnUpdateStatus = new QPushButton("Update Status", boardStatusBox); + statusLayout->addWidget(bnUpdateStatus, rowID, 14); + connect( bnUpdateStatus, &QPushButton::clicked, this, &DigiSettingsPanel::UpdateBoardAndChannelsStatus); + rowID ++; //============================== QLabel * bdFailLabel = new QLabel("Board Failure status : ", boardStatusBox); bdFailLabel->setAlignment(Qt::AlignRight | Qt::AlignCenter); @@ -123,6 +134,12 @@ DigiSettingsPanel::DigiSettingsPanel(Digitizer ** digi, unsigned int nDigi, QStr statusLayout->addWidget(bnBdFailStatus[ID][i], rowID, i + 1); } + leBdFailStatus[ID] = new QLineEdit(boardStatusBox); + leBdFailStatus[ID]->setAlignment(Qt::AlignCenter); + leBdFailStatus[ID]->setFixedWidth(60); + leBdFailStatus[ID]->setReadOnly(true); + statusLayout->addWidget(leBdFailStatus[ID], rowID, 4, 1, 4); + QLabel * ReadoutLabel = new QLabel("Readout status : ", boardStatusBox); ReadoutLabel->setAlignment(Qt::AlignRight | Qt::AlignCenter); statusLayout->addWidget(ReadoutLabel, rowID, 10); @@ -135,6 +152,12 @@ DigiSettingsPanel::DigiSettingsPanel(Digitizer ** digi, unsigned int nDigi, QStr statusLayout->addWidget(bnReadOutStatus[ID][i], rowID, i + 11); } + leReadOutStatus[ID] = new QLineEdit(boardStatusBox); + leReadOutStatus[ID]->setAlignment(Qt::AlignCenter); + //leReadOutStatus[ID]->setFixedWidth(60); + leReadOutStatus[ID]->setReadOnly(true); + statusLayout->addWidget(leReadOutStatus[ID], rowID, 14); + } {//^======================= Buttons @@ -160,7 +183,12 @@ DigiSettingsPanel::DigiSettingsPanel(Digitizer ** digi, unsigned int nDigi, QStr bnProgramPreDefined = new QPushButton("Program Default", this); buttonLayout->addWidget(bnProgramPreDefined, rowID, 1); - connect(bnProgramPreDefined, &QPushButton::clicked, this, [=](){ digi[ID]->ProgramPHABoard();}); //TODO for PSD + connect(bnProgramPreDefined, &QPushButton::clicked, this, [=](){ + if( digi[ID]->GetDPPType() == V1730_DPP_PHA_CODE ) digi[ID]->ProgramPHABoard(); + if( digi[ID]->GetDPPType() == V1730_DPP_PSD_CODE ) digi[ID]->ProgramPSDBoard(); + + ReadSettingsFromBoard(); + }); bnClearBuffer = new QPushButton("Clear Buffer/FIFO", this); buttonLayout->addWidget(bnClearBuffer, rowID, 2); @@ -253,6 +281,236 @@ DigiSettingsPanel::DigiSettingsPanel(Digitizer ** digi, unsigned int nDigi, QStr } //TODO ----- Copy settings tab + {//*##################################### Inquiry / Copy Tab + QWidget * inquiryTab = new QWidget(this); + tabWidget->addTab(inquiryTab, "Inquiry / Copy"); + + QGridLayout * layout = new QGridLayout(inquiryTab); + layout->setAlignment(Qt::AlignTop | Qt::AlignLeft); + + {//================ Inquiry + QGroupBox * inquiryBox = new QGroupBox("Register Settings", inquiryTab); + layout->addWidget(inquiryBox); + + QGridLayout * regLayout = new QGridLayout(inquiryBox); + + QLabel * lb1 = new QLabel("Register", inquiryBox); lb1->setAlignment(Qt::AlignCenter); regLayout->addWidget(lb1, 0, 1); + QLabel * lb2 = new QLabel("R/W", inquiryBox); lb2->setAlignment(Qt::AlignCenter); regLayout->addWidget(lb2, 0, 2); + QLabel * lb3 = new QLabel("Present Value", inquiryBox); lb3->setAlignment(Qt::AlignCenter); regLayout->addWidget(lb3, 0, 3); + QLabel * lb4 = new QLabel("Set Value", inquiryBox); lb4->setAlignment(Qt::AlignCenter); regLayout->addWidget(lb4, 0, 4); + + ///--------------- board + RComboBox * cbDigi = new RComboBox(inquiryBox); + for( int i = 0; i < (int) nDigi; i++) cbDigi->addItem("Digi-" + QString::number(digi[i]->GetSerialNumber()), i); + regLayout->addWidget(cbDigi, 1, 0); + + RComboBox * cbBdReg = new RComboBox(inquiryBox); + for( int i = 0; i < (int) RegisterDPPList.size() ; i++ ){ + cbBdReg->addItem( QString::fromStdString(RegisterDPPList[i].GetName()) + " [0x" + QString::number(RegisterDPPList[i].GetAddress(), 16).toUpper() + "]", RegisterDPPList[i].GetAddress()); + } + regLayout->addWidget(cbBdReg, 1, 1); + + QLineEdit * leBdRegRW = new QLineEdit(inquiryBox); + leBdRegRW->setReadOnly(true); + regLayout->addWidget(leBdRegRW, 1, 2); + + QLineEdit * leBdRegValue = new QLineEdit(inquiryBox); + leBdRegValue->setReadOnly(true); + regLayout->addWidget(leBdRegValue, 1, 3); + + QLineEdit * leBdRegSet = new QLineEdit(inquiryBox); + regLayout->addWidget(leBdRegSet, 1, 4); + + ///--------------- channel + RComboBox * cbCh = new RComboBox(inquiryBox); + regLayout->addWidget(cbCh, 2, 0); + + RComboBox * cbChReg = new RComboBox(inquiryBox); + regLayout->addWidget(cbChReg, 2, 1); + + QLineEdit * leChRegRW = new QLineEdit(inquiryBox); + leChRegRW->setReadOnly(true); + regLayout->addWidget(leChRegRW, 2, 2); + + QLineEdit * leChRegValue = new QLineEdit(inquiryBox); + leChRegValue->setReadOnly(true); + regLayout->addWidget(leChRegValue, 2, 3); + + QLineEdit * leChRegSet = new QLineEdit(inquiryBox); + regLayout->addWidget(leChRegSet, 2, 4); + + + connect(cbDigi, &RComboBox::currentIndexChanged, this, [=](int index){ + enableSignalSlot = false; + + cbCh->clear(); + for( int i = 0; i < digi[index]->GetNChannels(); i ++ ) cbCh->addItem("Ch-" + QString::number(i), i); + + if( digi[index]->GetDPPType() == V1730_DPP_PHA_CODE ) chRegList = RegisterPHAList; + if( digi[index]->GetDPPType() == V1730_DPP_PSD_CODE ) chRegList = RegisterPSDList; + + cbChReg->clear(); + for( int i = 0; i < (int) chRegList.size(); i++ ){ + cbChReg->addItem(QString::fromStdString(chRegList[i].GetName()) + " [0x" + QString::number(chRegList[i].GetAddress(), 16).toUpper() + "]", chRegList[i].GetAddress()); + } + enableSignalSlot = true; + }); + + cbDigi->currentIndexChanged(0); + + connect(cbBdReg, &RComboBox::currentIndexChanged, this, [=](int index){ + if( !enableSignalSlot ) return; + + if( RegisterDPPList[index].GetType() == RW::WriteONLY ) { + leBdRegRW->setText("Write ONLY" ); + leBdRegValue->setText(""); + leBdRegSet->setEnabled(true); + return; + } + + uint32_t value = digi[ cbDigi->currentIndex() ] ->ReadRegister(RegisterDPPList[index]); + leBdRegValue->setText( "0x" + QString::number(value, 16).toUpper()); + + if( RegisterDPPList[index].GetType() == RW::ReadONLY ) { + leBdRegRW->setText("Read ONLY" ); + leBdRegSet->setEnabled(false); + return; + } + + if( RegisterDPPList[index].GetType() == RW::ReadWrite ) { + leBdRegRW->setText("Read/Write" ); + leBdRegSet->setEnabled(true); + } + }); + + cbBdReg->currentIndexChanged(0); + + connect(cbChReg, &RComboBox::currentIndexChanged, this, [=](int index){ + if( !enableSignalSlot ) return; + + if( chRegList[index].GetType() == RW::WriteONLY ) { + leChRegRW->setText("Write ONLY" ); + leChRegValue->setText(""); + leChRegSet->setEnabled(true); + return; + } + + uint32_t value = digi[ cbDigi->currentIndex() ] ->ReadRegister(chRegList[index], cbCh->currentIndex()); + leChRegValue->setText( "0x" + QString::number(value, 16).toUpper()); + + if( chRegList[index].GetType() == RW::ReadONLY ) { + leChRegRW->setText("Read ONLY" ); + leChRegSet->setEnabled(false); + return; + } + + if( chRegList[index].GetType() == RW::ReadWrite ) { + leChRegRW->setText("Read/Write" ); + leChRegSet->setEnabled(true); + } + }); + cbChReg->currentIndexChanged(0); + + connect( leBdRegSet, &QLineEdit::textChanged, this, [=](){ + if( !enableSignalSlot ) return; + leBdRegSet->setStyleSheet("color : blue;"); + }); + connect( leBdRegSet, &QLineEdit::returnPressed, this, [=](){ + if( !enableSignalSlot ) return; + QString text = leBdRegSet->text(); + + if( text.contains("0x") ){ + uint32_t value = std::stoul(text.toStdString(), nullptr, 16); + int index = cbDigi->currentIndex(); + int regID = cbBdReg->currentIndex(); + digi[index]->WriteRegister(RegisterDPPList[regID], value); + leBdRegSet->setStyleSheet(""); + + cbBdReg->currentIndexChanged(regID); + + }else{ + leBdRegSet->setText("use Hex 0xAB123"); + leBdRegSet->setStyleSheet("color : red;"); + } + }); + + connect( leChRegSet, &QLineEdit::textChanged, this, [=](){ + if( !enableSignalSlot ) return; + leChRegSet->setStyleSheet("color : blue;"); + }); + connect( leChRegSet, &QLineEdit::returnPressed, this, [=](){ + if( !enableSignalSlot ) return; + QString text = leChRegSet->text(); + + if( text.contains("0x") ){ + uint32_t value = std::stoul(text.toStdString(), nullptr, 16); + int index = cbDigi->currentIndex(); + int regID = cbChReg->currentIndex(); + digi[index]->WriteRegister(chRegList[regID], value); + leChRegSet->setStyleSheet(""); + + cbChReg->currentIndexChanged(regID); + }else{ + leChRegSet->setText("use Hex 0xAB123"); + leChRegSet->setStyleSheet("color : red;"); + } + }); + + } + + {//================ Copy + QGroupBox * copyBox = new QGroupBox("Copy Settings", inquiryTab); + //TODO + copyBox->setEnabled(false); + layout->addWidget(copyBox); + + QGridLayout * copyLayout = new QGridLayout(copyBox); + + //---------- copy from + QGroupBox * copyFromBox = new QGroupBox("Copy From", copyBox); + copyFromBox->setFixedWidth(200); + copyLayout->addWidget(copyFromBox, 0, 0, MaxNChannels + 1, 2); + + QGridLayout * copyFromLayout = new QGridLayout(copyFromBox); + + RComboBox * cbFromBoard = new RComboBox(copyFromBox); + copyFromLayout->addWidget(cbFromBoard, 0, 0, 1, 2); + + for( int i = 0 ; i < MaxNChannels; i++ ){ + QLabel * leCh = new QLabel(QString::number(i), copyFromBox); + copyFromLayout->addWidget(leCh, i + 1, 0); + QRadioButton * rbCh = new QRadioButton(copyFromBox); + copyFromLayout->addWidget(rbCh, i + 1, 1); + } + + //---------- Acton buttons + QPushButton * bnCopyBoard = new QPushButton("Copy Board",copyBox); + bnCopyBoard->setFixedSize(200, 100); + copyLayout->addWidget(bnCopyBoard, 2, 2); + + QPushButton * bnCopyChannel = new QPushButton("Copy Channel(s)", copyBox); + bnCopyChannel->setFixedSize(200, 100); + copyLayout->addWidget(bnCopyChannel, 3, 2); + + //---------- copy to + QGroupBox * copyToBox = new QGroupBox("Copy To", copyBox); + copyToBox->setFixedWidth(200); + copyLayout->addWidget(copyToBox, 0, 3, MaxNChannels + 1, 2); + + QGridLayout * copyToLayout = new QGridLayout(copyToBox); + + RComboBox * cbToBoard = new RComboBox(copyToBox); + copyToLayout->addWidget(cbToBoard, 0, 0, 1, 2); + + for( int i = 0 ; i < MaxNChannels; i++ ){ + QLabel * leCh = new QLabel(QString::number(i), copyToBox); + copyToLayout->addWidget(leCh, i + 1, 0); + QCheckBox * chkCh = new QCheckBox(copyToBox); + copyToLayout->addWidget(chkCh, i + 1, 1); + } + + } + } connect(tabWidget, &QTabWidget::currentChanged, this, [=](int index){ @@ -856,7 +1114,7 @@ void DigiSettingsPanel::SetUpACQReadOutTab(){ DPP::AcquisitionControl, DPP::Bit_AcquistionControl::ACQStartArm, 1, 0); SetUpComboBoxBit(cbPLLRefClock[ID], "PLL Ref. Clock ", bdACQLayout[ID], 4, 0, DPP::Bit_AcquistionControl::ListPLLRef, - DPP::AcquisitionControl, DPP::Bit_AcquistionControl::ACQStartArm, 1, 0); + DPP::AcquisitionControl, DPP::Bit_AcquistionControl::PLLRef, 1, 0); SetUpSpinBox(sbRunDelay[ID], "Run Delay [ns] ", bdACQLayout[ID], 5, 0, DPP::RunStartStopDelay); @@ -1891,14 +2149,13 @@ void DigiSettingsPanel::SetUpPSDChannel(){ } //&########################################################### -void DigiSettingsPanel::UpdatePanelFromMemory(){ - - printf("============== %s \n", __func__); - - enableSignalSlot = false; +void DigiSettingsPanel::UpdateBoardAndChannelsStatus(){ //*======================================== - uint32_t AcqStatus = digi[ID]->GetSettingFromMemory(DPP::AcquisitionStatus_R); + uint32_t AcqStatus = digi[ID]->ReadRegister(DPP::AcquisitionStatus_R); + + leACQStatus[ID]->setText( "0x" + QString::number(AcqStatus, 16).toUpper()); + for( int i = 0; i < 9; i++){ if( Digitizer::ExtractBits(AcqStatus, {1, ACQToolTip[i].second}) == 0 ){ bnACQStatus[ID][i]->setStyleSheet(""); @@ -1912,7 +2169,9 @@ void DigiSettingsPanel::UpdatePanelFromMemory(){ } //*======================================== - uint32_t BdFailStatus = digi[ID]->GetSettingFromMemory(DPP::BoardFailureStatus_R); + uint32_t BdFailStatus = digi[ID]->ReadRegister(DPP::BoardFailureStatus_R); + leBdFailStatus[ID]->setText( "0x" + QString::number(BdFailStatus, 16).toUpper()); + for( int i = 0; i < 3; i++){ if( Digitizer::ExtractBits(BdFailStatus, {1, BdFailToolTip[i].second}) == 0 ){ bnBdFailStatus[ID][i]->setStyleSheet("background-color: green;"); @@ -1924,7 +2183,9 @@ void DigiSettingsPanel::UpdatePanelFromMemory(){ } //*======================================== - uint32_t ReadoutStatus = digi[ID]->GetSettingFromMemory(DPP::ReadoutStatus_R); + uint32_t ReadoutStatus = digi[ID]->ReadRegister(DPP::ReadoutStatus_R); + leReadOutStatus[ID]->setText( "0x" + QString::number(ReadoutStatus, 16).toUpper()); + for( int i = 0; i < 3; i++){ if( Digitizer::ExtractBits(ReadoutStatus, {1, ReadoutToolTip[i].second}) == 0 ){ if( ReadoutToolTip[i].second != 2 ) { @@ -1943,15 +2204,37 @@ void DigiSettingsPanel::UpdatePanelFromMemory(){ } } + //*========================================== Channel Status + for( int i = 0; i < MaxNChannels; i++){ + uint32_t chStatus = digi[ID]->ReadRegister(DPP::ChannelStatus_R, i); + + bnChStatus[ID][i][0]->setStyleSheet( ( (chStatus >> 2 ) & 0x1 ) ? "background-color: red;" : ""); + bnChStatus[ID][i][1]->setStyleSheet( ( (chStatus >> 3 ) & 0x1 ) ? "background-color: green;" : ""); + bnChStatus[ID][i][2]->setStyleSheet( ( (chStatus >> 8 ) & 0x1 ) ? "background-color: red;" : ""); + + leADCTemp[ID][i]->setText( QString::number( digi[ID]->GetSettingFromMemory(DPP::ChannelADCTemperature_R, i) ) ); + } + +} + + +void DigiSettingsPanel::UpdatePanelFromMemory(){ + + printf("============== %s \n", __func__); + + enableSignalSlot = false; + + UpdateBoardAndChannelsStatus(); + //*======================================== uint32_t BdCfg = digi[ID]->GetSettingFromMemory(DPP::BoardConfiguration); chkAutoDataFlush[ID]->setChecked( Digitizer::ExtractBits(BdCfg, DPP::Bit_BoardConfig::EnableAutoDataFlush) ); chkTrigPropagation[ID]->setChecked( Digitizer::ExtractBits(BdCfg, DPP::Bit_BoardConfig::TrigPropagation) ); - chkDecimateTrace[ID]->setChecked( Digitizer::ExtractBits(BdCfg, DPP::Bit_BoardConfig::DecimateTrace) ); - chkTraceRecording[ID]->setChecked( Digitizer::ExtractBits(BdCfg, DPP::Bit_BoardConfig::TrigPropagation) ); + chkTraceRecording[ID]->setChecked( Digitizer::ExtractBits(BdCfg, DPP::Bit_BoardConfig::RecordTrace) ); chkEnableExtra2[ID]->setChecked( Digitizer::ExtractBits(BdCfg, DPP::Bit_BoardConfig::EnableExtra2) ); + int temp = Digitizer::ExtractBits(BdCfg, DPP::Bit_BoardConfig::DigiProbel1); for(int i = 0; i < cbDigiProbe1[ID]->count(); i++){ if( cbDigiProbe1[ID]->itemData(i).toInt() == temp) { @@ -1968,6 +2251,7 @@ void DigiSettingsPanel::UpdatePanelFromMemory(){ } if( digi[ID]->GetDPPType() == V1730_DPP_PHA_CODE ) { + chkDecimateTrace[ID]->setChecked( Digitizer::ExtractBits(BdCfg, DPP::Bit_BoardConfig::DecimateTrace) ); chkDualTrace[ID]->setChecked( Digitizer::ExtractBits(BdCfg, DPP::Bit_BoardConfig::DualTrace) ); temp = Digitizer::ExtractBits(BdCfg, DPP::Bit_BoardConfig::AnalogProbe1); @@ -1988,6 +2272,7 @@ void DigiSettingsPanel::UpdatePanelFromMemory(){ } if( digi[ID]->GetDPPType() == V1730_DPP_PSD_CODE ) { + chkDecimateTrace[ID]->setChecked( Digitizer::ExtractBits(BdCfg, DPP::Bit_BoardConfig::DisableDigiTrace) ); temp = Digitizer::ExtractBits(BdCfg, DPP::Bit_BoardConfig::AnaProbe_PSD); for( int i = 0; i < cbAnaProbe1[ID]->count(); i++){ if( cbAnaProbe1[ID]->itemData(i).toInt() == temp) { @@ -2117,16 +2402,7 @@ void DigiSettingsPanel::UpdatePanelFromMemory(){ } } - //*========================================== Channel Status - for( int i = 0; i < MaxNChannels; i++){ - uint32_t chStatus = digi[ID]->GetSettingFromMemory(DPP::ChannelStatus_R, i); - bnChStatus[ID][i][0]->setStyleSheet( ( (chStatus >> 2 ) & 0x1 ) ? "background-color: red;" : ""); - bnChStatus[ID][i][1]->setStyleSheet( ( (chStatus >> 3 ) & 0x1 ) ? "background-color: green;" : ""); - bnChStatus[ID][i][2]->setStyleSheet( ( (chStatus >> 8 ) & 0x1 ) ? "background-color: red;" : ""); - - leADCTemp[ID][i]->setText( QString::number( digi[ID]->GetSettingFromMemory(DPP::ChannelADCTemperature_R, i) ) ); - } if( digi[ID]->GetDPPType() == V1730_DPP_PHA_CODE ) UpdatePHASetting(); if( digi[ID]->GetDPPType() == V1730_DPP_PSD_CODE ) UpdatePSDSetting(); diff --git a/DigiSettingsPanel.h b/DigiSettingsPanel.h index c7e7c5d..8960886 100644 --- a/DigiSettingsPanel.h +++ b/DigiSettingsPanel.h @@ -58,6 +58,8 @@ private: void SyncComboBox(RComboBox *(&cb)[][MaxNChannels+1]); void SyncCheckBox(QCheckBox *(&chk)[][MaxNChannels+1]); + void UpdateBoardAndChannelsStatus(); // ReadRegister + void SyncAllChannelsTab_PHA(); void UpdatePHASetting(); void SyncAllChannelsTab_PSD(); @@ -68,6 +70,8 @@ private: unsigned int nDigi; unsigned short ID; + std::vector chRegList; + QString rawDataPath; bool enableSignalSlot; @@ -145,6 +149,9 @@ private: QPushButton * bnACQStatus[MaxNDigitizer][9]; QPushButton * bnBdFailStatus[MaxNDigitizer][3]; QPushButton * bnReadOutStatus[MaxNDigitizer][3]; + QLineEdit * leACQStatus[MaxNDigitizer]; + QLineEdit * leBdFailStatus[MaxNDigitizer]; + QLineEdit * leReadOutStatus[MaxNDigitizer]; /// ============================= Mask Configure QPushButton * bnGlobalTriggerMask[MaxNDigitizer][MaxNChannels/2]; diff --git a/FSUDAQ.cpp b/FSUDAQ.cpp index 6d4cb2a..4dc4727 100644 --- a/FSUDAQ.cpp +++ b/FSUDAQ.cpp @@ -352,7 +352,7 @@ void MainWindow::OpenDigitizers(){ readDataThread = new ReadDataThread * [nDigi]; for( unsigned int i = 0; i < nDigi; i++){ digi[i] = new Digitizer(portList[i].first, portList[i].second); - digi[i]->Reset(); + //digi[i]->Reset(); ///============== load settings QString fileName = rawDataPath + "/Digi-" + QString::number(digi[i]->GetSerialNumber()) + ".bin"; //TODO add DPP Type in File Name @@ -360,13 +360,15 @@ void MainWindow::OpenDigitizers(){ if( !file.open(QIODevice::Text | QIODevice::ReadOnly) ) { if( digi[i]->GetDPPType() == V1730_DPP_PHA_CODE ) { - digi[i]->ProgramPHABoard(); - LogMsg("" + fileName + " not found. Program predefined PHA settings."); + //digi[i]->ProgramPHABoard(); + //LogMsg("" + fileName + " not found. Program predefined PHA settings."); + LogMsg("" + fileName + " not found."); } if( digi[i]->GetDPPType() == V1730_DPP_PSD_CODE ){ - - LogMsg("" + fileName + " not found."); //TODO, PSD? + //digi[i]->ProgramPSDBoard(); + //LogMsg("" + fileName + " not found. Program predefined PSD settings."); + LogMsg("" + fileName + " not found."); } }else{ @@ -380,6 +382,7 @@ void MainWindow::OpenDigitizers(){ LogMsg("Fail to Loaded settings file " + fileName + " for Digi-" + QString::number(digi[i]->GetSerialNumber())); } } + digi[i]->ReadAllSettingsFromBoard(true); readDataThread[i] = new ReadDataThread(digi[i], i); connect(readDataThread[i], &ReadDataThread::sendMsg, this, &MainWindow::LogMsg); @@ -390,6 +393,7 @@ void MainWindow::OpenDigitizers(){ LogMsg(QString("Done. Opened %1 digitizer(s).").arg(nDigi)); WaitForDigitizersOpen(false); + bnStopACQ->setEnabled(false); SetupScalar(); diff --git a/RegisterAddress.h b/RegisterAddress.h index 9e81455..e363866 100644 --- a/RegisterAddress.h +++ b/RegisterAddress.h @@ -738,6 +738,10 @@ namespace DPP { } // end of DPP namepace Register const std::vector RegisterPHAList = { + DPP::RecordLength_G , + DPP::InputDynamicRange , + DPP::NumberEventsPerAggregate_G , + DPP::PreTrigger , DPP::PHA::DataFlush_W , DPP::PHA::ChannelStopAcquisition , DPP::PHA::RCCR2SmoothingFactor , @@ -750,28 +754,24 @@ const std::vector RegisterPHAList = { DPP::PHA::RiseTimeValidationWindow , DPP::PHA::TriggerHoldOffWidth , DPP::PHA::PeakHoldOff , - DPP::PHA::ShapedTriggerWidth , - DPP::PHA::DPPAlgorithmControl2_G , - DPP::PHA::FineGain , - - DPP::RecordLength_G , - DPP::InputDynamicRange , - DPP::NumberEventsPerAggregate_G , - DPP::PreTrigger , - DPP::TriggerThreshold , - DPP::TriggerHoldOffWidth , DPP::DPPAlgorithmControl , + DPP::PHA::ShapedTriggerWidth , DPP::ChannelStatus_R , DPP::AMCFirmwareRevision_R , DPP::ChannelDCOffset , + DPP::PHA::DPPAlgorithmControl2_G , DPP::ChannelADCTemperature_R , DPP::IndividualSoftwareTrigger_W, + DPP::PHA::FineGain , DPP::VetoWidth , - DPP::TriggerValidationMask_G }; const std::vector RegisterPSDList = { + DPP::RecordLength_G , + DPP::InputDynamicRange , + DPP::NumberEventsPerAggregate_G , + DPP::PreTrigger , DPP::PSD::CFDSetting , DPP::PSD::ForcedDataFlush_W , DPP::PSD::ChargeZeroSuppressionThreshold , @@ -785,23 +785,15 @@ const std::vector RegisterPSDList = { DPP::PSD::TriggerHoldOffWidth , DPP::PSD::ThresholdForPSDCut , DPP::PSD::PurGapThreshold , - DPP::PSD::DPPAlgorithmControl2_G , - DPP::PSD::EarlyBaselineFreeze , - - DPP::RecordLength_G , - DPP::InputDynamicRange , - DPP::NumberEventsPerAggregate_G , - DPP::PreTrigger , - DPP::TriggerThreshold , - DPP::TriggerHoldOffWidth , DPP::DPPAlgorithmControl , + DPP::PSD::DPPAlgorithmControl2_G , DPP::ChannelStatus_R , DPP::AMCFirmwareRevision_R , DPP::ChannelDCOffset , DPP::ChannelADCTemperature_R , DPP::IndividualSoftwareTrigger_W, DPP::VetoWidth , - + DPP::PSD::EarlyBaselineFreeze , DPP::TriggerValidationMask_G }; diff --git a/Scope.cpp b/Scope.cpp index 5341b59..b8b838f 100644 --- a/Scope.cpp +++ b/Scope.cpp @@ -116,6 +116,8 @@ Scope::Scope(Digitizer ** digi, unsigned int nDigi, ReadDataThread ** readDataTh if( digi[ID]->GetDPPType() == V1730_DPP_PHA_CODE ) SetUpPHAPanel(); if( digi[ID]->GetDPPType() == V1730_DPP_PSD_CODE ) SetUpPSDPanel(); + ReadSettingsFromBoard(); + }); bnReadSettingsFromBoard = new QPushButton("Refresh Settings", this); @@ -547,6 +549,12 @@ void Scope::SetUpPSDPanel(){ if( !enableSignalSlot ) return; digi[ID]->SetBits(DPP::DPPAlgorithmControl, DPP::Bit_DPPAlgorithmControl_PHA::Polarity, cbPolarity->currentData().toInt(), cbScopeCh->currentIndex()); }); + + SetUpSpinBox(sbShortGate, "Short Gate [ns] ", rowID, 2, DPP::PSD::ShortGateWidth); + SetUpSpinBox(sbLongGate, "Long Gate [ns] ", rowID, 4, DPP::PSD::LongGateWidth); + SetUpSpinBox(sbGateOffset, "Gate Offset [ns] ", rowID, 6, DPP::PSD::GateOffset); + + } void Scope::EnableControl(bool enable){ diff --git a/Scope.h b/Scope.h index 1ac800f..68756ee 100644 --- a/Scope.h +++ b/Scope.h @@ -85,10 +85,8 @@ private: /// common to PSD and PHA RSpinBox * sbReordLength; RSpinBox * sbPreTrigger; - RSpinBox * sbDCOffset; RComboBox * cbDynamicRange; - RComboBox * cbPolarity; /// PHA @@ -110,6 +108,11 @@ private: RComboBox * cbDigiProbe1; RComboBox * cbDigiProbe2; + /// PSD + RSpinBox * sbShortGate; + RSpinBox * sbLongGate; + RSpinBox * sbGateOffset; + };