1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-22 16:08:39 -05:00

Multi device support: add channels from device control working concept

This commit is contained in:
f4exb 2016-05-14 18:12:39 +02:00
parent 117f636f1f
commit 58709e0bae
7 changed files with 50 additions and 11 deletions

View File

@ -30,25 +30,23 @@ void AMPlugin::initPlugin(PluginAPI* pluginAPI)
// register AM demodulator
QAction* action = new QAction(tr("&AM Demodulator"), this);
connect(action, SIGNAL(triggered()), this, SLOT(createInstanceAM()));
// connect(action, SIGNAL(triggered()), this, SLOT(createInstanceAM()));
m_pluginAPI->registerChannel("de.maintech.sdrangelove.channel.am", this, action);
}
PluginGUI* AMPlugin::createChannel(const QString& channelName)
{
if(channelName == "de.maintech.sdrangelove.channel.am") {
AMDemodGUI* gui = AMDemodGUI::create(m_pluginAPI);
m_pluginAPI->registerChannelInstance("de.maintech.sdrangelove.channel.am", gui);
m_pluginAPI->addChannelRollup(gui);
return gui;
return createInstanceAM();
} else {
return NULL;
}
}
void AMPlugin::createInstanceAM()
PluginGUI* AMPlugin::createInstanceAM()
{
AMDemodGUI* gui = AMDemodGUI::create(m_pluginAPI);
m_pluginAPI->registerChannelInstance("de.maintech.sdrangelove.channel.am", gui);
m_pluginAPI->addChannelRollup(gui);
return gui;
}

View File

@ -21,9 +21,7 @@ private:
static const PluginDescriptor m_pluginDescriptor;
PluginAPI* m_pluginAPI;
private slots:
void createInstanceAM();
PluginGUI* createInstanceAM();
};
#endif // INCLUDE_AMPLUGIN_H

View File

@ -38,6 +38,14 @@ QComboBox *SamplingDeviceControl::getDeviceSelector()
return ui->deviceSelect;
}
void SamplingDeviceControl::populateChannelSelector()
{
if (m_pluginManager)
{
m_pluginManager->populateChannelComboBox(ui->channelSelect);
}
}
void SamplingDeviceControl::on_showLoadedPlugins_clicked(bool checked)
{
if (m_pluginManager)
@ -46,3 +54,12 @@ void SamplingDeviceControl::on_showLoadedPlugins_clicked(bool checked)
pluginsDialog.exec();
}
}
void SamplingDeviceControl::on_addChannel_clicked(bool checked)
{
if (m_pluginManager)
{
m_pluginManager->createChannelInstance(ui->channelSelect->currentIndex());
}
}

View File

@ -39,6 +39,7 @@ public:
void setPluginManager(PluginManager *pluginManager) { m_pluginManager = pluginManager; }
QComboBox *getDeviceSelector();
void populateChannelSelector();
private:
Ui::SamplingDeviceControl* ui;
@ -46,6 +47,7 @@ private:
private slots:
void on_showLoadedPlugins_clicked(bool checked);
void on_addChannel_clicked(bool checked);
};

View File

@ -191,9 +191,11 @@ void MainWindow::addDevice()
PluginManager *pluginManager = new PluginManager(this, m_deviceUIs.size()-1, dspDeviceEngine, m_deviceUIs.back()->m_spectrum);
m_deviceUIs.back()->m_pluginManager = pluginManager;
m_deviceUIs.back()->m_samplingDeviceControl->setPluginManager(pluginManager);
pluginManager->loadPlugins();
m_deviceUIs.back()->m_samplingDeviceControl->setPluginManager(pluginManager);
m_deviceUIs.back()->m_samplingDeviceControl->populateChannelSelector();
dspDeviceEngine->addSink(m_deviceUIs.back()->m_spectrumVis);
ui->tabSpectra->addTab(m_deviceUIs.back()->m_spectrum, tabNameCStr);
ui->tabSpectraGUI->addTab(m_deviceUIs.back()->m_spectrumGUI, tabNameCStr);

View File

@ -519,3 +519,21 @@ void PluginManager::renameChannelInstances()
m_channelInstanceRegistrations[i].m_gui->setName(QString("%1:%2").arg(m_channelInstanceRegistrations[i].m_channelName).arg(i));
}
}
void PluginManager::populateChannelComboBox(QComboBox *channels)
{
for(ChannelRegistrations::iterator it = m_channelRegistrations.begin(); it != m_channelRegistrations.end(); ++it)
{
const PluginDescriptor& pluginDescipror = it->m_plugin->getPluginDescriptor();
channels->addItem(pluginDescipror.displayedName);
}
}
void PluginManager::createChannelInstance(int channelPluginIndex)
{
if (channelPluginIndex < m_channelRegistrations.size())
{
PluginInterface *pluginInterface = m_channelRegistrations[channelPluginIndex].m_plugin;
pluginInterface->createChannel(m_channelRegistrations[channelPluginIndex].m_channelName);
}
}

View File

@ -45,12 +45,13 @@ public:
void loadPlugins();
const Plugins& getPlugins() const { return m_plugins; }
// Callbacks from the plugins
void registerChannel(const QString& channelName, PluginInterface* plugin, QAction* action);
void registerChannelInstance(const QString& channelName, PluginGUI* pluginGUI);
void addChannelRollup(QWidget* pluginGUI);
void removeChannelInstance(PluginGUI* pluginGUI);
void registerSampleSource(const QString& sourceName, PluginInterface* plugin);
void setInputGUI(QWidget* gui);
void addSink(SampleSink* sink);
@ -89,6 +90,9 @@ public:
int selectFirstSampleSource(const QString& sourceId);
int selectSampleSourceBySerialOrSequence(const QString& sourceId, const QString& sourceSerial, int sourceSequence);
void populateChannelComboBox(QComboBox *channels);
void createChannelInstance(int channelPluginIndex);
private:
struct ChannelRegistration {
QString m_channelName;