diff --git a/.vscode/settings.json b/.vscode/settings.json index 37544d7..15a1c4b 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -156,6 +156,7 @@ "qrandomgenerator": "cpp", "source_location": "cpp", "splitpole.C": "cpp", - "forward_list": "cpp" + "forward_list": "cpp", + "fstream": "cpp" } } \ No newline at end of file diff --git a/FSUDAQ.cpp b/FSUDAQ.cpp index 3068dd3..93ec271 100644 --- a/FSUDAQ.cpp +++ b/FSUDAQ.cpp @@ -894,13 +894,18 @@ void MainWindow::UpdateScalar(){ // digi[iDigi]->GetData()->PrintAllData(true, 10); if( chkSaveData->isChecked() ) totalFileSize += digi[iDigi]->GetData()->GetTotalFileSize(); for( int i = 0; i < digi[iDigi]->GetNChannels(); i++){ + QString a = ""; + QString b = ""; + if( digi[iDigi]->GetChannelOnOff(i) == true ) { //printf(" %3d %2d | %7.2f %7.2f \n", digi[iDigi]->GetSerialNumber(), i, digi[iDigi]->GetData()->TriggerRate[i], digi[iDigi]->GetData()->NonPileUpRate[i]); - leTrigger[iDigi][i]->setText(QString::number(digi[iDigi]->GetData()->TriggerRate[i], 'f', 2)); - leAccept[iDigi][i]->setText(QString::number(digi[iDigi]->GetData()->NonPileUpRate[i], 'f', 2)); + QString a = QString::number(digi[iDigi]->GetData()->TriggerRate[i], 'f', 2); + QString b = QString::number(digi[iDigi]->GetData()->NonPileUpRate[i], 'f', 2); + leTrigger[iDigi][i]->setText(a); + leAccept[iDigi][i]->setText(b); - if( influx ){ - influx->AddDataPoint("Rate,Bd="+std::to_string(digi[iDigi]->GetSerialNumber()) + ",Ch=" + QString::number(i).rightJustified(2, '0').toStdString() + " value=" + QString::number(digi[iDigi]->GetData()->TriggerRate[i], 'f', 2).toStdString()); + 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()); } } } @@ -979,7 +984,7 @@ void MainWindow::StartACQ(){ if( onlineAnalyzer ) onlineAnalyzer->StartThread(); {//^=== elog and database - if( influx ){ + if( influx && chkSaveData->isChecked() ){ influx->AddDataPoint("RunID value=" + std::to_string(runID)); influx->AddDataPoint("SavingData,ExpName=" + elogName.toStdString() + " value=1"); influx->WriteData(dataBaseName.toStdString()); @@ -1033,10 +1038,11 @@ void MainWindow::StopACQ(){ if( onlineAnalyzer ) onlineAnalyzer->StopThread(); - if( histThread->isRunning()){ + if( canvas && histThread->isRunning()){ histThread->Stop(); histThread->quit(); histThread->wait(); + canvas->ClearInternalDataCount(); } lbScalarACQStatus->setText("ACQ Off"); @@ -1049,7 +1055,7 @@ void MainWindow::StopACQ(){ cbAutoRun->setEnabled(true); {//^=== elog and database - if( influx ){ + if( influx && chkSaveData->isChecked() ){ influx->AddDataPoint("SavingData,ExpName=" + elogName.toStdString() + " value=0"); influx->WriteData(dataBaseName.toStdString()); influx->ClearDataPointsBuffer(); @@ -1356,6 +1362,7 @@ void MainWindow::OpenScope(){ histThread->Stop(); histThread->quit(); histThread->wait(); + canvas->ClearInternalDataCount(); } } } diff --git a/Histogram1D.h b/Histogram1D.h index da2cd6e..f33e88c 100644 --- a/Histogram1D.h +++ b/Histogram1D.h @@ -210,6 +210,9 @@ public: txt[0]->setText("Under Flow : 0"); txt[1]->setText("Total Entry : 0"); txt[2]->setText("Over Flow : 0"); + totalEntry = 0; + underFlow = 0; + overFlow = 0; UpdatePlot(); } diff --git a/README.md b/README.md index 5d5b010..6daa7fe 100644 --- a/README.md +++ b/README.md @@ -96,4 +96,8 @@ The following files must be excluded from the *.pro, as they are not related to Those file can be compiled using -`make -f Makefile_test` \ No newline at end of file +`make -f Makefile_test` + +# Known Bugs + +* for PHA firmware, when the peak average changed, trace disapear and causing program lag. diff --git a/SingleSpectra.cpp b/SingleSpectra.cpp index deffa13..b40a98a 100644 --- a/SingleSpectra.cpp +++ b/SingleSpectra.cpp @@ -44,6 +44,8 @@ SingleSpectra::SingleSpectra(Digitizer ** digi, unsigned int nDigi, QString rawD for( unsigned int i = 0; i < nDigi; i++){ for( int j = 0; j < MaxNChannels; j++){ if( hist[i][j] ) hist[i][j]->Clear(); + lastFilledIndex[i][j] = -1; + loopFilledIndex[i][j] = 0; } } }); @@ -85,13 +87,8 @@ SingleSpectra::SingleSpectra(Digitizer ** digi, unsigned int nDigi, QString rawD layout->setStretch(0, 1); layout->setStretch(1, 6); + ClearInternalDataCount(); - for( unsigned int i = 0; i < nDigi; i++){ - for( int ch = 0; ch < MaxNChannels ; ch++) { - lastFilledIndex[i][ch] = -1; - loopFilledIndex[i][ch] = 0; - } - } oldBd = -1; oldCh = -1; @@ -108,6 +105,15 @@ SingleSpectra::~SingleSpectra(){ } } +void SingleSpectra::ClearInternalDataCount(){ + for( unsigned int i = 0; i < nDigi; i++){ + for( int ch = 0; ch < MaxNChannels ; ch++) { + lastFilledIndex[i][ch] = -1; + loopFilledIndex[i][ch] = 0; + } + } +} + void SingleSpectra::ChangeHistView(){ if( oldCh >= 0 ) { @@ -136,7 +142,7 @@ void SingleSpectra::FillHistograms(){ int temp1 = lastIndex + loopIndex*MaxNData; int temp2 = lastFilledIndex[i][ch] + loopFilledIndex[i][ch]*MaxNData; - //printf("%d |%d %d \n", ch, temp2, temp1); + // printf("%d |%d %d \n", ch, temp2, temp1); if( lastIndex < 0 ) continue; if( temp1 <= temp2 ) continue; diff --git a/SingleSpectra.h b/SingleSpectra.h index 02b3e86..95fec55 100644 --- a/SingleSpectra.h +++ b/SingleSpectra.h @@ -27,6 +27,7 @@ public: SingleSpectra(Digitizer ** digi, unsigned int nDigi, QString rawDataPath, QMainWindow * parent = nullptr); ~SingleSpectra(); + void ClearInternalDataCount(); void SetFillHistograms(bool onOff) { fillHistograms = onOff;} bool IsFillHistograms() const {return fillHistograms;} diff --git a/influxdb.cpp b/influxdb.cpp index afb8747..7a22f42 100644 --- a/influxdb.cpp +++ b/influxdb.cpp @@ -152,6 +152,6 @@ void InfluxDB::Execute(){ } size_t InfluxDB::WriteCallBack(char *contents, size_t size, size_t nmemb, void *userp){ - ((std::string*)userp)->append((char*)contents, size * nmemb); - return size * nmemb; + ((std::string*)userp)->append((char*)contents, size * nmemb); + return size * nmemb; }