mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 23:05:36 +08:00
refs #314, modulator based classes to latest style
* removed exceptions * removed tryGet methods * adjusted samples
This commit is contained in:
@@ -44,8 +44,7 @@ namespace BlackMiscTest
|
||||
qDebug() << c1;
|
||||
|
||||
// NAV system
|
||||
CNavSystem nav1;
|
||||
CNavSystem::tryGetNav1System(nav1, 110.0);
|
||||
CNavSystem nav1 = CNavSystem::getNav1System(110.0);
|
||||
qDebug() << nav1;
|
||||
|
||||
// Transponder tests
|
||||
|
||||
@@ -35,13 +35,10 @@ namespace BlackMisc
|
||||
CModulator(name, activeFrequency, standbyFrequency == CModulator::FrequencyNotSet() ? activeFrequency : standbyFrequency, digits)
|
||||
{ }
|
||||
|
||||
//! \copydoc CValueObject::toQVariant
|
||||
virtual QVariant toQVariant() const override { return QVariant::fromValue(*this); }
|
||||
|
||||
//! Valid aviation frequency?
|
||||
bool isValidFrequency(PhysicalQuantities::CFrequency f) const
|
||||
static bool isValidFrequency(PhysicalQuantities::CFrequency f)
|
||||
{
|
||||
double fr = f.valueRounded(PhysicalQuantities::CFrequencyUnit::kHz(), this->m_digits);
|
||||
double fr = f.valueRounded(PhysicalQuantities::CFrequencyUnit::kHz(), 3);
|
||||
return fr >= 190.0 && fr <= 1750.0;
|
||||
}
|
||||
|
||||
|
||||
@@ -30,9 +30,6 @@ namespace BlackMisc
|
||||
CModulator(name, activeFrequency, standbyFrequency, digits)
|
||||
{ }
|
||||
|
||||
//! \copydoc CValueObject::toQVariant
|
||||
virtual QVariant toQVariant() const override { return QVariant::fromValue(*this); }
|
||||
|
||||
//! Set active frequency
|
||||
void setFrequencyActiveMHz(double frequencyMHz)
|
||||
{
|
||||
@@ -58,16 +55,16 @@ namespace BlackMisc
|
||||
}
|
||||
|
||||
//! Valid civil aviation frequency?
|
||||
bool isValidCivilNavigationFrequency(BlackMisc::PhysicalQuantities::CFrequency f) const
|
||||
static bool isValidCivilNavigationFrequency(BlackMisc::PhysicalQuantities::CFrequency f)
|
||||
{
|
||||
double fr = f.valueRounded(BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz(), this->m_digits);
|
||||
double fr = f.valueRounded(BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz(), 3);
|
||||
return fr >= 108.0 && fr <= 117.95;
|
||||
}
|
||||
|
||||
//! Valid military aviation frequency?
|
||||
bool isValidMilitaryNavigationFrequency(BlackMisc::PhysicalQuantities::CFrequency f) const
|
||||
static bool isValidMilitaryNavigationFrequency(BlackMisc::PhysicalQuantities::CFrequency f)
|
||||
{
|
||||
double fr = f.valueRounded(BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz(), this->m_digits);
|
||||
double fr = f.valueRounded(BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz(), 3);
|
||||
return fr >= 960.0 && fr <= 1215.0; // valid TACAN frequency
|
||||
}
|
||||
|
||||
@@ -107,6 +104,13 @@ namespace BlackMisc
|
||||
this->isValidMilitaryNavigationFrequency(this->getFrequencyStandby()));
|
||||
return v;
|
||||
}
|
||||
|
||||
private:
|
||||
//! Easy access to derived class (CRTP template parameter)
|
||||
CNavSystem const *derived() const { return static_cast<CNavSystem const *>(this); }
|
||||
|
||||
//! Easy access to derived class (CRTP template parameter)
|
||||
CNavSystem *derived() { return static_cast<CNavSystem *>(this); }
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
#ifndef BLACKMISC_AVIOTRANSPONDER_H
|
||||
#define BLACKMISC_AVIOTRANSPONDER_H
|
||||
#include "blackmisc/aviobase.h"
|
||||
#include <stdexcept>
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
@@ -116,10 +115,7 @@ namespace BlackMisc
|
||||
QString getTransponderCodeAndModeFormatted() const;
|
||||
|
||||
//! Set transponder code
|
||||
void setTransponderCode(qint32 transponderCode)
|
||||
{
|
||||
this->m_transponderCode = transponderCode;
|
||||
}
|
||||
void setTransponderCode(qint32 transponderCode) { this->m_transponderCode = transponderCode; }
|
||||
|
||||
//! Set transponder code
|
||||
void setTransponderCode(const QString &transponderCode);
|
||||
@@ -128,28 +124,16 @@ namespace BlackMisc
|
||||
static TransponderMode modeFromString(const QString &modeString);
|
||||
|
||||
//! Set transponder mode
|
||||
void setTransponderMode(TransponderMode mode)
|
||||
{
|
||||
this->m_transponderMode = mode ;
|
||||
}
|
||||
void setTransponderMode(TransponderMode mode) { this->m_transponderMode = mode ; }
|
||||
|
||||
//! Set emergency
|
||||
void setEmergency()
|
||||
{
|
||||
this->m_transponderCode = 7700;
|
||||
}
|
||||
void setEmergency() { this->m_transponderCode = 7700; }
|
||||
|
||||
//! Set VFR
|
||||
void setVFR()
|
||||
{
|
||||
this->m_transponderCode = 7000;
|
||||
}
|
||||
void setVFR() { this->m_transponderCode = 7000; }
|
||||
|
||||
//! Set IFR
|
||||
void setIFR()
|
||||
{
|
||||
this->m_transponderCode = 2000;
|
||||
}
|
||||
void setIFR() { this->m_transponderCode = 2000; }
|
||||
|
||||
//! operator ==
|
||||
bool operator ==(const CTransponder &other) const
|
||||
@@ -160,11 +144,8 @@ namespace BlackMisc
|
||||
this->CAvionicsBase::operator ==(other);
|
||||
}
|
||||
|
||||
//! operator =!
|
||||
bool operator !=(const CTransponder &other) const
|
||||
{
|
||||
return !((*this) == other);
|
||||
}
|
||||
//! operator !=
|
||||
bool operator !=(const CTransponder &other) const { return !((*this) == other); }
|
||||
|
||||
//! Transponder unit
|
||||
static CTransponder getStandardTransponder(qint32 transponderCode, TransponderMode mode)
|
||||
|
||||
@@ -68,10 +68,8 @@ namespace BlackMiscTest
|
||||
QVERIFY2(c1 != c2, "COM system shall not be equal");
|
||||
c1 = c2;
|
||||
QVERIFY2(c1 == c2, "COM system shall be equal");
|
||||
CFrequency f(100.0, CFrequencyUnit::MHz());
|
||||
CNavSystem nav1;
|
||||
QVERIFY2(CNavSystem::tryGetNav1System(nav1, 110.0), "Expect NAV system");
|
||||
QVERIFY2(!CNavSystem::tryGetNav1System(nav1, 200.0), "Expect no NAV system");
|
||||
QVERIFY2(CNavSystem::isValidCivilNavigationFrequency(CFrequency(110.0, CFrequencyUnit::MHz())), "Expect valid nav frequency");
|
||||
QVERIFY2(!CNavSystem::isValidCivilNavigationFrequency(CFrequency(200.0, CFrequencyUnit::MHz())), "Expect invalid nav frequency");
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user