combined trace and scalar thread.

This commit is contained in:
Ryan Tang 2023-04-25 17:23:50 -04:00
parent 8fe3e09b51
commit 3df3fd50a1
6 changed files with 15 additions and 44 deletions

View File

@ -115,7 +115,7 @@ private:
QPushButton * pbCopyDigi; QPushButton * pbCopyDigi;
//------------ status //------------ status
QLineEdit * leInfo[MaxNumberOfChannel][12]; QLineEdit * leInfo[MaxNumberOfDigitizer][12];
QPushButton * LEDStatus[MaxNumberOfDigitizer][19]; QPushButton * LEDStatus[MaxNumberOfDigitizer][19];
QPushButton * ACQStatus[MaxNumberOfDigitizer][19]; QPushButton * ACQStatus[MaxNumberOfDigitizer][19];
QLineEdit * leTemp[MaxNumberOfDigitizer][8]; QLineEdit * leTemp[MaxNumberOfDigitizer][8];

View File

@ -63,8 +63,8 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent){
leTrigger = nullptr; leTrigger = nullptr;
leAccept = nullptr; leAccept = nullptr;
scalarThread = new ScalarThread(); scalarThread = new TimingThread();
connect(scalarThread, &ScalarThread::updataScalar, this, &MainWindow::UpdateScalar); connect(scalarThread, &TimingThread::TimeUp, this, &MainWindow::UpdateScalar);
} }

View File

@ -118,7 +118,7 @@ private:
//@----- scalar; //@----- scalar;
QMainWindow * scalar; QMainWindow * scalar;
QGridLayout * scalarLayout; QGridLayout * scalarLayout;
ScalarThread * scalarThread; TimingThread * scalarThread;
QPushButton * bnOpenScalar; QPushButton * bnOpenScalar;
QLineEdit *** leTrigger; // need to delete manually QLineEdit *** leTrigger; // need to delete manually
QLineEdit *** leAccept; // need to delete manually QLineEdit *** leAccept; // need to delete manually

View File

@ -62,46 +62,17 @@ private:
bool isSaveData; bool isSaveData;
}; };
//^#===================================================== UpdateTrace Thread //^#======================================================= Timing Thread, for some action need to be done periodically
class UpdateTraceThread : public QThread { class TimingThread : public QThread {
Q_OBJECT Q_OBJECT
public: public:
UpdateTraceThread(QObject * parent = 0) : QThread(parent){ TimingThread(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){
waitTime = 20; // 10 x 100 milisec waitTime = 20; // 10 x 100 milisec
stop = false; stop = false;
} }
void Stop() { this->stop = true;} 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(){ void run(){
unsigned int count = 0; unsigned int count = 0;
stop = false; stop = false;
@ -109,12 +80,12 @@ public:
usleep(100000); usleep(100000);
count ++; count ++;
if( count % waitTime == 0){ if( count % waitTime == 0){
emit updataScalar(); emit TimeUp();
} }
}while(!stop); }while(!stop);
} }
signals: signals:
void updataScalar(); void TimeUp();
private: private:
bool stop; bool stop;
unsigned int waitTime; unsigned int waitTime;

View File

@ -54,8 +54,8 @@ Scope::Scope(Digitizer2Gen **digi, unsigned int nDigi, ReadDataThread ** readDat
xaxis->setLabelFormat("%.0f"); xaxis->setLabelFormat("%.0f");
xaxis->setTitleText("Time [ns]"); xaxis->setTitleText("Time [ns]");
updateTraceThread = new UpdateTraceThread(); updateTraceThread = new TimingThread();
connect(updateTraceThread, &UpdateTraceThread::updateTrace, this, &Scope::UpdateScope); connect(updateTraceThread, &TimingThread::TimeUp, this, &Scope::UpdateScope);
//*================ add Widgets //*================ add Widgets
int rowID = -1; 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); QLabel * lbhints = new QLabel("Type 'r' to restore view, '+/-' Zoom in/out, arrow key to pan.", this);
layout->addWidget(lbhints, rowID, 0, 1, 4); 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); lbinfo->setAlignment(Qt::AlignRight);
layout->addWidget(lbinfo, rowID, 5); layout->addWidget(lbinfo, rowID, 5);

View File

@ -162,7 +162,7 @@ private:
unsigned short nDigi; unsigned short nDigi;
ReadDataThread ** readDataThread; ReadDataThread ** readDataThread;
UpdateTraceThread * updateTraceThread; TimingThread * updateTraceThread;
QChart * plot; QChart * plot;
QLineSeries * dataTrace[6]; QLineSeries * dataTrace[6];