1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-14 20:31:53 -05:00

REST API: config: GET (7): debug phase 1

This commit is contained in:
f4exb 2019-08-02 01:58:59 +02:00
parent a4007b762e
commit c7d05aeaff
8 changed files with 98 additions and 46 deletions

View File

@ -54,6 +54,7 @@ set(sdrbase_SOURCES
audio/audioresampler.cpp audio/audioresampler.cpp
channel/channelapi.cpp channel/channelapi.cpp
channel/channelutils.cpp
channel/remotedataqueue.cpp channel/remotedataqueue.cpp
channel/remotedatareadqueue.cpp channel/remotedatareadqueue.cpp
@ -160,6 +161,7 @@ set(sdrbase_HEADERS
audio/audioresampler.h audio/audioresampler.h
channel/channelapi.h channel/channelapi.h
channel/channelutils.h
channel/remotedataqueue.h channel/remotedataqueue.h
channel/remotedatareadqueue.h channel/remotedatareadqueue.h
channel/remotedatablock.h channel/remotedatablock.h

View File

@ -0,0 +1,40 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2017 Edouard Griffiths, F4EXB //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#include "channelutils.h"
bool ChannelUtils::compareRxChannelURIs(const QString& registerdChannelURI, const QString& xChannelURI)
{
return registerdChannelURI == getRegisteredChannelURI(xChannelURI);
}
QString ChannelUtils::getRegisteredChannelURI(const QString& xChannelURI)
{
if (xChannelURI == "sdrangel.channel.chanalyzerng") {
return "sdrangel.channel.chanalyzer";
} else if (xChannelURI == "de.maintech.sdrangelove.channel.am") {
return "sdrangel.channel.amdemod";
} else if (xChannelURI == "de.maintech.sdrangelove.channel.nfm") {
return "sdrangel.channel.nfmdemod";
} else if (xChannelURI == "de.maintech.sdrangelove.channel.ssb") {
return "sdrangel.channel.ssbdemod";
} else if (xChannelURI == "de.maintech.sdrangelove.channel.wfm") {
return "sdrangel.channel.wfmdemod";
} else {
return xChannelURI;
}
}

View File

@ -0,0 +1,30 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2017 Edouard Griffiths, F4EXB //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#ifndef SDRBASE_CHANNEL_CHANNELUTILS_H_
#define SDRBASE_CHANNEL_CHANNELUTILS_H_
#include <QString>
class ChannelUtils
{
public:
static bool compareRxChannelURIs(const QString& registerdChannelURI, const QString& xChannelURI);
static QString getRegisteredChannelURI(const QString& xChannelURI);
};
#endif // SDRBASE_CHANNEL_CHANNELUTILS_H_

View File

@ -19,6 +19,7 @@
#include "plugin/pluginmanager.h" #include "plugin/pluginmanager.h"
#include "channel/channelapi.h" #include "channel/channelapi.h"
#include "channel/channelutils.h"
#include "webapiadapterbase.h" #include "webapiadapterbase.h"
WebAPIAdapterBase::WebAPIAdapterBase() WebAPIAdapterBase::WebAPIAdapterBase()
@ -67,6 +68,7 @@ void WebAPIAdapterBase::webapiFormatPreset(
const Preset::ChannelConfig& channelConfig = preset.getChannelConfig(i); const Preset::ChannelConfig& channelConfig = preset.getChannelConfig(i);
QList<SWGSDRangel::SWGChannelConfig *> *swgChannelConfigs = apiPreset->getChannelConfigs(); QList<SWGSDRangel::SWGChannelConfig *> *swgChannelConfigs = apiPreset->getChannelConfigs();
swgChannelConfigs->append(new SWGSDRangel::SWGChannelConfig); swgChannelConfigs->append(new SWGSDRangel::SWGChannelConfig);
swgChannelConfigs->back()->init();
swgChannelConfigs->back()->setChannelIdUri(new QString(channelConfig.m_channelIdURI)); swgChannelConfigs->back()->setChannelIdUri(new QString(channelConfig.m_channelIdURI));
const QByteArray& channelSettings = channelConfig.m_config; const QByteArray& channelSettings = channelConfig.m_config;
SWGSDRangel::SWGChannelSettings *swgChannelSettings = swgChannelConfigs->back()->getConfig(); SWGSDRangel::SWGChannelSettings *swgChannelSettings = swgChannelConfigs->back()->getConfig();
@ -87,12 +89,13 @@ void WebAPIAdapterBase::webapiFormatPreset(
const Preset::DeviceConfig& deviceConfig = preset.getDeviceConfig(i); const Preset::DeviceConfig& deviceConfig = preset.getDeviceConfig(i);
QList<SWGSDRangel::SWGDeviceConfig *> *swgdeviceConfigs = apiPreset->getDeviceConfigs(); QList<SWGSDRangel::SWGDeviceConfig *> *swgdeviceConfigs = apiPreset->getDeviceConfigs();
swgdeviceConfigs->append(new SWGSDRangel::SWGDeviceConfig); swgdeviceConfigs->append(new SWGSDRangel::SWGDeviceConfig);
swgdeviceConfigs->back()->init();
swgdeviceConfigs->back()->setDeviceId(new QString(deviceConfig.m_deviceId)); swgdeviceConfigs->back()->setDeviceId(new QString(deviceConfig.m_deviceId));
swgdeviceConfigs->back()->setDeviceSerial(new QString(deviceConfig.m_deviceSerial)); swgdeviceConfigs->back()->setDeviceSerial(new QString(deviceConfig.m_deviceSerial));
swgdeviceConfigs->back()->setDeviceSequence(deviceConfig.m_deviceSequence); swgdeviceConfigs->back()->setDeviceSequence(deviceConfig.m_deviceSequence);
const QByteArray& deviceSettings = deviceConfig.m_config; // const QByteArray& deviceSettings = deviceConfig.m_config;
SWGSDRangel::SWGDeviceSettings *swgDeviceSettings = swgdeviceConfigs->back()->getConfig(); // SWGSDRangel::SWGDeviceSettings *swgDeviceSettings = swgdeviceConfigs->back()->getConfig();
swgDeviceSettings->init(); // swgDeviceSettings->init();
} }
} }
@ -114,15 +117,26 @@ void WebAPIAdapterBase::webapiFormatCommand(
ChannelAPI *WebAPIAdapterBase::WebAPIChannelAdapters::getChannelAPI(const QString& channelURI, const PluginManager *pluginManager) ChannelAPI *WebAPIAdapterBase::WebAPIChannelAdapters::getChannelAPI(const QString& channelURI, const PluginManager *pluginManager)
{ {
QMap<QString, ChannelAPI*>::iterator it = m_webAPIChannelAdapters.find(channelURI); QString registeredChannelURI = ChannelUtils::getRegisteredChannelURI(channelURI);
QMap<QString, ChannelAPI*>::iterator it = m_webAPIChannelAdapters.find(registeredChannelURI);
if (it == m_webAPIChannelAdapters.end()) if (it == m_webAPIChannelAdapters.end())
{ {
ChannelAPI *channelAPI = pluginManager->getChannelPluginInterface(channelURI)->createChannelWebAPIAdapter(); const PluginInterface *pluginInterface = pluginManager->getChannelPluginInterface(registeredChannelURI);
m_webAPIChannelAdapters.insert(channelURI, channelAPI);
if (pluginInterface)
{
ChannelAPI *channelAPI = pluginInterface->createChannelWebAPIAdapter();
m_webAPIChannelAdapters.insert(registeredChannelURI, channelAPI);
return channelAPI; return channelAPI;
} }
else else
{
m_webAPIChannelAdapters.insert(registeredChannelURI, nullptr);
return nullptr;
}
}
else
{ {
return *it; return *it;
} }

View File

@ -27,6 +27,7 @@
#include "plugin/plugininstancegui.h" #include "plugin/plugininstancegui.h"
#include "plugin/pluginapi.h" #include "plugin/pluginapi.h"
#include "plugin/plugininterface.h" #include "plugin/plugininterface.h"
#include "channel/channelutils.h"
#include "settings/preset.h" #include "settings/preset.h"
#include "deviceuiset.h" #include "deviceuiset.h"
@ -194,7 +195,7 @@ void DeviceUISet::loadRxChannelSettings(const Preset *preset, PluginAPI *pluginA
for(int i = 0; i < channelRegistrations->count(); i++) for(int i = 0; i < channelRegistrations->count(); i++)
{ {
//if((*channelRegistrations)[i].m_channelIdURI == channelConfig.m_channelIdURI) //if((*channelRegistrations)[i].m_channelIdURI == channelConfig.m_channelIdURI)
if (compareRxChannelURIs((*channelRegistrations)[i].m_channelIdURI, channelConfig.m_channelIdURI)) if (ChannelUtils::compareRxChannelURIs((*channelRegistrations)[i].m_channelIdURI, channelConfig.m_channelIdURI))
{ {
qDebug("DeviceUISet::loadRxChannelSettings: creating new channel [%s] from config [%s]", qDebug("DeviceUISet::loadRxChannelSettings: creating new channel [%s] from config [%s]",
qPrintable((*channelRegistrations)[i].m_channelIdURI), qPrintable((*channelRegistrations)[i].m_channelIdURI),
@ -354,19 +355,3 @@ bool DeviceUISet::ChannelInstanceRegistration::operator<(const ChannelInstanceRe
} }
} }
bool DeviceUISet::compareRxChannelURIs(const QString& registerdChannelURI, const QString& xChannelURI)
{
if ((xChannelURI == "sdrangel.channel.chanalyzerng") || (xChannelURI == "sdrangel.channel.chanalyzer")) { // renamed ChanalyzerNG to Chanalyzer in 4.0.0
return registerdChannelURI == "sdrangel.channel.chanalyzer";
} else if ((xChannelURI == "de.maintech.sdrangelove.channel.am") || (xChannelURI == "sdrangel.channel.amdemod")) {
return registerdChannelURI == "sdrangel.channel.amdemod";
} else if ((xChannelURI == "de.maintech.sdrangelove.channel.nfm") || (xChannelURI == "sdrangel.channel.nfmdemod")) {
return registerdChannelURI == "sdrangel.channel.nfmdemod";
} else if ((xChannelURI == "de.maintech.sdrangelove.channel.ssb") || (xChannelURI == "sdrangel.channel.ssbdemod")) {
return registerdChannelURI == "sdrangel.channel.ssbdemod";
} else if ((xChannelURI == "de.maintech.sdrangelove.channel.wfm") || (xChannelURI == "sdrangel.channel.wfmdemod")) {
return registerdChannelURI == "sdrangel.channel.wfmdemod";
} else {
return registerdChannelURI == xChannelURI;
}
}

View File

@ -111,8 +111,6 @@ private:
void renameRxChannelInstances(); void renameRxChannelInstances();
void renameTxChannelInstances(); void renameTxChannelInstances();
/** Use this function to support possible older identifiers in presets */
bool compareRxChannelURIs(const QString& registerdChannelURI, const QString& xChannelURI);
}; };

View File

@ -21,6 +21,7 @@
#include "plugin/plugininterface.h" #include "plugin/plugininterface.h"
#include "settings/preset.h" #include "settings/preset.h"
#include "channel/channelapi.h" #include "channel/channelapi.h"
#include "channel/channelutils.h"
#include "settings/preset.h" #include "settings/preset.h"
#include "deviceset.h" #include "deviceset.h"
@ -184,7 +185,7 @@ void DeviceSet::loadRxChannelSettings(const Preset *preset, PluginAPI *pluginAPI
qDebug("DeviceSet::loadChannelSettings: channels compare [%s] vs [%s]", qPrintable(openChannels[i].m_channelName), qPrintable(channelConfig.m_channelIdURI)); qDebug("DeviceSet::loadChannelSettings: channels compare [%s] vs [%s]", qPrintable(openChannels[i].m_channelName), qPrintable(channelConfig.m_channelIdURI));
//if(openChannels[i].m_channelName == channelConfig.m_channelIdURI) //if(openChannels[i].m_channelName == channelConfig.m_channelIdURI)
if (compareRxChannelURIs(openChannels[i].m_channelName, channelConfig.m_channelIdURI)) if (ChannelUtils::compareRxChannelURIs(openChannels[i].m_channelName, channelConfig.m_channelIdURI))
{ {
qDebug("DeviceSet::loadChannelSettings: channel [%s] found", qPrintable(openChannels[i].m_channelName)); qDebug("DeviceSet::loadChannelSettings: channel [%s] found", qPrintable(openChannels[i].m_channelName));
reg = openChannels.takeAt(i); reg = openChannels.takeAt(i);
@ -200,7 +201,7 @@ void DeviceSet::loadRxChannelSettings(const Preset *preset, PluginAPI *pluginAPI
for (int i = 0; i < channelRegistrations->count(); i++) for (int i = 0; i < channelRegistrations->count(); i++)
{ {
//if((*channelRegistrations)[i].m_channelIdURI == channelConfig.m_channelIdURI) //if((*channelRegistrations)[i].m_channelIdURI == channelConfig.m_channelIdURI)
if (compareRxChannelURIs((*channelRegistrations)[i].m_channelIdURI, channelConfig.m_channelIdURI)) if (ChannelUtils::compareRxChannelURIs((*channelRegistrations)[i].m_channelIdURI, channelConfig.m_channelIdURI))
{ {
qDebug("DeviceSet::loadChannelSettings: creating new channel [%s] from config [%s]", qDebug("DeviceSet::loadChannelSettings: creating new channel [%s] from config [%s]",
qPrintable((*channelRegistrations)[i].m_channelIdURI), qPrintable((*channelRegistrations)[i].m_channelIdURI),
@ -392,19 +393,3 @@ bool DeviceSet::ChannelInstanceRegistration::operator<(const ChannelInstanceRegi
} }
} }
bool DeviceSet::compareRxChannelURIs(const QString& registerdChannelURI, const QString& xChannelURI)
{
if ((xChannelURI == "sdrangel.channel.chanalyzerng") || (xChannelURI == "sdrangel.channel.chanalyzer")) { // renamed ChanalyzerNG to Chanalyzer in 4.0.0
return registerdChannelURI == "sdrangel.channel.chanalyzer";
} else if ((xChannelURI == "de.maintech.sdrangelove.channel.am") || (xChannelURI == "sdrangel.channel.amdemod")) {
return registerdChannelURI == "sdrangel.channel.amdemod";
} else if ((xChannelURI == "de.maintech.sdrangelove.channel.nfm") || (xChannelURI == "sdrangel.channel.nfmdemod")) {
return registerdChannelURI == "sdrangel.channel.nfmdemod";
} else if ((xChannelURI == "de.maintech.sdrangelove.channel.ssb") || (xChannelURI == "sdrangel.channel.ssbdemod")) {
return registerdChannelURI == "sdrangel.channel.ssbdemod";
} else if ((xChannelURI == "de.maintech.sdrangelove.channel.wfm") || (xChannelURI == "sdrangel.channel.wfmdemod")) {
return registerdChannelURI == "sdrangel.channel.wfmdemod";
} else {
return registerdChannelURI == xChannelURI;
}
}

View File

@ -82,8 +82,6 @@ private:
void renameRxChannelInstances(); void renameRxChannelInstances();
void renameTxChannelInstances(); void renameTxChannelInstances();
/** Use this function to support possible older identifiers in presets */
bool compareRxChannelURIs(const QString& registerdChannelURI, const QString& xChannelURI);
}; };
#endif /* SDRSRV_DEVICE_DEVICESET_H_ */ #endif /* SDRSRV_DEVICE_DEVICESET_H_ */