mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 14:55:36 +08:00
Enabled coordinates for DBus
This commit is contained in:
@@ -29,8 +29,8 @@ template <class AVIO> class CModulator : public CAvionicsBase
|
|||||||
friend const QDBusArgument &operator>>(const QDBusArgument &argument, AVIO &uc) {
|
friend const QDBusArgument &operator>>(const QDBusArgument &argument, AVIO &uc) {
|
||||||
// If I do not have the method here, DBus metasystem tries to stream against
|
// If I do not have the method here, DBus metasystem tries to stream against
|
||||||
// a container: inline const QDBusArgument &operator>>(const QDBusArgument &arg, Container<T> &list)
|
// a container: inline const QDBusArgument &operator>>(const QDBusArgument &arg, Container<T> &list)
|
||||||
// Once someone solves this, this methods should go and the CBaseStreamStringifier signature
|
// Once someone solves this, this methods should go and the
|
||||||
// should be used
|
// CBaseStreamStringifier signature should be used
|
||||||
CBaseStreamStringifier &sf = uc;
|
CBaseStreamStringifier &sf = uc;
|
||||||
return argument >> sf;
|
return argument >> sf;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ class CAviationVerticalPositions
|
|||||||
friend CLogMessage operator<<(CLogMessage log, const CAviationVerticalPositions &positions);
|
friend CLogMessage operator<<(CLogMessage log, const CAviationVerticalPositions &positions);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CAltitude m_altitude; //!< altitude
|
BlackMisc::Aviation::CAltitude m_altitude; //!< altitude
|
||||||
BlackMisc::PhysicalQuantities::CLength m_elevation; //!< elevation
|
BlackMisc::PhysicalQuantities::CLength m_elevation; //!< elevation
|
||||||
BlackMisc::PhysicalQuantities::CLength m_height; //!< height
|
BlackMisc::PhysicalQuantities::CLength m_height; //!< height
|
||||||
|
|
||||||
|
|||||||
@@ -36,16 +36,29 @@ void BlackMisc::Aviation::registerMetadata()
|
|||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Metadata for math
|
* Metadata for Math
|
||||||
*/
|
*/
|
||||||
void BlackMisc::Math::registerMetadata()
|
void BlackMisc::Math::registerMetadata()
|
||||||
{
|
{
|
||||||
CMatrix3x3::registerMetadata();
|
CMatrix3x3::registerMetadata();
|
||||||
CMatrix3x1::registerMetadata();
|
CMatrix3x1::registerMetadata();
|
||||||
CMatrix1x3::registerMetadata();
|
CMatrix1x3::registerMetadata();
|
||||||
|
CVector3D::registerMetadata();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Metadata for Geo
|
||||||
|
*/
|
||||||
|
void BlackMisc::Geo::registerMetadata()
|
||||||
|
{
|
||||||
|
CCoordinateEcef::registerMetadata();
|
||||||
|
CCoordinateNed::registerMetadata();
|
||||||
|
CCoordinateGeodetic::registerMetadata();
|
||||||
|
CLatitude::registerMetadata();
|
||||||
|
CLongitude::registerMetadata();
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Metadata for Blackmisc
|
* Metadata for Blackmisc
|
||||||
*/
|
*/
|
||||||
@@ -54,4 +67,5 @@ void BlackMisc::registerMetadata()
|
|||||||
PhysicalQuantities::registerMetadata();
|
PhysicalQuantities::registerMetadata();
|
||||||
Aviation::registerMetadata();
|
Aviation::registerMetadata();
|
||||||
Math::registerMetadata();
|
Math::registerMetadata();
|
||||||
|
Geo::registerMetadata();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
#include "avallclasses.h"
|
#include "avallclasses.h"
|
||||||
#include "pqallquantities.h"
|
#include "pqallquantities.h"
|
||||||
#include "mathallclasses.h"
|
#include "mathallclasses.h"
|
||||||
|
#include "geoallclasses.h"
|
||||||
|
|
||||||
namespace BlackMisc {
|
namespace BlackMisc {
|
||||||
|
|
||||||
@@ -42,7 +43,18 @@ namespace Math {
|
|||||||
*/
|
*/
|
||||||
void registerMetadata();
|
void registerMetadata();
|
||||||
|
|
||||||
}
|
} // Math
|
||||||
|
|
||||||
|
namespace Geo {
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Register metadata for geo (coordinates)
|
||||||
|
*/
|
||||||
|
void registerMetadata();
|
||||||
|
|
||||||
|
} // Geo
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Register all relevant metadata in BlackMisc
|
* \brief Register all relevant metadata in BlackMisc
|
||||||
|
|||||||
@@ -117,6 +117,6 @@ protected:
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
} // namespace
|
} // namespace
|
||||||
|
Q_DECLARE_METATYPE(BlackMisc::Geo::CCoordinateEcef)
|
||||||
|
|
||||||
#endif // guard
|
#endif // guard
|
||||||
|
|||||||
@@ -37,14 +37,12 @@ class ICoordinateGeodetic
|
|||||||
/*!
|
/*!
|
||||||
* \brief Geodetic coordinate
|
* \brief Geodetic coordinate
|
||||||
*/
|
*/
|
||||||
class CCoordinateGeodetic :
|
class CCoordinateGeodetic : public CBaseStreamStringifier, public ICoordinateGeodetic
|
||||||
public CBaseStreamStringifier,
|
|
||||||
public ICoordinateGeodetic
|
|
||||||
{
|
{
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CLatitude m_latitude; //!< Latitude
|
BlackMisc::Geo::CLatitude m_latitude; //!< Latitude
|
||||||
CLongitude m_longitude; //!< Longitude
|
BlackMisc::Geo::CLongitude m_longitude; //!< Longitude
|
||||||
BlackMisc::PhysicalQuantities::CLength m_height; //!< height
|
BlackMisc::PhysicalQuantities::CLength m_height; //!< height
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@@ -58,6 +56,25 @@ protected:
|
|||||||
QString s = "Geodetic: {%1, %2, %3}";
|
QString s = "Geodetic: {%1, %2, %3}";
|
||||||
return s.arg(this->m_latitude.unitValueRoundedWithUnit(6)).arg(this->m_longitude.unitValueRoundedWithUnit(6)).arg(this->m_height.unitValueRoundedWithUnit());
|
return s.arg(this->m_latitude.unitValueRoundedWithUnit(6)).arg(this->m_longitude.unitValueRoundedWithUnit(6)).arg(this->m_height.unitValueRoundedWithUnit());
|
||||||
}
|
}
|
||||||
|
/*!
|
||||||
|
* \brief Stream to DBus
|
||||||
|
* \param argument
|
||||||
|
*/
|
||||||
|
virtual void marshallToDbus(QDBusArgument &argument) const {
|
||||||
|
argument << this->m_latitude;
|
||||||
|
argument << this->m_longitude;
|
||||||
|
argument << this->m_height;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Stream from DBus
|
||||||
|
* \param argument
|
||||||
|
*/
|
||||||
|
virtual void unmarshallFromDbus(const QDBusArgument &argument) {
|
||||||
|
argument >> this->m_latitude;
|
||||||
|
argument >> this->m_longitude;
|
||||||
|
argument >> this->m_height;
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/*!
|
/*!
|
||||||
@@ -203,10 +220,16 @@ public:
|
|||||||
this->m_longitude = otherGeodetic.m_longitude;
|
this->m_longitude = otherGeodetic.m_longitude;
|
||||||
return (*this);
|
return (*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Register metadata
|
||||||
|
*/
|
||||||
|
static void registerMetadata();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
} // namespace
|
} // namespace
|
||||||
|
Q_DECLARE_METATYPE(BlackMisc::Geo::CCoordinateGeodetic)
|
||||||
|
|
||||||
#endif // guard
|
#endif // guard
|
||||||
|
|||||||
@@ -218,6 +218,6 @@ public:
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
} // namespace
|
} // namespace
|
||||||
|
Q_DECLARE_METATYPE(BlackMisc::Geo::CCoordinateNed)
|
||||||
|
|
||||||
#endif // guard
|
#endif // guard
|
||||||
|
|||||||
@@ -16,6 +16,33 @@ namespace Geo
|
|||||||
*/
|
*/
|
||||||
template <class LATorLON> class CEarthAngle : public BlackMisc::PhysicalQuantities::CAngle
|
template <class LATorLON> class CEarthAngle : public BlackMisc::PhysicalQuantities::CAngle
|
||||||
{
|
{
|
||||||
|
/*!
|
||||||
|
* \brief Unmarshalling operator >>, DBus to object
|
||||||
|
* \param argument
|
||||||
|
* \param uc
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
friend const QDBusArgument &operator>>(const QDBusArgument &argument, LATorLON &uc) {
|
||||||
|
// If I do not have the method here, DBus metasystem tries to stream against
|
||||||
|
// a container: inline const QDBusArgument &operator>>(const QDBusArgument &arg, Container<T> &list)
|
||||||
|
// Once someone solves this, this methods should go and the
|
||||||
|
// CBaseStreamStringifier signature should be used
|
||||||
|
CBaseStreamStringifier &sf = uc;
|
||||||
|
return argument >> sf;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Marshalling operator <<, object to DBus
|
||||||
|
* \param argument
|
||||||
|
* \param pq
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
friend QDBusArgument &operator<<(QDBusArgument &argument, const LATorLON &uc)
|
||||||
|
{
|
||||||
|
const CBaseStreamStringifier &sf = uc;
|
||||||
|
return argument << sf;
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/*!
|
/*!
|
||||||
* \brief Default constructor
|
* \brief Default constructor
|
||||||
@@ -44,8 +71,23 @@ protected:
|
|||||||
return this->unitValueRoundedWithUnit(6);
|
return this->unitValueRoundedWithUnit(6);
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
/*!
|
||||||
|
* \brief Stream to DBus <<
|
||||||
|
* \param argument
|
||||||
|
*/
|
||||||
|
virtual void marshallToDbus(QDBusArgument &argument) const {
|
||||||
|
CAngle::marshallToDbus(argument);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Stream from DBus >>
|
||||||
|
* \param argument
|
||||||
|
*/
|
||||||
|
virtual void unmarshallFromDbus(const QDBusArgument &argument) {
|
||||||
|
CAngle::unmarshallFromDbus(argument);
|
||||||
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
/*!
|
/*!
|
||||||
* \brief Virtual destructor
|
* \brief Virtual destructor
|
||||||
*/
|
*/
|
||||||
@@ -169,6 +211,15 @@ public:
|
|||||||
l -= latOrLon;
|
l -= latOrLon;
|
||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Register metadata
|
||||||
|
*/
|
||||||
|
static void registerMetadata()
|
||||||
|
{
|
||||||
|
qRegisterMetaType<LATorLON>(typeid(LATorLON).name());
|
||||||
|
qDBusRegisterMetaType<LATorLON>();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
@@ -50,5 +50,6 @@ public:
|
|||||||
} // namespace
|
} // namespace
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(BlackMisc::Geo::CLatitude)
|
||||||
|
|
||||||
#endif // guard
|
#endif // guard
|
||||||
|
|||||||
@@ -50,4 +50,6 @@ public:
|
|||||||
} // namespace
|
} // namespace
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(BlackMisc::Geo::CLongitude)
|
||||||
|
|
||||||
#endif // guard
|
#endif // guard
|
||||||
|
|||||||
@@ -97,4 +97,6 @@ public:
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
} // namespace
|
} // namespace
|
||||||
|
Q_DECLARE_METATYPE(BlackMisc::Math::CVector3D)
|
||||||
|
|
||||||
#endif // guard
|
#endif // guard
|
||||||
|
|||||||
@@ -20,8 +20,8 @@ template <class ImplVector> QString CVector3DBase<ImplVector>::stringForConverte
|
|||||||
{
|
{
|
||||||
QString s = ("{%1, %2, %3}");
|
QString s = ("{%1, %2, %3}");
|
||||||
s = s.arg(QString::number(this->m_i, 'f')).
|
s = s.arg(QString::number(this->m_i, 'f')).
|
||||||
arg(QString::number(this->m_j, 'f')).
|
arg(QString::number(this->m_j, 'f')).
|
||||||
arg(QString::number(this->m_k, 'f'));
|
arg(QString::number(this->m_k, 'f'));
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -131,6 +131,36 @@ template <class ImplVector> CMatrix3x1 CVector3DBase<ImplVector>::toMatrix3x1()
|
|||||||
return CMatrix3x1(this->m_i, this->m_j, this->m_k);
|
return CMatrix3x1(this->m_i, this->m_j, this->m_k);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Stream to DBus
|
||||||
|
* \param argument
|
||||||
|
*/
|
||||||
|
template <class ImplVector> void CVector3DBase<ImplVector>::marshallToDbus(QDBusArgument &argument) const {
|
||||||
|
argument << this->m_i;
|
||||||
|
argument << this->m_j;
|
||||||
|
argument << this->m_k;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Stream from DBus
|
||||||
|
* \param argument
|
||||||
|
*/
|
||||||
|
template <class ImplVector> void CVector3DBase<ImplVector>::unmarshallFromDbus(const QDBusArgument &argument) {
|
||||||
|
argument >> this->m_i;
|
||||||
|
argument >> this->m_j;
|
||||||
|
argument >> this->m_k;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Register metadata
|
||||||
|
*/
|
||||||
|
template <class ImplVector> void CVector3DBase<ImplVector>::registerMetadata()
|
||||||
|
{
|
||||||
|
qRegisterMetaType<ImplVector>(typeid(ImplVector).name());
|
||||||
|
qDBusRegisterMetaType<ImplVector>();
|
||||||
|
}
|
||||||
|
|
||||||
// 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 CVector3DBase<CVector3D>;
|
template class CVector3DBase<CVector3D>;
|
||||||
|
|||||||
@@ -24,6 +24,33 @@ class CMatrix3x1; // forward declaration
|
|||||||
template <class ImplVector> class CVector3DBase : public CBaseStreamStringifier
|
template <class ImplVector> class CVector3DBase : public CBaseStreamStringifier
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Unmarshalling operator >>, DBus to object
|
||||||
|
* \param argument
|
||||||
|
* \param uc
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
friend const QDBusArgument &operator>>(const QDBusArgument &argument, ImplVector &uc) {
|
||||||
|
// If I do not have the method here, DBus metasystem tries to stream against
|
||||||
|
// a container: inline const QDBusArgument &operator>>(const QDBusArgument &arg, Container<T> &list)
|
||||||
|
// Once someone solves this, this methods should go and the
|
||||||
|
// CBaseStreamStringifier signature should be used
|
||||||
|
CBaseStreamStringifier &sf = uc;
|
||||||
|
return argument >> sf;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Marshalling operator <<, object to DBus
|
||||||
|
* \param argument
|
||||||
|
* \param pq
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
friend QDBusArgument &operator<<(QDBusArgument &argument, const ImplVector &uc)
|
||||||
|
{
|
||||||
|
const CBaseStreamStringifier &sf = uc;
|
||||||
|
return argument << sf;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/*!
|
/*!
|
||||||
* \brief Easy access to derived class (CRTP template parameter)
|
* \brief Easy access to derived class (CRTP template parameter)
|
||||||
@@ -81,6 +108,18 @@ protected:
|
|||||||
*/
|
*/
|
||||||
virtual QString stringForConverter() const;
|
virtual QString stringForConverter() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Unmarshall from Dbus
|
||||||
|
* \param argument
|
||||||
|
*/
|
||||||
|
virtual void unmarshallFromDbus(const QDBusArgument &argument);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Marshall to Dbus
|
||||||
|
* \param argument
|
||||||
|
*/
|
||||||
|
virtual void marshallToDbus(QDBusArgument &argument) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// getter and setters are implemented in the derived classes
|
// getter and setters are implemented in the derived classes
|
||||||
@@ -416,6 +455,11 @@ public:
|
|||||||
v.round();
|
v.round();
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Register metadata
|
||||||
|
*/
|
||||||
|
static void registerMetadata();
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
@@ -271,7 +271,7 @@ public:
|
|||||||
void addUnitValue(double value);
|
void addUnitValue(double value);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Substratc to the unit value.
|
* \brief Substract to the unit value.
|
||||||
* \remarks Since overloading the - operator with double did lead to unintended conversions, as explicit method
|
* \remarks Since overloading the - operator with double did lead to unintended conversions, as explicit method
|
||||||
* \param value
|
* \param value
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user