From 3da7933fa7ff9879d96d95fb3c7010d32c082e7f Mon Sep 17 00:00:00 2001 From: f4exb Date: Thu, 15 Nov 2018 23:00:55 +0100 Subject: [PATCH] SoapySDR support: REST API: fixed individual gains and tunable elements settings --- .../soapysdroutput/soapysdroutput.cpp | 20 +++++++++++-------- .../soapysdrinput/soapysdrinput.cpp | 20 +++++++++++-------- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/plugins/samplesink/soapysdroutput/soapysdroutput.cpp b/plugins/samplesink/soapysdroutput/soapysdroutput.cpp index c775143cd..68374f2ff 100644 --- a/plugins/samplesink/soapysdroutput/soapysdroutput.cpp +++ b/plugins/samplesink/soapysdroutput/soapysdroutput.cpp @@ -1309,12 +1309,14 @@ int SoapySDROutput::webapiSettingsPutPatch( { QList *tunableElements = response.getSoapySdrOutputSettings()->getTunableElements(); - for (const auto itArg : *tunableElements) + for (const auto &itArg : *tunableElements) { - auto ovalue = settings.m_tunableElements.find(*itArg->getKey()); + QMap::iterator itSettings = settings.m_tunableElements.find(*(itArg->getKey())); - if ((ovalue != settings.m_tunableElements.end()) && (atof(itArg->getValueString()->toStdString().c_str()) != *ovalue)) { - m_settings.m_tunableElements[*itArg->getKey()] = atof(itArg->getValueString()->toStdString().c_str()); + if (itSettings != settings.m_tunableElements.end()) + { + QVariant v = webapiVariantFromArgValue(itArg); + itSettings.value() = v.toDouble(); } } } @@ -1327,12 +1329,14 @@ int SoapySDROutput::webapiSettingsPutPatch( { QList *individualGains = response.getSoapySdrOutputSettings()->getIndividualGains(); - for (const auto itArg : *individualGains) + for (const auto &itArg : *individualGains) { - auto ovalue = settings.m_individualGains.find(*itArg->getKey()); + QMap::iterator itSettings = settings.m_individualGains.find(*(itArg->getKey())); - if ((ovalue != settings.m_individualGains.end()) && (atof(itArg->getValueString()->toStdString().c_str()) != *ovalue)) { - m_settings.m_individualGains[*itArg->getKey()] = atof(itArg->getValueString()->toStdString().c_str()); + if (itSettings != settings.m_individualGains.end()) + { + QVariant v = webapiVariantFromArgValue(itArg); + itSettings.value() = v.toDouble(); } } } diff --git a/plugins/samplesource/soapysdrinput/soapysdrinput.cpp b/plugins/samplesource/soapysdrinput/soapysdrinput.cpp index 8bdbc2b36..b516f9eb6 100644 --- a/plugins/samplesource/soapysdrinput/soapysdrinput.cpp +++ b/plugins/samplesource/soapysdrinput/soapysdrinput.cpp @@ -1373,12 +1373,14 @@ int SoapySDRInput::webapiSettingsPutPatch( { QList *tunableElements = response.getSoapySdrInputSettings()->getTunableElements(); - for (const auto itArg : *tunableElements) + for (const auto &itArg : *tunableElements) { - auto ovalue = settings.m_tunableElements.find(*itArg->getKey()); + QMap::iterator itSettings = settings.m_tunableElements.find(*(itArg->getKey())); - if ((ovalue != settings.m_tunableElements.end()) && (atof(itArg->getValueString()->toStdString().c_str()) != *ovalue)) { - m_settings.m_tunableElements[*itArg->getKey()] = atof(itArg->getValueString()->toStdString().c_str()); + if (itSettings != settings.m_tunableElements.end()) + { + QVariant v = webapiVariantFromArgValue(itArg); + itSettings.value() = v.toDouble(); } } } @@ -1391,12 +1393,14 @@ int SoapySDRInput::webapiSettingsPutPatch( { QList *individualGains = response.getSoapySdrInputSettings()->getIndividualGains(); - for (const auto itArg : *individualGains) + for (const auto &itArg : *individualGains) { - auto ovalue = settings.m_individualGains.find(*itArg->getKey()); + QMap::iterator itSettings = settings.m_individualGains.find(*(itArg->getKey())); - if ((ovalue != settings.m_individualGains.end()) && (atof(itArg->getValueString()->toStdString().c_str()) != *ovalue)) { - m_settings.m_individualGains[*itArg->getKey()] = atof(itArg->getValueString()->toStdString().c_str()); + if (itSettings != settings.m_individualGains.end()) + { + QVariant v = webapiVariantFromArgValue(itArg); + itSettings.value() = v.toDouble(); } } }