mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-05-05 01:35:45 +08:00
refs #192, some housekeeping during the JSON introduction
* removed unused tryGet methods for transponder / COM * adjusted unit tests
This commit is contained in:
@@ -135,181 +135,52 @@ namespace BlackMisc
|
|||||||
//! \copydoc CValueObject::fromJson
|
//! \copydoc CValueObject::fromJson
|
||||||
virtual void fromJson(const QJsonObject &json) override;
|
virtual void fromJson(const QJsonObject &json) override;
|
||||||
|
|
||||||
/*!
|
//! \brief Members
|
||||||
* Try to get a COM unit with given name and frequency. Returns true in case an object
|
static const QStringList &jsonMembers();
|
||||||
* has been sucessfully created, otherwise returns a default object.
|
|
||||||
* \param[out] o_comSystem
|
|
||||||
* \param name
|
|
||||||
* \param activeFrequencyMHz
|
|
||||||
* \param standbyFrequencyMHz
|
|
||||||
* \return
|
|
||||||
*/
|
|
||||||
static bool tryGetComSystem(CComSystem &o_comSystem, const QString &name, double activeFrequencyMHz, double standbyFrequencyMHz = -1)
|
|
||||||
{
|
|
||||||
o_comSystem = CComSystem(false, name, BlackMisc::PhysicalQuantities::CFrequency(activeFrequencyMHz, BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz()), BlackMisc::PhysicalQuantities::CFrequency(standbyFrequencyMHz < 0 ? activeFrequencyMHz : standbyFrequencyMHz, BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz()));
|
|
||||||
bool s;
|
|
||||||
if (!(s = o_comSystem.validate(false))) o_comSystem = CComSystem(); // reset to default
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
//! \brief operator ==
|
||||||
* Try to get a COM unit with given name and frequency. Returns true in case an object
|
bool operator ==(const CComSystem &other) const;
|
||||||
* has been sucessfully created, otherwise returns a default object.
|
|
||||||
* \param[out] o_comSystem
|
|
||||||
* \param name
|
|
||||||
* \param activeFrequency
|
|
||||||
* \param standbyFrequency
|
|
||||||
* \return
|
|
||||||
*/
|
|
||||||
static bool tryGetComSystem(CComSystem &o_comSystem, const QString &name, BlackMisc::PhysicalQuantities::CFrequency activeFrequency, BlackMisc::PhysicalQuantities::CFrequency standbyFrequency = CModulator::FrequencyNotSet())
|
|
||||||
{
|
|
||||||
o_comSystem = CComSystem(false, name, activeFrequency, standbyFrequency);
|
|
||||||
bool s;
|
|
||||||
if (!(s = o_comSystem.validate(false))) o_comSystem = CComSystem(); // reset to default
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
//! \brief operator !=
|
||||||
* \brief COM1 unit
|
bool operator !=(const CComSystem &other) const;
|
||||||
* \param activeFrequencyMHz
|
|
||||||
* \param standbyFrequencyMHz
|
//! \brief COM1 unit
|
||||||
* \return
|
|
||||||
*/
|
|
||||||
static CComSystem getCom1System(double activeFrequencyMHz, double standbyFrequencyMHz = -1)
|
static CComSystem getCom1System(double activeFrequencyMHz, double standbyFrequencyMHz = -1)
|
||||||
{
|
{
|
||||||
return CComSystem(CModulator::NameCom1(), BlackMisc::PhysicalQuantities::CFrequency(activeFrequencyMHz, BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz()), BlackMisc::PhysicalQuantities::CFrequency(standbyFrequencyMHz < 0 ? activeFrequencyMHz : standbyFrequencyMHz, BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz()));
|
return CComSystem(CModulator::NameCom1(), BlackMisc::PhysicalQuantities::CFrequency(activeFrequencyMHz, BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz()), BlackMisc::PhysicalQuantities::CFrequency(standbyFrequencyMHz < 0 ? activeFrequencyMHz : standbyFrequencyMHz, BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
//! \brief COM1 unit
|
||||||
* \brief COM1 unit
|
|
||||||
* \param activeFrequency
|
|
||||||
* \param standbyFrequency
|
|
||||||
* \return
|
|
||||||
*/
|
|
||||||
static CComSystem getCom1System(BlackMisc::PhysicalQuantities::CFrequency activeFrequency, BlackMisc::PhysicalQuantities::CFrequency standbyFrequency = CModulator::FrequencyNotSet())
|
static CComSystem getCom1System(BlackMisc::PhysicalQuantities::CFrequency activeFrequency, BlackMisc::PhysicalQuantities::CFrequency standbyFrequency = CModulator::FrequencyNotSet())
|
||||||
{
|
{
|
||||||
return CComSystem(CModulator::NameCom1(), activeFrequency, standbyFrequency == CModulator::FrequencyNotSet() ? activeFrequency : standbyFrequency);
|
return CComSystem(CModulator::NameCom1(), activeFrequency, standbyFrequency == CModulator::FrequencyNotSet() ? activeFrequency : standbyFrequency);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
//! \brief COM2 unit
|
||||||
* \brief Try to get COM unit
|
|
||||||
* \param[out] o_comSystem
|
|
||||||
* \param activeFrequencyMHz
|
|
||||||
* \param standbyFrequencyMHz
|
|
||||||
* \return
|
|
||||||
*/
|
|
||||||
static bool tryGetCom1Unit(CComSystem &o_comSystem, double activeFrequencyMHz, double standbyFrequencyMHz = -1)
|
|
||||||
{
|
|
||||||
return CComSystem::tryGetComSystem(o_comSystem, CModulator::NameCom1(), activeFrequencyMHz, standbyFrequencyMHz);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief Try to get COM unit
|
|
||||||
* \param[out] o_comSystem
|
|
||||||
* \param activeFrequency
|
|
||||||
* \param standbyFrequency
|
|
||||||
* \return
|
|
||||||
*/
|
|
||||||
static bool tryGetCom1Unit(CComSystem &o_comSystem, BlackMisc::PhysicalQuantities::CFrequency activeFrequency, BlackMisc::PhysicalQuantities::CFrequency standbyFrequency = CModulator::FrequencyNotSet())
|
|
||||||
{
|
|
||||||
return CComSystem::tryGetComSystem(o_comSystem, CModulator::NameCom1(), activeFrequency, standbyFrequency);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief COM2 unit
|
|
||||||
* \param activeFrequencyMHz
|
|
||||||
* \param standbyFrequencyMHz
|
|
||||||
* \return
|
|
||||||
*/
|
|
||||||
static CComSystem getCom2System(double activeFrequencyMHz, double standbyFrequencyMHz = -1)
|
static CComSystem getCom2System(double activeFrequencyMHz, double standbyFrequencyMHz = -1)
|
||||||
{
|
{
|
||||||
return CComSystem(CModulator::NameCom2(), BlackMisc::PhysicalQuantities::CFrequency(activeFrequencyMHz, BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz()), BlackMisc::PhysicalQuantities::CFrequency(standbyFrequencyMHz < 0 ? activeFrequencyMHz : standbyFrequencyMHz, BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz()));
|
return CComSystem(CModulator::NameCom2(), BlackMisc::PhysicalQuantities::CFrequency(activeFrequencyMHz, BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz()), BlackMisc::PhysicalQuantities::CFrequency(standbyFrequencyMHz < 0 ? activeFrequencyMHz : standbyFrequencyMHz, BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
//! \brief COM2 unit
|
||||||
* \brief COM2 unit
|
|
||||||
* \param activeFrequency
|
|
||||||
* \param standbyFrequency
|
|
||||||
* \return
|
|
||||||
*/
|
|
||||||
static CComSystem getCom2System(BlackMisc::PhysicalQuantities::CFrequency activeFrequency, BlackMisc::PhysicalQuantities::CFrequency standbyFrequency = CModulator::FrequencyNotSet())
|
static CComSystem getCom2System(BlackMisc::PhysicalQuantities::CFrequency activeFrequency, BlackMisc::PhysicalQuantities::CFrequency standbyFrequency = CModulator::FrequencyNotSet())
|
||||||
{
|
{
|
||||||
return CComSystem(CModulator::NameCom2(), activeFrequency, standbyFrequency == CModulator::FrequencyNotSet() ? activeFrequency : standbyFrequency);
|
return CComSystem(CModulator::NameCom2(), activeFrequency, standbyFrequency == CModulator::FrequencyNotSet() ? activeFrequency : standbyFrequency);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
//! \brief COM3 unit
|
||||||
* \brief Try to get COM unit
|
|
||||||
* \param[out] o_comSystem
|
|
||||||
* \param activeFrequencyMHz
|
|
||||||
* \param standbyFrequencyMHz
|
|
||||||
* \return
|
|
||||||
*/
|
|
||||||
static bool tryGetCom2System(CComSystem &o_comSystem, double activeFrequencyMHz, double standbyFrequencyMHz = -1)
|
|
||||||
{
|
|
||||||
return CComSystem::tryGetComSystem(o_comSystem, CModulator::NameCom2(), activeFrequencyMHz, standbyFrequencyMHz);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief Try to get COM unit
|
|
||||||
* \param[out] o_comSystem
|
|
||||||
* \param activeFrequency
|
|
||||||
* \param standbyFrequency
|
|
||||||
* \return
|
|
||||||
*/
|
|
||||||
static bool tryGetCom2System(CComSystem &o_comSystem, BlackMisc::PhysicalQuantities::CFrequency activeFrequency, BlackMisc::PhysicalQuantities::CFrequency standbyFrequency = CModulator::FrequencyNotSet())
|
|
||||||
{
|
|
||||||
return CComSystem::tryGetComSystem(o_comSystem, CModulator::NameCom2(), activeFrequency, standbyFrequency);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief COM3 unit
|
|
||||||
* \param activeFrequencyMHz
|
|
||||||
* \param standbyFrequencyMHz
|
|
||||||
* \return
|
|
||||||
*/
|
|
||||||
static CComSystem getCom3System(double activeFrequencyMHz, double standbyFrequencyMHz = -1)
|
static CComSystem getCom3System(double activeFrequencyMHz, double standbyFrequencyMHz = -1)
|
||||||
{
|
{
|
||||||
return CComSystem(CModulator::NameCom3(), BlackMisc::PhysicalQuantities::CFrequency(activeFrequencyMHz, BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz()), BlackMisc::PhysicalQuantities::CFrequency(standbyFrequencyMHz < 0 ? activeFrequencyMHz : standbyFrequencyMHz, BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz()));
|
return CComSystem(CModulator::NameCom3(), BlackMisc::PhysicalQuantities::CFrequency(activeFrequencyMHz, BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz()), BlackMisc::PhysicalQuantities::CFrequency(standbyFrequencyMHz < 0 ? activeFrequencyMHz : standbyFrequencyMHz, BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
//! \brief COM3 unit
|
||||||
* \brief COM3 unit
|
|
||||||
* \param activeFrequency
|
|
||||||
* \param standbyFrequency
|
|
||||||
* \return
|
|
||||||
*/
|
|
||||||
static CComSystem getCom3System(BlackMisc::PhysicalQuantities::CFrequency activeFrequency, BlackMisc::PhysicalQuantities::CFrequency standbyFrequency = CModulator::FrequencyNotSet())
|
static CComSystem getCom3System(BlackMisc::PhysicalQuantities::CFrequency activeFrequency, BlackMisc::PhysicalQuantities::CFrequency standbyFrequency = CModulator::FrequencyNotSet())
|
||||||
{
|
{
|
||||||
return CComSystem(CModulator::NameCom3(), activeFrequency, standbyFrequency == CModulator::FrequencyNotSet() ? activeFrequency : standbyFrequency);
|
return CComSystem(CModulator::NameCom3(), activeFrequency, standbyFrequency == CModulator::FrequencyNotSet() ? activeFrequency : standbyFrequency);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
//! \brief Valid civil aviation frequency?
|
||||||
* \brief Try to get COM unit
|
|
||||||
* \param[out] o_comSystem
|
|
||||||
* \param activeFrequencyMHz
|
|
||||||
* \param standbyFrequencyMHz
|
|
||||||
* \return
|
|
||||||
*/
|
|
||||||
static bool tryGetCom3System(CComSystem &o_comSystem, double activeFrequencyMHz, double standbyFrequencyMHz = -1)
|
|
||||||
{
|
|
||||||
return CComSystem::tryGetComSystem(o_comSystem, CModulator::NameCom3(), activeFrequencyMHz, standbyFrequencyMHz);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief Try to get COM unit
|
|
||||||
* \param[out] o_comSystem
|
|
||||||
* \param activeFrequency
|
|
||||||
* \param standbyFrequency
|
|
||||||
* \return
|
|
||||||
*/
|
|
||||||
static bool tryGetCom3System(CComSystem &o_comSystem, BlackMisc::PhysicalQuantities::CFrequency activeFrequency, BlackMisc::PhysicalQuantities::CFrequency standbyFrequency = CModulator::FrequencyNotSet())
|
|
||||||
{
|
|
||||||
return CComSystem::tryGetComSystem(o_comSystem, CModulator::NameCom3(), activeFrequency, standbyFrequency);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief Valid civil aviation frequency?
|
|
||||||
*/
|
|
||||||
static bool isValidCivilAviationFrequency(const BlackMisc::PhysicalQuantities::CFrequency &f)
|
static bool isValidCivilAviationFrequency(const BlackMisc::PhysicalQuantities::CFrequency &f)
|
||||||
{
|
{
|
||||||
double fr = f.valueRounded(BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz(), 3);
|
double fr = f.valueRounded(BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz(), 3);
|
||||||
|
|||||||
@@ -34,45 +34,8 @@ namespace BlackMisc
|
|||||||
qint32 m_transponderCode; //<! Transponder code
|
qint32 m_transponderCode; //<! Transponder code
|
||||||
TransponderMode m_transponderMode; //<! Transponder mode
|
TransponderMode m_transponderMode; //<! Transponder mode
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief Constructor for validation
|
|
||||||
* \param validate
|
|
||||||
* \param name
|
|
||||||
* \param transponderCode
|
|
||||||
* \param transponderMode
|
|
||||||
*/
|
|
||||||
CTransponder(bool validate, const QString &name, qint32 transponderCode, TransponderMode transponderMode) :
|
|
||||||
CAvionicsBase(name), m_transponderCode(transponderCode), m_transponderMode(transponderMode)
|
|
||||||
{
|
|
||||||
this->validate(validate);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief Constructor for validation
|
|
||||||
* \param validate
|
|
||||||
* \param name
|
|
||||||
* \param transponderCode
|
|
||||||
* \param transponderMode
|
|
||||||
*/
|
|
||||||
CTransponder(bool validate, const QString &name, const QString transponderCode, TransponderMode transponderMode) :
|
|
||||||
CAvionicsBase(name), m_transponderCode(0), m_transponderMode(transponderMode)
|
|
||||||
{
|
|
||||||
bool ok = false;
|
|
||||||
this->m_transponderCode = transponderCode.toUInt(&ok);
|
|
||||||
if (!ok) this->m_transponderCode = -1; // will cause assert / exception
|
|
||||||
this->validate(validate);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/*!
|
//! \brief Default value?
|
||||||
* \copydoc CAvionicsBase::validValues
|
|
||||||
*/
|
|
||||||
virtual bool validValues() const override;
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief Default value
|
|
||||||
* \return
|
|
||||||
*/
|
|
||||||
virtual bool isDefaultValue() const
|
virtual bool isDefaultValue() const
|
||||||
{
|
{
|
||||||
return this->m_transponderCode == 0;
|
return this->m_transponderCode == 0;
|
||||||
@@ -100,36 +63,21 @@ namespace BlackMisc
|
|||||||
virtual int compareImpl(const CValueObject &other) const override;
|
virtual int compareImpl(const CValueObject &other) const override;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/*!
|
//! \brief Default constructor
|
||||||
* Default constructor
|
|
||||||
*/
|
|
||||||
CTransponder() : CAvionicsBase("transponder"), m_transponderCode(0), m_transponderMode(ModeS) {}
|
CTransponder() : CAvionicsBase("transponder"), m_transponderCode(0), m_transponderMode(ModeS) {}
|
||||||
|
|
||||||
/*!
|
//! \brief Copy constructor
|
||||||
* \brief Copy constructor
|
|
||||||
* \param other
|
|
||||||
*/
|
|
||||||
CTransponder(const CTransponder &other) : CAvionicsBase(other.getName()),
|
CTransponder(const CTransponder &other) : CAvionicsBase(other.getName()),
|
||||||
m_transponderCode(other.m_transponderCode), m_transponderMode(other.m_transponderMode) {}
|
m_transponderCode(other.m_transponderCode), m_transponderMode(other.m_transponderMode) {}
|
||||||
|
|
||||||
/*!
|
//! \brief Constructor
|
||||||
* \brief Constructor
|
|
||||||
* \param name
|
|
||||||
* \param transponderCode
|
|
||||||
* \param transponderMode
|
|
||||||
*/
|
|
||||||
CTransponder(const QString &name, qint32 transponderCode, TransponderMode transponderMode) :
|
CTransponder(const QString &name, qint32 transponderCode, TransponderMode transponderMode) :
|
||||||
CAvionicsBase(name), m_transponderCode(transponderCode), m_transponderMode(transponderMode)
|
CAvionicsBase(name), m_transponderCode(transponderCode), m_transponderMode(transponderMode)
|
||||||
{
|
{
|
||||||
this->validate(true);
|
this->validate(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
//! \brief Constructor with transponder mode as string
|
||||||
* \brief Constructor
|
|
||||||
* \param name
|
|
||||||
* \param transponderCode
|
|
||||||
* \param transponderMode
|
|
||||||
*/
|
|
||||||
CTransponder(const QString &name, qint32 transponderCode, QString transponderMode) :
|
CTransponder(const QString &name, qint32 transponderCode, QString transponderMode) :
|
||||||
CAvionicsBase(name), m_transponderCode(transponderCode), m_transponderMode(StateStandby)
|
CAvionicsBase(name), m_transponderCode(transponderCode), m_transponderMode(StateStandby)
|
||||||
{
|
{
|
||||||
@@ -137,12 +85,7 @@ namespace BlackMisc
|
|||||||
this->validate(true);
|
this->validate(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
//! \brief Constructor, code as string
|
||||||
* \brief Constructor
|
|
||||||
* \param name
|
|
||||||
* \param transponderCode
|
|
||||||
* \param transponderMode
|
|
||||||
*/
|
|
||||||
CTransponder(const QString &name, QString transponderCode, TransponderMode transponderMode) :
|
CTransponder(const QString &name, QString transponderCode, TransponderMode transponderMode) :
|
||||||
CAvionicsBase(name), m_transponderCode(0), m_transponderMode(transponderMode)
|
CAvionicsBase(name), m_transponderCode(0), m_transponderMode(transponderMode)
|
||||||
{
|
{
|
||||||
@@ -152,12 +95,7 @@ namespace BlackMisc
|
|||||||
this->validate(true);
|
this->validate(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
//! \brief Constructor
|
||||||
* \brief Constructor
|
|
||||||
* \param name
|
|
||||||
* \param transponderCode
|
|
||||||
* \param transponderMode
|
|
||||||
*/
|
|
||||||
CTransponder(const QString &name, QString transponderCode, QString transponderMode) :
|
CTransponder(const QString &name, QString transponderCode, QString transponderMode) :
|
||||||
CAvionicsBase(name), m_transponderCode(0), m_transponderMode(StateStandby)
|
CAvionicsBase(name), m_transponderCode(0), m_transponderMode(StateStandby)
|
||||||
{
|
{
|
||||||
@@ -168,9 +106,27 @@ namespace BlackMisc
|
|||||||
this->validate(true);
|
this->validate(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
//! \brief Constructor for validation, used with test cases
|
||||||
* \copydoc CValueObject::toQVariant
|
CTransponder(bool validate, const QString &name, qint32 transponderCode, TransponderMode transponderMode) :
|
||||||
*/
|
CAvionicsBase(name), m_transponderCode(transponderCode), m_transponderMode(transponderMode)
|
||||||
|
{
|
||||||
|
this->validate(validate);
|
||||||
|
}
|
||||||
|
|
||||||
|
//! \brief Constructor for validation, used with test cases
|
||||||
|
CTransponder(bool validate, const QString &name, const QString transponderCode, TransponderMode transponderMode) :
|
||||||
|
CAvionicsBase(name), m_transponderCode(0), m_transponderMode(transponderMode)
|
||||||
|
{
|
||||||
|
bool ok = false;
|
||||||
|
this->m_transponderCode = transponderCode.toUInt(&ok);
|
||||||
|
if (!ok) this->m_transponderCode = -1; // will cause assert / exception
|
||||||
|
this->validate(validate);
|
||||||
|
}
|
||||||
|
|
||||||
|
//! \copydoc CAvionicsBase::validValues
|
||||||
|
virtual bool validValues() const override;
|
||||||
|
|
||||||
|
//! \copydoc CValueObject::toQVariant
|
||||||
virtual QVariant toQVariant() const override
|
virtual QVariant toQVariant() const override
|
||||||
{
|
{
|
||||||
return QVariant::fromValue(*this);
|
return QVariant::fromValue(*this);
|
||||||
@@ -250,75 +206,12 @@ namespace BlackMisc
|
|||||||
return !((*this) == other);
|
return !((*this) == other);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
//! \brief Transponder unit
|
||||||
* Try to get a Transponder unit with given name and code. Returns true in case an object
|
|
||||||
* has been sucessfully created, otherwise returns a default object.
|
|
||||||
* \param[out] o_transponder
|
|
||||||
* \param name
|
|
||||||
* \param transponderCode
|
|
||||||
* \param mode
|
|
||||||
* \return
|
|
||||||
*/
|
|
||||||
static bool tryGetTransponder(CTransponder &o_transponder, const QString &name, qint32 transponderCode, TransponderMode mode)
|
|
||||||
{
|
|
||||||
o_transponder = CTransponder(false, name, transponderCode, mode);
|
|
||||||
bool s;
|
|
||||||
if (!(s = o_transponder.validate(false))) o_transponder = CTransponder(); // reset to default
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* Try to get a Transponder unit with given name and code. Returns true in case an object
|
|
||||||
* has been sucessfully created, otherwise returns a default object.
|
|
||||||
* \param[out] o_transponder
|
|
||||||
* \param name
|
|
||||||
* \param transponderCode
|
|
||||||
* \param mode
|
|
||||||
* \return
|
|
||||||
*/
|
|
||||||
static bool tryGetTransponder(CTransponder &o_transponder, const QString &name, const QString &transponderCode, TransponderMode mode)
|
|
||||||
{
|
|
||||||
o_transponder = CTransponder(false, name, transponderCode, mode);
|
|
||||||
bool s;
|
|
||||||
if (!(s = o_transponder.validate(false))) o_transponder = CTransponder(); // reset to default
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief Transponder unit
|
|
||||||
* \param transponderCode
|
|
||||||
* \param mode
|
|
||||||
* \return
|
|
||||||
*/
|
|
||||||
static CTransponder getStandardTransponder(qint32 transponderCode, TransponderMode mode)
|
static CTransponder getStandardTransponder(qint32 transponderCode, TransponderMode mode)
|
||||||
{
|
{
|
||||||
return CTransponder("Transponder", transponderCode, mode);
|
return CTransponder("Transponder", transponderCode, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief Try to get Transponder unit
|
|
||||||
* \param[out] o_transponder
|
|
||||||
* \param transponderCode
|
|
||||||
* \param mode
|
|
||||||
* \return
|
|
||||||
*/
|
|
||||||
static bool tryGetStandardTransponder(CTransponder &o_transponder, qint32 transponderCode, TransponderMode mode)
|
|
||||||
{
|
|
||||||
return CTransponder::tryGetTransponder(o_transponder, "Transponder", transponderCode, mode);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief Try to get Transponder unit
|
|
||||||
* \param[out] o_transponder
|
|
||||||
* \param transponderCode
|
|
||||||
* \param mode
|
|
||||||
* \return
|
|
||||||
*/
|
|
||||||
static bool tryGetStandardTransponder(CTransponder &o_transponder, const QString &transponderCode, TransponderMode mode)
|
|
||||||
{
|
|
||||||
return CTransponder::tryGetTransponder(o_transponder, "Transponder", transponderCode, mode);
|
|
||||||
}
|
|
||||||
|
|
||||||
//! \copydoc CValueObject::getValueHash()
|
//! \copydoc CValueObject::getValueHash()
|
||||||
virtual uint getValueHash() const override;
|
virtual uint getValueHash() const override;
|
||||||
|
|
||||||
@@ -343,7 +236,7 @@ namespace BlackMisc
|
|||||||
} // namespace
|
} // namespace
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
BLACK_DECLARE_TUPLE_CONVERSION(BlackMisc::Aviation::CTransponder, (o.m_transponderCode))
|
BLACK_DECLARE_TUPLE_CONVERSION(BlackMisc::Aviation::CTransponder, (o.m_transponderCode, o.m_transponderMode))
|
||||||
Q_DECLARE_METATYPE(BlackMisc::Aviation::CTransponder)
|
Q_DECLARE_METATYPE(BlackMisc::Aviation::CTransponder)
|
||||||
|
|
||||||
#endif // guard
|
#endif // guard
|
||||||
|
|||||||
@@ -177,7 +177,8 @@ bool BlackMisc::equalQVariants(const QVariant &v1, const QVariant &v2)
|
|||||||
const CValueObject *cs2 = CValueObject::fromQVariant(v2);
|
const CValueObject *cs2 = CValueObject::fromQVariant(v2);
|
||||||
if (cs1 && cs2)
|
if (cs1 && cs2)
|
||||||
{
|
{
|
||||||
return compare(*cs1, *cs2) == 0;
|
int c = compare(*cs1, *cs2);
|
||||||
|
return c == 0;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,7 +69,6 @@ namespace BlackMiscTest
|
|||||||
c1 = c2;
|
c1 = c2;
|
||||||
QVERIFY2(c1 == c2, "COM system shall be equal");
|
QVERIFY2(c1 == c2, "COM system shall be equal");
|
||||||
CFrequency f(100.0, CFrequencyUnit::MHz());
|
CFrequency f(100.0, CFrequencyUnit::MHz());
|
||||||
QVERIFY2(!CComSystem::tryGetComSystem(c1, "no valid unit", f), "Expect not to get COM system");
|
|
||||||
CNavSystem nav1;
|
CNavSystem nav1;
|
||||||
QVERIFY2(CNavSystem::tryGetNav1System(nav1, 110.0), "Expect NAV system");
|
QVERIFY2(CNavSystem::tryGetNav1System(nav1, 110.0), "Expect NAV system");
|
||||||
QVERIFY2(!CNavSystem::tryGetNav1System(nav1, 200.0), "Expect no NAV system");
|
QVERIFY2(!CNavSystem::tryGetNav1System(nav1, 200.0), "Expect no NAV system");
|
||||||
@@ -85,12 +84,16 @@ namespace BlackMiscTest
|
|||||||
QVERIFY2(t1 == t2, "Transponders shall be equal");
|
QVERIFY2(t1 == t2, "Transponders shall be equal");
|
||||||
t2.setTransponderMode(CTransponder::ModeC);
|
t2.setTransponderMode(CTransponder::ModeC);
|
||||||
QVERIFY2(t1 != t2, "Transponders shall not be equal");
|
QVERIFY2(t1 != t2, "Transponders shall not be equal");
|
||||||
QVERIFY2(!CTransponder::tryGetStandardTransponder(t1, 8888, CTransponder::StateStandby), "No valid transponder");
|
CTransponder tv = CTransponder(false, "transponder", 8888, CTransponder::StateStandby);
|
||||||
QVERIFY2(!CTransponder::tryGetStandardTransponder(t1, 781, CTransponder::StateStandby), "No valid transponder");
|
QVERIFY2(!tv.validValues(), "No valid transponder");
|
||||||
QVERIFY2(!CTransponder::tryGetStandardTransponder(t1, "0781", CTransponder::StateStandby), "No valid transponder");
|
tv = CTransponder(false, "transponder", 781, CTransponder::StateStandby);
|
||||||
QVERIFY2(CTransponder::tryGetStandardTransponder(t1, "7211", CTransponder::StateStandby), "No valid transponder");
|
QVERIFY2(!tv.validValues(), "No valid transponder");
|
||||||
QVERIFY2(!CTransponder::tryGetStandardTransponder(t1, "schnitzel", CTransponder::StateStandby), "No valid transponder");
|
tv = CTransponder(false, "transponder", "0781", CTransponder::StateStandby);
|
||||||
|
QVERIFY2(!tv.validValues(), "No valid transponder");
|
||||||
|
tv = CTransponder(false, "transponder", "7211", CTransponder::StateStandby);
|
||||||
|
QVERIFY2(tv.validValues(), "No valid transponder");
|
||||||
|
tv = CTransponder(false, "transponder", "schnitzel", CTransponder::StateStandby);
|
||||||
|
QVERIFY2(!tv.validValues(), "No valid transponder");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -71,13 +71,15 @@ namespace BlackMiscTest
|
|||||||
CValueMap vmWildcard(true);
|
CValueMap vmWildcard(true);
|
||||||
CValueMap vmNoWildcard(false);
|
CValueMap vmNoWildcard(false);
|
||||||
CValueMap vm;
|
CValueMap vm;
|
||||||
vm.addValue(CAtcStation::IndexController, CUser("123456", "Joe Doe"));
|
|
||||||
|
// remark: Shortcoming here, as the callsign will automatically set for user in station
|
||||||
|
// I have to set this as well, otherwise, not match.
|
||||||
|
vm.addValue(CAtcStation::IndexController, CUser("123456", "Joe Doe", CCallsign("EDDMTWR")));
|
||||||
|
|
||||||
// compare
|
// compare
|
||||||
QVERIFY2(vmWildcard == station1, "Station should be equal to wildcard");
|
QVERIFY2(vmWildcard == station1, "Station should be equal to wildcard");
|
||||||
QVERIFY2(station1 != vmNoWildcard, "Station should not be equal to empty list");
|
QVERIFY2(station1 != vmNoWildcard, "Station should not be equal to empty list");
|
||||||
QVERIFY2(station1 == vm, "Controller should match");
|
QVERIFY2(station1 == vm, "Controller should match");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} //namespace BlackMiscTest
|
} //namespace BlackMiscTest
|
||||||
|
|||||||
Reference in New Issue
Block a user