mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-16 18:35:35 +08:00
Revised avionics (stringifier) and matrix operations
This commit is contained in:
@@ -7,8 +7,9 @@ TEMPLATE = app
|
|||||||
CONFIG += console
|
CONFIG += console
|
||||||
CONFIG -= app_bundle
|
CONFIG -= app_bundle
|
||||||
|
|
||||||
DEPENDPATH += . ../../src
|
DEPENDPATH += . ../../src/blackmisc
|
||||||
INCLUDEPATH += . ../../src
|
INCLUDEPATH += . ../../src
|
||||||
|
|
||||||
SOURCES += main.cpp \
|
SOURCES += main.cpp \
|
||||||
samplesphysicalquantities.cpp \
|
samplesphysicalquantities.cpp \
|
||||||
samplesaviation.cpp
|
samplesaviation.cpp
|
||||||
|
|||||||
@@ -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
|
* 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
|
* 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/. */
|
||||||
@@ -93,10 +93,10 @@ int CSamplesPhysicalQuantities::samples()
|
|||||||
qDebug() << t3 << t3.valueRoundedWithUnit(CTemperatureUnit::C());
|
qDebug() << t3 << t3.valueRoundedWithUnit(CTemperatureUnit::C());
|
||||||
|
|
||||||
// some logging with CLogMessage
|
// some logging with CLogMessage
|
||||||
bDebug << p1;
|
// bDebug << p1;
|
||||||
bDebug << p1.getUnit() << p1.getUnit().getMultiplier();
|
// bDebug << p1.getUnit() << p1.getUnit().getMultiplier();
|
||||||
|
|
||||||
// some of the faults Mathew has pointed out,not longer possible
|
// some of the faults Mathew has pointed out, not longer possible
|
||||||
// CAngleUnit::rad() = CAngleUnit::deg();
|
// CAngleUnit::rad() = CAngleUnit::deg();
|
||||||
// qDebug() << CAngleUnit::rad(); // wrong
|
// qDebug() << CAngleUnit::rad(); // wrong
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
* 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
|
* 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/. */
|
||||||
@@ -29,10 +29,12 @@ protected:
|
|||||||
virtual QString stringForConverter() const;
|
virtual QString stringForConverter() const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Default constructor: 0 Altitude true
|
* \brief Default constructor: 0 Altitude true
|
||||||
*/
|
*/
|
||||||
CAltitude() : BlackMisc::PhysicalQuantities::CLength(0, BlackMisc::PhysicalQuantities::CLengthUnit::m()), m_msl(true) {}
|
CAltitude() : BlackMisc::PhysicalQuantities::CLength(0, BlackMisc::PhysicalQuantities::CLengthUnit::m()), m_msl(true) {}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Constructor
|
* \brief Constructor
|
||||||
* \param value
|
* \param value
|
||||||
@@ -40,6 +42,7 @@ public:
|
|||||||
* \param unit
|
* \param unit
|
||||||
*/
|
*/
|
||||||
CAltitude(double value, bool msl, const BlackMisc::PhysicalQuantities::CLengthUnit &unit) : BlackMisc::PhysicalQuantities::CLength(value, unit), m_msl(msl) {}
|
CAltitude(double value, bool msl, const BlackMisc::PhysicalQuantities::CLengthUnit &unit) : BlackMisc::PhysicalQuantities::CLength(value, unit), m_msl(msl) {}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Constructor
|
* \brief Constructor
|
||||||
* \param value
|
* \param value
|
||||||
@@ -47,6 +50,7 @@ public:
|
|||||||
* \param unit
|
* \param unit
|
||||||
*/
|
*/
|
||||||
CAltitude(int value, bool msl, const BlackMisc::PhysicalQuantities::CLengthUnit &unit) : CLength(value, unit), m_msl(msl) {}
|
CAltitude(int value, bool msl, const BlackMisc::PhysicalQuantities::CLengthUnit &unit) : CLength(value, unit), m_msl(msl) {}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Constructor by CLength
|
* \brief Constructor by CLength
|
||||||
* \param altitude
|
* \param altitude
|
||||||
@@ -56,29 +60,34 @@ public:
|
|||||||
{
|
{
|
||||||
BlackMisc::PhysicalQuantities::CLength::operator =(altitude);
|
BlackMisc::PhysicalQuantities::CLength::operator =(altitude);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Copy constructor
|
* \brief Copy constructor
|
||||||
* \param otherAltitude
|
* \param otherAltitude
|
||||||
*/
|
*/
|
||||||
CAltitude(const CAltitude &otherAltitude) : BlackMisc::PhysicalQuantities::CLength(otherAltitude), m_msl(otherAltitude.m_msl) {}
|
CAltitude(const CAltitude &otherAltitude) : BlackMisc::PhysicalQuantities::CLength(otherAltitude), m_msl(otherAltitude.m_msl) {}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Assignment operator =
|
* \brief Assignment operator =
|
||||||
* \param otherAltitude
|
* \param otherAltitude
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
CAltitude &operator =(const CAltitude &otherAltitude);
|
CAltitude &operator =(const CAltitude &otherAltitude);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Equal operator ==
|
* \brief Equal operator ==
|
||||||
* \param otherAltitude
|
* \param otherAltitude
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
bool operator ==(const CAltitude &otherAltitude);
|
bool operator ==(const CAltitude &otherAltitude);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Unequal operator ==
|
* \brief Unequal operator ==
|
||||||
* \param otherAltitude
|
* \param otherAltitude
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
bool operator !=(const CAltitude &otherAltitude);
|
bool operator !=(const CAltitude &otherAltitude);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief AGL Above ground level?
|
* \brief AGL Above ground level?
|
||||||
* \return
|
* \return
|
||||||
@@ -87,6 +96,7 @@ public:
|
|||||||
{
|
{
|
||||||
return !this->m_msl;
|
return !this->m_msl;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief MSL Mean sea level?
|
* \brief MSL Mean sea level?
|
||||||
* \return
|
* \return
|
||||||
@@ -100,4 +110,4 @@ public:
|
|||||||
} // namespace
|
} // namespace
|
||||||
} // 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
|
* 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
|
* 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/. */
|
||||||
@@ -7,6 +7,7 @@
|
|||||||
#define BLACKMISC_AVIOBASE_H
|
#define BLACKMISC_AVIOBASE_H
|
||||||
|
|
||||||
// QtGlobal is required for asserts
|
// QtGlobal is required for asserts
|
||||||
|
#include "blackmisc/basestreamstringifier.h"
|
||||||
#include "blackmisc/pqconstants.h"
|
#include "blackmisc/pqconstants.h"
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
|
|
||||||
@@ -18,67 +19,44 @@ namespace Aviation
|
|||||||
/*!
|
/*!
|
||||||
* \brief Base class for avionics
|
* \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:
|
private:
|
||||||
QString m_name; //!< name of the unit
|
QString m_name; //!< name of the unit
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Default constructor
|
* \brief Default constructor
|
||||||
*/
|
*/
|
||||||
CAvionicsBase(const QString &name) : m_name(name) {}
|
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
|
* \brief Are the set values valid / in range
|
||||||
* \return
|
* \return
|
||||||
*/
|
*/
|
||||||
virtual bool validValues() {
|
virtual bool validValues()
|
||||||
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Set name
|
* \brief Set name
|
||||||
* \param name
|
* \param name
|
||||||
*/
|
*/
|
||||||
void setName(const QString &name) {
|
void setName(const QString &name)
|
||||||
|
{
|
||||||
this->m_name = name;
|
this->m_name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief operator ==
|
* \brief operator ==
|
||||||
* \param otherSystem
|
* \param otherSystem
|
||||||
* \return
|
* \return
|
||||||
*/
|
*/
|
||||||
bool operator ==(const CAvionicsBase &otherSystem) const {
|
bool operator ==(const CAvionicsBase &otherSystem) const
|
||||||
|
{
|
||||||
if (this == &otherSystem) return true;
|
if (this == &otherSystem) return true;
|
||||||
return this->m_name == otherSystem.m_name;
|
return this->m_name == otherSystem.m_name;
|
||||||
}
|
}
|
||||||
@@ -88,21 +66,17 @@ public:
|
|||||||
* \brief Virtual destructor
|
* \brief Virtual destructor
|
||||||
*/
|
*/
|
||||||
virtual ~CAvionicsBase() {}
|
virtual ~CAvionicsBase() {}
|
||||||
/*!
|
|
||||||
* \brief Cast as QString
|
|
||||||
*/
|
|
||||||
operator QString() const {
|
|
||||||
return this->stringForStreamingOperator();
|
|
||||||
}
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Name
|
* \brief Name
|
||||||
* \return
|
* \return
|
||||||
*/
|
*/
|
||||||
QString getName() const {
|
QString getName() const
|
||||||
|
{
|
||||||
return this->m_name;
|
return this->m_name;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} // namespace
|
} // namespace
|
||||||
} // 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
|
* 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
|
* 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/. */
|
||||||
@@ -27,6 +27,7 @@ private:
|
|||||||
double fr = f.valueRounded(BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz(), this->m_digits);
|
double fr = f.valueRounded(BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz(), this->m_digits);
|
||||||
return fr >= 118.0 && fr <= 136.975;
|
return fr >= 118.0 && fr <= 136.975;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Valid military aviation frequency?
|
* \brief Valid military aviation frequency?
|
||||||
* \param f
|
* \param f
|
||||||
@@ -36,6 +37,7 @@ private:
|
|||||||
double fr = f.valueRounded(BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz(), this->m_digits);
|
double fr = f.valueRounded(BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz(), this->m_digits);
|
||||||
return fr >= 220.0 && fr <= 399.95;
|
return fr >= 220.0 && fr <= 399.95;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Constructor
|
* \brief Constructor
|
||||||
* \param validate
|
* \param validate
|
||||||
@@ -63,6 +65,7 @@ protected:
|
|||||||
(this->isValidCivilAviationFrequency(this->getFrequencyStandby()) ||
|
(this->isValidCivilAviationFrequency(this->getFrequencyStandby()) ||
|
||||||
this->isValidMilitaryFrequency(this->getFrequencyStandby()));
|
this->isValidMilitaryFrequency(this->getFrequencyStandby()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Validate values by assert and exception
|
* \brief Validate values by assert and exception
|
||||||
* \param strict
|
* \param strict
|
||||||
@@ -78,16 +81,19 @@ protected:
|
|||||||
if (!valid) throw std::range_error("Illegal values in CComSystem::validate");
|
if (!valid) throw std::range_error("Illegal values in CComSystem::validate");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/*!
|
/*!
|
||||||
* Default constructor
|
* Default constructor
|
||||||
*/
|
*/
|
||||||
CComSystem() : CModulator() {}
|
CComSystem() : CModulator() {}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Copy constructor
|
* \brief Copy constructor
|
||||||
* \param otherSystem
|
* \param otherSystem
|
||||||
*/
|
*/
|
||||||
CComSystem(const CComSystem &otherSystem) : CModulator(otherSystem) {}
|
CComSystem(const CComSystem &otherSystem) : CModulator(otherSystem) {}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Constructor
|
* \brief Constructor
|
||||||
* \param name
|
* \param name
|
||||||
@@ -99,6 +105,7 @@ public:
|
|||||||
CModulator(name, activeFrequency, standbyFrequency == CModulator::FrequencyNotSet() ? activeFrequency : standbyFrequency, digits) {
|
CModulator(name, activeFrequency, standbyFrequency == CModulator::FrequencyNotSet() ? activeFrequency : standbyFrequency, digits) {
|
||||||
this->validate(true);
|
this->validate(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Set active frequency
|
* \brief Set active frequency
|
||||||
* \param frequencyMHz
|
* \param frequencyMHz
|
||||||
@@ -107,6 +114,7 @@ public:
|
|||||||
CModulator::setFrequencyActiveMHz(frequencyMHz);
|
CModulator::setFrequencyActiveMHz(frequencyMHz);
|
||||||
this->validate(true);
|
this->validate(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Set standby frequency
|
* \brief Set standby frequency
|
||||||
* \param frequencyMHz
|
* \param frequencyMHz
|
||||||
@@ -115,6 +123,7 @@ public:
|
|||||||
CModulator::setFrequencyStandbyMHz(frequencyMHz);
|
CModulator::setFrequencyStandbyMHz(frequencyMHz);
|
||||||
this->validate(true);
|
this->validate(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Set UNICOM frequency as active
|
* \brief Set UNICOM frequency as active
|
||||||
*/
|
*/
|
||||||
@@ -122,6 +131,7 @@ public:
|
|||||||
this->toggleActiveStandby();
|
this->toggleActiveStandby();
|
||||||
this->setFrequencyActive(BlackMisc::PhysicalQuantities::CPhysicalQuantitiesConstants::FrequencyUnicom());
|
this->setFrequencyActive(BlackMisc::PhysicalQuantities::CPhysicalQuantitiesConstants::FrequencyUnicom());
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Set International Air Distress 121.5MHz
|
* \brief Set International Air Distress 121.5MHz
|
||||||
*/
|
*/
|
||||||
@@ -129,6 +139,7 @@ public:
|
|||||||
this->toggleActiveStandby();
|
this->toggleActiveStandby();
|
||||||
this->setFrequencyActive(BlackMisc::PhysicalQuantities::CPhysicalQuantitiesConstants::FrequencyInternationalAirDistress());
|
this->setFrequencyActive(BlackMisc::PhysicalQuantities::CPhysicalQuantitiesConstants::FrequencyInternationalAirDistress());
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Assigment operator =
|
* \brief Assigment operator =
|
||||||
* \param otherSystem
|
* \param otherSystem
|
||||||
@@ -138,6 +149,7 @@ public:
|
|||||||
CModulator::operator =(otherSystem);
|
CModulator::operator =(otherSystem);
|
||||||
return (*this);
|
return (*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief operator ==
|
* \brief operator ==
|
||||||
* \param otherSystem
|
* \param otherSystem
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ template <class AVIO> void CModulator<AVIO>::toggleActiveStandby()
|
|||||||
/*
|
/*
|
||||||
* String representation
|
* String representation
|
||||||
*/
|
*/
|
||||||
template <class AVIO> QString CModulator<AVIO>::stringForStreamingOperator() const
|
template <class AVIO> QString CModulator<AVIO>::stringForConverter() const
|
||||||
{
|
{
|
||||||
QString s(this->getName());
|
QString s(this->getName());
|
||||||
s.append(" Active: ").append(this->m_frequencyActive.unitValueRoundedWithUnit(3));
|
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
|
* 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
|
* 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/. */
|
||||||
@@ -28,6 +28,7 @@ protected:
|
|||||||
* \brief Default constructor
|
* \brief Default constructor
|
||||||
*/
|
*/
|
||||||
CModulator() : CAvionicsBase("default") {}
|
CModulator() : CAvionicsBase("default") {}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Copy constructor
|
* \brief Copy constructor
|
||||||
* \param otherUnit
|
* \param otherUnit
|
||||||
@@ -35,6 +36,7 @@ protected:
|
|||||||
CModulator(const CModulator &otherUnit) :
|
CModulator(const CModulator &otherUnit) :
|
||||||
m_frequencyActive(otherUnit.m_frequencyActive), m_frequencyStandby(otherUnit.m_frequencyStandby),
|
m_frequencyActive(otherUnit.m_frequencyActive), m_frequencyStandby(otherUnit.m_frequencyStandby),
|
||||||
m_digits(otherUnit.m_digits), CAvionicsBase(otherUnit.getName()) {}
|
m_digits(otherUnit.m_digits), CAvionicsBase(otherUnit.getName()) {}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Constructor
|
* \brief Constructor
|
||||||
* \param name
|
* \param name
|
||||||
@@ -45,51 +47,63 @@ protected:
|
|||||||
CModulator(const QString &name, const BlackMisc::PhysicalQuantities::CFrequency &activeFrequency, const BlackMisc::PhysicalQuantities::CFrequency &standbyFrequency, int digits) :
|
CModulator(const QString &name, const BlackMisc::PhysicalQuantities::CFrequency &activeFrequency, const BlackMisc::PhysicalQuantities::CFrequency &standbyFrequency, int digits) :
|
||||||
m_frequencyActive(activeFrequency),
|
m_frequencyActive(activeFrequency),
|
||||||
m_digits(digits), m_frequencyStandby(standbyFrequency), CAvionicsBase(name) { }
|
m_digits(digits), m_frequencyStandby(standbyFrequency), CAvionicsBase(name) { }
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Meaningful string representation
|
* \brief String for converter
|
||||||
* \return
|
* \return
|
||||||
*/
|
*/
|
||||||
virtual QString stringForStreamingOperator() const;
|
virtual QString stringForConverter() const;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Set active frequency
|
* \brief Set active frequency
|
||||||
* \param frequencyKHz
|
* \param frequencyKHz
|
||||||
*/
|
*/
|
||||||
void setFrequencyActiveKHz(double frequencyKHz) {
|
void setFrequencyActiveKHz(double frequencyKHz)
|
||||||
|
{
|
||||||
this->m_frequencyActive = CFrequency(frequencyKHz, CFrequencyUnit::kHz());
|
this->m_frequencyActive = CFrequency(frequencyKHz, CFrequencyUnit::kHz());
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Set standby frequency
|
* \brief Set standby frequency
|
||||||
* \param frequencyKHz
|
* \param frequencyKHz
|
||||||
*/
|
*/
|
||||||
void setFrequencyStandbyKHz(double frequencyKHz) {
|
void setFrequencyStandbyKHz(double frequencyKHz)
|
||||||
|
{
|
||||||
this->m_frequencyStandby = CFrequency(frequencyKHz, CFrequencyUnit::kHz());
|
this->m_frequencyStandby = CFrequency(frequencyKHz, CFrequencyUnit::kHz());
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Set active frequency
|
* \brief Set active frequency
|
||||||
* \param frequencyMHz
|
* \param frequencyMHz
|
||||||
*/
|
*/
|
||||||
void setFrequencyActiveMHz(double frequencyMHz) {
|
void setFrequencyActiveMHz(double frequencyMHz)
|
||||||
|
{
|
||||||
this->m_frequencyActive = BlackMisc::PhysicalQuantities::CFrequency(frequencyMHz, BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz());
|
this->m_frequencyActive = BlackMisc::PhysicalQuantities::CFrequency(frequencyMHz, BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz());
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Set standby frequency
|
* \brief Set standby frequency
|
||||||
* \param frequencyMHz
|
* \param frequencyMHz
|
||||||
*/
|
*/
|
||||||
void setFrequencyStandbyMHz(double frequencyMHz) {
|
void setFrequencyStandbyMHz(double frequencyMHz)
|
||||||
|
{
|
||||||
this->m_frequencyStandby = BlackMisc::PhysicalQuantities::CFrequency(frequencyMHz, BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz());
|
this->m_frequencyStandby = BlackMisc::PhysicalQuantities::CFrequency(frequencyMHz, BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz());
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Assigment operator =
|
* \brief Assigment operator =
|
||||||
* \param otherModulator
|
* \param otherModulator
|
||||||
* \return
|
* \return
|
||||||
*/
|
*/
|
||||||
CModulator& operator =(const CModulator &otherModulator);
|
CModulator &operator =(const CModulator &otherModulator);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief operator ==
|
* \brief operator ==
|
||||||
* \param otherModulator
|
* \param otherModulator
|
||||||
* \return
|
* \return
|
||||||
*/
|
*/
|
||||||
bool operator ==(const CModulator &otherModulator) const;
|
bool operator ==(const CModulator &otherModulator) const;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief operator !=
|
* \brief operator !=
|
||||||
* \param otherModulator
|
* \param otherModulator
|
||||||
@@ -100,117 +114,146 @@ protected:
|
|||||||
* \brief COM1
|
* \brief COM1
|
||||||
* \return
|
* \return
|
||||||
*/
|
*/
|
||||||
static const QString& NameCom1() {
|
static const QString &NameCom1()
|
||||||
|
{
|
||||||
static QString n("COM1");
|
static QString n("COM1");
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief COM2
|
* \brief COM2
|
||||||
* \return
|
* \return
|
||||||
*/
|
*/
|
||||||
static const QString& NameCom2() {
|
static const QString &NameCom2()
|
||||||
|
{
|
||||||
static QString n("COM2");
|
static QString n("COM2");
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief COM3
|
* \brief COM3
|
||||||
* \return
|
* \return
|
||||||
*/
|
*/
|
||||||
static const QString& NameCom3() {
|
static const QString &NameCom3()
|
||||||
|
{
|
||||||
static QString n("COM3");
|
static QString n("COM3");
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief NAV1
|
* \brief NAV1
|
||||||
* \return
|
* \return
|
||||||
*/
|
*/
|
||||||
static const QString& NameNav1() {
|
static const QString &NameNav1()
|
||||||
|
{
|
||||||
static QString n("NAV1");
|
static QString n("NAV1");
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief NAV2
|
* \brief NAV2
|
||||||
* \return
|
* \return
|
||||||
*/
|
*/
|
||||||
static const QString& NameNav2() {
|
static const QString &NameNav2()
|
||||||
|
{
|
||||||
static QString n("NAV2");
|
static QString n("NAV2");
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief NAV2
|
* \brief NAV2
|
||||||
* \return
|
* \return
|
||||||
*/
|
*/
|
||||||
static const QString& NameNav3() {
|
static const QString &NameNav3()
|
||||||
|
{
|
||||||
static QString n("NAV2");
|
static QString n("NAV2");
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief ADF1
|
* \brief ADF1
|
||||||
* \return
|
* \return
|
||||||
*/
|
*/
|
||||||
static const QString& NameAdf1() {
|
static const QString &NameAdf1()
|
||||||
|
{
|
||||||
static QString n("ADF1");
|
static QString n("ADF1");
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief ADF2
|
* \brief ADF2
|
||||||
* \return
|
* \return
|
||||||
*/
|
*/
|
||||||
static const QString& NameAdf2() {
|
static const QString &NameAdf2()
|
||||||
|
{
|
||||||
static QString n("ADF2");
|
static QString n("ADF2");
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Frequency not set
|
* \brief Frequency not set
|
||||||
* \return
|
* \return
|
||||||
*/
|
*/
|
||||||
static const BlackMisc::PhysicalQuantities::CFrequency& FrequencyNotSet() {
|
static const BlackMisc::PhysicalQuantities::CFrequency &FrequencyNotSet()
|
||||||
|
{
|
||||||
static BlackMisc::PhysicalQuantities::CFrequency f;
|
static BlackMisc::PhysicalQuantities::CFrequency f;
|
||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/*!
|
/*!
|
||||||
* \brief Virtual destructor
|
* \brief Virtual destructor
|
||||||
*/
|
*/
|
||||||
virtual ~CModulator() {}
|
virtual ~CModulator() {}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Default value
|
* \brief Default value
|
||||||
* \return
|
* \return
|
||||||
*/
|
*/
|
||||||
virtual bool isDefaultValue() const {
|
virtual bool isDefaultValue() const
|
||||||
|
{
|
||||||
return this->m_frequencyActive == CModulator::FrequencyNotSet();
|
return this->m_frequencyActive == CModulator::FrequencyNotSet();
|
||||||
}
|
}
|
||||||
/*!
|
/*!
|
||||||
* \brief Toggle active and standby frequencies
|
* \brief Toggle active and standby frequencies
|
||||||
*/
|
*/
|
||||||
void toggleActiveStandby();
|
void toggleActiveStandby();
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Active frequency
|
* \brief Active frequency
|
||||||
* \return
|
* \return
|
||||||
*/
|
*/
|
||||||
BlackMisc::PhysicalQuantities::CFrequency getFrequencyActive() const {
|
BlackMisc::PhysicalQuantities::CFrequency getFrequencyActive() const
|
||||||
|
{
|
||||||
return this->m_frequencyActive;
|
return this->m_frequencyActive;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Standby frequency
|
* \brief Standby frequency
|
||||||
* \return
|
* \return
|
||||||
*/
|
*/
|
||||||
BlackMisc::PhysicalQuantities::CFrequency getFrequencyStandby() const {
|
BlackMisc::PhysicalQuantities::CFrequency getFrequencyStandby() const
|
||||||
|
{
|
||||||
return this->m_frequencyActive;
|
return this->m_frequencyActive;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Set active frequency
|
* \brief Set active frequency
|
||||||
* \param frequency
|
* \param frequency
|
||||||
*/
|
*/
|
||||||
void setFrequencyActive(const BlackMisc::PhysicalQuantities::CFrequency &frequency) {
|
void setFrequencyActive(const BlackMisc::PhysicalQuantities::CFrequency &frequency)
|
||||||
|
{
|
||||||
this->m_frequencyActive = frequency;
|
this->m_frequencyActive = frequency;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Set standby frequency
|
* \brief Set standby frequency
|
||||||
* \param frequency
|
* \param frequency
|
||||||
*/
|
*/
|
||||||
void setFrequencyStandby(const BlackMisc::PhysicalQuantities::CFrequency &frequency) {
|
void setFrequencyStandby(const BlackMisc::PhysicalQuantities::CFrequency &frequency)
|
||||||
|
{
|
||||||
this->m_frequencyStandby = 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
|
* 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
|
* 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/. */
|
||||||
@@ -45,7 +45,7 @@ bool CTransponder::validate(bool strict) const
|
|||||||
/**
|
/**
|
||||||
* String representation
|
* String representation
|
||||||
*/
|
*/
|
||||||
QString CTransponder::stringForStreamingOperator() const
|
QString CTransponder::stringForConverter() const
|
||||||
{
|
{
|
||||||
QString s = this->getName();
|
QString s = this->getName();
|
||||||
s = s.append(" ").append(this->getTransponderCodeFormatted()).append(" ").append(this->getModeAsString());
|
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
|
* 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
|
* 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/. */
|
||||||
@@ -21,7 +21,8 @@ public:
|
|||||||
/*!
|
/*!
|
||||||
* \brief Our transponder codes
|
* \brief Our transponder codes
|
||||||
*/
|
*/
|
||||||
enum TransponderMode {
|
enum TransponderMode
|
||||||
|
{
|
||||||
StateStandby = 0, // not a real mode, more a state
|
StateStandby = 0, // not a real mode, more a state
|
||||||
ModeMil1 = 1, ModeMil2 = 2, ModeMil3 = 3, ModeMil4 = 4, ModeMil5 = 5,
|
ModeMil1 = 1, ModeMil2 = 2, ModeMil3 = 3, ModeMil4 = 4, ModeMil5 = 5,
|
||||||
StateIdent = 10, // not a real mode, more a state
|
StateIdent = 10, // not a real mode, more a state
|
||||||
@@ -41,9 +42,11 @@ private:
|
|||||||
* \param transponderMode
|
* \param transponderMode
|
||||||
*/
|
*/
|
||||||
CTransponder(bool validate, const QString &name, qint32 transponderCode, TransponderMode 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);
|
this->validate(validate);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Constructor for validation
|
* \brief Constructor for validation
|
||||||
* \param validate
|
* \param validate
|
||||||
@@ -52,7 +55,8 @@ private:
|
|||||||
* \param transponderMode
|
* \param transponderMode
|
||||||
*/
|
*/
|
||||||
CTransponder(bool validate, const QString &name, const QString transponderCode, TransponderMode 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;
|
bool ok = false;
|
||||||
this->m_transponderCode = transponderCode.toUInt(&ok);
|
this->m_transponderCode = transponderCode.toUInt(&ok);
|
||||||
if (!ok)this->m_transponderCode = -1; // will cause assert / exception
|
if (!ok)this->m_transponderCode = -1; // will cause assert / exception
|
||||||
@@ -64,13 +68,16 @@ protected:
|
|||||||
* \return
|
* \return
|
||||||
*/
|
*/
|
||||||
bool validValues() const;
|
bool validValues() const;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Default value
|
* \brief Default value
|
||||||
* \return
|
* \return
|
||||||
*/
|
*/
|
||||||
virtual bool isDefaultValue() const {
|
virtual bool isDefaultValue() const
|
||||||
|
{
|
||||||
return this->m_transponderCode == 0;
|
return this->m_transponderCode == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Validate values by assert and exception
|
* \brief Validate values by assert and exception
|
||||||
* \param strict
|
* \param strict
|
||||||
@@ -79,22 +86,26 @@ protected:
|
|||||||
* \return
|
* \return
|
||||||
*/
|
*/
|
||||||
bool validate(bool strict = true) const;
|
bool validate(bool strict = true) const;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Meaningful string representation
|
* \brief Meaningful string representation
|
||||||
* \return
|
* \return
|
||||||
*/
|
*/
|
||||||
virtual QString stringForStreamingOperator() const;
|
virtual QString stringForConverter() const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/*!
|
/*!
|
||||||
* Default constructor
|
* Default constructor
|
||||||
*/
|
*/
|
||||||
CTransponder() : CAvionicsBase("default"), m_transponderCode(0), m_transponderMode(StateStandby) {}
|
CTransponder() : CAvionicsBase("default"), m_transponderCode(0), m_transponderMode(StateStandby) {}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Copy constructor
|
* \brief Copy constructor
|
||||||
* \param otherTransponder
|
* \param otherTransponder
|
||||||
*/
|
*/
|
||||||
CTransponder(const CTransponder &otherTransponder) : CAvionicsBase(otherTransponder.getName()),
|
CTransponder(const CTransponder &otherTransponder) : CAvionicsBase(otherTransponder.getName()),
|
||||||
m_transponderCode(otherTransponder.m_transponderCode), m_transponderMode(otherTransponder.m_transponderMode) {}
|
m_transponderCode(otherTransponder.m_transponderCode), m_transponderMode(otherTransponder.m_transponderMode) {}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Constructor
|
* \brief Constructor
|
||||||
* \param name
|
* \param name
|
||||||
@@ -102,9 +113,11 @@ public:
|
|||||||
* \param transponderMode
|
* \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
|
* \brief Constructor
|
||||||
* \param name
|
* \param name
|
||||||
@@ -112,99 +125,122 @@ public:
|
|||||||
* \param transponderMode
|
* \param transponderMode
|
||||||
*/
|
*/
|
||||||
CTransponder(const QString &name, const QString &transponderCode, TransponderMode 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;
|
bool ok = false;
|
||||||
this->m_transponderCode = transponderCode.toUInt(&ok);
|
this->m_transponderCode = transponderCode.toUInt(&ok);
|
||||||
if (!ok)this->m_transponderCode = -1; // will cause assert / exception
|
if (!ok)this->m_transponderCode = -1; // will cause assert / exception
|
||||||
this->validate(true);
|
this->validate(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Transponder mode as string
|
* \brief Transponder mode as string
|
||||||
* \return
|
* \return
|
||||||
* \throws std::range_erros
|
* \throws std::range_erros
|
||||||
*/
|
*/
|
||||||
QString getModeAsString() const;
|
QString getModeAsString() const;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Transponder mode
|
* \brief Transponder mode
|
||||||
* \return
|
* \return
|
||||||
*/
|
*/
|
||||||
TransponderMode getTransponderMode() const {
|
TransponderMode getTransponderMode() const
|
||||||
|
{
|
||||||
return this->m_transponderMode;
|
return this->m_transponderMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Transponder code
|
* \brief Transponder code
|
||||||
* \return
|
* \return
|
||||||
*/
|
*/
|
||||||
qint32 getTransponderCode() const {
|
qint32 getTransponderCode() const
|
||||||
|
{
|
||||||
return this->m_transponderCode;
|
return this->m_transponderCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Transponder code
|
* \brief Transponder code
|
||||||
* \return
|
* \return
|
||||||
*/
|
*/
|
||||||
QString getTransponderCodeFormatted() const;
|
QString getTransponderCodeFormatted() const;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Set transponder code
|
* \brief Set transponder code
|
||||||
* \param transponderCode
|
* \param transponderCode
|
||||||
*/
|
*/
|
||||||
void setTransponderCode(qint32 transponderCode) {
|
void setTransponderCode(qint32 transponderCode)
|
||||||
|
{
|
||||||
this->m_transponderCode = transponderCode;
|
this->m_transponderCode = transponderCode;
|
||||||
this->validate(true);
|
this->validate(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Set transponder mode
|
* \brief Set transponder mode
|
||||||
* \param mode
|
* \param mode
|
||||||
*/
|
*/
|
||||||
void setTransponderMode(TransponderMode mode) {
|
void setTransponderMode(TransponderMode mode)
|
||||||
|
{
|
||||||
this->m_transponderMode = mode ;
|
this->m_transponderMode = mode ;
|
||||||
this->validate(true);
|
this->validate(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Set emergency
|
* \brief Set emergency
|
||||||
*/
|
*/
|
||||||
void setEmergency() {
|
void setEmergency()
|
||||||
|
{
|
||||||
this->m_transponderCode = 7700;
|
this->m_transponderCode = 7700;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Set emergency
|
* \brief Set emergency
|
||||||
*/
|
*/
|
||||||
void setVFR() {
|
void setVFR()
|
||||||
|
{
|
||||||
this->m_transponderCode = 7000;
|
this->m_transponderCode = 7000;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Set emergency
|
* \brief Set emergency
|
||||||
*/
|
*/
|
||||||
void setIFR() {
|
void setIFR()
|
||||||
|
{
|
||||||
this->m_transponderCode = 2000;
|
this->m_transponderCode = 2000;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Assigment operator =
|
* \brief Assigment operator =
|
||||||
* \param otherTransponder
|
* \param otherTransponder
|
||||||
* \return
|
* \return
|
||||||
*/
|
*/
|
||||||
CTransponder &operator =(const CTransponder &otherTransponder) {
|
CTransponder &operator =(const CTransponder &otherTransponder)
|
||||||
|
{
|
||||||
CAvionicsBase::operator =(otherTransponder);
|
CAvionicsBase::operator =(otherTransponder);
|
||||||
this->m_transponderMode = otherTransponder.m_transponderMode;
|
this->m_transponderMode = otherTransponder.m_transponderMode;
|
||||||
this->m_transponderCode = otherTransponder.m_transponderCode;
|
this->m_transponderCode = otherTransponder.m_transponderCode;
|
||||||
return (*this);
|
return (*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief operator ==
|
* \brief operator ==
|
||||||
* \param otherTransponder
|
* \param otherTransponder
|
||||||
* \return
|
* \return
|
||||||
*/
|
*/
|
||||||
bool operator ==(const CTransponder &otherTransponder) const {
|
bool operator ==(const CTransponder &otherTransponder) const
|
||||||
|
{
|
||||||
return
|
return
|
||||||
this->m_transponderCode == otherTransponder.m_transponderCode &&
|
this->m_transponderCode == otherTransponder.m_transponderCode &&
|
||||||
this->m_transponderMode == otherTransponder.m_transponderMode &&
|
this->m_transponderMode == otherTransponder.m_transponderMode &&
|
||||||
CAvionicsBase::operator ==(otherTransponder);
|
CAvionicsBase::operator ==(otherTransponder);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief operator =!
|
* \brief operator =!
|
||||||
* \param otherSystem
|
* \param otherSystem
|
||||||
* \return
|
* \return
|
||||||
*/
|
*/
|
||||||
bool operator !=(const CTransponder &otherSystem) const {
|
bool operator !=(const CTransponder &otherSystem) const
|
||||||
|
{
|
||||||
return !((*this) == otherSystem);
|
return !((*this) == otherSystem);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -217,7 +253,8 @@ public:
|
|||||||
* \param mode
|
* \param mode
|
||||||
* \return
|
* \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);
|
transponder = CTransponder(false, name, transponderCode, mode);
|
||||||
bool s;
|
bool s;
|
||||||
if (!(s = transponder.validate(false))) transponder = CTransponder(); // reset to default
|
if (!(s = transponder.validate(false))) transponder = CTransponder(); // reset to default
|
||||||
@@ -232,7 +269,8 @@ public:
|
|||||||
* \param mode
|
* \param mode
|
||||||
* \return
|
* \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);
|
transponder = CTransponder(false, name, transponderCode, mode);
|
||||||
bool s;
|
bool s;
|
||||||
if (!(s = transponder.validate(false))) transponder = CTransponder(); // reset to default
|
if (!(s = transponder.validate(false))) transponder = CTransponder(); // reset to default
|
||||||
@@ -244,7 +282,8 @@ public:
|
|||||||
* \param mode
|
* \param mode
|
||||||
* \return
|
* \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);
|
||||||
}
|
}
|
||||||
/*!
|
/*!
|
||||||
@@ -254,7 +293,8 @@ public:
|
|||||||
* \param mode
|
* \param mode
|
||||||
* \return
|
* \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);
|
return CTransponder::tryGetTransponder(transponder, "Transponder", transponderCode, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -265,7 +305,8 @@ public:
|
|||||||
* \param mode
|
* \param mode
|
||||||
* \return
|
* \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);
|
return CTransponder::tryGetTransponder(transponder, "Transponder", transponderCode, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ TEMPLATE = lib
|
|||||||
CONFIG += staticlib
|
CONFIG += staticlib
|
||||||
|
|
||||||
INCLUDEPATH += ..
|
INCLUDEPATH += ..
|
||||||
DEPENDPATH += . ..
|
# DEPENDPATH += . ..
|
||||||
|
|
||||||
#PRECOMPILED_HEADER = stdpch.h
|
#PRECOMPILED_HEADER = stdpch.h
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
#ifndef BLACKMISC_COORDINATEECEF_H
|
#ifndef BLACKMISC_COORDINATEECEF_H
|
||||||
#define BLACKMISC_COORDINATEECEF_H
|
#define BLACKMISC_COORDINATEECEF_H
|
||||||
#include "blackmisc/mathvector3dbase.h"
|
#include "blackmisc/mathvector3d.h"
|
||||||
|
|
||||||
namespace BlackMisc
|
namespace BlackMisc
|
||||||
{
|
{
|
||||||
@@ -30,6 +30,12 @@ public:
|
|||||||
*/
|
*/
|
||||||
CCoordinateEcef(qreal x, qreal y, qreal z) : CVector3DBase(x, y, z) {}
|
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
|
* \brief x
|
||||||
* \return
|
* \return
|
||||||
@@ -83,6 +89,15 @@ public:
|
|||||||
{
|
{
|
||||||
this->m_vector.setZ(z);
|
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
|
} // namespace
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
#ifndef BLACKMISC_COORDINATENED_H
|
#ifndef BLACKMISC_COORDINATENED_H
|
||||||
#define BLACKMISC_COORDINATENED_H
|
#define BLACKMISC_COORDINATENED_H
|
||||||
#include "blackmisc/mathvector3dbase.h"
|
#include "blackmisc/mathvector3d.h"
|
||||||
#include "blackmisc/mathmatrix3x3.h"
|
#include "blackmisc/mathmatrix3x3.h"
|
||||||
#include "blackmisc/coordinategeodetic.h"
|
#include "blackmisc/coordinategeodetic.h"
|
||||||
|
|
||||||
@@ -51,6 +51,19 @@ public:
|
|||||||
CCoordinateNed(const CCoordinateNed &otherNed) :
|
CCoordinateNed(const CCoordinateNed &otherNed) :
|
||||||
CVector3DBase(otherNed) , m_hasReferencePosition(otherNed.m_hasReferencePosition), m_referencePosition(otherNed.m_referencePosition) {}
|
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 ==
|
* \brief Equal operator ==
|
||||||
* \param otherNed
|
* \param otherNed
|
||||||
@@ -171,6 +184,14 @@ public:
|
|||||||
this->m_hasReferencePosition = true;
|
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
|
} // 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
|
* 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
|
* 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"
|
#include "coordinatetransformation.h"
|
||||||
using namespace BlackMisc::PhysicalQuantities;
|
using namespace BlackMisc::PhysicalQuantities;
|
||||||
@@ -18,11 +24,9 @@ namespace Geo
|
|||||||
CCoordinateEcef CCoordinateTransformation::toEcef(const CCoordinateNed &ned)
|
CCoordinateEcef CCoordinateTransformation::toEcef(const CCoordinateNed &ned)
|
||||||
{
|
{
|
||||||
CLatitude lat = ned.referencePosition().latitude();
|
CLatitude lat = ned.referencePosition().latitude();
|
||||||
lat.switchUnit(CAngleUnit::rad());
|
|
||||||
CLongitude lon = ned.referencePosition().longitude();
|
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 dcm1;
|
||||||
CMatrix3x3 dcm2;
|
CMatrix3x3 dcm2;
|
||||||
CMatrix3x3 dcm3;
|
CMatrix3x3 dcm3;
|
||||||
@@ -38,8 +42,7 @@ CCoordinateEcef CCoordinateTransformation::toEcef(const CCoordinateNed &ned)
|
|||||||
dcm2(2, 0) = sin(angleRad);
|
dcm2(2, 0) = sin(angleRad);
|
||||||
dcm2(2, 2) = cos(angleRad);
|
dcm2(2, 2) = cos(angleRad);
|
||||||
|
|
||||||
angleRad = lon.unitValueToDouble();
|
angleRad = lon.value(CAngleUnit::rad());
|
||||||
|
|
||||||
dcm3(0, 0) = cos(angleRad);
|
dcm3(0, 0) = cos(angleRad);
|
||||||
dcm3(0, 1) = sin(angleRad);
|
dcm3(0, 1) = sin(angleRad);
|
||||||
dcm3(1, 0) = -sin(angleRad);
|
dcm3(1, 0) = -sin(angleRad);
|
||||||
@@ -51,12 +54,44 @@ CCoordinateEcef CCoordinateTransformation::toEcef(const CCoordinateNed &ned)
|
|||||||
invDcm.setZero();
|
invDcm.setZero();
|
||||||
invDcm = dcm.inverse();
|
invDcm = dcm.inverse();
|
||||||
|
|
||||||
CCoordinateNed tempResult(ned);
|
CVector3D tempResult = invDcm * ned.toMathVector(); // to generic vector
|
||||||
tempResult.matrixMultiplication(invDcm);
|
CCoordinateEcef result(tempResult);
|
||||||
CCoordinateEcef result(tempResult.north(), tempResult.east(), tempResult.down());
|
|
||||||
|
|
||||||
return result;
|
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
|
} // 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
|
* 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
|
* 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
|
#ifndef BLACKMISC_COORDINATETRANSFORMATION_H
|
||||||
#define BLACKMISC_COORDINATETRANSFORMATION_H
|
#define BLACKMISC_COORDINATETRANSFORMATION_H
|
||||||
@@ -36,6 +43,13 @@ public:
|
|||||||
*/
|
*/
|
||||||
static CCoordinateEcef toEcef(const CCoordinateNed &ned);
|
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
|
} // 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
|
* 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
|
* 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/. */
|
||||||
|
|||||||
@@ -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
|
* 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
|
* 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/. */
|
||||||
@@ -83,6 +83,17 @@ public:
|
|||||||
return m;
|
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
|
* \brief Transposed matrix
|
||||||
* \return
|
* \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
|
* 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
|
* 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/. */
|
||||||
|
|||||||
Reference in New Issue
Block a user