1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-29 19:28:47 -05:00

Register channels with their URI

This commit is contained in:
f4exb 2020-10-03 05:16:19 +02:00
parent 8bf2d4469b
commit 93de98c53c
2 changed files with 24 additions and 25 deletions

View File

@ -19,16 +19,17 @@
#include <algorithm> #include <algorithm>
#include "gui/glspectrum.h"
#include "dsp/spectrumvis.h" #include "dsp/spectrumvis.h"
#include "gui/glspectrumgui.h"
#include "gui/channelwindow.h"
#include "dsp/dspdevicesourceengine.h" #include "dsp/dspdevicesourceengine.h"
#include "dsp/dspdevicesinkengine.h" #include "dsp/dspdevicesinkengine.h"
#include "gui/glspectrum.h"
#include "gui/glspectrumgui.h"
#include "gui/channelwindow.h"
#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 "channel/channelutils.h"
#include "channel/channelapi.h"
#include "settings/preset.h" #include "settings/preset.h"
#include "deviceuiset.h" #include "deviceuiset.h"
@ -196,7 +197,7 @@ void DeviceUISet::loadRxChannelSettings(const Preset *preset, PluginAPI *pluginA
for (int i = 0; i < preset->getChannelCount(); i++) for (int i = 0; i < preset->getChannelCount(); i++)
{ {
const Preset::ChannelConfig& channelConfig = preset->getChannelConfig(i); const Preset::ChannelConfig& channelConfig = preset->getChannelConfig(i);
ChannelInstanceRegistration reg; PluginInstanceGUI *rxChannelGUI = nullptr;
// create channel instance // create channel instance
@ -211,17 +212,16 @@ void DeviceUISet::loadRxChannelSettings(const Preset *preset, PluginAPI *pluginA
ChannelAPI *channelAPI; ChannelAPI *channelAPI;
BasebandSampleSink *rxChannel; BasebandSampleSink *rxChannel;
(*channelRegistrations)[i].m_plugin->createRxChannel(m_deviceAPI, &rxChannel, &channelAPI); (*channelRegistrations)[i].m_plugin->createRxChannel(m_deviceAPI, &rxChannel, &channelAPI);
PluginInstanceGUI *rxChannelGUI = rxChannelGUI = (*channelRegistrations)[i].m_plugin->createRxChannelGUI(this, rxChannel);
(*channelRegistrations)[i].m_plugin->createRxChannelGUI(this, rxChannel); registerRxChannelInstance(channelAPI->getURI(), channelAPI, rxChannelGUI);
reg = ChannelInstanceRegistration(channelConfig.m_channelIdURI, channelAPI, rxChannelGUI, 0);
break; break;
} }
} }
if (reg.m_gui != 0) if (rxChannelGUI)
{ {
qDebug("DeviceUISet::loadRxChannelSettings: deserializing channel [%s]", qPrintable(channelConfig.m_channelIdURI)); qDebug("DeviceUISet::loadRxChannelSettings: deserializing channel [%s]", qPrintable(channelConfig.m_channelIdURI));
reg.m_gui->deserialize(channelConfig.m_config); rxChannelGUI->deserialize(channelConfig.m_config);
} }
} }
@ -275,7 +275,7 @@ void DeviceUISet::loadTxChannelSettings(const Preset *preset, PluginAPI *pluginA
for(int i = 0; i < preset->getChannelCount(); i++) for(int i = 0; i < preset->getChannelCount(); i++)
{ {
const Preset::ChannelConfig& channelConfig = preset->getChannelConfig(i); const Preset::ChannelConfig& channelConfig = preset->getChannelConfig(i);
ChannelInstanceRegistration reg; PluginInstanceGUI *txChannelGUI = nullptr;
// create channel instance // create channel instance
@ -289,17 +289,16 @@ void DeviceUISet::loadTxChannelSettings(const Preset *preset, PluginAPI *pluginA
ChannelAPI *channelAPI; ChannelAPI *channelAPI;
BasebandSampleSource *txChannel; BasebandSampleSource *txChannel;
(*channelRegistrations)[i].m_plugin->createTxChannel(m_deviceAPI, &txChannel, &channelAPI); (*channelRegistrations)[i].m_plugin->createTxChannel(m_deviceAPI, &txChannel, &channelAPI);
PluginInstanceGUI *txChannelGUI = txChannelGUI = (*channelRegistrations)[i].m_plugin->createTxChannelGUI(this, txChannel);
(*channelRegistrations)[i].m_plugin->createTxChannelGUI(this, txChannel); registerTxChannelInstance(channelAPI->getURI(), channelAPI, txChannelGUI);
reg = ChannelInstanceRegistration(channelConfig.m_channelIdURI, channelAPI, txChannelGUI, 1);
break; break;
} }
} }
if(reg.m_gui != 0) if(txChannelGUI)
{ {
qDebug("DeviceUISet::loadTxChannelSettings: deserializing channel [%s]", qPrintable(channelConfig.m_channelIdURI)); qDebug("DeviceUISet::loadTxChannelSettings: deserializing channel [%s]", qPrintable(channelConfig.m_channelIdURI));
reg.m_gui->deserialize(channelConfig.m_config); txChannelGUI->deserialize(channelConfig.m_config);
} }
} }
@ -354,7 +353,7 @@ void DeviceUISet::loadMIMOChannelSettings(const Preset *preset, PluginAPI *plugi
for (int i = 0; i < preset->getChannelCount(); i++) for (int i = 0; i < preset->getChannelCount(); i++)
{ {
const Preset::ChannelConfig& channelConfig = preset->getChannelConfig(i); const Preset::ChannelConfig& channelConfig = preset->getChannelConfig(i);
ChannelInstanceRegistration reg; PluginInstanceGUI *mimoChannelGUI = nullptr;
// create channel instance // create channel instance
@ -369,18 +368,17 @@ void DeviceUISet::loadMIMOChannelSettings(const Preset *preset, PluginAPI *plugi
ChannelAPI *channelAPI; ChannelAPI *channelAPI;
MIMOChannel *mimoChannel; MIMOChannel *mimoChannel;
(*channelRegistrations)[i].m_plugin->createMIMOChannel(m_deviceAPI, &mimoChannel, &channelAPI); (*channelRegistrations)[i].m_plugin->createMIMOChannel(m_deviceAPI, &mimoChannel, &channelAPI);
PluginInstanceGUI *mimoChannelGUI = mimoChannelGUI = (*channelRegistrations)[i].m_plugin->createMIMOChannelGUI(this, mimoChannel);
(*channelRegistrations)[i].m_plugin->createMIMOChannelGUI(this, mimoChannel);
(*channelRegistrations)[i].m_plugin->createMIMOChannel(m_deviceAPI, &mimoChannel, &channelAPI); (*channelRegistrations)[i].m_plugin->createMIMOChannel(m_deviceAPI, &mimoChannel, &channelAPI);
reg = ChannelInstanceRegistration(channelConfig.m_channelIdURI, channelAPI, mimoChannelGUI, 2); registerChannelInstance(channelAPI->getURI(), channelAPI, mimoChannelGUI);
break; break;
} }
} }
if (reg.m_gui != 0) if (mimoChannelGUI)
{ {
qDebug("DeviceUISet::loadMIMOChannelSettings: deserializing channel [%s]", qPrintable(channelConfig.m_channelIdURI)); qDebug("DeviceUISet::loadMIMOChannelSettings: deserializing channel [%s]", qPrintable(channelConfig.m_channelIdURI));
reg.m_gui->deserialize(channelConfig.m_config); mimoChannelGUI->deserialize(channelConfig.m_config);
} }
} }

