From a670c03f46db980a81b4546f6b9218da82921a63 Mon Sep 17 00:00:00 2001 From: f4exb Date: Wed, 28 Sep 2016 17:58:29 +0200 Subject: [PATCH] DSD demod: update My Position from the GUI with the value stored in the main window --- plugins/channel/demoddsd/dsddecoder.h | 1 + plugins/channel/demoddsd/dsddemod.cpp | 13 +++++++++++++ plugins/channel/demoddsd/dsddemod.h | 24 ++++++++++++++++++++++++ plugins/channel/demoddsd/dsddemodgui.cpp | 15 +++++++++++++++ plugins/channel/demoddsd/dsddemodgui.h | 4 ++++ 5 files changed, 57 insertions(+) diff --git a/plugins/channel/demoddsd/dsddecoder.h b/plugins/channel/demoddsd/dsddecoder.h index 83dbe184a..71d8e426e 100644 --- a/plugins/channel/demoddsd/dsddecoder.h +++ b/plugins/channel/demoddsd/dsddecoder.h @@ -67,6 +67,7 @@ public: const DSDcc::DSDdPMR& getDPMRDecoder() const { return m_decoder.getDPMRDecoder(); } const DSDcc::DSDYSF& getYSFDecoder() const { return m_decoder.getYSFDecoder(); } + void setMyPoint(float lat, float lon) { m_decoder.setMyPoint(lat, lon); } void setAudioGain(float gain) { m_decoder.setAudioGain(gain); } void setBaudRate(int baudRate); diff --git a/plugins/channel/demoddsd/dsddemod.cpp b/plugins/channel/demoddsd/dsddemod.cpp index d2da8606d..14eddf7b5 100644 --- a/plugins/channel/demoddsd/dsddemod.cpp +++ b/plugins/channel/demoddsd/dsddemod.cpp @@ -29,6 +29,7 @@ static const Real afSqTones[2] = {1200.0, 6400.0}; // {1200.0, 8000.0}; MESSAGE_CLASS_DEFINITION(DSDDemod::MsgConfigureDSDDemod, Message) +MESSAGE_CLASS_DEFINITION(DSDDemod::MsgConfigureMyPosition, Message) DSDDemod::DSDDemod(SampleSink* sampleSink) : m_sampleCount(0), @@ -109,6 +110,12 @@ void DSDDemod::configure(MessageQueue* messageQueue, messageQueue->push(cmd); } +void DSDDemod::configureMyPosition(MessageQueue* messageQueue, float myLatitude, float myLongitude) +{ + Message* cmd = MsgConfigureMyPosition::create(myLatitude, myLongitude); + messageQueue->push(cmd); +} + void DSDDemod::feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool firstOfBurst) { Complex ci; @@ -363,6 +370,12 @@ bool DSDDemod::handleMessage(const Message& cmd) return true; } + else if (MsgConfigureMyPosition::match(cmd)) + { + MsgConfigureMyPosition& cfg = (MsgConfigureMyPosition&) cmd; + m_dsdDecoder.setMyPoint(cfg.getMyLatitude(), cfg.getMyLongitude()); + return true; + } else { return false; diff --git a/plugins/channel/demoddsd/dsddemod.h b/plugins/channel/demoddsd/dsddemod.h index 369076c99..474871bf2 100644 --- a/plugins/channel/demoddsd/dsddemod.h +++ b/plugins/channel/demoddsd/dsddemod.h @@ -55,6 +55,8 @@ public: bool slot2On, bool tdmaStereo); + void configureMyPosition(MessageQueue* messageQueue, float myLatitude, float myLongitude); + virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool po); virtual void start(); virtual void stop(); @@ -70,6 +72,28 @@ public: const DSDDecoder& getDecoder() const { return m_dsdDecoder; } private: + class MsgConfigureMyPosition : public Message { + MESSAGE_CLASS_DECLARATION + + public: + float getMyLatitude() const { return m_myLatitude; } + float getMyLongitude() const { return m_myLongitude; } + + static MsgConfigureMyPosition* create(float myLatitude, float myLongitude) + { + return new MsgConfigureMyPosition(myLatitude, myLongitude); + } + + private: + float m_myLatitude; + float m_myLongitude; + + MsgConfigureMyPosition(float myLatitude, float myLongitude) : + m_myLatitude(myLatitude), + m_myLongitude(myLongitude) + {} + }; + class MsgConfigureDSDDemod : public Message { MESSAGE_CLASS_DECLARATION diff --git a/plugins/channel/demoddsd/dsddemodgui.cpp b/plugins/channel/demoddsd/dsddemodgui.cpp index 407983c2f..22f3c40ca 100644 --- a/plugins/channel/demoddsd/dsddemodgui.cpp +++ b/plugins/channel/demoddsd/dsddemodgui.cpp @@ -196,6 +196,7 @@ bool DSDDemodGUI::deserialize(const QByteArray& data) blockApplySettings(false); m_channelMarker.blockSignals(false); + updateMyPosition(); // we do it also here to be able to refresh with latest settings applySettings(); return true; } @@ -386,6 +387,7 @@ DSDDemodGUI::DSDDemodGUI(PluginAPI* pluginAPI, DeviceAPI *deviceAPI, QWidget* pa ui->scopeGUI->setBuddies(m_scopeVis->getInputMessageQueue(), m_scopeVis, ui->glScope); + updateMyPosition(); applySettings(); } @@ -400,6 +402,19 @@ DSDDemodGUI::~DSDDemodGUI() delete ui; } +void DSDDemodGUI::updateMyPosition() +{ + float latitude = m_pluginAPI->getMainWindow()->getMainSettings().getLatitude(); + float longitude = m_pluginAPI->getMainWindow()->getMainSettings().getLongitude(); + + if ((m_myLatitude != latitude) || (m_myLongitude != longitude)) + { + m_dsdDemod->configureMyPosition(m_dsdDemod->getInputMessageQueue(), latitude, longitude); + m_myLatitude = latitude; + m_myLongitude = longitude; + } +} + void DSDDemodGUI::applySettings() { if (m_doApplySettings) diff --git a/plugins/channel/demoddsd/dsddemodgui.h b/plugins/channel/demoddsd/dsddemodgui.h index ec95bb3c1..914a0e405 100644 --- a/plugins/channel/demoddsd/dsddemodgui.h +++ b/plugins/channel/demoddsd/dsddemodgui.h @@ -112,6 +112,9 @@ private: MovingAverage m_channelPowerDbAvg; int m_tickCount; + float m_myLatitude; + float m_myLongitude; + static char m_dpmrFrameTypes[9][3]; static const char *m_ysfChannelTypeText[4]; static const char *m_ysfDataTypeText[4]; @@ -123,6 +126,7 @@ private: void blockApplySettings(bool block); void applySettings(); + void updateMyPosition(); void leaveEvent(QEvent*); void enterEvent(QEvent*);