diff --git a/Software/PC_Application/SpectrumAnalyzer/spectrumanalyzer.cpp b/Software/PC_Application/SpectrumAnalyzer/spectrumanalyzer.cpp index f6b5430..8af330c 100644 --- a/Software/PC_Application/SpectrumAnalyzer/spectrumanalyzer.cpp +++ b/Software/PC_Application/SpectrumAnalyzer/spectrumanalyzer.cpp @@ -155,6 +155,17 @@ SpectrumAnalyzer::SpectrumAnalyzer(AppWindow *window) }); tb_acq->addWidget(cbDetector); + tb_acq->addWidget(new QLabel("Averaging:")); + lAverages = new QLabel("0/"); + tb_acq->addWidget(lAverages); + auto sbAverages = new QSpinBox; + sbAverages->setRange(1, 100); + sbAverages->setRange(1, 99); + sbAverages->setFixedWidth(40); + connect(sbAverages, qOverload(&QSpinBox::valueChanged), this, &SpectrumAnalyzer::SetAveraging); + connect(this, &SpectrumAnalyzer::averagingChanged, sbAverages, &QSpinBox::setValue); + tb_acq->addWidget(sbAverages); + cbSignalID = new QCheckBox("Signal ID"); connect(cbSignalID, &QCheckBox::toggled, [=](bool enabled) { settings.SignalID = enabled; @@ -192,6 +203,7 @@ SpectrumAnalyzer::SpectrumAnalyzer(AppWindow *window) settings.f_stop = pref.Startup.SA.stop; ConstrainAndUpdateFrequencies(); SetRBW(pref.Startup.SA.RBW); + SetAveraging(pref.Startup.SA.averaging); settings.pointNum = 1001; cbWindowType->setCurrentIndex(pref.Startup.SA.window); cbDetector->setCurrentIndex(pref.Startup.SA.detector); @@ -226,6 +238,7 @@ void SpectrumAnalyzer::NewDatapoint(Protocol::SpectrumAnalyzerResult d) traceModel.addSAData(d); emit dataChanged(); if(d.pointNum == settings.pointNum - 1) { + UpdateAverageCount(); markerModel->updateMarkers(); } } @@ -242,6 +255,7 @@ void SpectrumAnalyzer::SettingsChanged() window->getDevice()->Configure(settings); } average.reset(); + UpdateAverageCount(); traceModel.clearVNAData(); emit traceModel.SpanChanged(settings.f_start, settings.f_stop); } @@ -344,6 +358,11 @@ void SpectrumAnalyzer::SetAveraging(unsigned int averages) SettingsChanged(); } +void SpectrumAnalyzer::UpdateAverageCount() +{ + lAverages->setText(QString::number(average.getLevel()) + "/"); +} + void SpectrumAnalyzer::ConstrainAndUpdateFrequencies() { if(settings.f_stop > Device::Limits().maxFreq) { @@ -373,6 +392,7 @@ void SpectrumAnalyzer::LoadSweepSettings() settings.pointNum = 1001; cbWindowType->setCurrentIndex(s.value("SAWindow", pref.Startup.SA.window).toInt()); cbDetector->setCurrentIndex(s.value("SADetector", pref.Startup.SA.detector).toInt()); + SetAveraging(s.value("SAAveraging", pref.Startup.SA.averaging).toInt()); cbSignalID->setChecked(s.value("SASignalID", pref.Startup.SA.signalID).toBool()); } @@ -384,5 +404,6 @@ void SpectrumAnalyzer::StoreSweepSettings() s.setValue("SARBW", settings.RBW); s.setValue("SAWindow", settings.WindowType); s.setValue("SADetector", settings.Detector); + s.setValue("SAAveraging", averages); s.setValue("SASignalID", static_cast(settings.SignalID)); } diff --git a/Software/PC_Application/SpectrumAnalyzer/spectrumanalyzer.h b/Software/PC_Application/SpectrumAnalyzer/spectrumanalyzer.h index b67f020..fca3e64 100644 --- a/Software/PC_Application/SpectrumAnalyzer/spectrumanalyzer.h +++ b/Software/PC_Application/SpectrumAnalyzer/spectrumanalyzer.h @@ -35,7 +35,7 @@ private slots: signals: private: - void UpdateStatusPanel(); + void UpdateAverageCount(); void SettingsChanged(); void ConstrainAndUpdateFrequencies(); void LoadSweepSettings(); @@ -50,6 +50,7 @@ private: TileWidget *central; QCheckBox *cbSignalID; QComboBox *cbWindowType, *cbDetector; + QLabel *lAverages; signals: void dataChanged(); diff --git a/Software/PC_Application/VNA/vna.cpp b/Software/PC_Application/VNA/vna.cpp index 84396be..897f24a 100644 --- a/Software/PC_Application/VNA/vna.cpp +++ b/Software/PC_Application/VNA/vna.cpp @@ -235,6 +235,16 @@ VNA::VNA(AppWindow *window) tb_acq->addWidget(new QLabel("IF BW:")); tb_acq->addWidget(eBandwidth); + tb_acq->addWidget(new QLabel("Averaging:")); + lAverages = new QLabel("0/"); + tb_acq->addWidget(lAverages); + auto sbAverages = new QSpinBox; + sbAverages->setRange(1, 99); + sbAverages->setFixedWidth(40); + connect(sbAverages, qOverload(&QSpinBox::valueChanged), this, &VNA::SetAveraging); + connect(this, &VNA::averagingChanged, sbAverages, &QSpinBox::setValue); + tb_acq->addWidget(sbAverages); + window->addToolBar(tb_acq); toolbars.insert(tb_acq); @@ -307,97 +317,6 @@ VNA::VNA(AppWindow *window) markerModel = new TraceMarkerModel(traceModel); - // Create status panel - auto statusLayout = new QVBoxLayout(); - statusLayout->setSpacing(0); - QFont statusFont( "Arial", 8); - { - auto l = new QLabel("Start Frequency:"); - l->setAlignment(Qt::AlignLeft); - l->setFont(statusFont); - statusLayout->addWidget(l); - lStart = new QLabel; - lStart->setAlignment(Qt::AlignRight); - lStart->setFont(statusFont); - statusLayout->addWidget(lStart); - - l = new QLabel("Center Frequency:"); - l->setAlignment(Qt::AlignLeft); - l->setFont(statusFont); - statusLayout->addWidget(l); - lCenter = new QLabel; - lCenter->setAlignment(Qt::AlignRight); - lCenter->setFont(statusFont); - statusLayout->addWidget(lCenter); - - l = new QLabel("Stop Frequency:"); - l->setAlignment(Qt::AlignLeft); - l->setFont(statusFont); - statusLayout->addWidget(l); - lStop = new QLabel; - lStop->setAlignment(Qt::AlignRight); - lStop->setFont(statusFont); - statusLayout->addWidget(lStop); - - l = new QLabel("Span:"); - l->setAlignment(Qt::AlignLeft); - l->setFont(statusFont); - statusLayout->addWidget(l); - lSpan = new QLabel; - lSpan->setAlignment(Qt::AlignRight); - lSpan->setFont(statusFont); - statusLayout->addWidget(lSpan); - - statusLayout->addStretch(); - - l = new QLabel("Points:"); - l->setAlignment(Qt::AlignLeft); - l->setFont(statusFont); - statusLayout->addWidget(l); - lPoints = new QLabel; - lPoints->setAlignment(Qt::AlignRight); - lPoints->setFont(statusFont); - statusLayout->addWidget(lPoints); - - l = new QLabel("IF Bandwidth:"); - l->setAlignment(Qt::AlignLeft); - l->setFont(statusFont); - statusLayout->addWidget(l); - lBandwidth = new QLabel; - lBandwidth->setAlignment(Qt::AlignRight); - lBandwidth->setFont(statusFont); - statusLayout->addWidget(lBandwidth); - - l = new QLabel("Averages:"); - l->setAlignment(Qt::AlignLeft); - l->setFont(statusFont); - statusLayout->addWidget(l); - lAverages = new QLabel; - lAverages->setAlignment(Qt::AlignRight); - lAverages->setFont(statusFont); - statusLayout->addWidget(lAverages); - - statusLayout->addStretch(); - - l = new QLabel("Calibration:"); - l->setAlignment(Qt::AlignLeft); - l->setFont(statusFont); - statusLayout->addWidget(l); - lCalibration = new QLabel; - lCalibration->setAlignment(Qt::AlignRight); - lCalibration->setFont(statusFont); - statusLayout->addWidget(lCalibration); - } - statusLayout->addStretch(); - - auto statusWidget = new QWidget; - statusWidget->setLayout(statusLayout); -// statusWidget->setFixedWidth(150); - auto statusDock = new QDockWidget("Status"); - statusDock->setWidget(statusWidget); - window->addDockWidget(Qt::LeftDockWidgetArea, statusDock); - docks.insert(statusDock); - auto tracesDock = new QDockWidget("Traces"); tracesDock->setWidget(new TraceWidget(traceModel)); window->addDockWidget(Qt::LeftDockWidgetArea, tracesDock); @@ -411,9 +330,6 @@ VNA::VNA(AppWindow *window) window->addDockWidget(Qt::BottomDockWidgetArea, markerDock); docks.insert(markerDock); - // status dock hidden by default - statusDock->hide(); - qRegisterMetaType("Datapoint"); // Set initial sweep settings @@ -433,6 +349,7 @@ VNA::VNA(AppWindow *window) ConstrainAndUpdateFrequencies(); SetSourceLevel(pref.Startup.DefaultSweep.excitation); SetIFBandwidth(pref.Startup.DefaultSweep.bandwidth); + SetAveraging(pref.Startup.DefaultSweep.averaging); SetPoints(pref.Startup.DefaultSweep.points); } @@ -503,39 +420,14 @@ void VNA::NewDatapoint(Protocol::Datapoint d) traceModel.addVNAData(d); emit dataChanged(); if(d.pointNum == settings.points - 1) { - UpdateStatusPanel(); + UpdateAverageCount(); markerModel->updateMarkers(); } } -void VNA::UpdateStatusPanel() +void VNA::UpdateAverageCount() { - lStart->setText(Unit::ToString(settings.f_start, "Hz", " kMG", 4)); - lCenter->setText(Unit::ToString((settings.f_start + settings.f_stop)/2, "Hz", " kMG", 4)); - lStop->setText(Unit::ToString(settings.f_stop, "Hz", " kMG", 4)); - lSpan->setText(Unit::ToString(settings.f_stop - settings.f_start, "Hz", " kMG", 4)); - lPoints->setText(QString::number(settings.points)); - lBandwidth->setText(Unit::ToString(settings.if_bandwidth, "Hz", " k", 2)); - lAverages->setText(QString::number(average.getLevel()) + "/" + QString::number(averages)); - if(calValid) { - switch(cal.getInterpolation(settings)) { - case Calibration::InterpolationType::Extrapolate: - lCalibration->setText("Enabled/Extrapolating"); - break; - case Calibration::InterpolationType::Interpolate: - lCalibration->setText("Enabled/Interpolating"); - break; - case Calibration::InterpolationType::Exact: - case Calibration::InterpolationType::Unchanged: - lCalibration->setText("Enabled"); - break; - default: - lCalibration->setText("Unknown"); - break; - } - } else { - lCalibration->setText("Off"); - } + lAverages->setText(QString::number(average.getLevel()) + "/"); } void VNA::SettingsChanged() @@ -546,7 +438,7 @@ void VNA::SettingsChanged() } average.reset(); traceModel.clearVNAData(); - UpdateStatusPanel(); + UpdateAverageCount(); emit traceModel.SpanChanged(settings.f_start, settings.f_stop); } @@ -778,6 +670,7 @@ void VNA::LoadSweepSettings() ConstrainAndUpdateFrequencies(); SetIFBandwidth(s.value("SweepBandwidth", pref.Startup.DefaultSweep.bandwidth).toUInt()); SetPoints(s.value("SweepPoints", pref.Startup.DefaultSweep.points).toInt()); + SetAveraging(s.value("SweepAveraging", pref.Startup.DefaultSweep.averaging).toInt()); SetSourceLevel(s.value("SweepLevel", pref.Startup.DefaultSweep.excitation).toDouble()); } @@ -788,5 +681,6 @@ void VNA::StoreSweepSettings() s.setValue("SweepStop", static_cast(settings.f_stop)); s.setValue("SweepBandwidth", settings.if_bandwidth); s.setValue("SweepPoints", settings.points); + s.setValue("SweepAveraging", averages); s.setValue("SweepLevel", (double) settings.cdbm_excitation / 100.0); } diff --git a/Software/PC_Application/VNA/vna.h b/Software/PC_Application/VNA/vna.h index 0aa89fb..b44cf81 100644 --- a/Software/PC_Application/VNA/vna.h +++ b/Software/PC_Application/VNA/vna.h @@ -42,7 +42,7 @@ signals: void CalibrationMeasurementComplete(Calibration::Measurement m); private: - void UpdateStatusPanel(); + void UpdateAverageCount(); void SettingsChanged(); void ConstrainAndUpdateFrequencies(); void LoadSweepSettings(); @@ -66,8 +66,6 @@ private: QAction *assignDefaultCal, *removeDefaultCal; // Status Labels - QLabel *lStart, *lCenter, *lStop, *lSpan, *lPoints, *lBandwidth; - QLabel *lCalibration; QLabel *lAverages; TileWidget *central; diff --git a/Software/PC_Application/preferences.cpp b/Software/PC_Application/preferences.cpp index 3dd3128..59c1bd4 100644 --- a/Software/PC_Application/preferences.cpp +++ b/Software/PC_Application/preferences.cpp @@ -24,6 +24,7 @@ PreferencesDialog::PreferencesDialog(Preferences *pref, QWidget *parent) : ui->StartupSweepPoints->setEnabled(false); ui->StartupSweepLevel->setEnabled(false); ui->StartupSweepBandwidth->setEnabled(false); + ui->StartupSweepAveraging->setEnabled(false); ui->StartupGeneratorFrequency->setEnabled(false); ui->StartupGeneratorLevel->setEnabled(false); ui->StartupSAStart->setEnabled(false); @@ -31,6 +32,7 @@ PreferencesDialog::PreferencesDialog(Preferences *pref, QWidget *parent) : ui->StartupSARBW->setEnabled(false); ui->StartupSAWindow->setEnabled(false); ui->StartupSADetector->setEnabled(false); + ui->StartupSAAveraging->setEnabled(false); ui->StartupSASignalID->setEnabled(false); }); connect(ui->StartupSweepDefault, &QPushButton::clicked, [=](){ @@ -39,6 +41,7 @@ PreferencesDialog::PreferencesDialog(Preferences *pref, QWidget *parent) : ui->StartupSweepPoints->setEnabled(true); ui->StartupSweepLevel->setEnabled(true); ui->StartupSweepBandwidth->setEnabled(true); + ui->StartupSweepAveraging->setEnabled(true); ui->StartupGeneratorFrequency->setEnabled(true); ui->StartupGeneratorLevel->setEnabled(true); ui->StartupSAStart->setEnabled(true); @@ -46,6 +49,7 @@ PreferencesDialog::PreferencesDialog(Preferences *pref, QWidget *parent) : ui->StartupSARBW->setEnabled(true); ui->StartupSAWindow->setEnabled(true); ui->StartupSADetector->setEnabled(true); + ui->StartupSAAveraging->setEnabled(true); ui->StartupSASignalID->setEnabled(true); }); ui->StartupSweepStart->setUnit("Hz"); @@ -92,6 +96,7 @@ PreferencesDialog::PreferencesDialog(Preferences *pref, QWidget *parent) : p->Startup.DefaultSweep.bandwidth = ui->StartupSweepBandwidth->value(); p->Startup.DefaultSweep.points = ui->StartupSweepPoints->value(); p->Startup.DefaultSweep.excitation = ui->StartupSweepLevel->value(); + p->Startup.DefaultSweep.averaging = ui->StartupSweepAveraging->value(); p->Startup.Generator.frequency = ui->StartupGeneratorFrequency->value(); p->Startup.Generator.level = ui->StartupGeneratorLevel->value(); p->Startup.SA.start = ui->StartupSAStart->value(); @@ -131,11 +136,13 @@ void PreferencesDialog::setInitialGUIState() ui->StartupSweepLevel->setValue(p->Startup.DefaultSweep.excitation); ui->StartupGeneratorFrequency->setValue(p->Startup.Generator.frequency); ui->StartupGeneratorLevel->setValue(p->Startup.Generator.level); + ui->StartupSweepAveraging->setValue(p->Startup.DefaultSweep.averaging); ui->StartupSAStart->setValue(p->Startup.SA.start); ui->StartupSAStop->setValue(p->Startup.SA.stop); ui->StartupSARBW->setValue(p->Startup.SA.RBW); ui->StartupSAWindow->setCurrentIndex(p->Startup.SA.window); ui->StartupSADetector->setCurrentIndex(p->Startup.SA.detector); + ui->StartupSAAveraging->setValue(p->Startup.SA.averaging); ui->StartupSASignalID->setChecked(p->Startup.SA.signalID); ui->AcquisitionAlwaysExciteBoth->setChecked(p->Acquisition.alwaysExciteBothPorts); diff --git a/Software/PC_Application/preferences.h b/Software/PC_Application/preferences.h index 43831c9..c72cdbe 100644 --- a/Software/PC_Application/preferences.h +++ b/Software/PC_Application/preferences.h @@ -47,6 +47,7 @@ public: int points; double bandwidth; double excitation; + int averaging; } DefaultSweep; struct { double frequency; @@ -58,6 +59,7 @@ public: double RBW; int window; int detector; + int averaging; bool signalID; } SA; } Startup; @@ -80,7 +82,7 @@ private: QString name; QVariant def; }; - const std::array descr = {{ + const std::array descr = {{ {&Startup.ConnectToFirstDevice, "Startup.ConnectToFirstDevice", true}, {&Startup.RememberSweepSettings, "Startup.RememberSweepSettings", false}, {&Startup.DefaultSweep.start, "Startup.DefaultSweep.start", 1000000.0}, @@ -88,6 +90,7 @@ private: {&Startup.DefaultSweep.points, "Startup.DefaultSweep.points", 501}, {&Startup.DefaultSweep.bandwidth, "Startup.DefaultSweep.bandwidth", 1000.0}, {&Startup.DefaultSweep.excitation, "Startup.DefaultSweep.excitation", -10.00}, + {&Startup.DefaultSweep.averaging, "Startup.DefaultSweep.averaging", 1}, {&Startup.Generator.frequency, "Startup.Generator.frequency", 1000000000.0}, {&Startup.Generator.level, "Startup.Generator.level", -10.00}, {&Startup.SA.start, "Startup.SA.start", 950000000.0}, @@ -95,6 +98,7 @@ private: {&Startup.SA.RBW, "Startup.SA.RBW", 10000.0}, {&Startup.SA.window, "Startup.SA.window", 1}, {&Startup.SA.detector, "Startup.SA.detector", 0}, + {&Startup.SA.averaging, "Startup.SA.averaging", 1}, {&Startup.SA.signalID, "Startup.SA.signalID", true}, {&Acquisition.alwaysExciteBothPorts, "Acquisition.alwaysExciteBothPorts", true}, {&Acquisition.suppressPeaks, "Acquisition.suppressPeaks", true}, diff --git a/Software/PC_Application/preferencesdialog.ui b/Software/PC_Application/preferencesdialog.ui index 8284d52..f9a6e74 100644 --- a/Software/PC_Application/preferencesdialog.ui +++ b/Software/PC_Application/preferencesdialog.ui @@ -6,8 +6,8 @@ 0 0 - 619 - 730 + 613 + 794 @@ -73,7 +73,7 @@ - 2 + 0 @@ -219,6 +219,23 @@ + + + + Averaging: + + + + + + + 1 + + + 99 + + + @@ -367,20 +384,37 @@ - + Signal Identification: - + + + + + Averaging: + + + + + + + 1 + + + 99 + + +