added scalar panel, only UI
This commit is contained in:
parent
166cc4357c
commit
e3b16f7694
|
@ -6,7 +6,7 @@ Digitizer2Gen::Digitizer2Gen(){
|
|||
}
|
||||
|
||||
Digitizer2Gen::~Digitizer2Gen(){
|
||||
printf("========Digitizer2Gen::%s \n",__func__);
|
||||
printf("========Digitizer2Gen::%s (%d)\n",__func__, serialNumber);
|
||||
if(isConnected ) CloseDigitizer();
|
||||
}
|
||||
|
||||
|
@ -43,9 +43,10 @@ void Digitizer2Gen::Initialization(){
|
|||
|
||||
}
|
||||
|
||||
void Digitizer2Gen::SetDummy(){
|
||||
void Digitizer2Gen::SetDummy(unsigned short sn){
|
||||
|
||||
isDummy = true;
|
||||
serialNumber = sn;
|
||||
nChannels = 64;
|
||||
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ class Digitizer2Gen {
|
|||
|
||||
unsigned short GetSerialNumber() {return serialNumber;}
|
||||
|
||||
void SetDummy();
|
||||
void SetDummy(unsigned short sn);
|
||||
bool IsDummy() {return isDummy;}
|
||||
|
||||
int OpenDigitizer(const char * url);
|
||||
|
|
163
mainwindow.cpp
163
mainwindow.cpp
|
@ -28,18 +28,28 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent){
|
|||
setWindowIcon(icon);
|
||||
|
||||
nDigi = 0;
|
||||
digiSerialNum.clear();
|
||||
digiSetting = NULL;
|
||||
readDataThread = NULL;
|
||||
|
||||
scope = NULL;
|
||||
|
||||
|
||||
{
|
||||
scalar = new QMainWindow(this);
|
||||
scalar->setWindowTitle("Scalar");
|
||||
scalar->setGeometry(0, 0, 1000, 800);
|
||||
|
||||
QWidget * layoutWidget = new QWidget(scalar);
|
||||
scalar->setCentralWidget(layoutWidget);
|
||||
scalarLayout = new QGridLayout(layoutWidget);
|
||||
scalarLayout->setSpacing(0);
|
||||
|
||||
leTrigger = NULL;
|
||||
}
|
||||
|
||||
QWidget * mainLayoutWidget = new QWidget(this);
|
||||
setCentralWidget(mainLayoutWidget);
|
||||
QVBoxLayout * layoutMain = new QVBoxLayout(mainLayoutWidget);
|
||||
mainLayoutWidget->setLayout(layoutMain);
|
||||
|
||||
|
||||
{//====================== General
|
||||
QGroupBox * box1 = new QGroupBox("General", mainLayoutWidget);
|
||||
layoutMain->addWidget(box1);
|
||||
|
@ -113,6 +123,10 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent){
|
|||
leRawDataPath->setReadOnly(true);
|
||||
leRawDataPath->setStyleSheet("background-color: #F3F3F3;");
|
||||
|
||||
bnOpenScalar = new QPushButton("Open Scalar", this);
|
||||
bnOpenScalar->setEnabled(false);
|
||||
connect(bnOpenScalar, &QPushButton::clicked, this, &MainWindow::OpenScaler);
|
||||
|
||||
bnStartACQ = new QPushButton("Start ACQ", this);
|
||||
bnStartACQ->setEnabled(false);
|
||||
connect(bnStartACQ, &QPushButton::clicked, this, &MainWindow::StartACQ);
|
||||
|
@ -134,7 +148,8 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent){
|
|||
runComment->setReadOnly(true);
|
||||
|
||||
layout2->addWidget(lbRawDataPath, 0, 0);
|
||||
layout2->addWidget(leRawDataPath, 0, 1, 1, 3);
|
||||
layout2->addWidget(leRawDataPath, 0, 1, 1, 2);
|
||||
layout2->addWidget(bnOpenScalar, 0, 3);
|
||||
|
||||
layout2->addWidget(lbRunID, 1, 0);
|
||||
layout2->addWidget(leRunID, 1, 1);
|
||||
|
@ -187,6 +202,7 @@ MainWindow::~MainWindow(){
|
|||
//delete logInfo;
|
||||
printf("- %s\n", __func__);
|
||||
|
||||
DeleteTriggerLineEdit();
|
||||
CloseDigitizers();
|
||||
|
||||
//---- need manually delete
|
||||
|
@ -263,8 +279,6 @@ void MainWindow::OpenDigitizers(){
|
|||
|
||||
if(digi[i]->IsConnected()){
|
||||
|
||||
digiSerialNum.push_back(digi[i]->GetSerialNumber());
|
||||
|
||||
LogMsg("Opened digitizer : <font style=\"color:red;\">" + QString::number(digi[i]->GetSerialNumber()) + "</font>");
|
||||
bnStartACQ->setEnabled(true);
|
||||
bnStopACQ->setEnabled(false);
|
||||
|
@ -274,9 +288,8 @@ void MainWindow::OpenDigitizers(){
|
|||
connect(readDataThread[i], &ReadDataThread::sendMsg, this, &MainWindow::LogMsg);
|
||||
|
||||
}else{
|
||||
LogMsg("Cannot open digitizer. Use a dummy with serial number " + QString::number(i));
|
||||
digi[i]->SetDummy();
|
||||
digiSerialNum.push_back(i);
|
||||
digi[i]->SetDummy(i);
|
||||
LogMsg("Cannot open digitizer. Use a dummy with serial number " + QString::number(i) + " and " + QString::number(digi[i]->GetNChannels()) + " ch.");
|
||||
|
||||
readDataThread[i] = NULL;
|
||||
}
|
||||
|
@ -287,26 +300,23 @@ void MainWindow::OpenDigitizers(){
|
|||
bnOpenDigitizers->setEnabled(false);
|
||||
bnOpenDigitizers->setStyleSheet("");
|
||||
|
||||
SetUpScalar();
|
||||
bnOpenScalar->setEnabled(true);
|
||||
}
|
||||
|
||||
void MainWindow::CloseDigitizers(){
|
||||
|
||||
if( digi == NULL) return;
|
||||
|
||||
scalar->close();
|
||||
DeleteTriggerLineEdit(); // this use digi->GetNChannels();
|
||||
|
||||
for( int i = 0; i < nDigi; i++){
|
||||
if( digi[i] == NULL) return;
|
||||
digi[i]->CloseDigitizer();
|
||||
delete digi[i];
|
||||
|
||||
LogMsg("Closed Digitizer : " + QString::number(digiSerialNum[0]));
|
||||
|
||||
digiSerialNum.clear();
|
||||
|
||||
bnOpenDigitizers->setEnabled(true);
|
||||
bnCloseDigitizers->setEnabled(false);
|
||||
bnDigiSettings->setEnabled(false);
|
||||
bnStartACQ->setEnabled(false);
|
||||
bnStopACQ->setEnabled(false);
|
||||
LogMsg("Closed Digitizer : " + QString::number(digi[i]->GetSerialNumber()));
|
||||
|
||||
if( digiSetting != NULL ) digiSetting->close();
|
||||
|
||||
|
@ -321,7 +331,15 @@ void MainWindow::CloseDigitizers(){
|
|||
digi = NULL;
|
||||
readDataThread = NULL;
|
||||
|
||||
|
||||
bnOpenDigitizers->setEnabled(true);
|
||||
bnCloseDigitizers->setEnabled(false);
|
||||
bnDigiSettings->setEnabled(false);
|
||||
bnStartACQ->setEnabled(false);
|
||||
bnStopACQ->setEnabled(false);
|
||||
bnOpenDigitizers->setFocus();
|
||||
bnOpenScalar->setEnabled(false);
|
||||
|
||||
}
|
||||
|
||||
//^###################################################################### Open Scope
|
||||
|
@ -329,7 +347,7 @@ void MainWindow::OpenScope(){
|
|||
|
||||
if( digi ){
|
||||
if( !scope ){
|
||||
scope = new Scope(digi, nDigi, readDataThread, this);
|
||||
scope = new Scope(digi, nDigi, readDataThread);
|
||||
connect(scope, &Scope::CloseWindow, this, [=](){
|
||||
bnStartACQ->setEnabled(true);
|
||||
});
|
||||
|
@ -354,6 +372,69 @@ void MainWindow::OpenDigitizersSettings(){
|
|||
}
|
||||
}
|
||||
|
||||
//^###################################################################### Open Scaler, when DAQ is running
|
||||
//TODO #################################
|
||||
void MainWindow::OpenScaler(){
|
||||
scalar->show();
|
||||
}
|
||||
|
||||
void MainWindow::SetUpScalar(){
|
||||
|
||||
scalar->setGeometry(0, 0, 10 + nDigi * 100, 1000);
|
||||
|
||||
int rowID = 0;
|
||||
for( int ch = 0; ch < MaxNumberOfChannel; ch++){
|
||||
|
||||
if( ch == 0 ){
|
||||
QLabel * lbCH_H = new QLabel("Ch", scalar); scalarLayout->addWidget(lbCH_H, rowID, 0);
|
||||
}
|
||||
|
||||
rowID ++;
|
||||
QLabel * lbCH = new QLabel(QString::number(ch), scalar);
|
||||
lbCH->setAlignment(Qt::AlignCenter);
|
||||
scalarLayout->addWidget(lbCH, rowID, 0);
|
||||
}
|
||||
|
||||
leTrigger = new QLineEdit**[nDigi];
|
||||
for( int iDigi = 0; iDigi < nDigi; iDigi++){
|
||||
rowID = 0;
|
||||
leTrigger[iDigi] = new QLineEdit *[digi[iDigi]->GetNChannels()];
|
||||
for( int ch = 0; ch < MaxNumberOfChannel; ch++){
|
||||
|
||||
if( ch == 0 ){
|
||||
QLabel * lbDigi = new QLabel("Digi-" + QString::number(digi[iDigi]->GetSerialNumber()), scalar);
|
||||
lbDigi->setAlignment(Qt::AlignCenter);
|
||||
scalarLayout->addWidget(lbDigi, rowID, iDigi+1);
|
||||
}
|
||||
|
||||
rowID ++;
|
||||
|
||||
leTrigger[iDigi][ch] = new QLineEdit();
|
||||
leTrigger[iDigi][ch]->setReadOnly(true);
|
||||
scalarLayout->addWidget(leTrigger[iDigi][ch], rowID, iDigi+1);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::DeleteTriggerLineEdit(){
|
||||
|
||||
printf("__________ %s \n", __func__);
|
||||
|
||||
if( leTrigger == NULL ) return;
|
||||
|
||||
for( int i = 0; i < nDigi; i++){
|
||||
for( int ch = 0; ch < digi[i]->GetNChannels(); ch ++){
|
||||
delete leTrigger[i][ch];
|
||||
}
|
||||
delete [] leTrigger[i];
|
||||
}
|
||||
delete [] leTrigger;
|
||||
leTrigger = NULL;
|
||||
printf("end of ____ %s \n", __func__);
|
||||
|
||||
}
|
||||
|
||||
//^###################################################################### Program Settings
|
||||
void MainWindow::ProgramSettings(){
|
||||
|
||||
|
@ -460,7 +541,6 @@ void MainWindow::ProgramSettings(){
|
|||
QObject::connect(button2, &QPushButton::clicked, this, [=](){this->LogMsg("Cancel <b>Program Settings</b>");});
|
||||
QObject::connect(button2, &QPushButton::clicked, &dialog, &QDialog::reject);
|
||||
|
||||
|
||||
layout->setColumnStretch(0, 2);
|
||||
layout->setColumnStretch(1, 2);
|
||||
layout->setColumnStretch(2, 2);
|
||||
|
@ -540,24 +620,7 @@ bool MainWindow::OpenProgramSettings(){
|
|||
|
||||
if( ret ){
|
||||
|
||||
//------- decode IPListStr
|
||||
nDigi = 0;
|
||||
QStringList parts = IPListStr.split(".");
|
||||
QString IPDomain = parts[0] + "." + parts[1] + "." + parts[2] + ".";
|
||||
parts = parts[3].split(",");
|
||||
for(int i = 0; i < parts.size(); i++){
|
||||
if( parts[i].indexOf("-") != -1){
|
||||
QStringList haha = parts[i].split("-");
|
||||
for( int j = haha[0].toInt(); j <= haha.last().toInt(); j++){
|
||||
IPList << IPDomain + QString::number(j);
|
||||
}
|
||||
}else{
|
||||
IPList << IPDomain + parts[i];
|
||||
}
|
||||
}
|
||||
|
||||
nDigi = IPList.size();
|
||||
|
||||
DecodeIPList();
|
||||
return true;
|
||||
|
||||
}else{
|
||||
|
@ -569,6 +632,26 @@ bool MainWindow::OpenProgramSettings(){
|
|||
}
|
||||
}
|
||||
|
||||
void MainWindow::DecodeIPList(){
|
||||
//------- decode IPListStr
|
||||
nDigi = 0;
|
||||
IPList.clear();
|
||||
QStringList parts = IPListStr.split(".");
|
||||
QString IPDomain = parts[0] + "." + parts[1] + "." + parts[2] + ".";
|
||||
parts = parts[3].split(",");
|
||||
for(int i = 0; i < parts.size(); i++){
|
||||
if( parts[i].indexOf("-") != -1){
|
||||
QStringList haha = parts[i].split("-");
|
||||
for( int j = haha[0].toInt(); j <= haha.last().toInt(); j++){
|
||||
IPList << IPDomain + QString::number(j);
|
||||
}
|
||||
}else{
|
||||
IPList << IPDomain + parts[i];
|
||||
}
|
||||
}
|
||||
nDigi = IPList.size();
|
||||
}
|
||||
|
||||
void MainWindow::SaveProgramSettings(){
|
||||
|
||||
IPListStr = lIPDomain->text();
|
||||
|
@ -600,6 +683,8 @@ void MainWindow::SaveProgramSettings(){
|
|||
bnNewExp->setEnabled(true);
|
||||
bnOpenDigitizers->setEnabled(true);
|
||||
|
||||
DecodeIPList();
|
||||
|
||||
OpenExpSettings();
|
||||
|
||||
}
|
||||
|
|
23
mainwindow.h
23
mainwindow.h
|
@ -42,9 +42,14 @@ private slots:
|
|||
void OpenScope();
|
||||
void OpenDigitizersSettings();
|
||||
|
||||
void OpenScaler();
|
||||
void SetUpScalar();
|
||||
void DeleteTriggerLineEdit();
|
||||
|
||||
void ProgramSettings();
|
||||
bool OpenProgramSettings();
|
||||
void SaveProgramSettings();
|
||||
void DecodeIPList();
|
||||
void OpenDirectory(int id);
|
||||
|
||||
void SetupNewExp();
|
||||
|
@ -54,7 +59,10 @@ private slots:
|
|||
void CreateRawDataFolderAndLink(const QString newExpName);
|
||||
|
||||
void closeEvent(QCloseEvent * event){
|
||||
printf("___ %s \n", __func__);
|
||||
printf("+++++++++++++++ digiSetting %p\n", digiSetting);
|
||||
if( digiSetting != NULL ) digiSetting->close();
|
||||
printf("+++++++++++++++ scope %p\n", scope);
|
||||
if( scope != NULL ) scope->close();
|
||||
event->accept();
|
||||
}
|
||||
|
@ -78,11 +86,20 @@ private:
|
|||
Scope * scope;
|
||||
QPushButton * bnOpenScope;
|
||||
|
||||
//@----- scalar;
|
||||
QMainWindow * scalar;
|
||||
QPushButton * bnOpenScalar;
|
||||
QLineEdit *** leTrigger; // need to delete manually
|
||||
QGridLayout * scalarLayout;
|
||||
|
||||
//@------ ACQ things
|
||||
QPushButton * bnStartACQ;
|
||||
QPushButton * bnStopACQ;
|
||||
QLineEdit * leRunID;
|
||||
QLineEdit * leRawDataPath;
|
||||
ReadDataThread ** readDataThread;
|
||||
void StartACQ();
|
||||
void StopACQ();
|
||||
|
||||
DigiSettings * digiSetting;
|
||||
|
||||
|
@ -90,12 +107,6 @@ private:
|
|||
|
||||
static Digitizer2Gen ** digi;
|
||||
unsigned short nDigi;
|
||||
std::vector<unsigned short> digiSerialNum;
|
||||
|
||||
void StartACQ();
|
||||
void StopACQ();
|
||||
|
||||
ReadDataThread ** readDataThread;
|
||||
|
||||
void LogMsg(QString msg);
|
||||
bool logMsgHTMLMode = true;
|
||||
|
|
Loading…
Reference in New Issue
Block a user