Improve load time of setup files by omitting excessive device configuration

This commit is contained in:
Jan Käberich 2022-10-30 12:07:59 +01:00
parent 2f5cbc80e9
commit eff18a22e8
7 changed files with 213 additions and 173 deletions

View file

@ -1140,6 +1140,14 @@ void AppWindow::LoadSetup(nlohmann::json j)
toolbars.reference.outFreq->setCurrentText(QString::fromStdString(j["Reference"].value("Output", "Off")));
}
// Disconnect device prior to deleting and creating new modes. This prevents excessice and unnnecessary configuration of the device
QString serial = QString();
if(vdevice->getConnected()) {
serial = vdevice->serial();
delete vdevice;
vdevice = nullptr;
}
modeHandler->closeModes();
/* old style VNA/Generator/Spectrum Analyzer settings,
@ -1170,6 +1178,11 @@ void AppWindow::LoadSetup(nlohmann::json j)
}
}
// reconnect to device
if(!serial.isEmpty()) {
vdevice = new VirtualDevice(serial);
}
// activate the correct mode
QString modeName = QString::fromStdString(j.value("activeMode", ""));
for(auto m : modeHandler->getModes()) {