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) {
|
||||
// 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
|
||||
// Once someone solves this, this methods should go and the
|
||||
// CBaseStreamStringifier signature should be used
|
||||
CBaseStreamStringifier &sf = uc;
|
||||
return argument >> sf;
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ class CAviationVerticalPositions
|
||||
friend CLogMessage operator<<(CLogMessage log, const CAviationVerticalPositions &positions);
|
||||
|
||||
private:
|
||||
CAltitude m_altitude; //!< altitude
|
||||
BlackMisc::Aviation::CAltitude m_altitude; //!< altitude
|
||||
BlackMisc::PhysicalQuantities::CLength m_elevation; //!< elevation
|
||||
BlackMisc::PhysicalQuantities::CLength m_height; //!< height
|
||||
|
||||
|
||||
@@ -36,16 +36,29 @@ void BlackMisc::Aviation::registerMetadata()
|
||||
|
||||
|
||||
/*
|
||||
* Metadata for math
|
||||
* Metadata for Math
|
||||
*/
|
||||
void BlackMisc::Math::registerMetadata()
|
||||
{
|
||||
CMatrix3x3::registerMetadata();
|
||||
CMatrix3x1::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
|
||||
*/
|
||||
@@ -54,4 +67,5 @@ void BlackMisc::registerMetadata()
|
||||
PhysicalQuantities::registerMetadata();
|
||||
Aviation::registerMetadata();
|
||||
Math::registerMetadata();
|
||||
Geo::registerMetadata();
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "avallclasses.h"
|
||||
#include "pqallquantities.h"
|
||||
#include "mathallclasses.h"
|
||||
#include "geoallclasses.h"
|
||||
|
||||
namespace BlackMisc {
|
||||
|
||||
@@ -42,7 +43,18 @@ namespace Math {
|
||||
*/
|
||||
void registerMetadata();
|
||||
|
||||
}
|
||||
} // Math
|
||||
|
||||
namespace Geo {
|
||||
|
||||
/*!
|
||||
* \brief Register metadata for geo (coordinates)
|
||||
*/
|
||||
void registerMetadata();
|
||||
|
||||
} // Geo
|
||||
|
||||
|
||||
|
||||
/*!
|
||||
* \brief Register all relevant metadata in BlackMisc
|
||||
|
||||
@@ -117,6 +117,6 @@ protected:
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
Q_DECLARE_METATYPE(BlackMisc::Geo::CCoordinateEcef)
|
||||
|
||||
#endif // guard
|
||||
|
||||
@@ -37,14 +37,12 @@ class ICoordinateGeodetic
|
||||
/*!
|
||||
* \brief Geodetic coordinate
|
||||
*/
|
||||
class CCoordinateGeodetic :
|
||||
public CBaseStreamStringifier,
|
||||
public ICoordinateGeodetic
|
||||
class CCoordinateGeodetic : public CBaseStreamStringifier, public ICoordinateGeodetic
|
||||
{
|
||||
|
||||
private:
|
||||
CLatitude m_latitude; //!< Latitude
|
||||
CLongitude m_longitude; //!< Longitude
|
||||
BlackMisc::Geo::CLatitude m_latitude; //!< Latitude
|
||||
BlackMisc::Geo::CLongitude m_longitude; //!< Longitude
|
||||
BlackMisc::PhysicalQuantities::CLength m_height; //!< height
|
||||
|
||||
protected:
|
||||
@@ -58,6 +56,25 @@ protected:
|
||||
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());
|
||||
}
|
||||
/*!
|
||||
* \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:
|
||||
/*!
|
||||
@@ -203,10 +220,16 @@ public:
|
||||
this->m_longitude = otherGeodetic.m_longitude;
|
||||
return (*this);
|
||||
}
|
||||
|
||||
/*
|
||||
* Register metadata
|
||||
*/
|
||||
static void registerMetadata();
|
||||
|
||||
};
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
Q_DECLARE_METATYPE(BlackMisc::Geo::CCoordinateGeodetic)
|
||||
|
||||
#endif // guard
|
||||
|
||||
@@ -218,6 +218,6 @@ public:
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
Q_DECLARE_METATYPE(BlackMisc::Geo::CCoordinateNed)
|
||||
|
||||
#endif // guard
|
||||
|
||||
@@ -16,6 +16,33 @@ namespace Geo
|
||||
*/
|
||||
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:
|
||||
/*!
|
||||
* \brief Default constructor
|
||||
@@ -44,8 +71,23 @@ protected:
|
||||
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
|
||||
*/
|
||||
@@ -169,6 +211,15 @@ public:
|
||||
l -= latOrLon;
|
||||
return l;
|
||||
}
|
||||
|
||||
/*
|
||||
* Register metadata
|
||||
*/
|
||||
static void registerMetadata()
|
||||
{
|
||||
qRegisterMetaType<LATorLON>(typeid(LATorLON).name());
|
||||
qDBusRegisterMetaType<LATorLON>();
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -50,5 +50,6 @@ public:
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
Q_DECLARE_METATYPE(BlackMisc::Geo::CLatitude)
|
||||
|
||||
#endif // guard
|
||||
|
||||
@@ -50,4 +50,6 @@ public:
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
Q_DECLARE_METATYPE(BlackMisc::Geo::CLongitude)
|
||||
|
||||
#endif // guard
|
||||
|
||||
@@ -97,4 +97,6 @@ public:
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
Q_DECLARE_METATYPE(BlackMisc::Math::CVector3D)
|
||||
|
||||
#endif // guard
|
||||
|
||||
@@ -131,6 +131,36 @@ template <class ImplVector> CMatrix3x1 CVector3DBase<ImplVector>::toMatrix3x1()
|
||||
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
|
||||
// http://www.parashift.com/c++-faq/separate-template-class-defn-from-decl.html
|
||||
template class CVector3DBase<CVector3D>;
|
||||
|
||||
@@ -24,6 +24,33 @@ class CMatrix3x1; // forward declaration
|
||||
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:
|
||||
/*!
|
||||
* \brief Easy access to derived class (CRTP template parameter)
|
||||
@@ -81,6 +108,18 @@ protected:
|
||||
*/
|
||||
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:
|
||||
|
||||
// getter and setters are implemented in the derived classes
|
||||
@@ -416,6 +455,11 @@ public:
|
||||
v.round();
|
||||
return v;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Register metadata
|
||||
*/
|
||||
static void registerMetadata();
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -271,7 +271,7 @@ public:
|
||||
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
|
||||
* \param value
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user