From 04a877fc51f3b99ab3003232ad0870663e24bfad Mon Sep 17 00:00:00 2001 From: "Ryan@WorkStation" Date: Mon, 8 Apr 2024 20:41:57 -0400 Subject: [PATCH] comment out some useless codes --- CustomThreads.h | 33 +++++++++++++++++---------------- mainwindow.cpp | 32 +++++++++++++++++++------------- mainwindow.h | 1 + 3 files changed, 37 insertions(+), 29 deletions(-) diff --git a/CustomThreads.h b/CustomThreads.h index 3aea96e..ae45a40 100644 --- a/CustomThreads.h +++ b/CustomThreads.h @@ -19,15 +19,15 @@ public: this->ID = digiID; isSaveData = false; stop = false; - canSendMsg = true; + // canSendMsg = true; } - void SuppressFileSizeMsg() {canSendMsg = false;} + // void SuppressFileSizeMsg() {canSendMsg = false;} void Stop(){ this->stop = true;} void SetSaveData(bool onOff) {this->isSaveData = onOff;} void run(){ - canSendMsg = true; + // canSendMsg = true; stop = false; - clock_gettime(CLOCK_REALTIME, &ta); + // clock_gettime(CLOCK_REALTIME, &ta); emit sendMsg("Digi-" + QString::number(digi->GetSerialNumber()) + " ReadDataThread started."); while(!stop){ @@ -45,17 +45,17 @@ public: //digi->ErrorMsg("ReadDataLoop()"); digi->hit->ClearTrace(); } - - if( isSaveData && canSendMsg ){ - clock_gettime(CLOCK_REALTIME, &tb); - if( tb.tv_sec - ta.tv_sec > 2 ) { - emit sendMsg("FileSize ("+ QString::number(digi->GetSerialNumber()) +"): " + QString::number(digi->GetTotalFilesSize()/1024./1024.) + " MB"); - //emit checkFileSize(); - //double duration = tb.tv_nsec-ta.tv_nsec + tb.tv_sec*1e+9 - ta.tv_sec*1e+9; - //printf("%4d, duration : %10.0f, %6.1f\n", readCount, duration, 1e9/duration); - ta = tb; - } - } +// + // if( isSaveData && canSendMsg ){ + // clock_gettime(CLOCK_REALTIME, &tb); + // if( tb.tv_sec - ta.tv_sec > 2 ) { + // emit sendMsg("FileSize ("+ QString::number(digi->GetSerialNumber()) +"): " + QString::number(digi->GetTotalFilesSize()/1024./1024.) + " MB"); + // //emit checkFileSize(); + // //double duration = tb.tv_nsec-ta.tv_nsec + tb.tv_sec*1e+9 - ta.tv_sec*1e+9; + // //printf("%4d, duration : %10.0f, %6.1f\n", readCount, duration, 1e9/duration); + // ta = tb; + // } + // } } emit sendMsg("Digi-" + QString::number(digi->GetSerialNumber()) + " ReadDataThread stopped."); @@ -69,7 +69,8 @@ private: Digitizer2Gen * digi; int ID; timespec ta, tb; - bool isSaveData, stop, canSendMsg; + // bool isSaveData, stop, canSendMsg; + bool isSaveData, stop; }; //^#======================================================= Timing Thread, for some action need to be done periodically diff --git a/mainwindow.cpp b/mainwindow.cpp index fcfe2d1..92742e5 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -65,6 +65,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent){ leTrigger = nullptr; leAccept = nullptr; + lbFileSize = nullptr; scalarThread = new TimingThread(); connect(scalarThread, &TimingThread::TimeUp, this, &MainWindow::UpdateScalar); @@ -549,9 +550,11 @@ void MainWindow::StopACQ(){ //=============== Stop digitizer for( int i = nDigi - 1; i >= 0; i--){ if( digi[i]->IsDummy () ) continue; + digiMTX[i].lock(); digi[i]->StopACQ(); - readDataThread[i]->SuppressFileSizeMsg(); + // readDataThread[i]->SuppressFileSizeMsg(); digi[i]->WriteValue(PHA::CH::WaveSaving, "OnRequest", -1); + digiMTX[i].unlock(); } isACQRunning = false; lbScalarACQStatus->setText("ACQ Off"); @@ -587,10 +590,10 @@ void MainWindow::StopACQ(){ influx->WriteData(DatabaseName.toStdString()); } - if( !chkSaveRun->isChecked() ) LogMsg("Collecting remaining data from the digitizers... "); + if( chkSaveRun->isChecked() ) LogMsg("Collecting remaining data from the digitizers... "); for( int i = nDigi -1; i >=0; i--){ if( readDataThread[i]->isRunning()){ - if( !chkSaveRun->isChecked() ) readDataThread[i]->Stop(); + if( !chkSaveRun->isChecked() ) readDataThread[i]->Stop(); // if it is a save run, don't force stop the readDataThread, wait for it. readDataThread[i]->quit(); readDataThread[i]->wait(); } @@ -1160,7 +1163,7 @@ void MainWindow::SetUpScalar(){ // connect(bnUpdateScaler, &QPushButton::clicked, this, &MainWindow::UpdateScalar); ///==== create the 1st row - int rowID = 4; + int rowID = 5; for( int ch = 0; ch < MaxNumberOfChannel; ch++){ if( ch == 0 ){ @@ -1177,8 +1180,11 @@ void MainWindow::SetUpScalar(){ ///===== create the trigger and accept leTrigger = new QLineEdit**[nDigi]; leAccept = new QLineEdit**[nDigi]; + lbFileSize = new QLabel *[nDigi]; for( int iDigi = 0; iDigi < nDigi; iDigi++){ rowID = 3; + lbFileSize[iDigi] = new QLabel("file Size", scalar); + lbFileSize[iDigi]->setAlignment(Qt::AlignCenter); leTrigger[iDigi] = new QLineEdit *[digi[iDigi]->GetNChannels()]; leAccept[iDigi] = new QLineEdit *[digi[iDigi]->GetNChannels()]; for( int ch = 0; ch < MaxNumberOfChannel; ch++){ @@ -1187,7 +1193,9 @@ void MainWindow::SetUpScalar(){ QLabel * lbDigi = new QLabel("Digi-" + QString::number(digi[iDigi]->GetSerialNumber()), scalar); lbDigi->setAlignment(Qt::AlignCenter); scalarLayout->addWidget(lbDigi, rowID, 2*iDigi+1, 1, 2); + rowID ++; + scalarLayout->addWidget(lbFileSize[iDigi], rowID, 2*iDigi+1, 1, 2); rowID ++; QLabel * lbA = new QLabel("Input [Hz]", scalar); @@ -1225,10 +1233,14 @@ void MainWindow::CleanUpScalar(){ delete leTrigger[i][ch]; delete leAccept[i][ch]; } + delete lbFileSize[i]; delete [] leTrigger[i]; delete [] leAccept[i]; } + delete [] lbFileSize; delete [] leTrigger; + delete [] leAccept; + lbFileSize = nullptr; leTrigger = nullptr; leAccept = nullptr; @@ -1251,14 +1263,6 @@ void MainWindow::UpdateScalar(){ unsigned long totalFileSize = 0; for( int iDigi = 0; iDigi < nDigi; iDigi ++ ){ if( digi[iDigi]->IsDummy() ) return; - - //=========== use ReadStat to get the trigger rate - //digiMTX.lock(); - //digi[iDigi]->ReadStat(); // digitizer update it every 500 msec; - //digiMTX.unlock(); - //for( int ch = 0; ch < digi[iDigi]->GetNChannels(); ch ++){ - // leTrigger[iDigi][ch]->setText(QString::number(digi[iDigi]->GetTriggerCount(ch)*1e9*1.0/ digi[iDigi]->GetRealTime(ch))); - //} //=========== another method, directly readValue for( int ch = 0; ch < digi[iDigi]->GetNChannels(); ch ++){ @@ -1272,7 +1276,6 @@ void MainWindow::UpdateScalar(){ unsigned long time = std::stoul(timeStr.c_str()) ; leTrigger[iDigi][ch]->setText(QString::fromStdString(haha[ch])); - if( oldTimeStamp[iDigi][ch] > 0 && time - oldTimeStamp[iDigi][ch] > 1e9 && kaka > oldSavedCount[iDigi][ch]){ acceptRate[ch] = (kaka - oldSavedCount[iDigi][ch]) * 1e9 *1.0 / (time - oldTimeStamp[iDigi][ch]); }else{ @@ -1284,6 +1287,9 @@ void MainWindow::UpdateScalar(){ oldTimeStamp[iDigi][ch] = time; //if( kaka != "0" ) printf("%s, %s | %.2f\n", time.c_str(), kaka.c_str(), acceptRate); leAccept[iDigi][ch]->setText(QString::number(acceptRate[ch],'f', 1)); + + lbFileSize[iDigi]->setText(QString::number(digi[iDigi]->GetTotalFilesSize()/1024./1024.) + " MB"); + } ///============== push the trigger, acceptRate rate database diff --git a/mainwindow.h b/mainwindow.h index 0b4d748..1a49296 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -122,6 +122,7 @@ private: QGridLayout * scalarLayout; TimingThread * scalarThread; QPushButton * bnOpenScalar; + QLabel ** lbFileSize;// need to delete manually QLineEdit *** leTrigger; // need to delete manually QLineEdit *** leAccept; // need to delete manually QLabel * lbLastUpdateTime;