From 28b447673b3bd2089a376a4bf2033cc1304b5e6c Mon Sep 17 00:00:00 2001 From: "Ryan@SOLARIS-DAQ" Date: Mon, 27 Mar 2023 18:34:22 -0400 Subject: [PATCH] fix bug when no digitizer connected. becasue the scalar did not setup --- main.cpp | 2 +- mainwindow.cpp | 9 ++++----- mainwindow.h | 1 + 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/main.cpp b/main.cpp index 834c9a1..a5a76aa 100644 --- a/main.cpp +++ b/main.cpp @@ -37,7 +37,7 @@ int main(int argc, char *argv[]){ msgBox.setText("The DAQ program is already opened, or crashed perviously. \nPID is " + QString::number(pid) + "\n You can kill the procee by \"kill -9 \" and delete the " + DAQLockFile + "\n or click the \"Kill\" button"); msgBox.setIcon(QMessageBox::Information); - QPushButton * kill = msgBox.addButton("Kill", QMessageBox::AcceptRole); + QPushButton * kill = msgBox.addButton("Kill and Open New", QMessageBox::AcceptRole); msgBox.setStandardButtons(QMessageBox::Ok); msgBox.setDefaultButton(QMessageBox::Ok); diff --git a/mainwindow.cpp b/mainwindow.cpp index a990dec..6b86eda 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -34,6 +34,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent){ setWindowIcon(icon); nDigi = 0; + nDigiConnected = 0; digiSetting = nullptr; influx = nullptr; readDataThread = nullptr; @@ -594,7 +595,7 @@ void MainWindow::OpenDigitizers(){ digi = new Digitizer2Gen*[nDigi]; readDataThread = new ReadDataThread*[nDigi]; - int nDigiConnected = 0; + nDigiConnected = 0; //Check path exist QDir dir(analysisPath + "/working/Settings/"); @@ -664,7 +665,7 @@ void MainWindow::OpenDigitizers(){ bnProgramSettings->setEnabled(false); bnNewExp->setEnabled(false); - bnSOLSettings->setEnabled(CheckSOLARISpanelOK()); + if( nDigiConnected > 0 ) bnSOLSettings->setEnabled(CheckSOLARISpanelOK()); } @@ -672,7 +673,7 @@ void MainWindow::CloseDigitizers(){ if( digi == NULL) return; - if(scalar ){ // scalar is child of this + if(scalar && nDigiConnected > 0 ){ // scalar is child of this scalar->close(); DeleteTriggerLineEdit(); // this use digi->GetNChannels(); } @@ -702,8 +703,6 @@ void MainWindow::CloseDigitizers(){ LogMsg("Closed Digitizer : " + QString::number(digi[i]->GetSerialNumber())); - if( digiSetting != NULL ) digiSetting->close(); - if( readDataThread[i] != NULL ){ LogMsg("Waiting for readData Thread ....."); readDataThread[i]->quit(); diff --git a/mainwindow.h b/mainwindow.h index 80e8822..e827d91 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -92,6 +92,7 @@ private: static Digitizer2Gen ** digi; unsigned short nDigi; + unsigned short nDigiConnected = 0; //@----- log msg QPlainTextEdit * logInfo;