mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-21 04:45:31 +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
@@ -255,7 +255,8 @@ namespace BlackMiscTest
|
|||||||
// on the client's side
|
// on the client's side
|
||||||
TestServiceInterface testserviceInterface(Testservice::ServiceName, Testservice::ServicePath, connection);
|
TestServiceInterface testserviceInterface(Testservice::ServiceName, Testservice::ServicePath, connection);
|
||||||
|
|
||||||
CSpeed speed(200, BlackMisc::PhysicalQuantities::CSpeedUnit::km_h());
|
CSpeed speed(200, CSpeedUnit::km_h());
|
||||||
|
CSpeed speedNull(0, CSpeedUnit::nullUnit());
|
||||||
CAltitude al(1000, CAltitude::MeanSeaLevel, CLengthUnit::ft());
|
CAltitude al(1000, CAltitude::MeanSeaLevel, CLengthUnit::ft());
|
||||||
QTextStream qtin(stdin);
|
QTextStream qtin(stdin);
|
||||||
QString line;
|
QString line;
|
||||||
@@ -289,7 +290,8 @@ namespace BlackMiscTest
|
|||||||
// PQs
|
// PQs
|
||||||
testserviceInterface.receiveSpeed(speed);
|
testserviceInterface.receiveSpeed(speed);
|
||||||
qDebug() << "Send speed via interface" << speed;
|
qDebug() << "Send speed via interface" << speed;
|
||||||
|
testserviceInterface.receiveSpeed(speedNull);
|
||||||
|
qDebug() << "Send null speed via interface" << speedNull;
|
||||||
speed.switchUnit(CSpeedUnit::kts());
|
speed.switchUnit(CSpeedUnit::kts());
|
||||||
testserviceInterface.receiveSpeed(speed);
|
testserviceInterface.receiveSpeed(speed);
|
||||||
qDebug() << "Send speed via interface" << speed;
|
qDebug() << "Send speed via interface" << speed;
|
||||||
@@ -367,8 +369,22 @@ namespace BlackMiscTest
|
|||||||
qDebug() << "Pinged ATC station via interface"
|
qDebug() << "Pinged ATC station via interface"
|
||||||
<< ((station == stationReceived) ? "OK" : "ERROR!") << stationReceived;
|
<< ((station == stationReceived) ? "OK" : "ERROR!") << stationReceived;
|
||||||
|
|
||||||
|
CUser pingUser("223344", "Ping Me user");
|
||||||
|
CUser userReceived = testserviceInterface.pingUser(pingUser);
|
||||||
|
qDebug() << "Pinged user via interface"
|
||||||
|
<< ((userReceived == pingUser) ? "OK" : "ERROR!") << userReceived;
|
||||||
|
|
||||||
CAircraftSituation situation;
|
CAircraftSituation situation;
|
||||||
|
CAircraftSituation situationReceived = testserviceInterface.pingSituation(situation);
|
||||||
|
qDebug() << "Pinged situation via interface"
|
||||||
|
<< ((situation == situationReceived) ? "OK" : "ERROR!") << situationReceived;
|
||||||
|
|
||||||
|
CTransponder transponderReceived = testserviceInterface.pingTransponder(transponder);
|
||||||
|
qDebug() << "Pinged transponder via interface"
|
||||||
|
<< ((transponderReceived == transponder) ? "OK" : "ERROR!") << transponderReceived;
|
||||||
|
|
||||||
CAircraft aircraft(callsign, CUser("123456", "Joe Pilot"), situation);
|
CAircraft aircraft(callsign, CUser("123456", "Joe Pilot"), situation);
|
||||||
|
aircraft.setTransponder(transponder);
|
||||||
CAircraft aircraftReceived = testserviceInterface.pingAircraft(aircraft);
|
CAircraft aircraftReceived = testserviceInterface.pingAircraft(aircraft);
|
||||||
qDebug() << "Pinged aircraft via interface"
|
qDebug() << "Pinged aircraft via interface"
|
||||||
<< ((aircraft == aircraftReceived) ? "OK" : "ERROR!") << aircraftReceived;
|
<< ((aircraft == aircraftReceived) ? "OK" : "ERROR!") << aircraftReceived;
|
||||||
|
|||||||
@@ -300,6 +300,33 @@ namespace BlackMiscTest
|
|||||||
return altitude;
|
return altitude;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Ping user
|
||||||
|
*/
|
||||||
|
CUser Testservice::pingUser(const CUser &user)
|
||||||
|
{
|
||||||
|
qDebug() << "Pid:" << ServiceTool::getPid() << "ping user:" << user;
|
||||||
|
return user;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Ping situation
|
||||||
|
*/
|
||||||
|
BlackMisc::Aviation::CAircraftSituation Testservice::pingSituation(const BlackMisc::Aviation::CAircraftSituation &situation)
|
||||||
|
{
|
||||||
|
qDebug() << "Pid:" << ServiceTool::getPid() << "ping situation:" << situation;
|
||||||
|
return situation;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Ping transponder
|
||||||
|
*/
|
||||||
|
BlackMisc::Aviation::CTransponder Testservice::pingTransponder(const BlackMisc::Aviation::CTransponder &transponder)
|
||||||
|
{
|
||||||
|
qDebug() << "Pid:" << ServiceTool::getPid() << "ping transponder:" << transponder;
|
||||||
|
return transponder;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Ping ATC station
|
* Ping ATC station
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -100,15 +100,24 @@ namespace BlackMiscTest
|
|||||||
//! Receive an value map
|
//! Receive an value map
|
||||||
void receiveValueMap(const BlackMisc::CPropertyIndexVariantMap &valueMap) const;
|
void receiveValueMap(const BlackMisc::CPropertyIndexVariantMap &valueMap) const;
|
||||||
|
|
||||||
//! Receive speed
|
//! Ping speed
|
||||||
BlackMisc::PhysicalQuantities::CSpeed pingSpeed(const BlackMisc::PhysicalQuantities::CSpeed &speed);
|
BlackMisc::PhysicalQuantities::CSpeed pingSpeed(const BlackMisc::PhysicalQuantities::CSpeed &speed);
|
||||||
|
|
||||||
//! Receive altitude
|
//! Ping altitude
|
||||||
BlackMisc::Aviation::CAltitude pingAltitude(const BlackMisc::Aviation::CAltitude &altitude);
|
BlackMisc::Aviation::CAltitude pingAltitude(const BlackMisc::Aviation::CAltitude &altitude);
|
||||||
|
|
||||||
|
//! Ping user
|
||||||
|
BlackMisc::Network::CUser pingUser(const BlackMisc::Network::CUser &user);
|
||||||
|
|
||||||
|
//! Ping situation
|
||||||
|
BlackMisc::Aviation::CAircraftSituation pingSituation(const BlackMisc::Aviation::CAircraftSituation &situation);
|
||||||
|
|
||||||
//! Ping ATC station
|
//! Ping ATC station
|
||||||
BlackMisc::Aviation::CAtcStation pingAtcStation(const BlackMisc::Aviation::CAtcStation &station);
|
BlackMisc::Aviation::CAtcStation pingAtcStation(const BlackMisc::Aviation::CAtcStation &station);
|
||||||
|
|
||||||
|
//! Ping transponder
|
||||||
|
BlackMisc::Aviation::CTransponder pingTransponder(const BlackMisc::Aviation::CTransponder &transponder);
|
||||||
|
|
||||||
//! Ping aircraft
|
//! Ping aircraft
|
||||||
BlackMisc::Aviation::CAircraft pingAircraft(const BlackMisc::Aviation::CAircraft &aircraft);
|
BlackMisc::Aviation::CAircraft pingAircraft(const BlackMisc::Aviation::CAircraft &aircraft);
|
||||||
|
|
||||||
|
|||||||
@@ -94,6 +94,27 @@ namespace BlackMiscTest
|
|||||||
return asyncCallWithArgumentList(QLatin1String("pingAltitude"), argumentList);
|
return asyncCallWithArgumentList(QLatin1String("pingAltitude"), argumentList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline QDBusPendingReply<BlackMisc::Aviation::CAircraftSituation> pingSituation(BlackMisc::Aviation::CAircraftSituation situation)
|
||||||
|
{
|
||||||
|
QList<QVariant> argumentList;
|
||||||
|
argumentList << QVariant::fromValue(situation);
|
||||||
|
return asyncCallWithArgumentList(QLatin1String("pingSituation"), argumentList);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline QDBusPendingReply<BlackMisc::Network::CUser> pingUser(BlackMisc::Network::CUser user)
|
||||||
|
{
|
||||||
|
QList<QVariant> argumentList;
|
||||||
|
argumentList << QVariant::fromValue(user);
|
||||||
|
return asyncCallWithArgumentList(QLatin1String("pingUser"), argumentList);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline QDBusPendingReply<BlackMisc::Aviation::CTransponder> pingTransponder(BlackMisc::Aviation::CTransponder transponder)
|
||||||
|
{
|
||||||
|
QList<QVariant> argumentList;
|
||||||
|
argumentList << QVariant::fromValue(transponder);
|
||||||
|
return asyncCallWithArgumentList(QLatin1String("pingTransponder"), argumentList);
|
||||||
|
}
|
||||||
|
|
||||||
inline QDBusPendingReply<BlackMisc::Aviation::CAtcStation> pingAtcStation(BlackMisc::Aviation::CAtcStation station)
|
inline QDBusPendingReply<BlackMisc::Aviation::CAtcStation> pingAtcStation(BlackMisc::Aviation::CAtcStation station)
|
||||||
{
|
{
|
||||||
QList<QVariant> argumentList;
|
QList<QVariant> argumentList;
|
||||||
|
|||||||
@@ -15,7 +15,6 @@
|
|||||||
|
|
||||||
namespace BlackMisc
|
namespace BlackMisc
|
||||||
{
|
{
|
||||||
|
|
||||||
namespace Aviation
|
namespace Aviation
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -29,43 +28,30 @@ namespace BlackMisc
|
|||||||
public Mixin::CompareByTuple<CAvionicsBase>,
|
public Mixin::CompareByTuple<CAvionicsBase>,
|
||||||
public Mixin::String<CAvionicsBase>
|
public Mixin::String<CAvionicsBase>
|
||||||
{
|
{
|
||||||
protected:
|
public:
|
||||||
QString m_name; //!< name of the unit
|
//! 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) {}
|
CAvionicsBase(const QString &name) : m_name(name) {}
|
||||||
|
|
||||||
//! Destructor
|
//! Set name
|
||||||
virtual ~CAvionicsBase() = default;
|
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
|
//! \copydoc CValueObject::convertToQString
|
||||||
QString convertToQString(bool i18n = false) const { Q_UNUSED(i18n); return ""; }
|
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:
|
private:
|
||||||
|
QString m_name; //!< name of the unit
|
||||||
BLACK_ENABLE_TUPLE_CONVERSION(CAvionicsBase)
|
BLACK_ENABLE_TUPLE_CONVERSION(CAvionicsBase)
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace
|
||||||
}
|
} // namespace
|
||||||
|
|
||||||
BLACK_DECLARE_TUPLE_CONVERSION(BlackMisc::Aviation::CAvionicsBase, (o.m_name))
|
BLACK_DECLARE_TUPLE_CONVERSION(BlackMisc::Aviation::CAvionicsBase, (o.m_name))
|
||||||
|
|
||||||
|
|||||||
@@ -145,10 +145,8 @@ namespace BlackMisc
|
|||||||
return isValidCivilAviationFrequency(f) || isValidMilitaryFrequency(f);
|
return isValidCivilAviationFrequency(f) || isValidMilitaryFrequency(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
//! Round to channel spacing, set MHz as unit
|
||||||
* Round to channel spacing, set MHz as unit
|
//! \see ChannelSpacing
|
||||||
* \see ChannelSpacing
|
|
||||||
*/
|
|
||||||
static void roundToChannelSpacing(BlackMisc::PhysicalQuantities::CFrequency &frequency, ChannelSpacing channelSpacing);
|
static void roundToChannelSpacing(BlackMisc::PhysicalQuantities::CFrequency &frequency, ChannelSpacing channelSpacing);
|
||||||
|
|
||||||
//! Is compareFrequency within channel spacing of setFrequency
|
//! Is compareFrequency within channel spacing of setFrequency
|
||||||
@@ -161,10 +159,8 @@ namespace BlackMisc
|
|||||||
private:
|
private:
|
||||||
ChannelSpacing m_channelSpacing = ChannelSpacing25KHz; //!< channel spacing
|
ChannelSpacing m_channelSpacing = ChannelSpacing25KHz; //!< channel spacing
|
||||||
|
|
||||||
/*!
|
//! Give me channel spacing in KHz
|
||||||
* Give me channel spacing in KHz
|
//! \remarks Just a helper method, that is why no CFrequency is returned
|
||||||
* \remarks Just a helper method, that is why no CFrequency is returned
|
|
||||||
*/
|
|
||||||
static double channelSpacingToFrequencyKHz(ChannelSpacing channelSpacing);
|
static double channelSpacingToFrequencyKHz(ChannelSpacing channelSpacing);
|
||||||
|
|
||||||
BLACK_ENABLE_TUPLE_CONVERSION(CComSystem)
|
BLACK_ENABLE_TUPLE_CONVERSION(CComSystem)
|
||||||
|
|||||||
@@ -23,12 +23,6 @@ namespace BlackMisc
|
|||||||
namespace Aviation
|
namespace Aviation
|
||||||
{
|
{
|
||||||
|
|
||||||
template <class AVIO>
|
|
||||||
bool CModulator<AVIO>::isDefaultValue() const
|
|
||||||
{
|
|
||||||
return (this->m_frequencyActive == FrequencyNotSet());
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class AVIO>
|
template <class AVIO>
|
||||||
void CModulator<AVIO>::toggleActiveStandby()
|
void CModulator<AVIO>::toggleActiveStandby()
|
||||||
{
|
{
|
||||||
@@ -37,66 +31,6 @@ namespace BlackMisc
|
|||||||
this->m_frequencyStandby = a;
|
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>
|
template <class AVIO>
|
||||||
CVariant CModulator<AVIO>::propertyByIndex(const CPropertyIndex &index) const
|
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>
|
template <class AVIO>
|
||||||
QString CModulator<AVIO>::convertToQString(bool i18n) const
|
QString CModulator<AVIO>::convertToQString(bool i18n) const
|
||||||
{
|
{
|
||||||
@@ -168,108 +94,6 @@ namespace BlackMisc
|
|||||||
return s;
|
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
|
// see here for the reason of thess forward instantiations
|
||||||
// http://www.parashift.com/c++-faq/separate-template-class-defn-from-decl.html
|
// http://www.parashift.com/c++-faq/separate-template-class-defn-from-decl.html
|
||||||
template class CModulator<CComSystem>;
|
template class CModulator<CComSystem>;
|
||||||
|
|||||||
@@ -22,10 +22,6 @@ namespace BlackMisc
|
|||||||
namespace Aviation
|
namespace Aviation
|
||||||
{
|
{
|
||||||
|
|
||||||
class CComSystem;
|
|
||||||
class CNavSystem;
|
|
||||||
class CAdfSystem;
|
|
||||||
|
|
||||||
//! Base class for COM, NAV, Squawk units.
|
//! Base class for COM, NAV, Squawk units.
|
||||||
template <class AVIO> class CModulator : public CValueObject<CModulator<AVIO>, CAvionicsBase>
|
template <class AVIO> class CModulator : public CValueObject<CModulator<AVIO>, CAvionicsBase>
|
||||||
{
|
{
|
||||||
@@ -41,126 +37,194 @@ namespace BlackMisc
|
|||||||
};
|
};
|
||||||
|
|
||||||
//! Default value?
|
//! Default value?
|
||||||
virtual bool isDefaultValue() const;
|
virtual bool isDefaultValue() const
|
||||||
|
{
|
||||||
|
return (this->m_frequencyActive == FrequencyNotSet());
|
||||||
|
}
|
||||||
|
|
||||||
//! Toggle active and standby frequencies
|
//! Toggle active and standby frequencies
|
||||||
void toggleActiveStandby();
|
void toggleActiveStandby();
|
||||||
|
|
||||||
//! Active frequency
|
//! Active frequency
|
||||||
BlackMisc::PhysicalQuantities::CFrequency getFrequencyActive() const;
|
BlackMisc::PhysicalQuantities::CFrequency getFrequencyActive() const
|
||||||
|
{
|
||||||
|
return this->m_frequencyActive;
|
||||||
|
}
|
||||||
|
|
||||||
//! Standby frequency
|
//! Standby frequency
|
||||||
BlackMisc::PhysicalQuantities::CFrequency getFrequencyStandby() const;
|
BlackMisc::PhysicalQuantities::CFrequency getFrequencyStandby() const
|
||||||
|
{
|
||||||
|
return this->m_frequencyStandby;
|
||||||
|
}
|
||||||
|
|
||||||
//! Set active frequency
|
//! 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
|
//! 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
|
//! Output volume 0..100
|
||||||
qint32 getVolumeOutput() const;
|
int getVolumeOutput() const { return this->m_volumeOutput; }
|
||||||
|
|
||||||
//! Input volume 0..100
|
//! Input volume 0..100
|
||||||
qint32 getVolumeInput() const;
|
int getVolumeInput() const { return this->m_volumeInput; }
|
||||||
|
|
||||||
//! Output volume 0.100
|
//! Output volume 0.100
|
||||||
void setVolumeOutput(qint32 volume);
|
void setVolumeOutput(int volume) { this->m_volumeOutput = volume; }
|
||||||
|
|
||||||
//! Input volume 0..100
|
//! Input volume 0..100
|
||||||
void setVolumeInput(qint32 volume);
|
void setVolumeInput(int volume) { this->m_volumeInput = volume; }
|
||||||
|
|
||||||
//! Enabled?
|
//! Enabled?
|
||||||
bool isEnabled() const;
|
bool isEnabled() const { return this->m_enabled;}
|
||||||
|
|
||||||
//! Enabled?
|
//! Enabled?
|
||||||
void setEnabled(bool enable);
|
void setEnabled(bool enable) { this->m_enabled = enable;}
|
||||||
|
|
||||||
//! \copydoc CValueObject::propertyByIndex
|
//! \copydoc CValueObject::propertyByIndex
|
||||||
CVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const;
|
virtual CVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const override;
|
||||||
|
|
||||||
//! \copydoc CValueObject::setPropertyByIndex
|
//! \copydoc CValueObject::setPropertyByIndex
|
||||||
void setPropertyByIndex(const CVariant &variant, const BlackMisc::CPropertyIndex &index);
|
virtual void setPropertyByIndex(const CVariant &variant, const BlackMisc::CPropertyIndex &index) override;
|
||||||
|
|
||||||
//! \copydoc CValueObject::convertToQString
|
|
||||||
QString convertToQString(bool i18n = false) const;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
//! Default constructor
|
//! Default constructor
|
||||||
CModulator();
|
CModulator() : CModulator::CValueObject("default") {}
|
||||||
|
|
||||||
//! Constructor
|
//! 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
|
//! 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
|
//! 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
|
//! 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
|
//! 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
|
//! COM1
|
||||||
static const QString &NameCom1();
|
static const QString &NameCom1()
|
||||||
|
{
|
||||||
|
static const QString n("COM1");
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
//! COM2
|
//! COM2
|
||||||
static const QString &NameCom2();
|
static const QString &NameCom2()
|
||||||
|
{
|
||||||
|
static const QString n("COM2");
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
//! COM3
|
//! COM3
|
||||||
static const QString &NameCom3();
|
static const QString &NameCom3()
|
||||||
|
{
|
||||||
|
static const QString n("COM3");
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
//! NAV1
|
//! NAV1
|
||||||
static const QString &NameNav1();
|
static const QString &NameNav1()
|
||||||
|
{
|
||||||
|
static const QString n("NAV1");
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
//! NAV2
|
//! NAV2
|
||||||
static const QString &NameNav2();
|
static const QString &NameNav2()
|
||||||
|
{
|
||||||
|
static const QString n("NAV2");
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
//! NAV3
|
//! NAV3
|
||||||
static const QString &NameNav3();
|
static const QString &NameNav3()
|
||||||
|
{
|
||||||
|
static const QString n("NAV3");
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
//! ADF1
|
//! ADF1
|
||||||
static const QString &NameAdf1();
|
static const QString &NameAdf1()
|
||||||
|
{
|
||||||
|
static QString n("ADF1");
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
//! ADF2
|
//! ADF2
|
||||||
static const QString &NameAdf2();
|
static const QString &NameAdf2()
|
||||||
|
{
|
||||||
|
static QString n("ADF2");
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
//! Frequency not set
|
//! 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:
|
private:
|
||||||
BLACK_ENABLE_TUPLE_CONVERSION(CModulator)
|
BLACK_ENABLE_TUPLE_CONVERSION(CModulator)
|
||||||
BlackMisc::PhysicalQuantities::CFrequency m_frequencyActive; //!< active frequency
|
BlackMisc::PhysicalQuantities::CFrequency m_frequencyActive; //!< active frequency
|
||||||
BlackMisc::PhysicalQuantities::CFrequency m_frequencyStandby; //!< standby frequency
|
BlackMisc::PhysicalQuantities::CFrequency m_frequencyStandby; //!< standby frequency
|
||||||
qint32 m_volumeInput = 0; //!< volume input
|
int m_volumeInput = 0; //!< volume input
|
||||||
qint32 m_volumeOutput = 0; //!< volume output
|
int m_volumeOutput = 0; //!< volume output
|
||||||
bool m_enabled = true; //!< is enabled, used e.g. for mute etc.
|
bool m_enabled = true; //!< is enabled, used e.g. for mute etc.
|
||||||
|
|
||||||
//! Easy access to derived class (CRTP template parameter)
|
//! 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)
|
//! Easy access to derived class (CRTP template parameter)
|
||||||
AVIO *derived();
|
AVIO *derived() { return static_cast<AVIO *>(this); }
|
||||||
};
|
|
||||||
|
|
||||||
//! \cond PRIVATE
|
//! \cond PRIVATE
|
||||||
|
class CComSystem;
|
||||||
|
class CNavSystem;
|
||||||
|
class CAdfSystem;
|
||||||
|
|
||||||
extern template class BLACKMISC_EXPORT_TEMPLATE CModulator<CComSystem>;
|
extern template class BLACKMISC_EXPORT_TEMPLATE CModulator<CComSystem>;
|
||||||
extern template class BLACKMISC_EXPORT_TEMPLATE CModulator<CNavSystem>;
|
extern template class BLACKMISC_EXPORT_TEMPLATE CModulator<CNavSystem>;
|
||||||
extern template class BLACKMISC_EXPORT_TEMPLATE CModulator<CAdfSystem>;
|
extern template class BLACKMISC_EXPORT_TEMPLATE CModulator<CAdfSystem>;
|
||||||
//! \endcond
|
//! \endcond
|
||||||
|
};
|
||||||
}
|
} // namespace
|
||||||
}
|
} // namespace
|
||||||
|
|
||||||
BLACK_DECLARE_TUPLE_CONVERSION_TEMPLATE(BlackMisc::Aviation::CModulator, (
|
BLACK_DECLARE_TUPLE_CONVERSION_TEMPLATE(BlackMisc::Aviation::CModulator, (
|
||||||
o.m_frequencyActive,
|
o.m_frequencyActive,
|
||||||
o.m_frequencyStandby,
|
o.m_frequencyStandby,
|
||||||
o.m_volumeInput ,
|
o.m_volumeInput ,
|
||||||
o.m_volumeOutput,
|
o.m_volumeOutput,
|
||||||
o.m_enabled
|
o.m_enabled))
|
||||||
))
|
|
||||||
|
|
||||||
#endif // guard
|
#endif // guard
|
||||||
|
|||||||
Reference in New Issue
Block a user