From d6cc6e3dd3711da76e86d5906c24bbef5daad758 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Mon, 10 Nov 2014 20:40:56 +0100 Subject: [PATCH] refs #288, made setFrequency methods virtual * rounding in setFrequency of com system * minor fixes in com/modulator --- src/blackmisc/aviocomsystem.cpp | 36 +++++++++++++++++++++++++++------ src/blackmisc/aviocomsystem.h | 12 +++++++++-- src/blackmisc/aviomodulator.h | 10 ++++----- 3 files changed, 45 insertions(+), 13 deletions(-) diff --git a/src/blackmisc/aviocomsystem.cpp b/src/blackmisc/aviocomsystem.cpp index 9ecbf6ad4..9930317b4 100644 --- a/src/blackmisc/aviocomsystem.cpp +++ b/src/blackmisc/aviocomsystem.cpp @@ -30,20 +30,44 @@ namespace BlackMisc CComSystem::isValidMilitaryFrequency(this->getFrequencyStandby())); } + /* + * COM frequency + */ void CComSystem::setFrequencyActiveMHz(double frequencyMHz) { CFrequency f(frequencyMHz, CFrequencyUnit::MHz()); - if (f == this->getFrequencyActive()) return; // save all the comparisons / rounding - CComSystem::roundToChannelSpacing(f, this->m_channelSpacing); - this->CModulator::setFrequencyActive(f); + this->setFrequencyActive(f); } + /* + * COM frequency + */ void CComSystem::setFrequencyStandbyMHz(double frequencyMHz) { CFrequency f(frequencyMHz, CFrequencyUnit::MHz()); - if (f == this->getFrequencyStandby()) return; // save all the comparisons / rounding - CComSystem::roundToChannelSpacing(f, this->m_channelSpacing); - CModulator::setFrequencyStandby(f); + this->setFrequencyStandby(f); + } + + /* + * COM frequency + */ + void CComSystem::setFrequencyActive(const CFrequency &frequency) + { + if (frequency == this->getFrequencyActive()) { return; } // save all the comparisons / rounding + CFrequency fRounded(frequency); + roundToChannelSpacing(fRounded, this->m_channelSpacing); + this->CModulator::setFrequencyActive(fRounded); + } + + /* + * COM frequency + */ + void CComSystem::setFrequencyStandby(const CFrequency &frequency) + { + if (frequency == this->getFrequencyStandby()) { return; } // save all the comparisons / rounding + CFrequency fRounded(frequency); + roundToChannelSpacing(fRounded, this->m_channelSpacing); + this->CModulator::setFrequencyStandby(fRounded); } /* diff --git a/src/blackmisc/aviocomsystem.h b/src/blackmisc/aviocomsystem.h index e0121205d..0b7642d45 100644 --- a/src/blackmisc/aviocomsystem.h +++ b/src/blackmisc/aviocomsystem.h @@ -54,11 +54,19 @@ namespace BlackMisc //! Set active frequency //! \remarks will be rounded to channel spacing - void setFrequencyActiveMHz(double frequencyMHz); + virtual void setFrequencyActiveMHz(double frequencyMHz) override; //! Set standby frequency //! \remarks will be rounded to channel spacing - void setFrequencyStandbyMHz(double frequencyMHz); + virtual void setFrequencyStandbyMHz(double frequencyMHz) override; + + //! Set active frequency + //! \remarks will be rounded to channel spacing + virtual void setFrequencyActive(const BlackMisc::PhysicalQuantities::CFrequency &frequency) override; + + //! Set active frequency + //! \remarks will be rounded to channel spacing + virtual void setFrequencyStandby(const BlackMisc::PhysicalQuantities::CFrequency &frequency) override; //! Is active frequency within 8.3383kHz channel? bool isActiveFrequencyWithin8_33kHzChannel(const BlackMisc::PhysicalQuantities::CFrequency &comFrequency) const diff --git a/src/blackmisc/aviomodulator.h b/src/blackmisc/aviomodulator.h index b35adaac7..85ec0863c 100644 --- a/src/blackmisc/aviomodulator.h +++ b/src/blackmisc/aviomodulator.h @@ -41,7 +41,7 @@ namespace BlackMisc //! Default value? virtual bool isDefaultValue() const { - return this->m_frequencyActive == CModulator::FrequencyNotSet(); + return (this->m_frequencyActive == FrequencyNotSet()); } //! Toggle active and standby frequencies @@ -60,13 +60,13 @@ namespace BlackMisc } //! Set active frequency - void setFrequencyActive(const BlackMisc::PhysicalQuantities::CFrequency &frequency) + virtual void setFrequencyActive(const BlackMisc::PhysicalQuantities::CFrequency &frequency) { this->m_frequencyActive = frequency; } //! Set standby frequency - void setFrequencyStandby(const BlackMisc::PhysicalQuantities::CFrequency &frequency) + virtual void setFrequencyStandby(const BlackMisc::PhysicalQuantities::CFrequency &frequency) { this->m_frequencyStandby = frequency; } @@ -126,14 +126,14 @@ namespace BlackMisc } //! Set active frequency - void setFrequencyActiveMHz(double frequencyMHz) + virtual void setFrequencyActiveMHz(double frequencyMHz) { frequencyMHz = Math::CMath::round(frequencyMHz, 3); this->m_frequencyActive = BlackMisc::PhysicalQuantities::CFrequency(frequencyMHz, BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz()); } //! Set standby frequency - void setFrequencyStandbyMHz(double frequencyMHz) + virtual void setFrequencyStandbyMHz(double frequencyMHz) { frequencyMHz = Math::CMath::round(frequencyMHz, 3); this->m_frequencyStandby = BlackMisc::PhysicalQuantities::CFrequency(frequencyMHz, BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz());