diff --git a/digiSettingsPanel.h b/digiSettingsPanel.h index 2bbad1d..129ab75 100644 --- a/digiSettingsPanel.h +++ b/digiSettingsPanel.h @@ -115,7 +115,7 @@ private: QPushButton * pbCopyDigi; //------------ status - QLineEdit * leInfo[MaxNumberOfChannel][12]; + QLineEdit * leInfo[MaxNumberOfDigitizer][12]; QPushButton * LEDStatus[MaxNumberOfDigitizer][19]; QPushButton * ACQStatus[MaxNumberOfDigitizer][19]; QLineEdit * leTemp[MaxNumberOfDigitizer][8]; diff --git a/mainwindow.cpp b/mainwindow.cpp index faacec3..0f4225b 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -63,8 +63,8 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent){ leTrigger = nullptr; leAccept = nullptr; - scalarThread = new ScalarThread(); - connect(scalarThread, &ScalarThread::updataScalar, this, &MainWindow::UpdateScalar); + scalarThread = new TimingThread(); + connect(scalarThread, &TimingThread::TimeUp, this, &MainWindow::UpdateScalar); } diff --git a/mainwindow.h b/mainwindow.h index faf3c5c..c4d46a5 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -118,7 +118,7 @@ private: //@----- scalar; QMainWindow * scalar; QGridLayout * scalarLayout; - ScalarThread * scalarThread; + TimingThread * scalarThread; QPushButton * bnOpenScalar; QLineEdit *** leTrigger; // need to delete manually QLineEdit *** leAccept; // need to delete manually diff --git a/manyThread.h b/manyThread.h index d4a1f62..cbb2755 100644 --- a/manyThread.h +++ b/manyThread.h @@ -62,46 +62,17 @@ private: bool isSaveData; }; -//^#===================================================== UpdateTrace Thread -class UpdateTraceThread : public QThread { +//^#======================================================= Timing Thread, for some action need to be done periodically +class TimingThread : public QThread { Q_OBJECT public: - UpdateTraceThread(QObject * parent = 0) : QThread(parent){ - waitTime = 2; - stop = false; - } - unsigned int GetWaitTimeSec() const {return waitTime;} - void SetWaitTimeSec(unsigned sec) {waitTime = sec;} - void Stop() {this->stop = true;} - void run(){ - unsigned int count = 0; - stop = false; - do{ - usleep(100000); - count ++; - if( count % waitTime == 0){ - emit updateTrace(); - } - }while(!stop); - } -signals: - void updateTrace(); - -private: - bool stop; - unsigned int waitTime; //100 of milisec -}; - -//^#======================================================= Scalar Thread -class ScalarThread : public QThread { - Q_OBJECT -public: - ScalarThread(QObject * parent = 0 ) : QThread(parent){ + TimingThread(QObject * parent = 0 ) : QThread(parent){ waitTime = 20; // 10 x 100 milisec stop = false; } void Stop() { this->stop = true;} - unsigned int GetWaitTimeinSec() const {return waitTime/10;} + float GetWaitTimeinSec() const {return waitTime/10.;} + void SetWaitTimeSec(float sec) {waitTime = sec * 10;} void run(){ unsigned int count = 0; stop = false; @@ -109,12 +80,12 @@ public: usleep(100000); count ++; if( count % waitTime == 0){ - emit updataScalar(); + emit TimeUp(); } }while(!stop); } signals: - void updataScalar(); + void TimeUp(); private: bool stop; unsigned int waitTime; diff --git a/scope.cpp b/scope.cpp index 92035a3..ba8537f 100644 --- a/scope.cpp +++ b/scope.cpp @@ -54,8 +54,8 @@ Scope::Scope(Digitizer2Gen **digi, unsigned int nDigi, ReadDataThread ** readDat xaxis->setLabelFormat("%.0f"); xaxis->setTitleText("Time [ns]"); - updateTraceThread = new UpdateTraceThread(); - connect(updateTraceThread, &UpdateTraceThread::updateTrace, this, &Scope::UpdateScope); + updateTraceThread = new TimingThread(); + connect(updateTraceThread, &TimingThread::TimeUp, this, &Scope::UpdateScope); //*================ add Widgets int rowID = -1; @@ -283,7 +283,7 @@ Scope::Scope(Digitizer2Gen **digi, unsigned int nDigi, ReadDataThread ** readDat QLabel * lbhints = new QLabel("Type 'r' to restore view, '+/-' Zoom in/out, arrow key to pan.", this); layout->addWidget(lbhints, rowID, 0, 1, 4); - QLabel * lbinfo = new QLabel("Trace update every " + QString::number(updateTraceThread->GetWaitTimeSec()) + " sec.", this); + QLabel * lbinfo = new QLabel("Trace update every " + QString::number(updateTraceThread->GetWaitTimeinSec()) + " sec.", this); lbinfo->setAlignment(Qt::AlignRight); layout->addWidget(lbinfo, rowID, 5); diff --git a/scope.h b/scope.h index ccaddd9..03724e1 100644 --- a/scope.h +++ b/scope.h @@ -162,7 +162,7 @@ private: unsigned short nDigi; ReadDataThread ** readDataThread; - UpdateTraceThread * updateTraceThread; + TimingThread * updateTraceThread; QChart * plot; QLineSeries * dataTrace[6];