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": {
"script.C": "cpp",
"SOLARIS_Qt6_DAQ.pro" : "makefile"
"SOLARIS_Qt6_DAQ.pro": "makefile",
"qlineseries": "cpp"
},
"better-comments.multilineComments": true,

View File

@ -6,7 +6,7 @@ CAEN_DIG2_v1.5.3
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

View File

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

View File

@ -8,7 +8,10 @@
#include <QDir>
#include <QFile>
#include <QProcess>
#include <QRegularExpression>
#include <QChartView>
#include <QLineSeries>
#include <QValueAxis>
#include <unistd.h>
@ -27,6 +30,8 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent){
digiSetting = NULL;
readDataThread = NULL;
plot = new QChart();
QWidget * mainLayoutWidget = new QWidget(this);
setCentralWidget(mainLayoutWidget);
QVBoxLayout * layoutMain = new QVBoxLayout(mainLayoutWidget);
@ -52,8 +57,9 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent){
leExpName->setAlignment(Qt::AlignHCenter);
leExpName->setReadOnly(true);
QPushButton * bnOpenScope = new QPushButton("Open scope", this);
bnOpenScope = new QPushButton("Open scope", this);
bnOpenScope->setEnabled(false);
connect(bnOpenScope, &QPushButton::clicked, this, &MainWindow::OpenScope);
bnOpenDigitizers = new QPushButton("Open Digitizers", this);
connect(bnOpenDigitizers, SIGNAL(clicked()), this, SLOT(OpenDigitizers()));
@ -66,7 +72,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent){
bnDigiSettings->setEnabled(false);
connect(bnDigiSettings, SIGNAL(clicked()), this, SLOT(OpenDigitizersSettings()));
QPushButton * bnSOLSettings = new QPushButton("SOLARIS Settings", this);
bnSOLSettings = new QPushButton("SOLARIS Settings", this);
bnSOLSettings->setEnabled(false);
layout1->addWidget(bnProgramSettings, 0, 0);
@ -163,8 +169,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent){
if( OpenProgramSettings() ) OpenExpSettings();
//bnOpenDigitizers_clicked();
//OpenDigitizersSettings();
bnOpenScope->setEnabled(true);
}
@ -178,6 +183,8 @@ MainWindow::~MainWindow(){
//delete bnNewExp;
//delete logInfo;
if( plot != NULL )delete plot;
//---- need manually delete
if( digiSetting != NULL ) delete digiSetting;
@ -233,7 +240,7 @@ void MainWindow::StopACQ(){
//^###################################################################### open and close digitizer
void MainWindow::OpenDigitizers(){
LogMsg("Opening " + QString::number(nDigi) + " Digitizers.....");
LogMsg("<font style=\"color:blue;\">Opening " + QString::number(nDigi) + " Digitizers..... </font>");
digi = new Digitizer2Gen*[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>");
bnStartACQ->setEnabled(true);
bnStopACQ->setEnabled(false);
bnOpenScope->setEnabled(true);
readDataThread[i] = new ReadDataThread(digi[i], this);
connect(readDataThread[i], &ReadDataThread::sendMsg, this, &MainWindow::LogMsg);
@ -273,6 +281,8 @@ void MainWindow::OpenDigitizers(){
void MainWindow::CloseDigitizers(){
if( digi == NULL) return;
for( int i = 0; i < nDigi; i++){
digi[i]->CloseDigitizer();
@ -306,6 +316,49 @@ void MainWindow::CloseDigitizers(){
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(){
LogMsg("Open digitizers Settings Panel");

View File

@ -11,6 +11,7 @@
#include <QScrollBar>
#include <QPushButton>
#include <QMutex>
#include <QChart>
#include <vector>
#include <time.h> // time in nano-sec
@ -85,92 +86,99 @@ private:
//=================================================
class MainWindow : public QMainWindow{
Q_OBJECT
Q_OBJECT
public:
MainWindow(QWidget *parent = nullptr);
~MainWindow();
MainWindow(QWidget *parent = nullptr);
~MainWindow();
private slots:
void OpenDigitizers();
void CloseDigitizers();
void OpenDigitizers();
void CloseDigitizers();
void OpenDigitizersSettings();
void OpenScope();
void OpenDigitizersSettings();
void ProgramSettings();
bool OpenProgramSettings();
void SaveProgramSettings();
void OpenDirectory(int id);
void ProgramSettings();
bool OpenProgramSettings();
void SaveProgramSettings();
void OpenDirectory(int id);
void SetupNewExp();
bool OpenExpSettings();
void CreateNewExperiment(const QString newExpName);
void ChangeExperiment(const QString newExpName);
void CreateRawDataFolderAndLink(const QString newExpName);
void SetupNewExp();
bool OpenExpSettings();
void CreateNewExperiment(const QString newExpName);
void ChangeExperiment(const QString newExpName);
void CreateRawDataFolderAndLink(const QString newExpName);
signals :
private:
QPushButton * bnProgramSettings;
QPushButton * bnNewExp;
QLineEdit * leExpName;
QPushButton * bnProgramSettings;
QPushButton * bnNewExp;
QLineEdit * leExpName;
QPushButton * bnOpenDigitizers;
QPushButton * bnCloseDigitizers;
QPushButton * bnDigiSettings;
QPushButton * bnOpenDigitizers;
QPushButton * bnCloseDigitizers;
QPushButton * bnStartACQ;
QPushButton * bnStopACQ;
QLineEdit * leRunID;
QLineEdit * leRawDataPath;
QPushButton * bnDigiSettings;
QPushButton * bnSOLSettings;
DigiSettings * digiSetting;
QPushButton * bnOpenScope;
QChart * plot;
QPlainTextEdit * logInfo;
QPushButton * bnStartACQ;
QPushButton * bnStopACQ;
QLineEdit * leRunID;
QLineEdit * leRawDataPath;
static Digitizer2Gen ** digi;
unsigned short nDigi;
std::vector<unsigned short> digiSerialNum;
DigiSettings * digiSetting;
void StartACQ();
void StopACQ();
QPlainTextEdit * logInfo;
ReadDataThread ** readDataThread;
static Digitizer2Gen ** digi;
unsigned short nDigi;
std::vector<unsigned short> digiSerialNum;
void LogMsg(QString msg);
bool logMsgHTMLMode = true;
void StartACQ();
void StopACQ();
//---------------- Program settings
QLineEdit * lSaveSettingPath; // only live in ProgramSettigns()
QLineEdit * lAnalysisPath; // only live in ProgramSettigns()
QLineEdit * lDataPath; // only live in ProgramSettigns()
ReadDataThread ** readDataThread;
QLineEdit * lIPDomain;
QLineEdit * lDatbaseIP;
QLineEdit * lDatbaseName;
QLineEdit * lElogIP;
void LogMsg(QString msg);
bool logMsgHTMLMode = true;
QString settingFilePath;
QString analysisPath;
QString dataPath;
QString IPListStr;
QStringList IPList;
QString DatabaseIP;
QString DatabaseName;
QString ElogIP;
//---------------- Program settings
QLineEdit * lSaveSettingPath; // only live in ProgramSettigns()
QLineEdit * lAnalysisPath; // only live in ProgramSettigns()
QLineEdit * lDataPath; // only live in ProgramSettigns()
//------------- experiment settings
bool isGitExist;
bool useGit;
QString expName;
QString rawDataFolder;
unsigned int runID;
unsigned int elogID;
QLineEdit * lIPDomain;
QLineEdit * lDatbaseIP;
QLineEdit * lDatbaseName;
QLineEdit * lElogIP;
QString settingFilePath;
QString analysisPath;
QString dataPath;
QString IPListStr;
QStringList IPList;
QString DatabaseIP;
QString DatabaseName;
QString ElogIP;
//------------- experiment settings
bool isGitExist;
bool useGit;
QString expName;
QString rawDataFolder;
unsigned int runID;
unsigned int elogID;
};