From 4020a2aeac3ff51e47df5fd3cd4400fcd8045594 Mon Sep 17 00:00:00 2001 From: splitPoleDAQ Date: Fri, 19 Jan 2024 13:21:59 -0500 Subject: [PATCH] add default setting name --- ClassData.h | 4 +--- ClassDigitizer.cpp | 2 ++ DigiSettingsPanel.cpp | 42 ++++++++++++++++++++++++++++-------------- Scope.cpp | 9 +++++---- 4 files changed, 36 insertions(+), 21 deletions(-) diff --git a/ClassData.h b/ClassData.h index faaa5c9..a4a3d2c 100644 --- a/ClassData.h +++ b/ClassData.h @@ -183,7 +183,7 @@ inline void Data::AllocateDataSize(uShort dataSize){ printf("dataSize cannot < 1, set dataSize = 1.\n"); dataSize = 1; } - printf("Data::%s, size: %u\n", __func__, dataSize); + //printf("Data::%s, size: %u\n", __func__, dataSize); this->dataSize = dataSize; @@ -219,8 +219,6 @@ inline void Data::AllocateDataSize(uShort dataSize){ inline void Data::ClearDataPointer(){ - printf("Data::%s\n", __func__); - for(int ch = 0; ch < numInputCh; ch++){ delete [] Timestamp[ch] ; delete [] fineTime[ch]; diff --git a/ClassDigitizer.cpp b/ClassDigitizer.cpp index dea6cbf..3c3a7b7 100644 --- a/ClassDigitizer.cpp +++ b/ClassDigitizer.cpp @@ -1022,6 +1022,8 @@ void Digitizer::SaveSettingToFile(Reg registerAddress, unsigned int value, unsig if ( !isSettingFileExist ) return ; if ( !isSettingFileCoupled ) return; + 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; diff --git a/DigiSettingsPanel.cpp b/DigiSettingsPanel.cpp index 7495ae2..eb40369 100644 --- a/DigiSettingsPanel.cpp +++ b/DigiSettingsPanel.cpp @@ -4019,24 +4019,38 @@ void DigiSettingsPanel::SaveSetting(int opt){ QDir dir(rawDataPath); if( !dir.exists() ) dir.mkpath("."); - QString filePath = QFileDialog::getSaveFileName(this, "Save Settings File", rawDataPath, opt == 0 ? "Binary (*.bin)" : "Text file (*.txt)"); + QString defaultFileName = "Digi-" + QString::number(digi[ID]->GetSerialNumber()) + "_" + QString::fromStdString(digi[ID]->GetData()->DPPTypeStr) + ".bin"; + + QString filePath = QFileDialog::getSaveFileName(this, + "Save Settings File", + rawDataPath, + opt == 0 ? "Binary (*.bin)" : "Text file (*.txt)"); if (!filePath.isEmpty()) { - QFileInfo fileInfo(filePath); - QString ext = fileInfo.suffix(); - if( opt == 0 ){ - if( ext == "") filePath += ".bin"; - digi[ID]->SaveAllSettingsAsBin(filePath.toStdString().c_str()); - leSaveFilePath[ID]->setText(filePath); - } - if( opt == 1 ){ - if( ext == "") filePath += ".txt"; - digi[ID]->SaveAllSettingsAsText(filePath.toStdString().c_str()); - leSaveFilePath[ID]->setText(filePath + " | not loadable!!"); - } + QFileDialog dialog; + dialog.selectFile(defaultFileName); - SendLogMsg("Saved setting file " + filePath + "."); + if( dialog.exec() == QDialog::Accepted){ + + filePath = dialog.selectedFiles().first(); + + QFileInfo fileInfo(filePath); + QString ext = fileInfo.suffix(); + if( opt == 0 ){ + if( ext.isEmpty() ) filePath += ".bin"; + digi[ID]->SaveAllSettingsAsBin(filePath.toStdString().c_str()); + leSaveFilePath[ID]->setText(filePath); + } + if( opt == 1 ){ + if( ext.isEmpty() ) filePath += ".txt"; + digi[ID]->SaveAllSettingsAsText(filePath.toStdString().c_str()); + leSaveFilePath[ID]->setText(filePath + " | not loadable!!"); + } + + SendLogMsg("Saved setting file " + filePath + "."); + + } } diff --git a/Scope.cpp b/Scope.cpp index e2f6c02..f3b4f2c 100644 --- a/Scope.cpp +++ b/Scope.cpp @@ -639,10 +639,11 @@ void Scope::SetUpSpinBox(RSpinBox * &sb, QString str, int row, int col, const Re uint32_t value = sb->value() / tick2ns / abs(para.GetPartialStep()); - if( para == DPP::RecordLength_G){ - int factor = digi[ID]->IsDualTrace_PHA() ? 2 : 1; - value = value * factor; - } + //todo NEED TO CHECK + // if( para == DPP::RecordLength_G){ + // int factor = digi[ID]->IsDualTrace_PHA() ? 2 : 1; + // value = value * factor; + // } if( para == DPP::ChannelDCOffset || para == DPP::QDC::DCOffset){ value = uint16_t((1.0 - sb->value()/100.) * 0xFFFF);