Ignore incoming datapoints while changing settings

This commit is contained in:
Jan Käberich 2022-03-07 22:51:56 +01:00
parent c85d8e8e1f
commit 16e001a64d
2 changed files with 14 additions and 0 deletions

View File

@ -63,6 +63,7 @@ VNA::VNA(AppWindow *window)
calWaitFirst = false; calWaitFirst = false;
calDialog.reset(); calDialog.reset();
calEdited = false; calEdited = false;
changingSettings = false;
settings.sweepType = SweepType::Frequency; settings.sweepType = SweepType::Frequency;
traceModel.setSource(TraceModel::DataSource::VNA); traceModel.setSource(TraceModel::DataSource::VNA);
@ -788,6 +789,11 @@ using namespace std;
void VNA::NewDatapoint(Protocol::Datapoint d) void VNA::NewDatapoint(Protocol::Datapoint d)
{ {
if(changingSettings) {
// already setting new sweep settings, ignore incoming points from old settings
return;
}
bool needsSegmentUpdate = false; bool needsSegmentUpdate = false;
if (settings.segments > 1) { if (settings.segments > 1) {
// using multiple segments, adjust pointNum // using multiple segments, adjust pointNum
@ -854,6 +860,7 @@ void VNA::NewDatapoint(Protocol::Datapoint d)
lastPoint = d.pointNum; lastPoint = d.pointNum;
if (needsSegmentUpdate) { if (needsSegmentUpdate) {
changingSettings = true;
if( settings.activeSegment < settings.segments - 1) { if( settings.activeSegment < settings.segments - 1) {
settings.activeSegment++; settings.activeSegment++;
} else { } else {
@ -870,6 +877,10 @@ void VNA::UpdateAverageCount()
void VNA::SettingsChanged(bool resetTraces, std::function<void (Device::TransmissionResult)> cb) void VNA::SettingsChanged(bool resetTraces, std::function<void (Device::TransmissionResult)> cb)
{ {
if (resetTraces) {
settings.activeSegment = 0;
}
changingSettings = true;
// assemble VNA protocol settings // assemble VNA protocol settings
Protocol::SweepSettings s; Protocol::SweepSettings s;
s.suppressPeaks = Preferences::getInstance().Acquisition.suppressPeaks ? 1 : 0; s.suppressPeaks = Preferences::getInstance().Acquisition.suppressPeaks ? 1 : 0;
@ -925,6 +936,7 @@ void VNA::SettingsChanged(bool resetTraces, std::function<void (Device::Transmis
if(s.excitePort1 == 0 && s.excitePort2 == 0) { if(s.excitePort1 == 0 && s.excitePort2 == 0) {
// no signal at either port, just set the device to idle // no signal at either port, just set the device to idle
window->getDevice()->SetIdle(); window->getDevice()->SetIdle();
changingSettings = false;
} else { } else {
window->getDevice()->Configure(s, [=](Device::TransmissionResult res){ window->getDevice()->Configure(s, [=](Device::TransmissionResult res){
// device received command, reset traces now // device received command, reset traces now
@ -937,6 +949,7 @@ void VNA::SettingsChanged(bool resetTraces, std::function<void (Device::Transmis
if(cb) { if(cb) {
cb(res); cb(res);
} }
changingSettings = false;
}); });
} }
} }

View File

@ -125,6 +125,7 @@ private:
// Calibration // Calibration
Calibration cal; Calibration cal;
bool changingSettings;
bool calValid; bool calValid;
bool calEdited; bool calEdited;
std::set<Calibration::Measurement> calMeasurements; std::set<Calibration::Measurement> calMeasurements;