bug fix on loading setting. DigiPanel Combox = Mixed when channels has mixed setting

This commit is contained in:
splitPoleDAQ 2024-01-24 12:58:50 -05:00
parent 9398bfbe16
commit 7e3aaf9c83
2 changed files with 26 additions and 17 deletions

View File

@ -7,6 +7,8 @@
#include <QDir>
#include <QFileDialog>
#include <QSortFilterProxyModel>
#define ComBoxMixed "Mixed"
// bit = 0, bit = 1
std::vector<std::pair<std::pair<QString, QString>, unsigned short>> ACQToolTip = {{{"ACQ STOP", "ACQ RUN"}, 2},
{{"No Event", "Has Events"}, 3},
@ -36,7 +38,7 @@ DigiSettingsPanel::DigiSettingsPanel(Digitizer ** digi, unsigned int nDigi, QStr
enableSignalSlot = false;
setWindowTitle("Digitizer Settings");
setGeometry(0, 0, 1600, 850);
setGeometry(0, 0, 1700, 850);
tabWidget = new QTabWidget(this);
setCentralWidget(tabWidget);
@ -368,7 +370,7 @@ void DigiSettingsPanel::SetUpComboBoxBit(RComboBox * &cb, QString label, QGridLa
cb = new RComboBox(this);
gLayout->addWidget(cb, row, col + 1, 1, colspan);
if( ch < 0 ) cb->addItem("", -999);
if( ch < 0 ) cb->addItem(ComBoxMixed, -999);
for(int i = 0; i < (int) items.size(); i++){
cb->addItem(QString::fromStdString(items[i].first), items[i].second);
@ -377,7 +379,7 @@ void DigiSettingsPanel::SetUpComboBoxBit(RComboBox * &cb, QString label, QGridLa
connect(cb, &RComboBox::currentIndexChanged, this, [=](){
if( !enableSignalSlot ) return;
if( ch == -1 && cb->currentText() == "" ) return;
if( ch == -1 && cb->currentText() == ComBoxMixed ) return;
int chID = ch < 0 ? chSelection[ID]->currentData().toInt() : ch;
@ -397,7 +399,7 @@ void DigiSettingsPanel::SetUpComboBox(RComboBox * &cb, QString label, QGridLayou
cb = new RComboBox(this);
gLayout->addWidget(cb, row, col + 1);
if( ch < 0 ) cb->addItem("", -999);
if( ch < 0 ) cb->addItem(ComBoxMixed, -999);
std::vector<std::pair<std::string, unsigned int>> items = para.GetComboList();
for(int i = 0; i < (int) items.size(); i++){
@ -407,7 +409,7 @@ void DigiSettingsPanel::SetUpComboBox(RComboBox * &cb, QString label, QGridLayou
connect(cb, &RComboBox::currentIndexChanged, this, [=](){
if( !enableSignalSlot ) return;
if( ch == -1 && cb->currentText() == "" ) return;
if( ch == -1 && cb->currentText() == ComBoxMixed ) return;
int chID = ch < 0 ? chSelection[ID]->currentData().toInt() : ch;
digi[ID]->WriteRegister(para, cb->currentData().toUInt(), chID);
@ -1386,7 +1388,7 @@ void DigiSettingsPanel::SetUpACQReadOutTab(){
//&###########################################################
void DigiSettingsPanel::SetUpBoard_PHA(){
printf("============== %s \n", __func__);
printf("============== DigiSettingsPanel::%s \n", __func__);
SetUpCheckBox(chkAutoDataFlush[ID], "Auto Data Flush", bdCfgLayout[ID], 1, 0, DPP::BoardConfiguration, DPP::Bit_BoardConfig::EnableAutoDataFlush);
SetUpCheckBox(chkTrigPropagation[ID], "Trig. Propagate", bdCfgLayout[ID], 2, 0, DPP::BoardConfiguration, DPP::Bit_BoardConfig::TrigPropagation);
@ -1843,7 +1845,7 @@ void DigiSettingsPanel::SetUpChannel_PHA(){
//&###########################################################
void DigiSettingsPanel::SetUpBoard_PSD(){
printf("============== %s \n", __func__);
printf("============== DigiSettingsPanel::%s \n", __func__);
SetUpCheckBox(chkAutoDataFlush[ID], "Auto Data Flush", bdCfgLayout[ID], 1, 0, DPP::BoardConfiguration, DPP::Bit_BoardConfig::EnableAutoDataFlush);
SetUpCheckBox(chkTrigPropagation[ID], "Trig. Propagate", bdCfgLayout[ID], 2, 0, DPP::BoardConfiguration, DPP::Bit_BoardConfig::TrigPropagation);
@ -2425,7 +2427,7 @@ void DigiSettingsPanel::SetUpChannel_PSD(){
//&###########################################################
void DigiSettingsPanel::SetUpBoard_QDC(){
printf("============== %s \n", __func__);
printf("============== DigiSettingsPanel::%s \n", __func__);
SetUpCheckBox(chkTraceRecording[ID], "Record Trace ", bdCfgLayout[ID], 1, 1, DPP::BoardConfiguration, DPP::Bit_BoardConfig::RecordTrace);
SetUpCheckBox(chkEnableExtra2[ID], "Enable Extra ", bdCfgLayout[ID], 1, 2, DPP::BoardConfiguration, DPP::Bit_BoardConfig::EnableExtra2);
@ -3502,7 +3504,7 @@ void DigiSettingsPanel::SyncComboBox(RComboBox *(&cb)[][MaxRegChannel+1]){
//printf("%d =? %d , %s\n", count, nCh, text.toStdString().c_str());
enableSignalSlot = false;
if( count != nCh ){
cb[ID][nCh]->setCurrentText("");
cb[ID][nCh]->setCurrentText(ComBoxMixed);
}else{
cb[ID][nCh]->setCurrentText(text);
}
@ -4075,7 +4077,7 @@ void DigiSettingsPanel::LoadSetting(){
if( digi[ID]->LoadSettingBinaryToMemory(fileName.toStdString().c_str()) == 0 ){
SendLogMsg("Loaded settings file " + fileName + " for Digi-" + QString::number(digi[ID]->GetSerialNumber()));
leSaveFilePath[ID]->setText(fileName + " | dynamic update");
leSaveFilePath[ID]->setText(fileName);
digi[ID]->ProgramSettingsToBoard();
UpdatePanelFromMemory();

View File

@ -64,8 +64,8 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent){
cbOpenMethod = new RComboBox(this);
cbOpenMethod->addItem("w/o settings", 0);
cbOpenMethod->addItem("default Program", 1);
cbOpenMethod->addItem("w/ settings", 1);
cbOpenMethod->addItem("default Program", 2);
layout->addWidget(cbOpenMethod, 1, 0);
bnCloseDigitizers = new QPushButton("Close Digitizers", this);
@ -628,12 +628,12 @@ void MainWindow::OpenDigitizers(){
digi[i] = new Digitizer(portList[i].first, portList[i].second);
//digi[i]->Reset();
if( cbOpenMethod->currentData().toInt() == 1 ) {
if( cbOpenMethod->currentData().toInt() == 2 ) {
digi[i]->ProgramBoard();
}
///============== load settings
if( cbOpenMethod->currentData().toInt() == 2 ){
if( cbOpenMethod->currentData().toInt() <= 1 ){
QString fileName = rawDataPath + "/Digi-" + QString::number(digi[i]->GetSerialNumber()) + "_" + QString::fromStdString(digi[i]->GetData()->DPPTypeStr) + ".bin";
QFile file(fileName);
if( !file.open(QIODevice::Text | QIODevice::ReadOnly) ) {
@ -655,12 +655,19 @@ void MainWindow::OpenDigitizers(){
}
}else{
LogMsg("Found <b>" + fileName + "</b> for digitizer settings.");
if( digi[i]->LoadSettingBinaryToMemory(fileName.toStdString().c_str()) == 0 ){
LogMsg("Loaded settings file <b>" + fileName + "</b> for Digi-" + QString::number(digi[i]->GetSerialNumber()));
digi[i]->ProgramSettingsToBoard();
if( cbOpenMethod->currentData().toInt() == 1 ){
if( digi[i]->LoadSettingBinaryToMemory(fileName.toStdString().c_str()) == 0 ){
LogMsg("Loaded settings file <b>" + fileName + "</b> for Digi-" + QString::number(digi[i]->GetSerialNumber()));
digi[i]->ProgramSettingsToBoard();
}else{
LogMsg("Fail to Loaded settings file " + fileName + " for Digi-" + QString::number(digi[i]->GetSerialNumber()));
}
}else{
LogMsg("Fail to Loaded settings file " + fileName + " for Digi-" + QString::number(digi[i]->GetSerialNumber()));
LogMsg("Save the setting file path, but not load.");
digi[i]->SetSettingBinaryPath(fileName.toStdString());
}
}
}
digi[i]->ReadAllSettingsFromBoard(true);