View File

@ -35,6 +35,7 @@
#include "device/deviceapi.h" #include "device/deviceapi.h"
#include "device/deviceuiset.h" #include "device/deviceuiset.h"
#include "device/deviceenumerator.h" #include "device/deviceenumerator.h"
#include "channel/channelapi.h"
#include "feature/featureuiset.h" #include "feature/featureuiset.h"
#include "gui/indicator.h" #include "gui/indicator.h"
#include "gui/presetitem.h" #include "gui/presetitem.h"
@ -1926,7 +1927,7 @@ void MainWindow::channelAddClicked(int channelIndex)
BasebandSampleSink *rxChannel; BasebandSampleSink *rxChannel;
pluginInterface->createRxChannel(deviceUI->m_deviceAPI, &rxChannel, &channelAPI); pluginInterface->createRxChannel(deviceUI->m_deviceAPI, &rxChannel, &channelAPI);
PluginInstanceGUI *gui = pluginInterface->createRxChannelGUI(deviceUI, rxChannel); PluginInstanceGUI *gui = pluginInterface->createRxChannelGUI(deviceUI, rxChannel);
deviceUI->registerRxChannelInstance(gui->getName(), channelAPI, gui); deviceUI->registerRxChannelInstance(channelAPI->getURI(), channelAPI, gui);
} }
else if (deviceUI->m_deviceSinkEngine) // sink device => Tx channels else if (deviceUI->m_deviceSinkEngine) // sink device => Tx channels
{ {
@ -1936,7 +1937,7 @@ void MainWindow::channelAddClicked(int channelIndex)
BasebandSampleSource *txChannel; BasebandSampleSource *txChannel;
pluginInterface->createTxChannel(deviceUI->m_deviceAPI, &txChannel, &channelAPI); pluginInterface->createTxChannel(deviceUI->m_deviceAPI, &txChannel, &channelAPI);
PluginInstanceGUI *gui = pluginInterface->createTxChannelGUI(deviceUI, txChannel); PluginInstanceGUI *gui = pluginInterface->createTxChannelGUI(deviceUI, txChannel);
deviceUI->registerTxChannelInstance(gui->getName(), channelAPI, gui); deviceUI->registerTxChannelInstance(channelAPI->getURI(), channelAPI, gui);
} }
else if (deviceUI->m_deviceMIMOEngine) // MIMO device => all possible channels. Depends on index range else if (deviceUI->m_deviceMIMOEngine) // MIMO device => all possible channels. Depends on index range
{ {
@ -1953,7 +1954,7 @@ void MainWindow::channelAddClicked(int channelIndex)
BasebandSampleSink *rxChannel; BasebandSampleSink *rxChannel;
pluginInterface->createRxChannel(deviceUI->m_deviceAPI, &rxChannel, &channelAPI); pluginInterface->createRxChannel(deviceUI->m_deviceAPI, &rxChannel, &channelAPI);
PluginInstanceGUI *gui = pluginInterface->createRxChannelGUI(deviceUI, rxChannel); PluginInstanceGUI *gui = pluginInterface->createRxChannelGUI(deviceUI, rxChannel);
deviceUI->registerRxChannelInstance(gui->getName(), channelAPI, gui); deviceUI->registerRxChannelInstance(channelAPI->getURI(), channelAPI, gui);
} }
else if (channelIndex < nbRxChannels + nbTxChannels) else if (channelIndex < nbRxChannels + nbTxChannels)
{ {
@ -1963,7 +1964,7 @@ void MainWindow::channelAddClicked(int channelIndex)
BasebandSampleSource *txChannel; BasebandSampleSource *txChannel;
pluginInterface->createTxChannel(deviceUI->m_deviceAPI, &txChannel, &channelAPI); pluginInterface->createTxChannel(deviceUI->m_deviceAPI, &txChannel, &channelAPI);
PluginInstanceGUI *gui = pluginInterface->createTxChannelGUI(deviceUI, txChannel); PluginInstanceGUI *gui = pluginInterface->createTxChannelGUI(deviceUI, txChannel);
deviceUI->registerTxChannelInstance(gui->getName(), channelAPI, gui); deviceUI->registerTxChannelInstance(channelAPI->getURI(), channelAPI, gui);
} }
} }
} }