2014-05-18 15:52:39 +00:00
|
|
|
#include <QApplication>
|
|
|
|
#include <QPluginLoader>
|
|
|
|
#include <QComboBox>
|
2016-05-15 02:38:37 +00:00
|
|
|
#include <cstdio>
|
|
|
|
|
2014-05-18 15:52:39 +00:00
|
|
|
#include "plugin/pluginmanager.h"
|
|
|
|
#include "plugin/plugingui.h"
|
2016-05-16 09:32:22 +00:00
|
|
|
#include "device/deviceapi.h"
|
2014-05-18 15:52:39 +00:00
|
|
|
#include "settings/preset.h"
|
|
|
|
#include "mainwindow.h"
|
2016-05-15 09:26:48 +00:00
|
|
|
#include "gui/glspectrum.h"
|
2016-05-16 08:35:36 +00:00
|
|
|
#include "dsp/dspdeviceengine.h"
|
|
|
|
#include "util/message.h"
|
2014-05-18 15:52:39 +00:00
|
|
|
|
2015-08-09 08:33:04 +00:00
|
|
|
#include <QDebug>
|
2015-06-07 01:30:28 +00:00
|
|
|
|
2016-05-22 19:56:07 +00:00
|
|
|
const QString PluginManager::m_sdrDaemonDeviceTypeID = "sdrangel.samplesource.sdrdaemon";
|
2016-06-19 23:58:46 +00:00
|
|
|
const QString PluginManager::m_sdrDaemonFECDeviceTypeID = "sdrangel.samplesource.sdrdaemonfec";
|
2016-05-22 19:56:07 +00:00
|
|
|
const QString PluginManager::m_fileSourceDeviceTypeID = "sdrangel.samplesource.filesource";
|
|
|
|
|
2016-05-16 22:04:27 +00:00
|
|
|
PluginManager::PluginManager(MainWindow* mainWindow, QObject* parent) :
|
2014-05-18 15:52:39 +00:00
|
|
|
QObject(parent),
|
2016-05-11 14:03:03 +00:00
|
|
|
m_pluginAPI(this, mainWindow),
|
2016-05-17 17:36:28 +00:00
|
|
|
m_mainWindow(mainWindow)
|
2014-05-18 15:52:39 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
PluginManager::~PluginManager()
|
|
|
|
{
|
2016-05-16 22:04:27 +00:00
|
|
|
// freeAll();
|
2014-05-18 15:52:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void PluginManager::loadPlugins()
|
|
|
|
{
|
2016-02-24 10:51:36 +00:00
|
|
|
QString applicationDirPath = QApplication::instance()->applicationDirPath();
|
|
|
|
QString applicationLibPath = applicationDirPath + "/../lib";
|
|
|
|
qDebug() << "PluginManager::loadPlugins: " << qPrintable(applicationDirPath) << ", " << qPrintable(applicationLibPath);
|
2015-08-26 00:03:20 +00:00
|
|
|
|
2016-02-24 10:51:36 +00:00
|
|
|
QDir pluginsBinDir = QDir(applicationDirPath);
|
|
|
|
QDir pluginsLibDir = QDir(applicationLibPath);
|
2014-05-18 15:52:39 +00:00
|
|
|
|
2016-02-24 10:51:36 +00:00
|
|
|
loadPlugins(pluginsBinDir);
|
|
|
|
loadPlugins(pluginsLibDir);
|
2014-05-18 15:52:39 +00:00
|
|
|
|
|
|
|
qSort(m_plugins);
|
|
|
|
|
2015-08-26 00:03:20 +00:00
|
|
|
for (Plugins::const_iterator it = m_plugins.begin(); it != m_plugins.end(); ++it)
|
|
|
|
{
|
2015-09-30 06:55:58 +00:00
|
|
|
it->pluginInterface->initPlugin(&m_pluginAPI);
|
2015-08-09 02:09:05 +00:00
|
|
|
}
|
2014-05-18 15:52:39 +00:00
|
|
|
|
|
|
|
updateSampleSourceDevices();
|
|
|
|
}
|
|
|
|
|
2016-05-14 19:33:12 +00:00
|
|
|
void PluginManager::registerChannel(const QString& channelName, PluginInterface* plugin)
|
2014-05-18 15:52:39 +00:00
|
|
|
{
|
2016-05-16 16:34:23 +00:00
|
|
|
m_channelRegistrations.append(PluginAPI::ChannelRegistration(channelName, plugin));
|
2014-05-18 15:52:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void PluginManager::registerSampleSource(const QString& sourceName, PluginInterface* plugin)
|
|
|
|
{
|
2015-08-09 08:33:04 +00:00
|
|
|
qDebug() << "PluginManager::registerSampleSource "
|
2015-08-09 09:11:28 +00:00
|
|
|
<< plugin->getPluginDescriptor().displayedName.toStdString().c_str()
|
|
|
|
<< " with source name " << sourceName.toStdString().c_str();
|
2015-06-07 01:30:28 +00:00
|
|
|
|
2014-05-18 15:52:39 +00:00
|
|
|
m_sampleSourceRegistrations.append(SampleSourceRegistration(sourceName, plugin));
|
|
|
|
}
|
|
|
|
|
|
|
|
void PluginManager::updateSampleSourceDevices()
|
|
|
|
{
|
|
|
|
m_sampleSourceDevices.clear();
|
2015-09-30 04:57:40 +00:00
|
|
|
|
|
|
|
for(int i = 0; i < m_sampleSourceRegistrations.count(); ++i)
|
|
|
|
{
|
2014-05-18 15:52:39 +00:00
|
|
|
PluginInterface::SampleSourceDevices ssd = m_sampleSourceRegistrations[i].m_plugin->enumSampleSources();
|
2015-09-30 04:57:40 +00:00
|
|
|
|
2014-05-18 15:52:39 +00:00
|
|
|
for(int j = 0; j < ssd.count(); ++j)
|
2015-09-30 04:57:40 +00:00
|
|
|
{
|
|
|
|
m_sampleSourceDevices.append(SampleSourceDevice(m_sampleSourceRegistrations[i].m_plugin,
|
|
|
|
ssd[j].displayedName,
|
|
|
|
ssd[j].id,
|
|
|
|
ssd[j].serial,
|
|
|
|
ssd[j].sequence));
|
|
|
|
}
|
2014-05-18 15:52:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-22 22:21:13 +00:00
|
|
|
void PluginManager::duplicateLocalSampleSourceDevices(uint deviceUID)
|
|
|
|
{
|
|
|
|
if (deviceUID == 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
SampleSourceDevice *sdrDaemonSSD0 = 0;
|
2016-06-19 23:58:46 +00:00
|
|
|
SampleSourceDevice *sdrDaemonFECSSD0 = 0;
|
2016-05-22 22:21:13 +00:00
|
|
|
SampleSourceDevice *fileSourceSSD0 = 0;
|
|
|
|
bool duplicateSDRDaemon = true;
|
2016-06-19 23:58:46 +00:00
|
|
|
bool duplicateSDRDaemonFEC = true;
|
2016-05-22 22:21:13 +00:00
|
|
|
bool duplicateFileSource = true;
|
|
|
|
|
|
|
|
for(int i = 0; i < m_sampleSourceDevices.count(); ++i)
|
|
|
|
{
|
|
|
|
if (m_sampleSourceDevices[i].m_sourceId == m_sdrDaemonDeviceTypeID) // SDRdaemon
|
|
|
|
{
|
|
|
|
if (m_sampleSourceDevices[i].m_sourceSequence == 0) { // reference to device 0
|
|
|
|
sdrDaemonSSD0 = &m_sampleSourceDevices[i];
|
|
|
|
}
|
|
|
|
else if (m_sampleSourceDevices[i].m_sourceSequence == deviceUID) { // already there
|
|
|
|
duplicateSDRDaemon = false;
|
|
|
|
}
|
|
|
|
}
|
2016-06-19 23:58:46 +00:00
|
|
|
else if (m_sampleSourceDevices[i].m_sourceId == m_sdrDaemonFECDeviceTypeID) // SDRdaemon with FEC
|
|
|
|
{
|
|
|
|
if (m_sampleSourceDevices[i].m_sourceSequence == 0) { // reference to device 0
|
|
|
|
sdrDaemonFECSSD0 = &m_sampleSourceDevices[i];
|
|
|
|
}
|
|
|
|
else if (m_sampleSourceDevices[i].m_sourceSequence == deviceUID) { // already there
|
|
|
|
duplicateSDRDaemonFEC = false;
|
|
|
|
}
|
|
|
|
}
|
2016-05-22 22:21:13 +00:00
|
|
|
else if (m_sampleSourceDevices[i].m_sourceId == m_fileSourceDeviceTypeID) // File Source
|
|
|
|
{
|
|
|
|
if (m_sampleSourceDevices[i].m_sourceSequence == 0) { // reference to device 0
|
|
|
|
fileSourceSSD0 = &m_sampleSourceDevices[i];
|
|
|
|
}
|
|
|
|
else if (m_sampleSourceDevices[i].m_sourceSequence == deviceUID) { // already there
|
|
|
|
duplicateFileSource = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sdrDaemonSSD0 && duplicateSDRDaemon) // append item for a new instance
|
|
|
|
{
|
|
|
|
m_sampleSourceDevices.append(
|
|
|
|
SampleSourceDevice(
|
|
|
|
sdrDaemonSSD0->m_plugin,
|
|
|
|
QString("SDRdaemon[%1]").arg(deviceUID),
|
|
|
|
sdrDaemonSSD0->m_sourceId,
|
|
|
|
sdrDaemonSSD0->m_sourceSerial,
|
|
|
|
deviceUID
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2016-06-19 23:58:46 +00:00
|
|
|
if (sdrDaemonFECSSD0 && duplicateSDRDaemonFEC) // append item for a new instance
|
|
|
|
{
|
|
|
|
m_sampleSourceDevices.append(
|
|
|
|
SampleSourceDevice(
|
|
|
|
sdrDaemonFECSSD0->m_plugin,
|
|
|
|
QString("SDRdaemonFEC[%1]").arg(deviceUID),
|
|
|
|
sdrDaemonFECSSD0->m_sourceId,
|
|
|
|
sdrDaemonFECSSD0->m_sourceSerial,
|
|
|
|
deviceUID
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2016-05-22 22:21:13 +00:00
|
|
|
if (fileSourceSSD0 && duplicateFileSource) // append item for a new instance
|
|
|
|
{
|
|
|
|
m_sampleSourceDevices.append(
|
|
|
|
SampleSourceDevice(
|
|
|
|
fileSourceSSD0->m_plugin,
|
|
|
|
QString("FileSource[%1]").arg(deviceUID),
|
|
|
|
fileSourceSSD0->m_sourceId,
|
|
|
|
fileSourceSSD0->m_sourceSerial,
|
|
|
|
deviceUID
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-22 19:56:07 +00:00
|
|
|
void PluginManager::fillSampleSourceSelector(QComboBox* comboBox, uint deviceUID)
|
2014-05-18 15:52:39 +00:00
|
|
|
{
|
|
|
|
comboBox->clear();
|
2015-10-02 12:21:56 +00:00
|
|
|
|
|
|
|
for(int i = 0; i < m_sampleSourceDevices.count(); i++)
|
|
|
|
{
|
2016-05-22 22:21:13 +00:00
|
|
|
// For "local" devices show only ones that concern this device set
|
2016-06-19 23:58:46 +00:00
|
|
|
if ((m_sampleSourceDevices[i].m_sourceId == m_sdrDaemonDeviceTypeID)
|
|
|
|
|| (m_sampleSourceDevices[i].m_sourceId == m_sdrDaemonFECDeviceTypeID)
|
|
|
|
|| (m_sampleSourceDevices[i].m_sourceId == m_fileSourceDeviceTypeID))
|
2016-05-22 19:56:07 +00:00
|
|
|
{
|
2016-05-22 22:21:13 +00:00
|
|
|
if (deviceUID != m_sampleSourceDevices[i].m_sourceSequence) {
|
2016-05-22 19:56:07 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-22 22:21:13 +00:00
|
|
|
comboBox->addItem(m_sampleSourceDevices[i].m_displayName, qVariantFromValue((void *) &m_sampleSourceDevices[i]));
|
2015-10-02 12:21:56 +00:00
|
|
|
}
|
2014-05-18 15:52:39 +00:00
|
|
|
}
|
|
|
|
|
2016-05-15 23:12:37 +00:00
|
|
|
int PluginManager::selectSampleSourceByIndex(int index, DeviceAPI *deviceAPI)
|
2014-05-18 15:52:39 +00:00
|
|
|
{
|
2015-10-02 12:19:28 +00:00
|
|
|
qDebug("PluginManager::selectSampleSourceByIndex: index: %d", index);
|
2015-06-07 01:30:28 +00:00
|
|
|
|
2015-10-02 12:19:28 +00:00
|
|
|
if (m_sampleSourceDevices.count() == 0)
|
2015-09-30 04:57:40 +00:00
|
|
|
{
|
2015-10-02 12:19:28 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2015-09-30 04:57:40 +00:00
|
|
|
|
2015-10-02 12:19:28 +00:00
|
|
|
if (index < 0)
|
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (index >= m_sampleSourceDevices.count())
|
|
|
|
{
|
|
|
|
index = 0;
|
2014-05-18 15:52:39 +00:00
|
|
|
}
|
2015-09-30 04:57:40 +00:00
|
|
|
|
2016-05-17 09:06:56 +00:00
|
|
|
qDebug() << "PluginManager::selectSampleSourceByIndex: m_sampleSource at index " << index
|
|
|
|
<< " id: " << m_sampleSourceDevices[index].m_sourceId.toStdString().c_str()
|
|
|
|
<< " ser: " << m_sampleSourceDevices[index].m_sourceSerial.toStdString().c_str()
|
|
|
|
<< " seq: " << m_sampleSourceDevices[index].m_sourceSequence;
|
|
|
|
|
|
|
|
deviceAPI->stopAcquisition();
|
|
|
|
deviceAPI->setSampleSourcePluginGUI(0); // this effectively destroys the previous GUI if it exists
|
2015-09-30 04:57:40 +00:00
|
|
|
|
2016-05-17 01:41:01 +00:00
|
|
|
QWidget *gui;
|
2016-05-17 09:06:56 +00:00
|
|
|
PluginGUI *pluginGUI = m_sampleSourceDevices[index].m_plugin->createSampleSourcePluginGUI(m_sampleSourceDevices[index].m_sourceId, &gui, deviceAPI);
|
|
|
|
|
|
|
|
// m_sampleSourcePluginGUI = pluginGUI;
|
2016-05-16 15:47:22 +00:00
|
|
|
deviceAPI->setSampleSourceSequence(m_sampleSourceDevices[index].m_sourceSequence);
|
|
|
|
deviceAPI->setSampleSourceId(m_sampleSourceDevices[index].m_sourceId);
|
|
|
|
deviceAPI->setSampleSourceSerial(m_sampleSourceDevices[index].m_sourceSerial);
|
|
|
|
deviceAPI->setSampleSourcePluginGUI(pluginGUI);
|
2016-05-17 01:41:01 +00:00
|
|
|
deviceAPI->setInputGUI(gui, m_sampleSourceDevices[index].m_displayName);
|
2014-05-18 15:52:39 +00:00
|
|
|
|
|
|
|
return index;
|
|
|
|
}
|
|
|
|
|
2016-05-15 23:12:37 +00:00
|
|
|
int PluginManager::selectFirstSampleSource(const QString& sourceId, DeviceAPI *deviceAPI)
|
2014-05-18 15:52:39 +00:00
|
|
|
{
|
2015-10-01 14:57:33 +00:00
|
|
|
qDebug("PluginManager::selectFirstSampleSource by id: [%s]", qPrintable(sourceId));
|
2015-06-07 01:30:28 +00:00
|
|
|
|
2014-05-18 15:52:39 +00:00
|
|
|
int index = -1;
|
|
|
|
|
2015-10-01 14:57:33 +00:00
|
|
|
for (int i = 0; i < m_sampleSourceDevices.count(); i++)
|
2015-09-30 04:57:40 +00:00
|
|
|
{
|
|
|
|
qDebug("*** %s vs %s", qPrintable(m_sampleSourceDevices[i].m_sourceId), qPrintable(sourceId));
|
|
|
|
|
|
|
|
if(m_sampleSourceDevices[i].m_sourceId == sourceId)
|
|
|
|
{
|
2014-05-18 15:52:39 +00:00
|
|
|
index = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2015-09-30 04:57:40 +00:00
|
|
|
|
|
|
|
if(index == -1)
|
|
|
|
{
|
2014-05-18 15:52:39 +00:00
|
|
|
if(m_sampleSourceDevices.count() > 0)
|
2015-09-30 04:57:40 +00:00
|
|
|
{
|
2014-05-18 15:52:39 +00:00
|
|
|
index = 0;
|
2015-09-30 04:57:40 +00:00
|
|
|
}
|
2015-10-01 14:57:33 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
2015-09-30 04:57:40 +00:00
|
|
|
}
|
|
|
|
|
2016-05-17 09:06:56 +00:00
|
|
|
qDebug() << "PluginManager::selectFirstSampleSource: m_sampleSource at index " << index
|
|
|
|
<< " id: " << m_sampleSourceDevices[index].m_sourceId.toStdString().c_str()
|
|
|
|
<< " ser: " << m_sampleSourceDevices[index].m_sourceSerial.toStdString().c_str()
|
|
|
|
<< " seq: " << m_sampleSourceDevices[index].m_sourceSequence;
|
2015-09-30 04:57:40 +00:00
|
|
|
|
2016-05-17 09:06:56 +00:00
|
|
|
deviceAPI->stopAcquisition();
|
|
|
|
deviceAPI->setSampleSourcePluginGUI(0); // this effectively destroys the previous GUI if it exists
|
|
|
|
|
|
|
|
QWidget *gui;
|
|
|
|
PluginGUI *pluginGUI = m_sampleSourceDevices[index].m_plugin->createSampleSourcePluginGUI(m_sampleSourceDevices[index].m_sourceId, &gui, deviceAPI);
|
|
|
|
|
|
|
|
// m_sampleSourcePluginGUI = pluginGUI;
|
2016-05-16 15:47:22 +00:00
|
|
|
deviceAPI->setSampleSourceSequence(m_sampleSourceDevices[index].m_sourceSequence);
|
|
|
|
deviceAPI->setSampleSourceId(m_sampleSourceDevices[index].m_sourceId);
|
|
|
|
deviceAPI->setSampleSourceSerial(m_sampleSourceDevices[index].m_sourceSerial);
|
|
|
|
deviceAPI->setSampleSourcePluginGUI(pluginGUI);
|
2016-05-17 01:41:01 +00:00
|
|
|
deviceAPI->setInputGUI(gui, m_sampleSourceDevices[index].m_displayName);
|
2014-05-18 15:52:39 +00:00
|
|
|
|
|
|
|
return index;
|
|
|
|
}
|
|
|
|
|
2016-05-15 23:12:37 +00:00
|
|
|
int PluginManager::selectSampleSourceBySerialOrSequence(const QString& sourceId, const QString& sourceSerial, int sourceSequence, DeviceAPI *deviceAPI)
|
2015-10-01 14:57:33 +00:00
|
|
|
{
|
|
|
|
qDebug("PluginManager::selectSampleSourceBySequence by sequence: id: %s ser: %s seq: %d", qPrintable(sourceId), qPrintable(sourceSerial), sourceSequence);
|
|
|
|
|
|
|
|
int index = -1;
|
|
|
|
int index_matchingSequence = -1;
|
|
|
|
int index_firstOfKind = -1;
|
|
|
|
|
|
|
|
for (int i = 0; i < m_sampleSourceDevices.count(); i++)
|
|
|
|
{
|
|
|
|
if (m_sampleSourceDevices[i].m_sourceId == sourceId)
|
|
|
|
{
|
|
|
|
index_firstOfKind = i;
|
|
|
|
|
|
|
|
if (m_sampleSourceDevices[i].m_sourceSerial == sourceSerial)
|
|
|
|
{
|
|
|
|
index = i; // exact match
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_sampleSourceDevices[i].m_sourceSequence == sourceSequence)
|
|
|
|
{
|
|
|
|
index_matchingSequence = i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(index == -1) // no exact match
|
|
|
|
{
|
|
|
|
if (index_matchingSequence == -1) // no matching sequence
|
|
|
|
{
|
|
|
|
if (index_firstOfKind == -1) // no matching device type
|
|
|
|
{
|
|
|
|
if(m_sampleSourceDevices.count() > 0) // take first if any
|
|
|
|
{
|
|
|
|
index = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return -1; // return if no device attached
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
index = index_firstOfKind; // take first that matches device type
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
index = index_matchingSequence; // take the one that matches the sequence in the device type
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-17 09:06:56 +00:00
|
|
|
qDebug() << "PluginManager::selectSampleSourceBySequence: m_sampleSource at index " << index
|
|
|
|
<< " id: " << m_sampleSourceDevices[index].m_sourceId.toStdString().c_str()
|
|
|
|
<< " ser: " << m_sampleSourceDevices[index].m_sourceSerial.toStdString().c_str()
|
|
|
|
<< " seq: " << m_sampleSourceDevices[index].m_sourceSequence;
|
2015-10-01 14:57:33 +00:00
|
|
|
|
2016-05-17 09:06:56 +00:00
|
|
|
deviceAPI->stopAcquisition();
|
|
|
|
deviceAPI->setSampleSourcePluginGUI(0); // this effectively destroys the previous GUI if it exists
|
|
|
|
|
|
|
|
QWidget *gui;
|
|
|
|
PluginGUI *pluginGUI = m_sampleSourceDevices[index].m_plugin->createSampleSourcePluginGUI(m_sampleSourceDevices[index].m_sourceId, &gui, deviceAPI);
|
|
|
|
|
|
|
|
// m_sampleSourcePluginGUI = pluginGUI;
|
2016-05-16 15:47:22 +00:00
|
|
|
deviceAPI->setSampleSourceSequence(m_sampleSourceDevices[index].m_sourceSequence);
|
|
|
|
deviceAPI->setSampleSourceId(m_sampleSourceDevices[index].m_sourceId);
|
|
|
|
deviceAPI->setSampleSourceSerial(m_sampleSourceDevices[index].m_sourceSerial);
|
|
|
|
deviceAPI->setSampleSourcePluginGUI(pluginGUI);
|
2016-05-17 01:41:01 +00:00
|
|
|
deviceAPI->setInputGUI(gui, m_sampleSourceDevices[index].m_displayName);
|
2015-10-01 14:57:33 +00:00
|
|
|
|
|
|
|
return index;
|
|
|
|
}
|
|
|
|
|
2016-05-22 22:21:13 +00:00
|
|
|
void PluginManager::selectSampleSourceByDevice(void *devicePtr, DeviceAPI *deviceAPI)
|
|
|
|
{
|
|
|
|
SampleSourceDevice *sampleSourceDevice = (SampleSourceDevice *) devicePtr;
|
|
|
|
|
|
|
|
qDebug() << "PluginManager::selectSampleSourceByDevice: "
|
|
|
|
<< " id: " << sampleSourceDevice->m_sourceId.toStdString().c_str()
|
|
|
|
<< " ser: " << sampleSourceDevice->m_sourceSerial.toStdString().c_str()
|
|
|
|
<< " seq: " << sampleSourceDevice->m_sourceSequence;
|
|
|
|
|
|
|
|
deviceAPI->stopAcquisition();
|
|
|
|
deviceAPI->setSampleSourcePluginGUI(0); // this effectively destroys the previous GUI if it exists
|
|
|
|
|
|
|
|
QWidget *gui;
|
|
|
|
PluginGUI *pluginGUI = sampleSourceDevice->m_plugin->createSampleSourcePluginGUI(sampleSourceDevice->m_sourceId, &gui, deviceAPI);
|
|
|
|
|
|
|
|
// m_sampleSourcePluginGUI = pluginGUI;
|
|
|
|
deviceAPI->setSampleSourceSequence(sampleSourceDevice->m_sourceSequence);
|
|
|
|
deviceAPI->setSampleSourceId(sampleSourceDevice->m_sourceId);
|
|
|
|
deviceAPI->setSampleSourceSerial(sampleSourceDevice->m_sourceSerial);
|
|
|
|
deviceAPI->setSampleSourcePluginGUI(pluginGUI);
|
|
|
|
deviceAPI->setInputGUI(gui, sampleSourceDevice->m_displayName);
|
|
|
|
}
|
|
|
|
|
2014-05-18 15:52:39 +00:00
|
|
|
void PluginManager::loadPlugins(const QDir& dir)
|
|
|
|
{
|
|
|
|
QDir pluginsDir(dir);
|
2015-08-09 02:09:05 +00:00
|
|
|
|
|
|
|
foreach (QString fileName, pluginsDir.entryList(QDir::Files))
|
|
|
|
{
|
2016-06-28 08:20:47 +00:00
|
|
|
if (fileName.endsWith(".so") || fileName.endsWith(".dll") || fileName.endsWith(".dylib"))
|
2015-08-26 00:03:20 +00:00
|
|
|
{
|
|
|
|
qDebug() << "PluginManager::loadPlugins: fileName: " << qPrintable(fileName);
|
2015-08-09 02:09:05 +00:00
|
|
|
|
2015-08-26 00:03:20 +00:00
|
|
|
QPluginLoader* loader = new QPluginLoader(pluginsDir.absoluteFilePath(fileName));
|
|
|
|
PluginInterface* plugin = qobject_cast<PluginInterface*>(loader->instance());
|
2015-08-09 02:09:05 +00:00
|
|
|
|
2015-08-26 00:03:20 +00:00
|
|
|
if (loader->isLoaded())
|
|
|
|
{
|
|
|
|
qWarning("PluginManager::loadPlugins: loaded plugin %s", qPrintable(fileName));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
qWarning() << "PluginManager::loadPlugins: " << qPrintable(loader->errorString());
|
|
|
|
}
|
|
|
|
|
|
|
|
if (plugin != 0)
|
|
|
|
{
|
|
|
|
m_plugins.append(Plugin(fileName, loader, plugin));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
loader->unload();
|
|
|
|
}
|
2015-08-29 01:09:44 +00:00
|
|
|
|
|
|
|
delete loader; // Valgrind memcheck
|
2014-05-18 15:52:39 +00:00
|
|
|
}
|
|
|
|
}
|
2015-08-09 02:09:05 +00:00
|
|
|
|
2015-08-26 00:03:20 +00:00
|
|
|
// recursive calls on subdirectories
|
|
|
|
|
|
|
|
foreach (QString dirName, pluginsDir.entryList(QDir::Dirs | QDir::NoDotAndDotDot))
|
|
|
|
{
|
2014-05-18 15:52:39 +00:00
|
|
|
loadPlugins(pluginsDir.absoluteFilePath(dirName));
|
2015-08-09 02:09:05 +00:00
|
|
|
}
|
2014-05-18 15:52:39 +00:00
|
|
|
}
|
|
|
|
|
2016-05-14 16:12:39 +00:00
|
|
|
void PluginManager::populateChannelComboBox(QComboBox *channels)
|
|
|
|
{
|
2016-05-16 16:34:23 +00:00
|
|
|
for(PluginAPI::ChannelRegistrations::iterator it = m_channelRegistrations.begin(); it != m_channelRegistrations.end(); ++it)
|
2016-05-14 16:12:39 +00:00
|
|
|
{
|
|
|
|
const PluginDescriptor& pluginDescipror = it->m_plugin->getPluginDescriptor();
|
|
|
|
channels->addItem(pluginDescipror.displayedName);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-16 01:21:21 +00:00
|
|
|
void PluginManager::createChannelInstance(int channelPluginIndex, DeviceAPI *deviceAPI)
|
2016-05-14 16:12:39 +00:00
|
|
|
{
|
|
|
|
if (channelPluginIndex < m_channelRegistrations.size())
|
|
|
|
{
|
|
|
|
PluginInterface *pluginInterface = m_channelRegistrations[channelPluginIndex].m_plugin;
|
2016-05-16 01:21:21 +00:00
|
|
|
pluginInterface->createChannel(m_channelRegistrations[channelPluginIndex].m_channelName, deviceAPI);
|
2016-05-14 16:12:39 +00:00
|
|
|
}
|
|
|
|
}
|