snapshot of digiSettingsPanel

This commit is contained in:
Ryan Tang 2023-02-23 16:08:47 -05:00
parent 7b42ab6d1b
commit f6f4d1b96d
11 changed files with 371 additions and 209 deletions

View File

@ -45,6 +45,7 @@ void Digitizer2Gen::Initialization(){
acqON = false;
settingFileName = "";
boardSettings = DIGIPARA::DIG::AllSettings;
for( int ch = 0; ch < MaxNumberOfChannel ; ch ++) chSettings[ch] = DIGIPARA::CH::AllSettings;
for( int index = 0 ; index < 4; index ++) VGASetting[index] = DIGIPARA::VGA::VGAGain;
@ -112,6 +113,18 @@ std::string Digitizer2Gen::ReadValue(Reg &para, int ch_index, bool verbose){
return para.GetValue();
}
std::string Digitizer2Gen::ReadValue(TYPE type, unsigned short index, int ch_index, bool verbose){
if( !isConnected ) return "not connected";
switch (type){
case TYPE::DIG: return ReadValue( boardSettings[index], ch_index, verbose );
case TYPE::CH: return ReadValue( chSettings[ch_index][index], ch_index, verbose );
case TYPE::VGA: return ReadValue( VGASetting[index], ch_index, verbose);
case TYPE::LVDS: return "no defined";
}
return "invalid";
}
std::string Digitizer2Gen::ReadDigValue(std::string shortPara, bool verbose){
std::string haha = "/par/" + shortPara;
return ReadValue(haha.c_str(), verbose);
@ -214,6 +227,9 @@ int Digitizer2Gen::OpenDigitizer(const char * url){
printf(" ADC rate : %d Msps, ch2ns : %d ns\n", adcRate, ch2ns);
printf(" Channels : %d\n", nChannels);
//------ set default setting file name
settingFileName = "settings_"+ std::to_string(serialNumber) + ".dat";
//ReadValue("/par/InputRange", true);
//ReadValue("/par/InputType", true);
//ReadValue("/par/Zin", true);
@ -723,6 +739,7 @@ std::string Digitizer2Gen::ErrorMsg(const char * funcName){
//^===================================================== Settings
void Digitizer2Gen::ReadAllSettings(){
if( !isConnected ) return;
for(int i = 0; i < (int) boardSettings.size(); i++){
if( boardSettings[i].ReadWrite() == RW::WriteOnly) continue;
ReadValue(boardSettings[i]);
@ -739,8 +756,10 @@ void Digitizer2Gen::ReadAllSettings(){
}
bool Digitizer2Gen::SaveSettingsToFile(const char * saveFileName){
//printf("Saving settings....\n");
FILE * saveFile = fopen(saveFileName, "w");
if( !isConnected ) return false;
if( saveFileName != NULL) settingFileName = saveFileName;
FILE * saveFile = fopen(settingFileName.c_str(), "w");
if( saveFile ){
for(int i = 0; i < (int) boardSettings.size(); i++){
if( boardSettings[i].ReadWrite() == RW::WriteOnly) continue;
@ -783,8 +802,9 @@ bool Digitizer2Gen::SaveSettingsToFile(const char * saveFileName){
bool Digitizer2Gen::LoadSettingsFromFile(const char * loadFileName){
FILE * loadFile = fopen(loadFileName, "r");
if( loadFileName != NULL) settingFileName = loadFileName;
FILE * loadFile = fopen(settingFileName.c_str(), "r");
if( loadFile ){
char * para = new char[100];
@ -837,7 +857,7 @@ bool Digitizer2Gen::LoadSettingsFromFile(const char * loadFileName){
VGASetting[id - 9000].SetValue(value);
}
//printf("%s|%s|%d|%s|\n", para, readWrite, id, value);
if( std::strcmp(readWrite, "2") == 0 ) WriteValue(para, value);
if( std::strcmp(readWrite, "2") == 0 && isConnected) WriteValue(para, value);
}

View File

@ -63,6 +63,7 @@ class Digitizer2Gen {
bool acqON;
//all read and read/write settings
std::string settingFileName;
std::vector<Reg> boardSettings;
std::vector<Reg> chSettings[MaxNumberOfChannel];
Reg VGASetting[4];
@ -84,6 +85,7 @@ class Digitizer2Gen {
std::string ReadValue(const char * parameter, bool verbose = false);
std::string ReadValue(Reg &para, int ch_index = -1, bool verbose = false);
std::string ReadValue(TYPE type, unsigned short index, int ch_index = -1, bool verbose = false);
std::string ReadDigValue(std::string shortPara, bool verbose = false);
std::string ReadChValue(std::string ch, std::string shortPara, bool verbose = false);
bool WriteValue(const char * parameter, std::string value);
@ -128,11 +130,20 @@ class Digitizer2Gen {
unsigned int GetFileSize() const {return outFileSize;}
uint64_t GetTotalFilesSize() const {return FinishedOutFilesSize + outFileSize;}
std::string GetSettingFileName() const {return settingFileName;}
void SetSettingFileName(std::string fileName) {settingFileName = fileName;}
void ReadAllSettings(); // read settings from digitier and save to memory
bool SaveSettingsToFile(const char * saveFileName); // ReadAllSettings + text file
bool LoadSettingsFromFile(const char * loadFileName); // Load settings, write to digitizer and save to memory
//void PrintAllSetting();
bool SaveSettingsToFile(const char * saveFileName = NULL); // ReadAllSettings + text file
bool LoadSettingsFromFile(const char * loadFileName = NULL); // Load settings, write to digitizer and save to memory
std::string GetSettingValue(TYPE type, unsigned short index, int ch_index = -1) const {
switch(type){
case TYPE::DIG: return boardSettings[index].GetValue();
case TYPE::CH: return chSettings[ch_index][index].GetValue();
case TYPE::VGA: return VGASetting[ch_index].GetValue();
case TYPE::LVDS: return "not defined";
}
return "invalid";
}
};
#endif

View File

@ -110,6 +110,7 @@ namespace DIGIPARA{
const Reg DPP_LicenseStatus ("LicenseStatus", RW::ReadOnly, TYPE::DIG);
const Reg DPP_LicenseRemainingTime ("LicenseRemainingTime", RW::ReadOnly, TYPE::DIG);
const Reg NumberOfChannel ("NumCh", RW::ReadOnly, TYPE::DIG);
const Reg ADC_bit ("ADC_Nbit", RW::ReadOnly, TYPE::DIG);
const Reg ADC_SampleRate ("ADC_SamplRate", RW::ReadOnly, TYPE::DIG);
const Reg InputDynamicRange ("InputRange", RW::ReadOnly, TYPE::DIG);
const Reg InputType ("InputType", RW::ReadOnly, TYPE::DIG);
@ -208,6 +209,7 @@ namespace DIGIPARA{
DPP_LicenseStatus ,
DPP_LicenseRemainingTime ,
NumberOfChannel ,
ADC_bit ,
ADC_SampleRate ,
InputDynamicRange ,
InputType ,

View File

@ -18,5 +18,5 @@ LIBS += -lcurl -lCAEN_FELib -lX11
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
# Input
HEADERS += ClassDigitizer2Gen.h Event.h influxdb.h mainwindow.h digiSettings.h Digiparameters.h scope.h manyThread.h
SOURCES += ClassDigitizer2Gen.cpp influxdb.cpp main.cpp mainwindow.cpp digiSettings.cpp scope.cpp
HEADERS += ClassDigitizer2Gen.h Event.h influxdb.h mainwindow.h digiSettingsPanel.h Digiparameters.h scope.h manyThread.h
SOURCES += ClassDigitizer2Gen.cpp influxdb.cpp main.cpp mainwindow.cpp digiSettingsPanel.cpp scope.cpp

View File

@ -1,128 +0,0 @@
#ifndef DigiSettings_H
#define DigiSettings_H
#include <QWidget>
#include <QLineEdit>
#include <QSpinBox>
#include <QDoubleSpinBox>
#include <QGridLayout>
#include <QScrollArea>
#include <QTabWidget>
#include <QGroupBox>
#include <QCheckBox>
#include <QComboBox>
#include <QTableWidget>
#include <QDebug>
#include <QPushButton>
#include <QFrame>
#include <QSignalMapper>
#include "ClassDigitizer2Gen.h"
#define MaxNumberOfDigitizer 10
class DigiSettings : public QWidget{
Q_OBJECT
public:
DigiSettings(Digitizer2Gen ** digi, unsigned short nDigi, QWidget * parent = nullptr);
~DigiSettings();
private slots:
void onReset(int id){
emit sendLogMsg("Reset Digitizer-" + QString::number(digi[id]->GetSerialNumber()));
digi[id]->Reset();
}
void onDefault(int id){
emit sendLogMsg("Program Digitizer-" + QString::number(digi[id]->GetSerialNumber()) + " to default PHA.");
digi[id]->ProgramPHA();
}
void onTriggerClick(int haha){
unsigned short iDig = haha >> 12;
unsigned short ch = (haha >> 8 ) & 0xF;
unsigned short ch2 = haha & 0xFF;
qDebug() << "Digi-" << iDig << ", Ch-" << ch << ", " << ch2;
if(bnClickStatus[ch][ch2]){
bn[ch][ch2]->setStyleSheet("");
bnClickStatus[ch][ch2] = false;
}else{
bn[ch][ch2]->setStyleSheet("background-color: red;");
bnClickStatus[ch][ch2] = true;
}
}
void onChannelonOff(int haha){
unsigned short iDig = haha >> 12;
//qDebug()<< "nDigi-" << iDig << ", ch-" << (haha & 0xFF);
if( (haha & 0xFF) == 64){
if( cbCh[iDig][64]->isChecked() ){
for( int i = 0 ; i < digi[iDig]->GetNChannels() ; i++){
cbCh[iDig][i]->setChecked(true);
}
}else{
for( int i = 0 ; i < digi[iDig]->GetNChannels() ; i++){
cbCh[iDig][i]->setChecked(false);
}
}
}else{
unsigned int nOn = 0;
for( int i = 0; i < digi[iDig]->GetNChannels(); i++){
nOn += (cbCh[iDig][i]->isChecked() ? 1 : 0);
}
if( nOn == 64){
cbCh[iDig][64]->setChecked(true);
}else{
cbCh[iDig][64]->setChecked(false);
}
}
}
signals:
void sendLogMsg(const QString &msg);
private:
Digitizer2Gen ** digi;
unsigned short nDigi;
QPushButton *bn[MaxNumberOfChannel][MaxNumberOfChannel];
bool bnClickStatus[MaxNumberOfChannel][MaxNumberOfChannel];
QCheckBox * cbCh[MaxNumberOfDigitizer][MaxNumberOfChannel + 1]; // index = 64 is for all channels
QSpinBox * sbRecordLength[MaxNumberOfChannel + 1];
QSpinBox * sbPreTrigger[MaxNumberOfChannel + 1];
QComboBox * cmbWaveRes[MaxNumberOfChannel + 1];
QComboBox * cmbAnaProbe0[MaxNumberOfChannel + 1];
QComboBox * cmbAnaProbe1[MaxNumberOfChannel + 1];
QComboBox * cmbDigProbe0[MaxNumberOfChannel + 1];
QComboBox * cmbDigProbe1[MaxNumberOfChannel + 1];
QComboBox * cmbDigProbe2[MaxNumberOfChannel + 1];
QComboBox * cmbDigProbe3[MaxNumberOfChannel + 1];
QComboBox * cmbEvtTrigger[MaxNumberOfChannel + 1];
QComboBox * cmbWaveTrigger[MaxNumberOfChannel + 1];
QComboBox * cmbWaveSave[MaxNumberOfChannel + 1];
QComboBox * cmbWaveSource[MaxNumberOfChannel + 1];
QComboBox * cmbChVetoSrc[MaxNumberOfChannel + 1];
QSpinBox * sbChADCVetoWidth[MaxNumberOfChannel + 1];
};
#endif

View File

@ -1,87 +1,98 @@
#include "digiSettings.h"
#include "digiSettingsPanel.h"
#include <QLabel>
#include <QFileDialog>
DigiSettings::DigiSettings(Digitizer2Gen ** digi, unsigned short nDigi, QWidget * parent) : QWidget(parent){
std::vector<std::pair<std::string, int>> infoIndex = {{"Serial Num : ", 8},
{"IP : ", 20},
{"Model Name : ", 5},
{"FPGA version : ", 1},
{"DPP Type : ", 2},
{"CUP version : ", 0},
{"ADC bits : ", 15},
{"ADC rate [Msps] : ", 16},
{"Num. of Channel : ", 14},
{"Input range [Vpp] : ", 17},
{"Input Type : ", 18},
{"Input Impedance [Ohm] : ", 19}
};
qDebug() << "DigiSettings constructor";
DigiSettingsPanel::DigiSettingsPanel(Digitizer2Gen ** digi, unsigned short nDigi, QWidget * parent) : QWidget(parent){
qDebug() << "DigiSettingsPanel constructor";
setWindowTitle("Digitizers Settings");
setGeometry(0, 0, 1900, 1000);
setGeometry(0, 0, 1600, 1000);
//setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
this->digi = digi;
this->nDigi = nDigi;
if( nDigi > MaxNumberOfDigitizer ) {
this->nDigi = MaxNumberOfChannel;
qDebug() << "Please increase the MaxNumberOfChannel";
}
std::vector<std::vector<std::string>> info = {{"Serial Num : ", "/par/SerialNum"},
{"IP : ", "/par/IPAddress"},
{"Model Name : ", "/par/ModelName"},
{"FPGA version : ", "/par/FPGA_FwVer"},
{"DPP Type : ", "/par/FwType"},
{"CUP version : ", "/par/cupver"},
{"ADC bits : ", "/par/ADC_Nbit"},
{"ADC rate [Msps] : ", "/par/ADC_SamplRate"},
{"Num. of Channel : ", "/par/NumCh"},
{"Input range [Vpp] : ", "/par/InputRange"},
{"Input Type : ", "/par/InputType"},
{"Input Impedance [Ohm] : ", "/par/Zin"}
};
ID = 0;
QVBoxLayout * mainLayout = new QVBoxLayout(this); this->setLayout(mainLayout);
QTabWidget * tabWidget = new QTabWidget(this); mainLayout->addWidget(tabWidget);
connect(tabWidget, &QTabWidget::currentChanged, this, [=](int index){ ID = index;});
//@========================== Tab for each digitizer
for(unsigned short iDigi = 0; iDigi < this->nDigi; iDigi++){
QWidget * tab = new QWidget(tabWidget);
QScrollArea * scrollArea = new QScrollArea(this); scrollArea->setWidget(tab);
QScrollArea * scrollArea = new QScrollArea(this);
scrollArea->setWidgetResizable(true);
scrollArea->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
tabWidget->addTab(scrollArea, "Digi-" + QString::number(digi[iDigi]->GetSerialNumber()));
QGridLayout *tabLayout = new QGridLayout(tab); tab->setLayout(tabLayout);
QWidget * tab = new QWidget(tabWidget);
scrollArea->setWidget(tab);
QHBoxLayout * tabLayout_H = new QHBoxLayout(tab); //tab->setLayout(tabLayout_H);
QVBoxLayout * tabLayout_V1 = new QVBoxLayout(); tabLayout_H->addLayout(tabLayout_V1);
QVBoxLayout * tabLayout_V2 = new QVBoxLayout(); tabLayout_H->addLayout(tabLayout_V2);
{//^====================== Group of Digitizer Info
QGroupBox * infoBox = new QGroupBox("Board Info", tab);
QGridLayout * infoLayout = new QGridLayout(infoBox);
tabLayout->addWidget(infoBox, 0, 0);
tabLayout_V1->addWidget(infoBox);
const unsigned short nRow = 4;
for( unsigned short j = 0; j < (unsigned short) info.size(); j++){
QLabel * lab = new QLabel(QString::fromStdString(info[j][0]), tab);
for( unsigned short j = 0; j < (unsigned short) infoIndex.size(); j++){
QLabel * lab = new QLabel(QString::fromStdString(infoIndex[j].first), tab);
lab->setAlignment(Qt::AlignRight);
QLineEdit * txt = new QLineEdit(tab);
txt->setReadOnly(true);
txt->setText(QString::fromStdString(digi[iDigi]->ReadValue(info[j][1].c_str())));
leInfo[iDigi][j] = new QLineEdit(tab);
leInfo[iDigi][j]->setReadOnly(true);
leInfo[iDigi][j]->setText(QString::fromStdString(digi[iDigi]->ReadValue(TYPE::DIG, infoIndex[j].second)));
infoLayout->addWidget(lab, j%nRow, 2*(j/nRow));
infoLayout->addWidget(txt, j%nRow, 2*(j/nRow) +1);
infoLayout->addWidget(leInfo[iDigi][j], j%nRow, 2*(j/nRow) +1);
}
}
{//^====================== Group Board status
QGroupBox * statusBox = new QGroupBox("Board Status", tab);
QSizePolicy sizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
sizePolicy.setHorizontalStretch(0);
sizePolicy.setVerticalStretch(0);
statusBox->setSizePolicy(sizePolicy);
//QSizePolicy sizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
//sizePolicy.setHorizontalStretch(0);
//sizePolicy.setVerticalStretch(0);
//statusBox->setSizePolicy(sizePolicy);
QGridLayout * statusLayout = new QGridLayout(statusBox);
statusLayout->setHorizontalSpacing(0);
tabLayout->addWidget(statusBox, 0, 1);
tabLayout_V1->addWidget(statusBox);
//------- LED Status
QLabel * lbLED = new QLabel("LED status : ");
lbLED->setAlignment(Qt::AlignRight | Qt::AlignCenter);
statusLayout->addWidget(lbLED, 0, 0);
QPushButton ** LEDStatus = new QPushButton *[19];
for( int i = 0; i < 19; i++){
LEDStatus[i] = new QPushButton(tab);
LEDStatus[i]->setEnabled(false);
LEDStatus[i]->setFixedSize(QSize(30,30));
statusLayout->addWidget(LEDStatus[i], 0, 1 + i);
LEDStatus[iDigi][i] = new QPushButton(tab);
LEDStatus[iDigi][i]->setEnabled(false);
LEDStatus[iDigi][i]->setFixedSize(QSize(30,30));
statusLayout->addWidget(LEDStatus[iDigi][i], 0, 1 + i);
}
//------- ACD Status
@ -89,12 +100,11 @@ DigiSettings::DigiSettings(Digitizer2Gen ** digi, unsigned short nDigi, QWidget
lbACQ->setAlignment(Qt::AlignRight | Qt::AlignCenter);
statusLayout->addWidget(lbACQ, 1, 0);
QPushButton ** ACQStatus = new QPushButton *[7];
for( int i = 0; i < 7; i++){
ACQStatus[i] = new QPushButton(tab);
ACQStatus[i]->setEnabled(false);
ACQStatus[i]->setFixedSize(QSize(30,30));
statusLayout->addWidget(ACQStatus[i], 1, 1 + i);
ACQStatus[iDigi][i] = new QPushButton(tab);
ACQStatus[iDigi][i]->setEnabled(false);
ACQStatus[iDigi][i]->setFixedSize(QSize(30,30));
statusLayout->addWidget(ACQStatus[iDigi][i], 1, 1 + i);
}
//------- Temperatures
@ -109,30 +119,52 @@ DigiSettings::DigiSettings(Digitizer2Gen ** digi, unsigned short nDigi, QWidget
leTemp[i]->setEnabled(false);
statusLayout->addWidget(leTemp[i], 2, 1 + 2*i, 1, 2);
}
}
{//^====================== Board Setting Buttons
QGridLayout * bnLayout = new QGridLayout();
tabLayout_V2->addLayout(bnLayout);
int rowId = 0;
//-------------------------------------
QLabel * lbSettingFile = new QLabel("Setting File : ", tab);
lbSettingFile->setAlignment(Qt::AlignRight | Qt::AlignCenter);
bnLayout->addWidget(lbSettingFile, rowId, 0);
leSettingFile[iDigi] = new QLineEdit(tab);
leSettingFile[iDigi]->setReadOnly(true);
bnLayout->addWidget(leSettingFile[iDigi], rowId, 1, 1, 9);
//-------------------------------------
rowId ++;
QPushButton * bnReadSettngs = new QPushButton("Refresh Settings", tab);
bnLayout->addWidget(bnReadSettngs, rowId, 0, 1, 2);
connect(bnReadSettngs, &QPushButton::clicked, this, &DigiSettingsPanel::RefreshSettings);
QPushButton * bnResetBd = new QPushButton("Reset Board", tab);
bnLayout->addWidget(bnResetBd, rowId, 2, 1, 2);
connect(bnResetBd, &QPushButton::clicked, this, &DigiSettingsPanel::onReset);
QPushButton * bnDefaultSetting = new QPushButton("Set Default Settings", tab);
bnLayout->addWidget(bnDefaultSetting, rowId, 4, 1, 2);
connect(bnDefaultSetting, &QPushButton::clicked, this, &DigiSettingsPanel::onDefault);
QPushButton * bnSaveSettings = new QPushButton("Save Settings", tab);
bnLayout->addWidget(bnSaveSettings, rowId, 6, 1, 2);
connect(bnSaveSettings, &QPushButton::clicked, this, &DigiSettingsPanel::SaveSettings);
QPushButton * bnLoadSettings = new QPushButton("Load Settings", tab);
bnLayout->addWidget(bnLoadSettings, rowId, 8, 1, 2);
connect(bnLoadSettings, &QPushButton::clicked, this, &DigiSettingsPanel::LoadSettings);
}
{//^====================== Group Board settings
QGroupBox * digiBox = new QGroupBox("Board Settings", tab);
QGridLayout * boardLayout = new QGridLayout(digiBox);
tabLayout->addWidget(digiBox, 1, 0);
tabLayout_V2->addWidget(digiBox);
int rowId = 0;
//-------------------------------------
QPushButton * bnResetBd = new QPushButton("Reset Board", tab);
boardLayout->addWidget(bnResetBd, rowId, 0, 1, 2);
connect(bnResetBd, &QPushButton::clicked, this, &DigiSettings::onReset);
QPushButton * bnDefaultSetting = new QPushButton("Set Default Settings", tab);
boardLayout->addWidget(bnDefaultSetting, rowId, 2, 1, 2);
connect(bnDefaultSetting, &QPushButton::clicked, this, &DigiSettings::onDefault);
QPushButton * bnSaveSettings = new QPushButton("Save Settings", tab);
boardLayout->addWidget(bnSaveSettings, rowId, 4, 1, 2);
QPushButton * bnLoadSettings = new QPushButton("Load Settings", tab);
boardLayout->addWidget(bnLoadSettings, rowId, 6, 1, 2);
//-------------------------------------
rowId ++;
QLabel * lbClockSource = new QLabel("Clock Source :", tab);
@ -332,12 +364,13 @@ DigiSettings::DigiSettings(Digitizer2Gen ** digi, unsigned short nDigi, QWidget
{//^====================== Group channel settings
QGroupBox * chBox = new QGroupBox("Channel Settings", tab); tabLayout->addWidget(chBox, 1, 1, 1, 1);
QGroupBox * chBox = new QGroupBox("Channel Settings", tab);
tabLayout_V2->addWidget(chBox);
QGridLayout * chLayout = new QGridLayout(chBox); //chBox->setLayout(chLayout);
QSignalMapper * onOffMapper = new QSignalMapper(tab);
connect(onOffMapper, &QSignalMapper::mappedInt, this, &DigiSettings::onChannelonOff);
connect(onOffMapper, &QSignalMapper::mappedInt, this, &DigiSettingsPanel::onChannelonOff);
QTabWidget * chTabWidget = new QTabWidget(tab); chLayout->addWidget(chTabWidget);
@ -392,7 +425,7 @@ DigiSettings::DigiSettings(Digitizer2Gen ** digi, unsigned short nDigi, QWidget
QGroupBox * triggerBox = new QGroupBox("Trigger Map", tab);
QGridLayout * triggerLayout = new QGridLayout(triggerBox);
//triggerBox->setLayout(triggerLayout);
tabLayout->addWidget(triggerBox, 2, 0);
tabLayout_V1->addWidget(triggerBox);
triggerLayout->setHorizontalSpacing(0);
triggerLayout->setVerticalSpacing(0);
@ -401,7 +434,7 @@ DigiSettings::DigiSettings(Digitizer2Gen ** digi, unsigned short nDigi, QWidget
triggerLayout->addWidget(instr, 0, 0, 1, 64+15);
QSignalMapper * triggerMapper = new QSignalMapper(tab);
connect(triggerMapper, &QSignalMapper::mappedInt, this, &DigiSettings::onTriggerClick);
connect(triggerMapper, &QSignalMapper::mappedInt, this, &DigiSettingsPanel::onTriggerClick);
int rowID = 1;
int colID = 0;
@ -451,7 +484,7 @@ DigiSettings::DigiSettings(Digitizer2Gen ** digi, unsigned short nDigi, QWidget
}
DigiSettings::~DigiSettings(){
DigiSettingsPanel::~DigiSettingsPanel(){
printf("%s\n", __func__);
@ -461,3 +494,125 @@ DigiSettings::~DigiSettings(){
}
}
}
//^================================================================
void DigiSettingsPanel::onTriggerClick(int haha){
unsigned short iDig = haha >> 12;
unsigned short ch = (haha >> 8 ) & 0xF;
unsigned short ch2 = haha & 0xFF;
qDebug() << "Digi-" << iDig << ", Ch-" << ch << ", " << ch2;
if(bnClickStatus[ch][ch2]){
bn[ch][ch2]->setStyleSheet("");
bnClickStatus[ch][ch2] = false;
}else{
bn[ch][ch2]->setStyleSheet("background-color: red;");
bnClickStatus[ch][ch2] = true;
}
}
void DigiSettingsPanel::onChannelonOff(int haha){
unsigned short iDig = haha >> 12;
//qDebug()<< "nDigi-" << iDig << ", ch-" << (haha & 0xFF);
if( (haha & 0xFF) == 64){
if( cbCh[iDig][64]->isChecked() ){
for( int i = 0 ; i < digi[iDig]->GetNChannels() ; i++){
cbCh[iDig][i]->setChecked(true);
}
}else{
for( int i = 0 ; i < digi[iDig]->GetNChannels() ; i++){
cbCh[iDig][i]->setChecked(false);
}
}
}else{
unsigned int nOn = 0;
for( int i = 0; i < digi[iDig]->GetNChannels(); i++){
nOn += (cbCh[iDig][i]->isChecked() ? 1 : 0);
}
if( nOn == 64){
cbCh[iDig][64]->setChecked(true);
}else{
cbCh[iDig][64]->setChecked(false);
}
}
}
//^================================================================
void DigiSettingsPanel::onReset(){
emit sendLogMsg("Reset Digitizer-" + QString::number(digi[ID]->GetSerialNumber()));
digi[ID]->Reset();
}
void DigiSettingsPanel::onDefault(){
emit sendLogMsg("Program Digitizer-" + QString::number(digi[ID]->GetSerialNumber()) + " to default PHA.");
digi[ID]->ProgramPHA();
}
void DigiSettingsPanel::RefreshSettings(){
digi[ID]->ReadAllSettings();
ShowSettingsToPanel();
}
void DigiSettingsPanel::SaveSettings(){
}
void DigiSettingsPanel::LoadSettings(){
QFileDialog fileDialog(this);
fileDialog.setFileMode(QFileDialog::ExistingFile);
fileDialog.setNameFilter("Data file (*.dat);;Text file (*.txt);;All file (*.*)");
fileDialog.exec();
QString fileName = fileDialog.selectedFiles().at(0);
leSettingFile[ID]->setText(fileName);
//TODO ==== check is the file valid;
if( digi[ID]->LoadSettingsFromFile(fileName.toStdString().c_str()) ){
emit sendLogMsg("Loaded settings file " + fileName + " for Digi-" + QString::number(digi[ID]->GetSerialNumber()));
}else{
emit sendLogMsg("Fail to Loaded settings file " + fileName + " for Digi-" + QString::number(digi[ID]->GetSerialNumber()));
}
//TODO ==== show result
ShowSettingsToPanel();
}
void DigiSettingsPanel::ShowSettingsToPanel(){
for (unsigned short j = 0; j < (unsigned short) infoIndex.size(); j++){
leInfo[ID][j]->setText(QString::fromStdString(digi[ID]->GetSettingValue(TYPE::DIG, infoIndex[j].second)));
}
//--------- LED Status
unsigned int ledStatus = atoi(digi[ID]->GetSettingValue(TYPE::DIG, 23).c_str());
for( int i = 0; i < 19; i++){
if( (ledStatus >> i) & 0x1 ) {
LEDStatus[ID][i]->setStyleSheet("background-color:green;");
}else{
LEDStatus[ID][i]->setStyleSheet("");
}
}
//--------- ACQ Status
unsigned int acqStatus = atoi(digi[ID]->GetSettingValue(TYPE::DIG, 24).c_str());
for( int i = 0; i < 7; i++){
if( (acqStatus >> i) & 0x1 ) {
ACQStatus[ID][i]->setStyleSheet("background-color:green;");
}else{
ACQStatus[ID][i]->setStyleSheet("");
}
}
}

96
digiSettingsPanel.h Normal file
View File

@ -0,0 +1,96 @@
#ifndef DigiSettings_H
#define DigiSettings_H
#include <QWidget>
#include <QLineEdit>
#include <QSpinBox>
#include <QDoubleSpinBox>
#include <QGridLayout>
#include <QScrollArea>
#include <QTabWidget>
#include <QGroupBox>
#include <QCheckBox>
#include <QComboBox>
#include <QTableWidget>
#include <QDebug>
#include <QPushButton>
#include <QFrame>
#include <QSignalMapper>
#include "ClassDigitizer2Gen.h"
#define MaxNumberOfDigitizer 20
class DigiSettingsPanel : public QWidget{
Q_OBJECT
public:
DigiSettingsPanel(Digitizer2Gen ** digi, unsigned short nDigi, QWidget * parent = nullptr);
~DigiSettingsPanel();
private slots:
void onTriggerClick(int haha);
void onChannelonOff(int haha);
void onReset();
void onDefault();
void RefreshSettings();
void SaveSettings();
void LoadSettings();
signals:
void sendLogMsg(const QString &msg);
private:
Digitizer2Gen ** digi;
unsigned short nDigi;
unsigned short ID; // index for digitizer;
void ShowSettingsToPanel();
QLineEdit * leInfo[MaxNumberOfChannel][12];
QPushButton * LEDStatus[MaxNumberOfDigitizer][19];
QPushButton * ACQStatus[MaxNumberOfDigitizer][19];
QPushButton *bn[MaxNumberOfChannel][MaxNumberOfChannel];
bool bnClickStatus[MaxNumberOfChannel][MaxNumberOfChannel];
QCheckBox * cbCh[MaxNumberOfDigitizer][MaxNumberOfChannel + 1]; // index = 64 is for all channels
QSpinBox * sbRecordLength[MaxNumberOfChannel + 1];
QSpinBox * sbPreTrigger[MaxNumberOfChannel + 1];
QComboBox * cmbWaveRes[MaxNumberOfChannel + 1];
QComboBox * cmbAnaProbe0[MaxNumberOfChannel + 1];
QComboBox * cmbAnaProbe1[MaxNumberOfChannel + 1];
QComboBox * cmbDigProbe0[MaxNumberOfChannel + 1];
QComboBox * cmbDigProbe1[MaxNumberOfChannel + 1];
QComboBox * cmbDigProbe2[MaxNumberOfChannel + 1];
QComboBox * cmbDigProbe3[MaxNumberOfChannel + 1];
QComboBox * cmbEvtTrigger[MaxNumberOfChannel + 1];
QComboBox * cmbWaveTrigger[MaxNumberOfChannel + 1];
QComboBox * cmbWaveSave[MaxNumberOfChannel + 1];
QComboBox * cmbWaveSource[MaxNumberOfChannel + 1];
QComboBox * cmbChVetoSrc[MaxNumberOfChannel + 1];
QSpinBox * sbChADCVetoWidth[MaxNumberOfChannel + 1];
QLineEdit * leSettingFile[MaxNumberOfDigitizer];
};
#endif

View File

@ -496,8 +496,10 @@ void MainWindow::OpenDigitizers(){
QString settingFile = analysisPath + "/settings_" + QString::number(digi[i]->GetSerialNumber()) + ".dat";
if( digi[i]->LoadSettingsFromFile( settingFile.toStdString().c_str() ) ){
LogMsg("Found setting file <b>" + settingFile + "</b> and loaded.");
digi[i]->SetSettingFileName(settingFile.toStdString());
}else{
LogMsg("<font style=\"color: red;\">Unable to found setting file <b>" + settingFile + "</b>. </font>");
digi[i]->SetSettingFileName("");
}
SetUpScalar();
@ -579,8 +581,8 @@ void MainWindow::OpenDigitizersSettings(){
LogMsg("Open digitizers Settings Panel");
if( digiSetting == NULL){
digiSetting = new DigiSettings(digi, nDigi);
connect(digiSetting, &DigiSettings::sendLogMsg, this, &MainWindow::LogMsg);
digiSetting = new DigiSettingsPanel(digi, nDigi);
connect(digiSetting, &DigiSettingsPanel::sendLogMsg, this, &MainWindow::LogMsg);
digiSetting->show();
}else{
digiSetting->show();

View File

@ -24,7 +24,7 @@
#include "manyThread.h"
#include "digiSettings.h"
#include "digiSettingsPanel.h"
#include "scope.h"
const int chromeWindowID = 10485763;
@ -120,7 +120,7 @@ private:
QString startComment;
QString stopComment;
DigiSettings * digiSetting;
DigiSettingsPanel * digiSetting;
QPlainTextEdit * logInfo;

View File

@ -26,3 +26,7 @@ influxdb.o : influxdb.cpp influxdb.h
windowID : windowID.cpp
@echo "------- windowID"
${CC} ${COPTS} -o windowID windowID.cpp -lX11 -lpng
clean :
rm -f $(ALL) $(OBJS)

View File

@ -94,11 +94,11 @@ int main(int argc, char* argv[]){
//printf("--------%s \n", digi->ReadChValue("0..63", "WaveAnalogprobe0", true).c_str());
//digi->SaveSettingsToFile(("settings_" + std::to_string(digi->GetSerialNumber()) + ".dat").c_str());
digi->SaveSettingsToFile(("settings_" + std::to_string(digi->GetSerialNumber()) + ".dat").c_str());
printf("===================================\n");
digi->LoadSettingsFromFile("settings_21245.dat");
//digi->LoadSettingsFromFile("settings_21245.dat");
//printf("%s \n", digi->ReadValue("/ch/0/par/ChRealtimeMonitor").c_str());
//printf("%s \n", digi->ReadValue("/ch/0/par/Energy_Nbit").c_str());
//printf("%s \n", digi->ReadValue("/par/MaxRawDataSize").c_str());