From dac4bc08df9dbf3850350f306d00c6977f524adb Mon Sep 17 00:00:00 2001 From: f4exb Date: Wed, 24 Jul 2024 23:30:41 +0200 Subject: [PATCH] WDSP: sender: replaced static methods --- wdsp/RXA.cpp | 22 ++++++++++---------- wdsp/sender.cpp | 55 +++++++++++++++++++++---------------------------- wdsp/sender.hpp | 20 +++++++++--------- 3 files changed, 44 insertions(+), 53 deletions(-) diff --git a/wdsp/RXA.cpp b/wdsp/RXA.cpp index a565c8066..9f9cf68a5 100644 --- a/wdsp/RXA.cpp +++ b/wdsp/RXA.cpp @@ -201,7 +201,7 @@ RXA* RXA::create_rxa ( rxa->ndb); // addr of database pointer // Post filter display send - send spectrum display (after S-meter in the block diagram) - rxa->sender = SENDER::create_sender ( + rxa->sender = new SENDER ( 0, // run 0, // flag 0, // mode @@ -583,7 +583,7 @@ void RXA::destroy_rxa (RXA *rxa) AMD::destroy_amd (rxa->amd); AMSQ::destroy_amsq (rxa->amsq); delete (rxa->smeter); - SENDER::destroy_sender (rxa->sender); + delete (rxa->sender); delete (rxa->bpsnba); delete (rxa->nbp0); delete (rxa->ndb); @@ -610,7 +610,7 @@ void RXA::flush_rxa (RXA *rxa) rxa->adcmeter->flush(); rxa->nbp0->flush(); rxa->bpsnba->flush(); - SENDER::flush_sender (rxa->sender); + rxa->sender->flush(); rxa->smeter->flush(); AMSQ::flush_amsq (rxa->amsq); AMD::flush_amd (rxa->amd); @@ -643,7 +643,7 @@ void RXA::xrxa (RXA *rxa) rxa->bpsnba->exec_in(0); rxa->nbp0->execute(0); rxa->smeter->execute(); - SENDER::xsender (rxa->sender); + rxa->sender->execute(); AMSQ::xamsqcap (rxa->amsq); rxa->bpsnba->exec_out(0); AMD::xamd (rxa->amd); @@ -756,7 +756,7 @@ void RXA::setDSPSamplerate (RXA *rxa, int dsp_rate) rxa->nbp0->setSamplerate(rxa->dsp_rate); rxa->bpsnba->setSamplerate(rxa->dsp_rate); rxa->smeter->setSamplerate(rxa->dsp_rate); - SENDER::setSamplerate_sender (rxa->sender, rxa->dsp_rate); + rxa->sender->setSamplerate(rxa->dsp_rate); AMSQ::setSamplerate_amsq (rxa->amsq, rxa->dsp_rate); AMD::setSamplerate_amd (rxa->amd, rxa->dsp_rate); FMD::setSamplerate_fmd (rxa->fmd, rxa->dsp_rate); @@ -822,9 +822,9 @@ void RXA::setDSPBuffsize (RXA *rxa, int dsp_size) rxa->bpsnba->setBuffers(rxa->midbuff, rxa->midbuff); rxa->bpsnba->setSize(rxa->dsp_size); rxa->smeter->setBuffers(rxa->midbuff); - rxa->smeter->METER::setSize(rxa->dsp_size); - SENDER::setBuffers_sender (rxa->sender, rxa->midbuff); - SENDER::setSize_sender (rxa->sender, rxa->dsp_size); + rxa->smeter->setSize(rxa->dsp_size); + rxa->sender->setBuffers(rxa->midbuff); + rxa->sender->setSize(rxa->dsp_size); AMSQ::setBuffers_amsq (rxa->amsq, rxa->midbuff, rxa->midbuff, rxa->midbuff); AMSQ::setSize_amsq (rxa->amsq, rxa->dsp_size); AMD::setBuffers_amd (rxa->amd, rxa->midbuff, rxa->midbuff); @@ -847,8 +847,8 @@ void RXA::setDSPBuffsize (RXA *rxa, int dsp_size) BANDPASS::setSize_bandpass (rxa->bp1, rxa->dsp_size); WCPAGC::setBuffers_wcpagc (rxa->agc, rxa->midbuff, rxa->midbuff); WCPAGC::setSize_wcpagc (rxa->agc, rxa->dsp_size); - rxa->agcmeter->METER::setBuffers(rxa->midbuff); - rxa->agcmeter->METER::setSize(rxa->dsp_size); + rxa->agcmeter->setBuffers(rxa->midbuff); + rxa->agcmeter->setSize(rxa->dsp_size); SIPHON::setBuffers_siphon (rxa->sip1, rxa->midbuff); SIPHON::setSize_siphon (rxa->sip1, rxa->dsp_size); CBL::setBuffers_cbl (rxa->cbl, rxa->midbuff, rxa->midbuff); @@ -868,7 +868,7 @@ void RXA::setDSPBuffsize (RXA *rxa, int dsp_size) void RXA::setSpectrumProbe(BufferProbe *spectrumProbe) { - SENDER::SetSpectrum(*this, 1, spectrumProbe); + sender->SetSpectrum(1, spectrumProbe); sender->run = 1; } diff --git a/wdsp/sender.cpp b/wdsp/sender.cpp index 9af4b8231..e8aaf811d 100644 --- a/wdsp/sender.cpp +++ b/wdsp/sender.cpp @@ -32,37 +32,30 @@ warren@wpratt.com namespace WDSP { -SENDER* SENDER::create_sender (int run, int flag, int mode, int size, float* in) +SENDER::SENDER(int _run, int _flag, int _mode, int _size, float* _in) : + run(_run), + flag(_flag), + mode(_mode), + size(_size), + in(_in) { - SENDER *a = new SENDER; - a->run = run; - a->flag = flag; - a->mode = mode; - a->size = size; - a->in = in; - a->spectrumProbe = nullptr; - return a; + spectrumProbe = nullptr; } -void SENDER::destroy_sender (SENDER *a) -{ - delete (a); -} - -void SENDER::flush_sender (SENDER *) +void SENDER::flush() { } -void SENDER::xsender (SENDER *a) +void SENDER::execute() { - if (a->run && a->flag) + if (run && flag) { - switch (a->mode) + switch (mode) { case 0: { - if (a->spectrumProbe) { - a->spectrumProbe->proceed(a->in, a->size); + if (spectrumProbe) { + spectrumProbe->proceed(in, size); } break; } @@ -70,33 +63,31 @@ void SENDER::xsender (SENDER *a) } } -void SENDER::setBuffers_sender (SENDER *a, float* in) +void SENDER::setBuffers(float* _in) { - a->in = in; + in = _in; } -void SENDER::setSamplerate_sender (SENDER *a, int) +void SENDER::setSamplerate(int) { - flush_sender (a); + flush(); } -void SENDER::setSize_sender (SENDER *a, int size) +void SENDER::setSize(int _size) { - a->size = size; + size = _size; } /******************************************************************************************************** * * -* RXA Properties * +* Public Properties * * * ********************************************************************************************************/ -void SENDER::SetSpectrum (RXA& rxa, int flag, BufferProbe *spectrumProbe) +void SENDER::SetSpectrum(int _flag, BufferProbe *_spectrumProbe) { - SENDER *a; - a = rxa.sender; - a->flag = flag; - a->spectrumProbe = spectrumProbe; + flag = _flag; + spectrumProbe = _spectrumProbe; } } // namespace WDSP diff --git a/wdsp/sender.hpp b/wdsp/sender.hpp index 23c6752e8..a174690b2 100644 --- a/wdsp/sender.hpp +++ b/wdsp/sender.hpp @@ -50,16 +50,16 @@ public: float* in; // buffer from which to take the data BufferProbe *spectrumProbe; // this is the data handler actually - static SENDER* create_sender (int run, int flag, int mode, int size, float* in); - static void destroy_sender (SENDER *a); - static void flush_sender (SENDER *a); - static void xsender (SENDER *a); - static void setBuffers_sender (SENDER *a, float* in); - static void setSamplerate_sender (SENDER *a, int rate); - static void setSize_sender (SENDER *a, int size); - // RXA Properties - static void SetSpectrum (RXA& rxa, int flag, BufferProbe *spectrumProbe); - // TXA Properties + SENDER(int run, int flag, int mode, int size, float* in); + ~SENDER() = default; + + void flush(); + void execute(); + void setBuffers(float* in); + void setSamplerate(int rate); + void setSize(int size); + // Public Properties + void SetSpectrum(int flag, BufferProbe *spectrumProbe); }; } // namespace WDSP