add a basic scope window

This commit is contained in:
Ryan Tang 2023-02-03 16:58:27 -05:00
parent 9dc44b5070
commit 19a637f366
5 changed files with 129 additions and 67 deletions

View File

@ -1,7 +1,8 @@
{ {
"files.associations": { "files.associations": {
"script.C": "cpp", "script.C": "cpp",
"SOLARIS_Qt6_DAQ.pro" : "makefile" "SOLARIS_Qt6_DAQ.pro": "makefile",
"qlineseries": "cpp"
}, },
"better-comments.multilineComments": true, "better-comments.multilineComments": true,

View File

@ -6,7 +6,7 @@ CAEN_DIG2_v1.5.3
CAEN_FELIB_v1.2.2 CAEN_FELIB_v1.2.2
`sudo apt install qt6-base-dev libcurl4-openssl-dev` `sudo apt install qt6-base-dev libcurl4-openssl-dev libqt6charts6-dev`
Digitizer firmware V2745-dpp-pha-2022092903.cup Digitizer firmware V2745-dpp-pha-2022092903.cup

View File

@ -6,7 +6,7 @@ TEMPLATE = app
TARGET = SOLARIS_DAQ TARGET = SOLARIS_DAQ
INCLUDEPATH += . INCLUDEPATH += .
QT += widgets QT += widgets charts
LIBS += -lcurl -lCAEN_FELib LIBS += -lcurl -lCAEN_FELib

View File

@ -8,7 +8,10 @@
#include <QDir> #include <QDir>
#include <QFile> #include <QFile>
#include <QProcess> #include <QProcess>
#include <QRegularExpression>
#include <QChartView>
#include <QLineSeries>
#include <QValueAxis>
#include <unistd.h> #include <unistd.h>
@ -27,6 +30,8 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent){
digiSetting = NULL; digiSetting = NULL;
readDataThread = NULL; readDataThread = NULL;
plot = new QChart();
QWidget * mainLayoutWidget = new QWidget(this); QWidget * mainLayoutWidget = new QWidget(this);
setCentralWidget(mainLayoutWidget); setCentralWidget(mainLayoutWidget);
QVBoxLayout * layoutMain = new QVBoxLayout(mainLayoutWidget); QVBoxLayout * layoutMain = new QVBoxLayout(mainLayoutWidget);
@ -52,8 +57,9 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent){
leExpName->setAlignment(Qt::AlignHCenter); leExpName->setAlignment(Qt::AlignHCenter);
leExpName->setReadOnly(true); leExpName->setReadOnly(true);
QPushButton * bnOpenScope = new QPushButton("Open scope", this); bnOpenScope = new QPushButton("Open scope", this);
bnOpenScope->setEnabled(false); bnOpenScope->setEnabled(false);
connect(bnOpenScope, &QPushButton::clicked, this, &MainWindow::OpenScope);
bnOpenDigitizers = new QPushButton("Open Digitizers", this); bnOpenDigitizers = new QPushButton("Open Digitizers", this);
connect(bnOpenDigitizers, SIGNAL(clicked()), this, SLOT(OpenDigitizers())); connect(bnOpenDigitizers, SIGNAL(clicked()), this, SLOT(OpenDigitizers()));
@ -66,7 +72,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent){
bnDigiSettings->setEnabled(false); bnDigiSettings->setEnabled(false);
connect(bnDigiSettings, SIGNAL(clicked()), this, SLOT(OpenDigitizersSettings())); connect(bnDigiSettings, SIGNAL(clicked()), this, SLOT(OpenDigitizersSettings()));
QPushButton * bnSOLSettings = new QPushButton("SOLARIS Settings", this); bnSOLSettings = new QPushButton("SOLARIS Settings", this);
bnSOLSettings->setEnabled(false); bnSOLSettings->setEnabled(false);
layout1->addWidget(bnProgramSettings, 0, 0); layout1->addWidget(bnProgramSettings, 0, 0);
@ -163,8 +169,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent){
if( OpenProgramSettings() ) OpenExpSettings(); if( OpenProgramSettings() ) OpenExpSettings();
//bnOpenDigitizers_clicked(); bnOpenScope->setEnabled(true);
//OpenDigitizersSettings();
} }
@ -178,6 +183,8 @@ MainWindow::~MainWindow(){
//delete bnNewExp; //delete bnNewExp;
//delete logInfo; //delete logInfo;
if( plot != NULL )delete plot;
//---- need manually delete //---- need manually delete
if( digiSetting != NULL ) delete digiSetting; if( digiSetting != NULL ) delete digiSetting;
@ -233,7 +240,7 @@ void MainWindow::StopACQ(){
//^###################################################################### open and close digitizer //^###################################################################### open and close digitizer
void MainWindow::OpenDigitizers(){ void MainWindow::OpenDigitizers(){
LogMsg("Opening " + QString::number(nDigi) + " Digitizers....."); LogMsg("<font style=\"color:blue;\">Opening " + QString::number(nDigi) + " Digitizers..... </font>");
digi = new Digitizer2Gen*[nDigi]; digi = new Digitizer2Gen*[nDigi];
readDataThread = new ReadDataThread*[nDigi]; readDataThread = new ReadDataThread*[nDigi];
@ -252,6 +259,7 @@ void MainWindow::OpenDigitizers(){
LogMsg("Opened digitizer : <font style=\"color:red;\">" + QString::number(digi[i]->GetSerialNumber()) + "</font>"); LogMsg("Opened digitizer : <font style=\"color:red;\">" + QString::number(digi[i]->GetSerialNumber()) + "</font>");
bnStartACQ->setEnabled(true); bnStartACQ->setEnabled(true);
bnStopACQ->setEnabled(false); bnStopACQ->setEnabled(false);
bnOpenScope->setEnabled(true);
readDataThread[i] = new ReadDataThread(digi[i], this); readDataThread[i] = new ReadDataThread(digi[i], this);
connect(readDataThread[i], &ReadDataThread::sendMsg, this, &MainWindow::LogMsg); connect(readDataThread[i], &ReadDataThread::sendMsg, this, &MainWindow::LogMsg);
@ -273,6 +281,8 @@ void MainWindow::OpenDigitizers(){
void MainWindow::CloseDigitizers(){ void MainWindow::CloseDigitizers(){
if( digi == NULL) return;
for( int i = 0; i < nDigi; i++){ for( int i = 0; i < nDigi; i++){
digi[i]->CloseDigitizer(); digi[i]->CloseDigitizer();
@ -306,6 +316,49 @@ void MainWindow::CloseDigitizers(){
bnOpenDigitizers->setFocus(); bnOpenDigitizers->setFocus();
} }
//^###################################################################### Open Scope
void MainWindow::OpenScope(){
QMainWindow * scope = new QMainWindow(this);
scope->setWindowTitle("Scope");
scope->setGeometry(0, 0, 1000, 800);
QWidget * layoutWidget = new QWidget(scope);
scope->setCentralWidget(layoutWidget);
QGridLayout * layout = new QGridLayout(layoutWidget);
layoutWidget->setLayout(layout);
plot->removeAllSeries();
QLineSeries * data = new QLineSeries(this);
data->setName("data");
//--------- add data
data->append(1, 2);
data->append(2, 2);
data->append(3, 5);
data->append(4, 2);
plot->addSeries(data);
plot->createDefaultAxes(); /// this must be after addSeries();
plot->axes(Qt::Vertical).first()->setRange(0, 10); /// this must be after createDefaultAxes();
plot->axes(Qt::Horizontal).first()->setRange(0, 5);
QChartView * plotView = new QChartView(plot);
plotView->setRenderHints(QPainter::Antialiasing);
//scope->setCentralWidget(plotView);
layout->addWidget(plotView);
scope->show();
}
//^###################################################################### Open digitizer setting panel
void MainWindow::OpenDigitizersSettings(){ void MainWindow::OpenDigitizersSettings(){
LogMsg("Open digitizers Settings Panel"); LogMsg("Open digitizers Settings Panel");

View File

@ -11,6 +11,7 @@
#include <QScrollBar> #include <QScrollBar>
#include <QPushButton> #include <QPushButton>
#include <QMutex> #include <QMutex>
#include <QChart>
#include <vector> #include <vector>
#include <time.h> // time in nano-sec #include <time.h> // time in nano-sec
@ -97,6 +98,8 @@ private slots:
void OpenDigitizers(); void OpenDigitizers();
void CloseDigitizers(); void CloseDigitizers();
void OpenScope();
void OpenDigitizersSettings(); void OpenDigitizersSettings();
@ -122,7 +125,12 @@ private:
QPushButton * bnOpenDigitizers; QPushButton * bnOpenDigitizers;
QPushButton * bnCloseDigitizers; QPushButton * bnCloseDigitizers;
QPushButton * bnDigiSettings; QPushButton * bnDigiSettings;
QPushButton * bnSOLSettings;
QPushButton * bnOpenScope;
QChart * plot;
QPushButton * bnStartACQ; QPushButton * bnStartACQ;
QPushButton * bnStopACQ; QPushButton * bnStopACQ;