mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-14 16:55:36 +08:00
committed by
Mathew Sutcliffe
parent
229d7c6068
commit
978f3c88e5
@@ -11,284 +11,272 @@
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Aviation
|
||||
{
|
||||
|
||||
/*!
|
||||
* \brief Base class for COM, NAV, Squawk units.
|
||||
*/
|
||||
template <class AVIO> class CModulator : public CAvionicsBase
|
||||
{
|
||||
private:
|
||||
BlackMisc::PhysicalQuantities::CFrequency m_frequencyActive; //!< active frequency
|
||||
BlackMisc::PhysicalQuantities::CFrequency m_frequencyStandby; //!< standby frequency
|
||||
|
||||
protected:
|
||||
int m_digits; //!< digits used
|
||||
|
||||
protected:
|
||||
/*!
|
||||
* \brief Default constructor
|
||||
*/
|
||||
CModulator() : CAvionicsBase("default") {}
|
||||
|
||||
/*!
|
||||
* \brief Copy constructor
|
||||
* \param other
|
||||
*/
|
||||
CModulator(const CModulator &other) : CAvionicsBase(other.getName()),
|
||||
m_frequencyActive(other.m_frequencyActive), m_frequencyStandby(other.m_frequencyStandby), m_digits(other.m_digits) {}
|
||||
|
||||
/*!
|
||||
* \brief Constructor
|
||||
* \param name
|
||||
* \param activeFrequency
|
||||
* \param standbyFrequency
|
||||
* \param digits
|
||||
*/
|
||||
CModulator(const QString &name, const BlackMisc::PhysicalQuantities::CFrequency &activeFrequency, const BlackMisc::PhysicalQuantities::CFrequency &standbyFrequency, int digits) :
|
||||
CAvionicsBase(name), m_frequencyActive(activeFrequency), m_frequencyStandby(standbyFrequency), m_digits(digits) {}
|
||||
|
||||
/*!
|
||||
* \brief String for converter
|
||||
* \param i18n
|
||||
* \return
|
||||
*/
|
||||
virtual QString convertToQString(bool i18n = false) const
|
||||
namespace Aviation
|
||||
{
|
||||
QString s(this->getName());
|
||||
s.append(" Active: ").append(this->m_frequencyActive.valueRoundedWithUnit(3, i18n));
|
||||
s.append(" Standby: ").append(this->m_frequencyStandby.valueRoundedWithUnit(3, i18n));
|
||||
return s;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Set active frequency
|
||||
* \param frequencyKHz
|
||||
*/
|
||||
void setFrequencyActiveKHz(double frequencyKHz)
|
||||
{
|
||||
this->m_frequencyActive = BlackMisc::PhysicalQuantities::CFrequency(frequencyKHz, BlackMisc::PhysicalQuantities::CFrequencyUnit::kHz());
|
||||
}
|
||||
/*!
|
||||
* \brief Base class for COM, NAV, Squawk units.
|
||||
*/
|
||||
template <class AVIO> class CModulator : public CAvionicsBase
|
||||
{
|
||||
private:
|
||||
BlackMisc::PhysicalQuantities::CFrequency m_frequencyActive; //!< active frequency
|
||||
BlackMisc::PhysicalQuantities::CFrequency m_frequencyStandby; //!< standby frequency
|
||||
|
||||
/*!
|
||||
* \brief Set standby frequency
|
||||
* \param frequencyKHz
|
||||
*/
|
||||
void setFrequencyStandbyKHz(double frequencyKHz)
|
||||
{
|
||||
this->m_frequencyStandby = BlackMisc::PhysicalQuantities::CFrequency(frequencyKHz, BlackMisc::PhysicalQuantities::CFrequencyUnit::kHz());
|
||||
}
|
||||
protected:
|
||||
int m_digits; //!< digits used
|
||||
|
||||
/*!
|
||||
* \brief Set active frequency
|
||||
* \param frequencyMHz
|
||||
*/
|
||||
void setFrequencyActiveMHz(double frequencyMHz)
|
||||
{
|
||||
this->m_frequencyActive = BlackMisc::PhysicalQuantities::CFrequency(frequencyMHz, BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz());
|
||||
}
|
||||
protected:
|
||||
/*!
|
||||
* \brief Default constructor
|
||||
*/
|
||||
CModulator() : CAvionicsBase("default") {}
|
||||
|
||||
/*!
|
||||
* \brief Set standby frequency
|
||||
* \param frequencyMHz
|
||||
*/
|
||||
void setFrequencyStandbyMHz(double frequencyMHz)
|
||||
{
|
||||
this->m_frequencyStandby = BlackMisc::PhysicalQuantities::CFrequency(frequencyMHz, BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz());
|
||||
}
|
||||
/*!
|
||||
* \brief Copy constructor
|
||||
* \param other
|
||||
*/
|
||||
CModulator(const CModulator &other) : CAvionicsBase(other.getName()),
|
||||
m_frequencyActive(other.m_frequencyActive), m_frequencyStandby(other.m_frequencyStandby), m_digits(other.m_digits) {}
|
||||
|
||||
/*!
|
||||
* \brief operator ==
|
||||
* \param other
|
||||
* \return
|
||||
*/
|
||||
bool operator ==(const CModulator &other) const;
|
||||
/*!
|
||||
* \brief Constructor
|
||||
* \param name
|
||||
* \param activeFrequency
|
||||
* \param standbyFrequency
|
||||
* \param digits
|
||||
*/
|
||||
CModulator(const QString &name, const BlackMisc::PhysicalQuantities::CFrequency &activeFrequency, const BlackMisc::PhysicalQuantities::CFrequency &standbyFrequency, int digits) :
|
||||
CAvionicsBase(name), m_frequencyActive(activeFrequency), m_frequencyStandby(standbyFrequency), m_digits(digits) {}
|
||||
|
||||
/*!
|
||||
* \brief operator !=
|
||||
* \param other
|
||||
* \return
|
||||
*/
|
||||
bool operator !=(const CModulator &other) const;
|
||||
/*!
|
||||
* \brief String for converter
|
||||
* \param i18n
|
||||
* \return
|
||||
*/
|
||||
virtual QString convertToQString(bool i18n = false) const
|
||||
{
|
||||
QString s(this->getName());
|
||||
s.append(" Active: ").append(this->m_frequencyActive.valueRoundedWithUnit(3, i18n));
|
||||
s.append(" Standby: ").append(this->m_frequencyStandby.valueRoundedWithUnit(3, i18n));
|
||||
return s;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief COM1
|
||||
* \return
|
||||
*/
|
||||
static const QString &NameCom1()
|
||||
{
|
||||
static QString n("COM1");
|
||||
return n;
|
||||
}
|
||||
/*!
|
||||
* \brief Set active frequency
|
||||
* \param frequencyKHz
|
||||
*/
|
||||
void setFrequencyActiveKHz(double frequencyKHz)
|
||||
{
|
||||
this->m_frequencyActive = BlackMisc::PhysicalQuantities::CFrequency(frequencyKHz, BlackMisc::PhysicalQuantities::CFrequencyUnit::kHz());
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief COM2
|
||||
* \return
|
||||
*/
|
||||
static const QString &NameCom2()
|
||||
{
|
||||
static QString n("COM2");
|
||||
return n;
|
||||
}
|
||||
/*!
|
||||
* \brief Set standby frequency
|
||||
* \param frequencyKHz
|
||||
*/
|
||||
void setFrequencyStandbyKHz(double frequencyKHz)
|
||||
{
|
||||
this->m_frequencyStandby = BlackMisc::PhysicalQuantities::CFrequency(frequencyKHz, BlackMisc::PhysicalQuantities::CFrequencyUnit::kHz());
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief COM3
|
||||
* \return
|
||||
*/
|
||||
static const QString &NameCom3()
|
||||
{
|
||||
static QString n("COM3");
|
||||
return n;
|
||||
}
|
||||
/*!
|
||||
* \brief Set active frequency
|
||||
* \param frequencyMHz
|
||||
*/
|
||||
void setFrequencyActiveMHz(double frequencyMHz)
|
||||
{
|
||||
this->m_frequencyActive = BlackMisc::PhysicalQuantities::CFrequency(frequencyMHz, BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz());
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief NAV1
|
||||
* \return
|
||||
*/
|
||||
static const QString &NameNav1()
|
||||
{
|
||||
static QString n("NAV1");
|
||||
return n;
|
||||
}
|
||||
/*!
|
||||
* \brief Set standby frequency
|
||||
* \param frequencyMHz
|
||||
*/
|
||||
void setFrequencyStandbyMHz(double frequencyMHz)
|
||||
{
|
||||
this->m_frequencyStandby = BlackMisc::PhysicalQuantities::CFrequency(frequencyMHz, BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz());
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief NAV2
|
||||
* \return
|
||||
*/
|
||||
static const QString &NameNav2()
|
||||
{
|
||||
static QString n("NAV2");
|
||||
return n;
|
||||
}
|
||||
/*!
|
||||
* \brief operator ==
|
||||
* \param other
|
||||
* \return
|
||||
*/
|
||||
bool operator ==(const CModulator &other) const;
|
||||
|
||||
/*!
|
||||
* \brief NAV2
|
||||
* \return
|
||||
*/
|
||||
static const QString &NameNav3()
|
||||
{
|
||||
static QString n("NAV3");
|
||||
return n;
|
||||
}
|
||||
/*!
|
||||
* \brief operator !=
|
||||
* \param other
|
||||
* \return
|
||||
*/
|
||||
bool operator !=(const CModulator &other) const;
|
||||
|
||||
/*!
|
||||
* \brief ADF1
|
||||
* \return
|
||||
*/
|
||||
static const QString &NameAdf1()
|
||||
{
|
||||
static QString n("ADF1");
|
||||
return n;
|
||||
}
|
||||
/*!
|
||||
* \brief COM1
|
||||
* \return
|
||||
*/
|
||||
static const QString &NameCom1()
|
||||
{
|
||||
static QString n("COM1");
|
||||
return n;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief ADF2
|
||||
* \return
|
||||
*/
|
||||
static const QString &NameAdf2()
|
||||
{
|
||||
static QString n("ADF2");
|
||||
return n;
|
||||
}
|
||||
/*!
|
||||
* \brief COM2
|
||||
* \return
|
||||
*/
|
||||
static const QString &NameCom2()
|
||||
{
|
||||
static QString n("COM2");
|
||||
return n;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Frequency not set
|
||||
* \return
|
||||
*/
|
||||
static const BlackMisc::PhysicalQuantities::CFrequency &FrequencyNotSet()
|
||||
{
|
||||
static BlackMisc::PhysicalQuantities::CFrequency f;
|
||||
return f;
|
||||
}
|
||||
/*!
|
||||
* \brief COM3
|
||||
* \return
|
||||
*/
|
||||
static const QString &NameCom3()
|
||||
{
|
||||
static QString n("COM3");
|
||||
return n;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Stream to DBus <<
|
||||
* \param argument
|
||||
*/
|
||||
virtual void marshallToDbus(QDBusArgument &argument) const
|
||||
{
|
||||
this->CAvionicsBase::marshallToDbus(argument);
|
||||
argument << this->m_frequencyActive;
|
||||
argument << this->m_frequencyStandby;
|
||||
argument << this->m_digits;
|
||||
}
|
||||
/*!
|
||||
* \brief NAV1
|
||||
* \return
|
||||
*/
|
||||
static const QString &NameNav1()
|
||||
{
|
||||
static QString n("NAV1");
|
||||
return n;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Stream from DBus >>
|
||||
* \param argument
|
||||
*/
|
||||
virtual void unmarshallFromDbus(const QDBusArgument &argument)
|
||||
{
|
||||
this->CAvionicsBase::unmarshallFromDbus(argument);
|
||||
argument >> this->m_frequencyActive;
|
||||
argument >> this->m_frequencyStandby;
|
||||
argument >> this->m_digits;
|
||||
}
|
||||
/*!
|
||||
* \brief NAV2
|
||||
* \return
|
||||
*/
|
||||
static const QString &NameNav2()
|
||||
{
|
||||
static QString n("NAV2");
|
||||
return n;
|
||||
}
|
||||
|
||||
public:
|
||||
/*!
|
||||
* \brief Virtual destructor
|
||||
*/
|
||||
virtual ~CModulator() {}
|
||||
/*!
|
||||
* \brief NAV2
|
||||
* \return
|
||||
*/
|
||||
static const QString &NameNav3()
|
||||
{
|
||||
static QString n("NAV3");
|
||||
return n;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Default value
|
||||
* \return
|
||||
*/
|
||||
virtual bool isDefaultValue() const
|
||||
{
|
||||
return this->m_frequencyActive == CModulator::FrequencyNotSet();
|
||||
}
|
||||
/*!
|
||||
* \brief ADF1
|
||||
* \return
|
||||
*/
|
||||
static const QString &NameAdf1()
|
||||
{
|
||||
static QString n("ADF1");
|
||||
return n;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Toggle active and standby frequencies
|
||||
*/
|
||||
void toggleActiveStandby();
|
||||
/*!
|
||||
* \brief ADF2
|
||||
* \return
|
||||
*/
|
||||
static const QString &NameAdf2()
|
||||
{
|
||||
static QString n("ADF2");
|
||||
return n;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Active frequency
|
||||
* \return
|
||||
*/
|
||||
BlackMisc::PhysicalQuantities::CFrequency getFrequencyActive() const
|
||||
{
|
||||
return this->m_frequencyActive;
|
||||
}
|
||||
/*!
|
||||
* \brief Frequency not set
|
||||
* \return
|
||||
*/
|
||||
static const BlackMisc::PhysicalQuantities::CFrequency &FrequencyNotSet()
|
||||
{
|
||||
static BlackMisc::PhysicalQuantities::CFrequency f;
|
||||
return f;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Standby frequency
|
||||
* \return
|
||||
*/
|
||||
BlackMisc::PhysicalQuantities::CFrequency getFrequencyStandby() const
|
||||
{
|
||||
return this->m_frequencyActive;
|
||||
}
|
||||
/*!
|
||||
* \brief Stream to DBus <<
|
||||
* \param argument
|
||||
*/
|
||||
virtual void marshallToDbus(QDBusArgument &argument) const;
|
||||
|
||||
/*!
|
||||
* \brief Set active frequency
|
||||
* \param frequency
|
||||
*/
|
||||
void setFrequencyActive(const BlackMisc::PhysicalQuantities::CFrequency &frequency)
|
||||
{
|
||||
this->m_frequencyActive = frequency;
|
||||
}
|
||||
/*!
|
||||
* \brief Stream from DBus >>
|
||||
* \param argument
|
||||
*/
|
||||
virtual void unmarshallFromDbus(const QDBusArgument &argument);
|
||||
|
||||
/*!
|
||||
* \brief Set standby frequency
|
||||
* \param frequency
|
||||
*/
|
||||
void setFrequencyStandby(const BlackMisc::PhysicalQuantities::CFrequency &frequency)
|
||||
{
|
||||
this->m_frequencyStandby = frequency;
|
||||
}
|
||||
public:
|
||||
/*!
|
||||
* \brief Virtual destructor
|
||||
*/
|
||||
virtual ~CModulator() {}
|
||||
|
||||
/*!
|
||||
* \brief Register metadata
|
||||
*/
|
||||
static void registerMetadata();
|
||||
};
|
||||
/*!
|
||||
* \brief Default value
|
||||
* \return
|
||||
*/
|
||||
virtual bool isDefaultValue() const
|
||||
{
|
||||
return this->m_frequencyActive == CModulator::FrequencyNotSet();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
/*!
|
||||
* \brief Toggle active and standby frequencies
|
||||
*/
|
||||
void toggleActiveStandby();
|
||||
|
||||
/*!
|
||||
* \brief Active frequency
|
||||
* \return
|
||||
*/
|
||||
BlackMisc::PhysicalQuantities::CFrequency getFrequencyActive() const
|
||||
{
|
||||
return this->m_frequencyActive;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Standby frequency
|
||||
* \return
|
||||
*/
|
||||
BlackMisc::PhysicalQuantities::CFrequency getFrequencyStandby() const
|
||||
{
|
||||
return this->m_frequencyActive;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Set active frequency
|
||||
* \param 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)
|
||||
{
|
||||
this->m_frequencyStandby = frequency;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Register metadata
|
||||
*/
|
||||
static void registerMetadata();
|
||||
};
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
#endif // guard
|
||||
|
||||
Reference in New Issue
Block a user