remove scope Qtimer for scalar, use the Scope::TellACQOnOff to start/stop work for scalar, singleHostogram, and onlineAnalyzer

This commit is contained in:
Ryan Tang 2024-08-29 17:15:36 -04:00
parent c2265f3cc6
commit 11ae70db18
3 changed files with 28 additions and 29 deletions

View File

@ -1714,39 +1714,46 @@ void FSUDAQ::OpenScope(){
if( scope == nullptr ) { if( scope == nullptr ) {
scope = new Scope(digi, nDigi, readDataThread); scope = new Scope(digi, nDigi, readDataThread);
connect(scope, &Scope::SendLogMsg, this, &FSUDAQ::LogMsg); connect(scope, &Scope::SendLogMsg, this, &FSUDAQ::LogMsg);
connect(scope, &Scope::CloseWindow, this, [=](){ connect(scope, &Scope::CloseWindow, this, [=](){
bnStartACQ->setEnabled(true); bnStartACQ->setEnabled(true);
bnStartACQ->setStyleSheet("background-color: green;"); bnStartACQ->setStyleSheet("background-color: green;");
bnStopACQ->setEnabled(false); bnStopACQ->setEnabled(false);
bnStopACQ->setStyleSheet(""); bnStopACQ->setStyleSheet("");
}); });
connect(scope, &Scope::TellACQOnOff, this, [=](bool onOff){ connect(scope, &Scope::TellACQOnOff, this, [=](bool onOff){
if( scope ) {
if( onOff ) { isACQStarted = onOff;
lbScalarACQStatus->setText("<font style=\"color: green;\"><b>ACQ On</b></font>");
if( onOff ){
if( influx && chkInflux->isChecked() && !elogName.isEmpty()) influx->AddDataPoint("SavingData,ExpName=" + elogName.toStdString() + " value=1"); if( influx && chkInflux->isChecked() && !elogName.isEmpty()) influx->AddDataPoint("SavingData,ExpName=" + elogName.toStdString() + " value=1");
}else{
lbScalarACQStatus->setText("<font style=\"color: red;\"><b>ACQ Off</b></font>"); if( scalar ){
if( influx && chkInflux->isChecked() && !elogName.isEmpty()) influx->AddDataPoint("SavingData,ExpName=" + elogName.toStdString() + " value=0"); lbScalarACQStatus->setText("<font style=\"color: green;\"><b>ACQ On</b></font>");
} scalarTimer->start(ScalarUpdateinMiliSec);
if( influx && chkInflux->isChecked()){
influx->WriteData(dataBaseName.toStdString());
influx->ClearDataPointsBuffer();
}
} }
if( digiSettings ) digiSettings->setEnabled(!onOff); if( singleHistograms ) singleHistograms->startWork();
if( singleHistograms ) { if( onlineAnalyzer ) onlineAnalyzer->startWork();
if( onOff ) {
singleHistograms->startWork();
}else{ }else{
singleHistograms->stopWork(); if( influx && chkInflux->isChecked() && !elogName.isEmpty()) influx->AddDataPoint("SavingData,ExpName=" + elogName.toStdString() + " value=0");
if( scalar ){
lbScalarACQStatus->setText("<font style=\"color: red;\"><b>ACQ Off</b></font>");
scalarTimer->stop();
} }
if( singleHistograms ) singleHistograms->stopWork();
if( onlineAnalyzer ) onlineAnalyzer->stopWork();
} }
if( digiSettings ) digiSettings->EnableButtons(!onOff);
}); });
if( scalar ) connect(scope, &Scope::UpdateScaler, scalarWorker, &ScalarWorker::UpdateScalar);
connect(scope, &Scope::UpdateOtherPanels, this, [=](){ UpdateAllPanels(1); }); connect(scope, &Scope::UpdateOtherPanels, this, [=](){ UpdateAllPanels(1); });
scope->show(); scope->show();

View File

@ -289,9 +289,6 @@ Scope::Scope(Digitizer ** digi, unsigned int nDigi, ReadDataThread ** readDataTh
}); });
workerThread->start(); workerThread->start();
scalarTimer = new QTimer(this);
connect(scalarTimer, &QTimer::timeout, this, &Scope::UpdateScaler);
enableSignalSlot = true; enableSignalSlot = true;
} }
@ -300,7 +297,7 @@ Scope::~Scope(){
DebugPrint("%s", "Scope"); DebugPrint("%s", "Scope");
scopeTimer->stop(); scopeTimer->stop();
scalarTimer->stop(); // scalarTimer->stop();
if( workerThread->isRunning() ){ if( workerThread->isRunning() ){
workerThread->quit(); workerThread->quit();
@ -435,7 +432,6 @@ void Scope::StartScope(){
} }
scopeTimer->start(ScopeUpdateMiliSec); scopeTimer->start(ScopeUpdateMiliSec);
scalarTimer->start(ScalarUpdateinMiliSec);
bnScopeStart->setEnabled(false); bnScopeStart->setEnabled(false);
bnScopeStart->setStyleSheet(""); bnScopeStart->setStyleSheet("");
@ -458,7 +454,7 @@ void Scope::StopScope(){
// printf("------ Scope::%s \n", __func__); // printf("------ Scope::%s \n", __func__);
scopeTimer->stop(); scopeTimer->stop();
scalarTimer->stop(); // scalarTimer->stop();
if( chkSoleRun->isChecked() ){ if( chkSoleRun->isChecked() ){
@ -517,7 +513,7 @@ void Scope::StopScope(){
} }
runStatus->setStyleSheet(""); // cheated, don;t know why digi[iDigi]->GetACQStatusFromMemory(), sometimes return ACQ on runStatus->setStyleSheet(""); // cheated, don;t know why digi[iDigi]->GetACQStatusFromMemory(), sometimes return ACQ one.
emit UpdateOtherPanels(); emit UpdateOtherPanels();

View File

@ -54,7 +54,6 @@ signals:
void CloseWindow(); void CloseWindow();
void SendLogMsg(const QString &msg); void SendLogMsg(const QString &msg);
void TellACQOnOff(const bool onOff); void TellACQOnOff(const bool onOff);
void UpdateScaler();
void UpdateOtherPanels(); void UpdateOtherPanels();
private: private:
@ -90,7 +89,6 @@ private:
unsigned short oldCh, oldDigi; unsigned short oldCh, oldDigi;
ReadDataThread ** readDataThread; ReadDataThread ** readDataThread;
// TimingThread * updateScalarThread;
bool enableSignalSlot; bool enableSignalSlot;
@ -152,8 +150,6 @@ private:
QThread * workerThread; QThread * workerThread;
ScopeWorker * scopeWorker; ScopeWorker * scopeWorker;
QTimer * scopeTimer; QTimer * scopeTimer;
QTimer * scalarTimer;
}; };