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

Multi device support: channel plugin per device mechanism validation with AM demod

This commit is contained in:
f4exb 2016-05-16 03:21:21 +02:00
parent 7412ee0d54
commit bbb4bc28b4
20 changed files with 102 additions and 53 deletions

View File

@ -34,9 +34,9 @@
#include "chanalyzer.h" #include "chanalyzer.h"
#include "chanalyzergui.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; 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), RollupWidget(parent),
ui(new Ui::ChannelAnalyzerGUI), ui(new Ui::ChannelAnalyzerGUI),
m_pluginAPI(pluginAPI), m_pluginAPI(pluginAPI),
m_deviceAPI(deviceAPI),
m_channelMarker(this), m_channelMarker(this),
m_basicSettingsShown(false), m_basicSettingsShown(false),
m_doApplySettings(true), m_doApplySettings(true),

View File

@ -23,6 +23,7 @@
#include "dsp/movingaverage.h" #include "dsp/movingaverage.h"
class PluginAPI; class PluginAPI;
class DeviceAPI;
class ThreadedSampleSink; class ThreadedSampleSink;
class Channelizer; class Channelizer;
@ -39,7 +40,7 @@ class ChannelAnalyzerGUI : public RollupWidget, public PluginGUI {
Q_OBJECT Q_OBJECT
public: public:
static ChannelAnalyzerGUI* create(PluginAPI* pluginAPI); static ChannelAnalyzerGUI* create(PluginAPI* pluginAPI, DeviceAPI *deviceAPI);
void destroy(); void destroy();
void setName(const QString& name); void setName(const QString& name);
@ -69,6 +70,7 @@ private slots:
private: private:
Ui::ChannelAnalyzerGUI* ui; Ui::ChannelAnalyzerGUI* ui;
PluginAPI* m_pluginAPI; PluginAPI* m_pluginAPI;
DeviceAPI* m_deviceAPI;
ChannelMarker m_channelMarker; ChannelMarker m_channelMarker;
bool m_basicSettingsShown; bool m_basicSettingsShown;
bool m_doApplySettings; bool m_doApplySettings;
@ -83,7 +85,7 @@ private:
SpectrumVis* m_spectrumVis; SpectrumVis* m_spectrumVis;
ScopeVis* m_scopeVis; ScopeVis* m_scopeVis;
explicit ChannelAnalyzerGUI(PluginAPI* pluginAPI, QWidget* parent = NULL); explicit ChannelAnalyzerGUI(PluginAPI* pluginAPI, DeviceAPI *deviceAPI, QWidget* parent = NULL);
virtual ~ChannelAnalyzerGUI(); virtual ~ChannelAnalyzerGUI();
int getEffectiveLowCutoff(int lowCutoff); int getEffectiveLowCutoff(int lowCutoff);

View File

@ -30,10 +30,10 @@ void ChannelAnalyzerPlugin::initPlugin(PluginAPI* pluginAPI)
m_pluginAPI->registerChannel("org.f4exb.sdrangelove.channel.chanalyzer", this); 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") { 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->registerChannelInstance("org.f4exb.sdrangelove.channel.chanalyzer", gui);
m_pluginAPI->addChannelRollup(gui); m_pluginAPI->addChannelRollup(gui);
return 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->registerChannelInstance("org.f4exb.sdrangelove.channel.chanalyzer", gui);
m_pluginAPI->addChannelRollup(gui); m_pluginAPI->addChannelRollup(gui);
} }

View File

@ -4,6 +4,8 @@
#include <QObject> #include <QObject>
#include "plugin/plugininterface.h" #include "plugin/plugininterface.h"
class DeviceAPI;
class ChannelAnalyzerPlugin : public QObject, PluginInterface { class ChannelAnalyzerPlugin : public QObject, PluginInterface {
Q_OBJECT Q_OBJECT
Q_INTERFACES(PluginInterface) Q_INTERFACES(PluginInterface)
@ -15,7 +17,7 @@ public:
const PluginDescriptor& getPluginDescriptor() const; const PluginDescriptor& getPluginDescriptor() const;
void initPlugin(PluginAPI* pluginAPI); void initPlugin(PluginAPI* pluginAPI);
PluginGUI* createChannel(const QString& channelName); PluginGUI* createChannel(const QString& channelName, DeviceAPI *deviceAPI);
private: private:
static const PluginDescriptor m_pluginDescriptor; static const PluginDescriptor m_pluginDescriptor;
@ -23,7 +25,7 @@ private:
PluginAPI* m_pluginAPI; PluginAPI* m_pluginAPI;
private slots: private slots:
void createInstanceChannelAnalyzer(); void createInstanceChannelAnalyzer(DeviceAPI *deviceAPI);
}; };
#endif // INCLUDE_CHANALYZERPLUGIN_H #endif // INCLUDE_CHANALYZERPLUGIN_H

