[Major] True parallel thread for filling histogram
This commit is contained in:
parent
0d379fec92
commit
b8011bc834
|
@ -1018,6 +1018,8 @@ void FSUDAQ::UpdateScalar(){
|
||||||
|
|
||||||
DebugPrint("%s", "FSUDAQ");
|
DebugPrint("%s", "FSUDAQ");
|
||||||
|
|
||||||
|
// qDebug() << __func__ << "| thread:" << QThread::currentThreadId();
|
||||||
|
|
||||||
// printf("================== FSUDAQ::%s\n", __func__);
|
// printf("================== FSUDAQ::%s\n", __func__);
|
||||||
|
|
||||||
if( digi == nullptr ) return;
|
if( digi == nullptr ) return;
|
||||||
|
|
|
@ -78,7 +78,7 @@ void MultiBuilder::PrintStat(){
|
||||||
printf("Total number of evet built : %ld\n", totalEventBuilt);
|
printf("Total number of evet built : %ld\n", totalEventBuilt);
|
||||||
for( int i = 0; i < nData ; i++){
|
for( int i = 0; i < nData ; i++){
|
||||||
for( int ch = 0; ch < data[i]->GetNChannel() ; ch++){
|
for( int ch = 0; ch < data[i]->GetNChannel() ; ch++){
|
||||||
if( nextIndex[i][ch] >= 0 ) printf("%d %3d %2d | %7ld (%d)\n", i, snList[i], ch, nextIndex[i][ch]);
|
if( nextIndex[i][ch] >= 0 ) printf("%d %3d %2d | %7ld\n", i, snList[i], ch, nextIndex[i][ch]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -277,7 +277,7 @@ void MultiBuilder::BuildEvents(bool isFinal, bool skipTrace, bool verbose){
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
printf("%05d, %02d | %5d | %5d %llu \n", sn, chxxx, nextIndex[bd][chxxx], events[eventIndex][i].energy, events[eventIndex][i].timestamp);
|
printf("%05d, %02d | %7ld | %5d %llu \n", sn, chxxx, nextIndex[bd][chxxx], events[eventIndex][i].energy, events[eventIndex][i].timestamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
if( nExhaushedCh == numTotCh ) {
|
if( nExhaushedCh == numTotCh ) {
|
||||||
|
@ -456,7 +456,7 @@ void MultiBuilder::BuildEventsBackWard(int maxNumEvent, bool verbose){
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
printf("%5d, %02d | %5d | %5d %llu \n", sn, chxxx, nextIndex[bd][chxxx], events[eventIndex][i].energy, events[eventIndex][i].timestamp);
|
printf("%5d, %02d | %7ld | %5d %llu \n", sn, chxxx, nextIndex[bd][chxxx], events[eventIndex][i].energy, events[eventIndex][i].timestamp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -153,18 +153,19 @@ SingleSpectra::SingleSpectra(Digitizer ** digi, unsigned int nDigi, QString rawD
|
||||||
timer = new QTimer(this);
|
timer = new QTimer(this);
|
||||||
|
|
||||||
histWorker->moveToThread(workerThread);
|
histWorker->moveToThread(workerThread);
|
||||||
|
timer->moveToThread(workerThread);
|
||||||
|
|
||||||
workerThread->start();
|
isFillingHistograms = false;
|
||||||
|
|
||||||
// connect(timer, &QTimer::timeout, histWorker, &HistWorker::FillHistograms);
|
// connect(timer, &QTimer::timeout, histWorker, &HistWorker::FillHistograms);
|
||||||
connect( histWorker, &HistWorker::workDone, this, &SingleSpectra::ReplotHistograms);
|
connect( histWorker, &HistWorker::workDone, this, &SingleSpectra::ReplotHistograms);
|
||||||
|
|
||||||
connect(timer, &QTimer::timeout, this, [=](){
|
connect(timer, &QTimer::timeout, histWorker, &HistWorker::FillHistograms);
|
||||||
if( isFillingHistograms == false){
|
|
||||||
histWorker->FillHistograms();
|
connect(this, &SingleSpectra::startWorkerTimer, timer, static_cast<void(QTimer::*)(int)>(&QTimer::start));
|
||||||
// ReplotHistograms();
|
connect(this, &SingleSpectra::stopWorkerTimer, timer, &QTimer::stop);
|
||||||
}
|
|
||||||
});
|
|
||||||
|
workerThread->start();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -249,6 +250,8 @@ void SingleSpectra::FillHistograms(){
|
||||||
timespec ta, tb;
|
timespec ta, tb;
|
||||||
|
|
||||||
printf("####################### SingleSpectra::%s\n", __func__);
|
printf("####################### SingleSpectra::%s\n", __func__);
|
||||||
|
// qDebug() << __func__ << "| thread:" << QThread::currentThreadId();
|
||||||
|
|
||||||
clock_gettime(CLOCK_REALTIME, &ta);
|
clock_gettime(CLOCK_REALTIME, &ta);
|
||||||
|
|
||||||
std::vector<int> digiChList; // (digi*1000 + ch)
|
std::vector<int> digiChList; // (digi*1000 + ch)
|
||||||
|
@ -315,7 +318,7 @@ void SingleSpectra::FillHistograms(){
|
||||||
}
|
}
|
||||||
hist2D[ID]->Fill(ch, data);
|
hist2D[ID]->Fill(ch, data);
|
||||||
|
|
||||||
QCoreApplication::processEvents();
|
// QCoreApplication::processEvents();
|
||||||
|
|
||||||
clock_gettime(CLOCK_REALTIME, &tb);
|
clock_gettime(CLOCK_REALTIME, &tb);
|
||||||
}while( isFillingHistograms && (tb.tv_nsec - ta.tv_nsec)/1e6 + (tb.tv_sec - ta.tv_sec)*1e3 < maxFillTimeinMilliSec );
|
}while( isFillingHistograms && (tb.tv_nsec - ta.tv_nsec)/1e6 + (tb.tv_sec - ta.tv_sec)*1e3 < maxFillTimeinMilliSec );
|
||||||
|
@ -334,6 +337,8 @@ void SingleSpectra::FillHistograms(){
|
||||||
|
|
||||||
void SingleSpectra::ReplotHistograms(){
|
void SingleSpectra::ReplotHistograms(){
|
||||||
|
|
||||||
|
// qDebug() << __func__ << "| thread:" << QThread::currentThreadId();
|
||||||
|
|
||||||
int ID = cbDigi->currentData().toInt();
|
int ID = cbDigi->currentData().toInt();
|
||||||
int ch = cbCh->currentData().toInt();
|
int ch = cbCh->currentData().toInt();
|
||||||
|
|
||||||
|
|
|
@ -45,16 +45,22 @@ public:
|
||||||
|
|
||||||
void ReplotHistograms();
|
void ReplotHistograms();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void startWorkerTimer(int interval);
|
||||||
|
void stopWorkerTimer();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void FillHistograms();
|
void FillHistograms();
|
||||||
void ChangeHistView();
|
void ChangeHistView();
|
||||||
void startTimer(){
|
void startTimer(){
|
||||||
// printf("timer start\n");
|
// printf("timer start\n");
|
||||||
timer->start(maxFillTimeinMilliSec);
|
// timer->start(maxFillTimeinMilliSec);
|
||||||
|
emit startWorkerTimer(maxFillTimeinMilliSec);
|
||||||
}
|
}
|
||||||
void stopTimer(){
|
void stopTimer(){
|
||||||
// printf("timer stop\n");
|
// printf("timer stop\n");
|
||||||
timer->stop();
|
// timer->stop();
|
||||||
|
emit stopWorkerTimer();
|
||||||
isFillingHistograms = false; // this will also break the FillHistogram do-loop
|
isFillingHistograms = false; // this will also break the FillHistogram do-loop
|
||||||
ClearInternalDataCount();
|
ClearInternalDataCount();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user