From dc50ba1249ebe850f0e489ab5e421525b10b7732 Mon Sep 17 00:00:00 2001 From: f4exb Date: Sun, 19 Nov 2017 18:18:17 +0100 Subject: [PATCH] Web API: report Rx channel info summary --- plugins/channelrx/demodam/amdemod.cpp | 2 ++ plugins/channelrx/demodam/amdemod.h | 3 ++- plugins/channelrx/demodbfm/bfmdemod.cpp | 2 ++ plugins/channelrx/demodbfm/bfmdemod.h | 3 ++- plugins/channelrx/demoddsd/dsddemod.cpp | 2 ++ plugins/channelrx/demoddsd/dsddemod.h | 7 ++++--- plugins/channelrx/demodlora/lorademod.cpp | 2 ++ plugins/channelrx/demodlora/lorademod.h | 9 +++++++-- plugins/channelrx/demodlora/lorademodsettings.cpp | 5 +++++ plugins/channelrx/demodlora/lorademodsettings.h | 3 +++ plugins/channelrx/demodnfm/nfmdemod.cpp | 4 ++++ plugins/channelrx/demodnfm/nfmdemod.h | 13 ++++++++++--- plugins/channelrx/demodnfm/nfmdemodgui.cpp | 4 +++- plugins/channelrx/demodnfm/nfmdemodsettings.cpp | 5 +++++ plugins/channelrx/demodnfm/nfmdemodsettings.h | 1 + plugins/channelrx/demodssb/ssbdemod.cpp | 9 ++++++--- plugins/channelrx/demodssb/ssbdemod.h | 13 +++++++++---- plugins/channelrx/demodssb/ssbdemodgui.cpp | 1 + plugins/channelrx/demodssb/ssbdemodsettings.cpp | 4 ++++ plugins/channelrx/demodssb/ssbdemodsettings.h | 1 + plugins/channelrx/demodwfm/wfmdemod.cpp | 4 ++++ plugins/channelrx/demodwfm/wfmdemod.h | 12 ++++++++++-- plugins/channelrx/demodwfm/wfmdemodgui.cpp | 4 +++- plugins/channelrx/demodwfm/wfmdemodsettings.cpp | 3 +++ plugins/channelrx/demodwfm/wfmdemodsettings.h | 1 + plugins/channelrx/tcpsrc/tcpsrc.cpp | 4 ++++ plugins/channelrx/tcpsrc/tcpsrc.h | 15 +++++++++++---- plugins/channelrx/tcpsrc/tcpsrcgui.cpp | 11 +---------- plugins/channelrx/tcpsrc/tcpsrcsettings.cpp | 5 +++++ plugins/channelrx/tcpsrc/tcpsrcsettings.h | 2 ++ plugins/channelrx/udpsrc/udpsrc.cpp | 4 ++++ plugins/channelrx/udpsrc/udpsrc.h | 15 +++++++++++---- plugins/channelrx/udpsrc/udpsrcgui.cpp | 4 +++- plugins/channelrx/udpsrc/udpsrcsettings.cpp | 5 +++++ plugins/channelrx/udpsrc/udpsrcsettings.h | 2 ++ 35 files changed, 144 insertions(+), 40 deletions(-) diff --git a/plugins/channelrx/demodam/amdemod.cpp b/plugins/channelrx/demodam/amdemod.cpp index a5071444e..e08c6a505 100644 --- a/plugins/channelrx/demodam/amdemod.cpp +++ b/plugins/channelrx/demodam/amdemod.cpp @@ -37,6 +37,7 @@ const int AMDemod::m_udpBlockSize = 512; AMDemod::AMDemod(DeviceSourceAPI *deviceAPI) : m_deviceAPI(deviceAPI), + m_absoluteFrequencyOffset(0), m_squelchOpen(false), m_magsqSum(0.0f), m_magsqPeak(0.0f), @@ -177,6 +178,7 @@ bool AMDemod::handleMessage(const Message& cmd) AMDemodSettings settings = cfg.getSettings(); // These settings are set with DownChannelizer::MsgChannelizerNotification + m_absoluteFrequencyOffset = settings.m_inputFrequencyOffset; settings.m_inputSampleRate = m_settings.m_inputSampleRate; settings.m_inputFrequencyOffset = m_settings.m_inputFrequencyOffset; diff --git a/plugins/channelrx/demodam/amdemod.h b/plugins/channelrx/demodam/amdemod.h index 98e09cede..b1ee1562b 100644 --- a/plugins/channelrx/demodam/amdemod.h +++ b/plugins/channelrx/demodam/amdemod.h @@ -92,7 +92,7 @@ public: virtual void stop(); virtual bool handleMessage(const Message& cmd); - virtual int getDeltaFrequency() const { return m_settings.m_inputFrequencyOffset; } + virtual int getDeltaFrequency() const { return m_absoluteFrequencyOffset; } virtual void getIdentifier(QString& id) { id = objectName(); } virtual void getTitle(QString& title) { title = m_settings.m_title; } @@ -121,6 +121,7 @@ private: ThreadedBasebandSampleSink* m_threadedChannelizer; DownChannelizer* m_channelizer; + int m_absoluteFrequencyOffset; AMDemodSettings m_settings; NCO m_nco; diff --git a/plugins/channelrx/demodbfm/bfmdemod.cpp b/plugins/channelrx/demodbfm/bfmdemod.cpp index 9959c3b43..7f327b9fa 100644 --- a/plugins/channelrx/demodbfm/bfmdemod.cpp +++ b/plugins/channelrx/demodbfm/bfmdemod.cpp @@ -40,6 +40,7 @@ const int BFMDemod::m_udpBlockSize = 512; BFMDemod::BFMDemod(DeviceSourceAPI *deviceAPI) : m_deviceAPI(deviceAPI), + m_absoluteFrequencyOffset(0), m_audioFifo(250000), m_settingsMutex(QMutex::Recursive), m_pilotPLL(19000/384000, 50/384000, 0.01), @@ -347,6 +348,7 @@ bool BFMDemod::handleMessage(const Message& cmd) BFMDemodSettings settings = cfg.getSettings(); // These settings are set with DownChannelizer::MsgChannelizerNotification + m_absoluteFrequencyOffset = settings.m_inputFrequencyOffset; settings.m_inputSampleRate = m_settings.m_inputSampleRate; settings.m_inputFrequencyOffset = m_settings.m_inputFrequencyOffset; diff --git a/plugins/channelrx/demodbfm/bfmdemod.h b/plugins/channelrx/demodbfm/bfmdemod.h index 8ab9d431a..4979dccce 100644 --- a/plugins/channelrx/demodbfm/bfmdemod.h +++ b/plugins/channelrx/demodbfm/bfmdemod.h @@ -122,7 +122,7 @@ public: virtual void stop(); virtual bool handleMessage(const Message& cmd); - virtual int getDeltaFrequency() const { return m_settings.m_inputFrequencyOffset; } + virtual int getDeltaFrequency() const { return m_absoluteFrequencyOffset; } virtual void getIdentifier(QString& id) { id = objectName(); } virtual void getTitle(QString& title) { title = m_settings.m_title; } @@ -163,6 +163,7 @@ private: DownChannelizer* m_channelizer; BFMDemodSettings m_settings; + int m_absoluteFrequencyOffset; NCO m_nco; Interpolator m_interpolator; //!< Interpolator between fixed demod bandwidth and audio bandwidth (rational) diff --git a/plugins/channelrx/demoddsd/dsddemod.cpp b/plugins/channelrx/demoddsd/dsddemod.cpp index e632e5d6e..ca159baac 100644 --- a/plugins/channelrx/demoddsd/dsddemod.cpp +++ b/plugins/channelrx/demoddsd/dsddemod.cpp @@ -40,6 +40,7 @@ const int DSDDemod::m_udpBlockSize = 512; DSDDemod::DSDDemod(DeviceSourceAPI *deviceAPI) : m_deviceAPI(deviceAPI), + m_absoluteFrequencyOffset(0), m_interpolatorDistance(0.0f), m_interpolatorDistanceRemain(0.0f), m_sampleCount(0), @@ -349,6 +350,7 @@ bool DSDDemod::handleMessage(const Message& cmd) DSDDemodSettings settings = cfg.getSettings(); // These settings are set with DownChannelizer::MsgChannelizerNotification + m_absoluteFrequencyOffset = settings.m_inputFrequencyOffset; settings.m_inputSampleRate = m_settings.m_inputSampleRate; settings.m_inputFrequencyOffset = m_settings.m_inputFrequencyOffset; diff --git a/plugins/channelrx/demoddsd/dsddemod.h b/plugins/channelrx/demoddsd/dsddemod.h index 54d0623d8..62b973951 100644 --- a/plugins/channelrx/demoddsd/dsddemod.h +++ b/plugins/channelrx/demoddsd/dsddemod.h @@ -101,7 +101,7 @@ public: virtual void stop(); virtual bool handleMessage(const Message& cmd); - virtual int getDeltaFrequency() const { return m_settings.m_inputFrequencyOffset; } + virtual int getDeltaFrequency() const { return m_absoluteFrequencyOffset; } virtual void getIdentifier(QString& id) { id = objectName(); } virtual void getTitle(QString& title) { title = m_settings.m_title; } @@ -151,12 +151,13 @@ private: RSRunning }; - DSDDemodSettings m_settings; - DeviceSourceAPI *m_deviceAPI; ThreadedBasebandSampleSink* m_threadedChannelizer; DownChannelizer* m_channelizer; + DSDDemodSettings m_settings; + int m_absoluteFrequencyOffset; + NCO m_nco; Interpolator m_interpolator; Real m_interpolatorDistance; diff --git a/plugins/channelrx/demodlora/lorademod.cpp b/plugins/channelrx/demodlora/lorademod.cpp index a731d03e2..0430e2b20 100644 --- a/plugins/channelrx/demodlora/lorademod.cpp +++ b/plugins/channelrx/demodlora/lorademod.cpp @@ -66,6 +66,7 @@ LoRaDemod::LoRaDemod(DeviceSourceAPI* deviceAPI) : m_channelizer = new DownChannelizer(this); m_threadedChannelizer = new ThreadedBasebandSampleSink(m_channelizer); m_deviceAPI->addThreadedSink(m_threadedChannelizer); + m_deviceAPI->addChannelAPI(this); } LoRaDemod::~LoRaDemod() @@ -81,6 +82,7 @@ LoRaDemod::~LoRaDemod() if (finetune) delete [] finetune; + m_deviceAPI->removeChannelAPI(this); m_deviceAPI->removeThreadedSink(m_threadedChannelizer); delete m_threadedChannelizer; delete m_channelizer; diff --git a/plugins/channelrx/demodlora/lorademod.h b/plugins/channelrx/demodlora/lorademod.h index 1bb53d7f2..998c54efe 100644 --- a/plugins/channelrx/demodlora/lorademod.h +++ b/plugins/channelrx/demodlora/lorademod.h @@ -21,7 +21,8 @@ #include #include -#include +#include "dsp/basebandsamplesink.h" +#include "channel/channelsinkapi.h" #include "dsp/nco.h" #include "dsp/interpolator.h" #include "util/message.h" @@ -39,7 +40,7 @@ class DeviceSourceAPI; class ThreadedBasebandSampleSink; class DownChannelizer; -class LoRaDemod : public BasebandSampleSink { +class LoRaDemod : public BasebandSampleSink, public ChannelSinkAPI { public: class MsgConfigureLoRaDemod : public Message { MESSAGE_CLASS_DECLARATION @@ -96,6 +97,10 @@ public: virtual void stop(); virtual bool handleMessage(const Message& cmd); + virtual int getDeltaFrequency() const { return 0; } + virtual void getIdentifier(QString& id) { id = objectName(); } + virtual void getTitle(QString& title) { title = m_settings.m_title; } + static const QString m_channelID; private: diff --git a/plugins/channelrx/demodlora/lorademodsettings.cpp b/plugins/channelrx/demodlora/lorademodsettings.cpp index c00d9a63e..f3b979871 100644 --- a/plugins/channelrx/demodlora/lorademodsettings.cpp +++ b/plugins/channelrx/demodlora/lorademodsettings.cpp @@ -22,6 +22,7 @@ void LoRaDemodSettings::resetToDefaults() m_bandwidthIndex = 0; m_spread = 0; m_rgbColor = QColor(255, 0, 255).rgb(); + m_title = "LoRa Demodulator"; } QByteArray LoRaDemodSettings::serialize() const @@ -39,6 +40,8 @@ QByteArray LoRaDemodSettings::serialize() const s.writeBlob(5, m_channelMarker->serialize()); } + s.writeString(6, m_title); + return s.final(); } @@ -70,6 +73,8 @@ bool LoRaDemodSettings::deserialize(const QByteArray& data) m_channelMarker->deserialize(bytetmp); } + d.readString(6, &m_title, "LoRa Demodulator"); + return true; } else diff --git a/plugins/channelrx/demodlora/lorademodsettings.h b/plugins/channelrx/demodlora/lorademodsettings.h index b0dd29dfd..734bbbd48 100644 --- a/plugins/channelrx/demodlora/lorademodsettings.h +++ b/plugins/channelrx/demodlora/lorademodsettings.h @@ -3,6 +3,8 @@ #define PLUGINS_CHANNELRX_DEMODLORA_LORADEMODSETTINGS_H_ #include +#include + #include class Serializable; @@ -13,6 +15,7 @@ struct LoRaDemodSettings int m_bandwidthIndex; int m_spread; uint32_t m_rgbColor; + QString m_title; Serializable *m_channelMarker; Serializable *m_spectrumGUI; diff --git a/plugins/channelrx/demodnfm/nfmdemod.cpp b/plugins/channelrx/demodnfm/nfmdemod.cpp index 8fd641a97..1f014c280 100644 --- a/plugins/channelrx/demodnfm/nfmdemod.cpp +++ b/plugins/channelrx/demodnfm/nfmdemod.cpp @@ -42,6 +42,7 @@ const int NFMDemod::m_udpBlockSize = 512; NFMDemod::NFMDemod(DeviceSourceAPI *devieAPI) : m_deviceAPI(devieAPI), + m_absoluteFrequencyOffset(0), m_ctcssIndex(0), m_sampleCount(0), m_squelchCount(0), @@ -77,6 +78,7 @@ NFMDemod::NFMDemod(DeviceSourceAPI *devieAPI) : m_channelizer = new DownChannelizer(this); m_threadedChannelizer = new ThreadedBasebandSampleSink(m_channelizer, this); m_deviceAPI->addThreadedSink(m_threadedChannelizer); + m_deviceAPI->addChannelAPI(this); applySettings(m_settings, true); } @@ -85,6 +87,7 @@ NFMDemod::~NFMDemod() { DSPEngine::instance()->removeAudioSink(&m_audioFifo); delete m_udpBufferAudio; + m_deviceAPI->removeChannelAPI(this); m_deviceAPI->removeThreadedSink(m_threadedChannelizer); delete m_threadedChannelizer; delete m_channelizer; @@ -345,6 +348,7 @@ bool NFMDemod::handleMessage(const Message& cmd) NFMDemodSettings settings = cfg.getSettings(); + m_absoluteFrequencyOffset = settings.m_inputFrequencyOffset; settings.m_inputSampleRate = m_settings.m_inputSampleRate; settings.m_inputFrequencyOffset = m_settings.m_inputFrequencyOffset; diff --git a/plugins/channelrx/demodnfm/nfmdemod.h b/plugins/channelrx/demodnfm/nfmdemod.h index c0d403c0f..a0f387cfb 100644 --- a/plugins/channelrx/demodnfm/nfmdemod.h +++ b/plugins/channelrx/demodnfm/nfmdemod.h @@ -18,10 +18,12 @@ #ifndef INCLUDE_NFMDEMOD_H #define INCLUDE_NFMDEMOD_H -#include -#include #include #include + +#include "dsp/basebandsamplesink.h" +#include "channel/channelsinkapi.h" +#include "dsp/phasediscri.h" #include "dsp/nco.h" #include "dsp/interpolator.h" #include "dsp/lowpass.h" @@ -39,7 +41,7 @@ class DeviceSourceAPI; class ThreadedBasebandSampleSink; class DownChannelizer; -class NFMDemod : public BasebandSampleSink { +class NFMDemod : public BasebandSampleSink, public ChannelSinkAPI { public: class MsgConfigureNFMDemod : public Message { MESSAGE_CLASS_DECLARATION @@ -115,6 +117,10 @@ public: virtual void stop(); virtual bool handleMessage(const Message& cmd); + virtual int getDeltaFrequency() const { return m_absoluteFrequencyOffset; } + virtual void getIdentifier(QString& id) { id = objectName(); } + virtual void getTitle(QString& title) { title = m_settings.m_title; } + const Real *getCtcssToneSet(int& nbTones) const { nbTones = m_ctcssDetector.getNTones(); return m_ctcssDetector.getToneSet(); @@ -151,6 +157,7 @@ private: DownChannelizer* m_channelizer; NFMDemodSettings m_settings; + int m_absoluteFrequencyOffset; NCO m_nco; Interpolator m_interpolator; diff --git a/plugins/channelrx/demodnfm/nfmdemodgui.cpp b/plugins/channelrx/demodnfm/nfmdemodgui.cpp index 973c2e588..4a036abb3 100644 --- a/plugins/channelrx/demodnfm/nfmdemodgui.cpp +++ b/plugins/channelrx/demodnfm/nfmdemodgui.cpp @@ -224,8 +224,9 @@ void NFMDemodGUI::onMenuDialogCalled(const QPoint &p) m_settings.m_udpAddress = m_channelMarker.getUDPAddress(), m_settings.m_udpPort = m_channelMarker.getUDPSendPort(), m_settings.m_rgbColor = m_channelMarker.getColor().rgb(); + m_settings.m_title = m_channelMarker.getTitle(); - setWindowTitle(m_channelMarker.getTitle()); + setWindowTitle(m_settings.m_title); setTitleColor(m_settings.m_rgbColor); displayUDPAddress(); @@ -336,6 +337,7 @@ void NFMDemodGUI::displaySettings() m_channelMarker.blockSignals(true); m_channelMarker.setCenterFrequency(m_settings.m_inputFrequencyOffset); m_channelMarker.setBandwidth(m_settings.m_rfBandwidth); + m_channelMarker.setTitle(m_settings.m_title); m_channelMarker.blockSignals(false); m_channelMarker.setColor(m_settings.m_rgbColor); diff --git a/plugins/channelrx/demodnfm/nfmdemodsettings.cpp b/plugins/channelrx/demodnfm/nfmdemodsettings.cpp index d0fa2d0c2..276d69950 100644 --- a/plugins/channelrx/demodnfm/nfmdemodsettings.cpp +++ b/plugins/channelrx/demodnfm/nfmdemodsettings.cpp @@ -55,6 +55,7 @@ void NFMDemodSettings::resetToDefaults() m_udpAddress = "127.0.0.1"; m_udpPort = 9999; m_rgbColor = QColor(255, 0, 0).rgb(); + m_title = "NFM Demodulator"; } QByteArray NFMDemodSettings::serialize() const @@ -75,6 +76,9 @@ QByteArray NFMDemodSettings::serialize() const if (m_channelMarker) { s.writeBlob(13, m_channelMarker->serialize()); } + + s.writeString(14, m_title); + return s.final(); } @@ -116,6 +120,7 @@ bool NFMDemodSettings::deserialize(const QByteArray& data) d.readBool(10, &m_audioMute, false); d.readS32(11, &m_squelchGate, 5); d.readBool(12, &m_deltaSquelch, false); + d.readString(14, &m_title, "NFM Demodulator"); return true; } diff --git a/plugins/channelrx/demodnfm/nfmdemodsettings.h b/plugins/channelrx/demodnfm/nfmdemodsettings.h index d686babd1..7d22bbfa3 100644 --- a/plugins/channelrx/demodnfm/nfmdemodsettings.h +++ b/plugins/channelrx/demodnfm/nfmdemodsettings.h @@ -44,6 +44,7 @@ struct NFMDemodSettings QString m_udpAddress; uint16_t m_udpPort; quint32 m_rgbColor; + QString m_title; Serializable *m_channelMarker; diff --git a/plugins/channelrx/demodssb/ssbdemod.cpp b/plugins/channelrx/demodssb/ssbdemod.cpp index 2932fc348..f50dbf4ab 100644 --- a/plugins/channelrx/demodssb/ssbdemod.cpp +++ b/plugins/channelrx/demodssb/ssbdemod.cpp @@ -60,8 +60,8 @@ SSBDemod::SSBDemod(DeviceSourceAPI *deviceAPI) : m_volume = 2.0; m_spanLog2 = 3; m_sampleRate = 96000; - m_frequency = 0; - m_nco.setFreq(m_frequency, m_sampleRate); + m_absoluteFrequencyOffset = 0; + m_nco.setFreq(m_absoluteFrequencyOffset, m_sampleRate); m_audioSampleRate = DSPEngine::instance()->getAudioSampleRate(); m_interpolator.create(16, m_sampleRate, 5000); @@ -89,6 +89,7 @@ SSBDemod::SSBDemod(DeviceSourceAPI *deviceAPI) : m_channelizer = new DownChannelizer(this); m_threadedChannelizer = new ThreadedBasebandSampleSink(m_channelizer, this); m_deviceAPI->addThreadedSink(m_threadedChannelizer); + m_deviceAPI->addChannelAPI(this); applySettings(m_settings, true); } @@ -100,6 +101,7 @@ SSBDemod::~SSBDemod() DSPEngine::instance()->removeAudioSink(&m_audioFifo); + m_deviceAPI->removeChannelAPI(this); m_deviceAPI->removeThreadedSink(m_threadedChannelizer); delete m_threadedChannelizer; delete m_channelizer; @@ -318,7 +320,8 @@ bool SSBDemod::handleMessage(const Message& cmd) SSBDemodSettings settings = cfg.getSettings(); - // These settings are set with DownChannelizer::MsgChannelizerNotification + // These settings are set with DownChannelizer::MsgChannelizerNotificatione + m_absoluteFrequencyOffset = settings.m_inputFrequencyOffset; // save as absolut frequency shift in baseband settings.m_inputSampleRate = m_settings.m_inputSampleRate; settings.m_inputFrequencyOffset = m_settings.m_inputFrequencyOffset; diff --git a/plugins/channelrx/demodssb/ssbdemod.h b/plugins/channelrx/demodssb/ssbdemod.h index 4357c45f4..0c7215a2e 100644 --- a/plugins/channelrx/demodssb/ssbdemod.h +++ b/plugins/channelrx/demodssb/ssbdemod.h @@ -21,7 +21,8 @@ #include #include -#include +#include "dsp/basebandsamplesink.h" +#include "channel/channelsinkapi.h" #include "dsp/ncof.h" #include "dsp/interpolator.h" #include "dsp/fftfilt.h" @@ -38,7 +39,7 @@ class DeviceSourceAPI; class ThreadedBasebandSampleSink; class DownChannelizer; -class SSBDemod : public BasebandSampleSink { +class SSBDemod : public BasebandSampleSink, public ChannelSinkAPI { public: class MsgConfigureSSBDemod : public Message { MESSAGE_CLASS_DECLARATION @@ -110,7 +111,11 @@ public: virtual void stop(); virtual bool handleMessage(const Message& cmd); - double getMagSq() const { return m_magsq; } + virtual int getDeltaFrequency() const { return m_absoluteFrequencyOffset; } + virtual void getIdentifier(QString& id) { id = objectName(); } + virtual void getTitle(QString& title) { title = m_settings.m_title; } + + double getMagSq() const { return m_magsq; } bool getAudioActive() const { return m_audioActive; } void getMagSqLevels(double& avg, double& peak, int& nbSamples) @@ -232,7 +237,7 @@ private: fftfilt::cmplx m_sum; int m_undersampleCount; int m_sampleRate; - int m_frequency; + int m_absoluteFrequencyOffset; bool m_audioBinaual; bool m_audioFlipChannels; bool m_usb; diff --git a/plugins/channelrx/demodssb/ssbdemodgui.cpp b/plugins/channelrx/demodssb/ssbdemodgui.cpp index 7545311a2..8ae7de355 100644 --- a/plugins/channelrx/demodssb/ssbdemodgui.cpp +++ b/plugins/channelrx/demodssb/ssbdemodgui.cpp @@ -375,6 +375,7 @@ void SSBDemodGUI::displaySettings() { m_channelMarker.blockSignals(true); m_channelMarker.setCenterFrequency(m_settings.m_inputFrequencyOffset); + m_channelMarker.setTitle(m_settings.m_title); m_channelMarker.setBandwidth(m_settings.m_rfBandwidth * 2); m_channelMarker.setLowCutoff(m_settings.m_lowCutoff); diff --git a/plugins/channelrx/demodssb/ssbdemodsettings.cpp b/plugins/channelrx/demodssb/ssbdemodsettings.cpp index fd18ea716..4effb1656 100644 --- a/plugins/channelrx/demodssb/ssbdemodsettings.cpp +++ b/plugins/channelrx/demodssb/ssbdemodsettings.cpp @@ -47,6 +47,7 @@ void SSBDemodSettings::resetToDefaults() m_inputFrequencyOffset = 0; m_audioSampleRate = DSPEngine::instance()->getAudioSampleRate(); m_rgbColor = QColor(0, 255, 0).rgb(); + m_title = "SSB Demodulator"; } QByteArray SSBDemodSettings::serialize() const @@ -71,6 +72,8 @@ QByteArray SSBDemodSettings::serialize() const s.writeS32(13, m_agcPowerThreshold); s.writeS32(14, m_agcThresholdGate); s.writeBool(15, m_agcClamping); + s.writeString(16, m_title); + return s.final(); } @@ -113,6 +116,7 @@ bool SSBDemodSettings::deserialize(const QByteArray& data) d.readS32(13, &m_agcPowerThreshold, -40); d.readS32(14, &m_agcThresholdGate, 4); d.readBool(15, &m_agcClamping, false); + d.readString(16, &m_title, "SSB Demodulator"); return true; } diff --git a/plugins/channelrx/demodssb/ssbdemodsettings.h b/plugins/channelrx/demodssb/ssbdemodsettings.h index 0fc1ca589..10b4d5e7f 100644 --- a/plugins/channelrx/demodssb/ssbdemodsettings.h +++ b/plugins/channelrx/demodssb/ssbdemodsettings.h @@ -42,6 +42,7 @@ struct SSBDemodSettings QString m_udpAddress; quint16 m_udpPort; quint32 m_rgbColor; + QString m_title; Serializable *m_channelMarker; Serializable *m_spectrumGUI; diff --git a/plugins/channelrx/demodwfm/wfmdemod.cpp b/plugins/channelrx/demodwfm/wfmdemod.cpp index 4673e7242..acb3a4ce2 100644 --- a/plugins/channelrx/demodwfm/wfmdemod.cpp +++ b/plugins/channelrx/demodwfm/wfmdemod.cpp @@ -37,6 +37,7 @@ const QString WFMDemod::m_channelID = "de.maintech.sdrangelove.channel.wfm"; WFMDemod::WFMDemod(DeviceSourceAPI* deviceAPI) : m_deviceAPI(deviceAPI), + m_absoluteFrequencyOffset(0), m_squelchOpen(false), m_magsq(0.0f), m_magsqSum(0.0f), @@ -63,6 +64,7 @@ WFMDemod::WFMDemod(DeviceSourceAPI* deviceAPI) : m_channelizer = new DownChannelizer(this); m_threadedChannelizer = new ThreadedBasebandSampleSink(m_channelizer, this); m_deviceAPI->addThreadedSink(m_threadedChannelizer); + m_deviceAPI->addChannelAPI(this); applySettings(m_settings, true); } @@ -76,6 +78,7 @@ WFMDemod::~WFMDemod() DSPEngine::instance()->removeAudioSink(&m_audioFifo); + m_deviceAPI->removeChannelAPI(this); m_deviceAPI->removeThreadedSink(m_threadedChannelizer); delete m_threadedChannelizer; delete m_channelizer; @@ -233,6 +236,7 @@ bool WFMDemod::handleMessage(const Message& cmd) WFMDemodSettings settings = cfg.getSettings(); // These settings are set with DownChannelizer::MsgChannelizerNotification + m_absoluteFrequencyOffset = settings.m_inputFrequencyOffset; settings.m_inputSampleRate = m_settings.m_inputSampleRate; settings.m_inputFrequencyOffset = m_settings.m_inputFrequencyOffset; diff --git a/plugins/channelrx/demodwfm/wfmdemod.h b/plugins/channelrx/demodwfm/wfmdemod.h index cb98dbcd2..0e5086484 100644 --- a/plugins/channelrx/demodwfm/wfmdemod.h +++ b/plugins/channelrx/demodwfm/wfmdemod.h @@ -18,9 +18,11 @@ #ifndef INCLUDE_WFMDEMOD_H #define INCLUDE_WFMDEMOD_H -#include #include #include + +#include "dsp/basebandsamplesink.h" +#include "channel/channelsinkapi.h" #include "dsp/nco.h" #include "dsp/interpolator.h" #include "dsp/lowpass.h" @@ -38,7 +40,7 @@ class ThreadedBasebandSampleSink; class DownChannelizer; class DeviceSourceAPI; -class WFMDemod : public BasebandSampleSink { +class WFMDemod : public BasebandSampleSink, public ChannelSinkAPI { public: class MsgConfigureWFMDemod : public Message { MESSAGE_CLASS_DECLARATION @@ -95,6 +97,10 @@ public: virtual void stop(); virtual bool handleMessage(const Message& cmd); + virtual int getDeltaFrequency() const { return m_absoluteFrequencyOffset; } + virtual void getIdentifier(QString& id) { id = objectName(); } + virtual void getTitle(QString& title) { title = m_settings.m_title; } + double getMagSq() const { return m_movingAverage.average(); } bool getSquelchOpen() const { return m_squelchOpen; } @@ -120,7 +126,9 @@ private: DeviceSourceAPI* m_deviceAPI; ThreadedBasebandSampleSink* m_threadedChannelizer; DownChannelizer* m_channelizer; + WFMDemodSettings m_settings; + int m_absoluteFrequencyOffset; NCO m_nco; Interpolator m_interpolator; //!< Interpolator between sample rate sent from DSP engine and requested RF bandwidth (rational) diff --git a/plugins/channelrx/demodwfm/wfmdemodgui.cpp b/plugins/channelrx/demodwfm/wfmdemodgui.cpp index 5ca41c3c1..49ba8156d 100644 --- a/plugins/channelrx/demodwfm/wfmdemodgui.cpp +++ b/plugins/channelrx/demodwfm/wfmdemodgui.cpp @@ -145,8 +145,9 @@ void WFMDemodGUI::onMenuDialogCalled(const QPoint &p) m_settings.m_udpAddress = m_channelMarker.getUDPAddress(), m_settings.m_udpPort = m_channelMarker.getUDPSendPort(), m_settings.m_rgbColor = m_channelMarker.getColor().rgb(); + m_settings.m_title = m_channelMarker.getTitle(); - setWindowTitle(m_channelMarker.getTitle()); + setWindowTitle(m_settings.m_title); setTitleColor(m_settings.m_rgbColor); displayUDPAddress(); @@ -240,6 +241,7 @@ void WFMDemodGUI::displaySettings() m_channelMarker.blockSignals(true); m_channelMarker.setCenterFrequency(m_settings.m_inputFrequencyOffset); m_channelMarker.setBandwidth(m_settings.m_rfBandwidth); + m_channelMarker.setTitle(m_settings.m_title); m_channelMarker.blockSignals(false); m_channelMarker.setColor(m_settings.m_rgbColor); // activate signal on the last setting only diff --git a/plugins/channelrx/demodwfm/wfmdemodsettings.cpp b/plugins/channelrx/demodwfm/wfmdemodsettings.cpp index 5d41f1b5a..c841e40e3 100644 --- a/plugins/channelrx/demodwfm/wfmdemodsettings.cpp +++ b/plugins/channelrx/demodwfm/wfmdemodsettings.cpp @@ -48,6 +48,7 @@ void WFMDemodSettings::resetToDefaults() m_udpAddress = "127.0.0.1"; m_udpPort = 9999; m_rgbColor = QColor(0, 0, 255).rgb(); + m_title = "WFM Demodulator"; } QByteArray WFMDemodSettings::serialize() const @@ -59,6 +60,7 @@ QByteArray WFMDemodSettings::serialize() const s.writeS32(4, m_volume*10.0); s.writeS32(5, m_squelch); s.writeU32(7, m_rgbColor); + s.writeString(8, m_title); if (m_channelMarker) { s.writeBlob(11, m_channelMarker->serialize()); @@ -94,6 +96,7 @@ bool WFMDemodSettings::deserialize(const QByteArray& data) d.readS32(5, &tmp, -60); m_squelch = tmp; d.readU32(7, &m_rgbColor); + d.readString(8, &m_title, "WFM Demodulator"); d.readBlob(11, &bytetmp); diff --git a/plugins/channelrx/demodwfm/wfmdemodsettings.h b/plugins/channelrx/demodwfm/wfmdemodsettings.h index ee5d0e276..79dfc8ca5 100644 --- a/plugins/channelrx/demodwfm/wfmdemodsettings.h +++ b/plugins/channelrx/demodwfm/wfmdemodsettings.h @@ -34,6 +34,7 @@ struct WFMDemodSettings QString m_udpAddress; quint16 m_udpPort; quint32 m_rgbColor; + QString m_title; Serializable *m_channelMarker; diff --git a/plugins/channelrx/tcpsrc/tcpsrc.cpp b/plugins/channelrx/tcpsrc/tcpsrc.cpp index 739d5260d..8b0eca9e5 100644 --- a/plugins/channelrx/tcpsrc/tcpsrc.cpp +++ b/plugins/channelrx/tcpsrc/tcpsrc.cpp @@ -34,6 +34,7 @@ const QString TCPSrc::m_channelID = "sdrangel.channel.tcpsrc"; TCPSrc::TCPSrc(DeviceSourceAPI* deviceAPI) : m_deviceAPI(deviceAPI), + m_absoluteFrequencyOffset(0), m_settingsMutex(QMutex::Recursive) { setObjectName("TCPSrc"); @@ -64,12 +65,14 @@ TCPSrc::TCPSrc(DeviceSourceAPI* deviceAPI) : m_channelizer = new DownChannelizer(this); m_threadedChannelizer = new ThreadedBasebandSampleSink(m_channelizer, this); m_deviceAPI->addThreadedSink(m_threadedChannelizer); + m_deviceAPI->addChannelAPI(this); } TCPSrc::~TCPSrc() { if (TCPFilter) delete TCPFilter; + m_deviceAPI->removeChannelAPI(this); m_deviceAPI->removeThreadedSink(m_threadedChannelizer); delete m_threadedChannelizer; delete m_channelizer; @@ -226,6 +229,7 @@ bool TCPSrc::handleMessage(const Message& cmd) TCPSrcSettings settings = cfg.getSettings(); // These settings are set with DownChannelizer::MsgChannelizerNotification + m_absoluteFrequencyOffset = settings.m_inputFrequencyOffset; settings.m_inputSampleRate = m_settings.m_inputSampleRate; settings.m_inputFrequencyOffset = m_settings.m_inputFrequencyOffset; diff --git a/plugins/channelrx/tcpsrc/tcpsrc.h b/plugins/channelrx/tcpsrc/tcpsrc.h index 36931185b..ec96fa030 100644 --- a/plugins/channelrx/tcpsrc/tcpsrc.h +++ b/plugins/channelrx/tcpsrc/tcpsrc.h @@ -4,7 +4,8 @@ #include #include -#include +#include "dsp/basebandsamplesink.h" +#include "channel/channelsinkapi.h" #include "dsp/nco.h" #include "dsp/fftfilt.h" #include "dsp/interpolator.h" @@ -21,7 +22,7 @@ class DeviceSourceAPI; class ThreadedBasebandSampleSink; class DownChannelizer; -class TCPSrc : public BasebandSampleSink { +class TCPSrc : public BasebandSampleSink, public ChannelSinkAPI { Q_OBJECT public: @@ -113,6 +114,10 @@ public: virtual void stop(); virtual bool handleMessage(const Message& cmd); + virtual int getDeltaFrequency() const { return m_absoluteFrequencyOffset; } + virtual void getIdentifier(QString& id) { id = objectName(); } + virtual void getTitle(QString& title) { title = m_settings.m_title; } + static const QString m_channelID; protected: @@ -155,11 +160,13 @@ protected: { } }; - TCPSrcSettings m_settings; - DeviceSourceAPI* m_deviceAPI; + DeviceSourceAPI* m_deviceAPI; ThreadedBasebandSampleSink* m_threadedChannelizer; DownChannelizer* m_channelizer; + TCPSrcSettings m_settings; + int m_absoluteFrequencyOffset; + int m_inputSampleRate; int m_sampleFormat; diff --git a/plugins/channelrx/tcpsrc/tcpsrcgui.cpp b/plugins/channelrx/tcpsrc/tcpsrcgui.cpp index 29e8e6b82..0c69ad17f 100644 --- a/plugins/channelrx/tcpsrc/tcpsrcgui.cpp +++ b/plugins/channelrx/tcpsrc/tcpsrcgui.cpp @@ -53,16 +53,6 @@ void TCPSrcGUI::resetToDefaults() QByteArray TCPSrcGUI::serialize() const { return m_settings.serialize(); -// SimpleSerializer s(1); -// s.writeS32(2, m_channelMarker.getCenterFrequency()); -// s.writeS32(3, m_sampleFormat); -// s.writeReal(4, m_outputSampleRate); -// s.writeReal(5, m_rfBandwidth); -// s.writeS32(6, m_tcpPort); -// s.writeBlob(7, ui->spectrumGUI->serialize()); -// s.writeS32(8, (qint32)m_boost); -// s.writeS32(9, m_channelMarker.getCenterFrequency()); -// return s.final(); } bool TCPSrcGUI::deserialize(const QByteArray& data) @@ -309,6 +299,7 @@ void TCPSrcGUI::displaySettings() m_channelMarker.blockSignals(true); m_channelMarker.setCenterFrequency(m_settings.m_inputFrequencyOffset); m_channelMarker.setBandwidth(m_settings.m_rfBandwidth); + m_channelMarker.setTitle(m_settings.m_title); m_channelMarker.blockSignals(false); m_channelMarker.setColor(m_settings.m_rgbColor); // activate signal on the last setting only diff --git a/plugins/channelrx/tcpsrc/tcpsrcsettings.cpp b/plugins/channelrx/tcpsrc/tcpsrcsettings.cpp index 7a6b56272..711454926 100644 --- a/plugins/channelrx/tcpsrc/tcpsrcsettings.cpp +++ b/plugins/channelrx/tcpsrc/tcpsrcsettings.cpp @@ -50,6 +50,7 @@ void TCPSrcSettings::resetToDefaults() m_udpPort = 9999; m_audioPort = 9998; m_rgbColor = QColor(225, 25, 99).rgb(); + m_title = "TCP Source"; } QByteArray TCPSrcSettings::serialize() const @@ -78,6 +79,8 @@ QByteArray TCPSrcSettings::serialize() const s.writeS32(16, m_squelchdB); s.writeS32(17, m_squelchGate); s.writeBool(18, m_agc); + s.writeString(19, m_title); + return s.final(); } @@ -134,6 +137,8 @@ bool TCPSrcSettings::deserialize(const QByteArray& data) d.readS32(16, &m_squelchdB, -60); d.readS32(17, &m_squelchGate, 5); d.readBool(18, &m_agc, false); + d.readString(19, &m_title, "TCP Source"); + return true; } else diff --git a/plugins/channelrx/tcpsrc/tcpsrcsettings.h b/plugins/channelrx/tcpsrc/tcpsrcsettings.h index aaf30ef0d..372a032f0 100644 --- a/plugins/channelrx/tcpsrc/tcpsrcsettings.h +++ b/plugins/channelrx/tcpsrc/tcpsrcsettings.h @@ -54,6 +54,8 @@ struct TCPSrcSettings uint16_t m_udpPort; uint16_t m_audioPort; + QString m_title; + Serializable *m_channelMarker; Serializable *m_spectrumGUI; diff --git a/plugins/channelrx/udpsrc/udpsrc.cpp b/plugins/channelrx/udpsrc/udpsrc.cpp index c5d2d41c1..862c1466a 100644 --- a/plugins/channelrx/udpsrc/udpsrc.cpp +++ b/plugins/channelrx/udpsrc/udpsrc.cpp @@ -37,6 +37,7 @@ const QString UDPSrc::m_channelID = "sdrangel.channel.udpsrc"; UDPSrc::UDPSrc(DeviceSourceAPI *deviceAPI) : m_deviceAPI(deviceAPI), + m_absoluteFrequencyOffset(0), m_outMovingAverage(480, 1e-10), m_inMovingAverage(480, 1e-10), m_amMovingAverage(1200, 1e-10), @@ -96,6 +97,7 @@ UDPSrc::UDPSrc(DeviceSourceAPI *deviceAPI) : m_channelizer = new DownChannelizer(this); m_threadedChannelizer = new ThreadedBasebandSampleSink(m_channelizer, this); m_deviceAPI->addThreadedSink(m_threadedChannelizer); + m_deviceAPI->addChannelAPI(this); applySettings(m_settings, true); } @@ -108,6 +110,7 @@ UDPSrc::~UDPSrc() delete[] m_udpAudioBuf; if (UDPFilter) delete UDPFilter; if (m_settings.m_audioActive) DSPEngine::instance()->removeAudioSink(&m_audioFifo); + m_deviceAPI->removeChannelAPI(this); m_deviceAPI->removeThreadedSink(m_threadedChannelizer); delete m_threadedChannelizer; delete m_channelizer; @@ -353,6 +356,7 @@ bool UDPSrc::handleMessage(const Message& cmd) UDPSrcSettings settings = cfg.getSettings(); // These settings are set with DownChannelizer::MsgChannelizerNotification + m_absoluteFrequencyOffset = settings.m_inputFrequencyOffset; settings.m_inputSampleRate = m_settings.m_inputSampleRate; settings.m_inputFrequencyOffset = m_settings.m_inputFrequencyOffset; diff --git a/plugins/channelrx/udpsrc/udpsrc.h b/plugins/channelrx/udpsrc/udpsrc.h index 391c378c9..2616bed7a 100644 --- a/plugins/channelrx/udpsrc/udpsrc.h +++ b/plugins/channelrx/udpsrc/udpsrc.h @@ -18,9 +18,11 @@ #ifndef INCLUDE_UDPSRC_H #define INCLUDE_UDPSRC_H -#include #include #include + +#include "dsp/basebandsamplesink.h" +#include "channel/channelsinkapi.h" #include "dsp/nco.h" #include "dsp/fftfilt.h" #include "dsp/interpolator.h" @@ -39,7 +41,7 @@ class DeviceSourceAPI; class ThreadedBasebandSampleSink; class DownChannelizer; -class UDPSrc : public BasebandSampleSink { +class UDPSrc : public BasebandSampleSink, public ChannelSinkAPI { Q_OBJECT public: @@ -104,6 +106,10 @@ public: virtual void stop(); virtual bool handleMessage(const Message& cmd); + virtual int getDeltaFrequency() const { return m_absoluteFrequencyOffset; } + virtual void getIdentifier(QString& id) { id = objectName(); } + virtual void getTitle(QString& title) { title = m_settings.m_title; } + static const QString m_channelID; static const int udpBlockSize = 512; // UDP block size in number of bytes @@ -131,12 +137,13 @@ protected: { } }; - UDPSrcSettings m_settings; - DeviceSourceAPI *m_deviceAPI; ThreadedBasebandSampleSink* m_threadedChannelizer; DownChannelizer* m_channelizer; + UDPSrcSettings m_settings; + int m_absoluteFrequencyOffset; + QUdpSocket *m_audioSocket; double m_magsq; diff --git a/plugins/channelrx/udpsrc/udpsrcgui.cpp b/plugins/channelrx/udpsrc/udpsrcgui.cpp index 76bd5152e..ad777a196 100644 --- a/plugins/channelrx/udpsrc/udpsrcgui.cpp +++ b/plugins/channelrx/udpsrc/udpsrcgui.cpp @@ -215,6 +215,7 @@ void UDPSrcGUI::displaySettings() m_channelMarker.blockSignals(true); m_channelMarker.setCenterFrequency(m_settings.m_inputFrequencyOffset); m_channelMarker.setBandwidth(m_settings.m_rfBandwidth); + m_channelMarker.setTitle(m_settings.m_title); m_channelMarker.blockSignals(false); m_channelMarker.setColor(m_settings.m_rgbColor); // activate signal on the last setting only @@ -544,8 +545,9 @@ void UDPSrcGUI::onMenuDialogCalled(const QPoint &p) m_settings.m_udpAddress = m_channelMarker.getUDPAddress(), m_settings.m_udpPort = m_channelMarker.getUDPSendPort(), m_settings.m_rgbColor = m_channelMarker.getColor().rgb(); + m_settings.m_title = m_channelMarker.getTitle(); - setWindowTitle(m_channelMarker.getTitle()); + setWindowTitle(m_settings.m_title); setTitleColor(m_settings.m_rgbColor); displayUDPAddress(); diff --git a/plugins/channelrx/udpsrc/udpsrcsettings.cpp b/plugins/channelrx/udpsrc/udpsrcsettings.cpp index df207733d..d8caf03df 100644 --- a/plugins/channelrx/udpsrc/udpsrcsettings.cpp +++ b/plugins/channelrx/udpsrc/udpsrcsettings.cpp @@ -49,6 +49,7 @@ void UDPSrcSettings::resetToDefaults() m_udpPort = 9999; m_audioPort = 9998; m_rgbColor = QColor(225, 25, 99).rgb(); + m_title = "UDP Sample Source"; } QByteArray UDPSrcSettings::serialize() const @@ -76,6 +77,8 @@ QByteArray UDPSrcSettings::serialize() const s.writeS32(16, m_squelchdB); s.writeS32(17, m_squelchGate); s.writeBool(18, m_agc); + s.writeString(19, m_title); + return s.final(); } @@ -130,6 +133,8 @@ bool UDPSrcSettings::deserialize(const QByteArray& data) d.readS32(16, &m_squelchdB, -60); d.readS32(17, &m_squelchGate, 5); d.readBool(18, &m_agc, false); + d.readString(19, &m_title, "UDP Sample Source"); + return true; } else diff --git a/plugins/channelrx/udpsrc/udpsrcsettings.h b/plugins/channelrx/udpsrc/udpsrcsettings.h index af57adeda..77ebec8c4 100644 --- a/plugins/channelrx/udpsrc/udpsrcsettings.h +++ b/plugins/channelrx/udpsrc/udpsrcsettings.h @@ -60,6 +60,8 @@ struct UDPSrcSettings uint16_t m_udpPort; uint16_t m_audioPort; + QString m_title; + Serializable *m_channelMarker; Serializable *m_spectrumGUI;