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:
parent
187b3b5b7f
commit
96e3d2a007
|
@ -39,7 +39,7 @@ void Digitizer::Initalization(){
|
||||||
isSettingFilledinMemeory = false;
|
isSettingFilledinMemeory = false;
|
||||||
settingFileName = "";
|
settingFileName = "";
|
||||||
isSettingFileExist = false;
|
isSettingFileExist = false;
|
||||||
isSettingFileCoupled = false;
|
isSettingFileUpdate = false;
|
||||||
settingFile = NULL;
|
settingFile = NULL;
|
||||||
|
|
||||||
ret = -1;
|
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){
|
void Digitizer::SaveSettingToFile(Reg registerAddress, unsigned int value, unsigned short ch){
|
||||||
|
|
||||||
if ( !isSettingFileExist ) return ;
|
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);
|
unsigned short index = registerAddress.Index(ch);
|
||||||
setting[index] = value;
|
setting[index] = value;
|
||||||
|
|
|
@ -54,7 +54,7 @@ class Digitizer{
|
||||||
std::string settingFileName; ///
|
std::string settingFileName; ///
|
||||||
FILE * settingFile; ///
|
FILE * settingFile; ///
|
||||||
bool isSettingFileExist; ///
|
bool isSettingFileExist; ///
|
||||||
bool isSettingFileCoupled;
|
bool isSettingFileUpdate;
|
||||||
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
|
||||||
|
|
||||||
|
@ -150,8 +150,9 @@ class Digitizer{
|
||||||
unsigned int GetSettingFromMemory (Reg registerAddress, unsigned short ch = 0);
|
unsigned int GetSettingFromMemory (Reg registerAddress, unsigned short ch = 0);
|
||||||
unsigned int * GetSettings() {return setting;}
|
unsigned int * GetSettings() {return setting;}
|
||||||
void PrintSettingFromMemory();
|
void PrintSettingFromMemory();
|
||||||
void SetSettingFileCoupled(bool onOff) {isSettingFileCoupled = onOff;}
|
void SetSettingFileUpdate(bool onOff) {isSettingFileUpdate = onOff;}
|
||||||
bool IsSettingFileCoupled() const {return isSettingFileCoupled;}
|
bool IsSettingFileUpdate() const {return isSettingFileUpdate;}
|
||||||
|
bool IsSettingFileExist() const {return isSettingFileExist;}
|
||||||
|
|
||||||
/// memory <--> file
|
/// memory <--> file
|
||||||
void SaveAllSettingsAsText (std::string fileName);
|
void SaveAllSettingsAsText (std::string fileName);
|
||||||
|
|
|
@ -221,11 +221,15 @@ DigiSettingsPanel::DigiSettingsPanel(Digitizer ** digi, unsigned int nDigi, QStr
|
||||||
// connect(bnSaveSettingsToText, &QPushButton::clicked, this, [=](){ SaveSetting(1);});
|
// connect(bnSaveSettingsToText, &QPushButton::clicked, this, [=](){ SaveSetting(1);});
|
||||||
|
|
||||||
//checkBox, to coupled or decouple the setting file.
|
//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);
|
buttonLayout->addWidget(chkCoupledSettingFile, rowID, 3);
|
||||||
chkCoupledSettingFile->setCheckState(Qt::CheckState::Unchecked);
|
chkCoupledSettingFile->setCheckState(Qt::CheckState::Unchecked);
|
||||||
connect(chkCoupledSettingFile, &QCheckBox::stateChanged, this, [=](){
|
connect(chkCoupledSettingFile, &QCheckBox::stateChanged, this, [=](int state){
|
||||||
digi[ID]->SetSettingFileCoupled(chkCoupledSettingFile->isChecked());
|
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();
|
QString ext = fileInfo.suffix();
|
||||||
if( opt == 0 ){
|
if( opt == 0 ){
|
||||||
if( ext.isEmpty() ) filePath += ".bin";
|
if( ext.isEmpty() ) filePath += ".bin";
|
||||||
digi[ID]->SaveAllSettingsAsBin(filePath.toStdString().c_str());
|
digi[ID]->SaveAllSettingsAsBin(filePath.toStdString());
|
||||||
leSaveFilePath[ID]->setText(filePath);
|
leSaveFilePath[ID]->setText(filePath);
|
||||||
}
|
}
|
||||||
if( opt == 1 ){
|
if( opt == 1 ){
|
||||||
if( ext.isEmpty() ) filePath += ".txt";
|
if( ext.isEmpty() ) filePath += ".txt";
|
||||||
digi[ID]->SaveAllSettingsAsText(filePath.toStdString().c_str());
|
digi[ID]->SaveAllSettingsAsText(filePath.toStdString());
|
||||||
leSaveFilePath[ID]->setText(filePath + " | not loadable!!");
|
leSaveFilePath[ID]->setText(filePath + " | not loadable!!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
34
FSUDAQ.cpp
34
FSUDAQ.cpp
|
@ -54,20 +54,22 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent){
|
||||||
|
|
||||||
cbOpenDigitizers = new RComboBox(this);
|
cbOpenDigitizers = new RComboBox(this);
|
||||||
cbOpenDigitizers->addItem("Open Digitizers ... ", 0);
|
cbOpenDigitizers->addItem("Open Digitizers ... ", 0);
|
||||||
cbOpenDigitizers->addItem("Open Digitizers w/o load Settings", 1);
|
// cbOpenDigitizers->addItem("Open Digitizers w/o load Settings", 1);
|
||||||
cbOpenDigitizers->addItem("Open Digitizers (default program)", 2);
|
// cbOpenDigitizers->addItem("Open Digitizers (default program)", 2);
|
||||||
cbOpenDigitizers->addItem("Open Digitizers + load Settings", 3);
|
// cbOpenDigitizers->addItem("Open Digitizers + load Settings", 3);
|
||||||
//cbOpenDigitizers->addItem("Open Digitizers via USB", 3);
|
//cbOpenDigitizers->addItem("Open Digitizers via USB", 3);
|
||||||
cbOpenDigitizers->addItem("Open Digitizers via A4818", 4);
|
cbOpenDigitizers->addItem("Open Digitizers via A4818", 4);
|
||||||
layout->addWidget(cbOpenDigitizers, 0, 0);
|
layout->addWidget(cbOpenDigitizers, 0, 0);
|
||||||
connect(cbOpenDigitizers, &RComboBox::currentIndexChanged, this, &MainWindow::OpenDigitizers);
|
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);
|
bnCloseDigitizers = new QPushButton("Close Digitizers", this);
|
||||||
layout->addWidget(bnCloseDigitizers, 1, 0);
|
layout->addWidget(bnCloseDigitizers, 2, 0);
|
||||||
connect(bnCloseDigitizers, &QPushButton::clicked, this, &MainWindow::CloseDigitizers);
|
connect(bnCloseDigitizers, &QPushButton::clicked, this, &MainWindow::CloseDigitizers);
|
||||||
|
|
||||||
bnDigiSettings = new QPushButton("Digitizers Settings", this);
|
bnDigiSettings = new QPushButton("Digitizers Settings", this);
|
||||||
|
@ -89,7 +91,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent){
|
||||||
connect(bnCanvas, &QPushButton::clicked, this, &MainWindow::OpenCanvas);
|
connect(bnCanvas, &QPushButton::clicked, this, &MainWindow::OpenCanvas);
|
||||||
|
|
||||||
bnSync = new QPushButton("Sync Boards", this);
|
bnSync = new QPushButton("Sync Boards", this);
|
||||||
layout->addWidget(bnSync);
|
layout->addWidget(bnSync, 2, 1);
|
||||||
connect(bnSync, &QPushButton::clicked, this, &MainWindow::SetSyncMode);
|
connect(bnSync, &QPushButton::clicked, this, &MainWindow::SetSyncMode);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -580,7 +582,6 @@ void MainWindow::OpenDigitizers(){
|
||||||
cbOpenDigitizers->setCurrentIndex(0);
|
cbOpenDigitizers->setCurrentIndex(0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if( cbOpenDigitizers->currentData().toInt() == 4 ) {
|
if( cbOpenDigitizers->currentData().toInt() == 4 ) {
|
||||||
|
@ -588,6 +589,7 @@ void MainWindow::OpenDigitizers(){
|
||||||
}else{
|
}else{
|
||||||
LogMsg("Searching digitizers via optical link or USB .....Please wait");
|
LogMsg("Searching digitizers via optical link or USB .....Please wait");
|
||||||
}
|
}
|
||||||
|
|
||||||
logMsgHTMLMode = false;
|
logMsgHTMLMode = false;
|
||||||
nDigi = 0;
|
nDigi = 0;
|
||||||
std::vector<std::pair<int, int>> portList; //boardID, portID
|
std::vector<std::pair<int, int>> portList; //boardID, portID
|
||||||
|
@ -614,10 +616,9 @@ void MainWindow::OpenDigitizers(){
|
||||||
cbOpenDigitizers->setCurrentIndex(0);
|
cbOpenDigitizers->setCurrentIndex(0);
|
||||||
return;
|
return;
|
||||||
}else{
|
}else{
|
||||||
if( cbOpenDigitizers->currentIndex() == 1 ) LogMsg(QString("Done seraching. Found %1 digitizer(s). Opening digitizer(s)....").arg(nDigi));
|
if( cbOpenMethod->currentData().toInt() == 0 ) 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( cbOpenMethod->currentData().toInt() == 1 ) 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() == 2 ) LogMsg(QString("Done seraching. Found %1 digitizer(s). Opening digitizer(s) and load settings....").arg(nDigi));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
digi = new Digitizer * [nDigi];
|
digi = new Digitizer * [nDigi];
|
||||||
|
@ -627,12 +628,12 @@ void MainWindow::OpenDigitizers(){
|
||||||
digi[i] = new Digitizer(portList[i].first, portList[i].second);
|
digi[i] = new Digitizer(portList[i].first, portList[i].second);
|
||||||
//digi[i]->Reset();
|
//digi[i]->Reset();
|
||||||
|
|
||||||
if( cbOpenDigitizers->currentIndex() == 2 ) {
|
if( cbOpenMethod->currentData().toInt() == 1 ) {
|
||||||
digi[i]->ProgramBoard();
|
digi[i]->ProgramBoard();
|
||||||
}
|
}
|
||||||
|
|
||||||
///============== load settings
|
///============== 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";
|
QString fileName = rawDataPath + "/Digi-" + QString::number(digi[i]->GetSerialNumber()) + "_" + QString::fromStdString(digi[i]->GetData()->DPPTypeStr) + ".bin";
|
||||||
QFile file(fileName);
|
QFile file(fileName);
|
||||||
if( !file.open(QIODevice::Text | QIODevice::ReadOnly) ) {
|
if( !file.open(QIODevice::Text | QIODevice::ReadOnly) ) {
|
||||||
|
@ -777,6 +778,7 @@ void MainWindow::WaitForDigitizersOpen(bool onOff){
|
||||||
// bnOpenDigitizers->setEnabled(onOff);
|
// bnOpenDigitizers->setEnabled(onOff);
|
||||||
|
|
||||||
cbOpenDigitizers->setEnabled(onOff);
|
cbOpenDigitizers->setEnabled(onOff);
|
||||||
|
cbOpenMethod->setEnabled(onOff);
|
||||||
|
|
||||||
bnCloseDigitizers->setEnabled(!onOff);
|
bnCloseDigitizers->setEnabled(!onOff);
|
||||||
bnOpenScope->setEnabled(!onOff);
|
bnOpenScope->setEnabled(!onOff);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user