View File

@ -6,6 +6,7 @@
#include "dsp/threadedsamplesink.h" #include "dsp/threadedsamplesink.h"
#include "dsp/channelizer.h" #include "dsp/channelizer.h"
#include "plugin/pluginapi.h" #include "plugin/pluginapi.h"
#include "device/deviceapi.h"
#include "util/simpleserializer.h" #include "util/simpleserializer.h"
#include "util/db.h" #include "util/db.h"
#include "gui/basicchannelsettingswidget.h" #include "gui/basicchannelsettingswidget.h"
@ -18,9 +19,9 @@ const int AMDemodGUI::m_rfBW[] = {
5000, 6250, 8330, 10000, 12500, 15000, 20000, 25000, 40000 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; 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), RollupWidget(parent),
ui(new Ui::AMDemodGUI), ui(new Ui::AMDemodGUI),
m_pluginAPI(pluginAPI), m_pluginAPI(pluginAPI),
m_deviceAPI(deviceAPI),
m_channelMarker(this), m_channelMarker(this),
m_basicSettingsShown(false), m_basicSettingsShown(false),
m_doApplySettings(true), m_doApplySettings(true),
@ -218,7 +220,8 @@ AMDemodGUI::AMDemodGUI(PluginAPI* pluginAPI, QWidget* parent) :
m_amDemod = new AMDemod(); m_amDemod = new AMDemod();
m_channelizer = new Channelizer(m_amDemod); m_channelizer = new Channelizer(m_amDemod);
m_threadedChannelizer = new ThreadedSampleSink(m_channelizer, this); 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())); 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.setCenterFrequency(0);
m_channelMarker.setVisible(true); m_channelMarker.setVisible(true);
connect(&m_channelMarker, SIGNAL(changed()), this, SLOT(viewChanged())); 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(); applySettings();
} }

View File

@ -7,6 +7,7 @@
#include "dsp/movingaverage.h" #include "dsp/movingaverage.h"
class PluginAPI; class PluginAPI;
class DeviceAPI;
class ThreadedSampleSink; class ThreadedSampleSink;
class Channelizer; class Channelizer;
@ -20,7 +21,7 @@ class AMDemodGUI : public RollupWidget, public PluginGUI {
Q_OBJECT Q_OBJECT
public: public:
static AMDemodGUI* create(PluginAPI* pluginAPI); static AMDemodGUI* create(PluginAPI* pluginAPI, DeviceAPI *deviceAPI);
void destroy(); void destroy();
void setName(const QString& name); void setName(const QString& name);
@ -50,6 +51,7 @@ private slots:
private: private:
Ui::AMDemodGUI* ui; Ui::AMDemodGUI* ui;
PluginAPI* m_pluginAPI; PluginAPI* m_pluginAPI;
DeviceAPI* m_deviceAPI;
ChannelMarker m_channelMarker; ChannelMarker m_channelMarker;
bool m_basicSettingsShown; bool m_basicSettingsShown;
bool m_doApplySettings; bool m_doApplySettings;
@ -62,7 +64,7 @@ private:
static const int m_rfBW[]; static const int m_rfBW[];
explicit AMDemodGUI(PluginAPI* pluginAPI, QWidget* parent = NULL); explicit AMDemodGUI(PluginAPI* pluginAPI, DeviceAPI *deviceAPI, QWidget* parent = NULL);
virtual ~AMDemodGUI(); virtual ~AMDemodGUI();
void blockApplySettings(bool block); void blockApplySettings(bool block);

View File

@ -32,21 +32,21 @@ void AMPlugin::initPlugin(PluginAPI* pluginAPI)
m_pluginAPI->registerChannel("de.maintech.sdrangelove.channel.am", this); 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") { 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->registerChannelInstance("de.maintech.sdrangelove.channel.am", gui);
m_pluginAPI->addChannelRollup(gui); // m_pluginAPI->addChannelRollup(gui);
return gui; return gui;
} else { } else {
return NULL; 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->registerChannelInstance("de.maintech.sdrangelove.channel.am", gui);
m_pluginAPI->addChannelRollup(gui); m_pluginAPI->addChannelRollup(gui);
} }

View File

