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;
//------------ status
QLineEdit * leInfo[MaxNumberOfChannel][12];
QLineEdit * leInfo[MaxNumberOfDigitizer][12];
QPushButton * LEDStatus[MaxNumberOfDigitizer][19];
QPushButton * ACQStatus[MaxNumberOfDigitizer][19];
QLineEdit * leTemp[MaxNumberOfDigitizer][8];

View File

@ -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);
}

View File

@ -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

View File

@ -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;

View File

@ -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);

View File

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