diff --git a/samples/blackmiscquantities_dbus/BlackMiscTest.Testservice.xml b/samples/blackmiscquantities_dbus/BlackMiscTest.Testservice.xml
index d8ba83ba6..a0ff44680 100644
--- a/samples/blackmiscquantities_dbus/BlackMiscTest.Testservice.xml
+++ b/samples/blackmiscquantities_dbus/BlackMiscTest.Testservice.xml
@@ -22,5 +22,13 @@
+
+
+
+
+
+
+
+
diff --git a/samples/blackmiscquantities_dbus/main.cpp b/samples/blackmiscquantities_dbus/main.cpp
index 785539601..14d2bced8 100644
--- a/samples/blackmiscquantities_dbus/main.cpp
+++ b/samples/blackmiscquantities_dbus/main.cpp
@@ -7,6 +7,7 @@
#include
#include
#include
+#include
#include "testservice.h"
#include "testservice_adaptor.h"
@@ -15,6 +16,7 @@
using namespace BlackMisc::PhysicalQuantities;
using namespace BlackMisc::Aviation;
+using namespace BlackMisc::Math;
using namespace BlackMiscTest;
/*!
@@ -88,12 +90,19 @@ int main(int argc, char *argv[])
if (connection.send(m)) {
qDebug() << "Send via low level method" << m;
}
- TestserviceTool::sleep(2500);
// same as interface message
testserviceInterface.receiveStringMessage(msg);
qDebug() << "Send string via interface" << msg;
- TestserviceTool::sleep(2500);
+
+ // a list
+ QList list;
+ list << 1.0 << 2.0 << 3.0;
+ testserviceInterface.receiveList(list);
+ qDebug() << "Send list via interface" << list;
+ qDebug() << "Key .......";
+ getchar();
+
// PQs
CSpeed speed(speedValue++, BlackMisc::PhysicalQuantities::CSpeedUnit::km_h());
@@ -115,8 +124,17 @@ int main(int argc, char *argv[])
testserviceInterface.receiveVariant(qv);
testserviceInterface.receiveAltitude(al);
qDebug() << "Send altitude via interface" << al;
-
TestserviceTool::sleep(2500);
+
+ // Math
+ CMatrix3x3 m33;
+ m33.setCellIndex();
+ testserviceInterface.receiveMatrix(m33);
+ qDebug() << "Send matrix" << m33;
+
+ // next round?
+ qDebug() << "Key .......";
+ getchar();
}
}
diff --git a/samples/blackmiscquantities_dbus/sample_quantities_avionics_dbus.pro b/samples/blackmiscquantities_dbus/sample_quantities_avionics_dbus.pro
index 52ddd002e..afabcc8a9 100644
--- a/samples/blackmiscquantities_dbus/sample_quantities_avionics_dbus.pro
+++ b/samples/blackmiscquantities_dbus/sample_quantities_avionics_dbus.pro
@@ -1,5 +1,4 @@
QT += core dbus
-QT -= gui
TARGET = sample_quantities_avionics_dbus
TEMPLATE = app
diff --git a/samples/blackmiscquantities_dbus/testservice.cpp b/samples/blackmiscquantities_dbus/testservice.cpp
index bcca70f78..dbecd51c9 100644
--- a/samples/blackmiscquantities_dbus/testservice.cpp
+++ b/samples/blackmiscquantities_dbus/testservice.cpp
@@ -54,12 +54,27 @@ void Testservice::receiveComUnit(const BlackMisc::Aviation::CComSystem &comUnit)
}
/*
- * Receivealtitude
+ * Receive altitude
*/
void Testservice::receiveAltitude(const BlackMisc::Aviation::CAltitude &altitude)
{
qDebug() << "Pid:" << TestserviceTool::getPid() << "Received altitude:" << altitude;
+}
+/*
+ * Receive matrix
+ */
+void Testservice::receiveMatrix(const BlackMisc::Math::CMatrix3x3 &matrix)
+{
+ qDebug() << "Pid:" << TestserviceTool::getPid() << "Received matrix:" << matrix;
+}
+
+/*
+ *
+ */
+void Testservice::receiveList(const QList &list)
+{
+ qDebug() << "Pid:" << TestserviceTool::getPid() << "Received list:" << list;
}
} // namespace
diff --git a/samples/blackmiscquantities_dbus/testservice.h b/samples/blackmiscquantities_dbus/testservice.h
index 81e10e7b5..db169fcda 100644
--- a/samples/blackmiscquantities_dbus/testservice.h
+++ b/samples/blackmiscquantities_dbus/testservice.h
@@ -76,6 +76,17 @@ public slots:
*/
void receiveAltitude(const BlackMisc::Aviation::CAltitude &altitude);
+ /*!
+ * \brief Receive matrix
+ * \param matrix
+ */
+ void receiveMatrix(const BlackMisc::Math::CMatrix3x3 &matrix);
+
+ /*!
+ * \brief Receive list
+ * \param list
+ */
+ void receiveList(const QList &list);
public:
static const QString ServiceName;
diff --git a/src/blackmisc/aviobase.h b/src/blackmisc/aviobase.h
index e9b152acb..f99c0b583 100644
--- a/src/blackmisc/aviobase.h
+++ b/src/blackmisc/aviobase.h
@@ -21,6 +21,7 @@ namespace Aviation
*/
class CAvionicsBase : public BlackMisc::CBaseStreamStringifier
{
+
protected:
QString m_name; //!< name of the unit
diff --git a/src/blackmisc/aviomodulator.h b/src/blackmisc/aviomodulator.h
index e82270b0d..86419639c 100644
--- a/src/blackmisc/aviomodulator.h
+++ b/src/blackmisc/aviomodulator.h
@@ -11,6 +11,7 @@
namespace BlackMisc
{
+
namespace Aviation
{
diff --git a/src/blackmisc/basestreamstringifier.h b/src/blackmisc/basestreamstringifier.h
index 393cf4565..9e4e50dee 100644
--- a/src/blackmisc/basestreamstringifier.h
+++ b/src/blackmisc/basestreamstringifier.h
@@ -159,7 +159,7 @@ protected:
* \brief Stream to DBus
* \param argument
*/
- virtual void marshallToDbus(QDBusArgument &) const { }
+ virtual void marshallToDbus(QDBusArgument &) const {}
/*!
* \brief Stream from DBus
diff --git a/src/blackmisc/blackmiscfreefunctions.cpp b/src/blackmisc/blackmiscfreefunctions.cpp
index 51316b601..e15b7eb22 100644
--- a/src/blackmisc/blackmiscfreefunctions.cpp
+++ b/src/blackmisc/blackmiscfreefunctions.cpp
@@ -34,6 +34,18 @@ void BlackMisc::Aviation::registerMetadata()
CAltitude::registerMetadata();
}
+
+/*
+ * Metadata for math
+ */
+void BlackMisc::Math::registerMetadata()
+{
+ CMatrix3x3::registerMetadata();
+ CMatrix3x1::registerMetadata();
+ CMatrix1x3::registerMetadata();
+}
+
+
/*
* Metadata for Blackmisc
*/
@@ -41,4 +53,5 @@ void BlackMisc::registerMetadata()
{
PhysicalQuantities::registerMetadata();
Aviation::registerMetadata();
+ Math::registerMetadata();
}
diff --git a/src/blackmisc/blackmiscfreefunctions.h b/src/blackmisc/blackmiscfreefunctions.h
index 22133fbf0..8309a12a3 100644
--- a/src/blackmisc/blackmiscfreefunctions.h
+++ b/src/blackmisc/blackmiscfreefunctions.h
@@ -7,6 +7,7 @@
#define BLACKMISC_FREEFUNCTIONS_H
#include "avallclasses.h"
#include "pqallquantities.h"
+#include "mathallclasses.h"
namespace BlackMisc {
@@ -34,6 +35,15 @@ void registerMetadata();
} // Aviation
+namespace Math {
+
+/*!
+ * \brief Register metadata for math (matrices, vectors)
+ */
+void registerMetadata();
+
+}
+
/*!
* \brief Register all relevant metadata in BlackMisc
*/
diff --git a/src/blackmisc/mathallclasses.h b/src/blackmisc/mathallclasses.h
new file mode 100644
index 000000000..0bdf4325f
--- /dev/null
+++ b/src/blackmisc/mathallclasses.h
@@ -0,0 +1,14 @@
+/* Copyright (C) 2013 VATSIM Community / contributors
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifndef BLACKMISC_MATHALLCLASSES_H
+#define BLACKMISC_MATHALLCLASSES_H
+
+#include "blackmisc/mathmatrix1x3.h"
+#include "blackmisc/mathmatrix3x3.h"
+#include "blackmisc/mathmatrix3x1.h"
+#include "blackmisc/mathvector3d.h"
+
+#endif // guard
diff --git a/src/blackmisc/mathmatrix1x3.h b/src/blackmisc/mathmatrix1x3.h
index 614c456cc..0daeea83b 100644
--- a/src/blackmisc/mathmatrix1x3.h
+++ b/src/blackmisc/mathmatrix1x3.h
@@ -54,5 +54,6 @@ public:
} // namespace
} // namespace
+Q_DECLARE_METATYPE(BlackMisc::Math::CMatrix1x3)
#endif // guard
diff --git a/src/blackmisc/mathmatrix3x1.h b/src/blackmisc/mathmatrix3x1.h
index c2da2aefd..e26b82810 100644
--- a/src/blackmisc/mathmatrix3x1.h
+++ b/src/blackmisc/mathmatrix3x1.h
@@ -76,5 +76,6 @@ public:
} // namespace
} // namespace
+Q_DECLARE_METATYPE(BlackMisc::Math::CMatrix3x1)
#endif // guard
diff --git a/src/blackmisc/mathmatrix3x3.h b/src/blackmisc/mathmatrix3x3.h
index 80878ac94..b4da2c090 100644
--- a/src/blackmisc/mathmatrix3x3.h
+++ b/src/blackmisc/mathmatrix3x3.h
@@ -177,5 +177,6 @@ public:
} // namespace
} // namespace
+Q_DECLARE_METATYPE(BlackMisc::Math::CMatrix3x3)
#endif // guard
diff --git a/src/blackmisc/mathmatrixbase.cpp b/src/blackmisc/mathmatrixbase.cpp
index 07dfc60b2..2bd2be4b3 100644
--- a/src/blackmisc/mathmatrixbase.cpp
+++ b/src/blackmisc/mathmatrixbase.cpp
@@ -69,6 +69,53 @@ template bool CMatrixBase void CMatrixBase::setCellIndex()
+{
+ for (int r = 0; r < Rows; r++)
+ {
+ for (int c = 0; c < Columns; c++)
+ {
+ this->m_matrix(r, c) = r + 0.1 * c;
+ }
+ }
+}
+
+/*
+ * To list
+ */
+template const QList CMatrixBase::toList() const
+{
+ QList list;
+ for (int r = 0; r < Rows; r++)
+ {
+ for (int c = 0; c < Columns; c++)
+ {
+ list.append(this->m_matrix(r, c));
+ }
+ }
+ return list;
+}
+
+/*
+ * From list
+ */
+template void CMatrixBase::fromList(const QList &list)
+{
+ Q_ASSERT_X(Rows * Columns == list.count(), "fromList()", "Mismatch of elements in list");
+ int ct = 0;
+ for (int r = 0; r < Rows; r++)
+ {
+ for (int c = 0; c < Columns; c++)
+ {
+ this->m_matrix(r, c) = list.at(ct++);
+ }
+ }
+}
+
/*
* All values equal?
*/
@@ -120,6 +167,16 @@ template QString CMatrixBase void CMatrixBase::registerMetadata()
+{
+ qRegisterMetaType(typeid(ImplMatrix).name());
+ qDBusRegisterMetaType();
+}
+
+
// see here for the reason of thess forward instantiations
// http://www.parashift.com/c++-faq/separate-template-class-defn-from-decl.html
template class CMatrixBase;
diff --git a/src/blackmisc/mathmatrixbase.h b/src/blackmisc/mathmatrixbase.h
index bfd2d8c81..f6d95bf41 100644
--- a/src/blackmisc/mathmatrixbase.h
+++ b/src/blackmisc/mathmatrixbase.h
@@ -9,6 +9,7 @@
#include "blackmisc/basestreamstringifier.h"
#include "blackmisc/mathvector3dbase.h"
#include
+#include
namespace BlackMisc
{
@@ -49,6 +50,34 @@ protected:
*/
QString stringForConverter() const;
+ /*!
+ * \brief Stream to DBus
+ * \param argument
+ */
+ virtual void marshallToDbus(QDBusArgument &argument) const {
+ const QList l = this->toList();
+
+ // there is an issue with the signature of QList, so I use
+ // individual values
+ foreach(double v, l) {
+ argument << v;
+ }
+ }
+
+ /*!
+ * \brief Stream from DBus
+ * \param argument
+ */
+ virtual void unmarshallFromDbus(const QDBusArgument &argument) {
+ QList list;
+ double v;
+ while(!argument.atEnd()) {
+ argument >> v;
+ list.append(v);
+ }
+ this->fromList(list);
+ }
+
public:
/*!
* \brief Default constructor
@@ -75,6 +104,18 @@ public:
*/
virtual ~CMatrixBase() {}
+ /*!
+ * \brief List of values
+ * \return
+ */
+ const QList toList() const;
+
+ /*!
+ * \brief List of values
+ * \return
+ */
+ void fromList(const QList &list);
+
/*!
* \brief Equal operator ==
* \param otherMatrix
@@ -264,6 +305,11 @@ public:
*/
bool isZero() const;
+ /*!
+ * \brief Each cell gets a unique index (used primarily for testing)
+ */
+ void setCellIndex();
+
/*!
* \brief Is identity matrix? Epsilon considered.
* \return
@@ -342,6 +388,11 @@ public:
return this->getElement(row, column);
}
+ /*!
+ * \brief Register metadata
+ */
+ static void registerMetadata();
+
private:
/*!
* \brief Check range of row / column
diff --git a/src/blackmisc/pqbase.h b/src/blackmisc/pqbase.h
index b0d37129b..4883035a6 100644
--- a/src/blackmisc/pqbase.h
+++ b/src/blackmisc/pqbase.h
@@ -294,14 +294,6 @@ protected:
*/
typedef double(*UnitConverter)(const CMeasurementUnit &, double);
- /*!
- * \brief Stream to DBus
- * \param argument
- */
- virtual void marshallToDbus(QDBusArgument &argument) const {
- argument << this->m_unitName;
- }
-
private:
QString m_name; //!< name, e.g. "meter"
QString m_unitName; //!< unit name, e.g. "m"
@@ -347,7 +339,6 @@ protected:
*/
CMeasurementUnit &operator =(const CMeasurementUnit &otherUnit);
-protected:
/*!
* \brief String for streaming operators is full name
* \return
@@ -397,6 +388,24 @@ protected:
return value / this->m_conversionFactorToSIConversionUnit;
}
+ /*!
+ * \brief Stream to DBus
+ * \param argument
+ */
+ virtual void marshallToDbus(QDBusArgument &argument) const {
+ argument << this->m_unitName;
+ }
+
+ /*!
+ * \brief Stream from DBus
+ * \param argument
+ */
+ virtual void unmarshallFromDbus(const QDBusArgument &) {
+ // the concrete implementations will override this default
+ // this is required so I can also stream None
+ (*this) = CMeasurementUnit::None();
+ }
+
public:
/*!
* \brief Equal operator ==