In setting panel, change save setting as text to a checkbox for update setting

This commit is contained in:
splitPoleDAQ 2024-01-18 23:41:18 -05:00
parent 14c2ceab6c
commit c0e6d7ae9a
4 changed files with 31 additions and 17 deletions

View File

@ -38,7 +38,8 @@ void Digitizer::Initalization(){
isSettingFilledinMemeory = false; isSettingFilledinMemeory = false;
settingFileName = ""; settingFileName = "";
settingFileExist = false; isSettingFileExist = false;
isSettingFileCoupled = false;
settingFile = NULL; settingFile = NULL;
ret = -1; ret = -1;
@ -255,8 +256,8 @@ void Digitizer::SetRegChannelMask(uint32_t mask){
if( !isConnected ) return; if( !isConnected ) return;
regChannelMask = mask; regChannelMask = mask;
ret |= CAEN_DGTZ_SetChannelEnableMask(handle, regChannelMask); ret |= CAEN_DGTZ_SetChannelEnableMask(handle, regChannelMask);
SaveSettingToFile(DPP::RegChannelEnableMask, mask);
SetSettingToMemory(DPP::RegChannelEnableMask, mask); SetSettingToMemory(DPP::RegChannelEnableMask, mask);
SaveSettingToFile(DPP::RegChannelEnableMask, mask);
ErrorMsg(__func__); ErrorMsg(__func__);
} }
@ -941,11 +942,11 @@ void Digitizer::SetSettingBinaryPath(std::string fileName){
SaveAllSettingsAsBin(fileName); SaveAllSettingsAsBin(fileName);
this->settingFileName = fileName; this->settingFileName = fileName;
settingFileExist = true; isSettingFileExist = true;
}else{ }else{
this->settingFileName = fileName; this->settingFileName = fileName;
settingFileExist = true; isSettingFileExist = true;
fclose(settingFile); fclose(settingFile);
printf("setting file already exist. do nothing. Should program the digitizer\n"); printf("setting file already exist. do nothing. Should program the digitizer\n");
} }
@ -958,11 +959,11 @@ int Digitizer::LoadSettingBinaryToMemory(std::string fileName){
if( settingFile == NULL ) { if( settingFile == NULL ) {
printf(" %s does not exist or cannot load.\n", fileName.c_str()); printf(" %s does not exist or cannot load.\n", fileName.c_str());
settingFileExist = false; isSettingFileExist = false;
return -1; return -1;
}else{ }else{
settingFileExist = true; isSettingFileExist = true;
settingFileName = fileName; settingFileName = fileName;
fclose (settingFile); fclose (settingFile);
@ -997,7 +998,7 @@ int Digitizer::LoadSettingBinaryToMemory(std::string fileName){
} }
unsigned int Digitizer::ReadSettingFromFile(Reg registerAddress, unsigned short ch){ unsigned int Digitizer::ReadSettingFromFile(Reg registerAddress, unsigned short ch){
if ( !settingFileExist ) return -1; if ( !isSettingFileExist ) return -1;
unsigned short index = registerAddress.Index(ch); unsigned short index = registerAddress.Index(ch);
@ -1018,7 +1019,8 @@ unsigned int Digitizer::ReadSettingFromFile(Reg registerAddress, unsigned short
void Digitizer::SaveSettingToFile(Reg registerAddress, unsigned int value, unsigned short ch){ void Digitizer::SaveSettingToFile(Reg registerAddress, unsigned int value, unsigned short ch){
if ( !settingFileExist ) return ; if ( !isSettingFileExist ) return ;
if ( !isSettingFileCoupled ) return;
unsigned short index = registerAddress.Index(ch); unsigned short index = registerAddress.Index(ch);
setting[index] = value; setting[index] = value;
@ -1048,7 +1050,7 @@ void Digitizer::SaveAllSettingsAsBin(std::string fileName){
fclose (binFile); fclose (binFile);
settingFileName = fileName; settingFileName = fileName;
settingFileExist = true; isSettingFileExist = true;
} }

View File

@ -53,7 +53,8 @@ class Digitizer{
//^-------- setting //^-------- setting
std::string settingFileName; /// std::string settingFileName; ///
FILE * settingFile; /// FILE * settingFile; ///
bool settingFileExist; /// bool isSettingFileExist; ///
bool isSettingFileCoupled;
bool isSettingFilledinMemeory; /// false for disabled ReadAllSettingFromBoard() bool isSettingFilledinMemeory; /// false for disabled ReadAllSettingFromBoard()
unsigned int setting[SETTINGSIZE]; /// Setting, 4bytes x 2048 = 8192 bytes unsigned int setting[SETTINGSIZE]; /// Setting, 4bytes x 2048 = 8192 bytes
@ -147,8 +148,10 @@ class Digitizer{
/// simply read settings from memory /// simply read settings from memory
void SetSettingToMemory (Reg registerAddress, unsigned int value, unsigned short ch = 0); void SetSettingToMemory (Reg registerAddress, unsigned int value, unsigned short ch = 0);
unsigned int GetSettingFromMemory (Reg registerAddress, unsigned short ch = 0); unsigned int GetSettingFromMemory (Reg registerAddress, unsigned short ch = 0);
void PrintSettingFromMemory (); unsigned int * GetSettings() {return setting;}
unsigned int * GetSettings() {return setting;}; void PrintSettingFromMemory();
void SetSettingFileCoupled(bool onOff) {isSettingFileCoupled = onOff;}
bool IsSettingFileCoupled() const {return isSettingFileCoupled;}
/// memory <--> file /// memory <--> file
void SaveAllSettingsAsText (std::string fileName); void SaveAllSettingsAsText (std::string fileName);

View File

@ -216,9 +216,17 @@ DigiSettingsPanel::DigiSettingsPanel(Digitizer ** digi, unsigned int nDigi, QStr
buttonLayout->addWidget(bnSaveSettings, rowID, 2); buttonLayout->addWidget(bnSaveSettings, rowID, 2);
connect(bnSaveSettings, &QPushButton::clicked, this, [=](){ SaveSetting(0);}); connect(bnSaveSettings, &QPushButton::clicked, this, [=](){ SaveSetting(0);});
bnSaveSettingsToText = new QPushButton("Save Settings (txt)", this); // bnSaveSettingsToText = new QPushButton("Save Settings (txt)", this);
buttonLayout->addWidget(bnSaveSettingsToText, rowID, 3); // buttonLayout->addWidget(bnSaveSettingsToText, rowID, 3);
connect(bnSaveSettingsToText, &QPushButton::clicked, this, [=](){ SaveSetting(1);}); // connect(bnSaveSettingsToText, &QPushButton::clicked, this, [=](){ SaveSetting(1);});
//checkBox, to coupled or decouple the setting file.
chkCoupledSettingFile = new QCheckBox("Update Bin", this);
buttonLayout->addWidget(chkCoupledSettingFile, rowID, 3);
chkCoupledSettingFile->setCheckState(Qt::CheckState::Unchecked);
connect(chkCoupledSettingFile, &QCheckBox::stateChanged, this, [=](){
digi[ID]->SetSettingFileCoupled(chkCoupledSettingFile->isChecked());
});
} }
{//^======================= Board Settings {//^======================= Board Settings
@ -4020,7 +4028,7 @@ void DigiSettingsPanel::SaveSetting(int opt){
if( opt == 0 ){ if( opt == 0 ){
if( ext == "") filePath += ".bin"; if( ext == "") filePath += ".bin";
digi[ID]->SaveAllSettingsAsBin(filePath.toStdString().c_str()); digi[ID]->SaveAllSettingsAsBin(filePath.toStdString().c_str());
leSaveFilePath[ID]->setText(filePath + " | dynamic update"); leSaveFilePath[ID]->setText(filePath);
} }
if( opt == 1 ){ if( opt == 1 ){
if( ext == "") filePath += ".txt"; if( ext == "") filePath += ".txt";

View File

@ -110,7 +110,8 @@ private:
QPushButton * bnSendSoftwareClockSyncSignal; QPushButton * bnSendSoftwareClockSyncSignal;
QPushButton * bnSaveSettings; QPushButton * bnSaveSettings;
QPushButton * bnLoadSettings; QPushButton * bnLoadSettings;
QPushButton * bnSaveSettingsToText; //QPushButton * bnSaveSettingsToText;
QCheckBox * chkCoupledSettingFile;
/// ============================= Board Configure /// ============================= Board Configure
QGridLayout * bdCfgLayout[MaxNDigitizer]; QGridLayout * bdCfgLayout[MaxNDigitizer];