From 4f194350598ed29fc2efb78f70a7989542dfcdb9 Mon Sep 17 00:00:00 2001 From: Jens Ahrensfeld Date: Fri, 24 Jun 2022 11:29:51 +0000 Subject: [PATCH] - use Processor::Buffer for collecting symbol error - Constellation diagram uses Processor::Buffer git-svn-id: http://moon:8086/svn/software/trunk/projects/mpsk_rx_gui@1076 b431acfa-c32f-4a4a-93f1-934dc6c82436 --- Source/IQPlaneComponent.cpp | 15 ++++++--------- Source/IQPlaneComponent.h | 2 +- Source/MainComponent.h | 13 ++----------- Source/Receiver.cpp | 35 +++++++++++++---------------------- Source/Receiver.hpp | 9 ++++----- 5 files changed, 26 insertions(+), 48 deletions(-) diff --git a/Source/IQPlaneComponent.cpp b/Source/IQPlaneComponent.cpp index 60603b0..0e8a3f0 100644 --- a/Source/IQPlaneComponent.cpp +++ b/Source/IQPlaneComponent.cpp @@ -141,19 +141,16 @@ void IQPlaneComponent::trackerPointDisable(uint32_t id) m_trackerPoints[id].isEnabled = 0; } -void IQPlaneComponent::pointAdd(sym_err_t *pPoint, uint32_t numPoints) +void IQPlaneComponent::pointAdd(Processor::Buffer &points) { - uint32_t i; - uint32_t numFill; - if (m_numPoints >= m_maxNumPoints) return; - numFill = (uint32_t)dmin(m_maxNumPoints-m_numPoints, numPoints); - for (i=0; i < numFill; i++) - { - m_pPointArray[m_numPoints++] = pPoint[i]; - } + size_t nSyms = (uint32)dmin((float)128, (float)points.len()); + size_t numFill = (uint32_t)dmin(m_maxNumPoints-m_numPoints, nSyms); + points.read(&m_pPointArray[m_numPoints], numFill); + points.consume(points.len()); + m_numPoints += numFill; } float IQPlaneComponent::getScreenCoordX(float x) diff --git a/Source/IQPlaneComponent.h b/Source/IQPlaneComponent.h index 02134d2..4705ed1 100644 --- a/Source/IQPlaneComponent.h +++ b/Source/IQPlaneComponent.h @@ -46,7 +46,7 @@ public: //============================================================================== //[UserMethods] -- You can add your own custom methods in this section. - void pointAdd(sym_err_t *pPoint, uint32_t numPoints); + void pointAdd(Processor::Buffer &points); void trackerPointEnable(uint32_t id, juce::Colour color, cpx_t pos, float size); void trackerPointDisable(uint32_t id); //[/UserMethods] diff --git a/Source/MainComponent.h b/Source/MainComponent.h index d69ac21..cd3d6f9 100644 --- a/Source/MainComponent.h +++ b/Source/MainComponent.h @@ -91,20 +91,11 @@ private: void audioDeviceStopped(); void receiverDataChanged(Receiver *pObj) { - uint32_t i; - uint32 nSyms; - sym_err_t *pSoftSyms; - - nSyms = (uint32)dmin((float)128, (float)pObj->getNumSoftSym()); - pSoftSyms = pObj->getSoftSyms(); - - m_pIQPlaneComponent->pointAdd(pSoftSyms, nSyms); - - for (i=0; i < 4; i++) + m_pIQPlaneComponent->pointAdd(pObj->getSoftSyms()); + for (size_t i=0; i < 4; i++) { m_pIQPlaneComponent->trackerPointEnable(i, juce::Colours::red, ((ReceiverInterface*)pObj)->getTracker(i), 15); } - } void handleMessage(String msg) { diff --git a/Source/Receiver.cpp b/Source/Receiver.cpp index 3f9e3f9..2128791 100644 --- a/Source/Receiver.cpp +++ b/Source/Receiver.cpp @@ -41,7 +41,6 @@ Receiver::Receiver(LogHandler *pLogHandler) : m_log(pLogHandler) , m_pPassbandBuffer(0) , m_pBasebandBuffer(0) - , m_pSymbolBuffer(0) , m_ReceiverEnable(false) , m_pDataListener(0) , m_timingGenerator() @@ -93,32 +92,21 @@ void Receiver::setBufSize(uint32 size) if (m_pBasebandBuffer) delete m_pBasebandBuffer; - if (m_pSymbolBuffer) - delete m_pSymbolBuffer; - m_pPassbandBuffer = new cpx_t[size]; m_pBasebandBuffer = new cpx_t[size]; - m_pSymbolBuffer = new sym_err_t[size]; + + m_buf_symerr.resize(size); + m_buf_sym.resize(size); } m_bufsize = size; - m_buffer_agc.resize(200*size); + m_buffer_agc.resize(2*size); m_buffer_ip.resize(size); init(); } -uint32 Receiver::getNumSoftSym() +Processor::Buffer& Receiver::getSoftSyms() { - return m_numSymsInBuffer; -} - -sym_err_t Receiver::getSoftSym(uint32 index) -{ - return m_pSymbolBuffer[index]; -} - -sym_err_t* Receiver::getSoftSyms() -{ - return m_pSymbolBuffer; + return m_buf_symerr; } cpx_t Receiver::getTracker(uint32 index) @@ -438,7 +426,7 @@ void Receiver::processBaseband(CVec const &iq, uint32_t len) symbol_t sym; map_t sym_cma; static map_t sym_dfe_off; - m_numSymsInBuffer = 0; + m_buf_symerr.clear(); if (!m_ReceiverEnable) return; @@ -631,11 +619,14 @@ void Receiver::processBaseband(CVec const &iq, uint32_t len) IQ_hard_last = IQ_hard; // Call frame receiver with current symbol - m_frameReceiver.process((symbol_t)sym); + m_frameReceiver.process(sym); // Feed symbol buffer - m_pSymbolBuffer[m_numSymsInBuffer++] = sym_err; - + // m_buf_sym.write(&sym, 1); + + // Feed symbol error buffer + m_buf_symerr.write(&sym_err, 1); + // Update per-symbol statistic SymStatUpDate(&m_sym_stat, sym, &sym_err); if (m_pDataListener) diff --git a/Source/Receiver.hpp b/Source/Receiver.hpp index 6a6cae4..e74b55e 100644 --- a/Source/Receiver.hpp +++ b/Source/Receiver.hpp @@ -335,9 +335,7 @@ public: void processBaseband(radio_float_t *pI, radio_float_t *pQ, uint32_t len); void processPassband(RVec const &rf, uint32_t len); void setBufSize(uint32 size); - uint32 getNumSoftSym(); - sym_err_t getSoftSym(uint32 index); - sym_err_t* getSoftSyms(); + Processor::Buffer& getSoftSyms(); void initDefaultParams(); void addStatusListener(ReceiverStatusListener *pListener); void addDataListener(ReceiverDataListener *pListener); @@ -351,8 +349,9 @@ private: CVec m_passbandBuffer; CVec m_basebandBuffer; - sym_err_t *m_pSymbolBuffer; - uint32_t m_numSymsInBuffer; + Processor::Buffer m_buf_symerr; + Processor::Buffer m_buf_sym; + uint32_t m_bufsize; bool m_ReceiverEnable; pfd_t m_pfdCpr;