From 1ae7309eb2294f697a2e7f23e3d2a8b5f48b3010 Mon Sep 17 00:00:00 2001 From: splitPoleDAQ Date: Tue, 23 May 2023 17:02:39 -0400 Subject: [PATCH] uncomment filling histograms, added UpdateOtherPanels() --- ClassDigitizer.h | 4 ++-- DigiSettingsPanel.cpp | 7 +++++++ DigiSettingsPanel.h | 4 ++-- FSUDAQ.cpp | 26 +++++++++++++++++++++++++- FSUDAQ.h | 2 ++ FSUDAQ_Qt6.pro | 7 +++++-- Scope.cpp | 15 +++++++++++++-- Scope.h | 6 ++++-- 8 files changed, 60 insertions(+), 11 deletions(-) diff --git a/ClassDigitizer.h b/ClassDigitizer.h index 14d1982..7be3a64 100644 --- a/ClassDigitizer.h +++ b/ClassDigitizer.h @@ -152,10 +152,10 @@ class Digitizer{ // bool IsEnabledAutoDataFlush() {return ( GetSettingFromMemory(DPP::BoardConfiguration) & 0x1 );} // bool IsDecimateTrace() {return ( (GetSettingFromMemory(DPP::BoardConfiguration) >> 1) & 0x1 );} // bool IsTriggerPropagate() {return ( (GetSettingFromMemory(DPP::BoardConfiguration) >> 2) & 0x1 );} - bool IsDualTrace() {return ( (GetSettingFromMemory(DPP::BoardConfiguration) >> 11) & 0x1 );} + bool IsDualTrace_PHA() {return ( (GetSettingFromMemory(DPP::BoardConfiguration) >> 11) & 0x1 );} // unsigned short AnaProbe1Type() {return ( (GetSettingFromMemory(DPP::BoardConfiguration) >> 12) & 0x3 );} // unsigned short AnaProbe2Type() {return ( (GetSettingFromMemory(DPP::BoardConfiguration) >> 14) & 0x3 );} - // bool IsRecordTrace() {return ( (GetSettingFromMemory(DPP::BoardConfiguration) >> 16) & 0x1 );} + bool IsRecordTrace() {return ( (GetSettingFromMemory(DPP::BoardConfiguration) >> 16) & 0x1 );} // bool IsEnabledExtra2() {return ( (GetSettingFromMemory(DPP::BoardConfiguration) >> 17) & 0x1 );} // bool IsRecordTimeStamp() {return ( (GetSettingFromMemory(DPP::BoardConfiguration) >> 18) & 0x1 );} // bool IsRecordEnergy() {return ( (GetSettingFromMemory(DPP::BoardConfiguration) >> 19) & 0x1 );} diff --git a/DigiSettingsPanel.cpp b/DigiSettingsPanel.cpp index b01e16e..25c0597 100644 --- a/DigiSettingsPanel.cpp +++ b/DigiSettingsPanel.cpp @@ -655,6 +655,7 @@ void DigiSettingsPanel::SetUpCheckBox(QCheckBox * &chkBox, QString label, QGridL digi[ID]->SetBits(para, bit, state ? 1 : 0, chID); if( para.IsCoupled() == true && chID >= 0 ) digi[ID]->SetBits(para, bit, state ? 1 : 0, chID%2 == 0 ? chID + 1 : chID - 1); UpdatePanelFromMemory(); + emit UpdateOtherPanels(); }); } @@ -683,6 +684,7 @@ void DigiSettingsPanel::SetUpComboBoxBit(RComboBox * &cb, QString label, QGridLa digi[ID]->SetBits(para, bit, cb->currentData().toUInt(), chID); if( para.IsCoupled() == true && chID >= 0 ) digi[ID]->SetBits(para, bit, cb->currentData().toUInt(), chID%2 == 0 ? chID + 1 : chID - 1); UpdatePanelFromMemory(); + emit UpdateOtherPanels(); }); } @@ -711,6 +713,7 @@ void DigiSettingsPanel::SetUpComboBox(RComboBox * &cb, QString label, QGridLayou digi[ID]->WriteRegister(para, cb->currentData().toUInt(), chID); if( para.IsCoupled() == true && chID >= 0 ) digi[ID]->WriteRegister(para, cb->currentData().toUInt(), chID%2 == 0 ? chID + 1 : chID - 1); UpdatePanelFromMemory(); + emit UpdateOtherPanels(); }); } @@ -762,18 +765,21 @@ void DigiSettingsPanel::SetUpSpinBox(RSpinBox * &sb, QString label, QGridLayout if( para == DPP::ChannelDCOffset ){ digi[ID]->WriteRegister(para, 0xFFFF * (1.0 - sb->value() / 100. ), chID); UpdatePanelFromMemory(); + emit UpdateOtherPanels(); return; } if( para == DPP::PSD::CFDSetting ){ digi[ID]->SetBits(para, DPP::PSD::Bit_CFDSetting::CFDDealy, sb->value()/digi[ID]->GetCh2ns(), chID); UpdatePanelFromMemory(); + emit UpdateOtherPanels(); return; } if( para == DPP::DPPAlgorithmControl ){ digi[ID]->SetBits(para, {5,0}, sb->value(), chID); UpdatePanelFromMemory(); + emit UpdateOtherPanels(); return; } @@ -783,6 +789,7 @@ void DigiSettingsPanel::SetUpSpinBox(RSpinBox * &sb, QString label, QGridLayout if( para.IsCoupled() == true && chID >= 0 ) digi[ID]->WriteRegister(para, bit, chID%2 == 0 ? chID + 1 : chID - 1); UpdatePanelFromMemory(); + emit UpdateOtherPanels(); }); } diff --git a/DigiSettingsPanel.h b/DigiSettingsPanel.h index 62cbf85..1e630f3 100644 --- a/DigiSettingsPanel.h +++ b/DigiSettingsPanel.h @@ -21,7 +21,7 @@ public: DigiSettingsPanel(Digitizer ** digi, unsigned int nDigi, QString rawDataPath, QMainWindow * parent = nullptr); ~DigiSettingsPanel(); -private slots: +public slots: void UpdatePanelFromMemory(); void ReadSettingsFromBoard(); @@ -30,6 +30,7 @@ private slots: signals: void SendLogMsg(const QString &msg); + void UpdateOtherPanels(); private: @@ -68,7 +69,6 @@ private: void CheckRadioAndCheckedButtons(); - Digitizer ** digi; unsigned int nDigi; unsigned short ID; diff --git a/FSUDAQ.cpp b/FSUDAQ.cpp index 4b38dc8..8b67d26 100644 --- a/FSUDAQ.cpp +++ b/FSUDAQ.cpp @@ -393,6 +393,7 @@ void MainWindow::OpenDigitizers(){ QCoreApplication::processEvents(); //to prevent Qt said application not responding. } + canvas = new Canvas(digi, nDigi); histThread = new TimingThread(this); histThread->SetWaitTimeinSec(0.5); connect(histThread, &TimingThread::timeUp, this, [=](){ @@ -660,7 +661,7 @@ void MainWindow::StartACQ(){ } lbScalarACQStatus->setText("ACQ On"); - //if( canvas != nullptr ) histThread->start(); + if( canvas != nullptr ) histThread->start(); bnStartACQ->setEnabled(false); bnStopACQ->setEnabled(true); @@ -847,6 +848,9 @@ void MainWindow::OpenScope(){ }); connect(scope, &Scope::UpdateScaler, this, &MainWindow::UpdateScalar); + + connect(scope, &Scope::UpdateOtherPanels, this, [=](){ UpdateAllPanels(1); }); + scope->show(); }else{ scope->show(); @@ -867,6 +871,8 @@ void MainWindow::OpenDigiSettings(){ if( digiSettings == nullptr ) { digiSettings = new DigiSettingsPanel(digi, nDigi, rawDataPath); //connect(scope, &Scope::SendLogMsg, this, &MainWindow::LogMsg); + connect(digiSettings, &DigiSettingsPanel::UpdateOtherPanels, this, [=](){ UpdateAllPanels(2); }); + digiSettings->show(); }else{ digiSettings->show(); @@ -889,6 +895,24 @@ void MainWindow::OpenCanvas(){ } +//*************************************************************** +//*************************************************************** +void MainWindow::UpdateAllPanels(int panelID){ + + //panelID is the source panel that call + // scope = 1; + // digiSetting = 2; + + if( panelID == 1 ){ // from scope + if( digiSettings && digiSettings->isVisible() ) digiSettings->UpdatePanelFromMemory(); + } + + if( panelID == 2 ){ + if(scope && scope->isVisible() ) scope->UpdatePanelFromMomeory(); + } + +} + //*************************************************************** //*************************************************************** void MainWindow::LogMsg(QString msg){ diff --git a/FSUDAQ.h b/FSUDAQ.h index 6d78a5f..e7ab178 100644 --- a/FSUDAQ.h +++ b/FSUDAQ.h @@ -61,6 +61,8 @@ private slots: void OpenCanvas(); + void UpdateAllPanels(int panelID); + private: Digitizer ** digi; diff --git a/FSUDAQ_Qt6.pro b/FSUDAQ_Qt6.pro index 9f4062a..5522649 100644 --- a/FSUDAQ_Qt6.pro +++ b/FSUDAQ_Qt6.pro @@ -8,8 +8,11 @@ INCLUDEPATH += . QT += core widgets charts -QMAKE_CXXFLAGS += `root-config --cflags --glibs` -LIBS += -lCAENDigitizer `root-config --cflags --glibs` +#QMAKE_CXXFLAGS += `root-config --cflags --glibs` +#LIBS += -lCAENDigitizer `root-config --cflags --glibs` + +#QMAKE_CXXFLAGS += -g +LIBS += -lCAENDigitizer # You can make your code fail to compile if you use deprecated APIs. # In order to do so, uncomment the following line. diff --git a/Scope.cpp b/Scope.cpp index 9c10256..13ad080 100644 --- a/Scope.cpp +++ b/Scope.cpp @@ -13,6 +13,8 @@ Scope::Scope(Digitizer ** digi, unsigned int nDigi, ReadDataThread ** readDataTh this->nDigi = nDigi; this->readDataThread = readDataThread; + for( unsigned int i = 0; i < nDigi; i++){ traceOn[i] = digi[i]->IsRecordTrace();} + setWindowTitle("Scope"); setGeometry(0, 0, 1000, 800); setWindowFlags( this->windowFlags() & ~Qt::WindowCloseButtonHint ); @@ -230,6 +232,7 @@ void Scope::StartScope(){ for( unsigned int iDigi = 0; iDigi < nDigi; iDigi ++){ + digi[iDigi]->SetBits(DPP::BoardConfiguration, DPP::Bit_BoardConfig::RecordTrace, 1, -1); digi[iDigi]->GetData()->SetSaveWaveToMemory(true); digi[iDigi]->StartACQ(); @@ -244,6 +247,8 @@ void Scope::StartScope(){ readDataThread[iDigi]->start(); } + emit UpdateOtherPanels(); + updateTraceThread->start(); bnScopeStart->setEnabled(false); @@ -273,8 +278,12 @@ void Scope::StopScope(){ digiMTX[iDigi].lock(); digi[iDigi]->StopACQ(); digiMTX[iDigi].unlock(); + + digi[iDigi]->SetBits(DPP::BoardConfiguration, DPP::Bit_BoardConfig::RecordTrace, traceOn[iDigi], -1); } + emit UpdateOtherPanels(); + bnScopeStart->setEnabled(true); bnScopeStop->setEnabled(false); @@ -292,7 +301,7 @@ void Scope::UpdateScope(){ int ch = cbScopeCh->currentIndex(); int ch2ns = digi[ID]->GetCh2ns(); - int factor = digi[ID]->IsDualTrace() ? 2 : 1; + int factor = digi[ID]->IsDualTrace_PHA() ? 2 : 1; digiMTX[ID].lock(); Data * data = digi[ID]->GetData(); @@ -374,6 +383,7 @@ void Scope::SetUpComboBox(RComboBox * &cb, QString str, int row, int col, const if( digi[ID]->GetErrorCode() == CAEN_DGTZ_Success ){ SendLogMsg(msg + " | OK."); cb->setStyleSheet(""); + emit UpdateOtherPanels(); }else{ SendLogMsg(msg + " | Fail."); cb->setStyleSheet("color:red;"); @@ -421,7 +431,7 @@ void Scope::SetUpSpinBox(RSpinBox * &sb, QString str, int row, int col, const Re uint32_t value = sb->value() / ch2ns / abs(para.GetPartialStep()); if( para == DPP::RecordLength_G){ - int factor = digi[ID]->IsDualTrace() ? 2 : 1; + int factor = digi[ID]->IsDualTrace_PHA() ? 2 : 1; value = value * factor; } @@ -441,6 +451,7 @@ void Scope::SetUpSpinBox(RSpinBox * &sb, QString str, int row, int col, const Re if( digi[ID]->GetErrorCode() == CAEN_DGTZ_Success ){ SendLogMsg(msg + " | OK."); sb->setStyleSheet(""); + emit UpdateOtherPanels(); }else{ SendLogMsg(msg + " | Fail."); sb->setStyleSheet("color:red;"); diff --git a/Scope.h b/Scope.h index fe50ccb..c33f6e9 100644 --- a/Scope.h +++ b/Scope.h @@ -37,11 +37,12 @@ public: event->accept(); } -private slots: +public slots: void StartScope(); void StopScope(); void UpdateScope(); void ReadSettingsFromBoard(); + void UpdatePanelFromMomeory(); signals: @@ -49,6 +50,7 @@ signals: void SendLogMsg(const QString &msg); void TellACQOnOff(const bool onOff); void UpdateScaler(); + void UpdateOtherPanels(); private: @@ -63,7 +65,6 @@ private: void UpdateComobox(RComboBox * &cb, const Reg para); void UpdateSpinBox(RSpinBox * &sb, const Reg para); - void UpdatePanelFromMomeory(); void UpdatePHAPanel(); void UpdatePSDPanel(); @@ -71,6 +72,7 @@ private: unsigned short nDigi; unsigned short ID; // the id of digi, index of cbScopeDigi int ch2ns; + bool traceOn[MaxNDigitizer]; ReadDataThread ** readDataThread; TimingThread * updateTraceThread;