@ -4,6 +4,8 @@
#include <QObject> #include <QObject>
#include "plugin/plugininterface.h" #include "plugin/plugininterface.h"
class DeviceAPI;
class AMPlugin : public QObject, PluginInterface { class AMPlugin : public QObject, PluginInterface {
Q_OBJECT Q_OBJECT
Q_INTERFACES(PluginInterface) Q_INTERFACES(PluginInterface)
@ -15,7 +17,7 @@ public:
const PluginDescriptor& getPluginDescriptor() const; const PluginDescriptor& getPluginDescriptor() const;
void initPlugin(PluginAPI* pluginAPI); void initPlugin(PluginAPI* pluginAPI);
PluginGUI* createChannel(const QString& channelName); PluginGUI* createChannel(const QString& channelName, DeviceAPI *deviceAPI);
private: private:
static const PluginDescriptor m_pluginDescriptor; static const PluginDescriptor m_pluginDescriptor;
@ -23,7 +25,7 @@ private:
PluginAPI* m_pluginAPI; PluginAPI* m_pluginAPI;
private slots: private slots:
void createInstanceAM(); void createInstanceAM(DeviceAPI *deviceAPI);
}; };
#endif // INCLUDE_AMPLUGIN_H #endif // INCLUDE_AMPLUGIN_H

View File

@ -53,9 +53,9 @@ int requiredBW(int rfBW)
return 384000; 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; 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), RollupWidget(parent),
ui(new Ui::BFMDemodGUI), ui(new Ui::BFMDemodGUI),
m_pluginAPI(pluginAPI), m_pluginAPI(pluginAPI),
m_deviceAPI(deviceAPI),
m_channelMarker(this), m_channelMarker(this),
m_basicSettingsShown(false), m_basicSettingsShown(false),
m_rdsTimerCount(0), m_rdsTimerCount(0),

View File

@ -25,6 +25,7 @@
#include "rdsparser.h" #include "rdsparser.h"
class PluginAPI; class PluginAPI;
class DeviceAPI;
class ThreadedSampleSink; class ThreadedSampleSink;
class Channelizer; class Channelizer;
@ -39,7 +40,7 @@ class BFMDemodGUI : public RollupWidget, public PluginGUI {
Q_OBJECT Q_OBJECT
public: public:
static BFMDemodGUI* create(PluginAPI* pluginAPI); static BFMDemodGUI* create(PluginAPI* pluginAPI, DeviceAPI *deviceAPI);
void destroy(); void destroy();
void setName(const QString& name); void setName(const QString& name);
@ -78,6 +79,7 @@ private slots:
private: private:
Ui::BFMDemodGUI* ui; Ui::BFMDemodGUI* ui;
PluginAPI* m_pluginAPI; PluginAPI* m_pluginAPI;
DeviceAPI* m_deviceAPI;
ChannelMarker m_channelMarker; ChannelMarker m_channelMarker;
bool m_basicSettingsShown; bool m_basicSettingsShown;
bool m_doApplySettings; bool m_doApplySettings;
@ -95,7 +97,7 @@ private:
static const int m_rfBW[]; static const int m_rfBW[];
explicit BFMDemodGUI(PluginAPI* pluginAPI, QWidget* parent = NULL); explicit BFMDemodGUI(PluginAPI* pluginAPI, DeviceAPI *deviceAPI, QWidget* parent = NULL);
virtual ~BFMDemodGUI(); virtual ~BFMDemodGUI();
void blockApplySettings(bool block); void blockApplySettings(bool block);

View File

@ -49,10 +49,10 @@ void BFMPlugin::initPlugin(PluginAPI* pluginAPI)
m_pluginAPI->registerChannel("sdrangel.channel.bfm", this); 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") { 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->registerChannelInstance("sdrangel.channel.bfm", gui);
m_pluginAPI->addChannelRollup(gui); m_pluginAPI->addChannelRollup(gui);
return 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->registerChannelInstance("sdrangel.channel.bfm", gui);
m_pluginAPI->addChannelRollup(gui); m_pluginAPI->addChannelRollup(gui);
} }

View File

@ -21,6 +21,8 @@
#include <QObject> #include <QObject>
#include "plugin/plugininterface.h" #include "plugin/plugininterface.h"
class DeviceAPI;
class BFMPlugin : public QObject, PluginInterface { class BFMPlugin : public QObject, PluginInterface {
Q_OBJECT Q_OBJECT
Q_INTERFACES(PluginInterface) Q_INTERFACES(PluginInterface)
@ -32,7 +34,7 @@ public:
const PluginDescriptor& getPluginDescriptor() const; const PluginDescriptor& getPluginDescriptor() const;
void initPlugin(PluginAPI* pluginAPI); void initPlugin(PluginAPI* pluginAPI);
PluginGUI* createChannel(const QString& channelName); PluginGUI* createChannel(const QString& channelName, DeviceAPI *deviceAPI);
private: private:
static const PluginDescriptor m_pluginDescriptor; static const PluginDescriptor m_pluginDescriptor;
@ -40,7 +42,7 @@ private:
PluginAPI* m_pluginAPI; PluginAPI* m_pluginAPI;
private slots: private slots:
void createInstanceBFM(); void createInstanceBFM(DeviceAPI *deviceAPI);
}; };
#endif // INCLUDE_BFMPLUGIN_H #endif // INCLUDE_BFMPLUGIN_H

