mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-31 12:55:33 +08:00
refs #411, some more DBus tests and some minor adjustments found in course of action
This commit is contained in:
committed by
Mathew Sutcliffe
parent
1b9878fdd3
commit
4aa5f8069e
@@ -15,7 +15,6 @@
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
|
||||
namespace Aviation
|
||||
{
|
||||
|
||||
@@ -29,43 +28,30 @@ namespace BlackMisc
|
||||
public Mixin::CompareByTuple<CAvionicsBase>,
|
||||
public Mixin::String<CAvionicsBase>
|
||||
{
|
||||
protected:
|
||||
QString m_name; //!< name of the unit
|
||||
public:
|
||||
//! Name
|
||||
QString getName() const { return this->m_name; }
|
||||
|
||||
//! \brief Constructor
|
||||
//! Are set values valid?
|
||||
virtual bool validValues() const { return true; }
|
||||
|
||||
protected:
|
||||
//! Constructor
|
||||
CAvionicsBase(const QString &name) : m_name(name) {}
|
||||
|
||||
//! Destructor
|
||||
virtual ~CAvionicsBase() = default;
|
||||
//! Set name
|
||||
void setName(const QString &name) { this->m_name = name; }
|
||||
|
||||
//! \brief Set name
|
||||
void setName(const QString &name)
|
||||
{
|
||||
this->m_name = name;
|
||||
}
|
||||
|
||||
public:
|
||||
//! \copydoc CValueObject::convertToQString
|
||||
QString convertToQString(bool i18n = false) const { Q_UNUSED(i18n); return ""; }
|
||||
|
||||
//! \brief Name
|
||||
QString getName() const
|
||||
{
|
||||
return this->m_name;
|
||||
}
|
||||
|
||||
//! \brief Are set values valid?
|
||||
virtual bool validValues() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
QString m_name; //!< name of the unit
|
||||
BLACK_ENABLE_TUPLE_CONVERSION(CAvionicsBase)
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
BLACK_DECLARE_TUPLE_CONVERSION(BlackMisc::Aviation::CAvionicsBase, (o.m_name))
|
||||
|
||||
|
||||
@@ -145,10 +145,8 @@ namespace BlackMisc
|
||||
return isValidCivilAviationFrequency(f) || isValidMilitaryFrequency(f);
|
||||
}
|
||||
|
||||
/*!
|
||||
* Round to channel spacing, set MHz as unit
|
||||
* \see ChannelSpacing
|
||||
*/
|
||||
//! Round to channel spacing, set MHz as unit
|
||||
//! \see ChannelSpacing
|
||||
static void roundToChannelSpacing(BlackMisc::PhysicalQuantities::CFrequency &frequency, ChannelSpacing channelSpacing);
|
||||
|
||||
//! Is compareFrequency within channel spacing of setFrequency
|
||||
@@ -161,10 +159,8 @@ namespace BlackMisc
|
||||
private:
|
||||
ChannelSpacing m_channelSpacing = ChannelSpacing25KHz; //!< channel spacing
|
||||
|
||||
/*!
|
||||
* Give me channel spacing in KHz
|
||||
* \remarks Just a helper method, that is why no CFrequency is returned
|
||||
*/
|
||||
//! Give me channel spacing in KHz
|
||||
//! \remarks Just a helper method, that is why no CFrequency is returned
|
||||
static double channelSpacingToFrequencyKHz(ChannelSpacing channelSpacing);
|
||||
|
||||
BLACK_ENABLE_TUPLE_CONVERSION(CComSystem)
|
||||
|
||||
@@ -23,12 +23,6 @@ namespace BlackMisc
|
||||
namespace Aviation
|
||||
{
|
||||
|
||||
template <class AVIO>
|
||||
bool CModulator<AVIO>::isDefaultValue() const
|
||||
{
|
||||
return (this->m_frequencyActive == FrequencyNotSet());
|
||||
}
|
||||
|
||||
template <class AVIO>
|
||||
void CModulator<AVIO>::toggleActiveStandby()
|
||||
{
|
||||
@@ -37,66 +31,6 @@ namespace BlackMisc
|
||||
this->m_frequencyStandby = a;
|
||||
}
|
||||
|
||||
template <class AVIO>
|
||||
BlackMisc::PhysicalQuantities::CFrequency CModulator<AVIO>::getFrequencyActive() const
|
||||
{
|
||||
return this->m_frequencyActive;
|
||||
}
|
||||
|
||||
template <class AVIO>
|
||||
BlackMisc::PhysicalQuantities::CFrequency CModulator<AVIO>::getFrequencyStandby() const
|
||||
{
|
||||
return this->m_frequencyStandby;
|
||||
}
|
||||
|
||||
template <class AVIO>
|
||||
void CModulator<AVIO>::setFrequencyActive(const BlackMisc::PhysicalQuantities::CFrequency &frequency)
|
||||
{
|
||||
this->m_frequencyActive = frequency;
|
||||
}
|
||||
|
||||
template <class AVIO>
|
||||
void CModulator<AVIO>::setFrequencyStandby(const BlackMisc::PhysicalQuantities::CFrequency &frequency)
|
||||
{
|
||||
this->m_frequencyStandby = frequency;
|
||||
}
|
||||
|
||||
template <class AVIO>
|
||||
qint32 CModulator<AVIO>::getVolumeOutput() const
|
||||
{
|
||||
return this->m_volumeOutput;
|
||||
}
|
||||
|
||||
template <class AVIO>
|
||||
qint32 CModulator<AVIO>::getVolumeInput() const
|
||||
{
|
||||
return this->m_volumeInput;
|
||||
}
|
||||
|
||||
template <class AVIO>
|
||||
void CModulator<AVIO>::setVolumeOutput(qint32 volume)
|
||||
{
|
||||
this->m_volumeOutput = volume;
|
||||
}
|
||||
|
||||
template <class AVIO>
|
||||
void CModulator<AVIO>::setVolumeInput(qint32 volume)
|
||||
{
|
||||
this->m_volumeInput = volume;
|
||||
}
|
||||
|
||||
template <class AVIO>
|
||||
bool CModulator<AVIO>::isEnabled() const
|
||||
{
|
||||
return this->m_enabled;
|
||||
}
|
||||
|
||||
template <class AVIO>
|
||||
void CModulator<AVIO>::setEnabled(bool enable)
|
||||
{
|
||||
this->m_enabled = enable;
|
||||
}
|
||||
|
||||
template <class AVIO>
|
||||
CVariant CModulator<AVIO>::propertyByIndex(const CPropertyIndex &index) const
|
||||
{
|
||||
@@ -151,14 +85,6 @@ namespace BlackMisc
|
||||
}
|
||||
}
|
||||
|
||||
template <class AVIO>
|
||||
CModulator<AVIO>::CModulator() :
|
||||
CModulator::CValueObject("default") {}
|
||||
|
||||
template <class AVIO>
|
||||
CModulator<AVIO>::CModulator(const QString &name, const BlackMisc::PhysicalQuantities::CFrequency &activeFrequency, const BlackMisc::PhysicalQuantities::CFrequency &standbyFrequency) :
|
||||
CModulator::CValueObject(name), m_frequencyActive(activeFrequency), m_frequencyStandby(standbyFrequency) {}
|
||||
|
||||
template <class AVIO>
|
||||
QString CModulator<AVIO>::convertToQString(bool i18n) const
|
||||
{
|
||||
@@ -168,108 +94,6 @@ namespace BlackMisc
|
||||
return s;
|
||||
}
|
||||
|
||||
template <class AVIO>
|
||||
void CModulator<AVIO>::setFrequencyActiveKHz(double frequencyKHz)
|
||||
{
|
||||
this->m_frequencyActive = BlackMisc::PhysicalQuantities::CFrequency(frequencyKHz, BlackMisc::PhysicalQuantities::CFrequencyUnit::kHz());
|
||||
}
|
||||
|
||||
template <class AVIO>
|
||||
void CModulator<AVIO>::setFrequencyStandbyKHz(double frequencyKHz)
|
||||
{
|
||||
this->m_frequencyStandby = BlackMisc::PhysicalQuantities::CFrequency(frequencyKHz, BlackMisc::PhysicalQuantities::CFrequencyUnit::kHz());
|
||||
}
|
||||
|
||||
|
||||
template <class AVIO>
|
||||
void CModulator<AVIO>::setFrequencyActiveMHz(double frequencyMHz)
|
||||
{
|
||||
frequencyMHz = Math::CMathUtils::round(frequencyMHz, 3);
|
||||
this->m_frequencyActive = BlackMisc::PhysicalQuantities::CFrequency(frequencyMHz, BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz());
|
||||
}
|
||||
|
||||
template <class AVIO>
|
||||
void CModulator<AVIO>::setFrequencyStandbyMHz(double frequencyMHz)
|
||||
{
|
||||
frequencyMHz = Math::CMathUtils::round(frequencyMHz, 3);
|
||||
this->m_frequencyStandby = BlackMisc::PhysicalQuantities::CFrequency(frequencyMHz, BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz());
|
||||
}
|
||||
|
||||
template <class AVIO>
|
||||
const QString &CModulator<AVIO>::NameCom1()
|
||||
{
|
||||
static QString n("COM1");
|
||||
return n;
|
||||
}
|
||||
|
||||
template <class AVIO>
|
||||
const QString &CModulator<AVIO>::NameCom2()
|
||||
{
|
||||
static QString n("COM2");
|
||||
return n;
|
||||
}
|
||||
|
||||
template <class AVIO>
|
||||
const QString &CModulator<AVIO>::NameCom3()
|
||||
{
|
||||
static QString n("COM3");
|
||||
return n;
|
||||
}
|
||||
|
||||
template <class AVIO>
|
||||
const QString &CModulator<AVIO>::NameNav1()
|
||||
{
|
||||
static QString n("NAV1");
|
||||
return n;
|
||||
}
|
||||
|
||||
template <class AVIO>
|
||||
const QString &CModulator<AVIO>::NameNav2()
|
||||
{
|
||||
static QString n("NAV2");
|
||||
return n;
|
||||
}
|
||||
|
||||
template <class AVIO>
|
||||
const QString &CModulator<AVIO>::NameNav3()
|
||||
{
|
||||
static QString n("NAV3");
|
||||
return n;
|
||||
}
|
||||
|
||||
template <class AVIO>
|
||||
const QString &CModulator<AVIO>::NameAdf1()
|
||||
{
|
||||
static QString n("ADF1");
|
||||
return n;
|
||||
}
|
||||
|
||||
template <class AVIO>
|
||||
const QString &CModulator<AVIO>::NameAdf2()
|
||||
{
|
||||
static QString n("ADF2");
|
||||
return n;
|
||||
}
|
||||
|
||||
template <class AVIO>
|
||||
const BlackMisc::PhysicalQuantities::CFrequency &CModulator<AVIO>::FrequencyNotSet()
|
||||
{
|
||||
static BlackMisc::PhysicalQuantities::CFrequency f;
|
||||
return f;
|
||||
}
|
||||
|
||||
template <class AVIO>
|
||||
AVIO const *CModulator<AVIO>::derived() const
|
||||
{
|
||||
return static_cast<AVIO const *>(this);
|
||||
}
|
||||
|
||||
template <class AVIO>
|
||||
AVIO *CModulator<AVIO>::derived()
|
||||
{
|
||||
return static_cast<AVIO *>(this);
|
||||
}
|
||||
|
||||
// see here for the reason of thess forward instantiations
|
||||
// http://www.parashift.com/c++-faq/separate-template-class-defn-from-decl.html
|
||||
template class CModulator<CComSystem>;
|
||||
|
||||
@@ -22,10 +22,6 @@ namespace BlackMisc
|
||||
namespace Aviation
|
||||
{
|
||||
|
||||
class CComSystem;
|
||||
class CNavSystem;
|
||||
class CAdfSystem;
|
||||
|
||||
//! Base class for COM, NAV, Squawk units.
|
||||
template <class AVIO> class CModulator : public CValueObject<CModulator<AVIO>, CAvionicsBase>
|
||||
{
|
||||
@@ -41,126 +37,194 @@ namespace BlackMisc
|
||||
};
|
||||
|
||||
//! Default value?
|
||||
virtual bool isDefaultValue() const;
|
||||
virtual bool isDefaultValue() const
|
||||
{
|
||||
return (this->m_frequencyActive == FrequencyNotSet());
|
||||
}
|
||||
|
||||
//! Toggle active and standby frequencies
|
||||
void toggleActiveStandby();
|
||||
|
||||
//! Active frequency
|
||||
BlackMisc::PhysicalQuantities::CFrequency getFrequencyActive() const;
|
||||
BlackMisc::PhysicalQuantities::CFrequency getFrequencyActive() const
|
||||
{
|
||||
return this->m_frequencyActive;
|
||||
}
|
||||
|
||||
//! Standby frequency
|
||||
BlackMisc::PhysicalQuantities::CFrequency getFrequencyStandby() const;
|
||||
BlackMisc::PhysicalQuantities::CFrequency getFrequencyStandby() const
|
||||
{
|
||||
return this->m_frequencyStandby;
|
||||
}
|
||||
|
||||
//! Set active frequency
|
||||
virtual void setFrequencyActive(const BlackMisc::PhysicalQuantities::CFrequency &frequency);
|
||||
virtual void setFrequencyActive(const BlackMisc::PhysicalQuantities::CFrequency &frequency)
|
||||
{
|
||||
this->m_frequencyActive = frequency;
|
||||
}
|
||||
|
||||
//! Set standby frequency
|
||||
virtual void setFrequencyStandby(const BlackMisc::PhysicalQuantities::CFrequency &frequency);
|
||||
virtual void setFrequencyStandby(const BlackMisc::PhysicalQuantities::CFrequency &frequency)
|
||||
{
|
||||
this->m_frequencyStandby = frequency;
|
||||
}
|
||||
|
||||
//! Output volume 0..100
|
||||
qint32 getVolumeOutput() const;
|
||||
int getVolumeOutput() const { return this->m_volumeOutput; }
|
||||
|
||||
//! Input volume 0..100
|
||||
qint32 getVolumeInput() const;
|
||||
int getVolumeInput() const { return this->m_volumeInput; }
|
||||
|
||||
//! Output volume 0.100
|
||||
void setVolumeOutput(qint32 volume);
|
||||
void setVolumeOutput(int volume) { this->m_volumeOutput = volume; }
|
||||
|
||||
//! Input volume 0..100
|
||||
void setVolumeInput(qint32 volume);
|
||||
void setVolumeInput(int volume) { this->m_volumeInput = volume; }
|
||||
|
||||
//! Enabled?
|
||||
bool isEnabled() const;
|
||||
bool isEnabled() const { return this->m_enabled;}
|
||||
|
||||
//! Enabled?
|
||||
void setEnabled(bool enable);
|
||||
void setEnabled(bool enable) { this->m_enabled = enable;}
|
||||
|
||||
//! \copydoc CValueObject::propertyByIndex
|
||||
CVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const;
|
||||
virtual CVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const override;
|
||||
|
||||
//! \copydoc CValueObject::setPropertyByIndex
|
||||
void setPropertyByIndex(const CVariant &variant, const BlackMisc::CPropertyIndex &index);
|
||||
|
||||
//! \copydoc CValueObject::convertToQString
|
||||
QString convertToQString(bool i18n = false) const;
|
||||
virtual void setPropertyByIndex(const CVariant &variant, const BlackMisc::CPropertyIndex &index) override;
|
||||
|
||||
protected:
|
||||
//! Default constructor
|
||||
CModulator();
|
||||
CModulator() : CModulator::CValueObject("default") {}
|
||||
|
||||
//! Constructor
|
||||
CModulator(const QString &name, const BlackMisc::PhysicalQuantities::CFrequency &activeFrequency, const BlackMisc::PhysicalQuantities::CFrequency &standbyFrequency);
|
||||
CModulator(const QString &name, const BlackMisc::PhysicalQuantities::CFrequency &activeFrequency, const BlackMisc::PhysicalQuantities::CFrequency &standbyFrequency) :
|
||||
CModulator::CValueObject(name), m_frequencyActive(activeFrequency), m_frequencyStandby(standbyFrequency) {}
|
||||
|
||||
//! \copydoc CValueObject::convertToQString
|
||||
virtual QString convertToQString(bool i18n = false) const override;
|
||||
|
||||
//! Set active frequency
|
||||
void setFrequencyActiveKHz(double frequencyKHz);
|
||||
void setFrequencyActiveKHz(double frequencyKHz)
|
||||
{
|
||||
this->m_frequencyActive = BlackMisc::PhysicalQuantities::CFrequency(frequencyKHz, BlackMisc::PhysicalQuantities::CFrequencyUnit::kHz());
|
||||
}
|
||||
|
||||
//! Set standby frequency
|
||||
void setFrequencyStandbyKHz(double frequencyKHz);
|
||||
void setFrequencyStandbyKHz(double frequencyKHz)
|
||||
{
|
||||
this->m_frequencyStandby = BlackMisc::PhysicalQuantities::CFrequency(frequencyKHz, BlackMisc::PhysicalQuantities::CFrequencyUnit::kHz());
|
||||
}
|
||||
|
||||
//! Set active frequency
|
||||
virtual void setFrequencyActiveMHz(double frequencyMHz);
|
||||
virtual void setFrequencyActiveMHz(double frequencyMHz)
|
||||
{
|
||||
frequencyMHz = Math::CMathUtils::round(frequencyMHz, 3);
|
||||
this->m_frequencyActive = BlackMisc::PhysicalQuantities::CFrequency(frequencyMHz, BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz());
|
||||
}
|
||||
|
||||
//! Set standby frequency
|
||||
virtual void setFrequencyStandbyMHz(double frequencyMHz);
|
||||
virtual void setFrequencyStandbyMHz(double frequencyMHz)
|
||||
{
|
||||
frequencyMHz = Math::CMathUtils::round(frequencyMHz, 3);
|
||||
this->m_frequencyStandby = BlackMisc::PhysicalQuantities::CFrequency(frequencyMHz, BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz());
|
||||
}
|
||||
|
||||
//! COM1
|
||||
static const QString &NameCom1();
|
||||
static const QString &NameCom1()
|
||||
{
|
||||
static const QString n("COM1");
|
||||
return n;
|
||||
}
|
||||
|
||||
//! COM2
|
||||
static const QString &NameCom2();
|
||||
static const QString &NameCom2()
|
||||
{
|
||||
static const QString n("COM2");
|
||||
return n;
|
||||
}
|
||||
|
||||
//! COM3
|
||||
static const QString &NameCom3();
|
||||
static const QString &NameCom3()
|
||||
{
|
||||
static const QString n("COM3");
|
||||
return n;
|
||||
}
|
||||
|
||||
//! NAV1
|
||||
static const QString &NameNav1();
|
||||
static const QString &NameNav1()
|
||||
{
|
||||
static const QString n("NAV1");
|
||||
return n;
|
||||
}
|
||||
|
||||
//! NAV2
|
||||
static const QString &NameNav2();
|
||||
static const QString &NameNav2()
|
||||
{
|
||||
static const QString n("NAV2");
|
||||
return n;
|
||||
}
|
||||
|
||||
//! NAV3
|
||||
static const QString &NameNav3();
|
||||
static const QString &NameNav3()
|
||||
{
|
||||
static const QString n("NAV3");
|
||||
return n;
|
||||
}
|
||||
|
||||
//! ADF1
|
||||
static const QString &NameAdf1();
|
||||
static const QString &NameAdf1()
|
||||
{
|
||||
static QString n("ADF1");
|
||||
return n;
|
||||
}
|
||||
|
||||
//! ADF2
|
||||
static const QString &NameAdf2();
|
||||
static const QString &NameAdf2()
|
||||
{
|
||||
static QString n("ADF2");
|
||||
return n;
|
||||
}
|
||||
|
||||
//! Frequency not set
|
||||
static const BlackMisc::PhysicalQuantities::CFrequency &FrequencyNotSet();
|
||||
static const BlackMisc::PhysicalQuantities::CFrequency &FrequencyNotSet()
|
||||
{
|
||||
static const BlackMisc::PhysicalQuantities::CFrequency f(0, BlackMisc::PhysicalQuantities::CFrequencyUnit::nullUnit());
|
||||
return f;
|
||||
}
|
||||
|
||||
private:
|
||||
BLACK_ENABLE_TUPLE_CONVERSION(CModulator)
|
||||
BlackMisc::PhysicalQuantities::CFrequency m_frequencyActive; //!< active frequency
|
||||
BlackMisc::PhysicalQuantities::CFrequency m_frequencyStandby; //!< standby frequency
|
||||
qint32 m_volumeInput = 0; //!< volume input
|
||||
qint32 m_volumeOutput = 0; //!< volume output
|
||||
int m_volumeInput = 0; //!< volume input
|
||||
int m_volumeOutput = 0; //!< volume output
|
||||
bool m_enabled = true; //!< is enabled, used e.g. for mute etc.
|
||||
|
||||
//! Easy access to derived class (CRTP template parameter)
|
||||
AVIO const *derived() const;
|
||||
AVIO const *derived() const { return static_cast<AVIO const *>(this); }
|
||||
|
||||
//! Easy access to derived class (CRTP template parameter)
|
||||
AVIO *derived();
|
||||
AVIO *derived() { return static_cast<AVIO *>(this); }
|
||||
|
||||
//! \cond PRIVATE
|
||||
class CComSystem;
|
||||
class CNavSystem;
|
||||
class CAdfSystem;
|
||||
|
||||
extern template class BLACKMISC_EXPORT_TEMPLATE CModulator<CComSystem>;
|
||||
extern template class BLACKMISC_EXPORT_TEMPLATE CModulator<CNavSystem>;
|
||||
extern template class BLACKMISC_EXPORT_TEMPLATE CModulator<CAdfSystem>;
|
||||
//! \endcond
|
||||
};
|
||||
|
||||
//! \cond PRIVATE
|
||||
extern template class BLACKMISC_EXPORT_TEMPLATE CModulator<CComSystem>;
|
||||
extern template class BLACKMISC_EXPORT_TEMPLATE CModulator<CNavSystem>;
|
||||
extern template class BLACKMISC_EXPORT_TEMPLATE CModulator<CAdfSystem>;
|
||||
//! \endcond
|
||||
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
BLACK_DECLARE_TUPLE_CONVERSION_TEMPLATE(BlackMisc::Aviation::CModulator, (
|
||||
o.m_frequencyActive,
|
||||
o.m_frequencyStandby,
|
||||
o.m_volumeInput ,
|
||||
o.m_volumeOutput,
|
||||
o.m_enabled
|
||||
))
|
||||
o.m_frequencyActive,
|
||||
o.m_frequencyStandby,
|
||||
o.m_volumeInput ,
|
||||
o.m_volumeOutput,
|
||||
o.m_enabled))
|
||||
|
||||
#endif // guard
|
||||
|
||||
Reference in New Issue
Block a user