From 2963e8b3d5b6466c576d2c1e51d2691e62dbfea4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20K=C3=A4berich?= Date: Sat, 20 Apr 2024 15:56:57 +0200 Subject: [PATCH] Reset refernence on *RST, fix VNA:ACQ:RUN? query --- .../Device/LibreVNA/librevnadriver.cpp | 6 ++++++ .../SpectrumAnalyzer/spectrumanalyzer.cpp | 4 +++- Software/PC_Application/LibreVNA-GUI/VNA/vna.cpp | 14 +++----------- Software/PC_Application/LibreVNA-GUI/appwindow.cpp | 8 ++++++++ Software/PC_Application/LibreVNA-GUI/appwindow.h | 1 + 5 files changed, 21 insertions(+), 12 deletions(-) diff --git a/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/librevnadriver.cpp b/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/librevnadriver.cpp index 9545c21..33a10f2 100644 --- a/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/librevnadriver.cpp +++ b/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/librevnadriver.cpp @@ -546,6 +546,9 @@ bool LibreVNADriver::setExtRef(QString option_in, QString option_out) case Reference::TypeIn::None: p.reference.UseExternalRef = 0; p.reference.AutomaticSwitch = 0; + if(hardwareVersion == 0x01) { + lastStatus.V1.extRefInUse = 0; + } break; case Reference::TypeIn::Auto: p.reference.UseExternalRef = 0; @@ -554,6 +557,9 @@ bool LibreVNADriver::setExtRef(QString option_in, QString option_out) case Reference::TypeIn::External: p.reference.UseExternalRef = 1; p.reference.AutomaticSwitch = 0; + if(hardwareVersion == 0x01) { + lastStatus.V1.extRefInUse = 1; + } break; } switch(refOut) { diff --git a/Software/PC_Application/LibreVNA-GUI/SpectrumAnalyzer/spectrumanalyzer.cpp b/Software/PC_Application/LibreVNA-GUI/SpectrumAnalyzer/spectrumanalyzer.cpp index d0d21f2..feb0f63 100644 --- a/Software/PC_Application/LibreVNA-GUI/SpectrumAnalyzer/spectrumanalyzer.cpp +++ b/Software/PC_Application/LibreVNA-GUI/SpectrumAnalyzer/spectrumanalyzer.cpp @@ -966,7 +966,9 @@ void SpectrumAnalyzer::SetupSCPI() scpi_acq->add(new SCPICommand("RUN", [=](QStringList) -> QString { Run(); return SCPI::getResultName(SCPI::Result::Empty); - }, nullptr)); + }, [=](QStringList) -> QString { + return running ? SCPI::getResultName(SCPI::Result::True) : SCPI::getResultName(SCPI::Result::False); + })); scpi_acq->add(new SCPICommand("STOP", [=](QStringList) -> QString { Stop(); return SCPI::getResultName(SCPI::Result::Empty); diff --git a/Software/PC_Application/LibreVNA-GUI/VNA/vna.cpp b/Software/PC_Application/LibreVNA-GUI/VNA/vna.cpp index 45c9ffe..88c033a 100644 --- a/Software/PC_Application/LibreVNA-GUI/VNA/vna.cpp +++ b/Software/PC_Application/LibreVNA-GUI/VNA/vna.cpp @@ -1421,7 +1421,9 @@ void VNA::SetupSCPI() scpi_acq->add(new SCPICommand("RUN", [=](QStringList) -> QString { Run(); return SCPI::getResultName(SCPI::Result::Empty); - }, nullptr)); + }, [=](QStringList) -> QString { + return running ? SCPI::getResultName(SCPI::Result::True) : SCPI::getResultName(SCPI::Result::False); + })); scpi_acq->add(new SCPICommand("STOP", [=](QStringList) -> QString { Stop(); return SCPI::getResultName(SCPI::Result::Empty); @@ -1479,16 +1481,6 @@ void VNA::SetupSCPI() }, [=](QStringList) -> QString { return singleSweep ? SCPI::getResultName(SCPI::Result::True) : SCPI::getResultName(SCPI::Result::False); })); - scpi_acq->add(new SCPICommand("RUN", [=](QStringList) -> QString { - Run(); - return SCPI::getResultName(SCPI::Result::Empty); - }, [=](QStringList) -> QString { - return running ? SCPI::getResultName(SCPI::Result::True) : SCPI::getResultName(SCPI::Result::False); - })); - scpi_acq->add(new SCPICommand("STOP", [=](QStringList) -> QString { - Stop(); - return SCPI::getResultName(SCPI::Result::Empty); - }, nullptr)); auto scpi_stim = new SCPINode("STIMulus"); SCPINode::add(scpi_stim); scpi_stim->add(new SCPICommand("LVL", [=](QStringList params) -> QString { diff --git a/Software/PC_Application/LibreVNA-GUI/appwindow.cpp b/Software/PC_Application/LibreVNA-GUI/appwindow.cpp index 327147c..dffc501 100644 --- a/Software/PC_Application/LibreVNA-GUI/appwindow.cpp +++ b/Software/PC_Application/LibreVNA-GUI/appwindow.cpp @@ -322,6 +322,8 @@ void AppWindow::SetInitialState() modeHandler->createMode("Spectrum Analyzer", Mode::Type::SA); modeHandler->setCurrentIndex(vnaIndex); } + + ResetReference(); } bool AppWindow::ConnectToDevice(QString serial, DeviceDriver *driver) @@ -1043,6 +1045,12 @@ int AppWindow::UpdateDeviceList() return available; } +void AppWindow::ResetReference() +{ + toolbars.reference.type->setCurrentIndex(0); + toolbars.reference.outFreq->setCurrentIndex(0); +} + //void AppWindow::StartManualControl() //{ // if(!vdevice || vdevice->isCompoundDevice()) { diff --git a/Software/PC_Application/LibreVNA-GUI/appwindow.h b/Software/PC_Application/LibreVNA-GUI/appwindow.h index 175dd1b..911390e 100644 --- a/Software/PC_Application/LibreVNA-GUI/appwindow.h +++ b/Software/PC_Application/LibreVNA-GUI/appwindow.h @@ -63,6 +63,7 @@ private slots: void DisconnectDevice(); int UpdateDeviceList(); // void StartManualControl(); + void ResetReference(); void UpdateReferenceToolbar(); void UpdateReference(); void DeviceStatusUpdated();