From bedbe44164deaaa01c1ec3734719197cc04c5486 Mon Sep 17 00:00:00 2001 From: Ryan Tang Date: Fri, 5 Apr 2024 22:33:05 -0400 Subject: [PATCH 01/14] improved Histogram2D color map, set every cell to nan = white; improve the SingleSpectrum filling algorithm, fill random digi and random ch --- Histogram2D.h | 35 +++++++++++++++++--------- SingleSpectra.cpp | 63 +++++++++++++++++++++++++++++------------------ SingleSpectra.h | 5 ++++ 3 files changed, 67 insertions(+), 36 deletions(-) diff --git a/Histogram2D.h b/Histogram2D.h index 5393adf..a188f4b 100644 --- a/Histogram2D.h +++ b/Histogram2D.h @@ -49,10 +49,13 @@ public: colorScale->setType(QCPAxis::atRight); colorMap->setColorScale(colorScale); + QCPColorGradient color; + color.setNanHandling(QCPColorGradient::NanHandling::nhNanColor); + color.setNanColor(QColor("white")); color.clearColorStops(); - color.setColorStopAt( 0.0, QColor("white" )); - color.setColorStopAt( 0.000001, QColor("purple" )); + // color.setColorStopAt( 0.0, QColor("white" )); + color.setColorStopAt( 0.0, QColor("purple" )); color.setColorStopAt( 0.2, QColor("blue")); color.setColorStopAt( 0.4, QColor("cyan")); color.setColorStopAt( 0.6, QColor("green")); @@ -191,16 +194,18 @@ public: void SetChannelMap(bool onOff, int tickStep = 1) { isChannelMap = onOff; this->tickStep = tickStep;} void UpdatePlot(){ - QCPColorGradient color; - color.clearColorStops(); - color.setColorStopAt( 0.0, QColor("white" )); - color.setColorStopAt( 1.0/entry[1][1], QColor("purple" )); - color.setColorStopAt( 0.2, QColor("blue")); - color.setColorStopAt( 0.4, QColor("cyan")); - color.setColorStopAt( 0.6, QColor("green")); - color.setColorStopAt( 0.8, QColor("yellow")); - color.setColorStopAt( 1.0, QColor("red")); - colorMap->setGradient(color); + // QCPColorGradient color; + // color.clearColorStops(); + // color.setNanColor(QColor("white")); + // // color.setColorStopAt( 0.0, QColor("white" )); + // // color.setColorStopAt( 1.0/entry[1][1], QColor("purple" )); + // color.setColorStopAt( 0.0, QColor("purple" )); + // color.setColorStopAt( 0.2, QColor("blue")); + // color.setColorStopAt( 0.4, QColor("cyan")); + // color.setColorStopAt( 0.6, QColor("green")); + // color.setColorStopAt( 0.8, QColor("yellow")); + // color.setColorStopAt( 1.0, QColor("red")); + // colorMap->setGradient(color); colorMap->rescaleDataRange(); @@ -309,6 +314,12 @@ inline void Histogram2D::Rebin(int xbin, double xmin, double xmax, int ybin, do colorMap->data()->setSize(xBin, yBin); colorMap->data()->setRange(QCPRange(xMin, xMax), QCPRange(yMin, yMax)); + for( int i = 0; i < xBin; i++){ + for( int j = 0; j < yBin; j++){ + colorMap->data()->setCell(i, j, NAN); + } + } + if( isChannelMap ){ QCPAxis * xAxis = colorMap->keyAxis(); xAxis->ticker()->setTickCount(xbin/tickStep); diff --git a/SingleSpectra.cpp b/SingleSpectra.cpp index 80589ab..d8da715 100644 --- a/SingleSpectra.cpp +++ b/SingleSpectra.cpp @@ -1,11 +1,9 @@ #include "SingleSpectra.h" #include -#include #include #include #include -#include SingleSpectra::SingleSpectra(Digitizer ** digi, unsigned int nDigi, QString rawDataPath, QMainWindow * parent) : QMainWindow(parent){ DebugPrint("%s", "SingleSpectra"); @@ -13,7 +11,8 @@ SingleSpectra::SingleSpectra(Digitizer ** digi, unsigned int nDigi, QString rawD this->nDigi = nDigi; this->rawDataPath = rawDataPath; - maxFillTimeinMilliSec = 500; + maxFillTimeinMilliSec = 1000; + maxFillTimePerDigi = maxFillTimeinMilliSec/nDigi; isSignalSlotActive = true; @@ -205,47 +204,52 @@ void SingleSpectra::FillHistograms(){ // DebugPrint("%s", "SingleSpectra"); if( !fillHistograms ) return; - unsigned short maxFillTimePerDigi = maxFillTimeinMilliSec/nDigi; timespec t0, t1; - for( int i = 0; i < nDigi; i++){ + QVector randomDigiList = generateNonRepeatedCombination(nDigi); - digiMTX[i].lock(); + for( int i = 0; i < nDigi; i++){ + int ID = randomDigiList[i]; + + QVector randomChList = generateNonRepeatedCombination(digi[ID]->GetNumInputCh()); + + digiMTX[ID].lock(); clock_gettime(CLOCK_REALTIME, &t0); - for( int ch = 0; ch < digi[i]->GetNumInputCh(); ch ++ ){ - int lastIndex = digi[i]->GetData()->GetDataIndex(ch); + for( int k = 0; k < digi[ID]->GetNumInputCh(); k ++ ){ + int ch = randomChList[k]; + int lastIndex = digi[ID]->GetData()->GetDataIndex(ch); if( lastIndex < 0 ) continue; - int loopIndex = digi[i]->GetData()->GetLoopIndex(ch); + int loopIndex = digi[ID]->GetData()->GetLoopIndex(ch); - int temp1 = lastIndex + loopIndex * digi[i]->GetData()->GetDataSize(); - int temp2 = lastFilledIndex[i][ch] + loopFilledIndex[i][ch] * digi[i]->GetData()->GetDataSize(); + int temp1 = lastIndex + loopIndex * digi[ID]->GetData()->GetDataSize(); + int temp2 = lastFilledIndex[ID][ch] + loopFilledIndex[ID][ch] * digi[ID]->GetData()->GetDataSize(); // printf("%d |%d %d \n", ch, temp2, temp1); if( temp1 <= temp2 ) continue; - if( temp1 - temp2 > digi[i]->GetData()->GetDataSize() ) { //DefaultDataSize = 10k - temp2 = temp1 - digi[i]->GetData()->GetDataSize(); - lastFilledIndex[i][ch] = lastIndex; - lastFilledIndex[i][ch] = loopIndex - 1; + if( temp1 - temp2 > digi[ID]->GetData()->GetDataSize() ) { //DefaultDataSize = 10k + temp2 = temp1 - digi[ID]->GetData()->GetDataSize(); + lastFilledIndex[ID][ch] = lastIndex; + lastFilledIndex[ID][ch] = loopIndex - 1; } for( int j = 0 ; j <= temp1 - temp2; j ++){ - lastFilledIndex[i][ch] ++; - if( lastFilledIndex[i][ch] > digi[i]->GetData()->GetDataSize() ) { - lastFilledIndex[i][ch] = 0; - loopFilledIndex[i][ch] ++; + lastFilledIndex[ID][ch] ++; + if( lastFilledIndex[ID][ch] > digi[ID]->GetData()->GetDataSize() ) { + lastFilledIndex[ID][ch] = 0; + loopFilledIndex[ID][ch] ++; } - hist[i][ch]->Fill( digi[i]->GetData()->GetEnergy(ch, lastFilledIndex[i][ch])); - hist2D[i]->Fill(ch, digi[i]->GetData()->GetEnergy(ch, lastFilledIndex[i][ch])); + hist[ID][ch]->Fill( digi[ID]->GetData()->GetEnergy(ch, lastFilledIndex[ID][ch])); + hist2D[ID]->Fill(ch, digi[ID]->GetData()->GetEnergy(ch, lastFilledIndex[ID][ch])); } - if( histVisibility[i][ch] ) hist[i][ch]->UpdatePlot(); - if( hist2DVisibility[i] ) hist2D[i]->UpdatePlot(); + if( histVisibility[ID][ch] ) hist[ID][ch]->UpdatePlot(); + if( hist2DVisibility[ID] ) hist2D[ID]->UpdatePlot(); clock_gettime(CLOCK_REALTIME, &t1); if( t1.tv_nsec - t0.tv_nsec + (t1.tv_sec - t0.tv_sec)*1e9 > maxFillTimePerDigi * 1e6 ) break; } - digiMTX[i].unlock(); + digiMTX[ID].unlock(); } } @@ -339,4 +343,15 @@ void SingleSpectra::LoadSetting(){ } +} + +QVector SingleSpectra::generateNonRepeatedCombination(int size) { + QVector combination; + for (int i = 0; i < size; ++i) combination.append(i); + + for (int i = 0; i < size - 1; ++i) { + int j = QRandomGenerator::global()->bounded(i, size); + combination.swapItemsAt(i, j); + } + return combination; } \ No newline at end of file diff --git a/SingleSpectra.h b/SingleSpectra.h index a91794e..4e04a8f 100644 --- a/SingleSpectra.h +++ b/SingleSpectra.h @@ -10,6 +10,8 @@ #include #include #include +#include +#include #include "macro.h" #include "ClassDigitizer.h" @@ -38,6 +40,8 @@ public: void SetMaxFillTime(unsigned short milliSec) { maxFillTimeinMilliSec = milliSec;} unsigned short GetMaxFillTime() const {return maxFillTimeinMilliSec;}; + QVector generateNonRepeatedCombination(int size); + public slots: void FillHistograms(); void ChangeHistView(); @@ -70,6 +74,7 @@ private: QString rawDataPath; unsigned short maxFillTimeinMilliSec; + unsigned short maxFillTimePerDigi; bool isSignalSlotActive; From 8a0503629c4ba622b00333f15a97662d1bdd5651 Mon Sep 17 00:00:00 2001 From: Ryan Tang Date: Fri, 5 Apr 2024 22:47:58 -0400 Subject: [PATCH 02/14] added CustomApplication in main.cpp, for debug what cause the slow down --- main.cpp | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/main.cpp b/main.cpp index 2643467..8a3d2fc 100644 --- a/main.cpp +++ b/main.cpp @@ -1,13 +1,28 @@ -#include "FSUDAQ.h" - #include #include #include #include #include +#include "FSUDAQ.h" + +#include +#include + +class CustomApplication : public QApplication{ +public: + CustomApplication(int &argc, char **argv) : QApplication(argc, argv) {} + +protected: + bool notify(QObject *receiver, QEvent *event) override{ + qDebug() << "Event:" << event->type() << "Receiver:" << receiver; + return QApplication::notify(receiver, event); + } +}; + int main(int argc, char *argv[]){ - QApplication a(argc, argv); + + CustomApplication a(argc, argv); bool isLock = false; int pid = 0; From ff3f94e0def0808cf85e22ea6c0f4e4418b51fcc Mon Sep 17 00:00:00 2001 From: "Ryan@WorkStation" Date: Mon, 8 Apr 2024 20:51:57 -0400 Subject: [PATCH 03/14] bug fix Histogram2D.h; now no data is white, at least one data is non-white --- Histogram2D.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Histogram2D.h b/Histogram2D.h index a188f4b..54ca5a6 100644 --- a/Histogram2D.h +++ b/Histogram2D.h @@ -292,7 +292,11 @@ inline void Histogram2D::Fill(double x, double y){ if( xk == 1 && yk == 1 ) { double value = colorMap->data()->cell(xIndex, yIndex); - colorMap->data()->setCell(xIndex, yIndex, value + 1); + if( std::isnan(value) ){ + colorMap->data()->setCell(xIndex, yIndex, 1); + }else{ + colorMap->data()->setCell(xIndex, yIndex, value + 1); + } for( int i = 0; i < cutList.count(); i++){ if( cutList[i].isEmpty() ) continue; @@ -346,6 +350,11 @@ inline void Histogram2D::Clear(){ colorMap->data()->clear(); colorMap->data()->setSize(xBin, yBin); colorMap->data()->setRange(QCPRange(xMin, xMax), QCPRange(yMin, yMax)); + for( int i = 0; i < xBin; i++){ + for( int j = 0; j < yBin; j++){ + colorMap->data()->setCell(i, j, NAN); + } + } UpdatePlot(); } From 6d7daaa13cf398ba5e45aa3d42ee6b559b892e70 Mon Sep 17 00:00:00 2001 From: "Ryan@WorkStation" Date: Tue, 9 Apr 2024 13:54:44 -0400 Subject: [PATCH 04/14] move saving file size to Scalar --- CustomThreads.h | 24 ++++++++++++------------ FSUDAQ.cpp | 5 +++++ FSUDAQ.h | 2 ++ macro.h | 2 +- main.cpp | 21 +++++++++++---------- 5 files changed, 31 insertions(+), 23 deletions(-) diff --git a/CustomThreads.h b/CustomThreads.h index 00aab69..53973d7 100644 --- a/CustomThreads.h +++ b/CustomThreads.h @@ -35,7 +35,7 @@ public: stop = false; readCount = 0; clock_gettime(CLOCK_REALTIME, &t0); - ta = t0; + // ta = t0; t1 = t0; printf("ReadDataThread for digi-%d running.\n", digi->GetSerialNumber()); @@ -79,17 +79,17 @@ public: t2 = t1; } - if( isSaveData && !stop ) { - clock_gettime(CLOCK_REALTIME, &tb); - if( tb.tv_sec - ta.tv_sec > 2 ) { - digiMTX[ID].lock(); - emit sendMsg("FileSize ("+ QString::number(digi->GetSerialNumber()) +"): " + QString::number(digi->GetData()->GetTotalFileSize()/1024./1024., 'f', 4) + " MB [" + QString::number(tb.tv_sec-t0.tv_sec) + " sec]"); - //emit sendMsg("FileSize ("+ QString::number(digi->GetSerialNumber()) +"): " + QString::number(digi->GetData()->GetTotalFileSize()/1024./1024., 'f', 4) + " MB [" + QString::number(tb.tv_sec-t0.tv_sec) + " sec] (" + QString::number(readCount) + ")"); - digiMTX[ID].unlock(); - // readCount = 0; - ta = tb; - } - } + // if( isSaveData && !stop ) { + // clock_gettime(CLOCK_REALTIME, &tb); + // if( tb.tv_sec - ta.tv_sec > 2 ) { + // digiMTX[ID].lock(); + // emit sendMsg("FileSize ("+ QString::number(digi->GetSerialNumber()) +"): " + QString::number(digi->GetData()->GetTotalFileSize()/1024./1024., 'f', 4) + " MB [" + QString::number(tb.tv_sec-t0.tv_sec) + " sec]"); + // //emit sendMsg("FileSize ("+ QString::number(digi->GetSerialNumber()) +"): " + QString::number(digi->GetData()->GetTotalFileSize()/1024./1024., 'f', 4) + " MB [" + QString::number(tb.tv_sec-t0.tv_sec) + " sec] (" + QString::number(readCount) + ")"); + // digiMTX[ID].unlock(); + // // readCount = 0; + // ta = tb; + // } + // } }while(!stop); printf("ReadDataThread for digi-%d stopped.\n", digi->GetSerialNumber()); diff --git a/FSUDAQ.cpp b/FSUDAQ.cpp index 359d379..9f17060 100644 --- a/FSUDAQ.cpp +++ b/FSUDAQ.cpp @@ -891,6 +891,10 @@ void MainWindow::SetupScalar(){ lbAggCount[iDigi] = new QLabel("AggCount/ReadCount", scalar); lbAggCount[iDigi]->setAlignment(Qt::AlignLeft | Qt::AlignCenter); hBoxLayout->addWidget(lbAggCount[iDigi]); + + lbFileSize[iDigi] = new QLabel("File Size", scalar); + lbFileSize[iDigi]->setAlignment(Qt::AlignLeft | Qt::AlignCenter); + hBoxLayout->addWidget(lbFileSize[iDigi]); QLabel * lbDigi = new QLabel("Digi-" + QString::number(digi[iDigi]->GetSerialNumber()), scalar); lbDigi->setAlignment(Qt::AlignRight | Qt::AlignCenter); @@ -1003,6 +1007,7 @@ void MainWindow::UpdateScalar(){ blockCountStr += "/" + QString::number(readDataThread[iDigi]->GetReadCount()); readDataThread[iDigi]->SetReadCountZero(); lbAggCount[iDigi]->setText(blockCountStr); + lbFileSize[iDigi]->setText(QString::number(digi[iDigi]->GetData()->GetTotalFileSize()/1024./1024., 'f', 3) + " MB"); digi[iDigi]->GetData()->CalTriggerRate(); //this will reset NumEventDecode & AggCount if( chkSaveData->isChecked() ) totalFileSize += digi[iDigi]->GetData()->GetTotalFileSize(); diff --git a/FSUDAQ.h b/FSUDAQ.h index fccee35..7912622 100644 --- a/FSUDAQ.h +++ b/FSUDAQ.h @@ -171,6 +171,8 @@ private: QLabel * lbLastUpdateTime; QLabel * lbScalarACQStatus; QLabel * lbAggCount[MaxNDigitizer]; + QLabel * lbFileSize[MaxNDigitizer]; + //@----- Run Record QMainWindow * runRecord; diff --git a/macro.h b/macro.h index fcb3b33..d071d78 100644 --- a/macro.h +++ b/macro.h @@ -11,7 +11,7 @@ #define MaxRecordLength 0x3fff * 8 #define MaxSaveFileSize 1024 * 1024 * 1024 * 2 -#define MaxDisplayTraceTimeLength 10000 //ns +#define MaxDisplayTraceTimeLength 20000 //ns #define ScopeUpdateMiliSec 200 // msec #define MaxNumberOfTrace 5 // in an event diff --git a/main.cpp b/main.cpp index 8a3d2fc..e829a6a 100644 --- a/main.cpp +++ b/main.cpp @@ -9,20 +9,21 @@ #include #include -class CustomApplication : public QApplication{ -public: - CustomApplication(int &argc, char **argv) : QApplication(argc, argv) {} +// class CustomApplication : public QApplication{ +// public: +// CustomApplication(int &argc, char **argv) : QApplication(argc, argv) {} -protected: - bool notify(QObject *receiver, QEvent *event) override{ - qDebug() << "Event:" << event->type() << "Receiver:" << receiver; - return QApplication::notify(receiver, event); - } -}; +// protected: +// bool notify(QObject *receiver, QEvent *event) override{ +// qDebug() << event->type() << "Receiver:" << receiver; +// return QApplication::notify(receiver, event); +// } +// }; int main(int argc, char *argv[]){ - CustomApplication a(argc, argv); + // CustomApplication a(argc, argv); + QApplication a(argc, argv); bool isLock = false; int pid = 0; From 03c3e79497df6023c2794b5684d19e7df9844dd6 Mon Sep 17 00:00:00 2001 From: "Ryan@WorkStation" Date: Tue, 9 Apr 2024 15:18:48 -0400 Subject: [PATCH 05/14] added SoftwareDisable Digitizer, Replace SW trigger button with SetNoTrace button --- ClassDigitizer.cpp | 2 ++ ClassDigitizer.h | 1 + CustomThreads.h | 6 ++++-- DigiSettingsPanel.cpp | 36 ++++++++++++++++++++++++++++++++---- DigiSettingsPanel.h | 4 +++- FSUDAQ.cpp | 5 +++++ 6 files changed, 47 insertions(+), 7 deletions(-) diff --git a/ClassDigitizer.cpp b/ClassDigitizer.cpp index dcfcc3d..0e14e3d 100644 --- a/ClassDigitizer.cpp +++ b/ClassDigitizer.cpp @@ -1341,6 +1341,7 @@ void Digitizer::SetOptimialAggOrg(){ uint32_t EventAgg = ReadRegister(DPP::QDC::NumberEventsPerAggregate, 0); uint32_t chMask = ReadRegister(DPP::QDC::GroupEnableMask); uint32_t RecordLen = ReadRegister(DPP::QDC::RecordLength_R, 0); + if( RecordLen == 0 ) SetBits(DPP::BoardConfiguration, DPP::Bit_BoardConfig::RecordTrace, 0, -1); uint32_t AggRead = ReadRegister(DPP::MaxAggregatePerBlockTransfer); uint32_t boardCfg = ReadRegister(DPP::BoardConfiguration); @@ -1359,6 +1360,7 @@ void Digitizer::SetOptimialAggOrg(){ printf(" Record Length (bit) : %u = %u sample = %u ns\n", RecordLen, RecordLen*8, RecordLen*8*16); printf("==============================================================\n"); + int eventSize = 6 + 2 * Ex + traceOn * RecordLen * 8; // sample double maxAggOrg = log2( MemorySizekSample * 1024 / eventSize / EventAgg ); printf(" max Agg. Org. should be less than %.2f\n", maxAggOrg); diff --git a/ClassDigitizer.h b/ClassDigitizer.h index e1a571a..6b7652f 100644 --- a/ClassDigitizer.h +++ b/ClassDigitizer.h @@ -90,6 +90,7 @@ class Digitizer{ bool IsConnected() {return isConnected;} void DisableBoard() {softwareDisable = true;} + void EnableBoard() {softwareDisable = false;} bool IsBoardDisabled() const {return softwareDisable;} void PrintBoard(); diff --git a/CustomThreads.h b/CustomThreads.h index 53973d7..62e2c3f 100644 --- a/CustomThreads.h +++ b/CustomThreads.h @@ -38,6 +38,10 @@ public: // ta = t0; t1 = t0; + digiMTX[ID].lock(); + digi->ReadACQStatus(); + digiMTX[ID].unlock(); + printf("ReadDataThread for digi-%d running.\n", digi->GetSerialNumber()); do{ @@ -90,7 +94,6 @@ public: // ta = tb; // } // } - }while(!stop); printf("ReadDataThread for digi-%d stopped.\n", digi->GetSerialNumber()); } @@ -104,7 +107,6 @@ private: bool isSaveData; bool isScope; unsigned long readCount; - }; //^#======================================================= Timing Thread diff --git a/DigiSettingsPanel.cpp b/DigiSettingsPanel.cpp index 1ba93e9..8dad238 100644 --- a/DigiSettingsPanel.cpp +++ b/DigiSettingsPanel.cpp @@ -219,9 +219,17 @@ DigiSettingsPanel::DigiSettingsPanel(Digitizer ** digi, unsigned int nDigi, QStr connect(bnLoadSettings, &QPushButton::clicked, this, &DigiSettingsPanel::LoadSetting); rowID ++; //--------------------------- - bnSendSoftwareTriggerSignal = new QPushButton("Send SW Trigger Signal", this); - buttonLayout->addWidget(bnSendSoftwareTriggerSignal, rowID, 0); - connect(bnSendSoftwareTriggerSignal, &QPushButton::clicked, this, [=](){ digi[ID]->WriteRegister(DPP::SoftwareTrigger_W, 1); UpdateBoardAndChannelsStatus();}); + // bnSendSoftwareTriggerSignal = new QPushButton("Send SW Trigger Signal", this); + // buttonLayout->addWidget(bnSendSoftwareTriggerSignal, rowID, 0); + // connect(bnSendSoftwareTriggerSignal, &QPushButton::clicked, this, [=](){ digi[ID]->WriteRegister(DPP::SoftwareTrigger_W, 1); UpdateBoardAndChannelsStatus();}); + + bnSetNoTrace = new QPushButton("Set No Trace", this); + buttonLayout->addWidget(bnSetNoTrace, rowID, 0); + connect(bnSetNoTrace, &QPushButton::clicked, this, [=](){ + for( unsigned int i = 0; i < nDigi; i++){ + chkTraceRecording[i]->setChecked(false); + } + }); bhAutoSetEventPulling = new QPushButton("Autoset Reading Conf.", this); buttonLayout->addWidget(bhAutoSetEventPulling, rowID, 1); @@ -330,7 +338,6 @@ DigiSettingsPanel::DigiSettingsPanel(Digitizer ** digi, unsigned int nDigi, QStr ID = index; //if( digi[ID]->GetDPPType() == V1730_DPP_PHA_CODE ) UpdatePanelFromMemory(); UpdatePanelFromMemory(); - } }); @@ -1375,7 +1382,28 @@ void DigiSettingsPanel::SetUpChannelMask(unsigned int digiID){ emit UpdateOtherPanels(); }); } + + QLabel * blank = new QLabel(" ", this); + chLayout->addWidget(blank, 1, nChGrp ); + + cbDigiEnable[digiID] = new QCheckBox("Enable Digitizer",this); + cbDigiEnable[digiID]->setChecked(true); + chLayout->addWidget(cbDigiEnable[digiID], 1, nChGrp + 2 ); + + connect(cbDigiEnable[digiID], &QCheckBox::stateChanged, this, [=](int state){ + if( state == Qt::Checked ){ + digi[digiID]->EnableBoard(); + cbDigiEnable[digiID]->setStyleSheet(""); + tabWidget->setTabText(digiID, "Digi-" + QString::number(digi[digiID]->GetSerialNumber())); + }else{ + digi[digiID]->DisableBoard(); + cbDigiEnable[digiID]->setStyleSheet("color: red"); + tabWidget->setTabText(digiID, "Digi-" + QString::number(digi[digiID]->GetSerialNumber()) + "(D)"); + } + UpdateBoardAndChannelsStatus(); + }); + } void DigiSettingsPanel::SetUpACQReadOutTab(){ diff --git a/DigiSettingsPanel.h b/DigiSettingsPanel.h index 11cd147..ea82950 100644 --- a/DigiSettingsPanel.h +++ b/DigiSettingsPanel.h @@ -106,7 +106,8 @@ private: QPushButton * bnProgramPreDefined; QPushButton * bnClearBuffer; - QPushButton * bnSendSoftwareTriggerSignal; + // QPushButton * bnSendSoftwareTriggerSignal; + QPushButton * bnSetNoTrace; QPushButton * bhAutoSetEventPulling; //QPushButton * bnSendSoftwareClockSyncSignal; QPushButton * bnSaveSettings; @@ -134,6 +135,7 @@ private: RComboBox * cbDigiProbe2[MaxNDigitizer]; QPushButton * bnChEnableMask[MaxNDigitizer][MaxRegChannel]; + QCheckBox * cbDigiEnable[MaxNDigitizer]; RComboBox * cbAggOrg[MaxNDigitizer]; RSpinBox * sbAggNum[MaxNDigitizer]; QCheckBox * chkEnableExternalTrigger[MaxNDigitizer]; diff --git a/FSUDAQ.cpp b/FSUDAQ.cpp index 9f17060..155aa26 100644 --- a/FSUDAQ.cpp +++ b/FSUDAQ.cpp @@ -1105,6 +1105,7 @@ void MainWindow::StartACQ(){ bnStopACQ->setStyleSheet("background-color: red;"); bnOpenScope->setEnabled(false); cbAutoRun->setEnabled(false); + bnSync->setEnabled(false); if( digiSettings ) digiSettings->setEnabled(false); @@ -1134,6 +1135,9 @@ void MainWindow::StartACQ(){ void MainWindow::StopACQ(){ DebugPrint("%s", "FSUDAQ"); + + QCoreApplication::processEvents(); + if( digi == nullptr ) return; bool commentResult = true; @@ -1183,6 +1187,7 @@ void MainWindow::StopACQ(){ bnStopACQ->setStyleSheet(""); bnOpenScope->setEnabled(true); cbAutoRun->setEnabled(true); + bnSync->setEnabled(true); if( scalar ){ for( unsigned int iDigi = 0; iDigi < nDigi; iDigi ++){ From 3c8229fbfb7ddc7e2b994fa3ec855eabf56f4a75 Mon Sep 17 00:00:00 2001 From: "Ryan@SOLARIS_testStation" Date: Fri, 12 Apr 2024 18:53:00 -0400 Subject: [PATCH 06/14] fixed histogram fill zero --- SingleSpectra.cpp | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/SingleSpectra.cpp b/SingleSpectra.cpp index d8da715..801449b 100644 --- a/SingleSpectra.cpp +++ b/SingleSpectra.cpp @@ -204,28 +204,39 @@ void SingleSpectra::FillHistograms(){ // DebugPrint("%s", "SingleSpectra"); if( !fillHistograms ) return; + printf("=====================%s\n", __func__); + timespec t0, t1; QVector randomDigiList = generateNonRepeatedCombination(nDigi); + // qDebug() << randomDigiList; + for( int i = 0; i < nDigi; i++){ int ID = randomDigiList[i]; QVector randomChList = generateNonRepeatedCombination(digi[ID]->GetNumInputCh()); + // qDebug() << randomChList; + digiMTX[ID].lock(); + + // digi[ID]->GetData()->PrintAllData(); + clock_gettime(CLOCK_REALTIME, &t0); for( int k = 0; k < digi[ID]->GetNumInputCh(); k ++ ){ int ch = randomChList[k]; int lastIndex = digi[ID]->GetData()->GetDataIndex(ch); + // printf("--- ch %2d | last index %d \n", ch, lastIndex); if( lastIndex < 0 ) continue; int loopIndex = digi[ID]->GetData()->GetLoopIndex(ch); int temp1 = lastIndex + loopIndex * digi[ID]->GetData()->GetDataSize(); - int temp2 = lastFilledIndex[ID][ch] + loopFilledIndex[ID][ch] * digi[ID]->GetData()->GetDataSize(); + int temp2 = lastFilledIndex[ID][ch] + loopFilledIndex[ID][ch] * digi[ID]->GetData()->GetDataSize() + 1; + + // printf("loopIndx : %d | ID now : %d, ID old : %d \n", loopIndex, temp1, temp2); - // printf("%d |%d %d \n", ch, temp2, temp1); if( temp1 <= temp2 ) continue; if( temp1 - temp2 > digi[ID]->GetData()->GetDataSize() ) { //DefaultDataSize = 10k @@ -233,6 +244,8 @@ void SingleSpectra::FillHistograms(){ lastFilledIndex[ID][ch] = lastIndex; lastFilledIndex[ID][ch] = loopIndex - 1; } + + // printf("ch %d | regulated ID now %d new %d | last fill idx %d\n", ch, temp2, temp1, lastFilledIndex[ID][ch]); for( int j = 0 ; j <= temp1 - temp2; j ++){ lastFilledIndex[ID][ch] ++; @@ -240,8 +253,13 @@ void SingleSpectra::FillHistograms(){ lastFilledIndex[ID][ch] = 0; loopFilledIndex[ID][ch] ++; } - hist[ID][ch]->Fill( digi[ID]->GetData()->GetEnergy(ch, lastFilledIndex[ID][ch])); - hist2D[ID]->Fill(ch, digi[ID]->GetData()->GetEnergy(ch, lastFilledIndex[ID][ch])); + + uShort data = digi[ID]->GetData()->GetEnergy(ch, lastFilledIndex[ID][ch]); + + // printf(" ch: %d, last fill idx : %d | %d \n", ch, lastFilledIndex[ID][ch], data); + + hist[ID][ch]->Fill( data ); + hist2D[ID]->Fill(ch, data); } if( histVisibility[ID][ch] ) hist[ID][ch]->UpdatePlot(); if( hist2DVisibility[ID] ) hist2D[ID]->UpdatePlot(); From dfe4c4738b1a34686dd9281ed3940a43d1ec318c Mon Sep 17 00:00:00 2001 From: ANASEN Date: Thu, 18 Apr 2024 10:06:55 -0400 Subject: [PATCH 07/14] solved the slow down problem by repaint the main window --- .vscode/settings.json | 3 ++- CustomThreads.h | 2 ++ DigiSettingsPanel.cpp | 13 +++++++++++-- FSUDAQ.cpp | 30 +++++++++++++++++++++++------- FSUDAQ.h | 1 + SingleSpectra.cpp | 2 -- main.cpp | 4 ++++ 7 files changed, 43 insertions(+), 12 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 7a3b6d7..05f7e93 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -160,6 +160,7 @@ "fstream": "cpp", "Analyzer.C": "cpp", "process_Run.C": "cpp", - "EncoreAnalyzer.C": "cpp" + "EncoreAnalyzer.C": "cpp", + "qfiledialog": "cpp" } } \ No newline at end of file diff --git a/CustomThreads.h b/CustomThreads.h index 62e2c3f..6ee9d73 100644 --- a/CustomThreads.h +++ b/CustomThreads.h @@ -5,6 +5,7 @@ #include #include #include +#include #include "macro.h" #include "ClassDigitizer.h" @@ -81,6 +82,7 @@ public: digi->ReadACQStatus(); digiMTX[ID].unlock(); t2 = t1; + // QCoreApplication::processEvents(); } // if( isSaveData && !stop ) { diff --git a/DigiSettingsPanel.cpp b/DigiSettingsPanel.cpp index 8dad238..70061ed 100644 --- a/DigiSettingsPanel.cpp +++ b/DigiSettingsPanel.cpp @@ -97,8 +97,17 @@ DigiSettingsPanel::DigiSettingsPanel(Digitizer ** digi, unsigned int nDigi, QStr SetUpInfo("Ch. Mem. Size ", memStr.toStdString() , infoLayout[ID], 3, 2); uint32_t boardInfo = digi[ID]->GetSettingFromMemory(DPP::BoardInfo_R); - printf("----------- boardInfo : 0x%08X \n", boardInfo); - SetUpInfo("Board Type ", ((boardInfo >> 16) & 0xFF) == 0x10 ? "16-ch VME" : "8-ch Bd.", infoLayout[ID], 3, 4); + // printf("----------- boardInfo : 0x%08X \n", boardInfo); + std::string boardInfoStr; + unsigned short boardTypeNumber = (boardInfo & 0xFF); + switch (boardTypeNumber){ + case 0x04 : boardInfoStr = "64-ch VME"; break; + case 0x0E : boardInfoStr = ((boardInfo >> 16) & 0xFF) == 0x10 ? "16-ch VME" : "8-ch Bd."; break; + case 0x0B : boardInfoStr = ((boardInfo >> 16) & 0xFF) == 0x10 ? "16-ch VME" : "8-ch Bd."; break; + default : boardInfoStr = "unknown"; + } + + SetUpInfo("Board Type ", boardInfoStr, infoLayout[ID], 3, 4); } diff --git a/FSUDAQ.cpp b/FSUDAQ.cpp index 155aa26..2457105 100644 --- a/FSUDAQ.cpp +++ b/FSUDAQ.cpp @@ -41,6 +41,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent){ runRecord = nullptr; model = nullptr; influx = nullptr; + scalarCount = 0; QWidget * mainLayoutWidget = new QWidget(this); setCentralWidget(mainLayoutWidget); @@ -896,7 +897,8 @@ void MainWindow::SetupScalar(){ lbFileSize[iDigi]->setAlignment(Qt::AlignLeft | Qt::AlignCenter); hBoxLayout->addWidget(lbFileSize[iDigi]); - QLabel * lbDigi = new QLabel("Digi-" + QString::number(digi[iDigi]->GetSerialNumber()), scalar); + // QLabel * lbDigi = new QLabel("Digi-" + QString::number(digi[iDigi]->GetSerialNumber()), scalar); + QLabel * lbDigi = new QLabel(QString::number(digi[iDigi]->GetSerialNumber()), scalar); lbDigi->setAlignment(Qt::AlignRight | Qt::AlignCenter); hBoxLayout->addWidget(lbDigi); @@ -986,6 +988,7 @@ void MainWindow::UpdateScalar(){ // digi[0]->GetData()->PrintAllData(); lbLastUpdateTime->setText("Last update: " + QDateTime::currentDateTime().toString("MM.dd hh:mm:ss")); + scalarCount ++; uint64_t totalFileSize = 0; for( unsigned int iDigi = 0; iDigi < nDigi; iDigi++){ @@ -994,9 +997,9 @@ void MainWindow::UpdateScalar(){ uint32_t acqStatus = digi[iDigi]->GetACQStatusFromMemory(); //printf("Digi-%d : acq on/off ? : %d \n", digi[iDigi]->GetSerialNumber(), (acqStatus >> 2) & 0x1 ); if( ( acqStatus >> 2 ) & 0x1 ){ - runStatus[iDigi]->setStyleSheet("background-color : green;"); + if( runStatus[iDigi]->styleSheet() == "") runStatus[iDigi]->setStyleSheet("background-color : green;"); }else{ - runStatus[iDigi]->setStyleSheet(""); + if( runStatus[iDigi]->styleSheet() != "") runStatus[iDigi]->setStyleSheet(""); } if(digiSettings && digiSettings->isVisible() && digiSettings->GetTabID() == iDigi) digiSettings->UpdateACQStatus(acqStatus); @@ -1023,16 +1026,20 @@ void MainWindow::UpdateScalar(){ leAccept[iDigi][i]->setText(b); if( influx && a != "inf" ){ - influx->AddDataPoint("Rate,Bd="+std::to_string(digi[iDigi]->GetSerialNumber()) + ",Ch=" + QString::number(i).rightJustified(2, '0').toStdString() + " value=" + a.toStdString()); + influx->AddDataPoint("TrigRate,Bd="+std::to_string(digi[iDigi]->GetSerialNumber()) + ",Ch=" + QString::number(i).rightJustified(2, '0').toStdString() + " value=" + a.toStdString()); } } } digiMTX[iDigi].unlock(); + } - if( influx ){ + repaint(); + scalar->repaint(); + + if( influx && scalarCount >= 3){ if( chkSaveData->isChecked() ) { influx->AddDataPoint("RunID value=" + std::to_string(runID)); influx->AddDataPoint("FileSize value=" + std::to_string(totalFileSize)); @@ -1040,6 +1047,7 @@ void MainWindow::UpdateScalar(){ //nflux->PrintDataPoints(); influx->WriteData(dataBaseName.toStdString()); influx->ClearDataPointsBuffer(); + scalarCount = 0; } } @@ -1228,6 +1236,9 @@ void MainWindow::StopACQ(){ chkSaveData->setEnabled(true); bnDigiSettings->setEnabled(true); + repaint(); + printf("================ end of %s \n", __func__); + } void MainWindow::AutoRun(){ @@ -1638,7 +1649,8 @@ void MainWindow::WriteRunTimestamp(bool isStartRun){ //*************************************************************** //*************************************************************** void MainWindow::OpenScope(){ - + DebugPrint("%s", "FSUDAQ"); + QCoreApplication::processEvents(); if( scope == nullptr ) { scope = new Scope(digi, nDigi, readDataThread); connect(scope, &Scope::SendLogMsg, this, &MainWindow::LogMsg); @@ -1711,7 +1723,6 @@ void MainWindow::OpenDigiSettings(){ digiSettings->show(); digiSettings->activateWindow(); } - } //*************************************************************** @@ -1731,6 +1742,7 @@ void MainWindow::OpenCanvas(){ //*************************************************************** void MainWindow::OpenAnalyzer(){ DebugPrint("%s", "FSUDAQ"); + int id = cbAnalyzer->currentData().toInt(); if( id < 0 ) return; @@ -1890,6 +1902,8 @@ void MainWindow::SetUpInflux(){ void MainWindow::CheckElog(){ DebugPrint("%s", "FSUDAQ"); + LogMsg("---- Checking elog... please wait...."); + printf("---- Checking elog... please wait....\n"); if( elogIP != "" && elogName != "" && elogUser != "" && elogPWD != "" ){ WriteElog("Testing communication.", "Testing communication.", "Other", 0); AppendElog("test append elog."); @@ -1902,11 +1916,13 @@ void MainWindow::CheckElog(){ if( elogID >= 0 ) { LogMsg("Elog testing OK."); + printf("Elog testing OK.\n"); return; } //QMessageBox::information(nullptr, "Information", "Elog write Fail.\nPlease set the elog User and PWD in the programSettings.txt.\nline 6 = user.\nline 7 = pwd."); LogMsg("Elog testing Fail"); + printf("Elog testing Fail\n"); if( elogIP == "" ) LogMsg("no elog IP"); if( elogName == "" ) LogMsg("no elog Name"); if( elogUser == "" ) LogMsg("no elog User name. Please set it in the programSettings.txt, line 6."); diff --git a/FSUDAQ.h b/FSUDAQ.h index 7912622..1a285b2 100644 --- a/FSUDAQ.h +++ b/FSUDAQ.h @@ -135,6 +135,7 @@ private: QLineEdit * leDatabaseName; QPushButton * bnLock; QString influxToken; + short scalarCount; //@----- Elog QString elogIP; diff --git a/SingleSpectra.cpp b/SingleSpectra.cpp index 801449b..490fd1b 100644 --- a/SingleSpectra.cpp +++ b/SingleSpectra.cpp @@ -204,8 +204,6 @@ void SingleSpectra::FillHistograms(){ // DebugPrint("%s", "SingleSpectra"); if( !fillHistograms ) return; - printf("=====================%s\n", __func__); - timespec t0, t1; QVector randomDigiList = generateNonRepeatedCombination(nDigi); diff --git a/main.cpp b/main.cpp index e829a6a..4f2ec66 100644 --- a/main.cpp +++ b/main.cpp @@ -9,6 +9,8 @@ #include #include +#include + // class CustomApplication : public QApplication{ // public: // CustomApplication(int &argc, char **argv) : QApplication(argc, argv) {} @@ -25,6 +27,8 @@ int main(int argc, char *argv[]){ // CustomApplication a(argc, argv); QApplication a(argc, argv); + setpriority(PRIO_PROCESS, 0, -20); + bool isLock = false; int pid = 0; QFile lockFile(DAQLockFile); From 8fd4c92c2b29dc104b7e4204b7e154334f425eaf Mon Sep 17 00:00:00 2001 From: "Ryan@SOLARIS_testStation" Date: Thu, 25 Apr 2024 17:01:45 -0400 Subject: [PATCH 08/14] Scalar UI update --- FSUDAQ.cpp | 96 +++++++++++++++++++++++++++++++----------------------- FSUDAQ.h | 2 +- 2 files changed, 57 insertions(+), 41 deletions(-) diff --git a/FSUDAQ.cpp b/FSUDAQ.cpp index 2457105..d2b3e55 100644 --- a/FSUDAQ.cpp +++ b/FSUDAQ.cpp @@ -833,6 +833,7 @@ void MainWindow::SetupScalar(){ lbLastUpdateTime = nullptr; lbScalarACQStatus = nullptr; + lbTotalFileSize = nullptr; scalarThread = new TimingThread(scalar); scalarThread->SetWaitTimeinSec(1.0); @@ -843,11 +844,12 @@ void MainWindow::SetupScalar(){ if( digi[k]->GetNumInputCh() > maxNChannel ) maxNChannel = digi[k]->GetNumInputCh(); } - scalar->setGeometry(0, 0, 100 + nDigi * 200, 200 + maxNChannel * 20); + scalar->setGeometry(0, 0, 50 + nDigi * 240, 160 + maxNChannel * 25); if( lbLastUpdateTime == nullptr ){ lbLastUpdateTime = new QLabel("Last update : NA", scalar); lbScalarACQStatus = new QLabel("ACQ status", scalar); + lbTotalFileSize = new QLabel("Total File Size", scalar); } lbLastUpdateTime->setAlignment(Qt::AlignRight); @@ -858,13 +860,17 @@ void MainWindow::SetupScalar(){ scalarLayout->removeWidget(lbScalarACQStatus); scalarLayout->addWidget(lbScalarACQStatus, 0, 1 + nDigi); - int rowID = 3; - ///==== create the header row + lbTotalFileSize->setAlignment(Qt::AlignCenter); + scalarLayout->removeWidget(lbTotalFileSize); + scalarLayout->addWidget(lbTotalFileSize, 1, 0, 1, 1 + 2*nDigi); + ///==== create the header row + int rowID = 4; for( int ch = 0; ch < maxNChannel; ch++){ if( ch == 0 ){ QLabel * lbCH_H = new QLabel("Ch", scalar); + lbCH_H->setAlignment(Qt::AlignCenter); scalarLayout->addWidget(lbCH_H, rowID, 0); } @@ -879,54 +885,61 @@ void MainWindow::SetupScalar(){ leAccept = new QLineEdit**[nDigi]; for( unsigned int iDigi = 0; iDigi < nDigi; iDigi++){ rowID = 2; + uint32_t chMask = digi[iDigi]->GetRegChannelMask(); + + QWidget * hBox = new QWidget(scalar); + QHBoxLayout * hBoxLayout = new QHBoxLayout(hBox); + scalarLayout->addWidget(hBox, rowID, 2*iDigi+1, 1, 2); + + QLabel * lbDigi = new QLabel("Digi-" + QString::number(digi[iDigi]->GetSerialNumber()), scalar); + // QLabel * lbDigi = new QLabel(QString::number(digi[iDigi]->GetSerialNumber()), scalar); + // lbDigi->setAlignment(Qt::AlignRight | Qt::AlignCenter); + lbDigi->setAlignment(Qt::AlignCenter); + hBoxLayout->addWidget(lbDigi); + + runStatus[iDigi] = new QPushButton("", scalar); + runStatus[iDigi]->setEnabled(false); + runStatus[iDigi]->setFixedSize(QSize(20,20)); + runStatus[iDigi]->setToolTip("ACQ RUN On/OFF"); + runStatus[iDigi]->setToolTipDuration(-1); + hBoxLayout->addWidget(runStatus[iDigi]); + + rowID = 3; + QWidget * hBox2 = new QWidget(scalar); + QHBoxLayout * hBoxLayout2 = new QHBoxLayout(hBox2); + scalarLayout->addWidget(hBox2, rowID, 2*iDigi+1, 1, 2); + + lbAggCount[iDigi] = new QLabel("AggCount/ReadCount", scalar); + lbAggCount[iDigi]->setAlignment(Qt::AlignLeft | Qt::AlignCenter); + hBoxLayout2->addWidget(lbAggCount[iDigi]); + + lbFileSize[iDigi] = new QLabel("File Size", scalar); + lbFileSize[iDigi]->setAlignment(Qt::AlignLeft | Qt::AlignCenter); + hBoxLayout2->addWidget(lbFileSize[iDigi]); + + rowID = 4; + QLabel * lbA = new QLabel("Trig. [Hz]", scalar); + lbA->setAlignment(Qt::AlignCenter); + scalarLayout->addWidget(lbA, rowID, 2*iDigi+1); + QLabel * lbB = new QLabel("Accp. [Hz]", scalar); + lbB->setAlignment(Qt::AlignCenter); + scalarLayout->addWidget(lbB, rowID, 2*iDigi+2); + leTrigger[iDigi] = new QLineEdit *[digi[iDigi]->GetNumInputCh()]; leAccept[iDigi] = new QLineEdit *[digi[iDigi]->GetNumInputCh()]; - uint32_t chMask = digi[iDigi]->GetRegChannelMask(); + for( int ch = 0; ch < digi[iDigi]->GetNumInputCh(); ch++){ - - if( ch == 0 ){ - QWidget * hBox = new QWidget(scalar); - QHBoxLayout * hBoxLayout = new QHBoxLayout(hBox); - scalarLayout->addWidget(hBox, rowID, 2*iDigi+1, 1, 2); - - lbAggCount[iDigi] = new QLabel("AggCount/ReadCount", scalar); - lbAggCount[iDigi]->setAlignment(Qt::AlignLeft | Qt::AlignCenter); - hBoxLayout->addWidget(lbAggCount[iDigi]); - - lbFileSize[iDigi] = new QLabel("File Size", scalar); - lbFileSize[iDigi]->setAlignment(Qt::AlignLeft | Qt::AlignCenter); - hBoxLayout->addWidget(lbFileSize[iDigi]); - - // QLabel * lbDigi = new QLabel("Digi-" + QString::number(digi[iDigi]->GetSerialNumber()), scalar); - QLabel * lbDigi = new QLabel(QString::number(digi[iDigi]->GetSerialNumber()), scalar); - lbDigi->setAlignment(Qt::AlignRight | Qt::AlignCenter); - hBoxLayout->addWidget(lbDigi); - - runStatus[iDigi] = new QPushButton("", scalar); - runStatus[iDigi]->setEnabled(false); - runStatus[iDigi]->setFixedSize(QSize(20,20)); - runStatus[iDigi]->setToolTip("ACQ RUN On/OFF"); - runStatus[iDigi]->setToolTipDuration(-1); - hBoxLayout->addWidget(runStatus[iDigi]); - - rowID ++; - - QLabel * lbA = new QLabel("Trig. [Hz]", scalar); - lbA->setAlignment(Qt::AlignCenter); - scalarLayout->addWidget(lbA, rowID, 2*iDigi+1); - QLabel * lbB = new QLabel("Accp. [Hz]", scalar); - lbB->setAlignment(Qt::AlignCenter); - scalarLayout->addWidget(lbB, rowID, 2*iDigi+2); - } rowID ++; leTrigger[iDigi][ch] = new QLineEdit(scalar); leTrigger[iDigi][ch]->setReadOnly(true); + leTrigger[iDigi][ch]->setFixedSize(120, 25); leTrigger[iDigi][ch]->setAlignment(Qt::AlignRight); scalarLayout->addWidget(leTrigger[iDigi][ch], rowID, 2*iDigi+1); leAccept[iDigi][ch] = new QLineEdit(scalar); leAccept[iDigi][ch]->setReadOnly(true); + leAccept[iDigi][ch]->setFixedSize(120, 25); leAccept[iDigi][ch]->setAlignment(Qt::AlignRight); leAccept[iDigi][ch]->setStyleSheet("background-color: #F0F0F0;"); @@ -987,7 +1000,8 @@ void MainWindow::UpdateScalar(){ // digi[0]->GetData()->PrintAllData(); - lbLastUpdateTime->setText("Last update: " + QDateTime::currentDateTime().toString("MM.dd hh:mm:ss")); + // lbLastUpdateTime->setText("Last update: " + QDateTime::currentDateTime().toString("MM.dd hh:mm:ss")); + lbLastUpdateTime->setText(QDateTime::currentDateTime().toString("MM/dd hh:mm:ss")); scalarCount ++; uint64_t totalFileSize = 0; @@ -1036,6 +1050,8 @@ void MainWindow::UpdateScalar(){ } + lbTotalFileSize->setText("Total Data Size : " + QString::number(totalFileSize/1024./1024., 'f', 3) + " MB"); + repaint(); scalar->repaint(); diff --git a/FSUDAQ.h b/FSUDAQ.h index 1a285b2..120fd53 100644 --- a/FSUDAQ.h +++ b/FSUDAQ.h @@ -173,7 +173,7 @@ private: QLabel * lbScalarACQStatus; QLabel * lbAggCount[MaxNDigitizer]; QLabel * lbFileSize[MaxNDigitizer]; - + QLabel * lbTotalFileSize; //@----- Run Record QMainWindow * runRecord; From 513608e99118d1c24d3319bd9d03d55aeb4deab9 Mon Sep 17 00:00:00 2001 From: "Ryan@SOLARIS_testStation" Date: Thu, 25 Apr 2024 18:24:05 -0400 Subject: [PATCH 09/14] SingleSpectrum, add button to rebin y-axis for whole digitizer --- Histogram2D.h | 5 +++ SingleSpectra.cpp | 99 ++++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 99 insertions(+), 5 deletions(-) diff --git a/Histogram2D.h b/Histogram2D.h index 54ca5a6..88f8eed 100644 --- a/Histogram2D.h +++ b/Histogram2D.h @@ -190,6 +190,7 @@ public: void SetXTitle(QString xTitle) { xAxis->setLabel(xTitle); } void SetYTitle(QString yTitle) { yAxis->setLabel(yTitle); } void Rebin(int xbin, double xmin, double xmax, int ybin, double ymin, double ymax); + void RebinY(int ybin, double ymin, double ymax); void SetChannelMap(bool onOff, int tickStep = 1) { isChannelMap = onOff; this->tickStep = tickStep;} @@ -339,6 +340,10 @@ inline void Histogram2D::Rebin(int xbin, double xmin, double xmax, int ybin, do } +inline void Histogram2D::RebinY(int ybin, double ymin, double ymax){ + Rebin(xBin-2, xMin, xMax, ybin, ymin, ymax); +} + inline void Histogram2D::Clear(){ DebugPrint("%s", "Histogram2D"); for( int i = 0; i < 3; i ++){ diff --git a/SingleSpectra.cpp b/SingleSpectra.cpp index 490fd1b..40e2ad2 100644 --- a/SingleSpectra.cpp +++ b/SingleSpectra.cpp @@ -16,7 +16,7 @@ SingleSpectra::SingleSpectra(Digitizer ** digi, unsigned int nDigi, QString rawD isSignalSlotActive = true; - setWindowTitle("1-D Histograms"); + setWindowTitle("Single Histograms"); setGeometry(0, 0, 1000, 800); //setWindowFlags( this->windowFlags() & ~Qt::WindowCloseButtonHint ); @@ -68,15 +68,103 @@ SingleSpectra::SingleSpectra(Digitizer ** digi, unsigned int nDigi, QString rawD for( unsigned int i = 0; i < nDigi; i++){ for( int j = 0; j < digi[i]->GetNumInputCh(); j++){ if( hist[i][j] ) hist[i][j]->Clear(); - // lastFilledIndex[i][j] = -1; - // loopFilledIndex[i][j] = 0; } if( hist2D[i] ) hist2D[i]->Clear(); } }); + QPushButton * bnRebinDigi = new QPushButton("Rebin Energy", this); + ctrlLayout->addWidget(bnRebinDigi, 0, 6, 1, 2); + connect(bnRebinDigi, &QPushButton::clicked, this, [=](){ + int ID = cbDigi->currentIndex(); + int ch = cbCh->currentIndex(); + + int a_Bin; + float a_Min, a_Max; + + if( ch >= 0 ){ + a_Bin = hist[ID][ch]->GetNBin(); + a_Min = hist[ID][ch]->GetXMin(); + a_Max = hist[ID][ch]->GetXMax(); + }else{ + a_Bin = hist2D[ID]->GetYNBin(); + a_Min = hist2D[ID]->GetYMin(); + a_Max = hist2D[ID]->GetYMax(); + } + + //pop up a dialog for nBin and ranhe + + QDialog dialog(this); + dialog.setWindowTitle("Rebin histograms"); + + QFormLayout layout(&dialog); + + QLabel * info = new QLabel(&dialog); + info->setStyleSheet("color:red;"); + info->setText("This will also clear histogram!!"); + layout.addRow(info); + + QStringList nameList = {"Num. Bin", "x-Min", "x-Max"}; + QLineEdit* lineEdit[3]; + + for (int i = 0; i < 3; ++i) { + lineEdit[i] = new QLineEdit(&dialog); + layout.addRow(nameList[i] + " : ", lineEdit[i]); + } + lineEdit[0]->setText(QString::number(a_Bin)); + lineEdit[1]->setText(QString::number(a_Min)); + lineEdit[2]->setText(QString::number(a_Max)); + + QLabel * msg = new QLabel(&dialog); + msg->setStyleSheet("color:red;"); + layout.addRow(msg); + + QDialogButtonBox buttonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, &dialog); + layout.addRow(&buttonBox); + + double number[3]; + + QObject::connect(&buttonBox, &QDialogButtonBox::accepted, [&]() { + int OKcount = 0; + bool conversionOk = true; + for( int i = 0; i < 3; i++ ){ + number[i] = lineEdit[i]->text().toDouble(&conversionOk); + if( conversionOk ){ + OKcount++; + }else{ + msg->setText(nameList[i] + " is invalid."); + return; + } + } + + if( OKcount == 3 ) { + if( number[2] > number[1] ) { + dialog.accept(); + }else{ + msg->setText(nameList[2] + " is smaller than " + nameList[1]); + } + } + }); + QObject::connect(&buttonBox, &QDialogButtonBox::rejected, [&]() { dialog.reject();}); + + if( dialog.exec() == QDialog::Accepted ){ + if( hist2D[ID] ) { + hist2D[ID]->RebinY((int)number[0], number[1], number[2]); + hist2D[ID]->rescaleAxes(); + hist2D[ID]->UpdatePlot(); + } + for( int j = 0; j < digi[ID]->GetNumInputCh(); j++){ + if( hist[ID][j] ) { + hist[ID][j]->Rebin((int)number[0], number[1], number[2]); + hist[ID][j]->UpdatePlot(); + } + } + } + + }); + QCheckBox * chkIsFillHistogram = new QCheckBox("Fill Histograms", this); - ctrlLayout->addWidget(chkIsFillHistogram, 0, 6); + ctrlLayout->addWidget(chkIsFillHistogram, 0, 8); connect(chkIsFillHistogram, &QCheckBox::stateChanged, this, [=](int state){ fillHistograms = state;}); chkIsFillHistogram->setChecked(false); fillHistograms = false; @@ -260,11 +348,12 @@ void SingleSpectra::FillHistograms(){ hist2D[ID]->Fill(ch, data); } if( histVisibility[ID][ch] ) hist[ID][ch]->UpdatePlot(); - if( hist2DVisibility[ID] ) hist2D[ID]->UpdatePlot(); clock_gettime(CLOCK_REALTIME, &t1); if( t1.tv_nsec - t0.tv_nsec + (t1.tv_sec - t0.tv_sec)*1e9 > maxFillTimePerDigi * 1e6 ) break; } + + if( hist2DVisibility[ID] ) hist2D[ID]->UpdatePlot(); digiMTX[ID].unlock(); } From 952b352e8af819235cfc49101c9fdae466bcad4a Mon Sep 17 00:00:00 2001 From: "Ryan@SOLARIS_testStation" Date: Mon, 6 May 2024 14:06:00 -0400 Subject: [PATCH 10/14] fix display bug on QDC scope RecordLength --- FSUDAQ.cpp | 2 +- Scope.cpp | 176 +++++++++++++++++++++++++++++++++++------------------ Scope.h | 5 +- 3 files changed, 121 insertions(+), 62 deletions(-) diff --git a/FSUDAQ.cpp b/FSUDAQ.cpp index d2b3e55..3c95c4a 100644 --- a/FSUDAQ.cpp +++ b/FSUDAQ.cpp @@ -1943,7 +1943,7 @@ void MainWindow::CheckElog(){ if( elogName == "" ) LogMsg("no elog Name"); if( elogUser == "" ) LogMsg("no elog User name. Please set it in the programSettings.txt, line 6."); if( elogPWD == "" ) LogMsg("no elog User pwd. Please set it in the programSettings.txt, line 7."); - if( elogID < 0 ) LogMsg("Possible elog IP, Name, User name, or pwd incorrect"); + if( elogID < 0 ) LogMsg("Possible elog IP, Name, User name, pwd incorrect, or elog not installed."); leElogIP->setEnabled(false); leElogName->setEnabled(false); diff --git a/Scope.cpp b/Scope.cpp index cf05922..d8c7071 100644 --- a/Scope.cpp +++ b/Scope.cpp @@ -68,31 +68,6 @@ Scope::Scope(Digitizer ** digi, unsigned int nDigi, ReadDataThread ** readDataTh plot->addSeries(dataTrace[i]); } - // testing software trapezoid filter - // FILE * fileIn = fopen("wave.txt", "r"); - // if( fileIn != nullptr ){ - - // char buf[500]; - // int v1, v2; - - // QVector points; - // QVector points1; - // while( fgets(buf, sizeof(buf), fileIn) != nullptr ){ - - // if (sscanf(buf, "%d, %d", &v1, &v2) == 2) { - // points.append(QPointF(v1, v2 + 7000)); - // } - // } - - // fclose(fileIn); - - // points1 = TrapezoidFilter(points, 400/16, 100, 200, 1000); - - // dataTrace[0]->replace(points); - // dataTrace[1]->replace(points1); - - // } - dataTrace[0]->setPen(QPen(Qt::red, 2)); dataTrace[1]->setPen(QPen(Qt::blue, 2)); dataTrace[2]->setPen(QPen(Qt::darkYellow, 1)); @@ -191,7 +166,6 @@ Scope::Scope(Digitizer ** digi, unsigned int nDigi, ReadDataThread ** readDataTh }); - bnReadSettingsFromBoard = new QPushButton("Refresh Settings", this); layout->addWidget(bnReadSettingsFromBoard, rowID, 2); connect(bnReadSettingsFromBoard, &QPushButton::clicked, this, &Scope::ReadSettingsFromBoard); @@ -257,18 +231,21 @@ Scope::Scope(Digitizer ** digi, unsigned int nDigi, ReadDataThread ** readDataTh layout->addWidget(bnScopeStart, rowID, 0); connect(bnScopeStart, &QPushButton::clicked, this, [=](){this->StartScope();}); + chkSoleRun = new QCheckBox("Only this channel", this); + layout->addWidget(chkSoleRun, rowID, 1); + bnScopeStop = new QPushButton("Stop", this); - layout->addWidget(bnScopeStop, rowID, 1); + layout->addWidget(bnScopeStop, rowID, 2); connect(bnScopeStop, &QPushButton::clicked, this, &Scope::StopScope); QLabel * lbTriggerRate = new QLabel("Trigger Rate [Hz] : ", this); lbTriggerRate->setAlignment(Qt::AlignCenter | Qt::AlignRight); - layout->addWidget(lbTriggerRate, rowID, 2); + layout->addWidget(lbTriggerRate, rowID, 3); leTriggerRate = new QLineEdit(this); leTriggerRate->setAlignment(Qt::AlignRight); leTriggerRate->setReadOnly(true); - layout->addWidget(leTriggerRate, rowID, 3); + layout->addWidget(leTriggerRate, rowID, 4); QPushButton * bnClose = new QPushButton("Close", this); layout->addWidget(bnClose, rowID, 6); @@ -365,29 +342,79 @@ void Scope::StartScope(){ //TODO set other channel to be no trace; emit UpdateOtherPanels(); - for( int iDigi = (int)nDigi-1 ; iDigi >= 0; iDigi --){ + if( chkSoleRun->isChecked() ){ - traceOn[iDigi] = digi[iDigi]->IsRecordTrace(); //remember setting - SendLogMsg("Digi-" + QString::number(digi[iDigi]->GetSerialNumber()) + " is starting ACQ." ); - digi[iDigi]->WriteRegister(DPP::SoftwareClear_W, 1); - digi[iDigi]->SetBits(DPP::BoardConfiguration, DPP::Bit_BoardConfig::RecordTrace, 1, -1); + int ID = cbScopeDigi->currentIndex(); + int ch = cbScopeCh->currentIndex(); - //AggPerRead[iDigi] = digi[iDigi]->GetSettingFromMemory(DPP::MaxAggregatePerBlockTransfer); - //SendLogMsg("Set Agg/Read to 1 for scope, it was " + QString::number(AggPerRead[iDigi]) + "."); - //digi[iDigi]->WriteRegister(DPP::MaxAggregatePerBlockTransfer, 1); + //save present settings, channleMap, trigger condition + traceOn[ID] = digi[ID]->IsRecordTrace(); + digi[ID]->SetBits(DPP::BoardConfiguration, DPP::Bit_BoardConfig::RecordTrace, 1, -1); - readDataThread[iDigi]->SetScopeMode(true); - readDataThread[iDigi]->SetSaveData(false); + if( digi[ID]->GetDPPType() == DPPTypeCode::DPP_PHA_CODE ){ + dppAlg = digi[ID]->GetSettingFromMemory(DPP::DPPAlgorithmControl, ch); + dppAlg2 = digi[ID]->GetSettingFromMemory(DPP::PHA::DPPAlgorithmControl2_G, ch); + chMask = digi[ID]->GetSettingFromMemory(DPP::RegChannelEnableMask); - digi[iDigi]->StartACQ(); + digi[ID]->SetBits(DPP::DPPAlgorithmControl, DPP::Bit_DPPAlgorithmControl_PHA::TriggerMode, 0, ch); + digi[ID]->SetBits(DPP::DPPAlgorithmControl, DPP::Bit_DPPAlgorithmControl_PHA::DisableSelfTrigger, 0, ch); + + digi[ID]->SetBits(DPP::PHA::DPPAlgorithmControl2_G, DPP::PHA::Bit_DPPAlgorithmControl2::LocalShapeTriggerMode, 0, ch); + digi[ID]->SetBits(DPP::PHA::DPPAlgorithmControl2_G, DPP::PHA::Bit_DPPAlgorithmControl2::LocalTrigValidMode, 0, ch); + + } + + if( digi[ID]->GetDPPType() == DPPTypeCode::DPP_PSD_CODE ){ + dppAlg = digi[ID]->GetSettingFromMemory(DPP::DPPAlgorithmControl, ch); + dppAlg2 = digi[ID]->GetSettingFromMemory(DPP::PSD::DPPAlgorithmControl2_G, ch); + chMask = digi[ID]->GetSettingFromMemory(DPP::RegChannelEnableMask); + //TODO =============== + } + + if( digi[ID]->GetDPPType() == DPPTypeCode::DPP_QDC_CODE ){ + dppAlg = digi[ID]->GetSettingFromMemory(DPP::QDC::DPPAlgorithmControl, ch); + chMask = digi[ID]->GetSettingFromMemory(DPP::RegChannelEnableMask); + //TODO =============== + } + + digi[ID]->WriteRegister(DPP::RegChannelEnableMask, (1 << ch)); + + //=========== start + digi[ID]->WriteRegister(DPP::SoftwareClear_W, 1); + + readDataThread[ID]->SetScopeMode(true); + readDataThread[ID]->SetSaveData(false); + + digi[ID]->StartACQ(); + readDataThread[ID]->start(); + + }else{ + + for( int iDigi = (int)nDigi-1 ; iDigi >= 0; iDigi --){ + + traceOn[iDigi] = digi[iDigi]->IsRecordTrace(); //remember setting + SendLogMsg("Digi-" + QString::number(digi[iDigi]->GetSerialNumber()) + " is starting ACQ." ); + digi[iDigi]->WriteRegister(DPP::SoftwareClear_W, 1); + digi[iDigi]->SetBits(DPP::BoardConfiguration, DPP::Bit_BoardConfig::RecordTrace, 1, -1); + + //AggPerRead[iDigi] = digi[iDigi]->GetSettingFromMemory(DPP::MaxAggregatePerBlockTransfer); + //SendLogMsg("Set Agg/Read to 1 for scope, it was " + QString::number(AggPerRead[iDigi]) + "."); + //digi[iDigi]->WriteRegister(DPP::MaxAggregatePerBlockTransfer, 1); + + readDataThread[iDigi]->SetScopeMode(true); + readDataThread[iDigi]->SetSaveData(false); + + digi[iDigi]->StartACQ(); + + // printf("----- readDataThread running ? %d.\n", readDataThread[iDigi]->isRunning()); + // if( readDataThread[iDigi]->isRunning() ){ + // readDataThread[iDigi]->quit(); + // readDataThread[iDigi]->wait(); + // } + readDataThread[iDigi]->start(); + // printf("----- readDataThread running ? %d.\n", readDataThread[iDigi]->isRunning()); + } -// printf("----- readDataThread running ? %d.\n", readDataThread[iDigi]->isRunning()); - // if( readDataThread[iDigi]->isRunning() ){ - // readDataThread[iDigi]->quit(); - // readDataThread[iDigi]->wait(); - // } - readDataThread[iDigi]->start(); -// printf("----- readDataThread running ? %d.\n", readDataThread[iDigi]->isRunning()); } updateTraceThread->start(); @@ -398,6 +425,8 @@ void Scope::StartScope(){ bnScopeStop->setEnabled(true); bnScopeStop->setStyleSheet("background-color: red;"); + chkSoleRun->setEnabled(false); + EnableControl(false); TellACQOnOff(true); @@ -419,21 +448,47 @@ void Scope::StopScope(){ updateScalarThread->quit(); updateScalarThread->exit(); - for( unsigned int iDigi = 0; iDigi < nDigi; iDigi ++){ + if( chkSoleRun->isChecked() ){ - if( readDataThread[iDigi]->isRunning() ){ - readDataThread[iDigi]->Stop(); - readDataThread[iDigi]->quit(); - readDataThread[iDigi]->wait(); + int ID = cbScopeDigi->currentIndex(); + + if( readDataThread[ID]->isRunning() ){ + readDataThread[ID]->Stop(); + readDataThread[ID]->quit(); + readDataThread[ID]->wait(); + readDataThread[ID]->SetScopeMode(false); } - digiMTX[iDigi].lock(); - digi[iDigi]->StopACQ(); - digi[iDigi]->ReadACQStatus(); - //digi[iDigi]->GetData()->PrintAllData(); - digiMTX[iDigi].unlock(); - digi[iDigi]->SetBits(DPP::BoardConfiguration, DPP::Bit_BoardConfig::RecordTrace, traceOn[iDigi], -1); - //digi[iDigi]->WriteRegister(DPP::MaxAggregatePerBlockTransfer, AggPerRead[iDigi]); + digiMTX[ID].lock(); + digi[ID]->StopACQ(); + digi[ID]->ReadACQStatus(); + digiMTX[ID].unlock(); + + //restore setting + digi[ID]->SetBits(DPP::BoardConfiguration, DPP::Bit_BoardConfig::RecordTrace, traceOn[ID], -1); + //TODO ============= + + + }else{ + + for( unsigned int iDigi = 0; iDigi < nDigi; iDigi ++){ + + if( readDataThread[iDigi]->isRunning() ){ + readDataThread[iDigi]->Stop(); + readDataThread[iDigi]->quit(); + readDataThread[iDigi]->wait(); + readDataThread[iDigi]->SetScopeMode(false); + } + digiMTX[iDigi].lock(); + digi[iDigi]->StopACQ(); + digi[iDigi]->ReadACQStatus(); + //digi[iDigi]->GetData()->PrintAllData(); + digiMTX[iDigi].unlock(); + + digi[iDigi]->SetBits(DPP::BoardConfiguration, DPP::Bit_BoardConfig::RecordTrace, traceOn[iDigi], -1); + //digi[iDigi]->WriteRegister(DPP::MaxAggregatePerBlockTransfer, AggPerRead[iDigi]); + + } } @@ -444,6 +499,7 @@ void Scope::StopScope(){ bnScopeStop->setEnabled(false); bnScopeStop->setStyleSheet(""); + chkSoleRun->setEnabled(true); runStatus->setStyleSheet(""); EnableControl(true); @@ -1230,7 +1286,7 @@ void Scope::UpdatePanel_QDC(){ sbDCOffset->setValue((1.0 - haha * 1.0 / 0xFFFF) * 100 ); //UpdateSpinBox(sbReordLength, DPP::QDC::RecordLength); - sbReordLength->setValue(digi[ID]->ReadQDCRecordLength()); + sbReordLength->setValue(digi[ID]->ReadQDCRecordLength() * 8 * 16); UpdateSpinBox(sbPreTrigger, DPP::QDC::PreTrigger); UpdateSpinBox(sbShortGate, DPP::QDC::GateWidth); diff --git a/Scope.h b/Scope.h index ddf43af..0f7e0ab 100644 --- a/Scope.h +++ b/Scope.h @@ -80,9 +80,11 @@ private: bool isACQStarted; int tick2ns; int factor; // whether dual trace or not - bool traceOn[MaxNDigitizer]; int AggPerRead[MaxNDigitizer]; + bool traceOn[MaxNDigitizer]; + uint32_t dppAlg, dppAlg2, chMask; //for single channel run + ReadDataThread ** readDataThread; TimingThread * updateTraceThread; TimingThread * updateScalarThread; @@ -105,6 +107,7 @@ private: QGroupBox * settingGroup; QGridLayout * settingLayout; + QCheckBox * chkSoleRun; QPushButton * runStatus; /// common to PSD and PHA From ff5120395bdb06e64be302a42c1189ab3049fdc4 Mon Sep 17 00:00:00 2001 From: "Ryan@SOLARIS_testStation" Date: Mon, 6 May 2024 16:42:17 -0400 Subject: [PATCH 11/14] use a4818_list.txt for a4818 PID --- .gitignore | 1 + FSUDAQ.cpp | 83 ++++++++++++++++++++++++++++++++++++++++-------------- 2 files changed, 63 insertions(+), 21 deletions(-) diff --git a/.gitignore b/.gitignore index 4d359d7..7527a69 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ FSUDAQ_Qt6 test test_indep programSettings.txt +a4818_list.txt EventBuilder EventBuilderNew EventBuilder2 diff --git a/FSUDAQ.cpp b/FSUDAQ.cpp index 3c95c4a..d0d762b 100644 --- a/FSUDAQ.cpp +++ b/FSUDAQ.cpp @@ -59,7 +59,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent){ // cbOpenDigitizers->addItem("Open Digitizers (default program)", 2); // cbOpenDigitizers->addItem("Open Digitizers + load Settings", 3); //cbOpenDigitizers->addItem("Open Digitizers via USB", 3); - cbOpenDigitizers->addItem("Open Digitizers via A4818", 4); + cbOpenDigitizers->addItem("Open Digitizers via A4818(s)", 4); layout->addWidget(cbOpenDigitizers, 0, 0); connect(cbOpenDigitizers, &RComboBox::currentIndexChanged, this, &MainWindow::OpenDigitizers); @@ -353,7 +353,6 @@ void MainWindow::OpenDataPath(){ LoadLastRunFile(); - } void MainWindow::OpenRecord(){ @@ -575,16 +574,38 @@ void MainWindow::OpenDigitizers(){ // return; // } - QString a4818PID = "26006"; + QStringList a4818PIDs; if( cbOpenDigitizers->currentData().toInt() == 4 ) { - bool ok; - a4818PID = QInputDialog::getText(nullptr, "A4818 PID", "Can be found on the A4818:", QLineEdit::Normal, "", &ok); + QString a4818Path = QDir::current().absolutePath() + "/a4818_list.txt"; + LogMsg("Looking " + a4818Path + ""); - if ( !ok || a4818PID.isEmpty()) { - LogMsg("User cancel or fail to connect A4818 without PID"); + QFile file(a4818Path); + + if( !file.open(QIODevice::Text | QIODevice::ReadOnly) ) { + LogMsg("" + a4818Path + " not found."); + LogMsg("Please create such file and put the a4818 PIDs inseperate lines."); + return; + }else{ + QTextStream in(&file); + QString line = in.readLine(); + + while( !line.isNull()){ + a4818PIDs.push_back(line); + line = in.readLine(); + } + } + + if( a4818PIDs.isEmpty()){ + LogMsg("" + a4818Path + " is empty."); cbOpenDigitizers->setCurrentIndex(0); return; + }else{ + + if( a4818PIDs.size() > 4){ + LogMsg("There are more than 4 a4818, please edit the MaxNPorts in macro.h and recompile."); + } + } } @@ -597,20 +618,40 @@ void MainWindow::OpenDigitizers(){ logMsgHTMLMode = false; nDigi = 0; std::vector> portList; //boardID, portID - for(int port = 0; port < MaxNPorts; port++){ - if( cbOpenDigitizers->currentData().toInt() == 4 ) port = a4818PID.toInt(); - for( int board = 0; board < MaxNBoards; board ++){ /// max number of diasy chain - Digitizer dig; - dig.OpenDigitizer(board, port); - if( dig.IsConnected() ){ - nDigi++; - portList.push_back(std::pair(board, port)); - LogMsg(QString("... Found at port: %1, board: %2. SN: %3 %4").arg(port).arg(board).arg(dig.GetSerialNumber(), 3, 10, QChar(' ')).arg(dig.GetDPPString().c_str())); - }//else{ - //LogMsg(QString("... Nothing at port: %1, board: %2.").arg(port).arg(board)); - //} - dig.CloseDigitizer(); - QCoreApplication::processEvents(); //to prevent Qt said application not responding. + + if( cbOpenDigitizers->currentData().toInt() == 4 ) { //for A4818 + + for( int i = 0; i < std::min((int)a4818PIDs.size(), MaxNPorts); i++){ + int port = a4818PIDs.at(i).toInt(); + + for( int board = 0; board < MaxNBoards; board ++){ /// max number of diasy chain + Digitizer dig; + dig.OpenDigitizer(board, port); + if( dig.IsConnected() ){ + nDigi++; + portList.push_back(std::pair(board, port)); + LogMsg(QString("... Found at port: %1, board: %2. SN: %3 %4").arg(port).arg(board).arg(dig.GetSerialNumber(), 3, 10, QChar(' ')).arg(dig.GetDPPString().c_str())); + } + dig.CloseDigitizer(); + QCoreApplication::processEvents(); //to prevent Qt said application not responding. + } + } + + }else{ // optical fiber + + for(int port = 0; port < MaxNPorts; port++){ + + for( int board = 0; board < MaxNBoards; board ++){ /// max number of diasy chain + Digitizer dig; + dig.OpenDigitizer(board, port); + if( dig.IsConnected() ){ + nDigi++; + portList.push_back(std::pair(board, port)); + LogMsg(QString("... Found at port: %1, board: %2. SN: %3 %4").arg(port).arg(board).arg(dig.GetSerialNumber(), 3, 10, QChar(' ')).arg(dig.GetDPPString().c_str())); + } + dig.CloseDigitizer(); + QCoreApplication::processEvents(); //to prevent Qt said application not responding. + } } } logMsgHTMLMode = true; From ab61ee1bb0171b03f418785022f2b117c47b3f1e Mon Sep 17 00:00:00 2001 From: "Ryan@SOLARIS_testStation" Date: Mon, 6 May 2024 18:22:10 -0400 Subject: [PATCH 12/14] when EventAgg = 0, set to 30 --- ClassDigitizer.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ClassDigitizer.cpp b/ClassDigitizer.cpp index 0e14e3d..7b0bc6b 100644 --- a/ClassDigitizer.cpp +++ b/ClassDigitizer.cpp @@ -1339,6 +1339,7 @@ void Digitizer::SetOptimialAggOrg(){ } uint32_t EventAgg = ReadRegister(DPP::QDC::NumberEventsPerAggregate, 0); + if( EventAgg == 0 ) WriteRegister(DPP::QDC::NumberEventsPerAggregate, 30); uint32_t chMask = ReadRegister(DPP::QDC::GroupEnableMask); uint32_t RecordLen = ReadRegister(DPP::QDC::RecordLength_R, 0); if( RecordLen == 0 ) SetBits(DPP::BoardConfiguration, DPP::Bit_BoardConfig::RecordTrace, 0, -1); @@ -1362,6 +1363,7 @@ void Digitizer::SetOptimialAggOrg(){ int eventSize = 6 + 2 * Ex + traceOn * RecordLen * 8; // sample + printf(" estimated event size : %d sample \n", eventSize); double maxAggOrg = log2( MemorySizekSample * 1024 / eventSize / EventAgg ); printf(" max Agg. Org. should be less than %.2f\n", maxAggOrg); uint32_t aggOrg = std::floor(maxAggOrg) ; From b79fd72fe7b622f65211493a844890ffd60960c5 Mon Sep 17 00:00:00 2001 From: "Ryan@SOLARIS_testStation" Date: Fri, 17 May 2024 16:41:44 -0400 Subject: [PATCH 13/14] kind of complete single channel scope for PHA --- ClassDigitizer.cpp | 6 +++--- Scope.cpp | 19 ++++++++++++++++++- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/ClassDigitizer.cpp b/ClassDigitizer.cpp index 7b0bc6b..828a57c 100644 --- a/ClassDigitizer.cpp +++ b/ClassDigitizer.cpp @@ -113,9 +113,9 @@ int Digitizer::OpenDigitizer(int boardID, int portID, bool program, bool verbose } if( ret == 0 ){ - if( LinkType == CAEN_DGTZ_USB ) printf("Open digitizer via USB, board : %d\n", boardID); - if( LinkType == CAEN_DGTZ_OpticalLink ) printf("Open digitizer via Optical Link, port : %d, board : %d\n", portID, boardID); - if( LinkType == CAEN_DGTZ_USB_A4818 ) printf("Open digitizer via A4818, port : %d, board : %d\n", portID, boardID); + if( LinkType == CAEN_DGTZ_USB ) printf("### Open digitizer via USB, board : %d\n", boardID); + if( LinkType == CAEN_DGTZ_OpticalLink ) printf("### Open digitizer via Optical Link, port : %d, board : %d\n", portID, boardID); + if( LinkType == CAEN_DGTZ_USB_A4818 ) printf("### Open digitizer via A4818, port : %d, board : %d\n", portID, boardID); } if (ret != 0) { diff --git a/Scope.cpp b/Scope.cpp index d8c7071..3e228ab 100644 --- a/Scope.cpp +++ b/Scope.cpp @@ -466,7 +466,24 @@ void Scope::StopScope(){ //restore setting digi[ID]->SetBits(DPP::BoardConfiguration, DPP::Bit_BoardConfig::RecordTrace, traceOn[ID], -1); - //TODO ============= + int ch = cbScopeCh->currentIndex(); + + if( digi[ID]->GetDPPType() == DPPTypeCode::DPP_PHA_CODE ){ + digi[ID]->WriteRegister(DPP::DPPAlgorithmControl, dppAlg, ch); + digi[ID]->WriteRegister(DPP::PHA::DPPAlgorithmControl2_G, dppAlg2, ch); + digi[ID]->WriteRegister(DPP::RegChannelEnableMask, chMask); + } + + if( digi[ID]->GetDPPType() == DPPTypeCode::DPP_PSD_CODE ){ + digi[ID]->WriteRegister(DPP::DPPAlgorithmControl, dppAlg, ch); + digi[ID]->WriteRegister(DPP::PSD::DPPAlgorithmControl2_G, dppAlg2, ch); + digi[ID]->WriteRegister(DPP::RegChannelEnableMask, chMask); + } + + if( digi[ID]->GetDPPType() == DPPTypeCode::DPP_QDC_CODE ){ + digi[ID]->WriteRegister(DPP::QDC::DPPAlgorithmControl, dppAlg, ch); + digi[ID]->WriteRegister(DPP::RegChannelEnableMask, chMask); + } }else{ From 7ad3ed4af08ed6b6c0550777dab56e0870a16a3b Mon Sep 17 00:00:00 2001 From: "Ryan@SOLARIS_testStation" Date: Fri, 17 May 2024 17:45:30 -0400 Subject: [PATCH 14/14] bugs fix on scope --- ClassDigitizer.cpp | 68 +++++++++++++++++++++---------------------- DigiSettingsPanel.cpp | 6 ++-- FSUDAQ.cpp | 6 +++- Scope.cpp | 34 ++++++++++++---------- Scope.h | 1 + 5 files changed, 61 insertions(+), 54 deletions(-) diff --git a/ClassDigitizer.cpp b/ClassDigitizer.cpp index 828a57c..8d10f82 100644 --- a/ClassDigitizer.cpp +++ b/ClassDigitizer.cpp @@ -1258,40 +1258,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 %d | %d, Communication Error.\n", header.c_str(), BoardInfo.SerialNumber, ret); break; - case CAEN_DGTZ_GenericError : /** -2 */ printf("%s %d | %d, Unspecified error.\n", header.c_str(), BoardInfo.SerialNumber, ret); break; - case CAEN_DGTZ_InvalidParam : /** -3 */ printf("%s %d | %d, Invalid parameter.\n", header.c_str(), BoardInfo.SerialNumber, ret); break; - case CAEN_DGTZ_InvalidLinkType : /** -4 */ printf("%s %d | %d, Invalid Link Type.\n", header.c_str(), BoardInfo.SerialNumber, ret); break; - case CAEN_DGTZ_InvalidHandle : /** -5 */ printf("%s %d | %d, Invalid device handler.\n", header.c_str(), BoardInfo.SerialNumber, ret); break; - case CAEN_DGTZ_MaxDevicesError : /** -6 */ printf("%s %d | %d, Maximum number of devices exceeded.\n", header.c_str(), BoardInfo.SerialNumber, ret); break; - case CAEN_DGTZ_BadBoardType : /** -7 */ printf("%s %d | %d, Operation not allowed on this type of board.\n", header.c_str(), BoardInfo.SerialNumber, ret); break; - case CAEN_DGTZ_BadInterruptLev : /** -8 */ printf("%s %d | %d, The interrupt level is not allowed.\n", header.c_str(), BoardInfo.SerialNumber, ret); break; - case CAEN_DGTZ_BadEventNumber : /** -9 */ printf("%s %d | %d, The event number is bad.\n", header.c_str(), BoardInfo.SerialNumber, ret); break; - case CAEN_DGTZ_ReadDeviceRegisterFail : /** -10 */ printf("%s %d | %d, Unable to read the registry.\n", header.c_str(), BoardInfo.SerialNumber, ret); break; - case CAEN_DGTZ_WriteDeviceRegisterFail : /** -11 */ printf("%s %d | %d, Unable to write the registry.\n", header.c_str(), BoardInfo.SerialNumber, ret); break; - case CAEN_DGTZ_InvalidChannelNumber : /** -13 */ printf("%s %d | %d, The channel number is invalid.\n", header.c_str(), BoardInfo.SerialNumber, ret); break; - case CAEN_DGTZ_ChannelBusy : /** -14 */ printf("%s %d | %d, The channel is busy.\n", header.c_str(), BoardInfo.SerialNumber, ret); break; - case CAEN_DGTZ_FPIOModeInvalid : /** -15 */ printf("%s %d | %d, Invalid FPIO mode.\n", header.c_str(), BoardInfo.SerialNumber, ret); break; - case CAEN_DGTZ_WrongAcqMode : /** -16 */ printf("%s %d | %d, Wrong Acquistion mode.\n", header.c_str(), BoardInfo.SerialNumber, ret); break; - case CAEN_DGTZ_FunctionNotAllowed : /** -17 */ printf("%s %d | %d, This function is not allowed on this module.\n", header.c_str(), BoardInfo.SerialNumber, ret); break; - case CAEN_DGTZ_Timeout : /** -18 */ printf("%s %d | %d, Communication Timeout.\n", header.c_str(), BoardInfo.SerialNumber, ret); break; - case CAEN_DGTZ_InvalidBuffer : /** -19 */ printf("%s %d | %d, The buffer is invalid.\n", header.c_str(), BoardInfo.SerialNumber, ret); break; - case CAEN_DGTZ_EventNotFound : /** -20 */ printf("%s %d | %d, The event is not found.\n", header.c_str(), BoardInfo.SerialNumber, ret); break; - case CAEN_DGTZ_InvalidEvent : /** -21 */ printf("%s %d | %d, The event is invalid.\n", header.c_str(), BoardInfo.SerialNumber, ret); break; - case CAEN_DGTZ_OutOfMemory : /** -22 */ printf("%s %d | %d, Out of memory.\n", header.c_str(), BoardInfo.SerialNumber, ret); break; - case CAEN_DGTZ_CalibrationError : /** -23 */ printf("%s %d | %d, Unable to calibrate the board.\n", header.c_str(), BoardInfo.SerialNumber, ret); break; - case CAEN_DGTZ_DigitizerNotFound : /** -24 */ printf("%s %d | %d, Unbale to open the digitizer.\n", header.c_str(), BoardInfo.SerialNumber, ret); break; - case CAEN_DGTZ_DigitizerAlreadyOpen : /** -25 */ printf("%s %d | %d, The digitizer is already open.\n", header.c_str(), BoardInfo.SerialNumber, ret); break; - case CAEN_DGTZ_DigitizerNotReady : /** -26 */ printf("%s %d | %d, The digitizer is not ready.\n", header.c_str(), BoardInfo.SerialNumber, ret); break; - case CAEN_DGTZ_InterruptNotConfigured : /** -27 */ printf("%s %d | %d, The digitizer has no IRQ configured.\n", header.c_str(), BoardInfo.SerialNumber, ret); break; - case CAEN_DGTZ_DigitizerMemoryCorrupted: /** -28 */ printf("%s %d | %d, The digitizer flash memory is corrupted.\n", header.c_str(), BoardInfo.SerialNumber, ret); break; - case CAEN_DGTZ_DPPFirmwareNotSupported : /** -29 */ printf("%s %d | %d, The digitier DPP firmware is not supported in this lib version.\n", header.c_str(), BoardInfo.SerialNumber, ret); break; - case CAEN_DGTZ_InvalidLicense : /** -30 */ printf("%s %d | %d, Invalid firmware licence.\n", header.c_str(), BoardInfo.SerialNumber, ret); break; - case CAEN_DGTZ_InvalidDigitizerStatus : /** -31 */ printf("%s %d | %d, The digitizer is found in a corrupted status.\n", header.c_str(), BoardInfo.SerialNumber, ret); break; - case CAEN_DGTZ_UnsupportedTrace : /** -32 */ printf("%s %d | %d, The given trace is not supported.\n", header.c_str(), BoardInfo.SerialNumber, ret); break; - case CAEN_DGTZ_InvalidProbe : /** -33 */ printf("%s %d | %d, The given probe is not supported.\n", header.c_str(), BoardInfo.SerialNumber, ret); break; - case CAEN_DGTZ_UnsupportedBaseAddress : /** -34 */ printf("%s %d | %d, The base address is not supported.\n", header.c_str(), BoardInfo.SerialNumber, ret); break; - case CAEN_DGTZ_NotYetImplemented : /** -99 */ printf("%s %d | %d, The function is not yet implemented.\n", header.c_str(), BoardInfo.SerialNumber, ret); break; + case CAEN_DGTZ_CommError : /** -1 */ printf("%s digi-%d | %d, Communication Error.\n", header.c_str(), BoardInfo.SerialNumber, ret); break; + case CAEN_DGTZ_GenericError : /** -2 */ printf("%s digi-%d | %d, Unspecified error.\n", header.c_str(), BoardInfo.SerialNumber, ret); break; + case CAEN_DGTZ_InvalidParam : /** -3 */ printf("%s digi-%d | %d, Invalid parameter.\n", header.c_str(), BoardInfo.SerialNumber, ret); break; + case CAEN_DGTZ_InvalidLinkType : /** -4 */ printf("%s digi-%d | %d, Invalid Link Type.\n", header.c_str(), BoardInfo.SerialNumber, ret); break; + case CAEN_DGTZ_InvalidHandle : /** -5 */ printf("%s digi-%d | %d, Invalid device handler.\n", header.c_str(), BoardInfo.SerialNumber, ret); break; + case CAEN_DGTZ_MaxDevicesError : /** -6 */ printf("%s digi-%d | %d, Maximum number of devices exceeded.\n", header.c_str(), BoardInfo.SerialNumber, ret); break; + case CAEN_DGTZ_BadBoardType : /** -7 */ printf("%s digi-%d | %d, Operation not allowed on this type of board.\n", header.c_str(), BoardInfo.SerialNumber, ret); break; + case CAEN_DGTZ_BadInterruptLev : /** -8 */ printf("%s digi-%d | %d, The interrupt level is not allowed.\n", header.c_str(), BoardInfo.SerialNumber, ret); break; + case CAEN_DGTZ_BadEventNumber : /** -9 */ printf("%s digi-%d | %d, The event number is bad.\n", header.c_str(), BoardInfo.SerialNumber, ret); break; + case CAEN_DGTZ_ReadDeviceRegisterFail : /** -10 */ printf("%s digi-%d | %d, Unable to read the registry.\n", header.c_str(), BoardInfo.SerialNumber, ret); break; + case CAEN_DGTZ_WriteDeviceRegisterFail : /** -11 */ printf("%s digi-%d | %d, Unable to write the registry.\n", header.c_str(), BoardInfo.SerialNumber, ret); break; + case CAEN_DGTZ_InvalidChannelNumber : /** -13 */ printf("%s digi-%d | %d, The channel number is invalid.\n", header.c_str(), BoardInfo.SerialNumber, ret); break; + case CAEN_DGTZ_ChannelBusy : /** -14 */ printf("%s digi-%d | %d, The channel is busy.\n", header.c_str(), BoardInfo.SerialNumber, ret); break; + case CAEN_DGTZ_FPIOModeInvalid : /** -15 */ printf("%s digi-%d | %d, Invalid FPIO mode.\n", header.c_str(), BoardInfo.SerialNumber, ret); break; + case CAEN_DGTZ_WrongAcqMode : /** -16 */ printf("%s digi-%d | %d, Wrong Acquistion mode.\n", header.c_str(), BoardInfo.SerialNumber, ret); break; + case CAEN_DGTZ_FunctionNotAllowed : /** -17 */ printf("%s digi-%d | %d, This function is not allowed on this module.\n", header.c_str(), BoardInfo.SerialNumber, ret); break; + case CAEN_DGTZ_Timeout : /** -18 */ printf("%s digi-%d | %d, Communication Timeout.\n", header.c_str(), BoardInfo.SerialNumber, ret); break; + case CAEN_DGTZ_InvalidBuffer : /** -19 */ printf("%s digi-%d | %d, The buffer is invalid.\n", header.c_str(), BoardInfo.SerialNumber, ret); break; + case CAEN_DGTZ_EventNotFound : /** -20 */ printf("%s digi-%d | %d, The event is not found.\n", header.c_str(), BoardInfo.SerialNumber, ret); break; + case CAEN_DGTZ_InvalidEvent : /** -21 */ printf("%s digi-%d | %d, The event is invalid.\n", header.c_str(), BoardInfo.SerialNumber, ret); break; + case CAEN_DGTZ_OutOfMemory : /** -22 */ printf("%s digi-%d | %d, Out of memory.\n", header.c_str(), BoardInfo.SerialNumber, ret); break; + case CAEN_DGTZ_CalibrationError : /** -23 */ printf("%s digi-%d | %d, Unable to calibrate the board.\n", header.c_str(), BoardInfo.SerialNumber, ret); break; + case CAEN_DGTZ_DigitizerNotFound : /** -24 */ printf("%s digi-%d | %d, Unbale to open the digitizer.\n", header.c_str(), BoardInfo.SerialNumber, ret); break; + case CAEN_DGTZ_DigitizerAlreadyOpen : /** -25 */ printf("%s digi-%d | %d, The digitizer is already open.\n", header.c_str(), BoardInfo.SerialNumber, ret); break; + case CAEN_DGTZ_DigitizerNotReady : /** -26 */ printf("%s digi-%d | %d, The digitizer is not ready.\n", header.c_str(), BoardInfo.SerialNumber, ret); break; + case CAEN_DGTZ_InterruptNotConfigured : /** -27 */ printf("%s digi-%d | %d, The digitizer has no IRQ configured.\n", header.c_str(), BoardInfo.SerialNumber, ret); break; + case CAEN_DGTZ_DigitizerMemoryCorrupted: /** -28 */ printf("%s digi-%d | %d, The digitizer flash memory is corrupted.\n", header.c_str(), BoardInfo.SerialNumber, ret); break; + case CAEN_DGTZ_DPPFirmwareNotSupported : /** -29 */ printf("%s digi-%d | %d, The digitier DPP firmware is not supported in this lib version.\n", header.c_str(), BoardInfo.SerialNumber, ret); break; + case CAEN_DGTZ_InvalidLicense : /** -30 */ printf("%s digi-%d | %d, Invalid firmware licence.\n", header.c_str(), BoardInfo.SerialNumber, ret); break; + case CAEN_DGTZ_InvalidDigitizerStatus : /** -31 */ printf("%s digi-%d | %d, The digitizer is found in a corrupted status.\n", header.c_str(), BoardInfo.SerialNumber, ret); break; + case CAEN_DGTZ_UnsupportedTrace : /** -32 */ printf("%s digi-%d | %d, The given trace is not supported.\n", header.c_str(), BoardInfo.SerialNumber, ret); break; + case CAEN_DGTZ_InvalidProbe : /** -33 */ printf("%s digi-%d | %d, The given probe is not supported.\n", header.c_str(), BoardInfo.SerialNumber, ret); break; + case CAEN_DGTZ_UnsupportedBaseAddress : /** -34 */ printf("%s digi-%d | %d, The base address is not supported.\n", header.c_str(), BoardInfo.SerialNumber, ret); break; + case CAEN_DGTZ_NotYetImplemented : /** -99 */ printf("%s digi-%d | %d, The function is not yet implemented.\n", header.c_str(), BoardInfo.SerialNumber, ret); break; } } diff --git a/DigiSettingsPanel.cpp b/DigiSettingsPanel.cpp index 70061ed..f0f63b0 100644 --- a/DigiSettingsPanel.cpp +++ b/DigiSettingsPanel.cpp @@ -2317,7 +2317,7 @@ void DigiSettingsPanel::SetUpChannel_PSD(){ SetUpSpinBox(sbThreshold[ID][ch], "", tabLayout, ch + 1, 2, DPP::PSD::TriggerThreshold, ch); SetUpComboBoxBit(cbTrigMode[ID][ch], "", tabLayout, ch + 1, 4, DPP::Bit_DPPAlgorithmControl_PHA::ListTrigMode, DPP::DPPAlgorithmControl, DPP::Bit_DPPAlgorithmControl_PHA::TriggerMode, 1, ch); SetUpSpinBox(sbTriggerHoldOff[ID][ch], "", tabLayout, ch + 1, 6, DPP::PSD::TriggerHoldOffWidth, ch); - SetUpComboBoxBit(cbLocalTriggerValid[ID][ch], "", tabLayout, ch + 1, 8, DPP::PSD::Bit_DPPAlgorithmControl2::ListLocalTrigValidMode, DPP::PHA::DPPAlgorithmControl2_G, DPP::PHA::Bit_DPPAlgorithmControl2::LocalTrigValidMode, 1, ch); + SetUpComboBoxBit(cbLocalTriggerValid[ID][ch], "", tabLayout, ch + 1, 8, DPP::PSD::Bit_DPPAlgorithmControl2::ListLocalTrigValidMode, DPP::PSD::DPPAlgorithmControl2_G, DPP::PSD::Bit_DPPAlgorithmControl2::LocalTrigValidMode, 1, ch); } if( i == 1 ){ @@ -2327,8 +2327,8 @@ void DigiSettingsPanel::SetUpChannel_PSD(){ QLabel * lb1 = new QLabel("Trig. Counter Flag [G]", this); lb1->setAlignment(Qt::AlignHCenter); tabLayout->addWidget(lb1, 0, 6); } SetUpSpinBox(sbShapedTrigWidth[ID][ch], "", tabLayout, ch + 1, 1, DPP::PSD::ShapedTriggerWidth, ch); - SetUpComboBoxBit(cbLocalShapedTrigger[ID][ch], "", tabLayout, ch + 1, 3, DPP::PSD::Bit_DPPAlgorithmControl2::ListLocalShapeTrigMode, DPP::PHA::DPPAlgorithmControl2_G, DPP::PHA::Bit_DPPAlgorithmControl2::LocalShapeTriggerMode, 1, ch); - SetUpComboBoxBit(cbTrigCount[ID][ch], "", tabLayout, ch + 1, 5, DPP::PSD::Bit_DPPAlgorithmControl2::ListTrigCounter, DPP::PHA::DPPAlgorithmControl2_G, DPP::PHA::Bit_DPPAlgorithmControl2::TriggerCounterFlag, 1, ch); + SetUpComboBoxBit(cbLocalShapedTrigger[ID][ch], "", tabLayout, ch + 1, 3, DPP::PSD::Bit_DPPAlgorithmControl2::ListLocalShapeTrigMode, DPP::PSD::DPPAlgorithmControl2_G, DPP::PSD::Bit_DPPAlgorithmControl2::LocalShapeTriggerMode, 1, ch); + SetUpComboBoxBit(cbTrigCount[ID][ch], "", tabLayout, ch + 1, 5, DPP::PSD::Bit_DPPAlgorithmControl2::ListTrigCounter, DPP::PSD::DPPAlgorithmControl2_G, DPP::PSD::Bit_DPPAlgorithmControl2::TriggerCounterFlag, 1, ch); } if( i == 2 ){ diff --git a/FSUDAQ.cpp b/FSUDAQ.cpp index d0d762b..feb768b 100644 --- a/FSUDAQ.cpp +++ b/FSUDAQ.cpp @@ -291,6 +291,10 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent){ CheckElog(); + + LogMsg("====== FSU DAQ is ready. ======"); + + } MainWindow::~MainWindow(){ @@ -731,7 +735,7 @@ void MainWindow::OpenDigitizers(){ canvas->FillHistograms(); }); - LogMsg(QString("Done. Opened %1 digitizer(s).").arg(nDigi)); + LogMsg("====== " + QString("Done. Opened %1 digitizer(s).").arg(nDigi) + " ====="); WaitForDigitizersOpen(false); bnStartACQ->setStyleSheet("background-color: green;"); diff --git a/Scope.cpp b/Scope.cpp index 3e228ab..49e4fe0 100644 --- a/Scope.cpp +++ b/Scope.cpp @@ -346,15 +346,17 @@ void Scope::StartScope(){ int ID = cbScopeDigi->currentIndex(); int ch = cbScopeCh->currentIndex(); + oldDigi = ID; + oldCh = ch; //save present settings, channleMap, trigger condition traceOn[ID] = digi[ID]->IsRecordTrace(); digi[ID]->SetBits(DPP::BoardConfiguration, DPP::Bit_BoardConfig::RecordTrace, 1, -1); + chMask = digi[ID]->GetSettingFromMemory(DPP::RegChannelEnableMask); if( digi[ID]->GetDPPType() == DPPTypeCode::DPP_PHA_CODE ){ dppAlg = digi[ID]->GetSettingFromMemory(DPP::DPPAlgorithmControl, ch); dppAlg2 = digi[ID]->GetSettingFromMemory(DPP::PHA::DPPAlgorithmControl2_G, ch); - chMask = digi[ID]->GetSettingFromMemory(DPP::RegChannelEnableMask); digi[ID]->SetBits(DPP::DPPAlgorithmControl, DPP::Bit_DPPAlgorithmControl_PHA::TriggerMode, 0, ch); digi[ID]->SetBits(DPP::DPPAlgorithmControl, DPP::Bit_DPPAlgorithmControl_PHA::DisableSelfTrigger, 0, ch); @@ -367,14 +369,17 @@ void Scope::StartScope(){ if( digi[ID]->GetDPPType() == DPPTypeCode::DPP_PSD_CODE ){ dppAlg = digi[ID]->GetSettingFromMemory(DPP::DPPAlgorithmControl, ch); dppAlg2 = digi[ID]->GetSettingFromMemory(DPP::PSD::DPPAlgorithmControl2_G, ch); - chMask = digi[ID]->GetSettingFromMemory(DPP::RegChannelEnableMask); - //TODO =============== + + digi[ID]->SetBits(DPP::DPPAlgorithmControl, DPP::Bit_DPPAlgorithmControl_PHA::TriggerMode, 0, ch); + digi[ID]->SetBits(DPP::DPPAlgorithmControl, DPP::Bit_DPPAlgorithmControl_PHA::DisableSelfTrigger, 0, ch); + + digi[ID]->SetBits(DPP::PSD::DPPAlgorithmControl2_G, DPP::PSD::Bit_DPPAlgorithmControl2::LocalShapeTriggerMode, 0, ch); + digi[ID]->SetBits(DPP::PSD::DPPAlgorithmControl2_G, DPP::PSD::Bit_DPPAlgorithmControl2::LocalTrigValidMode, 0, ch); } if( digi[ID]->GetDPPType() == DPPTypeCode::DPP_QDC_CODE ){ dppAlg = digi[ID]->GetSettingFromMemory(DPP::QDC::DPPAlgorithmControl, ch); - chMask = digi[ID]->GetSettingFromMemory(DPP::RegChannelEnableMask); - //TODO =============== + digi[ID]->SetBits(DPP::QDC::DPPAlgorithmControl, DPP::QDC::Bit_DPPAlgorithmControl::TriggerMode, 0, ch); //set self-triiger } digi[ID]->WriteRegister(DPP::RegChannelEnableMask, (1 << ch)); @@ -450,7 +455,8 @@ void Scope::StopScope(){ if( chkSoleRun->isChecked() ){ - int ID = cbScopeDigi->currentIndex(); + //int ID = cbScopeDigi->currentIndex(); + int ID = oldDigi; if( readDataThread[ID]->isRunning() ){ readDataThread[ID]->Stop(); @@ -466,26 +472,22 @@ void Scope::StopScope(){ //restore setting digi[ID]->SetBits(DPP::BoardConfiguration, DPP::Bit_BoardConfig::RecordTrace, traceOn[ID], -1); - int ch = cbScopeCh->currentIndex(); + digi[ID]->WriteRegister(DPP::RegChannelEnableMask, chMask); if( digi[ID]->GetDPPType() == DPPTypeCode::DPP_PHA_CODE ){ - digi[ID]->WriteRegister(DPP::DPPAlgorithmControl, dppAlg, ch); - digi[ID]->WriteRegister(DPP::PHA::DPPAlgorithmControl2_G, dppAlg2, ch); - digi[ID]->WriteRegister(DPP::RegChannelEnableMask, chMask); + digi[ID]->WriteRegister(DPP::DPPAlgorithmControl, dppAlg, oldCh); + digi[ID]->WriteRegister(DPP::PHA::DPPAlgorithmControl2_G, dppAlg2, oldCh); } if( digi[ID]->GetDPPType() == DPPTypeCode::DPP_PSD_CODE ){ - digi[ID]->WriteRegister(DPP::DPPAlgorithmControl, dppAlg, ch); - digi[ID]->WriteRegister(DPP::PSD::DPPAlgorithmControl2_G, dppAlg2, ch); - digi[ID]->WriteRegister(DPP::RegChannelEnableMask, chMask); + digi[ID]->WriteRegister(DPP::DPPAlgorithmControl, dppAlg, oldCh); + digi[ID]->WriteRegister(DPP::PSD::DPPAlgorithmControl2_G, dppAlg2, oldCh); } if( digi[ID]->GetDPPType() == DPPTypeCode::DPP_QDC_CODE ){ - digi[ID]->WriteRegister(DPP::QDC::DPPAlgorithmControl, dppAlg, ch); - digi[ID]->WriteRegister(DPP::RegChannelEnableMask, chMask); + digi[ID]->WriteRegister(DPP::QDC::DPPAlgorithmControl, dppAlg, oldCh); } - }else{ for( unsigned int iDigi = 0; iDigi < nDigi; iDigi ++){ diff --git a/Scope.h b/Scope.h index 0f7e0ab..2f2c769 100644 --- a/Scope.h +++ b/Scope.h @@ -84,6 +84,7 @@ private: bool traceOn[MaxNDigitizer]; uint32_t dppAlg, dppAlg2, chMask; //for single channel run + unsigned short oldCh, oldDigi; ReadDataThread ** readDataThread; TimingThread * updateTraceThread;