mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-12-23 01:55:48 -05:00
REST API: config: GET (7): debug phase 1
This commit is contained in:
parent
a4007b762e
commit
c7d05aeaff
@ -54,6 +54,7 @@ set(sdrbase_SOURCES
|
||||
audio/audioresampler.cpp
|
||||
|
||||
channel/channelapi.cpp
|
||||
channel/channelutils.cpp
|
||||
channel/remotedataqueue.cpp
|
||||
channel/remotedatareadqueue.cpp
|
||||
|
||||
@ -160,6 +161,7 @@ set(sdrbase_HEADERS
|
||||
audio/audioresampler.h
|
||||
|
||||
channel/channelapi.h
|
||||
channel/channelutils.h
|
||||
channel/remotedataqueue.h
|
||||
channel/remotedatareadqueue.h
|
||||
channel/remotedatablock.h
|
||||
|
40
sdrbase/channel/channelutils.cpp
Normal file
40
sdrbase/channel/channelutils.cpp
Normal 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;
|
||||
}
|
||||
}
|
30
sdrbase/channel/channelutils.h
Normal file
30
sdrbase/channel/channelutils.h
Normal 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_
|
@ -19,6 +19,7 @@
|
||||
|
||||
#include "plugin/pluginmanager.h"
|
||||
#include "channel/channelapi.h"
|
||||
#include "channel/channelutils.h"
|
||||
#include "webapiadapterbase.h"
|
||||
|
||||
WebAPIAdapterBase::WebAPIAdapterBase()
|
||||
@ -67,6 +68,7 @@ void WebAPIAdapterBase::webapiFormatPreset(
|
||||
const Preset::ChannelConfig& channelConfig = preset.getChannelConfig(i);
|
||||
QList<SWGSDRangel::SWGChannelConfig *> *swgChannelConfigs = apiPreset->getChannelConfigs();
|
||||
swgChannelConfigs->append(new SWGSDRangel::SWGChannelConfig);
|
||||
swgChannelConfigs->back()->init();
|
||||
swgChannelConfigs->back()->setChannelIdUri(new QString(channelConfig.m_channelIdURI));
|
||||
const QByteArray& channelSettings = channelConfig.m_config;
|
||||
SWGSDRangel::SWGChannelSettings *swgChannelSettings = swgChannelConfigs->back()->getConfig();
|
||||
@ -87,12 +89,13 @@ void WebAPIAdapterBase::webapiFormatPreset(
|
||||
const Preset::DeviceConfig& deviceConfig = preset.getDeviceConfig(i);
|
||||
QList<SWGSDRangel::SWGDeviceConfig *> *swgdeviceConfigs = apiPreset->getDeviceConfigs();
|
||||
swgdeviceConfigs->append(new SWGSDRangel::SWGDeviceConfig);
|
||||
swgdeviceConfigs->back()->init();
|
||||
swgdeviceConfigs->back()->setDeviceId(new QString(deviceConfig.m_deviceId));
|
||||
swgdeviceConfigs->back()->setDeviceSerial(new QString(deviceConfig.m_deviceSerial));
|
||||
swgdeviceConfigs->back()->setDeviceSequence(deviceConfig.m_deviceSequence);
|
||||
const QByteArray& deviceSettings = deviceConfig.m_config;
|
||||
SWGSDRangel::SWGDeviceSettings *swgDeviceSettings = swgdeviceConfigs->back()->getConfig();
|
||||
swgDeviceSettings->init();
|
||||
// const QByteArray& deviceSettings = deviceConfig.m_config;
|
||||
// SWGSDRangel::SWGDeviceSettings *swgDeviceSettings = swgdeviceConfigs->back()->getConfig();
|
||||
// swgDeviceSettings->init();
|
||||
}
|
||||
}
|
||||
|
||||
@ -114,13 +117,24 @@ void WebAPIAdapterBase::webapiFormatCommand(
|
||||
|
||||
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())
|
||||
{
|
||||
ChannelAPI *channelAPI = pluginManager->getChannelPluginInterface(channelURI)->createChannelWebAPIAdapter();
|
||||
m_webAPIChannelAdapters.insert(channelURI, channelAPI);
|
||||
return channelAPI;
|
||||
const PluginInterface *pluginInterface = pluginManager->getChannelPluginInterface(registeredChannelURI);
|
||||
|
||||
if (pluginInterface)
|
||||
{
|
||||
ChannelAPI *channelAPI = pluginInterface->createChannelWebAPIAdapter();
|
||||
m_webAPIChannelAdapters.insert(registeredChannelURI, channelAPI);
|
||||
return channelAPI;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_webAPIChannelAdapters.insert(registeredChannelURI, nullptr);
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "plugin/plugininstancegui.h"
|
||||
#include "plugin/pluginapi.h"
|
||||
#include "plugin/plugininterface.h"
|
||||
#include "channel/channelutils.h"
|
||||
#include "settings/preset.h"
|
||||
|
||||
#include "deviceuiset.h"
|
||||
@ -194,7 +195,7 @@ void DeviceUISet::loadRxChannelSettings(const Preset *preset, PluginAPI *pluginA
|
||||
for(int i = 0; i < channelRegistrations->count(); i++)
|
||||
{
|
||||
//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]",
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -111,8 +111,6 @@ private:
|
||||
|
||||
void renameRxChannelInstances();
|
||||
void renameTxChannelInstances();
|
||||
/** Use this function to support possible older identifiers in presets */
|
||||
bool compareRxChannelURIs(const QString& registerdChannelURI, const QString& xChannelURI);
|
||||
};
|
||||
|
||||
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "plugin/plugininterface.h"
|
||||
#include "settings/preset.h"
|
||||
#include "channel/channelapi.h"
|
||||
#include "channel/channelutils.h"
|
||||
#include "settings/preset.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));
|
||||
|
||||
//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));
|
||||
reg = openChannels.takeAt(i);
|
||||
@ -200,7 +201,7 @@ void DeviceSet::loadRxChannelSettings(const Preset *preset, PluginAPI *pluginAPI
|
||||
for (int i = 0; i < channelRegistrations->count(); i++)
|
||||
{
|
||||
//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]",
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -82,8 +82,6 @@ private:
|
||||
|
||||
void renameRxChannelInstances();
|
||||
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_ */
|
||||
|
Loading…
Reference in New Issue
Block a user