Scope panel
This commit is contained in:
parent
04be3f0776
commit
3bfcccb698
150
mainwindow.cpp
150
mainwindow.cpp
|
@ -9,9 +9,10 @@
|
|||
#include <QFile>
|
||||
#include <QProcess>
|
||||
#include <QRandomGenerator>
|
||||
|
||||
#include <QVariant>
|
||||
#include <QChartView>
|
||||
#include <QValueAxis>
|
||||
#include <QStandardItemModel>
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
|
@ -214,13 +215,14 @@ void MainWindow::StartACQ(){
|
|||
digi[i]->StartACQ();
|
||||
|
||||
//TODO ========================== Sync start.
|
||||
readDataThread[i]->SetScopeRun(false);
|
||||
readDataThread[i]->start();
|
||||
}
|
||||
|
||||
bnStartACQ->setEnabled(false);
|
||||
bnStopACQ->setEnabled(true);
|
||||
|
||||
updateTraceThread->start();
|
||||
//updateTraceThread->start();
|
||||
|
||||
LogMsg("end of " + QString::fromStdString(__func__));
|
||||
}
|
||||
|
@ -330,20 +332,22 @@ void MainWindow::CloseDigitizers(){
|
|||
//^###################################################################### Open Scope
|
||||
void MainWindow::OpenScope(){
|
||||
|
||||
QWidget * layoutWidget = new QWidget(scope);
|
||||
scope->setCentralWidget(layoutWidget);
|
||||
QGridLayout * layout = new QGridLayout(layoutWidget);
|
||||
layoutWidget->setLayout(layout);
|
||||
cbScopeDigi->clear(); ///thsi will also trigger QComboBox::currentIndexChanged
|
||||
cbScopeCh->clear();
|
||||
if( nDigi > 0 && digi != NULL) {
|
||||
for( int i = 0 ; i < nDigi; i++) {
|
||||
cbScopeDigi->addItem("Digi-" + QString::number(digi[i]->GetSerialNumber()), i);
|
||||
//*---- set digitizer to take full trace; since in scope mode, no data saving, speed would be fast (How fast?)
|
||||
//* when the input rate is faster than trigger rate, Digitizer will stop data taking.
|
||||
|
||||
QChartView * plotView = new QChartView(plot);
|
||||
plotView->setRenderHints(QPainter::Antialiasing);
|
||||
|
||||
//scope->setCentralWidget(plotView);
|
||||
layout->addWidget(plotView, 0, 0);
|
||||
//digi[i]->WriteValue();
|
||||
//readDataThread[i]->SetScopeRun(true);
|
||||
|
||||
}
|
||||
//if( nDigi == 1 ) cbScopeDigi->setEnabled(false);
|
||||
//updateTraceThread->start();
|
||||
}
|
||||
|
||||
QPushButton * bnUpdate = new QPushButton("Random", scope);
|
||||
layout->addWidget(bnUpdate, 1, 0);
|
||||
connect(bnUpdate, &QPushButton::clicked, this, &MainWindow::UpdateScope);
|
||||
|
||||
scope->show();
|
||||
|
||||
|
@ -366,6 +370,124 @@ void MainWindow::SetUpPlot(){ //@--- this function run at start up
|
|||
updateTraceThread = new UpdateTraceThread();
|
||||
connect(updateTraceThread, &UpdateTraceThread::updateTrace, this, &MainWindow::UpdateScope);
|
||||
|
||||
//*================ ad Widgets
|
||||
int rowID = -1;
|
||||
QWidget * layoutWidget = new QWidget(scope);
|
||||
scope->setCentralWidget(layoutWidget);
|
||||
QGridLayout * layout = new QGridLayout(layoutWidget);
|
||||
layoutWidget->setLayout(layout);
|
||||
|
||||
//------------ Digitizer + channel selection
|
||||
rowID ++;
|
||||
cbScopeDigi = new QComboBox(scope);
|
||||
cbScopeCh = new QComboBox(scope);
|
||||
layout->addWidget(cbScopeDigi, rowID, 0);
|
||||
layout->addWidget(cbScopeCh, rowID, 1);
|
||||
|
||||
connect(cbScopeDigi, &QComboBox::currentIndexChanged, this, [=](){
|
||||
int index = cbScopeDigi->currentIndex();
|
||||
if( index == -1 ) return;
|
||||
for( int i = 0; i < digi[index]->GetNChannels(); i++){
|
||||
cbScopeCh->addItem("ch-" + QString::number(i), i);
|
||||
}
|
||||
});
|
||||
|
||||
//------------ Probe selection
|
||||
cbAnaProbe[0] = new QComboBox(scope);
|
||||
cbAnaProbe[0]->addItem("ADC Input");
|
||||
cbAnaProbe[0]->addItem("Time Filter");
|
||||
cbAnaProbe[0]->addItem("Trapazoid");
|
||||
cbAnaProbe[0]->addItem("Trap. Baseline");
|
||||
cbAnaProbe[0]->addItem("Trap. - Baseline");
|
||||
|
||||
cbAnaProbe[1] = new QComboBox(scope);
|
||||
for( int i = 0; i < cbAnaProbe[0]->count() ; i++) cbAnaProbe[1]->addItem(cbAnaProbe[0]->itemText(i), cbAnaProbe[0]->itemData(i));
|
||||
|
||||
connect(cbAnaProbe[0], &QComboBox::currentIndexChanged, this, [=](){ this->ProbeChange(cbAnaProbe, 2);});
|
||||
connect(cbAnaProbe[1], &QComboBox::currentIndexChanged, this, [=](){ this->ProbeChange(cbAnaProbe, 2);});
|
||||
|
||||
cbAnaProbe[0]->setCurrentIndex(1); ///trigger the AnaProbeChange
|
||||
cbAnaProbe[0]->setCurrentIndex(0);
|
||||
cbAnaProbe[1]->setCurrentIndex(4);
|
||||
|
||||
|
||||
cbDigProbe[0] = new QComboBox(scope);
|
||||
cbDigProbe[0]->addItem("Trigger");
|
||||
cbDigProbe[0]->addItem("Time Filter Armed");
|
||||
cbDigProbe[0]->addItem("ReTrigger Guard");
|
||||
cbDigProbe[0]->addItem("Trap. basline Freeze");
|
||||
cbDigProbe[0]->addItem("Peaking");
|
||||
cbDigProbe[0]->addItem("Peak Ready");
|
||||
cbDigProbe[0]->addItem("Pile-up Guard");
|
||||
cbDigProbe[0]->addItem("ADC Saturate");
|
||||
cbDigProbe[0]->addItem("ADC Sat. Protection");
|
||||
cbDigProbe[0]->addItem("Post Sat. Event");
|
||||
cbDigProbe[0]->addItem("Trap. Saturate");
|
||||
cbDigProbe[0]->addItem("ACQ Inhibit");
|
||||
|
||||
cbDigProbe[1] = new QComboBox(scope);
|
||||
cbDigProbe[2] = new QComboBox(scope);
|
||||
cbDigProbe[3] = new QComboBox(scope);
|
||||
for( int i = 0; i < cbDigProbe[0]->count() ; i++) {
|
||||
cbDigProbe[1]->addItem(cbDigProbe[0]->itemText(i), cbDigProbe[0]->itemData(i));
|
||||
cbDigProbe[2]->addItem(cbDigProbe[0]->itemText(i), cbDigProbe[0]->itemData(i));
|
||||
cbDigProbe[3]->addItem(cbDigProbe[0]->itemText(i), cbDigProbe[0]->itemData(i));
|
||||
}
|
||||
|
||||
connect(cbDigProbe[0], &QComboBox::currentIndexChanged, this, [=](){ this->ProbeChange(cbDigProbe, 4);});
|
||||
connect(cbDigProbe[1], &QComboBox::currentIndexChanged, this, [=](){ this->ProbeChange(cbDigProbe, 4);});
|
||||
connect(cbDigProbe[2], &QComboBox::currentIndexChanged, this, [=](){ this->ProbeChange(cbDigProbe, 4);});
|
||||
connect(cbDigProbe[3], &QComboBox::currentIndexChanged, this, [=](){ this->ProbeChange(cbDigProbe, 4);});
|
||||
|
||||
cbDigProbe[0]->setCurrentIndex(1); ///trigger the DigProbeChange
|
||||
cbDigProbe[0]->setCurrentIndex(0);
|
||||
cbDigProbe[1]->setCurrentIndex(4);
|
||||
cbDigProbe[2]->setCurrentIndex(5);
|
||||
cbDigProbe[3]->setCurrentIndex(6);
|
||||
|
||||
layout->addWidget(cbAnaProbe[0], rowID, 2);
|
||||
layout->addWidget(cbAnaProbe[1], rowID, 3);
|
||||
|
||||
rowID ++;
|
||||
layout->addWidget(cbDigProbe[0], rowID, 0);
|
||||
layout->addWidget(cbDigProbe[1], rowID, 1);
|
||||
layout->addWidget(cbDigProbe[2], rowID, 2);
|
||||
layout->addWidget(cbDigProbe[3], rowID, 3);
|
||||
|
||||
//------------ plot view
|
||||
rowID ++;
|
||||
QChartView * plotView = new QChartView(plot);
|
||||
plotView->setRenderHints(QPainter::Antialiasing);
|
||||
layout->addWidget(plotView, rowID, 0, 1, 4);
|
||||
|
||||
//------------ testing button
|
||||
rowID ++;
|
||||
QPushButton * bnUpdate = new QPushButton("Random", scope);
|
||||
layout->addWidget(bnUpdate, rowID, 0);
|
||||
connect(bnUpdate, &QPushButton::clicked, this, &MainWindow::UpdateScope);
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::ProbeChange(QComboBox * cb[], const int size ){
|
||||
|
||||
QStandardItemModel * model[size] = {NULL};
|
||||
for( int i = 0; i < size; i++){
|
||||
model[i] = qobject_cast<QStandardItemModel*>(cb[i]->model());
|
||||
}
|
||||
|
||||
/// Enable all items
|
||||
for( int i = 0; i < cb[0]->count(); i++) {
|
||||
for( int j = 0; j < size; j ++ ) model[j]->item(i)->setEnabled(true);
|
||||
}
|
||||
|
||||
for( int i = 0; i < size; i++){
|
||||
int index = cb[i]->currentIndex();
|
||||
for( int j = 0; j < size; j++){
|
||||
if( i == j ) continue;
|
||||
model[j]->item(index)->setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::UpdateScope(){
|
||||
|
|
29
mainwindow.h
29
mainwindow.h
|
@ -10,6 +10,7 @@
|
|||
#include <QDateTime>
|
||||
#include <QScrollBar>
|
||||
#include <QPushButton>
|
||||
#include <QComboBox>
|
||||
#include <QMutex>
|
||||
#include <QChart>
|
||||
#include <QLineSeries>
|
||||
|
@ -30,7 +31,9 @@ class ReadDataThread : public QThread {
|
|||
public:
|
||||
ReadDataThread(Digitizer2Gen * dig, QObject * parent = 0) : QThread(parent){
|
||||
this->digi = dig;
|
||||
isScopeRun = false;
|
||||
}
|
||||
void SetScopeRun(bool onOff) {this->isScopeRun = onOff;}
|
||||
void run(){
|
||||
clock_gettime(CLOCK_REALTIME, &ta);
|
||||
while(true){
|
||||
|
@ -39,7 +42,7 @@ public:
|
|||
digiMTX.unlock();
|
||||
|
||||
if( ret == CAEN_FELib_Success){
|
||||
digi->SaveDataToFile();
|
||||
if( !isScopeRun) digi->SaveDataToFile();
|
||||
}else if(ret == CAEN_FELib_Stop){
|
||||
digi->ErrorMsg("No more data");
|
||||
break;
|
||||
|
@ -47,13 +50,15 @@ public:
|
|||
digi->ErrorMsg("ReadDataLoop()");
|
||||
}
|
||||
|
||||
clock_gettime(CLOCK_REALTIME, &tb);
|
||||
if( tb.tv_sec - ta.tv_sec > 2 ) {
|
||||
emit sendMsg("FileSize : " + QString::number(digi->GetFileSize()/1024./1024.) + " MB");
|
||||
|
||||
//double duration = tb.tv_nsec-ta.tv_nsec + tb.tv_sec*1e+9 - ta.tv_sec*1e+9;
|
||||
//printf("%4d, duration : %10.0f, %6.1f\n", readCount, duration, 1e9/duration);
|
||||
ta = tb;
|
||||
if( !isScopeRun ){
|
||||
clock_gettime(CLOCK_REALTIME, &tb);
|
||||
if( tb.tv_sec - ta.tv_sec > 2 ) {
|
||||
emit sendMsg("FileSize : " + QString::number(digi->GetFileSize()/1024./1024.) + " MB");
|
||||
|
||||
//double duration = tb.tv_nsec-ta.tv_nsec + tb.tv_sec*1e+9 - ta.tv_sec*1e+9;
|
||||
//printf("%4d, duration : %10.0f, %6.1f\n", readCount, duration, 1e9/duration);
|
||||
ta = tb;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -62,6 +67,7 @@ signals:
|
|||
private:
|
||||
Digitizer2Gen * digi;
|
||||
timespec ta, tb;
|
||||
bool isScopeRun;
|
||||
};
|
||||
|
||||
//^#===================================================== UpdateTrace Thread
|
||||
|
@ -138,12 +144,19 @@ private:
|
|||
QPushButton * bnDigiSettings;
|
||||
QPushButton * bnSOLSettings;
|
||||
|
||||
//@------ scope things
|
||||
QMainWindow * scope;
|
||||
QPushButton * bnOpenScope;
|
||||
QChart * plot;
|
||||
QLineSeries * dataTrace;
|
||||
UpdateTraceThread * updateTraceThread;
|
||||
QComboBox * cbScopeDigi;
|
||||
QComboBox * cbScopeCh;
|
||||
QComboBox * cbAnaProbe[2];
|
||||
QComboBox * cbDigProbe[4];
|
||||
void ProbeChange(QComboBox * cb[], const int size);
|
||||
|
||||
//@------ ACQ things
|
||||
QPushButton * bnStartACQ;
|
||||
QPushButton * bnStopACQ;
|
||||
QLineEdit * leRunID;
|
||||
|
|
Loading…
Reference in New Issue
Block a user