mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-12-17 23:28:50 -05:00
Multi device support: load and save source presets moved to device API
This commit is contained in:
parent
bb8c3a305f
commit
9e77782da9
@ -19,6 +19,7 @@
|
|||||||
#include "gui/glspectrum.h"
|
#include "gui/glspectrum.h"
|
||||||
#include "gui/channelwindow.h"
|
#include "gui/channelwindow.h"
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
|
#include "settings/preset.h"
|
||||||
|
|
||||||
DeviceAPI::DeviceAPI(MainWindow *mainWindow,
|
DeviceAPI::DeviceAPI(MainWindow *mainWindow,
|
||||||
int deviceTabIndex,
|
int deviceTabIndex,
|
||||||
@ -109,11 +110,6 @@ void DeviceAPI::configureCorrections(bool dcOffsetCorrection, bool iqImbalanceCo
|
|||||||
m_deviceEngine->configureCorrections(dcOffsetCorrection, iqImbalanceCorrection);
|
m_deviceEngine->configureCorrections(dcOffsetCorrection, iqImbalanceCorrection);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeviceAPI::setSourceSequence(int sourceSequence)
|
|
||||||
{
|
|
||||||
m_deviceEngine->setSourceSequence(sourceSequence);
|
|
||||||
}
|
|
||||||
|
|
||||||
GLSpectrum *DeviceAPI::getSpectrum()
|
GLSpectrum *DeviceAPI::getSpectrum()
|
||||||
{
|
{
|
||||||
return m_spectrum;
|
return m_spectrum;
|
||||||
@ -152,6 +148,7 @@ void DeviceAPI::setSampleSourceSerial(const QString& serial)
|
|||||||
void DeviceAPI::setSampleSourceSequence(int sequence)
|
void DeviceAPI::setSampleSourceSequence(int sequence)
|
||||||
{
|
{
|
||||||
m_sampleSourceSequence = sequence;
|
m_sampleSourceSequence = sequence;
|
||||||
|
m_deviceEngine->setSourceSequence(sequence);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeviceAPI::setSampleSourcePluginGUI(PluginGUI *gui)
|
void DeviceAPI::setSampleSourcePluginGUI(PluginGUI *gui)
|
||||||
@ -171,3 +168,53 @@ void DeviceAPI::freeAll()
|
|||||||
m_sampleSourceId.clear();
|
m_sampleSourceId.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DeviceAPI::loadSourceSettings(const Preset* preset)
|
||||||
|
{
|
||||||
|
qDebug("DeviceAPI::loadSourceSettings: Loading preset [%s | %s]\n", qPrintable(preset->getGroup()), qPrintable(preset->getDescription()));
|
||||||
|
|
||||||
|
if(m_sampleSourcePluginGUI != 0)
|
||||||
|
{
|
||||||
|
const QByteArray* sourceConfig = preset->findBestSourceConfig(m_sampleSourceId, m_sampleSourceSerial, m_sampleSourceSequence);
|
||||||
|
|
||||||
|
if (sourceConfig != 0)
|
||||||
|
{
|
||||||
|
qDebug() << "DeviceAPI::loadSettings: deserializing source " << qPrintable(m_sampleSourceId);
|
||||||
|
m_sampleSourcePluginGUI->deserialize(*sourceConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
qint64 centerFrequency = preset->getCenterFrequency();
|
||||||
|
m_sampleSourcePluginGUI->setCenterFrequency(centerFrequency);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DeviceAPI::saveSourceSettings(Preset* preset)
|
||||||
|
{
|
||||||
|
qDebug("DeviceAPI::saveSourceSettings");
|
||||||
|
|
||||||
|
if(m_sampleSourcePluginGUI != NULL)
|
||||||
|
{
|
||||||
|
preset->addOrUpdateSourceConfig(m_sampleSourceId, m_sampleSourceSerial, m_sampleSourceSequence, m_sampleSourcePluginGUI->serialize());
|
||||||
|
preset->setCenterFrequency(m_sampleSourcePluginGUI->getCenterFrequency());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// sort by increasing delta frequency and type (i.e. name)
|
||||||
|
bool DeviceAPI::ChannelInstanceRegistration::operator<(const ChannelInstanceRegistration& other) const
|
||||||
|
{
|
||||||
|
if (m_gui && other.m_gui)
|
||||||
|
{
|
||||||
|
if (m_gui->getCenterFrequency() == other.m_gui->getCenterFrequency())
|
||||||
|
{
|
||||||
|
return m_gui->getName() < other.m_gui->getName();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return m_gui->getCenterFrequency() < other.m_gui->getCenterFrequency();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -35,6 +35,7 @@ class MessageQueue;
|
|||||||
class ChannelMarker;
|
class ChannelMarker;
|
||||||
class QWidget;
|
class QWidget;
|
||||||
class PluginGUI;
|
class PluginGUI;
|
||||||
|
class Preset;
|
||||||
|
|
||||||
class SDRANGEL_API DeviceAPI : public QObject {
|
class SDRANGEL_API DeviceAPI : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -56,8 +57,6 @@ public:
|
|||||||
MessageQueue *getDeviceOutputMessageQueue();
|
MessageQueue *getDeviceOutputMessageQueue();
|
||||||
void configureCorrections(bool dcOffsetCorrection, bool iqImbalanceCorrection); //!< Configure current device engine DSP corrections
|
void configureCorrections(bool dcOffsetCorrection, bool iqImbalanceCorrection); //!< Configure current device engine DSP corrections
|
||||||
|
|
||||||
void setSourceSequence(int sourceSequence);
|
|
||||||
|
|
||||||
// device related stuff
|
// device related stuff
|
||||||
GLSpectrum *getSpectrum(); //!< Direct spectrum getter
|
GLSpectrum *getSpectrum(); //!< Direct spectrum getter
|
||||||
void addChannelMarker(ChannelMarker* channelMarker); //!< Add channel marker to spectrum
|
void addChannelMarker(ChannelMarker* channelMarker); //!< Add channel marker to spectrum
|
||||||
@ -72,7 +71,30 @@ public:
|
|||||||
|
|
||||||
void freeAll();
|
void freeAll();
|
||||||
|
|
||||||
|
void loadSourceSettings(const Preset* preset);
|
||||||
|
void saveSourceSettings(Preset* preset);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
struct ChannelInstanceRegistration
|
||||||
|
{
|
||||||
|
QString m_channelName;
|
||||||
|
PluginGUI* m_gui;
|
||||||
|
|
||||||
|
ChannelInstanceRegistration() :
|
||||||
|
m_channelName(),
|
||||||
|
m_gui(NULL)
|
||||||
|
{ }
|
||||||
|
|
||||||
|
ChannelInstanceRegistration(const QString& channelName, PluginGUI* pluginGUI) :
|
||||||
|
m_channelName(channelName),
|
||||||
|
m_gui(pluginGUI)
|
||||||
|
{ }
|
||||||
|
|
||||||
|
bool operator<(const ChannelInstanceRegistration& other) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef QList<ChannelInstanceRegistration> ChannelInstanceRegistrations;
|
||||||
|
|
||||||
DeviceAPI(MainWindow *mainWindow,
|
DeviceAPI(MainWindow *mainWindow,
|
||||||
int deviceTabIndex,
|
int deviceTabIndex,
|
||||||
DSPDeviceEngine *deviceEngine,
|
DSPDeviceEngine *deviceEngine,
|
||||||
@ -91,6 +113,8 @@ protected:
|
|||||||
int m_sampleSourceSequence;
|
int m_sampleSourceSequence;
|
||||||
PluginGUI* m_sampleSourcePluginGUI;
|
PluginGUI* m_sampleSourcePluginGUI;
|
||||||
|
|
||||||
|
ChannelInstanceRegistrations m_channelInstanceRegistrations;
|
||||||
|
|
||||||
friend class MainWindow;
|
friend class MainWindow;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -317,6 +317,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_deviceAPI);
|
deviceUI->m_pluginManager->loadSettings(preset, deviceUI->m_deviceAPI);
|
||||||
|
deviceUI->m_deviceAPI->loadSourceSettings(preset);
|
||||||
}
|
}
|
||||||
|
|
||||||
// has to be last step
|
// has to be last step
|
||||||
@ -344,6 +345,7 @@ void MainWindow::savePresetSettings(Preset* preset)
|
|||||||
preset->setSpectrumConfig(deviceUI->m_spectrumGUI->serialize());
|
preset->setSpectrumConfig(deviceUI->m_spectrumGUI->serialize());
|
||||||
preset->clearChannels();
|
preset->clearChannels();
|
||||||
deviceUI->m_pluginManager->saveSettings(preset);
|
deviceUI->m_pluginManager->saveSettings(preset);
|
||||||
|
deviceUI->m_deviceAPI->saveSourceSettings(preset);
|
||||||
|
|
||||||
preset->setLayout(saveState());
|
preset->setLayout(saveState());
|
||||||
}
|
}
|
||||||
@ -673,11 +675,13 @@ void MainWindow::on_sampleSource_currentIndexChanged(int index)
|
|||||||
if (currentSourceTabIndex >= 0)
|
if (currentSourceTabIndex >= 0)
|
||||||
{
|
{
|
||||||
DeviceUISet *deviceUI = m_deviceUIs[currentSourceTabIndex];
|
DeviceUISet *deviceUI = m_deviceUIs[currentSourceTabIndex];
|
||||||
deviceUI->m_pluginManager->saveSourceSettings(m_settings.getWorkingPreset());
|
deviceUI->m_deviceAPI->saveSourceSettings(m_settings.getWorkingPreset());
|
||||||
|
//deviceUI->m_pluginManager->saveSourceSettings(m_settings.getWorkingPreset());
|
||||||
deviceUI->m_pluginManager->selectSampleSourceByIndex(deviceUI->m_samplingDeviceControl->getDeviceSelector()->currentIndex(), deviceUI->m_deviceAPI);
|
deviceUI->m_pluginManager->selectSampleSourceByIndex(deviceUI->m_samplingDeviceControl->getDeviceSelector()->currentIndex(), deviceUI->m_deviceAPI);
|
||||||
m_settings.setSourceIndex(deviceUI->m_samplingDeviceControl->getDeviceSelector()->currentIndex());
|
m_settings.setSourceIndex(deviceUI->m_samplingDeviceControl->getDeviceSelector()->currentIndex());
|
||||||
|
|
||||||
deviceUI->m_pluginManager->loadSourceSettings(m_settings.getWorkingPreset());
|
//deviceUI->m_pluginManager->loadSourceSettings(m_settings.getWorkingPreset());
|
||||||
|
deviceUI->m_deviceAPI->loadSourceSettings(m_settings.getWorkingPreset());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,27 +144,27 @@ void PluginManager::loadSettings(const Preset* preset, DeviceAPI *deviceAPI)
|
|||||||
|
|
||||||
renameChannelInstances();
|
renameChannelInstances();
|
||||||
|
|
||||||
loadSourceSettings(preset);
|
// loadSourceSettings(preset); // FIXME
|
||||||
}
|
}
|
||||||
|
|
||||||
void PluginManager::loadSourceSettings(const Preset* preset)
|
//void PluginManager::loadSourceSettings(const Preset* preset)
|
||||||
{
|
//{
|
||||||
fprintf(stderr, "PluginManager::loadSourceSettings: Loading preset [%s | %s]\n", qPrintable(preset->getGroup()), qPrintable(preset->getDescription()));
|
// fprintf(stderr, "PluginManager::loadSourceSettings: Loading preset [%s | %s]\n", qPrintable(preset->getGroup()), qPrintable(preset->getDescription()));
|
||||||
|
//
|
||||||
if(m_sampleSourcePluginGUI != 0)
|
// if(m_sampleSourcePluginGUI != 0)
|
||||||
{
|
// {
|
||||||
const QByteArray* sourceConfig = preset->findBestSourceConfig(m_sampleSourceId, m_sampleSourceSerial, m_sampleSourceSequence);
|
// const QByteArray* sourceConfig = preset->findBestSourceConfig(m_sampleSourceId, m_sampleSourceSerial, m_sampleSourceSequence);
|
||||||
|
//
|
||||||
if (sourceConfig != 0)
|
// if (sourceConfig != 0)
|
||||||
{
|
// {
|
||||||
qDebug() << "PluginManager::loadSettings: deserializing source " << qPrintable(m_sampleSourceId);
|
// qDebug() << "PluginManager::loadSettings: deserializing source " << qPrintable(m_sampleSourceId);
|
||||||
m_sampleSourcePluginGUI->deserialize(*sourceConfig);
|
// m_sampleSourcePluginGUI->deserialize(*sourceConfig);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
qint64 centerFrequency = preset->getCenterFrequency();
|
// qint64 centerFrequency = preset->getCenterFrequency();
|
||||||
m_sampleSourcePluginGUI->setCenterFrequency(centerFrequency);
|
// m_sampleSourcePluginGUI->setCenterFrequency(centerFrequency);
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
||||||
// sort by increasing delta frequency and type (i.e. name)
|
// sort by increasing delta frequency and type (i.e. name)
|
||||||
bool PluginManager::ChannelInstanceRegistration::operator<(const ChannelInstanceRegistration& other) const {
|
bool PluginManager::ChannelInstanceRegistration::operator<(const ChannelInstanceRegistration& other) const {
|
||||||
@ -182,7 +182,7 @@ bool PluginManager::ChannelInstanceRegistration::operator<(const ChannelInstance
|
|||||||
void PluginManager::saveSettings(Preset* preset)
|
void PluginManager::saveSettings(Preset* preset)
|
||||||
{
|
{
|
||||||
qDebug("PluginManager::saveSettings");
|
qDebug("PluginManager::saveSettings");
|
||||||
saveSourceSettings(preset);
|
// saveSourceSettings(preset); // FIXME
|
||||||
|
|
||||||
qSort(m_channelInstanceRegistrations.begin(), m_channelInstanceRegistrations.end()); // sort by increasing delta frequency and type
|
qSort(m_channelInstanceRegistrations.begin(), m_channelInstanceRegistrations.end()); // sort by increasing delta frequency and type
|
||||||
|
|
||||||
@ -192,17 +192,17 @@ void PluginManager::saveSettings(Preset* preset)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PluginManager::saveSourceSettings(Preset* preset)
|
//void PluginManager::saveSourceSettings(Preset* preset)
|
||||||
{
|
//{
|
||||||
qDebug("PluginManager::saveSourceSettings");
|
// qDebug("PluginManager::saveSourceSettings");
|
||||||
|
//
|
||||||
if(m_sampleSourcePluginGUI != NULL)
|
// if(m_sampleSourcePluginGUI != NULL)
|
||||||
{
|
// {
|
||||||
preset->addOrUpdateSourceConfig(m_sampleSourceId, m_sampleSourceSerial, m_sampleSourceSequence, m_sampleSourcePluginGUI->serialize());
|
// preset->addOrUpdateSourceConfig(m_sampleSourceId, m_sampleSourceSerial, m_sampleSourceSequence, m_sampleSourcePluginGUI->serialize());
|
||||||
//preset->setSourceConfig(m_sampleSourceId, m_sampleSourceSerial, m_sampleSourceSequence, m_sampleSourcePluginGUI->serialize());
|
// //preset->setSourceConfig(m_sampleSourceId, m_sampleSourceSerial, m_sampleSourceSequence, m_sampleSourcePluginGUI->serialize());
|
||||||
preset->setCenterFrequency(m_sampleSourcePluginGUI->getCenterFrequency());
|
// preset->setCenterFrequency(m_sampleSourcePluginGUI->getCenterFrequency());
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
||||||
void PluginManager::freeAll()
|
void PluginManager::freeAll()
|
||||||
{
|
{
|
||||||
@ -317,7 +317,10 @@ int PluginManager::selectSampleSourceByIndex(int index, DeviceAPI *deviceAPI)
|
|||||||
|
|
||||||
PluginGUI *pluginGUI = m_sampleSourceDevices[index].m_plugin->createSampleSourcePluginGUI(m_sampleSourceId, m_sampleSourceDevices[index].m_displayName, deviceAPI);
|
PluginGUI *pluginGUI = m_sampleSourceDevices[index].m_plugin->createSampleSourcePluginGUI(m_sampleSourceId, m_sampleSourceDevices[index].m_displayName, deviceAPI);
|
||||||
m_sampleSourcePluginGUI = pluginGUI;
|
m_sampleSourcePluginGUI = pluginGUI;
|
||||||
deviceAPI->setSourceSequence(m_sampleSourceSequence);
|
deviceAPI->setSampleSourceSequence(m_sampleSourceDevices[index].m_sourceSequence);
|
||||||
|
deviceAPI->setSampleSourceId(m_sampleSourceDevices[index].m_sourceId);
|
||||||
|
deviceAPI->setSampleSourceSerial(m_sampleSourceDevices[index].m_sourceSerial);
|
||||||
|
deviceAPI->setSampleSourcePluginGUI(pluginGUI);
|
||||||
|
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
@ -372,7 +375,10 @@ int PluginManager::selectFirstSampleSource(const QString& sourceId, DeviceAPI *d
|
|||||||
|
|
||||||
PluginGUI *pluginGUI = m_sampleSourceDevices[index].m_plugin->createSampleSourcePluginGUI(m_sampleSourceId, m_sampleSourceDevices[index].m_displayName, deviceAPI);
|
PluginGUI *pluginGUI = m_sampleSourceDevices[index].m_plugin->createSampleSourcePluginGUI(m_sampleSourceId, m_sampleSourceDevices[index].m_displayName, deviceAPI);
|
||||||
m_sampleSourcePluginGUI = pluginGUI;
|
m_sampleSourcePluginGUI = pluginGUI;
|
||||||
deviceAPI->setSourceSequence(m_sampleSourceSequence);
|
deviceAPI->setSampleSourceSequence(m_sampleSourceDevices[index].m_sourceSequence);
|
||||||
|
deviceAPI->setSampleSourceId(m_sampleSourceDevices[index].m_sourceId);
|
||||||
|
deviceAPI->setSampleSourceSerial(m_sampleSourceDevices[index].m_sourceSerial);
|
||||||
|
deviceAPI->setSampleSourcePluginGUI(pluginGUI);
|
||||||
|
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
@ -441,7 +447,10 @@ int PluginManager::selectSampleSourceBySerialOrSequence(const QString& sourceId,
|
|||||||
|
|
||||||
PluginGUI *pluginGUI = m_sampleSourceDevices[index].m_plugin->createSampleSourcePluginGUI(m_sampleSourceId, m_sampleSourceDevices[index].m_displayName, deviceAPI);
|
PluginGUI *pluginGUI = m_sampleSourceDevices[index].m_plugin->createSampleSourcePluginGUI(m_sampleSourceId, m_sampleSourceDevices[index].m_displayName, deviceAPI);
|
||||||
m_sampleSourcePluginGUI = pluginGUI;
|
m_sampleSourcePluginGUI = pluginGUI;
|
||||||
deviceAPI->setSourceSequence(m_sampleSourceSequence);
|
deviceAPI->setSampleSourceSequence(m_sampleSourceDevices[index].m_sourceSequence);
|
||||||
|
deviceAPI->setSampleSourceId(m_sampleSourceDevices[index].m_sourceId);
|
||||||
|
deviceAPI->setSampleSourceSerial(m_sampleSourceDevices[index].m_sourceSerial);
|
||||||
|
deviceAPI->setSampleSourcePluginGUI(pluginGUI);
|
||||||
|
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
|
@ -48,9 +48,9 @@ public:
|
|||||||
void registerSampleSource(const QString& sourceName, PluginInterface* plugin);
|
void registerSampleSource(const QString& sourceName, PluginInterface* plugin);
|
||||||
|
|
||||||
void loadSettings(const Preset* preset, DeviceAPI *deviceAPI);
|
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);
|
||||||
|
|
||||||
void freeAll();
|
void freeAll();
|
||||||
|
|
||||||
@ -129,10 +129,10 @@ private:
|
|||||||
DSPDeviceEngine* m_dspDeviceEngine;
|
DSPDeviceEngine* m_dspDeviceEngine;
|
||||||
Plugins m_plugins;
|
Plugins m_plugins;
|
||||||
|
|
||||||
ChannelRegistrations m_channelRegistrations;
|
ChannelRegistrations m_channelRegistrations; //!< Channel plugins register here
|
||||||
ChannelInstanceRegistrations m_channelInstanceRegistrations;
|
ChannelInstanceRegistrations m_channelInstanceRegistrations; // TODO: remove
|
||||||
SampleSourceRegistrations m_sampleSourceRegistrations;
|
SampleSourceRegistrations m_sampleSourceRegistrations; //!< Input source plugins (one per device kind) register here
|
||||||
SampleSourceDevices m_sampleSourceDevices;
|
SampleSourceDevices m_sampleSourceDevices; //!< Instances of input sources present in the system
|
||||||
|
|
||||||
QString m_sampleSourceId;
|
QString m_sampleSourceId;
|
||||||
QString m_sampleSourceSerial;
|
QString m_sampleSourceSerial;
|
||||||
|
Loading…
Reference in New Issue
Block a user