modified UI for open digitizer. when click on update Setting, it will overwrite the setting file to make sure the setting is updated

This commit is contained in:
splitPoleDAQ 2024-01-19 14:15:37 -05:00
parent 187b3b5b7f
commit 96e3d2a007
5 changed files with 35 additions and 27 deletions

View File

@ -39,7 +39,7 @@ void Digitizer::Initalization(){
isSettingFilledinMemeory = false;
settingFileName = "";
isSettingFileExist = false;
isSettingFileCoupled = false;
isSettingFileUpdate = false;
settingFile = NULL;
ret = -1;
@ -1020,9 +1020,9 @@ unsigned int Digitizer::ReadSettingFromFile(Reg registerAddress, unsigned short
void Digitizer::SaveSettingToFile(Reg registerAddress, unsigned int value, unsigned short ch){
if ( !isSettingFileExist ) return ;
if ( !isSettingFileCoupled ) return;
if ( !isSettingFileUpdate ) return;
printf("Write setting file : %s. %s, ch:%u, 0x%8X\n", settingFileName.c_str(), registerAddress.GetNameChar(), ch, value);
// printf("Write setting file : %s. %s, ch:%u, 0x%8X\n", settingFileName.c_str(), registerAddress.GetNameChar(), ch, value);
unsigned short index = registerAddress.Index(ch);
setting[index] = value;

View File

@ -54,7 +54,7 @@ class Digitizer{
std::string settingFileName; ///
FILE * settingFile; ///
bool isSettingFileExist; ///
bool isSettingFileCoupled;
bool isSettingFileUpdate;
bool isSettingFilledinMemeory; /// false for disabled ReadAllSettingFromBoard()
unsigned int setting[SETTINGSIZE]; /// Setting, 4bytes x 2048 = 8192 bytes
@ -150,8 +150,9 @@ class Digitizer{
unsigned int GetSettingFromMemory (Reg registerAddress, unsigned short ch = 0);
unsigned int * GetSettings() {return setting;}
void PrintSettingFromMemory();
void SetSettingFileCoupled(bool onOff) {isSettingFileCoupled = onOff;}
bool IsSettingFileCoupled() const {return isSettingFileCoupled;}
void SetSettingFileUpdate(bool onOff) {isSettingFileUpdate = onOff;}
bool IsSettingFileUpdate() const {return isSettingFileUpdate;}
bool IsSettingFileExist() const {return isSettingFileExist;}
/// memory <--> file
void SaveAllSettingsAsText (std::string fileName);

View File

@ -221,11 +221,15 @@ DigiSettingsPanel::DigiSettingsPanel(Digitizer ** digi, unsigned int nDigi, QStr
// connect(bnSaveSettingsToText, &QPushButton::clicked, this, [=](){ SaveSetting(1);});
//checkBox, to coupled or decouple the setting file.
chkCoupledSettingFile = new QCheckBox("Update Bin", this);
chkCoupledSettingFile = new QCheckBox("Update Setting", this);
buttonLayout->addWidget(chkCoupledSettingFile, rowID, 3);
chkCoupledSettingFile->setCheckState(Qt::CheckState::Unchecked);
connect(chkCoupledSettingFile, &QCheckBox::stateChanged, this, [=](){
digi[ID]->SetSettingFileCoupled(chkCoupledSettingFile->isChecked());
connect(chkCoupledSettingFile, &QCheckBox::stateChanged, this, [=](int state){
digi[ID]->SetSettingFileUpdate(state);
if( state && digi[ID]->IsSettingFileExist() ) {
std::string filePath = digi[ID]->GetSettingFileName();
digi[ID]->SaveAllSettingsAsBin(filePath);
}
});
}
@ -4032,12 +4036,12 @@ void DigiSettingsPanel::SaveSetting(int opt){
QString ext = fileInfo.suffix();
if( opt == 0 ){
if( ext.isEmpty() ) filePath += ".bin";
digi[ID]->SaveAllSettingsAsBin(filePath.toStdString().c_str());
digi[ID]->SaveAllSettingsAsBin(filePath.toStdString());
leSaveFilePath[ID]->setText(filePath);
}
if( opt == 1 ){
if( ext.isEmpty() ) filePath += ".txt";
digi[ID]->SaveAllSettingsAsText(filePath.toStdString().c_str());
digi[ID]->SaveAllSettingsAsText(filePath.toStdString());
leSaveFilePath[ID]->setText(filePath + " | not loadable!!");
}

View File

@ -54,20 +54,22 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent){
cbOpenDigitizers = new RComboBox(this);
cbOpenDigitizers->addItem("Open Digitizers ... ", 0);
cbOpenDigitizers->addItem("Open Digitizers w/o load Settings", 1);
cbOpenDigitizers->addItem("Open Digitizers (default program)", 2);
cbOpenDigitizers->addItem("Open Digitizers + load Settings", 3);
// cbOpenDigitizers->addItem("Open Digitizers w/o load Settings", 1);
// cbOpenDigitizers->addItem("Open Digitizers (default program)", 2);
// cbOpenDigitizers->addItem("Open Digitizers + load Settings", 3);
//cbOpenDigitizers->addItem("Open Digitizers via USB", 3);
cbOpenDigitizers->addItem("Open Digitizers via A4818", 4);
layout->addWidget(cbOpenDigitizers, 0, 0);
connect(cbOpenDigitizers, &RComboBox::currentIndexChanged, this, &MainWindow::OpenDigitizers);
// bnOpenDigitizers = new QPushButton("Open Digitizers", this);
// layout->addWidget(bnOpenDigitizers, 0, 0);
// connect(bnOpenDigitizers, &QPushButton::clicked, this, &MainWindow::OpenDigitizers);
cbOpenMethod = new RComboBox(this);
cbOpenMethod->addItem("w/o settings", 0);
cbOpenMethod->addItem("default Program", 1);
cbOpenMethod->addItem("w/ settings", 1);
layout->addWidget(cbOpenMethod, 1, 0);
bnCloseDigitizers = new QPushButton("Close Digitizers", this);
layout->addWidget(bnCloseDigitizers, 1, 0);
layout->addWidget(bnCloseDigitizers, 2, 0);
connect(bnCloseDigitizers, &QPushButton::clicked, this, &MainWindow::CloseDigitizers);
bnDigiSettings = new QPushButton("Digitizers Settings", this);
@ -89,7 +91,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent){
connect(bnCanvas, &QPushButton::clicked, this, &MainWindow::OpenCanvas);
bnSync = new QPushButton("Sync Boards", this);
layout->addWidget(bnSync);
layout->addWidget(bnSync, 2, 1);
connect(bnSync, &QPushButton::clicked, this, &MainWindow::SetSyncMode);
}
@ -580,7 +582,6 @@ void MainWindow::OpenDigitizers(){
cbOpenDigitizers->setCurrentIndex(0);
return;
}
}
if( cbOpenDigitizers->currentData().toInt() == 4 ) {
@ -588,6 +589,7 @@ void MainWindow::OpenDigitizers(){
}else{
LogMsg("Searching digitizers via optical link or USB .....Please wait");
}
logMsgHTMLMode = false;
nDigi = 0;
std::vector<std::pair<int, int>> portList; //boardID, portID
@ -614,10 +616,9 @@ void MainWindow::OpenDigitizers(){
cbOpenDigitizers->setCurrentIndex(0);
return;
}else{
if( cbOpenDigitizers->currentIndex() == 1 ) LogMsg(QString("Done seraching. Found %1 digitizer(s). Opening digitizer(s)....").arg(nDigi));
if( cbOpenDigitizers->currentIndex() == 2 ) LogMsg(QString("Done seraching. Found %1 digitizer(s). Opening digitizer(s) and program default....").arg(nDigi));
if( cbOpenDigitizers->currentIndex() == 3 ) LogMsg(QString("Done seraching. Found %1 digitizer(s). Opening digitizer(s) and load settings....").arg(nDigi));
if( cbOpenMethod->currentData().toInt() == 0 ) LogMsg(QString("Done seraching. Found %1 digitizer(s). Opening digitizer(s)....").arg(nDigi));
if( cbOpenMethod->currentData().toInt() == 1 ) LogMsg(QString("Done seraching. Found %1 digitizer(s). Opening digitizer(s) and program default....").arg(nDigi));
if( cbOpenMethod->currentData().toInt() == 2 ) LogMsg(QString("Done seraching. Found %1 digitizer(s). Opening digitizer(s) and load settings....").arg(nDigi));
}
digi = new Digitizer * [nDigi];
@ -627,12 +628,12 @@ void MainWindow::OpenDigitizers(){
digi[i] = new Digitizer(portList[i].first, portList[i].second);
//digi[i]->Reset();
if( cbOpenDigitizers->currentIndex() == 2 ) {
if( cbOpenMethod->currentData().toInt() == 1 ) {
digi[i]->ProgramBoard();
}
///============== load settings
if( cbOpenDigitizers->currentIndex() == 3 ){
if( cbOpenMethod->currentData().toInt() == 2 ){
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) ) {
@ -777,6 +778,7 @@ void MainWindow::WaitForDigitizersOpen(bool onOff){
// bnOpenDigitizers->setEnabled(onOff);
cbOpenDigitizers->setEnabled(onOff);
cbOpenMethod->setEnabled(onOff);
bnCloseDigitizers->setEnabled(!onOff);
bnOpenScope->setEnabled(!onOff);

View File

@ -104,6 +104,7 @@ private:
int elogID;
RComboBox * cbOpenDigitizers;
RComboBox * cbOpenMethod;
//QPushButton * bnOpenDigitizers;
QPushButton * bnCloseDigitizers;