1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-13 11:51:47 -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 "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),

View File

@ -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);

View File

@ -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);
}

View File

@ -4,6 +4,8 @@
#include <QObject>
#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

View File

@ -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();
}

View File

@ -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);

View File

@ -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);
}

View File

@ -4,6 +4,8 @@
#include <QObject>
#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

View File

@ -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),

View File

@ -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);

View File

@ -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);
}

View File

@ -21,6 +21,8 @@
#include <QObject>
#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

View File

@ -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);
}

View File

@ -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;
};

View File

@ -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);
}
}

View File

@ -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);

View File

@ -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

View File

@ -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;
}

View File

@ -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);
}
}

View File

@ -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 {