mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 23:05:36 +08:00
Revised avionics (stringifier) and matrix operations
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2013 VATSIM Community / authors
|
||||
/* Copyright (C) 2013 VATSIM Community / contributors
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
@@ -29,10 +29,12 @@ protected:
|
||||
virtual QString stringForConverter() const;
|
||||
|
||||
public:
|
||||
|
||||
/*!
|
||||
* \brief Default constructor: 0 Altitude true
|
||||
*/
|
||||
CAltitude() : BlackMisc::PhysicalQuantities::CLength(0, BlackMisc::PhysicalQuantities::CLengthUnit::m()), m_msl(true) {}
|
||||
|
||||
/*!
|
||||
* \brief Constructor
|
||||
* \param value
|
||||
@@ -40,6 +42,7 @@ public:
|
||||
* \param unit
|
||||
*/
|
||||
CAltitude(double value, bool msl, const BlackMisc::PhysicalQuantities::CLengthUnit &unit) : BlackMisc::PhysicalQuantities::CLength(value, unit), m_msl(msl) {}
|
||||
|
||||
/*!
|
||||
* \brief Constructor
|
||||
* \param value
|
||||
@@ -47,6 +50,7 @@ public:
|
||||
* \param unit
|
||||
*/
|
||||
CAltitude(int value, bool msl, const BlackMisc::PhysicalQuantities::CLengthUnit &unit) : CLength(value, unit), m_msl(msl) {}
|
||||
|
||||
/*!
|
||||
* \brief Constructor by CLength
|
||||
* \param altitude
|
||||
@@ -56,29 +60,34 @@ public:
|
||||
{
|
||||
BlackMisc::PhysicalQuantities::CLength::operator =(altitude);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Copy constructor
|
||||
* \param otherAltitude
|
||||
*/
|
||||
CAltitude(const CAltitude &otherAltitude) : BlackMisc::PhysicalQuantities::CLength(otherAltitude), m_msl(otherAltitude.m_msl) {}
|
||||
|
||||
/*!
|
||||
* \brief Assignment operator =
|
||||
* \param otherAltitude
|
||||
* @return
|
||||
*/
|
||||
CAltitude &operator =(const CAltitude &otherAltitude);
|
||||
|
||||
/*!
|
||||
* \brief Equal operator ==
|
||||
* \param otherAltitude
|
||||
* @return
|
||||
*/
|
||||
bool operator ==(const CAltitude &otherAltitude);
|
||||
|
||||
/*!
|
||||
* \brief Unequal operator ==
|
||||
* \param otherAltitude
|
||||
* @return
|
||||
*/
|
||||
bool operator !=(const CAltitude &otherAltitude);
|
||||
|
||||
/*!
|
||||
* \brief AGL Above ground level?
|
||||
* \return
|
||||
@@ -87,6 +96,7 @@ public:
|
||||
{
|
||||
return !this->m_msl;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief MSL Mean sea level?
|
||||
* \return
|
||||
@@ -100,4 +110,4 @@ public:
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
#endif // BLACKMISC_AVALTITUDE_H
|
||||
#endif // guard
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2013 VATSIM Community / authors
|
||||
/* Copyright (C) 2013 VATSIM Community / contributors
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
@@ -7,6 +7,7 @@
|
||||
#define BLACKMISC_AVIOBASE_H
|
||||
|
||||
// QtGlobal is required for asserts
|
||||
#include "blackmisc/basestreamstringifier.h"
|
||||
#include "blackmisc/pqconstants.h"
|
||||
#include <QtGlobal>
|
||||
|
||||
@@ -18,67 +19,44 @@ namespace Aviation
|
||||
/*!
|
||||
* \brief Base class for avionics
|
||||
*/
|
||||
class CAvionicsBase
|
||||
class CAvionicsBase : public CBaseStreamStringifier<CAvionicsBase>
|
||||
{
|
||||
/*!
|
||||
* Stream operator for debugging
|
||||
* \brief operator <<
|
||||
* \param debug
|
||||
* \param avionic
|
||||
* \return
|
||||
* \remarks Has to be in the header files to avoid template link errors
|
||||
*/
|
||||
friend QDebug operator<<(QDebug debug, const CAvionicsBase &avionic) {
|
||||
QString v = avionic.stringForStreamingOperator();
|
||||
debug << v;
|
||||
return debug;
|
||||
}
|
||||
/*!
|
||||
* Stream operator for log messages
|
||||
* \brief operator <<
|
||||
* \param log
|
||||
* \param avionic
|
||||
* \return
|
||||
* \remarks Has to be in the header files to avoid template link errors
|
||||
*/
|
||||
friend CLogMessage operator<<(CLogMessage log, const CAvionicsBase &avionic) {
|
||||
QString v = avionic.stringForStreamingOperator();
|
||||
log << v;
|
||||
return log;
|
||||
}
|
||||
|
||||
private:
|
||||
QString m_name; //!< name of the unit
|
||||
|
||||
protected:
|
||||
|
||||
/*!
|
||||
* \brief Default constructor
|
||||
*/
|
||||
CAvionicsBase(const QString &name) : m_name(name) {}
|
||||
/*!
|
||||
* \brief Meaningful string representation
|
||||
* \return
|
||||
*/
|
||||
virtual QString stringForStreamingOperator() const = 0;
|
||||
|
||||
/*!
|
||||
* \brief Are the set values valid / in range
|
||||
* \return
|
||||
*/
|
||||
virtual bool validValues() {
|
||||
virtual bool validValues()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Set name
|
||||
* \param name
|
||||
*/
|
||||
void setName(const QString &name) {
|
||||
void setName(const QString &name)
|
||||
{
|
||||
this->m_name = name;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief operator ==
|
||||
* \param otherSystem
|
||||
* \return
|
||||
*/
|
||||
bool operator ==(const CAvionicsBase &otherSystem) const {
|
||||
bool operator ==(const CAvionicsBase &otherSystem) const
|
||||
{
|
||||
if (this == &otherSystem) return true;
|
||||
return this->m_name == otherSystem.m_name;
|
||||
}
|
||||
@@ -88,21 +66,17 @@ public:
|
||||
* \brief Virtual destructor
|
||||
*/
|
||||
virtual ~CAvionicsBase() {}
|
||||
/*!
|
||||
* \brief Cast as QString
|
||||
*/
|
||||
operator QString() const {
|
||||
return this->stringForStreamingOperator();
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Name
|
||||
* \return
|
||||
*/
|
||||
QString getName() const {
|
||||
QString getName() const
|
||||
{
|
||||
return this->m_name;
|
||||
}
|
||||
};
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
#endif // BLACKMISC_AVIOBASE_H
|
||||
#endif // guard
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2013 VATSIM Community
|
||||
/* Copyright (C) 2013 VATSIM Community / contributors
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
@@ -27,6 +27,7 @@ private:
|
||||
double fr = f.valueRounded(BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz(), this->m_digits);
|
||||
return fr >= 118.0 && fr <= 136.975;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Valid military aviation frequency?
|
||||
* \param f
|
||||
@@ -36,6 +37,7 @@ private:
|
||||
double fr = f.valueRounded(BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz(), this->m_digits);
|
||||
return fr >= 220.0 && fr <= 399.95;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Constructor
|
||||
* \param validate
|
||||
@@ -63,6 +65,7 @@ protected:
|
||||
(this->isValidCivilAviationFrequency(this->getFrequencyStandby()) ||
|
||||
this->isValidMilitaryFrequency(this->getFrequencyStandby()));
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Validate values by assert and exception
|
||||
* \param strict
|
||||
@@ -78,16 +81,19 @@ protected:
|
||||
if (!valid) throw std::range_error("Illegal values in CComSystem::validate");
|
||||
return true;
|
||||
}
|
||||
|
||||
public:
|
||||
/*!
|
||||
* Default constructor
|
||||
*/
|
||||
CComSystem() : CModulator() {}
|
||||
|
||||
/*!
|
||||
* \brief Copy constructor
|
||||
* \param otherSystem
|
||||
*/
|
||||
CComSystem(const CComSystem &otherSystem) : CModulator(otherSystem) {}
|
||||
|
||||
/*!
|
||||
* \brief Constructor
|
||||
* \param name
|
||||
@@ -99,6 +105,7 @@ public:
|
||||
CModulator(name, activeFrequency, standbyFrequency == CModulator::FrequencyNotSet() ? activeFrequency : standbyFrequency, digits) {
|
||||
this->validate(true);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Set active frequency
|
||||
* \param frequencyMHz
|
||||
@@ -107,6 +114,7 @@ public:
|
||||
CModulator::setFrequencyActiveMHz(frequencyMHz);
|
||||
this->validate(true);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Set standby frequency
|
||||
* \param frequencyMHz
|
||||
@@ -115,6 +123,7 @@ public:
|
||||
CModulator::setFrequencyStandbyMHz(frequencyMHz);
|
||||
this->validate(true);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Set UNICOM frequency as active
|
||||
*/
|
||||
@@ -122,6 +131,7 @@ public:
|
||||
this->toggleActiveStandby();
|
||||
this->setFrequencyActive(BlackMisc::PhysicalQuantities::CPhysicalQuantitiesConstants::FrequencyUnicom());
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Set International Air Distress 121.5MHz
|
||||
*/
|
||||
@@ -129,6 +139,7 @@ public:
|
||||
this->toggleActiveStandby();
|
||||
this->setFrequencyActive(BlackMisc::PhysicalQuantities::CPhysicalQuantitiesConstants::FrequencyInternationalAirDistress());
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Assigment operator =
|
||||
* \param otherSystem
|
||||
@@ -138,6 +149,7 @@ public:
|
||||
CModulator::operator =(otherSystem);
|
||||
return (*this);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief operator ==
|
||||
* \param otherSystem
|
||||
|
||||
@@ -28,7 +28,7 @@ template <class AVIO> void CModulator<AVIO>::toggleActiveStandby()
|
||||
/*
|
||||
* String representation
|
||||
*/
|
||||
template <class AVIO> QString CModulator<AVIO>::stringForStreamingOperator() const
|
||||
template <class AVIO> QString CModulator<AVIO>::stringForConverter() const
|
||||
{
|
||||
QString s(this->getName());
|
||||
s.append(" Active: ").append(this->m_frequencyActive.unitValueRoundedWithUnit(3));
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2013 VATSIM Community
|
||||
/* Copyright (C) 2013 VATSIM Community / contributors
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
@@ -28,6 +28,7 @@ protected:
|
||||
* \brief Default constructor
|
||||
*/
|
||||
CModulator() : CAvionicsBase("default") {}
|
||||
|
||||
/*!
|
||||
* \brief Copy constructor
|
||||
* \param otherUnit
|
||||
@@ -35,6 +36,7 @@ protected:
|
||||
CModulator(const CModulator &otherUnit) :
|
||||
m_frequencyActive(otherUnit.m_frequencyActive), m_frequencyStandby(otherUnit.m_frequencyStandby),
|
||||
m_digits(otherUnit.m_digits), CAvionicsBase(otherUnit.getName()) {}
|
||||
|
||||
/*!
|
||||
* \brief Constructor
|
||||
* \param name
|
||||
@@ -45,51 +47,63 @@ protected:
|
||||
CModulator(const QString &name, const BlackMisc::PhysicalQuantities::CFrequency &activeFrequency, const BlackMisc::PhysicalQuantities::CFrequency &standbyFrequency, int digits) :
|
||||
m_frequencyActive(activeFrequency),
|
||||
m_digits(digits), m_frequencyStandby(standbyFrequency), CAvionicsBase(name) { }
|
||||
|
||||
/*!
|
||||
* \brief Meaningful string representation
|
||||
* \brief String for converter
|
||||
* \return
|
||||
*/
|
||||
virtual QString stringForStreamingOperator() const;
|
||||
virtual QString stringForConverter() const;
|
||||
|
||||
/*!
|
||||
* \brief Set active frequency
|
||||
* \param frequencyKHz
|
||||
*/
|
||||
void setFrequencyActiveKHz(double frequencyKHz) {
|
||||
void setFrequencyActiveKHz(double frequencyKHz)
|
||||
{
|
||||
this->m_frequencyActive = CFrequency(frequencyKHz, CFrequencyUnit::kHz());
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Set standby frequency
|
||||
* \param frequencyKHz
|
||||
*/
|
||||
void setFrequencyStandbyKHz(double frequencyKHz) {
|
||||
void setFrequencyStandbyKHz(double frequencyKHz)
|
||||
{
|
||||
this->m_frequencyStandby = CFrequency(frequencyKHz, CFrequencyUnit::kHz());
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Set active frequency
|
||||
* \param frequencyMHz
|
||||
*/
|
||||
void setFrequencyActiveMHz(double frequencyMHz) {
|
||||
void setFrequencyActiveMHz(double frequencyMHz)
|
||||
{
|
||||
this->m_frequencyActive = BlackMisc::PhysicalQuantities::CFrequency(frequencyMHz, BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz());
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Set standby frequency
|
||||
* \param frequencyMHz
|
||||
*/
|
||||
void setFrequencyStandbyMHz(double frequencyMHz) {
|
||||
void setFrequencyStandbyMHz(double frequencyMHz)
|
||||
{
|
||||
this->m_frequencyStandby = BlackMisc::PhysicalQuantities::CFrequency(frequencyMHz, BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz());
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Assigment operator =
|
||||
* \param otherModulator
|
||||
* \return
|
||||
*/
|
||||
CModulator& operator =(const CModulator &otherModulator);
|
||||
CModulator &operator =(const CModulator &otherModulator);
|
||||
|
||||
/*!
|
||||
* \brief operator ==
|
||||
* \param otherModulator
|
||||
* \return
|
||||
*/
|
||||
bool operator ==(const CModulator &otherModulator) const;
|
||||
|
||||
/*!
|
||||
* \brief operator !=
|
||||
* \param otherModulator
|
||||
@@ -100,117 +114,146 @@ protected:
|
||||
* \brief COM1
|
||||
* \return
|
||||
*/
|
||||
static const QString& NameCom1() {
|
||||
static const QString &NameCom1()
|
||||
{
|
||||
static QString n("COM1");
|
||||
return n;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief COM2
|
||||
* \return
|
||||
*/
|
||||
static const QString& NameCom2() {
|
||||
static const QString &NameCom2()
|
||||
{
|
||||
static QString n("COM2");
|
||||
return n;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief COM3
|
||||
* \return
|
||||
*/
|
||||
static const QString& NameCom3() {
|
||||
static const QString &NameCom3()
|
||||
{
|
||||
static QString n("COM3");
|
||||
return n;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief NAV1
|
||||
* \return
|
||||
*/
|
||||
static const QString& NameNav1() {
|
||||
static const QString &NameNav1()
|
||||
{
|
||||
static QString n("NAV1");
|
||||
return n;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief NAV2
|
||||
* \return
|
||||
*/
|
||||
static const QString& NameNav2() {
|
||||
static const QString &NameNav2()
|
||||
{
|
||||
static QString n("NAV2");
|
||||
return n;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief NAV2
|
||||
* \return
|
||||
*/
|
||||
static const QString& NameNav3() {
|
||||
static const QString &NameNav3()
|
||||
{
|
||||
static QString n("NAV2");
|
||||
return n;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief ADF1
|
||||
* \return
|
||||
*/
|
||||
static const QString& NameAdf1() {
|
||||
static const QString &NameAdf1()
|
||||
{
|
||||
static QString n("ADF1");
|
||||
return n;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief ADF2
|
||||
* \return
|
||||
*/
|
||||
static const QString& NameAdf2() {
|
||||
static const QString &NameAdf2()
|
||||
{
|
||||
static QString n("ADF2");
|
||||
return n;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Frequency not set
|
||||
* \return
|
||||
*/
|
||||
static const BlackMisc::PhysicalQuantities::CFrequency& FrequencyNotSet() {
|
||||
static const BlackMisc::PhysicalQuantities::CFrequency &FrequencyNotSet()
|
||||
{
|
||||
static BlackMisc::PhysicalQuantities::CFrequency f;
|
||||
return f;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public:
|
||||
/*!
|
||||
* \brief Virtual destructor
|
||||
*/
|
||||
virtual ~CModulator() {}
|
||||
|
||||
/*!
|
||||
* \brief Default value
|
||||
* \return
|
||||
*/
|
||||
virtual bool isDefaultValue() const {
|
||||
virtual bool isDefaultValue() const
|
||||
{
|
||||
return this->m_frequencyActive == CModulator::FrequencyNotSet();
|
||||
}
|
||||
/*!
|
||||
* \brief Toggle active and standby frequencies
|
||||
*/
|
||||
void toggleActiveStandby();
|
||||
|
||||
/*!
|
||||
* \brief Active frequency
|
||||
* \return
|
||||
*/
|
||||
BlackMisc::PhysicalQuantities::CFrequency getFrequencyActive() const {
|
||||
BlackMisc::PhysicalQuantities::CFrequency getFrequencyActive() const
|
||||
{
|
||||
return this->m_frequencyActive;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Standby frequency
|
||||
* \return
|
||||
*/
|
||||
BlackMisc::PhysicalQuantities::CFrequency getFrequencyStandby() const {
|
||||
BlackMisc::PhysicalQuantities::CFrequency getFrequencyStandby() const
|
||||
{
|
||||
return this->m_frequencyActive;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Set active frequency
|
||||
* \param frequency
|
||||
*/
|
||||
void setFrequencyActive(const BlackMisc::PhysicalQuantities::CFrequency &frequency) {
|
||||
void setFrequencyActive(const BlackMisc::PhysicalQuantities::CFrequency &frequency)
|
||||
{
|
||||
this->m_frequencyActive = frequency;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Set standby frequency
|
||||
* \param frequency
|
||||
*/
|
||||
void setFrequencyStandby(const BlackMisc::PhysicalQuantities::CFrequency &frequency) {
|
||||
void setFrequencyStandby(const BlackMisc::PhysicalQuantities::CFrequency &frequency)
|
||||
{
|
||||
this->m_frequencyStandby = frequency;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
#include "aviobase.h"
|
||||
|
||||
namespace BlackMisc {
|
||||
|
||||
/**
|
||||
* Defaultc
|
||||
*/
|
||||
CAvionicsBase::CAvionicsBase()
|
||||
{
|
||||
}
|
||||
|
||||
} // namespace
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2013 VATSIM Community / authors
|
||||
/* Copyright (C) 2013 VATSIM Community / contributors
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
@@ -45,7 +45,7 @@ bool CTransponder::validate(bool strict) const
|
||||
/**
|
||||
* String representation
|
||||
*/
|
||||
QString CTransponder::stringForStreamingOperator() const
|
||||
QString CTransponder::stringForConverter() const
|
||||
{
|
||||
QString s = this->getName();
|
||||
s = s.append(" ").append(this->getTransponderCodeFormatted()).append(" ").append(this->getModeAsString());
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2013 VATSIM Community / authors
|
||||
/* Copyright (C) 2013 VATSIM Community / contributors
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
@@ -21,7 +21,8 @@ public:
|
||||
/*!
|
||||
* \brief Our transponder codes
|
||||
*/
|
||||
enum TransponderMode {
|
||||
enum TransponderMode
|
||||
{
|
||||
StateStandby = 0, // not a real mode, more a state
|
||||
ModeMil1 = 1, ModeMil2 = 2, ModeMil3 = 3, ModeMil4 = 4, ModeMil5 = 5,
|
||||
StateIdent = 10, // not a real mode, more a state
|
||||
@@ -41,9 +42,11 @@ private:
|
||||
* \param transponderMode
|
||||
*/
|
||||
CTransponder(bool validate, const QString &name, qint32 transponderCode, TransponderMode transponderMode) :
|
||||
m_transponderCode(transponderCode), m_transponderMode(transponderMode), CAvionicsBase(name) {
|
||||
m_transponderCode(transponderCode), m_transponderMode(transponderMode), CAvionicsBase(name)
|
||||
{
|
||||
this->validate(validate);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Constructor for validation
|
||||
* \param validate
|
||||
@@ -52,7 +55,8 @@ private:
|
||||
* \param transponderMode
|
||||
*/
|
||||
CTransponder(bool validate, const QString &name, const QString transponderCode, TransponderMode transponderMode) :
|
||||
m_transponderCode(0), m_transponderMode(transponderMode), CAvionicsBase(name) {
|
||||
m_transponderCode(0), m_transponderMode(transponderMode), CAvionicsBase(name)
|
||||
{
|
||||
bool ok = false;
|
||||
this->m_transponderCode = transponderCode.toUInt(&ok);
|
||||
if (!ok)this->m_transponderCode = -1; // will cause assert / exception
|
||||
@@ -64,13 +68,16 @@ protected:
|
||||
* \return
|
||||
*/
|
||||
bool validValues() const;
|
||||
|
||||
/*!
|
||||
* \brief Default value
|
||||
* \return
|
||||
*/
|
||||
virtual bool isDefaultValue() const {
|
||||
virtual bool isDefaultValue() const
|
||||
{
|
||||
return this->m_transponderCode == 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Validate values by assert and exception
|
||||
* \param strict
|
||||
@@ -79,22 +86,26 @@ protected:
|
||||
* \return
|
||||
*/
|
||||
bool validate(bool strict = true) const;
|
||||
|
||||
/*!
|
||||
* \brief Meaningful string representation
|
||||
* \return
|
||||
*/
|
||||
virtual QString stringForStreamingOperator() const;
|
||||
virtual QString stringForConverter() const;
|
||||
|
||||
public:
|
||||
/*!
|
||||
* Default constructor
|
||||
*/
|
||||
CTransponder() : CAvionicsBase("default"), m_transponderCode(0), m_transponderMode(StateStandby) {}
|
||||
|
||||
/*!
|
||||
* \brief Copy constructor
|
||||
* \param otherTransponder
|
||||
*/
|
||||
CTransponder(const CTransponder &otherTransponder) : CAvionicsBase(otherTransponder.getName()),
|
||||
m_transponderCode(otherTransponder.m_transponderCode), m_transponderMode(otherTransponder.m_transponderMode) {}
|
||||
|
||||
/*!
|
||||
* \brief Constructor
|
||||
* \param name
|
||||
@@ -102,9 +113,11 @@ public:
|
||||
* \param 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);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Constructor
|
||||
* \param name
|
||||
@@ -112,99 +125,122 @@ public:
|
||||
* \param transponderMode
|
||||
*/
|
||||
CTransponder(const QString &name, const QString &transponderCode, TransponderMode transponderMode) :
|
||||
CAvionicsBase(name), m_transponderCode(0), m_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(true);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Transponder mode as string
|
||||
* \return
|
||||
* \throws std::range_erros
|
||||
*/
|
||||
QString getModeAsString() const;
|
||||
|
||||
/*!
|
||||
* \brief Transponder mode
|
||||
* \return
|
||||
*/
|
||||
TransponderMode getTransponderMode() const {
|
||||
TransponderMode getTransponderMode() const
|
||||
{
|
||||
return this->m_transponderMode;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Transponder code
|
||||
* \return
|
||||
*/
|
||||
qint32 getTransponderCode() const {
|
||||
qint32 getTransponderCode() const
|
||||
{
|
||||
return this->m_transponderCode;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Transponder code
|
||||
* \return
|
||||
*/
|
||||
QString getTransponderCodeFormatted() const;
|
||||
|
||||
/*!
|
||||
* \brief Set transponder code
|
||||
* \param transponderCode
|
||||
*/
|
||||
void setTransponderCode(qint32 transponderCode) {
|
||||
void setTransponderCode(qint32 transponderCode)
|
||||
{
|
||||
this->m_transponderCode = transponderCode;
|
||||
this->validate(true);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Set transponder mode
|
||||
* \param mode
|
||||
*/
|
||||
void setTransponderMode(TransponderMode mode) {
|
||||
void setTransponderMode(TransponderMode mode)
|
||||
{
|
||||
this->m_transponderMode = mode ;
|
||||
this->validate(true);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Set emergency
|
||||
*/
|
||||
void setEmergency() {
|
||||
void setEmergency()
|
||||
{
|
||||
this->m_transponderCode = 7700;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Set emergency
|
||||
*/
|
||||
void setVFR() {
|
||||
void setVFR()
|
||||
{
|
||||
this->m_transponderCode = 7000;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Set emergency
|
||||
*/
|
||||
void setIFR() {
|
||||
void setIFR()
|
||||
{
|
||||
this->m_transponderCode = 2000;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Assigment operator =
|
||||
* \param otherTransponder
|
||||
* \return
|
||||
*/
|
||||
CTransponder &operator =(const CTransponder &otherTransponder) {
|
||||
CTransponder &operator =(const CTransponder &otherTransponder)
|
||||
{
|
||||
CAvionicsBase::operator =(otherTransponder);
|
||||
this->m_transponderMode = otherTransponder.m_transponderMode;
|
||||
this->m_transponderCode = otherTransponder.m_transponderCode;
|
||||
return (*this);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief operator ==
|
||||
* \param otherTransponder
|
||||
* \return
|
||||
*/
|
||||
bool operator ==(const CTransponder &otherTransponder) const {
|
||||
bool operator ==(const CTransponder &otherTransponder) const
|
||||
{
|
||||
return
|
||||
this->m_transponderCode == otherTransponder.m_transponderCode &&
|
||||
this->m_transponderMode == otherTransponder.m_transponderMode &&
|
||||
CAvionicsBase::operator ==(otherTransponder);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief operator =!
|
||||
* \param otherSystem
|
||||
* \return
|
||||
*/
|
||||
bool operator !=(const CTransponder &otherSystem) const {
|
||||
bool operator !=(const CTransponder &otherSystem) const
|
||||
{
|
||||
return !((*this) == otherSystem);
|
||||
}
|
||||
|
||||
@@ -217,7 +253,8 @@ public:
|
||||
* \param mode
|
||||
* \return
|
||||
*/
|
||||
static bool tryGetTransponder(CTransponder &transponder, const QString &name, qint32 transponderCode, TransponderMode mode) {
|
||||
static bool tryGetTransponder(CTransponder &transponder, const QString &name, qint32 transponderCode, TransponderMode mode)
|
||||
{
|
||||
transponder = CTransponder(false, name, transponderCode, mode);
|
||||
bool s;
|
||||
if (!(s = transponder.validate(false))) transponder = CTransponder(); // reset to default
|
||||
@@ -232,7 +269,8 @@ public:
|
||||
* \param mode
|
||||
* \return
|
||||
*/
|
||||
static bool tryGetTransponder(CTransponder &transponder, const QString &name, const QString &transponderCode, TransponderMode mode) {
|
||||
static bool tryGetTransponder(CTransponder &transponder, const QString &name, const QString &transponderCode, TransponderMode mode)
|
||||
{
|
||||
transponder = CTransponder(false, name, transponderCode, mode);
|
||||
bool s;
|
||||
if (!(s = transponder.validate(false))) transponder = CTransponder(); // reset to default
|
||||
@@ -244,7 +282,8 @@ public:
|
||||
* \param mode
|
||||
* \return
|
||||
*/
|
||||
static CTransponder getStandardTransponder(qint32 transponderCode, TransponderMode mode) {
|
||||
static CTransponder getStandardTransponder(qint32 transponderCode, TransponderMode mode)
|
||||
{
|
||||
return CTransponder("Transponder", transponderCode, mode);
|
||||
}
|
||||
/*!
|
||||
@@ -254,7 +293,8 @@ public:
|
||||
* \param mode
|
||||
* \return
|
||||
*/
|
||||
static bool tryGetStandardTransponder(CTransponder &transponder, qint32 transponderCode, TransponderMode mode) {
|
||||
static bool tryGetStandardTransponder(CTransponder &transponder, qint32 transponderCode, TransponderMode mode)
|
||||
{
|
||||
return CTransponder::tryGetTransponder(transponder, "Transponder", transponderCode, mode);
|
||||
}
|
||||
|
||||
@@ -265,7 +305,8 @@ public:
|
||||
* \param mode
|
||||
* \return
|
||||
*/
|
||||
static bool tryGetStandardTransponder(CTransponder &transponder, const QString &transponderCode, TransponderMode mode) {
|
||||
static bool tryGetStandardTransponder(CTransponder &transponder, const QString &transponderCode, TransponderMode mode)
|
||||
{
|
||||
return CTransponder::tryGetTransponder(transponder, "Transponder", transponderCode, mode);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ TEMPLATE = lib
|
||||
CONFIG += staticlib
|
||||
|
||||
INCLUDEPATH += ..
|
||||
DEPENDPATH += . ..
|
||||
# DEPENDPATH += . ..
|
||||
|
||||
#PRECOMPILED_HEADER = stdpch.h
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
#ifndef BLACKMISC_COORDINATEECEF_H
|
||||
#define BLACKMISC_COORDINATEECEF_H
|
||||
#include "blackmisc/mathvector3dbase.h"
|
||||
#include "blackmisc/mathvector3d.h"
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
@@ -30,6 +30,12 @@ public:
|
||||
*/
|
||||
CCoordinateEcef(qreal x, qreal y, qreal z) : CVector3DBase(x, y, z) {}
|
||||
|
||||
/*!
|
||||
* \brief Constructor by math vector
|
||||
* \param vector
|
||||
*/
|
||||
CCoordinateEcef(const BlackMisc::Math::CVector3D vector) : CVector3DBase(vector.i(), vector.j(), vector.k()) {}
|
||||
|
||||
/*!
|
||||
* \brief x
|
||||
* \return
|
||||
@@ -83,6 +89,15 @@ public:
|
||||
{
|
||||
this->m_vector.setZ(z);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Concrete implementation of a 3D vector
|
||||
* \return
|
||||
*/
|
||||
BlackMisc::Math::CVector3D toMathVector() const
|
||||
{
|
||||
return BlackMisc::Math::CVector3D(this->z(), this->y(), this->x());
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
#ifndef BLACKMISC_COORDINATENED_H
|
||||
#define BLACKMISC_COORDINATENED_H
|
||||
#include "blackmisc/mathvector3dbase.h"
|
||||
#include "blackmisc/mathvector3d.h"
|
||||
#include "blackmisc/mathmatrix3x3.h"
|
||||
#include "blackmisc/coordinategeodetic.h"
|
||||
|
||||
@@ -51,6 +51,19 @@ public:
|
||||
CCoordinateNed(const CCoordinateNed &otherNed) :
|
||||
CVector3DBase(otherNed) , m_hasReferencePosition(otherNed.m_hasReferencePosition), m_referencePosition(otherNed.m_referencePosition) {}
|
||||
|
||||
/*!
|
||||
* \brief Constructor by math vector
|
||||
* \param vector
|
||||
*/
|
||||
CCoordinateNed(const BlackMisc::Math::CVector3D vector) : CVector3DBase(vector.i(), vector.j(), vector.k()), m_referencePosition(), m_hasReferencePosition(false) {}
|
||||
|
||||
/*!
|
||||
* \brief Constructor by math vector and reference position
|
||||
* \param referencePosition
|
||||
* \param vector
|
||||
*/
|
||||
CCoordinateNed(const CCoordinateGeodetic &referencePosition, const BlackMisc::Math::CVector3D vector) : CVector3DBase(vector.i(), vector.j(), vector.k()), m_referencePosition(referencePosition), m_hasReferencePosition(true) {}
|
||||
|
||||
/*!
|
||||
* \brief Equal operator ==
|
||||
* \param otherNed
|
||||
@@ -171,6 +184,14 @@ public:
|
||||
this->m_hasReferencePosition = true;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Concrete implementation of a 3D vector
|
||||
* \return
|
||||
*/
|
||||
BlackMisc::Math::CVector3D toMathVector() const
|
||||
{
|
||||
return BlackMisc::Math::CVector3D(this->north(), this->east(), this->down());
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
/* Copyright (C) 2013 VATSIM Community / authors
|
||||
/* Copyright (C) 2013 VATSIM Community / contributors
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* This file incorporates work covered by the following copyright and
|
||||
* permission notice:
|
||||
* Copyright (c) Charles Karney (2008-2011) <charles@karney.com> and licensed
|
||||
* under the MIT/X11 License. For more information, see http://geographiclib.sourceforge.net/
|
||||
*/
|
||||
|
||||
#include "coordinatetransformation.h"
|
||||
using namespace BlackMisc::PhysicalQuantities;
|
||||
@@ -18,11 +24,9 @@ namespace Geo
|
||||
CCoordinateEcef CCoordinateTransformation::toEcef(const CCoordinateNed &ned)
|
||||
{
|
||||
CLatitude lat = ned.referencePosition().latitude();
|
||||
lat.switchUnit(CAngleUnit::rad());
|
||||
CLongitude lon = ned.referencePosition().longitude();
|
||||
lon.switchUnit(CAngleUnit::rad());
|
||||
double angleRad = - (lat.value(CAngleUnit::rad())) - BlackMisc::Math::PI / 2;
|
||||
|
||||
double angleRad = - (lat.unitValueToDouble()) - BlackMisc::Math::PI / 2;
|
||||
CMatrix3x3 dcm1;
|
||||
CMatrix3x3 dcm2;
|
||||
CMatrix3x3 dcm3;
|
||||
@@ -38,8 +42,7 @@ CCoordinateEcef CCoordinateTransformation::toEcef(const CCoordinateNed &ned)
|
||||
dcm2(2, 0) = sin(angleRad);
|
||||
dcm2(2, 2) = cos(angleRad);
|
||||
|
||||
angleRad = lon.unitValueToDouble();
|
||||
|
||||
angleRad = lon.value(CAngleUnit::rad());
|
||||
dcm3(0, 0) = cos(angleRad);
|
||||
dcm3(0, 1) = sin(angleRad);
|
||||
dcm3(1, 0) = -sin(angleRad);
|
||||
@@ -51,12 +54,44 @@ CCoordinateEcef CCoordinateTransformation::toEcef(const CCoordinateNed &ned)
|
||||
invDcm.setZero();
|
||||
invDcm = dcm.inverse();
|
||||
|
||||
CCoordinateNed tempResult(ned);
|
||||
tempResult.matrixMultiplication(invDcm);
|
||||
CCoordinateEcef result(tempResult.north(), tempResult.east(), tempResult.down());
|
||||
|
||||
CVector3D tempResult = invDcm * ned.toMathVector(); // to generic vector
|
||||
CCoordinateEcef result(tempResult);
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert to NED
|
||||
*/
|
||||
CCoordinateNed toNed(const CCoordinateEcef &ecef, const CCoordinateGeodetic &geo) {
|
||||
|
||||
CLatitude lat = geo.latitude();
|
||||
CLongitude lon = geo.longitude();
|
||||
double angleRad = - (lat.value(CAngleUnit::rad())) - BlackMisc::Math::PI / 2;
|
||||
|
||||
CMatrix3x3 dcm1;
|
||||
CMatrix3x3 dcm2(0.0);
|
||||
CMatrix3x3 dcm3(0.0);
|
||||
CMatrix3x3 dcm(0.0);
|
||||
dcm1.setToIdentity();
|
||||
|
||||
dcm2(0,0) = cos( angleRad );
|
||||
dcm2(0,2) = -sin( angleRad );
|
||||
dcm2(1,1) = 1;
|
||||
dcm2(2,0) = sin( angleRad );
|
||||
dcm2(2,2) = cos( angleRad );
|
||||
|
||||
angleRad = lon.value(CAngleUnit::rad());
|
||||
dcm3(0,0) = cos(angleRad );
|
||||
dcm3(0,1) = sin(angleRad );
|
||||
dcm3(1,0) = -sin(angleRad );
|
||||
dcm3(1,1) = cos(angleRad );
|
||||
dcm3(2,2) = 1;
|
||||
|
||||
dcm = dcm1 * dcm2 * dcm3;
|
||||
|
||||
CVector3D tempResult = dcm * ecef.toMathVector(); // to generic vector
|
||||
CCoordinateNed result(geo, tempResult);
|
||||
return result;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -1,7 +1,14 @@
|
||||
/* Copyright (C) 2013 VATSIM Community / authors
|
||||
/* Copyright (C) 2013 VATSIM Community / contributors
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* This file incorporates work covered by the following copyright and
|
||||
* permission notice:
|
||||
* Copyright (c) Charles Karney (2008-2011) <charles@karney.com> and licensed
|
||||
* under the MIT/X11 License. For more information, see
|
||||
* http://geographiclib.sourceforge.net/
|
||||
*/
|
||||
|
||||
#ifndef BLACKMISC_COORDINATETRANSFORMATION_H
|
||||
#define BLACKMISC_COORDINATETRANSFORMATION_H
|
||||
@@ -36,6 +43,13 @@ public:
|
||||
*/
|
||||
static CCoordinateEcef toEcef(const CCoordinateNed &ned);
|
||||
|
||||
/*!
|
||||
* \brief ECEF via Geodetic to NED
|
||||
* \param geo
|
||||
* \return
|
||||
*/
|
||||
static CCoordinateNed toNed(const CCoordinateEcef &ecef, const CCoordinateGeodetic &geo);
|
||||
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2013 VATSIM Community / authors
|
||||
/* Copyright (C) 2013 VATSIM Community / contributors
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2013 VATSIM Community / authors
|
||||
/* Copyright (C) 2013 VATSIM Community / contributors
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
@@ -83,6 +83,17 @@ public:
|
||||
return m;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Multiply vector with this 3x3 matrix
|
||||
* \param vector
|
||||
* \return
|
||||
*/
|
||||
CVector3D operator *(const CVector3D &vector) const {
|
||||
CVector3D v(vector);
|
||||
v.matrixMultiplication(*this);
|
||||
return v;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Transposed matrix
|
||||
* \return
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2013 VATSIM Community / authors
|
||||
/* Copyright (C) 2013 VATSIM Community / contributors
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
Reference in New Issue
Block a user