mirror of
https://github.com/f4exb/sdrangel.git
synced 2026-06-08 00:44:48 -04:00
API: simplify handling of ChannelAnalyzer and SoapySDR
This commit is contained in:
@@ -4642,17 +4642,15 @@ bool WebAPIRequestMapper::getDeviceSettings(
|
||||
}
|
||||
else if (deviceSettingsKey == "soapySDRInputSettings")
|
||||
{
|
||||
processSoapySDRSettings(deviceSettings, settingsJsonObject, deviceSettingsKeys, true);
|
||||
// deviceSettings->setSoapySdrInputSettings(new SWGSDRangel::SWGSoapySDRInputSettings());
|
||||
// deviceSettings->getSoapySdrInputSettings()->init(); // contains complex objects
|
||||
// deviceSettings->getSoapySdrInputSettings()->fromJsonObject(settingsJsonObject);
|
||||
deviceSettings->setSoapySdrInputSettings(new SWGSDRangel::SWGSoapySDRInputSettings());
|
||||
deviceSettings->getSoapySdrInputSettings()->init(); // contains complex objects
|
||||
deviceSettings->getSoapySdrInputSettings()->fromJsonObject(settingsJsonObject);
|
||||
}
|
||||
else if (deviceSettingsKey == "soapySDROutputSettings")
|
||||
{
|
||||
processSoapySDRSettings(deviceSettings, settingsJsonObject, deviceSettingsKeys, false);
|
||||
// deviceSettings->setSoapySdrOutputSettings(new SWGSDRangel::SWGSoapySDROutputSettings());
|
||||
// deviceSettings->getSoapySdrOutputSettings()->init(); // contains complex objects
|
||||
// deviceSettings->getSoapySdrOutputSettings()->fromJsonObject(settingsJsonObject);
|
||||
deviceSettings->setSoapySdrOutputSettings(new SWGSDRangel::SWGSoapySDROutputSettings());
|
||||
deviceSettings->getSoapySdrOutputSettings()->init(); // contains complex objects
|
||||
deviceSettings->getSoapySdrOutputSettings()->fromJsonObject(settingsJsonObject);
|
||||
}
|
||||
else if (deviceSettingsKey == "testSourceSettings")
|
||||
{
|
||||
@@ -5140,262 +5138,3 @@ void WebAPIRequestMapper::resetFeatureActions(SWGSDRangel::SWGFeatureActions& fe
|
||||
featureActions.setSimplePttActions(nullptr);
|
||||
}
|
||||
|
||||
void WebAPIRequestMapper::processSoapySDRSettings(
|
||||
SWGSDRangel::SWGDeviceSettings *deviceSettings,
|
||||
QJsonObject& deviceSettingsJson,
|
||||
QStringList& deviceSettingsKeys,
|
||||
bool inputElseOutput
|
||||
)
|
||||
{
|
||||
if (inputElseOutput)
|
||||
{
|
||||
SWGSDRangel::SWGSoapySDRInputSettings *swgSoapySDRInputSettings = new SWGSDRangel::SWGSoapySDRInputSettings();
|
||||
deviceSettings->setSoapySdrInputSettings(swgSoapySDRInputSettings);
|
||||
swgSoapySDRInputSettings->init();
|
||||
|
||||
if (deviceSettingsJson.contains("centerFrequency")) {
|
||||
swgSoapySDRInputSettings->setCenterFrequency(deviceSettingsJson["centerFrequency"].toInt());
|
||||
}
|
||||
if (deviceSettingsJson.contains("LOppmTenths")) {
|
||||
swgSoapySDRInputSettings->setLOppmTenths(deviceSettingsJson["LOppmTenths"].toInt());
|
||||
}
|
||||
if (deviceSettingsJson.contains("devSampleRate")) {
|
||||
swgSoapySDRInputSettings->setDevSampleRate(deviceSettingsJson["devSampleRate"].toInt());
|
||||
}
|
||||
if (deviceSettingsJson.contains("log2Decim")) {
|
||||
swgSoapySDRInputSettings->setLog2Decim(deviceSettingsJson["log2Decim"].toInt());
|
||||
}
|
||||
if (deviceSettingsJson.contains("fcPos")) {
|
||||
swgSoapySDRInputSettings->setFcPos(deviceSettingsJson["fcPos"].toInt());
|
||||
}
|
||||
if (deviceSettingsJson.contains("softDCCorrection")) {
|
||||
swgSoapySDRInputSettings->setSoftDcCorrection(deviceSettingsJson["softDCCorrection"].toInt());
|
||||
}
|
||||
if (deviceSettingsJson.contains("softIQCorrection")) {
|
||||
swgSoapySDRInputSettings->setSoftIqCorrection(deviceSettingsJson["softIQCorrection"].toInt());
|
||||
}
|
||||
if (deviceSettingsJson.contains("transverterMode")) {
|
||||
swgSoapySDRInputSettings->setTransverterMode(deviceSettingsJson["transverterMode"].toInt());
|
||||
}
|
||||
if (deviceSettingsJson.contains("transverterDeltaFrequency")) {
|
||||
swgSoapySDRInputSettings->setTransverterDeltaFrequency(deviceSettingsJson["transverterDeltaFrequency"].toInt());
|
||||
}
|
||||
if (deviceSettingsJson.contains("antenna")) {
|
||||
swgSoapySDRInputSettings->setAntenna(new QString(deviceSettingsJson["antenna"].toString()));
|
||||
}
|
||||
if (deviceSettingsJson.contains("bandwidth")) {
|
||||
swgSoapySDRInputSettings->setBandwidth(deviceSettingsJson["bandwidth"].toInt());
|
||||
}
|
||||
if (deviceSettingsJson.contains("globalGain")) {
|
||||
swgSoapySDRInputSettings->setGlobalGain(deviceSettingsJson["globalGain"].toInt());
|
||||
}
|
||||
if (deviceSettingsJson.contains("autoGain")) {
|
||||
swgSoapySDRInputSettings->setAutoGain(deviceSettingsJson["autoGain"].toInt());
|
||||
}
|
||||
if (deviceSettingsJson.contains("autoDCCorrection")) {
|
||||
swgSoapySDRInputSettings->setAutoDcCorrection(deviceSettingsJson["autoDCCorrection"].toInt());
|
||||
}
|
||||
if (deviceSettingsJson.contains("autoIQCorrection")) {
|
||||
swgSoapySDRInputSettings->setAutoIqCorrection(deviceSettingsJson["autoIQCorrection"].toInt());
|
||||
}
|
||||
if (deviceSettingsJson.contains("dcCorrection"))
|
||||
{
|
||||
SWGSDRangel::SWGComplex *swgComplex = new SWGSDRangel::SWGComplex;
|
||||
swgSoapySDRInputSettings->setDcCorrection(swgComplex);
|
||||
QJsonObject complexJson = deviceSettingsJson["dcCorrection"].toObject();
|
||||
|
||||
if (complexJson.contains("real")) {
|
||||
swgComplex->setReal(complexJson["real"].toDouble());
|
||||
}
|
||||
if (complexJson.contains("imag")) {
|
||||
swgComplex->setImag(complexJson["imag"].toDouble());
|
||||
}
|
||||
}
|
||||
if (deviceSettingsJson.contains("iqCorrection"))
|
||||
{
|
||||
SWGSDRangel::SWGComplex *swgComplex = new SWGSDRangel::SWGComplex;
|
||||
swgSoapySDRInputSettings->setIqCorrection(swgComplex);
|
||||
QJsonObject complexJson = deviceSettingsJson["iqCorrection"].toObject();
|
||||
|
||||
if (complexJson.contains("real")) {
|
||||
swgComplex->setReal(complexJson["real"].toDouble());
|
||||
}
|
||||
if (complexJson.contains("imag")) {
|
||||
swgComplex->setImag(complexJson["imag"].toDouble());
|
||||
}
|
||||
}
|
||||
if (deviceSettingsJson.contains("useReverseAPI")) {
|
||||
swgSoapySDRInputSettings->setUseReverseApi(deviceSettingsJson["useReverseAPI"].toInt());
|
||||
}
|
||||
if (deviceSettingsJson.contains("reverseAPIAddress")) {
|
||||
swgSoapySDRInputSettings->setReverseApiAddress(new QString(deviceSettingsJson["reverseAPIAddress"].toString()));
|
||||
}
|
||||
if (deviceSettingsJson.contains("reverseAPIPort")) {
|
||||
swgSoapySDRInputSettings->setReverseApiPort(deviceSettingsJson["reverseAPIPort"].toInt());
|
||||
}
|
||||
if (deviceSettingsJson.contains("reverseAPIDeviceIndex")) {
|
||||
swgSoapySDRInputSettings->setReverseApiDeviceIndex(deviceSettingsJson["reverseAPIDeviceIndex"].toInt());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SWGSDRangel::SWGSoapySDROutputSettings *swgSoapySDROutputSettings = new SWGSDRangel::SWGSoapySDROutputSettings();
|
||||
deviceSettings->setSoapySdrOutputSettings(swgSoapySDROutputSettings);
|
||||
swgSoapySDROutputSettings->init();
|
||||
|
||||
if (deviceSettingsJson.contains("centerFrequency")) {
|
||||
swgSoapySDROutputSettings->setCenterFrequency(deviceSettingsJson["centerFrequency"].toInt());
|
||||
}
|
||||
if (deviceSettingsJson.contains("LOppmTenths")) {
|
||||
swgSoapySDROutputSettings->setLOppmTenths(deviceSettingsJson["LOppmTenths"].toInt());
|
||||
}
|
||||
if (deviceSettingsJson.contains("devSampleRate")) {
|
||||
swgSoapySDROutputSettings->setDevSampleRate(deviceSettingsJson["devSampleRate"].toInt());
|
||||
}
|
||||
if (deviceSettingsJson.contains("log2Interp")) {
|
||||
swgSoapySDROutputSettings->setLog2Interp(deviceSettingsJson["log2Interp"].toInt());
|
||||
}
|
||||
if (deviceSettingsJson.contains("transverterMode")) {
|
||||
swgSoapySDROutputSettings->setTransverterMode(deviceSettingsJson["transverterMode"].toInt());
|
||||
}
|
||||
if (deviceSettingsJson.contains("transverterDeltaFrequency")) {
|
||||
swgSoapySDROutputSettings->setTransverterDeltaFrequency(deviceSettingsJson["transverterDeltaFrequency"].toInt());
|
||||
}
|
||||
if (deviceSettingsJson.contains("antenna")) {
|
||||
swgSoapySDROutputSettings->setAntenna(new QString(deviceSettingsJson["antenna"].toString()));
|
||||
}
|
||||
if (deviceSettingsJson.contains("bandwidth")) {
|
||||
swgSoapySDROutputSettings->setBandwidth(deviceSettingsJson["bandwidth"].toInt());
|
||||
}
|
||||
if (deviceSettingsJson.contains("globalGain")) {
|
||||
swgSoapySDROutputSettings->setGlobalGain(deviceSettingsJson["globalGain"].toInt());
|
||||
}
|
||||
if (deviceSettingsJson.contains("autoGain")) {
|
||||
swgSoapySDROutputSettings->setAutoGain(deviceSettingsJson["autoGain"].toInt());
|
||||
}
|
||||
if (deviceSettingsJson.contains("autoDCCorrection")) {
|
||||
swgSoapySDROutputSettings->setAutoDcCorrection(deviceSettingsJson["autoDCCorrection"].toInt());
|
||||
}
|
||||
if (deviceSettingsJson.contains("autoIQCorrection")) {
|
||||
swgSoapySDROutputSettings->setAutoIqCorrection(deviceSettingsJson["autoIQCorrection"].toInt());
|
||||
}
|
||||
if (deviceSettingsJson.contains("dcCorrection"))
|
||||
{
|
||||
SWGSDRangel::SWGComplex *swgComplex = new SWGSDRangel::SWGComplex;
|
||||
swgSoapySDROutputSettings->setDcCorrection(swgComplex);
|
||||
QJsonObject complexJson = deviceSettingsJson["dcCorrection"].toObject();
|
||||
|
||||
if (complexJson.contains("real")) {
|
||||
swgComplex->setReal(complexJson["real"].toDouble());
|
||||
}
|
||||
if (complexJson.contains("imag")) {
|
||||
swgComplex->setImag(complexJson["imag"].toDouble());
|
||||
}
|
||||
}
|
||||
if (deviceSettingsJson.contains("iqCorrection"))
|
||||
{
|
||||
SWGSDRangel::SWGComplex *swgComplex = new SWGSDRangel::SWGComplex;
|
||||
swgSoapySDROutputSettings->setIqCorrection(swgComplex);
|
||||
QJsonObject complexJson = deviceSettingsJson["iqCorrection"].toObject();
|
||||
|
||||
if (complexJson.contains("real")) {
|
||||
swgComplex->setReal(complexJson["real"].toDouble());
|
||||
}
|
||||
if (complexJson.contains("imag")) {
|
||||
swgComplex->setImag(complexJson["imag"].toDouble());
|
||||
}
|
||||
}
|
||||
if (deviceSettingsJson.contains("useReverseAPI")) {
|
||||
swgSoapySDROutputSettings->setUseReverseApi(deviceSettingsJson["useReverseAPI"].toInt());
|
||||
}
|
||||
if (deviceSettingsJson.contains("reverseAPIAddress")) {
|
||||
swgSoapySDROutputSettings->setReverseApiAddress(new QString(deviceSettingsJson["reverseAPIAddress"].toString()));
|
||||
}
|
||||
if (deviceSettingsJson.contains("reverseAPIPort")) {
|
||||
swgSoapySDROutputSettings->setReverseApiPort(deviceSettingsJson["reverseAPIPort"].toInt());
|
||||
}
|
||||
if (deviceSettingsJson.contains("reverseAPIDeviceIndex")) {
|
||||
swgSoapySDROutputSettings->setReverseApiDeviceIndex(deviceSettingsJson["reverseAPIDeviceIndex"].toInt());
|
||||
}
|
||||
}
|
||||
|
||||
if (deviceSettingsKeys.contains("deviceArgSettings"))
|
||||
{
|
||||
QList<SWGSDRangel::SWGArgValue *> *swgArgSettings = new QList<SWGSDRangel::SWGArgValue *>;
|
||||
QJsonArray argsJson = deviceSettingsJson["deviceArgSettings"].toArray();
|
||||
|
||||
if (inputElseOutput) {
|
||||
deviceSettings->getSoapySdrInputSettings()->setDeviceArgSettings(swgArgSettings);
|
||||
} else {
|
||||
deviceSettings->getSoapySdrOutputSettings()->setDeviceArgSettings(swgArgSettings);
|
||||
}
|
||||
|
||||
for (int i = 0; i < argsJson.count(); i++)
|
||||
{
|
||||
SWGSDRangel::SWGArgValue *argValue = new SWGSDRangel::SWGArgValue();
|
||||
swgArgSettings->append(argValue);
|
||||
QJsonObject argValueJson = argsJson.at(i).toObject();
|
||||
argValue->fromJsonObject(argValueJson);
|
||||
}
|
||||
}
|
||||
|
||||
if (deviceSettingsKeys.contains("individualGains"))
|
||||
{
|
||||
QList<SWGSDRangel::SWGArgValue *> *swgIndividualGains = new QList<SWGSDRangel::SWGArgValue *>;
|
||||
QJsonArray argsJson = deviceSettingsJson["individualGains"].toArray();
|
||||
|
||||
if (inputElseOutput) {
|
||||
deviceSettings->getSoapySdrInputSettings()->setIndividualGains(swgIndividualGains);
|
||||
} else {
|
||||
deviceSettings->getSoapySdrOutputSettings()->setIndividualGains(swgIndividualGains);
|
||||
}
|
||||
|
||||
for (int i = 0; i < argsJson.count(); i++)
|
||||
{
|
||||
SWGSDRangel::SWGArgValue *argValue = new SWGSDRangel::SWGArgValue();
|
||||
swgIndividualGains->append(argValue);
|
||||
QJsonObject argValueJson = argsJson.at(i).toObject();
|
||||
argValue->fromJsonObject(argValueJson);
|
||||
}
|
||||
}
|
||||
|
||||
if (deviceSettingsKeys.contains("streamArgSettings"))
|
||||
{
|
||||
QList<SWGSDRangel::SWGArgValue *> *swgStreamArgSettings = new QList<SWGSDRangel::SWGArgValue *>;
|
||||
QJsonArray argsJson = deviceSettingsJson["streamArgSettings"].toArray();
|
||||
|
||||
if (inputElseOutput) {
|
||||
deviceSettings->getSoapySdrInputSettings()->setStreamArgSettings(swgStreamArgSettings);
|
||||
} else {
|
||||
deviceSettings->getSoapySdrOutputSettings()->setStreamArgSettings(swgStreamArgSettings);
|
||||
}
|
||||
|
||||
for (int i = 0; i < argsJson.count(); i++)
|
||||
{
|
||||
SWGSDRangel::SWGArgValue *argValue = new SWGSDRangel::SWGArgValue();
|
||||
swgStreamArgSettings->append(argValue);
|
||||
QJsonObject argValueJson = argsJson.at(i).toObject();
|
||||
argValue->fromJsonObject(argValueJson);
|
||||
}
|
||||
}
|
||||
|
||||
if (deviceSettingsKeys.contains("tunableElements"))
|
||||
{
|
||||
QList<SWGSDRangel::SWGArgValue *> *swgTunableElements = new QList<SWGSDRangel::SWGArgValue *>;
|
||||
QJsonArray argsJson = deviceSettingsJson["tunableElements"].toArray();
|
||||
|
||||
if (inputElseOutput) {
|
||||
deviceSettings->getSoapySdrInputSettings()->setTunableElements(swgTunableElements);
|
||||
} else {
|
||||
deviceSettings->getSoapySdrOutputSettings()->setTunableElements(swgTunableElements);
|
||||
}
|
||||
|
||||
for (int i = 0; i < argsJson.count(); i++)
|
||||
{
|
||||
SWGSDRangel::SWGArgValue *argValue = new SWGSDRangel::SWGArgValue();
|
||||
swgTunableElements->append(argValue);
|
||||
QJsonObject argValueJson = argsJson.at(i).toObject();
|
||||
argValue->fromJsonObject(argValueJson);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user