From 6d27dc5e0b1a91e506f36a4c6ecdf69a9b1b0a45 Mon Sep 17 00:00:00 2001 From: f4exb Date: Sun, 19 Jul 2015 02:07:40 +0200 Subject: [PATCH] Sort channel plugins by delta frequency and type before saving to preset --- Readme.md | 4 +++- include-gpl/plugin/pluginmanager.h | 3 ++- include/plugin/plugingui.h | 2 +- plugins/channel/am/amdemodgui.cpp | 4 ++++ plugins/channel/am/amdemodgui.h | 1 + plugins/channel/chanalyzer/chanalyzergui.cpp | 5 +++++ plugins/channel/chanalyzer/chanalyzergui.h | 1 + plugins/channel/lora/lorademodgui.cpp | 4 ++++ plugins/channel/lora/lorademodgui.h | 1 + plugins/channel/nfm/nfmdemodgui.cpp | 5 +++++ plugins/channel/nfm/nfmdemodgui.h | 1 + plugins/channel/ssb/ssbdemodgui.cpp | 5 +++++ plugins/channel/ssb/ssbdemodgui.h | 1 + plugins/channel/tcpsrc/tcpsrcgui.cpp | 5 +++++ plugins/channel/tcpsrc/tcpsrcgui.h | 1 + plugins/channel/wfm/wfmdemodgui.cpp | 5 +++++ plugins/channel/wfm/wfmdemodgui.h | 1 + plugins/samplesource/bladerf/bladerfgui.cpp | 2 +- plugins/samplesource/bladerf/bladerfgui.h | 2 +- plugins/samplesource/fcd/fcdgui.cpp | 2 +- plugins/samplesource/fcd/fcdgui.h | 2 +- plugins/samplesource/rtlsdr/rtlsdrgui.cpp | 2 +- plugins/samplesource/rtlsdr/rtlsdrgui.h | 2 +- sdrbase/plugin/plugingui.cpp | 2 +- sdrbase/plugin/pluginmanager.cpp | 19 +++++++++++++++++-- 25 files changed, 70 insertions(+), 12 deletions(-) diff --git a/Readme.md b/Readme.md index 21f8bd4ed..e4a6d124e 100644 --- a/Readme.md +++ b/Readme.md @@ -114,13 +114,15 @@ Done since the fork - Enhanced scope display and controls: scale display, better X (time) and Y scales control, grid fit to scale, effectively implementing triggers, trigger on magnitude and phase, properly handling time shift, ... - Enhanced spectrum display: Histogram: define NO_AVX, wider decay range, make stroke and late holdoff adjustable. Added option to show live spectrum (had only max hold before). - Enhanced channel analyzer: enhanced scope and spectrum displays as mentioned above, make the spectrum display synchronous to scope (hence triggerable a la E4406A). + - Sort channel plugins by delta frequency and type before saving to preset ===== To Do ===== - - Enhance presets management (Edit, Move, Import/Export from/to human readable format like JSON) + - Implement trigger delay on scope - Variable scope memory depth + - Enhance presets management (Edit, Move, Import/Export from/to human readable format like JSON) - Level calibration - Enhance WFM (stereo, RDS?) - Even more demods ... diff --git a/include-gpl/plugin/pluginmanager.h b/include-gpl/plugin/pluginmanager.h index 8080b5ad1..41605f108 100644 --- a/include-gpl/plugin/pluginmanager.h +++ b/include-gpl/plugin/pluginmanager.h @@ -45,7 +45,7 @@ public: void registerSampleSource(const QString& sourceName, PluginInterface* plugin); void loadSettings(const Preset* preset); - void saveSettings(Preset* preset) const; + void saveSettings(Preset* preset); void freeAll(); @@ -78,6 +78,7 @@ private: m_channelName(channelName), m_gui(pluginGUI) { } + bool operator<(const ChannelInstanceRegistration& other) const; }; typedef QList ChannelInstanceRegistrations; diff --git a/include/plugin/plugingui.h b/include/plugin/plugingui.h index d0e2e3543..b4ec413e5 100644 --- a/include/plugin/plugingui.h +++ b/include/plugin/plugingui.h @@ -18,7 +18,7 @@ public: virtual QByteArray serializeGeneral() const; virtual bool deserializeGeneral(const QByteArray& data); - virtual quint64 getCenterFrequency() const; + virtual qint64 getCenterFrequency() const; virtual QByteArray serialize() const = 0; virtual bool deserialize(const QByteArray& data) = 0; diff --git a/plugins/channel/am/amdemodgui.cpp b/plugins/channel/am/amdemodgui.cpp index d6d73442b..668768f58 100644 --- a/plugins/channel/am/amdemodgui.cpp +++ b/plugins/channel/am/amdemodgui.cpp @@ -39,6 +39,10 @@ QString AMDemodGUI::getName() const return objectName(); } +qint64 AMDemodGUI::getCenterFrequency() const { + return m_channelMarker->getCenterFrequency(); +} + void AMDemodGUI::resetToDefaults() { ui->rfBW->setValue(4); diff --git a/plugins/channel/am/amdemodgui.h b/plugins/channel/am/amdemodgui.h index 95d13944f..f60f628c2 100644 --- a/plugins/channel/am/amdemodgui.h +++ b/plugins/channel/am/amdemodgui.h @@ -26,6 +26,7 @@ public: void setName(const QString& name); QString getName() const; + qint64 getCenterFrequency() const; void resetToDefaults(); QByteArray serialize() const; diff --git a/plugins/channel/chanalyzer/chanalyzergui.cpp b/plugins/channel/chanalyzer/chanalyzergui.cpp index 1afb7fd4d..9d91c53a1 100644 --- a/plugins/channel/chanalyzer/chanalyzergui.cpp +++ b/plugins/channel/chanalyzer/chanalyzergui.cpp @@ -37,6 +37,11 @@ QString ChannelAnalyzerGUI::getName() const return objectName(); } +qint64 ChannelAnalyzerGUI::getCenterFrequency() const +{ + return m_channelMarker->getCenterFrequency(); +} + void ChannelAnalyzerGUI::resetToDefaults() { ui->BW->setValue(30); diff --git a/plugins/channel/chanalyzer/chanalyzergui.h b/plugins/channel/chanalyzer/chanalyzergui.h index d78401b3b..2b31bb000 100644 --- a/plugins/channel/chanalyzer/chanalyzergui.h +++ b/plugins/channel/chanalyzer/chanalyzergui.h @@ -28,6 +28,7 @@ public: void setName(const QString& name); QString getName() const; + qint64 getCenterFrequency() const; void resetToDefaults(); QByteArray serialize() const; diff --git a/plugins/channel/lora/lorademodgui.cpp b/plugins/channel/lora/lorademodgui.cpp index 2d74f1d97..bb29518ba 100644 --- a/plugins/channel/lora/lorademodgui.cpp +++ b/plugins/channel/lora/lorademodgui.cpp @@ -34,6 +34,10 @@ QString LoRaDemodGUI::getName() const return objectName(); } +qint64 LoRaDemodGUI::getCenterFrequency() const { + return m_channelMarker->getCenterFrequency(); +} + void LoRaDemodGUI::resetToDefaults() { ui->BW->setValue(0); diff --git a/plugins/channel/lora/lorademodgui.h b/plugins/channel/lora/lorademodgui.h index a0ec12a7b..e9e016162 100644 --- a/plugins/channel/lora/lorademodgui.h +++ b/plugins/channel/lora/lorademodgui.h @@ -26,6 +26,7 @@ public: void setName(const QString& name); QString getName() const; + qint64 getCenterFrequency() const; void resetToDefaults(); QByteArray serialize() const; diff --git a/plugins/channel/nfm/nfmdemodgui.cpp b/plugins/channel/nfm/nfmdemodgui.cpp index 63968be5e..6346c98c3 100644 --- a/plugins/channel/nfm/nfmdemodgui.cpp +++ b/plugins/channel/nfm/nfmdemodgui.cpp @@ -38,6 +38,11 @@ QString NFMDemodGUI::getName() const return objectName(); } +qint64 NFMDemodGUI::getCenterFrequency() const +{ + return m_channelMarker->getCenterFrequency(); +} + void NFMDemodGUI::resetToDefaults() { ui->rfBW->setValue(4); diff --git a/plugins/channel/nfm/nfmdemodgui.h b/plugins/channel/nfm/nfmdemodgui.h index b502a45ff..19d7639ec 100644 --- a/plugins/channel/nfm/nfmdemodgui.h +++ b/plugins/channel/nfm/nfmdemodgui.h @@ -27,6 +27,7 @@ public: void setName(const QString& name); QString getName() const; + qint64 getCenterFrequency() const; void resetToDefaults(); QByteArray serialize() const; diff --git a/plugins/channel/ssb/ssbdemodgui.cpp b/plugins/channel/ssb/ssbdemodgui.cpp index ceb4009ec..1afe2c690 100644 --- a/plugins/channel/ssb/ssbdemodgui.cpp +++ b/plugins/channel/ssb/ssbdemodgui.cpp @@ -36,6 +36,11 @@ QString SSBDemodGUI::getName() const return objectName(); } +qint64 SSBDemodGUI::getCenterFrequency() const +{ + return m_channelMarker->getCenterFrequency(); +} + void SSBDemodGUI::resetToDefaults() { ui->BW->setValue(30); diff --git a/plugins/channel/ssb/ssbdemodgui.h b/plugins/channel/ssb/ssbdemodgui.h index a2857fd61..97e23f916 100644 --- a/plugins/channel/ssb/ssbdemodgui.h +++ b/plugins/channel/ssb/ssbdemodgui.h @@ -26,6 +26,7 @@ public: void setName(const QString& name); QString getName() const; + qint64 getCenterFrequency() const; void resetToDefaults(); QByteArray serialize() const; diff --git a/plugins/channel/tcpsrc/tcpsrcgui.cpp b/plugins/channel/tcpsrc/tcpsrcgui.cpp index e92315e3d..95792ec5d 100644 --- a/plugins/channel/tcpsrc/tcpsrcgui.cpp +++ b/plugins/channel/tcpsrc/tcpsrcgui.cpp @@ -24,6 +24,11 @@ void TCPSrcGUI::setName(const QString& name) setObjectName(name); } +qint64 TCPSrcGUI::getCenterFrequency() const +{ + return m_channelMarker->getCenterFrequency(); +} + QString TCPSrcGUI::getName() const { return objectName(); diff --git a/plugins/channel/tcpsrc/tcpsrcgui.h b/plugins/channel/tcpsrc/tcpsrcgui.h index 881658c25..3e3629381 100644 --- a/plugins/channel/tcpsrc/tcpsrcgui.h +++ b/plugins/channel/tcpsrc/tcpsrcgui.h @@ -26,6 +26,7 @@ public: void setName(const QString& name); QString getName() const; + qint64 getCenterFrequency() const; void resetToDefaults(); QByteArray serialize() const; diff --git a/plugins/channel/wfm/wfmdemodgui.cpp b/plugins/channel/wfm/wfmdemodgui.cpp index 0511f00ca..c0d9009a9 100644 --- a/plugins/channel/wfm/wfmdemodgui.cpp +++ b/plugins/channel/wfm/wfmdemodgui.cpp @@ -48,6 +48,11 @@ QString WFMDemodGUI::getName() const return objectName(); } +qint64 WFMDemodGUI::getCenterFrequency() const +{ + return m_channelMarker->getCenterFrequency(); +} + void WFMDemodGUI::resetToDefaults() { ui->rfBW->setValue(4); diff --git a/plugins/channel/wfm/wfmdemodgui.h b/plugins/channel/wfm/wfmdemodgui.h index c3f8123e7..66f9c0de7 100644 --- a/plugins/channel/wfm/wfmdemodgui.h +++ b/plugins/channel/wfm/wfmdemodgui.h @@ -26,6 +26,7 @@ public: void setName(const QString& name); QString getName() const; + qint64 getCenterFrequency() const; void resetToDefaults(); QByteArray serialize() const; diff --git a/plugins/samplesource/bladerf/bladerfgui.cpp b/plugins/samplesource/bladerf/bladerfgui.cpp index e6d602b5a..f7cbba6e6 100644 --- a/plugins/samplesource/bladerf/bladerfgui.cpp +++ b/plugins/samplesource/bladerf/bladerfgui.cpp @@ -82,7 +82,7 @@ bool BladerfGui::deserializeGeneral(const QByteArray&data) } } -quint64 BladerfGui::getCenterFrequency() const +qint64 BladerfGui::getCenterFrequency() const { return m_generalSettings.m_centerFrequency; } diff --git a/plugins/samplesource/bladerf/bladerfgui.h b/plugins/samplesource/bladerf/bladerfgui.h index a88c6acb3..66c6949fd 100644 --- a/plugins/samplesource/bladerf/bladerfgui.h +++ b/plugins/samplesource/bladerf/bladerfgui.h @@ -43,7 +43,7 @@ public: void resetToDefaults(); QByteArray serializeGeneral() const; bool deserializeGeneral(const QByteArray&data); - quint64 getCenterFrequency() const; + qint64 getCenterFrequency() const; QByteArray serialize() const; bool deserialize(const QByteArray& data); bool handleMessage(Message* message); diff --git a/plugins/samplesource/fcd/fcdgui.cpp b/plugins/samplesource/fcd/fcdgui.cpp index dfda51a93..2203a6d3b 100644 --- a/plugins/samplesource/fcd/fcdgui.cpp +++ b/plugins/samplesource/fcd/fcdgui.cpp @@ -63,7 +63,7 @@ bool FCDGui::deserializeGeneral(const QByteArray&data) } } -quint64 FCDGui::getCenterFrequency() const +qint64 FCDGui::getCenterFrequency() const { return m_generalSettings.m_centerFrequency; } diff --git a/plugins/samplesource/fcd/fcdgui.h b/plugins/samplesource/fcd/fcdgui.h index be7a50309..5e719858e 100644 --- a/plugins/samplesource/fcd/fcdgui.h +++ b/plugins/samplesource/fcd/fcdgui.h @@ -25,7 +25,7 @@ public: void resetToDefaults(); QByteArray serializeGeneral() const; bool deserializeGeneral(const QByteArray&data); - quint64 getCenterFrequency() const; + qint64 getCenterFrequency() const; QByteArray serialize() const; bool deserialize(const QByteArray& data); bool handleMessage(Message* message); diff --git a/plugins/samplesource/rtlsdr/rtlsdrgui.cpp b/plugins/samplesource/rtlsdr/rtlsdrgui.cpp index 577ca3943..1ef4ed3ed 100644 --- a/plugins/samplesource/rtlsdr/rtlsdrgui.cpp +++ b/plugins/samplesource/rtlsdr/rtlsdrgui.cpp @@ -64,7 +64,7 @@ bool RTLSDRGui::deserializeGeneral(const QByteArray&data) } } -quint64 RTLSDRGui::getCenterFrequency() const +qint64 RTLSDRGui::getCenterFrequency() const { return m_generalSettings.m_centerFrequency; } diff --git a/plugins/samplesource/rtlsdr/rtlsdrgui.h b/plugins/samplesource/rtlsdr/rtlsdrgui.h index e392f06a1..65fd1a8a9 100644 --- a/plugins/samplesource/rtlsdr/rtlsdrgui.h +++ b/plugins/samplesource/rtlsdr/rtlsdrgui.h @@ -26,7 +26,7 @@ public: void resetToDefaults(); QByteArray serializeGeneral() const; bool deserializeGeneral(const QByteArray&data); - quint64 getCenterFrequency() const; + qint64 getCenterFrequency() const; QByteArray serialize() const; bool deserialize(const QByteArray& data); bool handleMessage(Message* message); diff --git a/sdrbase/plugin/plugingui.cpp b/sdrbase/plugin/plugingui.cpp index 63ddcce79..6b4e5e8c8 100644 --- a/sdrbase/plugin/plugingui.cpp +++ b/sdrbase/plugin/plugingui.cpp @@ -10,7 +10,7 @@ bool PluginGUI::deserializeGeneral(const QByteArray& data) return false; } -quint64 PluginGUI::getCenterFrequency() const +qint64 PluginGUI::getCenterFrequency() const { return 0; } diff --git a/sdrbase/plugin/pluginmanager.cpp b/sdrbase/plugin/pluginmanager.cpp index 2f31c32e4..e6bdbe3a7 100644 --- a/sdrbase/plugin/pluginmanager.cpp +++ b/sdrbase/plugin/pluginmanager.cpp @@ -133,7 +133,20 @@ void PluginManager::loadSettings(const Preset* preset) } } -void PluginManager::saveSettings(Preset* preset) const +// sort by increasing delta frequency and type (i.e. name) +bool PluginManager::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; + } +} + +void PluginManager::saveSettings(Preset* preset) { if(m_sampleSourceInstance != NULL) { preset->setSourceConfig(m_sampleSource, m_sampleSourceInstance->serializeGeneral(), m_sampleSourceInstance->serialize()); @@ -141,8 +154,10 @@ void PluginManager::saveSettings(Preset* preset) const } else { preset->setSourceConfig(QString::null, QByteArray(), QByteArray()); } - for(int i = 0; i < m_channelInstanceRegistrations.count(); i++) + qSort(m_channelInstanceRegistrations.begin(), m_channelInstanceRegistrations.end()); // sort by increasing delta frequency and type + for(int i = 0; i < m_channelInstanceRegistrations.count(); i++) { preset->addChannel(m_channelInstanceRegistrations[i].m_channelName, m_channelInstanceRegistrations[i].m_gui->serialize()); + } } void PluginManager::freeAll()