From b9b60f7c18a16685d4ec7fbc41bc3905146f06f0 Mon Sep 17 00:00:00 2001 From: "carina@hades" Date: Thu, 19 Oct 2023 15:32:44 -0400 Subject: [PATCH] added Run Status in Scalar --- FSUDAQ.cpp | 46 ++++++++++++++++++++++++++++++++++++++-------- FSUDAQ.h | 1 + Scope.cpp | 37 +++++++++++++++++++++++++++++-------- Scope.h | 2 ++ influxdb.cpp | 2 +- 5 files changed, 71 insertions(+), 17 deletions(-) diff --git a/FSUDAQ.cpp b/FSUDAQ.cpp index 50b3c5f..035abe0 100644 --- a/FSUDAQ.cpp +++ b/FSUDAQ.cpp @@ -243,7 +243,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent){ } needManualComment = true; StopACQ(); - }); + }); layout->addWidget(lbPrefix, rowID, 0); layout->addWidget(lePrefix, rowID, 1); @@ -826,13 +826,13 @@ void MainWindow::SetupScalar(){ lbScalarACQStatus = new QLabel("ACQ status", scalar); } - lbLastUpdateTime->setAlignment(Qt::AlignCenter); + lbLastUpdateTime->setAlignment(Qt::AlignRight); scalarLayout->removeWidget(lbLastUpdateTime); - scalarLayout->addWidget(lbLastUpdateTime, 0, 1, 1, 1 + nDigi); + scalarLayout->addWidget(lbLastUpdateTime, 0, 0, 1, 1 + nDigi); lbScalarACQStatus->setAlignment(Qt::AlignCenter); scalarLayout->removeWidget(lbScalarACQStatus); - scalarLayout->addWidget(lbScalarACQStatus, 1, 1, 1, 1 + nDigi); + scalarLayout->addWidget(lbScalarACQStatus, 0, 1 + nDigi); int rowID = 3; ///==== create the header row @@ -861,9 +861,20 @@ void MainWindow::SetupScalar(){ 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); + QLabel * lbDigi = new QLabel("Digi-" + QString::number(digi[iDigi]->GetSerialNumber()), scalar); - lbDigi->setAlignment(Qt::AlignCenter); - scalarLayout->addWidget(lbDigi, rowID, 2*iDigi+1, 1, 2); + 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 ++; @@ -948,6 +959,13 @@ void MainWindow::UpdateScalar(){ for( unsigned int iDigi = 0; iDigi < nDigi; iDigi++){ digiMTX[iDigi].lock(); + uint32_t acqStatus = digi[iDigi]->ReadRegister(DPP::AcquisitionStatus_R); + if( ( acqStatus >> 2 ) & 0x1 ){ + runStatus[iDigi]->setStyleSheet("background-color : green;"); + }else{ + runStatus[iDigi]->setStyleSheet(""); + } + // printf("### %d ", iDigi); // digi[iDigi]->GetData()->PrintAllData(true, 10); if( chkSaveData->isChecked() ) totalFileSize += digi[iDigi]->GetData()->GetTotalFileSize(); @@ -976,6 +994,7 @@ void MainWindow::UpdateScalar(){ influx->AddDataPoint("RunID value=" + std::to_string(runID)); influx->AddDataPoint("FileSize value=" + std::to_string(totalFileSize)); } + //influx->PrintDataPoints(); influx->WriteData(dataBaseName.toStdString()); influx->ClearDataPointsBuffer(); } @@ -1047,7 +1066,7 @@ if( chkSaveData->isChecked() ) SaveLastRunFile(); {//^=== elog and database if( influx ){ influx->AddDataPoint("RunID value=" + std::to_string(runID)); - influx->AddDataPoint("SavingData,ExpName=" + elogName.toStdString() + " value=1"); + if( elogName != "" ) influx->AddDataPoint("SavingData,ExpName=" + elogName.toStdString() + " value=1"); influx->WriteData(dataBaseName.toStdString()); influx->ClearDataPointsBuffer(); } @@ -1112,10 +1131,21 @@ void MainWindow::StopACQ(){ bnOpenScope->setEnabled(true); cbAutoRun->setEnabled(true); + if( scalar ){ + for( unsigned int iDigi = 0; iDigi < nDigi; iDigi ++){ + uint32_t acqStatus = digi[iDigi]->ReadRegister(DPP::AcquisitionStatus_R); + if( ( acqStatus >> 2 ) & 0x1 ){ + runStatus[iDigi]->setStyleSheet("background-color : green;"); + }else{ + runStatus[iDigi]->setStyleSheet(""); + } + } + } + if( digiSettings ) digiSettings->setEnabled(true); {//^=== elog and database - if( influx ){ + if( influx && elogName != "" ) { influx->AddDataPoint("SavingData,ExpName=" + elogName.toStdString() + " value=0"); influx->WriteData(dataBaseName.toStdString()); influx->ClearDataPointsBuffer(); diff --git a/FSUDAQ.h b/FSUDAQ.h index a156b41..2688d40 100644 --- a/FSUDAQ.h +++ b/FSUDAQ.h @@ -150,6 +150,7 @@ private: TimingThread * scalarThread; QLineEdit *** leTrigger; // need to delete manually QLineEdit *** leAccept; // need to delete manually + QPushButton * runStatus[MaxNDigitizer]; QLabel * lbLastUpdateTime; QLabel * lbScalarACQStatus; diff --git a/Scope.cpp b/Scope.cpp index fa118e2..bbf96e1 100644 --- a/Scope.cpp +++ b/Scope.cpp @@ -138,12 +138,20 @@ Scope::Scope(Digitizer ** digi, unsigned int nDigi, ReadDataThread ** readDataTh layout->addWidget(bnClearBuffer, rowID, 4); connect(bnClearBuffer, &QPushButton::clicked, this, [=](){ digi[ID]->WriteRegister(DPP::SoftwareClear_W, 1);}); + QLabel * lbRun = new QLabel("Run Status : ", this); + lbRun->setAlignment(Qt::AlignCenter | Qt::AlignRight); + layout->addWidget(lbRun, rowID, 5); + + runStatus = new QPushButton("", this); + runStatus->setEnabled(false); + runStatus->setFixedSize(QSize(20,20)); + layout->addWidget(runStatus, rowID, 6); //================ Trace settings rowID ++; { settingGroup = new QGroupBox("Trace Settings",this); - layout->addWidget(settingGroup, rowID, 0, 1, 6); + layout->addWidget(settingGroup, rowID, 0, 1, 7); settingLayout = new QGridLayout(settingGroup); settingLayout->setSpacing(0); @@ -156,7 +164,7 @@ Scope::Scope(Digitizer ** digi, unsigned int nDigi, ReadDataThread ** readDataTh //================ Plot view rowID ++; plotView = new RChartView(plot, this); - layout->addWidget(plotView, rowID, 0, 1, 6); + layout->addWidget(plotView, rowID, 0, 1, 7); //================ Key binding @@ -166,7 +174,7 @@ Scope::Scope(Digitizer ** digi, unsigned int nDigi, ReadDataThread ** readDataTh QLabel * lbinfo = new QLabel("Trace updates every " + QString::number(updateTraceThread->GetWaitTimeinSec()) + " sec.", this); lbinfo->setAlignment(Qt::AlignRight); - layout->addWidget(lbinfo, rowID, 5); + layout->addWidget(lbinfo, rowID, 6); rowID ++; //TODO =========== Trace step @@ -193,7 +201,7 @@ Scope::Scope(Digitizer ** digi, unsigned int nDigi, ReadDataThread ** readDataTh layout->addWidget(leTriggerRate, rowID, 3); QPushButton * bnClose = new QPushButton("Close", this); - layout->addWidget(bnClose, rowID, 5); + layout->addWidget(bnClose, rowID, 6); connect(bnClose, &QPushButton::clicked, this, &Scope::close); layout->setColumnStretch(0, 1); @@ -362,8 +370,16 @@ void Scope::UpdateScope(){ if( digi[ID]->GetInputChannelOnOff(ch) == false) return; //printf("### %d %d \n", ch, digi[ID]->GetData()->DataIndex[ch]); - + digiMTX[ID].lock(); + + uint32_t acqStatus = digi[ID]->ReadRegister(DPP::AcquisitionStatus_R); + if( ( acqStatus >> 2 ) & 0x1 ){ + runStatus->setStyleSheet("background-color : green;"); + }else{ + runStatus->setStyleSheet(""); + } + Data * data = digi[ID]->GetData(); //leTriggerRate->setText(QString::number(data->TriggerRate[ch]) + " [" + QString::number(data->NumEventsDecoded[ch]) + "]"); @@ -549,7 +565,7 @@ void Scope::SetUpSpinBox(RSpinBox * &sb, QString str, int row, int col, const Re if( digi[ID]->GetDPPType() == DPPType::DPP_QDC_CODE ){ int grp = ch/8; // convert ch to grp digiMTX[ID].lock(); - digi[ID]->WriteRegister(para, value, grp); + digi[ID]->WriteRegister(para, value, grp); digiMTX[ID].unlock(); }else{ digiMTX[ID].lock(); @@ -764,7 +780,8 @@ void Scope::SetUpPanel_QDC() { printf("==== %s \n", __func__); int rowID = 0; - SetUpSpinBox(sbReordLength, "Record Length [ns] ", rowID, 0, DPP::QDC::RecordLength); + + SetUpSpinBox(sbReordLength, "Record Length [ns] ", rowID, 0, DPP::QDC::RecordLength_W); SetUpSpinBox(sbPreTrigger, "Pre Trigger [ns] ", rowID, 2, DPP::QDC::PreTrigger); SetUpSpinBox(sbDCOffset, "DC offset [%] ", rowID, 4, DPP::QDC::DCOffset); sbDCOffset->setDecimals(2); @@ -774,7 +791,7 @@ void Scope::SetUpPanel_QDC() { cbPolarity->addItem("Negative", 1); connect(cbPolarity, &RComboBox::currentIndexChanged, this, [=](){ if( !enableSignalSlot ) return; - digi[ID]->SetBits(DPP::QDC::DPPAlgorithmControl, DPP::QDC::Bit_DPPAlgorithmControl::Polarity, cbPolarity->currentData().toInt(), cbScopeCh->currentIndex()); + digi[ID]->SetBits(DPP::QDC::DPPAlgorithmControl, DPP::QDC::Bit_DPPAlgorithmControl::Polarity, cbPolarity->currentData().toInt(), cbScopeCh->currentIndex()/8); }); rowID ++; //============================================================= @@ -887,6 +904,10 @@ void Scope::EnableControl(bool enable){ cbPeakAvg->setEnabled(enable); sbPeakHoldOff->setEnabled(enable); + }else{ + + settingGroup->setEnabled(enable); + } } diff --git a/Scope.h b/Scope.h index 36a4324..8ce561a 100644 --- a/Scope.h +++ b/Scope.h @@ -101,6 +101,8 @@ private: QGroupBox * settingGroup; QGridLayout * settingLayout; + QPushButton * runStatus; + /// common to PSD and PHA RSpinBox * sbReordLength; RSpinBox * sbPreTrigger; diff --git a/influxdb.cpp b/influxdb.cpp index 7a22f42..f440532 100644 --- a/influxdb.cpp +++ b/influxdb.cpp @@ -144,7 +144,7 @@ void InfluxDB::Execute(){ respond = curl_easy_perform(curl); curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &respondCode); //printf("==== respond %d (OK = %d)\n", respond, CURLE_OK); - if( respond != CURLE_OK) printf("############# InfluxDB::Execute fail\n"); + if( respond != CURLE_OK) printf("############# InfluxDB::Execute fail | %ld\n", respondCode); } catch (std::exception& e){ // in case of unexpected error printf("%s\n", e.what()); respond = CURLE_SEND_ERROR;