2023-01-25 14:59:48 -05:00
|
|
|
#include "mainwindow.h"
|
|
|
|
|
|
|
|
#include <QLabel>
|
|
|
|
#include <QGridLayout>
|
|
|
|
|
|
|
|
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent){
|
|
|
|
|
|
|
|
setWindowTitle("SOLARIS DAQ");
|
|
|
|
setGeometry(500, 500, 1000, 500);
|
|
|
|
QIcon icon("SOLARIS_favicon.png");
|
|
|
|
setWindowIcon(icon);
|
|
|
|
|
|
|
|
nDigi = 0;
|
2023-01-25 17:16:14 -05:00
|
|
|
digiSerialNum.clear();
|
|
|
|
digiSetting = NULL;
|
2023-01-25 14:59:48 -05:00
|
|
|
|
|
|
|
QWidget * mainLayoutWidget = new QWidget(this);
|
|
|
|
setCentralWidget(mainLayoutWidget);
|
2023-01-25 17:16:14 -05:00
|
|
|
QVBoxLayout * layout1 = new QVBoxLayout(mainLayoutWidget);
|
2023-01-25 14:59:48 -05:00
|
|
|
mainLayoutWidget->setLayout(layout1);
|
|
|
|
|
|
|
|
{
|
|
|
|
QGridLayout *layout = new QGridLayout();
|
|
|
|
layout1->addLayout(layout);
|
|
|
|
layout1->addStretch();
|
|
|
|
layout1->setStretchFactor(layout, 8);
|
|
|
|
|
|
|
|
bnProgramSettings = new QPushButton("Program Settings", this);
|
|
|
|
|
|
|
|
bnOpenDigitizers = new QPushButton("Open Digitizers", this);
|
|
|
|
connect(bnOpenDigitizers, SIGNAL(clicked()), this, SLOT(bnOpenDigitizers_clicked()));
|
|
|
|
|
|
|
|
bnCloseDigitizers = new QPushButton("Close Digitizers", this);
|
|
|
|
bnCloseDigitizers->setEnabled(false);
|
|
|
|
connect(bnCloseDigitizers, SIGNAL(clicked()), this, SLOT(bnCloseDigitizers_clicked()));
|
|
|
|
|
|
|
|
bnDigiSettings = new QPushButton("Digitizers Settings", this);
|
|
|
|
bnDigiSettings->setEnabled(false);
|
2023-01-25 17:16:14 -05:00
|
|
|
connect(bnDigiSettings, SIGNAL(clicked()), this, SLOT(OpenDigitizersSettings()));
|
2023-01-25 14:59:48 -05:00
|
|
|
|
|
|
|
bnStartACQ = new QPushButton("Start ACQ", this);
|
|
|
|
bnStartACQ->setEnabled(false);
|
|
|
|
bnStopACQ = new QPushButton("Stop ACQ", this);
|
|
|
|
bnStopACQ->setEnabled(false);
|
|
|
|
|
|
|
|
layout->addWidget(bnProgramSettings, 0, 0);
|
|
|
|
layout->addWidget(bnOpenDigitizers, 0, 1);
|
|
|
|
layout->addWidget(bnCloseDigitizers, 0, 2);
|
|
|
|
layout->addWidget(bnDigiSettings, 1, 1);
|
|
|
|
|
2023-01-26 19:12:18 -05:00
|
|
|
QFrame * separator = new QFrame(this);
|
2023-01-25 14:59:48 -05:00
|
|
|
separator->setFrameShape(QFrame::HLine);
|
|
|
|
layout->addWidget(separator, 2, 0, 1, 3);
|
|
|
|
|
|
|
|
layout->addWidget(bnStartACQ, 3, 0);
|
|
|
|
layout->addWidget(bnStopACQ, 3, 1);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
logInfo = new QPlainTextEdit(this);
|
|
|
|
logInfo->isReadOnly();
|
|
|
|
logInfo->setGeometry(100, 200, 500, 100);
|
|
|
|
|
|
|
|
layout1->addWidget(logInfo);
|
|
|
|
layout1->setStretchFactor(logInfo, 1);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//StartRunThread = new QThread(this);
|
|
|
|
//connect(StartRunThread, &QThread::started, this, &MainWindow::onThreadStarted);
|
|
|
|
//connect(StartRunThread, &QThread::finished, this, &MainWindow::onThreadFinished);
|
|
|
|
|
|
|
|
LogMsg("Welcome to SOLARIS DAQ.");
|
|
|
|
|
2023-01-27 18:52:03 -05:00
|
|
|
bnOpenDigitizers_clicked();
|
2023-01-25 17:16:14 -05:00
|
|
|
OpenDigitizersSettings();
|
|
|
|
|
2023-01-25 14:59:48 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
MainWindow::~MainWindow(){
|
|
|
|
|
2023-01-25 17:16:14 -05:00
|
|
|
delete digiSetting;
|
|
|
|
|
2023-01-25 14:59:48 -05:00
|
|
|
delete bnProgramSettings;
|
|
|
|
delete bnOpenDigitizers;
|
|
|
|
delete bnCloseDigitizers;
|
|
|
|
delete bnDigiSettings;
|
|
|
|
delete logInfo;
|
|
|
|
|
|
|
|
if( digi != NULL ){
|
|
|
|
digi->CloseDigitizer();
|
|
|
|
delete digi;
|
|
|
|
}
|
|
|
|
|
|
|
|
//StartRunThread->quit();
|
|
|
|
//StartRunThread->wait();
|
|
|
|
//delete StartRunThread;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::bnOpenDigitizers_clicked(){
|
|
|
|
LogMsg("Opening digitizer.....");
|
|
|
|
|
|
|
|
digi = new Digitizer2Gen();
|
|
|
|
|
|
|
|
digi->OpenDigitizer("dig2://192.168.0.100/");
|
|
|
|
|
|
|
|
if(digi->IsConnected()){
|
|
|
|
|
2023-01-25 17:16:14 -05:00
|
|
|
digiSerialNum.push_back(digi->GetSerialNumber());
|
|
|
|
nDigi ++;
|
|
|
|
|
|
|
|
LogMsg("Opened digitizer : " + QString::number(digi->GetSerialNumber()));
|
2023-01-25 14:59:48 -05:00
|
|
|
bnOpenDigitizers->setEnabled(false);
|
2023-01-25 17:16:14 -05:00
|
|
|
bnCloseDigitizers->setEnabled(true);
|
|
|
|
bnDigiSettings->setEnabled(true);
|
|
|
|
bnStartACQ->setEnabled(true);
|
2023-01-25 14:59:48 -05:00
|
|
|
|
|
|
|
}else{
|
|
|
|
LogMsg("Cannot open digitizer");
|
2023-01-27 18:52:03 -05:00
|
|
|
|
|
|
|
LogMsg("use a dummy.");
|
|
|
|
|
|
|
|
digi->SetDummy();
|
|
|
|
digiSerialNum.push_back(0000);
|
|
|
|
nDigi ++;
|
|
|
|
|
2023-01-25 14:59:48 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::bnCloseDigitizers_clicked(){
|
|
|
|
if( digi != NULL ){
|
|
|
|
digi->CloseDigitizer();
|
|
|
|
delete digi;
|
|
|
|
digi = NULL;
|
2023-01-25 17:16:14 -05:00
|
|
|
LogMsg("Closed Digitizer : " + QString::number(digiSerialNum[0]));
|
2023-01-25 14:59:48 -05:00
|
|
|
|
2023-01-25 17:16:14 -05:00
|
|
|
nDigi = 0;
|
|
|
|
digiSerialNum.clear();
|
|
|
|
|
2023-01-25 14:59:48 -05:00
|
|
|
bnOpenDigitizers->setEnabled(true);
|
2023-01-25 17:16:14 -05:00
|
|
|
bnCloseDigitizers->setEnabled(false);
|
|
|
|
bnDigiSettings->setEnabled(false);
|
|
|
|
bnStartACQ->setEnabled(false);
|
|
|
|
bnStopACQ->setEnabled(false);
|
2023-01-25 14:59:48 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-25 17:16:14 -05:00
|
|
|
void MainWindow::OpenDigitizersSettings(){
|
|
|
|
LogMsg("Open digitizers Settings Panel");
|
|
|
|
|
|
|
|
if( digiSetting == NULL){
|
|
|
|
digiSetting = new DigiSettings(digi, nDigi);
|
|
|
|
digiSetting->show();
|
|
|
|
}else{
|
|
|
|
digiSetting->show();
|
|
|
|
}
|
|
|
|
}
|
2023-01-25 14:59:48 -05:00
|
|
|
|
|
|
|
void MainWindow::LogMsg(QString msg){
|
|
|
|
|
|
|
|
QString countStr = QStringLiteral("[%1] %2").arg(QDateTime::currentDateTime().toString("MM.dd hh:mm:ss"), msg);
|
|
|
|
logInfo->appendPlainText(countStr);
|
|
|
|
QScrollBar *v = logInfo->verticalScrollBar();
|
|
|
|
v->setValue(v->maximum());
|
|
|
|
qDebug() << msg;
|
|
|
|
logInfo->repaint();
|
|
|
|
}
|