fixed repeat run problems

This commit is contained in:
Ryan Tang 2024-04-08 20:17:26 -04:00
parent 4f10519089
commit 17657d7d7e
2 changed files with 18 additions and 7 deletions

View File

@ -42,6 +42,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent){
runTimer = new QTimer(); runTimer = new QTimer();
needManualComment = true; needManualComment = true;
ACQStopButtonPressed = false;
isACQRunning = false; isACQRunning = false;
{ {
@ -185,12 +186,13 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent){
cbAutoRun = new QComboBox(this); cbAutoRun = new QComboBox(this);
cbAutoRun->addItem("Single infinte", 0); cbAutoRun->addItem("Single infinte", 0);
cbAutoRun->addItem("Single 1 min", 1); cbAutoRun->addItem("Single 1 min", 1);
cbAutoRun->addItem("Single 30 mins", 30); cbAutoRun->addItem("Single 30 mins", 30);
cbAutoRun->addItem("Single 60 mins", 60); cbAutoRun->addItem("Single 60 mins", 60);
cbAutoRun->addItem("Single 2 hrs", 120); cbAutoRun->addItem("Single 2 hrs", 120);
cbAutoRun->addItem("Single 3 hrs", 180); cbAutoRun->addItem("Single 3 hrs", 180);
cbAutoRun->addItem("Single 5 hrs", 300); cbAutoRun->addItem("Single 5 hrs", 300);
cbAutoRun->addItem("Every 1 mins", -1);
cbAutoRun->addItem("Every 30 mins", -30); cbAutoRun->addItem("Every 30 mins", -30);
cbAutoRun->addItem("Every 60 mins", -60); cbAutoRun->addItem("Every 60 mins", -60);
cbAutoRun->addItem("Every 2 hrs", -120); cbAutoRun->addItem("Every 2 hrs", -120);
@ -215,6 +217,9 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent){
bnStopACQ = new QPushButton("Stop ACQ", this); bnStopACQ = new QPushButton("Stop ACQ", this);
bnStopACQ->setEnabled(false); bnStopACQ->setEnabled(false);
connect(bnStopACQ, &QPushButton::clicked, this, [=](){ connect(bnStopACQ, &QPushButton::clicked, this, [=](){
LogMsg("@@@@@@@@@ Stop ACQ Button Pressed.");
ACQStopButtonPressed = true;
needManualComment = true; needManualComment = true;
runTimer->stop(); runTimer->stop();
StopACQ(); StopACQ();
@ -364,6 +369,8 @@ MainWindow::~MainWindow(){
//*################################################################ ACQ control //*################################################################ ACQ control
int MainWindow::StartACQ(){ int MainWindow::StartACQ(){
ACQStopButtonPressed = false;
if( chkSaveRun->isChecked() ){ if( chkSaveRun->isChecked() ){
runID ++; runID ++;
leRunID->setText(QString::number(runID)); leRunID->setText(QString::number(runID));
@ -500,8 +507,6 @@ void MainWindow::StopACQ(){
if( !isACQRunning ) return; if( !isACQRunning ) return;
bnStopACQ->setEnabled(false);
if( chkSaveRun->isChecked() ){ if( chkSaveRun->isChecked() ){
//============ stop comment //============ stop comment
if( needManualComment ){ if( needManualComment ){
@ -640,12 +645,16 @@ void MainWindow::AutoRun(){
cbDataFormat->setEnabled(true); cbDataFormat->setEnabled(true);
if( digiSetting ) digiSetting->EnableControl(); if( digiSetting ) digiSetting->EnableControl();
}else{ }else{
LogMsg("Wait for 10 sec for next Run...."); LogMsg("Wait for 10 sec for next Run....");
elapsedTimer.invalidate(); elapsedTimer.invalidate();
elapsedTimer.start(); elapsedTimer.start();
while(elapsedTimer.elapsed() < 10000) QCoreApplication::processEvents(); while(elapsedTimer.elapsed() < 10000) {
QCoreApplication::processEvents();
if( ACQStopButtonPressed ) {
ACQStopButtonPressed = false;
return;
}
}
StartACQ(); StartACQ();
} }
}); });
@ -665,7 +674,7 @@ void MainWindow::AutoRun(){
///=========== infinite timed run ///=========== infinite timed run
if( cbAutoRun->currentData().toInt() < 0 ){ if( cbAutoRun->currentData().toInt() < 0 ){
runTimer->setSingleShot(false); runTimer->setSingleShot(false);
runTimer->start(timeMiliSec); runTimer->start(abs(timeMiliSec));
needManualComment = false; needManualComment = false;
} }

View File

@ -149,6 +149,8 @@ private:
QElapsedTimer elapsedTimer; QElapsedTimer elapsedTimer;
unsigned int autoRunStartRunID; unsigned int autoRunStartRunID;
bool ACQStopButtonPressed;
//@----- digi Setting panel //@----- digi Setting panel
DigiSettingsPanel * digiSetting; DigiSettingsPanel * digiSetting;