View File

@ -15,10 +15,13 @@
/////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////
#include "device/deviceapi.h" #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_deviceEngine(deviceEngine),
m_spectrum(glSpectrum) m_spectrum(glSpectrum),
m_channelWindow(channelWindow)
{ {
} }
@ -100,3 +103,19 @@ GLSpectrum *DeviceAPI::getSpectrum()
{ {
return m_spectrum; 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);
}

View File

@ -27,10 +27,13 @@
class MainWindow; class MainWindow;
class DSPDeviceEngine; class DSPDeviceEngine;
class GLSpectrum; class GLSpectrum;
class ChannelWindow;
class SampleSink; class SampleSink;
class ThreadedSampleSink; class ThreadedSampleSink;
class SampleSource; class SampleSource;
class MessageQueue; class MessageQueue;
class ChannelMarker;
class QWidget;
class SDRANGEL_API DeviceAPI : public QObject { class SDRANGEL_API DeviceAPI : public QObject {
Q_OBJECT Q_OBJECT
@ -53,14 +56,18 @@ public:
void configureCorrections(bool dcOffsetCorrection, bool iqImbalanceCorrection); //!< Configure current device engine DSP corrections void configureCorrections(bool dcOffsetCorrection, bool iqImbalanceCorrection); //!< Configure current device engine DSP corrections
// device related stuff // 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: protected:
DeviceAPI(DSPDeviceEngine *deviceEngine, GLSpectrum *glSpectrum); DeviceAPI(DSPDeviceEngine *deviceEngine, GLSpectrum *glSpectrum, ChannelWindow *channelWindow);
~DeviceAPI(); ~DeviceAPI();
DSPDeviceEngine *m_deviceEngine; DSPDeviceEngine *m_deviceEngine;
GLSpectrum *m_spectrum; GLSpectrum *m_spectrum;
ChannelWindow *m_channelWindow;
friend class MainWindow; friend class MainWindow;
}; };

View File

@ -59,7 +59,7 @@ void SamplingDeviceControl::on_addChannel_clicked(bool checked)
{ {
if (m_pluginManager) if (m_pluginManager)
{ {
m_pluginManager->createChannelInstance(ui->channelSelect->currentIndex()); m_pluginManager->createChannelInstance(ui->channelSelect->currentIndex(), m_deviceAPI);
} }
} }

View File

