mirror of
https://github.com/jankae/LibreVNA.git
synced 2025-12-06 07:12:10 +01:00
decouple RST settings from startup settings
This commit is contained in:
parent
77efc4d924
commit
5692356e90
|
|
@ -46,6 +46,13 @@ void Generator::initializeDevice()
|
|||
updateDevice();
|
||||
}
|
||||
|
||||
void Generator::resetSettings()
|
||||
{
|
||||
central->setFrequency(1000000000);
|
||||
central->setLevel(0);
|
||||
central->setPort(0);
|
||||
}
|
||||
|
||||
nlohmann::json Generator::toJSON()
|
||||
{
|
||||
return central->toJSON();
|
||||
|
|
|
|||
|
|
@ -15,6 +15,8 @@ public:
|
|||
|
||||
virtual Type getType() override { return Type::SG;}
|
||||
|
||||
virtual void resetSettings() override;
|
||||
|
||||
// Nothing to do for now
|
||||
virtual nlohmann::json toJSON() override;
|
||||
virtual void fromJSON(nlohmann::json j) override;
|
||||
|
|
|
|||
|
|
@ -366,6 +366,18 @@ void SpectrumAnalyzer::deviceDisconnected()
|
|||
emit sweepStopped();
|
||||
}
|
||||
|
||||
void SpectrumAnalyzer::resetSettings()
|
||||
{
|
||||
settings.freqStart = DeviceDriver::getInfo(window->getDevice()).Limits.SA.minFreq;
|
||||
settings.freqStop = DeviceDriver::getInfo(window->getDevice()).Limits.SA.maxFreq;
|
||||
ConstrainAndUpdateFrequencies();
|
||||
SetRBW(1000000);
|
||||
SetAveraging(1);
|
||||
SetWindow(DeviceDriver::SASettings::Window::FlatTop);
|
||||
SetDetector(DeviceDriver::SASettings::Detector::PPeak);
|
||||
Stop();
|
||||
}
|
||||
|
||||
nlohmann::json SpectrumAnalyzer::toJSON()
|
||||
{
|
||||
nlohmann::json j;
|
||||
|
|
|
|||
|
|
@ -25,6 +25,8 @@ public:
|
|||
|
||||
virtual Type getType() override { return Type::SA;}
|
||||
|
||||
virtual void resetSettings() override;
|
||||
|
||||
// Only save/load user changeable stuff, no need to save the widgets/mode name etc.
|
||||
virtual nlohmann::json toJSON() override;
|
||||
virtual void fromJSON(nlohmann::json j) override;
|
||||
|
|
|
|||
|
|
@ -772,6 +772,23 @@ void VNA::shutdown()
|
|||
}
|
||||
}
|
||||
|
||||
void VNA::resetSettings()
|
||||
{
|
||||
settings.Freq.start = DeviceDriver::getInfo(window->getDevice()).Limits.VNA.minFreq;
|
||||
settings.Freq.stop = DeviceDriver::getInfo(window->getDevice()).Limits.VNA.maxFreq;
|
||||
SetLogSweep(false);
|
||||
SetSourceLevel(DeviceDriver::getInfo(window->getDevice()).Limits.VNA.maxdBm);
|
||||
ConstrainAndUpdateFrequencies();
|
||||
SetStartPower(DeviceDriver::getInfo(window->getDevice()).Limits.VNA.mindBm);
|
||||
SetStopPower(DeviceDriver::getInfo(window->getDevice()).Limits.VNA.maxdBm);
|
||||
SetPowerSweepFrequency(DeviceDriver::getInfo(window->getDevice()).Limits.VNA.maxFreq);
|
||||
SetIFBandwidth(1000);
|
||||
SetAveraging(1);
|
||||
SetPoints(501);
|
||||
SetSweepType(SweepType::Frequency);
|
||||
Stop();
|
||||
}
|
||||
|
||||
nlohmann::json VNA::toJSON()
|
||||
{
|
||||
nlohmann::json j;
|
||||
|
|
|
|||
|
|
@ -27,6 +27,8 @@ public:
|
|||
|
||||
virtual Type getType() override { return Type::VNA;}
|
||||
|
||||
virtual void resetSettings() override;
|
||||
|
||||
// Only save/load user changeable stuff, no need to save the widgets/mode name etc.
|
||||
virtual nlohmann::json toJSON() override;
|
||||
virtual void fromJSON(nlohmann::json j) override;
|
||||
|
|
|
|||
|
|
@ -324,6 +324,20 @@ void AppWindow::SetInitialState()
|
|||
}
|
||||
}
|
||||
|
||||
void AppWindow::SetResetState()
|
||||
{
|
||||
modeHandler->closeModes();
|
||||
auto vnaIndex = modeHandler->createMode("Vector Network Analyzer", Mode::Type::VNA);
|
||||
modeHandler->createMode("Signal Generator", Mode::Type::SG);
|
||||
modeHandler->createMode("Spectrum Analyzer", Mode::Type::SA);
|
||||
|
||||
for(auto m : modeHandler->getModes()) {
|
||||
m->resetSettings();
|
||||
}
|
||||
|
||||
modeHandler->setCurrentIndex(vnaIndex);
|
||||
}
|
||||
|
||||
bool AppWindow::ConnectToDevice(QString serial, DeviceDriver *driver)
|
||||
{
|
||||
if(serial.isEmpty()) {
|
||||
|
|
@ -487,15 +501,7 @@ void AppWindow::SetupSCPI()
|
|||
return "LibreVNA,LibreVNA-GUI,dummy_serial,"+appVersion;
|
||||
}));
|
||||
scpi.add(new SCPICommand("*RST", [=](QStringList){
|
||||
SetInitialState();
|
||||
auto vna = dynamic_cast<VNA*>(modeHandler->getActiveMode());
|
||||
if(vna) {
|
||||
vna->Stop();
|
||||
}
|
||||
auto sa = dynamic_cast<SpectrumAnalyzer*>(modeHandler->getActiveMode());
|
||||
if(sa) {
|
||||
sa->Stop();
|
||||
}
|
||||
SetResetState();
|
||||
ResetReference();
|
||||
return SCPI::getResultName(SCPI::Result::Empty);
|
||||
}, nullptr));
|
||||
|
|
|
|||
|
|
@ -59,6 +59,7 @@ protected:
|
|||
void closeEvent(QCloseEvent *event) override;
|
||||
private slots:
|
||||
void SetInitialState();
|
||||
void SetResetState();
|
||||
bool ConnectToDevice(QString serial = QString(), DeviceDriver *driver = nullptr);
|
||||
void DisconnectDevice();
|
||||
int UpdateDeviceList();
|
||||
|
|
|
|||
|
|
@ -36,6 +36,8 @@ public:
|
|||
static Type TypeFromName(QString s);
|
||||
virtual Type getType() = 0;
|
||||
|
||||
virtual void resetSettings(){}
|
||||
|
||||
virtual void initializeDevice() = 0;
|
||||
virtual void deviceDisconnected(){}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue