diff --git a/Software/PC_Application/appwindow.cpp b/Software/PC_Application/appwindow.cpp index aa1cec8..d0807cc 100644 --- a/Software/PC_Application/appwindow.cpp +++ b/Software/PC_Application/appwindow.cpp @@ -144,15 +144,7 @@ AppWindow::AppWindow(QWidget *parent) // aborted selection return; } - if(!filename.endsWith(".setup")) { - filename.append(".setup"); - } - ofstream file; - file.open(filename.toStdString()); - file << setw(4) << SaveSetup() << endl; - file.close(); - QFileInfo fi(filename); - lSetupName.setText("Setup: "+fi.fileName()); + SaveSetup(filename); }); connect(ui->actionLoad_setup, &QAction::triggered, [=](){ auto filename = QFileDialog::getOpenFileName(nullptr, "Load setup data", "", "Setup files (*.setup)", nullptr, QFileDialog::DontUseNativeDialog); @@ -243,9 +235,12 @@ AppWindow::AppWindow(QWidget *parent) qRegisterMetaType("SpectrumAnalyzerResult"); qRegisterMetaType("AmplitudeCorrection"); + auto pref = Preferences::getInstance(); + if(pref.Startup.UseSetupFile) { + LoadSetup(pref.Startup.SetupFile); + } // List available devices UpdateDeviceList(); - auto pref = Preferences::getInstance(); if(pref.Startup.ConnectToFirstDevice) { // at least one device available ConnectToDevice(); @@ -257,9 +252,6 @@ AppWindow::AppWindow(QWidget *parent) } else { InformationBox::setGUI(false); } - if(pref.Startup.UseSetupFile) { - LoadSetup(pref.Startup.SetupFile); - } } AppWindow::~AppWindow() @@ -270,6 +262,10 @@ AppWindow::~AppWindow() void AppWindow::closeEvent(QCloseEvent *event) { + auto pref = Preferences::getInstance(); + if(pref.Startup.UseSetupFile && pref.Startup.AutosaveSetupFile) { + SaveSetup(pref.Startup.SetupFile); + } vna->shutdown(); generator->shutdown(); spectrumAnalyzer->shutdown(); @@ -280,7 +276,7 @@ void AppWindow::closeEvent(QCloseEvent *event) if(Mode::getActiveMode()) { Mode::getActiveMode()->deactivate(); } - Preferences::getInstance().store(); + pref.store(); QMainWindow::closeEvent(event); } @@ -926,6 +922,19 @@ void AppWindow::FrequencyCalibrationDialog() d->exec(); } +void AppWindow::SaveSetup(QString filename) +{ + if(!filename.endsWith(".setup")) { + filename.append(".setup"); + } + ofstream file; + file.open(filename.toStdString()); + file << setw(4) << SaveSetup() << endl; + file.close(); + QFileInfo fi(filename); + lSetupName.setText("Setup: "+fi.fileName()); +} + nlohmann::json AppWindow::SaveSetup() { nlohmann::json j; diff --git a/Software/PC_Application/appwindow.h b/Software/PC_Application/appwindow.h index 3caa04b..e79c2d7 100644 --- a/Software/PC_Application/appwindow.h +++ b/Software/PC_Application/appwindow.h @@ -61,6 +61,7 @@ private slots: void ReceiverCalibrationDialog(); void FrequencyCalibrationDialog(); nlohmann::json SaveSetup(); + void SaveSetup(QString filename); void LoadSetup(QString filename); void LoadSetup(nlohmann::json j); private: diff --git a/Software/PC_Application/preferences.cpp b/Software/PC_Application/preferences.cpp index f4290c8..b8ceed8 100644 --- a/Software/PC_Application/preferences.cpp +++ b/Software/PC_Application/preferences.cpp @@ -52,16 +52,19 @@ PreferencesDialog::PreferencesDialog(Preferences *pref, QWidget *parent) : setDefaultSettingsEnabled(false); ui->StartupSetupFile->setEnabled(false); ui->StartupBrowse->setEnabled(false); + ui->StartupStack->setCurrentWidget(ui->StartupPageLastUsed); }); connect(ui->StartupSweepDefault, &QPushButton::clicked, [=](){ setDefaultSettingsEnabled(true); ui->StartupSetupFile->setEnabled(false); ui->StartupBrowse->setEnabled(false); + ui->StartupStack->setCurrentWidget(ui->StartupPageDefaultValues); }); connect(ui->StartupUseSetupFile, &QPushButton::clicked, [=](){ setDefaultSettingsEnabled(false); ui->StartupSetupFile->setEnabled(true); ui->StartupBrowse->setEnabled(true); + ui->StartupStack->setCurrentWidget(ui->StartupPageSetupFile); }); connect(ui->StartupBrowse, &QPushButton::clicked, [=](){ ui->StartupSetupFile->setText(QFileDialog::getOpenFileName(nullptr, "Select startup setup file", "", "Setup files (*.setup)", nullptr, QFileDialog::DontUseNativeDialog)); @@ -203,6 +206,7 @@ void PreferencesDialog::setInitialGUIState() } else { ui->StartupSweepDefault->click(); } + ui->StartupAutosaveSetupFile->setChecked(p->Startup.AutosaveSetupFile); ui->StartupSetupFile->setText(p->Startup.SetupFile); ui->StartupSweepType->setCurrentText(p->Startup.DefaultSweep.type); ui->StartupSweepStart->setValueQuiet(p->Startup.DefaultSweep.f_start); @@ -263,6 +267,7 @@ void PreferencesDialog::updateFromGUI() p->Startup.RememberSweepSettings = ui->StartupSweepLastUsed->isChecked(); p->Startup.UseSetupFile = ui->StartupUseSetupFile->isChecked(); p->Startup.SetupFile = ui->StartupSetupFile->text(); + p->Startup.AutosaveSetupFile = ui->StartupAutosaveSetupFile->isChecked(); p->Startup.DefaultSweep.type = ui->StartupSweepType->currentText(); p->Startup.DefaultSweep.f_start = ui->StartupSweepStart->value(); p->Startup.DefaultSweep.f_stop = ui->StartupSweepStop->value(); diff --git a/Software/PC_Application/preferences.h b/Software/PC_Application/preferences.h index 3c78e4a..095cf92 100644 --- a/Software/PC_Application/preferences.h +++ b/Software/PC_Application/preferences.h @@ -33,6 +33,7 @@ public: bool ConnectToFirstDevice; bool RememberSweepSettings; bool UseSetupFile; + bool AutosaveSetupFile; QString SetupFile; struct { QString type; @@ -121,6 +122,7 @@ private: {&Startup.RememberSweepSettings, "Startup.RememberSweepSettings", false}, {&Startup.UseSetupFile, "Startup.UseSetupFile", false}, {&Startup.SetupFile, "Startup.SetupFile", ""}, + {&Startup.AutosaveSetupFile, "Startup.AutosaveSetupFile", false}, {&Startup.DefaultSweep.type, "Startup.DefaultSweep.type", "Frequency"}, {&Startup.DefaultSweep.f_start, "Startup.DefaultSweep.start", 1000000.0}, {&Startup.DefaultSweep.f_stop, "Startup.DefaultSweep.stop", 6000000000.0}, diff --git a/Software/PC_Application/preferencesdialog.ui b/Software/PC_Application/preferencesdialog.ui index 1ee3a30..13ef28c 100644 --- a/Software/PC_Application/preferencesdialog.ui +++ b/Software/PC_Application/preferencesdialog.ui @@ -6,8 +6,8 @@ 0 0 - 957 - 891 + 936 + 951 @@ -112,7 +112,7 @@ - + @@ -136,35 +136,13 @@ - Use setup file: + Setup file StartupSweepGroup - - - - - - - - 0 - 0 - - - - - 20 - 16777215 - - - - ... - - - @@ -183,388 +161,503 @@ - - - Vector Network Analyzer + + + 2 - - - - - - - Type: - - - - - - + + + + + + The last used sweep settings (e.g. span, bandwidth,...) will be remembered. The graphs, traces and markers will not be remembered and the default configuration for them is used on startup. + + + true + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + All settings (sweep settings as well as graphs, markers and traces) will be taken from the specified file. If the autosave option is checked, the current state of the GUI is stored in this file during shutdown as well. + + + true + + + + + + + - Frequency Sweep + File location: + + + + + + + + + + 0 + 0 + + + + + 20 + 16777215 + + + + ... + + + + + + + + + Autosave to this file on shutdown + + + + + + + Qt::Vertical + + + + 20 + 545 + + + + + + + + + + + + These default values for the sweep settings will be used. The graphs, traces and markers will not be remembered and the default configuration for them is used on startup. + + + true + + + + + + + Vector Network Analyzer + + + + + + + + Type: + + + + + + + + Frequency Sweep + + + + + Power Sweep + + + + + - - Power Sweep - + + + + + Frequency Sweep: + + + + + + Start: + + + + + + + + + + Stop: + + + + + + + + + + Simulus level: + + + + + + + dbm + + + -42.000000000000000 + + + 0.000000000000000 + + + 0.250000000000000 + + + + + + + + + + Power Sweep: + + + + + + Start: + + + + + + + dbm + + + -42.000000000000000 + + + 0.000000000000000 + + + 0.250000000000000 + + + + + + + Stop: + + + + + + + dbm + + + -42.000000000000000 + + + 0.000000000000000 + + + 0.250000000000000 + + + + + + + Frequency: + + + + + + + + + + - - - - - - - - - - Frequency Sweep: - - - - + + + + + + Points: + + + + + + + 1 + + + 4501 + + + 501 + + + + + + + IF bandwitdh: + + + + + + + + + + Averaging: + + + + + + + 1 + + + 99 + + + + + + + + + + + + Signal Generator + + + + + + Frequency: + + + + + + + + + + Output level: + + + + + + + dbm + + + -42.000000000000000 + + + 0.000000000000000 + + + 0.250000000000000 + + + + + + + + + + Spectrum Analyzer + + + + + + Start: + + + + + + + + + + Stop: + + + + + + + + + + RBW: + + + + + + + + + + Window: + + + + + + - Start: + None - - - - - - - + + - Stop: + Kaiser - - - - - - - + + - Simulus level: + Hann - - - - - - dbm - - - -42.000000000000000 - - - 0.000000000000000 - - - 0.250000000000000 - - - - - - - - - - Power Sweep: - - - - + + - Start: + Flat Top - - - - - - dbm - - - -42.000000000000000 - - - 0.000000000000000 - - - 0.250000000000000 - - - - - + + + + + + + Detector: + + + + + + - Stop: + +Peak - - - - - - dbm - - - -42.000000000000000 - - - 0.000000000000000 - - - 0.250000000000000 - - - - - + + - Frequency: + -Peak - - - - - - - - - - - - - - - - Points: - - - - - - - 1 - - - 4501 - - - 501 - - - - - - - IF bandwitdh: - - - - - - - - - - Averaging: - - - - - - - 1 - - - 99 - - - - - - - - - - - - Signal Generator - - - - - - Frequency: - - - - - - - - - - Output level: - - - - - - - dbm - - - -42.000000000000000 - - - 0.000000000000000 - - - 0.250000000000000 - - - - - - - - - - Spectrum Analyzer - - - - - - Start: - - - - - - - - - - Stop: - - - - - - - - - - RBW: - - - - - - - - - - Window: - - - - - - - - None - - - - - Kaiser - - - - - Hann - - - - - Flat Top - - - - - - - - Detector: - - - - - - - - +Peak - - - - - -Peak - - - - - Sample - - - - - Normal - - - - - Average - - - - - - - - Signal Identification: - - - - - - - - - - - - - - Averaging: - - - - - - - 1 - - - 99 - - - - + + + + Sample + + + + + Normal + + + + + Average + + + + + + + + Signal Identification: + + + + + + + + + + + + + + Averaging: + + + + + + + 1 + + + 99 + + + + + + + +