From 6a55ceb8843ff55f8c7bcb0b50d022ac4aa14107 Mon Sep 17 00:00:00 2001 From: "Ryan@WorkStation" Date: Fri, 22 Mar 2024 12:43:17 -0400 Subject: [PATCH] added maxFillTimeMilliSec for filling single spectra --- FSUDAQ.cpp | 2 +- SingleSpectra.cpp | 9 +++++++++ SingleSpectra.h | 5 +++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/FSUDAQ.cpp b/FSUDAQ.cpp index 3eb2d39..d58aacd 100644 --- a/FSUDAQ.cpp +++ b/FSUDAQ.cpp @@ -683,7 +683,7 @@ void MainWindow::OpenDigitizers(){ canvas = new SingleSpectra(digi, nDigi, rawDataPath); histThread = new TimingThread(this); - histThread->SetWaitTimeinSec(0.5); + histThread->SetWaitTimeinSec(canvas->GetMaxFillTime()/1000.); connect(histThread, &TimingThread::timeUp, this, [=](){ if( canvas == nullptr && !canvas->IsFillHistograms()) return; canvas->FillHistograms(); diff --git a/SingleSpectra.cpp b/SingleSpectra.cpp index fa62d8d..111edab 100644 --- a/SingleSpectra.cpp +++ b/SingleSpectra.cpp @@ -13,6 +13,8 @@ SingleSpectra::SingleSpectra(Digitizer ** digi, unsigned int nDigi, QString rawD this->nDigi = nDigi; this->rawDataPath = rawDataPath; + maxFillTimeinMilliSec = 500; + isSignalSlotActive = true; setWindowTitle("1-D Histograms"); @@ -201,9 +203,13 @@ void SingleSpectra::ChangeHistView(){ void SingleSpectra::FillHistograms(){ if( !fillHistograms ) return; + unsigned short maxFillTimePerDigi = maxFillTimeinMilliSec/nDigi; + timespec t0, t1; + for( int i = 0; i < nDigi; i++){ digiMTX[i].lock(); + clock_gettime(CLOCK_REALTIME, &t0); for( int ch = 0; ch < digi[i]->GetNumInputCh(); ch ++ ){ int lastIndex = digi[i]->GetData()->GetDataIndex(ch); if( lastIndex < 0 ) continue; @@ -233,6 +239,9 @@ void SingleSpectra::FillHistograms(){ } if( histVisibility[i][ch] ) hist[i][ch]->UpdatePlot(); if( hist2DVisibility[i] ) hist2D[i]->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(); diff --git a/SingleSpectra.h b/SingleSpectra.h index 36d1ebb..a91794e 100644 --- a/SingleSpectra.h +++ b/SingleSpectra.h @@ -35,6 +35,9 @@ public: void LoadSetting(); void SaveSetting(); + void SetMaxFillTime(unsigned short milliSec) { maxFillTimeinMilliSec = milliSec;} + unsigned short GetMaxFillTime() const {return maxFillTimeinMilliSec;}; + public slots: void FillHistograms(); void ChangeHistView(); @@ -66,6 +69,8 @@ private: QString rawDataPath; + unsigned short maxFillTimeinMilliSec; + bool isSignalSlotActive; };