@ -29,6 +29,7 @@ namespace Ui {
class ChannelMarker; class ChannelMarker;
class PluginManager; class PluginManager;
class DeviceAPI;
class SDRANGEL_API SamplingDeviceControl : public QWidget { class SDRANGEL_API SamplingDeviceControl : public QWidget {
Q_OBJECT Q_OBJECT
@ -38,12 +39,14 @@ public:
~SamplingDeviceControl(); ~SamplingDeviceControl();
void setPluginManager(PluginManager *pluginManager) { m_pluginManager = pluginManager; } void setPluginManager(PluginManager *pluginManager) { m_pluginManager = pluginManager; }
void setDeviceAPI(DeviceAPI *devieAPI) { m_deviceAPI = devieAPI; }
QComboBox *getDeviceSelector(); QComboBox *getDeviceSelector();
void populateChannelSelector(); void populateChannelSelector();
private: private:
Ui::SamplingDeviceControl* ui; Ui::SamplingDeviceControl* ui;
PluginManager *m_pluginManager; PluginManager *m_pluginManager;
DeviceAPI *m_deviceAPI;
private slots: private slots:
void on_showLoadedPlugins_clicked(bool checked); void on_showLoadedPlugins_clicked(bool checked);

View File

@ -196,7 +196,7 @@ void MainWindow::addDevice()
m_deviceUIs.push_back(new DeviceUISet(m_masterTimer)); m_deviceUIs.push_back(new DeviceUISet(m_masterTimer));
m_deviceUIs.back()->m_deviceEngine = dspDeviceEngine; 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; m_deviceUIs.back()->m_deviceAPI = deviceAPI;
// TODO: do not create one plugin manager per device. Use device API instead // TODO: do not create one plugin manager per device. Use device API instead
@ -205,6 +205,7 @@ void MainWindow::addDevice()
pluginManager->loadPlugins(); pluginManager->loadPlugins();
m_deviceUIs.back()->m_samplingDeviceControl->setDeviceAPI(deviceAPI);
m_deviceUIs.back()->m_samplingDeviceControl->setPluginManager(pluginManager); m_deviceUIs.back()->m_samplingDeviceControl->setPluginManager(pluginManager);
m_deviceUIs.back()->m_samplingDeviceControl->populateChannelSelector(); m_deviceUIs.back()->m_samplingDeviceControl->populateChannelSelector();
@ -313,7 +314,7 @@ void MainWindow::loadPresetSettings(const Preset* preset)
{ {
DeviceUISet *deviceUI = m_deviceUIs[currentSourceTabIndex]; DeviceUISet *deviceUI = m_deviceUIs[currentSourceTabIndex];
deviceUI->m_spectrumGUI->deserialize(preset->getSpectrumConfig()); deviceUI->m_spectrumGUI->deserialize(preset->getSpectrumConfig());
deviceUI->m_pluginManager->loadSettings(preset); deviceUI->m_pluginManager->loadSettings(preset, deviceUI->m_deviceAPI);
} }
// has to be last step // has to be last step

View File

@ -44,12 +44,10 @@ public:
virtual const PluginDescriptor& getPluginDescriptor() const = 0; virtual const PluginDescriptor& getPluginDescriptor() const = 0;
virtual void initPlugin(PluginAPI* pluginAPI) = 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 SampleSourceDevices enumSampleSources() { return SampleSourceDevices(); }
virtual PluginGUI* createSampleSourcePluginGUI(const QString& sourceId, virtual PluginGUI* createSampleSourcePluginGUI(const QString& sourceId, const QString& sourceDisplayName, DeviceAPI *deviceAPI)
const QString& sourceDisplayName,
DeviceAPI *deviceAPI)
{ {
return 0; return 0;
} }

View File

@ -126,7 +126,7 @@ void PluginManager::removeThreadedSink(ThreadedSampleSink* sink)
m_dspDeviceEngine->removeThreadedSink(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())); 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) if(m_channelRegistrations[i].m_channelName == channelConfig.m_channel)
{ {
qDebug("PluginManager::loadSettings: creating new channel [%s]", qPrintable(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; 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()) if (channelPluginIndex < m_channelRegistrations.size())
{ {
PluginInterface *pluginInterface = m_channelRegistrations[channelPluginIndex].m_plugin; PluginInterface *pluginInterface = m_channelRegistrations[channelPluginIndex].m_plugin;
pluginInterface->createChannel(m_channelRegistrations[channelPluginIndex].m_channelName); pluginInterface->createChannel(m_channelRegistrations[channelPluginIndex].m_channelName, deviceAPI);
} }
} }

View File

@ -80,7 +80,7 @@ public:
// GLSpectrum *getSpectrum() { return m_spectrum; } // GLSpectrum *getSpectrum() { return m_spectrum; }
void loadSettings(const Preset* preset); void loadSettings(const Preset* preset, DeviceAPI *deviceAPI);
void loadSourceSettings(const Preset* preset); void loadSourceSettings(const Preset* preset);
void saveSettings(Preset* preset); void saveSettings(Preset* preset);
void saveSourceSettings(Preset* preset); void saveSourceSettings(Preset* preset);
@ -91,12 +91,13 @@ public:
void updateSampleSourceDevices(); void updateSampleSourceDevices();
void fillSampleSourceSelector(QComboBox* comboBox); void fillSampleSourceSelector(QComboBox* comboBox);
int selectSampleSourceByIndex(int index, DeviceAPI *deviceAPI); int selectSampleSourceByIndex(int index, DeviceAPI *deviceAPI);
int selectFirstSampleSource(const QString& sourceId, DeviceAPI *deviceAPI); int selectFirstSampleSource(const QString& sourceId, DeviceAPI *deviceAPI);
int selectSampleSourceBySerialOrSequence(const QString& sourceId, const QString& sourceSerial, int sourceSequence, DeviceAPI *deviceAPI); int selectSampleSourceBySerialOrSequence(const QString& sourceId, const QString& sourceSerial, int sourceSequence, DeviceAPI *deviceAPI);
void populateChannelComboBox(QComboBox *channels); void populateChannelComboBox(QComboBox *channels);
void createChannelInstance(int channelPluginIndex); void createChannelInstance(int channelPluginIndex, DeviceAPI *deviceAPI);
private: private:
struct ChannelRegistration { struct ChannelRegistration {