From bbb4bc28b4a421e500b82e548524a7e41b813ded Mon Sep 17 00:00:00 2001 From: f4exb Date: Mon, 16 May 2016 03:21:21 +0200 Subject: [PATCH] Multi device support: channel plugin per device mechanism validation with AM demod --- plugins/channel/chanalyzer/chanalyzergui.cpp | 7 +++--- plugins/channel/chanalyzer/chanalyzergui.h | 6 +++-- .../channel/chanalyzer/chanalyzerplugin.cpp | 8 +++---- plugins/channel/chanalyzer/chanalyzerplugin.h | 6 +++-- plugins/channel/demodam/amdemodgui.cpp | 16 +++++++++---- plugins/channel/demodam/amdemodgui.h | 6 +++-- plugins/channel/demodam/amplugin.cpp | 10 ++++---- plugins/channel/demodam/amplugin.h | 6 +++-- plugins/channel/demodbfm/bfmdemodgui.cpp | 7 +++--- plugins/channel/demodbfm/bfmdemodgui.h | 6 +++-- plugins/channel/demodbfm/bfmplugin.cpp | 8 +++---- plugins/channel/demodbfm/bfmplugin.h | 6 +++-- sdrbase/device/deviceapi.cpp | 23 +++++++++++++++++-- sdrbase/device/deviceapi.h | 11 +++++++-- sdrbase/gui/samplingdevicecontrol.cpp | 2 +- sdrbase/gui/samplingdevicecontrol.h | 3 +++ sdrbase/mainwindow.cpp | 5 ++-- sdrbase/plugin/plugininterface.h | 6 ++--- sdrbase/plugin/pluginmanager.cpp | 8 +++---- sdrbase/plugin/pluginmanager.h | 5 ++-- 20 files changed, 102 insertions(+), 53 deletions(-) diff --git a/plugins/channel/chanalyzer/chanalyzergui.cpp b/plugins/channel/chanalyzer/chanalyzergui.cpp index 8d1620805..9784ba975 100644 --- a/plugins/channel/chanalyzer/chanalyzergui.cpp +++ b/plugins/channel/chanalyzer/chanalyzergui.cpp @@ -34,9 +34,9 @@ #include "chanalyzer.h" #include "chanalyzergui.h" -ChannelAnalyzerGUI* ChannelAnalyzerGUI::create(PluginAPI* pluginAPI) +ChannelAnalyzerGUI* ChannelAnalyzerGUI::create(PluginAPI* pluginAPI, DeviceAPI *deviceAPI) { - ChannelAnalyzerGUI* gui = new ChannelAnalyzerGUI(pluginAPI); + ChannelAnalyzerGUI* gui = new ChannelAnalyzerGUI(pluginAPI, deviceAPI); return gui; } @@ -301,10 +301,11 @@ void ChannelAnalyzerGUI::onMenuDoubleClicked() } } -ChannelAnalyzerGUI::ChannelAnalyzerGUI(PluginAPI* pluginAPI, QWidget* parent) : +ChannelAnalyzerGUI::ChannelAnalyzerGUI(PluginAPI* pluginAPI, DeviceAPI *deviceAPI, QWidget* parent) : RollupWidget(parent), ui(new Ui::ChannelAnalyzerGUI), m_pluginAPI(pluginAPI), + m_deviceAPI(deviceAPI), m_channelMarker(this), m_basicSettingsShown(false), m_doApplySettings(true), diff --git a/plugins/channel/chanalyzer/chanalyzergui.h b/plugins/channel/chanalyzer/chanalyzergui.h index 98f72d924..760951756 100644 --- a/plugins/channel/chanalyzer/chanalyzergui.h +++ b/plugins/channel/chanalyzer/chanalyzergui.h @@ -23,6 +23,7 @@ #include "dsp/movingaverage.h" class PluginAPI; +class DeviceAPI; class ThreadedSampleSink; class Channelizer; @@ -39,7 +40,7 @@ class ChannelAnalyzerGUI : public RollupWidget, public PluginGUI { Q_OBJECT public: - static ChannelAnalyzerGUI* create(PluginAPI* pluginAPI); + static ChannelAnalyzerGUI* create(PluginAPI* pluginAPI, DeviceAPI *deviceAPI); void destroy(); void setName(const QString& name); @@ -69,6 +70,7 @@ private slots: private: Ui::ChannelAnalyzerGUI* ui; PluginAPI* m_pluginAPI; + DeviceAPI* m_deviceAPI; ChannelMarker m_channelMarker; bool m_basicSettingsShown; bool m_doApplySettings; @@ -83,7 +85,7 @@ private: SpectrumVis* m_spectrumVis; ScopeVis* m_scopeVis; - explicit ChannelAnalyzerGUI(PluginAPI* pluginAPI, QWidget* parent = NULL); + explicit ChannelAnalyzerGUI(PluginAPI* pluginAPI, DeviceAPI *deviceAPI, QWidget* parent = NULL); virtual ~ChannelAnalyzerGUI(); int getEffectiveLowCutoff(int lowCutoff); diff --git a/plugins/channel/chanalyzer/chanalyzerplugin.cpp b/plugins/channel/chanalyzer/chanalyzerplugin.cpp index 9c3b77625..ae2912a4f 100644 --- a/plugins/channel/chanalyzer/chanalyzerplugin.cpp +++ b/plugins/channel/chanalyzer/chanalyzerplugin.cpp @@ -30,10 +30,10 @@ void ChannelAnalyzerPlugin::initPlugin(PluginAPI* pluginAPI) m_pluginAPI->registerChannel("org.f4exb.sdrangelove.channel.chanalyzer", this); } -PluginGUI* ChannelAnalyzerPlugin::createChannel(const QString& channelName) +PluginGUI* ChannelAnalyzerPlugin::createChannel(const QString& channelName, DeviceAPI *deviceAPI) { if(channelName == "org.f4exb.sdrangelove.channel.chanalyzer") { - ChannelAnalyzerGUI* gui = ChannelAnalyzerGUI::create(m_pluginAPI); + ChannelAnalyzerGUI* gui = ChannelAnalyzerGUI::create(m_pluginAPI, deviceAPI); m_pluginAPI->registerChannelInstance("org.f4exb.sdrangelove.channel.chanalyzer", gui); m_pluginAPI->addChannelRollup(gui); return gui; @@ -42,9 +42,9 @@ PluginGUI* ChannelAnalyzerPlugin::createChannel(const QString& channelName) } } -void ChannelAnalyzerPlugin::createInstanceChannelAnalyzer() +void ChannelAnalyzerPlugin::createInstanceChannelAnalyzer(DeviceAPI *deviceAPI) { - ChannelAnalyzerGUI* gui = ChannelAnalyzerGUI::create(m_pluginAPI); + ChannelAnalyzerGUI* gui = ChannelAnalyzerGUI::create(m_pluginAPI, deviceAPI); m_pluginAPI->registerChannelInstance("org.f4exb.sdrangelove.channel.chanalyzer", gui); m_pluginAPI->addChannelRollup(gui); } diff --git a/plugins/channel/chanalyzer/chanalyzerplugin.h b/plugins/channel/chanalyzer/chanalyzerplugin.h index 8ef4b3507..37198e344 100644 --- a/plugins/channel/chanalyzer/chanalyzerplugin.h +++ b/plugins/channel/chanalyzer/chanalyzerplugin.h @@ -4,6 +4,8 @@ #include #include "plugin/plugininterface.h" +class DeviceAPI; + class ChannelAnalyzerPlugin : public QObject, PluginInterface { Q_OBJECT Q_INTERFACES(PluginInterface) @@ -15,7 +17,7 @@ public: const PluginDescriptor& getPluginDescriptor() const; void initPlugin(PluginAPI* pluginAPI); - PluginGUI* createChannel(const QString& channelName); + PluginGUI* createChannel(const QString& channelName, DeviceAPI *deviceAPI); private: static const PluginDescriptor m_pluginDescriptor; @@ -23,7 +25,7 @@ private: PluginAPI* m_pluginAPI; private slots: - void createInstanceChannelAnalyzer(); + void createInstanceChannelAnalyzer(DeviceAPI *deviceAPI); }; #endif // INCLUDE_CHANALYZERPLUGIN_H diff --git a/plugins/channel/demodam/amdemodgui.cpp b/plugins/channel/demodam/amdemodgui.cpp index 5a82f681b..1aa4ba31c 100644 --- a/plugins/channel/demodam/amdemodgui.cpp +++ b/plugins/channel/demodam/amdemodgui.cpp @@ -6,6 +6,7 @@ #include "dsp/threadedsamplesink.h" #include "dsp/channelizer.h" #include "plugin/pluginapi.h" +#include "device/deviceapi.h" #include "util/simpleserializer.h" #include "util/db.h" #include "gui/basicchannelsettingswidget.h" @@ -18,9 +19,9 @@ const int AMDemodGUI::m_rfBW[] = { 5000, 6250, 8330, 10000, 12500, 15000, 20000, 25000, 40000 }; -AMDemodGUI* AMDemodGUI::create(PluginAPI* pluginAPI) +AMDemodGUI* AMDemodGUI::create(PluginAPI* pluginAPI, DeviceAPI *deviceAPI) { - AMDemodGUI* gui = new AMDemodGUI(pluginAPI); + AMDemodGUI* gui = new AMDemodGUI(pluginAPI, deviceAPI); return gui; } @@ -200,10 +201,11 @@ void AMDemodGUI::onMenuDoubleClicked() } } -AMDemodGUI::AMDemodGUI(PluginAPI* pluginAPI, QWidget* parent) : +AMDemodGUI::AMDemodGUI(PluginAPI* pluginAPI, DeviceAPI *deviceAPI, QWidget* parent) : RollupWidget(parent), ui(new Ui::AMDemodGUI), m_pluginAPI(pluginAPI), + m_deviceAPI(deviceAPI), m_channelMarker(this), m_basicSettingsShown(false), m_doApplySettings(true), @@ -218,7 +220,8 @@ AMDemodGUI::AMDemodGUI(PluginAPI* pluginAPI, QWidget* parent) : m_amDemod = new AMDemod(); m_channelizer = new Channelizer(m_amDemod); m_threadedChannelizer = new ThreadedSampleSink(m_channelizer, this); - m_pluginAPI->addThreadedSink(m_threadedChannelizer); + //m_pluginAPI->addThreadedSink(m_threadedChannelizer); + m_deviceAPI->addThreadedSink(m_threadedChannelizer); connect(&m_pluginAPI->getMainWindow()->getMasterTimer(), SIGNAL(timeout()), this, SLOT(tick())); @@ -230,7 +233,10 @@ AMDemodGUI::AMDemodGUI(PluginAPI* pluginAPI, QWidget* parent) : m_channelMarker.setCenterFrequency(0); m_channelMarker.setVisible(true); connect(&m_channelMarker, SIGNAL(changed()), this, SLOT(viewChanged())); - m_pluginAPI->addChannelMarker(&m_channelMarker); + //m_pluginAPI->addChannelMarker(&m_channelMarker); + m_deviceAPI->addChannelMarker(&m_channelMarker); + + m_deviceAPI->addRollupWidget(this); applySettings(); } diff --git a/plugins/channel/demodam/amdemodgui.h b/plugins/channel/demodam/amdemodgui.h index d920485fd..be1081c8c 100644 --- a/plugins/channel/demodam/amdemodgui.h +++ b/plugins/channel/demodam/amdemodgui.h @@ -7,6 +7,7 @@ #include "dsp/movingaverage.h" class PluginAPI; +class DeviceAPI; class ThreadedSampleSink; class Channelizer; @@ -20,7 +21,7 @@ class AMDemodGUI : public RollupWidget, public PluginGUI { Q_OBJECT public: - static AMDemodGUI* create(PluginAPI* pluginAPI); + static AMDemodGUI* create(PluginAPI* pluginAPI, DeviceAPI *deviceAPI); void destroy(); void setName(const QString& name); @@ -50,6 +51,7 @@ private slots: private: Ui::AMDemodGUI* ui; PluginAPI* m_pluginAPI; + DeviceAPI* m_deviceAPI; ChannelMarker m_channelMarker; bool m_basicSettingsShown; bool m_doApplySettings; @@ -62,7 +64,7 @@ private: static const int m_rfBW[]; - explicit AMDemodGUI(PluginAPI* pluginAPI, QWidget* parent = NULL); + explicit AMDemodGUI(PluginAPI* pluginAPI, DeviceAPI *deviceAPI, QWidget* parent = NULL); virtual ~AMDemodGUI(); void blockApplySettings(bool block); diff --git a/plugins/channel/demodam/amplugin.cpp b/plugins/channel/demodam/amplugin.cpp index 1af8ebd54..3fc31f6a7 100644 --- a/plugins/channel/demodam/amplugin.cpp +++ b/plugins/channel/demodam/amplugin.cpp @@ -32,21 +32,21 @@ void AMPlugin::initPlugin(PluginAPI* pluginAPI) m_pluginAPI->registerChannel("de.maintech.sdrangelove.channel.am", this); } -PluginGUI* AMPlugin::createChannel(const QString& channelName) +PluginGUI* AMPlugin::createChannel(const QString& channelName, DeviceAPI *deviceAPI) { if(channelName == "de.maintech.sdrangelove.channel.am") { - AMDemodGUI* gui = AMDemodGUI::create(m_pluginAPI); + AMDemodGUI* gui = AMDemodGUI::create(m_pluginAPI, deviceAPI); m_pluginAPI->registerChannelInstance("de.maintech.sdrangelove.channel.am", gui); - m_pluginAPI->addChannelRollup(gui); +// m_pluginAPI->addChannelRollup(gui); return gui; } else { return NULL; } } -void AMPlugin::createInstanceAM() +void AMPlugin::createInstanceAM(DeviceAPI *deviceAPI) { - AMDemodGUI* gui = AMDemodGUI::create(m_pluginAPI); + AMDemodGUI* gui = AMDemodGUI::create(m_pluginAPI, deviceAPI); m_pluginAPI->registerChannelInstance("de.maintech.sdrangelove.channel.am", gui); m_pluginAPI->addChannelRollup(gui); } diff --git a/plugins/channel/demodam/amplugin.h b/plugins/channel/demodam/amplugin.h index 3c974f310..ade65eeb9 100644 --- a/plugins/channel/demodam/amplugin.h +++ b/plugins/channel/demodam/amplugin.h @@ -4,6 +4,8 @@ #include #include "plugin/plugininterface.h" +class DeviceAPI; + class AMPlugin : public QObject, PluginInterface { Q_OBJECT Q_INTERFACES(PluginInterface) @@ -15,7 +17,7 @@ public: const PluginDescriptor& getPluginDescriptor() const; void initPlugin(PluginAPI* pluginAPI); - PluginGUI* createChannel(const QString& channelName); + PluginGUI* createChannel(const QString& channelName, DeviceAPI *deviceAPI); private: static const PluginDescriptor m_pluginDescriptor; @@ -23,7 +25,7 @@ private: PluginAPI* m_pluginAPI; private slots: - void createInstanceAM(); + void createInstanceAM(DeviceAPI *deviceAPI); }; #endif // INCLUDE_AMPLUGIN_H diff --git a/plugins/channel/demodbfm/bfmdemodgui.cpp b/plugins/channel/demodbfm/bfmdemodgui.cpp index cfe2e6527..0a178d0e4 100644 --- a/plugins/channel/demodbfm/bfmdemodgui.cpp +++ b/plugins/channel/demodbfm/bfmdemodgui.cpp @@ -53,9 +53,9 @@ int requiredBW(int rfBW) return 384000; } -BFMDemodGUI* BFMDemodGUI::create(PluginAPI* pluginAPI) +BFMDemodGUI* BFMDemodGUI::create(PluginAPI* pluginAPI, DeviceAPI *deviceAPI) { - BFMDemodGUI* gui = new BFMDemodGUI(pluginAPI); + BFMDemodGUI* gui = new BFMDemodGUI(pluginAPI, deviceAPI); return gui; } @@ -356,10 +356,11 @@ void BFMDemodGUI::onMenuDoubleClicked() } } -BFMDemodGUI::BFMDemodGUI(PluginAPI* pluginAPI, QWidget* parent) : +BFMDemodGUI::BFMDemodGUI(PluginAPI* pluginAPI, DeviceAPI *deviceAPI, QWidget* parent) : RollupWidget(parent), ui(new Ui::BFMDemodGUI), m_pluginAPI(pluginAPI), + m_deviceAPI(deviceAPI), m_channelMarker(this), m_basicSettingsShown(false), m_rdsTimerCount(0), diff --git a/plugins/channel/demodbfm/bfmdemodgui.h b/plugins/channel/demodbfm/bfmdemodgui.h index 391e87663..923367efe 100644 --- a/plugins/channel/demodbfm/bfmdemodgui.h +++ b/plugins/channel/demodbfm/bfmdemodgui.h @@ -25,6 +25,7 @@ #include "rdsparser.h" class PluginAPI; +class DeviceAPI; class ThreadedSampleSink; class Channelizer; @@ -39,7 +40,7 @@ class BFMDemodGUI : public RollupWidget, public PluginGUI { Q_OBJECT public: - static BFMDemodGUI* create(PluginAPI* pluginAPI); + static BFMDemodGUI* create(PluginAPI* pluginAPI, DeviceAPI *deviceAPI); void destroy(); void setName(const QString& name); @@ -78,6 +79,7 @@ private slots: private: Ui::BFMDemodGUI* ui; PluginAPI* m_pluginAPI; + DeviceAPI* m_deviceAPI; ChannelMarker m_channelMarker; bool m_basicSettingsShown; bool m_doApplySettings; @@ -95,7 +97,7 @@ private: static const int m_rfBW[]; - explicit BFMDemodGUI(PluginAPI* pluginAPI, QWidget* parent = NULL); + explicit BFMDemodGUI(PluginAPI* pluginAPI, DeviceAPI *deviceAPI, QWidget* parent = NULL); virtual ~BFMDemodGUI(); void blockApplySettings(bool block); diff --git a/plugins/channel/demodbfm/bfmplugin.cpp b/plugins/channel/demodbfm/bfmplugin.cpp index 845c35a78..ac7bd849d 100644 --- a/plugins/channel/demodbfm/bfmplugin.cpp +++ b/plugins/channel/demodbfm/bfmplugin.cpp @@ -49,10 +49,10 @@ void BFMPlugin::initPlugin(PluginAPI* pluginAPI) m_pluginAPI->registerChannel("sdrangel.channel.bfm", this); } -PluginGUI* BFMPlugin::createChannel(const QString& channelName) +PluginGUI* BFMPlugin::createChannel(const QString& channelName, DeviceAPI *deviceAPI) { if(channelName == "sdrangel.channel.bfm") { - BFMDemodGUI* gui = BFMDemodGUI::create(m_pluginAPI); + BFMDemodGUI* gui = BFMDemodGUI::create(m_pluginAPI, deviceAPI); m_pluginAPI->registerChannelInstance("sdrangel.channel.bfm", gui); m_pluginAPI->addChannelRollup(gui); return gui; @@ -61,9 +61,9 @@ PluginGUI* BFMPlugin::createChannel(const QString& channelName) } } -void BFMPlugin::createInstanceBFM() +void BFMPlugin::createInstanceBFM(DeviceAPI *deviceAPI) { - BFMDemodGUI* gui = BFMDemodGUI::create(m_pluginAPI); + BFMDemodGUI* gui = BFMDemodGUI::create(m_pluginAPI, deviceAPI); m_pluginAPI->registerChannelInstance("sdrangel.channel.bfm", gui); m_pluginAPI->addChannelRollup(gui); } diff --git a/plugins/channel/demodbfm/bfmplugin.h b/plugins/channel/demodbfm/bfmplugin.h index b33b847b7..68793cc7b 100644 --- a/plugins/channel/demodbfm/bfmplugin.h +++ b/plugins/channel/demodbfm/bfmplugin.h @@ -21,6 +21,8 @@ #include #include "plugin/plugininterface.h" +class DeviceAPI; + class BFMPlugin : public QObject, PluginInterface { Q_OBJECT Q_INTERFACES(PluginInterface) @@ -32,7 +34,7 @@ public: const PluginDescriptor& getPluginDescriptor() const; void initPlugin(PluginAPI* pluginAPI); - PluginGUI* createChannel(const QString& channelName); + PluginGUI* createChannel(const QString& channelName, DeviceAPI *deviceAPI); private: static const PluginDescriptor m_pluginDescriptor; @@ -40,7 +42,7 @@ private: PluginAPI* m_pluginAPI; private slots: - void createInstanceBFM(); + void createInstanceBFM(DeviceAPI *deviceAPI); }; #endif // INCLUDE_BFMPLUGIN_H diff --git a/sdrbase/device/deviceapi.cpp b/sdrbase/device/deviceapi.cpp index d4ace4b75..2b15f93de 100644 --- a/sdrbase/device/deviceapi.cpp +++ b/sdrbase/device/deviceapi.cpp @@ -15,10 +15,13 @@ /////////////////////////////////////////////////////////////////////////////////// #include "device/deviceapi.h" +#include "gui/glspectrum.h" +#include "gui/channelwindow.h" -DeviceAPI::DeviceAPI(DSPDeviceEngine *deviceEngine, GLSpectrum *glSpectrum) : +DeviceAPI::DeviceAPI(DSPDeviceEngine *deviceEngine, GLSpectrum *glSpectrum, ChannelWindow *channelWindow) : m_deviceEngine(deviceEngine), - m_spectrum(glSpectrum) + m_spectrum(glSpectrum), + m_channelWindow(channelWindow) { } @@ -100,3 +103,19 @@ GLSpectrum *DeviceAPI::getSpectrum() { return m_spectrum; } + +void DeviceAPI::addChannelMarker(ChannelMarker* channelMarker) +{ + m_spectrum->addChannelMarker(channelMarker); +} + +ChannelWindow *DeviceAPI::getChannelWindow() +{ + return m_channelWindow; +} + +void DeviceAPI::addRollupWidget(QWidget *widget) +{ + m_channelWindow->addRollupWidget(widget); +} + diff --git a/sdrbase/device/deviceapi.h b/sdrbase/device/deviceapi.h index 2198ae568..0acb222c5 100644 --- a/sdrbase/device/deviceapi.h +++ b/sdrbase/device/deviceapi.h @@ -27,10 +27,13 @@ class MainWindow; class DSPDeviceEngine; class GLSpectrum; +class ChannelWindow; class SampleSink; class ThreadedSampleSink; class SampleSource; class MessageQueue; +class ChannelMarker; +class QWidget; class SDRANGEL_API DeviceAPI : public QObject { Q_OBJECT @@ -53,14 +56,18 @@ public: void configureCorrections(bool dcOffsetCorrection, bool iqImbalanceCorrection); //!< Configure current device engine DSP corrections // device related stuff - GLSpectrum *getSpectrum(); + GLSpectrum *getSpectrum(); //!< Direct spectrum getter + void addChannelMarker(ChannelMarker* channelMarker); //!< Add channel marker to spectrum + ChannelWindow *getChannelWindow(); //!< Direct channel window getter + void addRollupWidget(QWidget *widget); //!< Add rollup widget to channel window protected: - DeviceAPI(DSPDeviceEngine *deviceEngine, GLSpectrum *glSpectrum); + DeviceAPI(DSPDeviceEngine *deviceEngine, GLSpectrum *glSpectrum, ChannelWindow *channelWindow); ~DeviceAPI(); DSPDeviceEngine *m_deviceEngine; GLSpectrum *m_spectrum; + ChannelWindow *m_channelWindow; friend class MainWindow; }; diff --git a/sdrbase/gui/samplingdevicecontrol.cpp b/sdrbase/gui/samplingdevicecontrol.cpp index d0ba20535..d09948950 100644 --- a/sdrbase/gui/samplingdevicecontrol.cpp +++ b/sdrbase/gui/samplingdevicecontrol.cpp @@ -59,7 +59,7 @@ void SamplingDeviceControl::on_addChannel_clicked(bool checked) { if (m_pluginManager) { - m_pluginManager->createChannelInstance(ui->channelSelect->currentIndex()); + m_pluginManager->createChannelInstance(ui->channelSelect->currentIndex(), m_deviceAPI); } } diff --git a/sdrbase/gui/samplingdevicecontrol.h b/sdrbase/gui/samplingdevicecontrol.h index b019e04cf..47aac8b53 100644 --- a/sdrbase/gui/samplingdevicecontrol.h +++ b/sdrbase/gui/samplingdevicecontrol.h @@ -29,6 +29,7 @@ namespace Ui { class ChannelMarker; class PluginManager; +class DeviceAPI; class SDRANGEL_API SamplingDeviceControl : public QWidget { Q_OBJECT @@ -38,12 +39,14 @@ public: ~SamplingDeviceControl(); void setPluginManager(PluginManager *pluginManager) { m_pluginManager = pluginManager; } + void setDeviceAPI(DeviceAPI *devieAPI) { m_deviceAPI = devieAPI; } QComboBox *getDeviceSelector(); void populateChannelSelector(); private: Ui::SamplingDeviceControl* ui; PluginManager *m_pluginManager; + DeviceAPI *m_deviceAPI; private slots: void on_showLoadedPlugins_clicked(bool checked); diff --git a/sdrbase/mainwindow.cpp b/sdrbase/mainwindow.cpp index 60ccc58c2..c82d3c56e 100644 --- a/sdrbase/mainwindow.cpp +++ b/sdrbase/mainwindow.cpp @@ -196,7 +196,7 @@ void MainWindow::addDevice() m_deviceUIs.push_back(new DeviceUISet(m_masterTimer)); m_deviceUIs.back()->m_deviceEngine = dspDeviceEngine; - DeviceAPI *deviceAPI = new DeviceAPI(dspDeviceEngine, m_deviceUIs.back()->m_spectrum); + DeviceAPI *deviceAPI = new DeviceAPI(dspDeviceEngine, m_deviceUIs.back()->m_spectrum, m_deviceUIs.back()->m_channelWindow); m_deviceUIs.back()->m_deviceAPI = deviceAPI; // TODO: do not create one plugin manager per device. Use device API instead @@ -205,6 +205,7 @@ void MainWindow::addDevice() pluginManager->loadPlugins(); + m_deviceUIs.back()->m_samplingDeviceControl->setDeviceAPI(deviceAPI); m_deviceUIs.back()->m_samplingDeviceControl->setPluginManager(pluginManager); m_deviceUIs.back()->m_samplingDeviceControl->populateChannelSelector(); @@ -313,7 +314,7 @@ void MainWindow::loadPresetSettings(const Preset* preset) { DeviceUISet *deviceUI = m_deviceUIs[currentSourceTabIndex]; deviceUI->m_spectrumGUI->deserialize(preset->getSpectrumConfig()); - deviceUI->m_pluginManager->loadSettings(preset); + deviceUI->m_pluginManager->loadSettings(preset, deviceUI->m_deviceAPI); } // has to be last step diff --git a/sdrbase/plugin/plugininterface.h b/sdrbase/plugin/plugininterface.h index 0bee23c3d..6d59d7ef0 100644 --- a/sdrbase/plugin/plugininterface.h +++ b/sdrbase/plugin/plugininterface.h @@ -44,12 +44,10 @@ public: virtual const PluginDescriptor& getPluginDescriptor() const = 0; virtual void initPlugin(PluginAPI* pluginAPI) = 0; - virtual PluginGUI* createChannel(const QString& channelName) { return 0; } + virtual PluginGUI* createChannel(const QString& channelName, DeviceAPI *deviceAPI) { return 0; } virtual SampleSourceDevices enumSampleSources() { return SampleSourceDevices(); } - virtual PluginGUI* createSampleSourcePluginGUI(const QString& sourceId, - const QString& sourceDisplayName, - DeviceAPI *deviceAPI) + virtual PluginGUI* createSampleSourcePluginGUI(const QString& sourceId, const QString& sourceDisplayName, DeviceAPI *deviceAPI) { return 0; } diff --git a/sdrbase/plugin/pluginmanager.cpp b/sdrbase/plugin/pluginmanager.cpp index 4862ad739..fc83c5518 100644 --- a/sdrbase/plugin/pluginmanager.cpp +++ b/sdrbase/plugin/pluginmanager.cpp @@ -126,7 +126,7 @@ void PluginManager::removeThreadedSink(ThreadedSampleSink* sink) m_dspDeviceEngine->removeThreadedSink(sink); } -void PluginManager::loadSettings(const Preset* preset) +void PluginManager::loadSettings(const Preset* preset, DeviceAPI *deviceAPI) { fprintf(stderr, "PluginManager::loadSettings: Loading preset [%s | %s]\n", qPrintable(preset->getGroup()), qPrintable(preset->getDescription())); @@ -163,7 +163,7 @@ void PluginManager::loadSettings(const Preset* preset) if(m_channelRegistrations[i].m_channelName == channelConfig.m_channel) { qDebug("PluginManager::loadSettings: creating new channel [%s]", qPrintable(channelConfig.m_channel)); - reg = ChannelInstanceRegistration(channelConfig.m_channel, m_channelRegistrations[i].m_plugin->createChannel(channelConfig.m_channel)); + reg = ChannelInstanceRegistration(channelConfig.m_channel, m_channelRegistrations[i].m_plugin->createChannel(channelConfig.m_channel, deviceAPI)); break; } } @@ -541,11 +541,11 @@ void PluginManager::populateChannelComboBox(QComboBox *channels) } } -void PluginManager::createChannelInstance(int channelPluginIndex) +void PluginManager::createChannelInstance(int channelPluginIndex, DeviceAPI *deviceAPI) { if (channelPluginIndex < m_channelRegistrations.size()) { PluginInterface *pluginInterface = m_channelRegistrations[channelPluginIndex].m_plugin; - pluginInterface->createChannel(m_channelRegistrations[channelPluginIndex].m_channelName); + pluginInterface->createChannel(m_channelRegistrations[channelPluginIndex].m_channelName, deviceAPI); } } diff --git a/sdrbase/plugin/pluginmanager.h b/sdrbase/plugin/pluginmanager.h index d42088d0b..db9d408af 100644 --- a/sdrbase/plugin/pluginmanager.h +++ b/sdrbase/plugin/pluginmanager.h @@ -80,7 +80,7 @@ public: // GLSpectrum *getSpectrum() { return m_spectrum; } - void loadSettings(const Preset* preset); + void loadSettings(const Preset* preset, DeviceAPI *deviceAPI); void loadSourceSettings(const Preset* preset); void saveSettings(Preset* preset); void saveSourceSettings(Preset* preset); @@ -91,12 +91,13 @@ public: void updateSampleSourceDevices(); void fillSampleSourceSelector(QComboBox* comboBox); + int selectSampleSourceByIndex(int index, DeviceAPI *deviceAPI); int selectFirstSampleSource(const QString& sourceId, DeviceAPI *deviceAPI); int selectSampleSourceBySerialOrSequence(const QString& sourceId, const QString& sourceSerial, int sourceSequence, DeviceAPI *deviceAPI); void populateChannelComboBox(QComboBox *channels); - void createChannelInstance(int channelPluginIndex); + void createChannelInstance(int channelPluginIndex, DeviceAPI *deviceAPI); private: struct ChannelRegistration {