mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 14:55:36 +08:00
refs #140 , adjust sample for DBus marshalling / unmarshalling in order to test "tupel-ized" classes
* Added further DBus tests * Crossover from refs #85 , removed dependency from generator adaptor and XML files, as this will not work anymore in the future * Removed from .pro DBUS_ADAPTORS , DBUS_INTERFACES, QDBUSXML2CPP_INTERFACE_HEADER_FLAGS , QDBUSXML2CPP_ADAPTOR_HEADER_FLAGS * Added interface, as this will be no longer generated * Removed samples no longer required, the sample no represents a framework to test DBus marshalling / unmarshalling
This commit is contained in:
@@ -1,34 +0,0 @@
|
||||
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
|
||||
<node>
|
||||
<interface name="blackmisctest.datacontext">
|
||||
<property name="qpAtcOnlineList" type="(a((ss)(dd(s))(ssss)((dd(s))(dd(s))(dd(s)))(dd(s))(dd(s))b((iii)(iiii)i)((iii)(iiii)i)(si((iii)(iiii)i))(si((iii)(iiii)i))(ssbb)))" access="readwrite">
|
||||
<annotation name="org.qtproject.QtDBus.QtTypeName" value="BlackMisc::Aviation::CAtcStationList"/>
|
||||
</property>
|
||||
<property name="qpAtcBookedList" type="(a((ss)(dd(s))(ssss)((dd(s))(dd(s))(dd(s)))(dd(s))(dd(s))b((iii)(iiii)i)((iii)(iiii)i)(si((iii)(iiii)i))(si((iii)(iiii)i))(ssbb)))" access="readwrite">
|
||||
<annotation name="org.qtproject.QtDBus.QtTypeName" value="BlackMisc::Aviation::CAtcStationList"/>
|
||||
</property>
|
||||
<property name="qpFooStrings" type="as" access="read"/>
|
||||
<signal name="fooSignal">
|
||||
<arg name="message" type="s" direction="out"/>
|
||||
</signal>
|
||||
<method name="fooSlot">
|
||||
<arg name="baz" type="s" direction="in"/>
|
||||
</method>
|
||||
<method name="fooSlotRet">
|
||||
<arg type="s" direction="out"/>
|
||||
<arg name="baz" type="s" direction="in"/>
|
||||
</method>
|
||||
<method name="updateBookedControllers">
|
||||
<arg name="condition" type="(aiavai)" direction="in"/>
|
||||
<annotation name="org.qtproject.QtDBus.QtTypeName.In0" value="BlackMisc::CValueMap"/>
|
||||
<arg name="values" type="(aiavai)" direction="in"/>
|
||||
<annotation name="org.qtproject.QtDBus.QtTypeName.In1" value="BlackMisc::CValueMap"/>
|
||||
</method>
|
||||
<method name="updateOnlineControllers">
|
||||
<arg name="condition" type="(aiavai)" direction="in"/>
|
||||
<annotation name="org.qtproject.QtDBus.QtTypeName.In0" value="BlackMisc::CValueMap"/>
|
||||
<arg name="values" type="(aiavai)" direction="in"/>
|
||||
<annotation name="org.qtproject.QtDBus.QtTypeName.In1" value="BlackMisc::CValueMap"/>
|
||||
</method>
|
||||
</interface>
|
||||
</node>
|
||||
@@ -1,114 +0,0 @@
|
||||
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
|
||||
<node>
|
||||
<interface name="blackmisctest.testservice">
|
||||
<signal name="sendStringMessage">
|
||||
<arg name="message" type="s" direction="out"/>
|
||||
</signal>
|
||||
<method name="receiveStringMessage">
|
||||
<arg name="message" type="s" direction="in"/>
|
||||
</method>
|
||||
<method name="receiveVariant">
|
||||
<arg name="variant" type="v" direction="in"/>
|
||||
<arg name="localMetyType" type="i" direction="in"/>
|
||||
</method>
|
||||
<method name="receiveSpeed">
|
||||
<arg name="speed" type="(dd(s))" direction="in"/>
|
||||
<annotation name="org.qtproject.QtDBus.QtTypeName.In0" value="BlackMisc::PhysicalQuantities::CSpeed"/>
|
||||
</method>
|
||||
<method name="pingSpeed">
|
||||
<arg type="(dd(s))" direction="out"/>
|
||||
<annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="BlackMisc::PhysicalQuantities::CSpeed"/>
|
||||
<arg name="speed" type="(dd(s))" direction="in"/>
|
||||
<annotation name="org.qtproject.QtDBus.QtTypeName.In0" value="BlackMisc::PhysicalQuantities::CSpeed"/>
|
||||
</method>
|
||||
<method name="receiveComUnit">
|
||||
<arg name="comUnit" type="(s(dd(s))(dd(s))iiib)" direction="in"/>
|
||||
<annotation name="org.qtproject.QtDBus.QtTypeName.In0" value="BlackMisc::Aviation::CComSystem"/>
|
||||
</method>
|
||||
<method name="receiveAltitude">
|
||||
<arg name="altitude" type="(dd(s)i)" direction="in"/>
|
||||
<annotation name="org.qtproject.QtDBus.QtTypeName.In0" value="BlackMisc::Aviation::CAltitude"/>
|
||||
</method>
|
||||
<method name="pingAltitude">
|
||||
<arg type="(dd(s)i)" direction="out"/>
|
||||
<annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="BlackMisc::Aviation::CAltitude"/>
|
||||
<arg name="altitude" type="(dd(s)i)" direction="in"/>
|
||||
<annotation name="org.qtproject.QtDBus.QtTypeName.In0" value="BlackMisc::Aviation::CAltitude"/>
|
||||
</method>
|
||||
<method name="receiveMatrix">
|
||||
<arg name="matrix" type="(ddddddddd)" direction="in"/>
|
||||
<annotation name="org.qtproject.QtDBus.QtTypeName.In0" value="BlackMisc::Math::CMatrix3x3"/>
|
||||
</method>
|
||||
<method name="receiveList">
|
||||
<arg name="list" type="ad" direction="in"/>
|
||||
<annotation name="org.qtproject.QtDBus.QtTypeName.In0" value="QList<double>"/>
|
||||
</method>
|
||||
<method name="receiveGeoPosition">
|
||||
<arg name="geo" type="((dd(s))(dd(s))(dd(s)))" direction="in"/>
|
||||
<annotation name="org.qtproject.QtDBus.QtTypeName.In0" value="BlackMisc::Geo::CCoordinateGeodetic"/>
|
||||
</method>
|
||||
<method name="receiveTransponder">
|
||||
<arg name="transponder" type="(sii)" direction="in"/>
|
||||
<annotation name="org.qtproject.QtDBus.QtTypeName.In0" value="BlackMisc::Aviation::CTransponder"/>
|
||||
</method>
|
||||
<method name="receiveTrack">
|
||||
<arg name="track" type="(dd(s)i)" direction="in"/>
|
||||
<annotation name="org.qtproject.QtDBus.QtTypeName.In0" value="BlackMisc::Aviation::CTrack"/>
|
||||
</method>
|
||||
<method name="receiveLength">
|
||||
<arg name="length" type="(dd(s))" direction="in"/>
|
||||
<annotation name="org.qtproject.QtDBus.QtTypeName.In0" value="BlackMisc::PhysicalQuantities::CLength"/>
|
||||
</method>
|
||||
<method name="receiveLengthsQl">
|
||||
<arg name="lengthsList" type="av" direction="in"/>
|
||||
</method>
|
||||
<method name="receiveLengthsQvl">
|
||||
<arg name="lengthsVariantList" type="av" direction="in"/>
|
||||
</method>
|
||||
<method name="receiveAtcStation">
|
||||
<arg name="station" type="((ss)(dd(s))(ssss)((dd(s))(dd(s))(dd(s)))(dd(s))(dd(s))b((iii)(iiii)i)((iii)(iiii)i)(si((iii)(iiii)i))(si((iii)(iiii)i))(ssbb))" direction="in"/>
|
||||
<annotation name="org.qtproject.QtDBus.QtTypeName.In0" value="BlackMisc::Aviation::CAtcStation"/>
|
||||
</method>
|
||||
<method name="pingAtcStation">
|
||||
<arg type="((ss)(dd(s))(ssss)((dd(s))(dd(s))(dd(s)))(dd(s))(dd(s))b((iii)(iiii)i)((iii)(iiii)i)(si((iii)(iiii)i))(si((iii)(iiii)i))(ssbb))" direction="out"/>
|
||||
<annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="BlackMisc::Aviation::CAtcStation"/>
|
||||
<arg name="station" type="((ss)(dd(s))(ssss)((dd(s))(dd(s))(dd(s)))(dd(s))(dd(s))b((iii)(iiii)i)((iii)(iiii)i)(si((iii)(iiii)i))(si((iii)(iiii)i))(ssbb))" direction="in"/>
|
||||
<annotation name="org.qtproject.QtDBus.QtTypeName.In0" value="BlackMisc::Aviation::CAtcStation"/>
|
||||
</method>
|
||||
<method name="receiveCallsign">
|
||||
<arg name="callsign" type="(ss)" direction="in"/>
|
||||
<annotation name="org.qtproject.QtDBus.QtTypeName.In0" value="BlackMisc::Aviation::CCallsign"/>
|
||||
</method>
|
||||
<method name="getAtcStationList">
|
||||
<arg type="(a((ss)(dd(s))(ssss)((dd(s))(dd(s))(dd(s)))(dd(s))(dd(s))b((iii)(iiii)i)((iii)(iiii)i)(si((iii)(iiii)i))(si((iii)(iiii)i))(ssbb)))" direction="out"/>
|
||||
<annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="BlackMisc::Aviation::CAtcStationList"/>
|
||||
<arg name="number" type="i" direction="in"/>
|
||||
</method>
|
||||
<method name="getObjectPaths">
|
||||
<arg type="ao" direction="out"/>
|
||||
<arg name="number" type="i" direction="in"/>
|
||||
</method>
|
||||
<method name="receiveAtcStationList">
|
||||
<arg name="AtcStationList" type="(a((ss)(dd(s))(ssss)((dd(s))(dd(s))(dd(s)))(dd(s))(dd(s))b((iii)(iiii)i)((iii)(iiii)i)(si((iii)(iiii)i))(si((iii)(iiii)i))(ssbb)))" direction="in"/>
|
||||
<annotation name="org.qtproject.QtDBus.QtTypeName.In0" value="BlackMisc::Aviation::CAtcStationList"/>
|
||||
</method>
|
||||
<method name="receiveValueMap">
|
||||
<arg name="valueMap" type="(aiavai)" direction="in"/>
|
||||
<annotation name="org.qtproject.QtDBus.QtTypeName.In0" value="BlackMisc::CValueMap"/>
|
||||
</method>
|
||||
<method name="pingAtcStationList">
|
||||
<arg type="(a((ss)(dd(s))(ssss)((dd(s))(dd(s))(dd(s)))(dd(s))(dd(s))b((iii)(iiii)i)((iii)(iiii)i)(si((iii)(iiii)i))(si((iii)(iiii)i))(ssbb)))" direction="out"/>
|
||||
<annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="BlackMisc::Aviation::CAtcStationList"/>
|
||||
<arg name="AtcStationList" type="(a((ss)(dd(s))(ssss)((dd(s))(dd(s))(dd(s)))(dd(s))(dd(s))b((iii)(iiii)i)((iii)(iiii)i)(si((iii)(iiii)i))(si((iii)(iiii)i))(ssbb)))" direction="in"/>
|
||||
<annotation name="org.qtproject.QtDBus.QtTypeName.In0" value="BlackMisc::Aviation::CAtcStationList"/>
|
||||
</method>
|
||||
<method name="getSpeed">
|
||||
<arg type="(dd(s))" direction="out"/>
|
||||
<annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="BlackMisc::PhysicalQuantities::CSpeed"/>
|
||||
</method>
|
||||
<method name="getAtcStation">
|
||||
<arg type="((ss)(dd(s))(ssss)((dd(s))(dd(s))(dd(s)))(dd(s))(dd(s))b((iii)(iiii)i)((iii)(iiii)i)(si((iii)(iiii)i))(si((iii)(iiii)i))(ssbb))" direction="out"/>
|
||||
<annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="BlackMisc::Aviation::CAtcStation"/>
|
||||
</method>
|
||||
</interface>
|
||||
</node>
|
||||
@@ -1,39 +0,0 @@
|
||||
#include "datacontext.h"
|
||||
|
||||
namespace BlackMiscTest
|
||||
{
|
||||
|
||||
const QString CDataContext::ServiceName = QString(BLACKMISCKTEST_DATACONTEXT_INTERFACENAME);
|
||||
const QString CDataContext::ServicePath = QString(BLACKMISCKTEST_DATACONTEXT_SERVICEPATH);
|
||||
|
||||
/*
|
||||
* Init this context
|
||||
*/
|
||||
CDataContext::CDataContext(BlackCore::CDBusServer *server)
|
||||
{
|
||||
// 1. Register with the server
|
||||
server->addObject(CDataContext::ServicePath, this);
|
||||
|
||||
// 2. Next I would wire all signals and slots of this context
|
||||
// belonging together
|
||||
}
|
||||
|
||||
/*
|
||||
* FooSlot
|
||||
*/
|
||||
void CDataContext::fooSlot(const QString &baz)
|
||||
{
|
||||
qDebug() << "foo slot" << baz;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* FooSlot
|
||||
* \return
|
||||
*/
|
||||
QString CDataContext::fooSlotRet(const QString &baz)
|
||||
{
|
||||
qDebug() << "foo slot" << baz;
|
||||
return baz;
|
||||
}
|
||||
}
|
||||
@@ -1,193 +0,0 @@
|
||||
#ifndef BLACKMISCTEST_DATACONTEXTCORE_H
|
||||
#define BLACKMISCTEST_DATACONTEXTCORE_H
|
||||
|
||||
#include "blackcore/dbus_server.h"
|
||||
#include "blackmisc/avallclasses.h"
|
||||
#include <QObject>
|
||||
|
||||
#define BLACKMISCKTEST_DATACONTEXT_INTERFACENAME "blackmisctest.datacontext"
|
||||
#define BLACKMISCKTEST_DATACONTEXT_SERVICEPATH "/datacontext"
|
||||
|
||||
namespace BlackMiscTest
|
||||
{
|
||||
|
||||
/*!
|
||||
* \brief A poor man's Data context running in the core
|
||||
*/
|
||||
class CDataContext : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_CLASSINFO("D-Bus Interface", BLACKMISCKTEST_DATACONTEXT_INTERFACENAME)
|
||||
Q_PROPERTY(BlackMisc::Aviation::CAtcStationList qpAtcOnlineList READ onlineControllers WRITE setOnlineControllers)
|
||||
Q_PROPERTY(BlackMisc::Aviation::CAtcStationList qpAtcBookedList READ bookedControllers WRITE setBookedControllers)
|
||||
Q_PROPERTY(QStringList qpFooStrings READ fooStrings)
|
||||
|
||||
// no property for Foo, which is just meant to be local only
|
||||
|
||||
Q_SIGNALS:
|
||||
void fooSignal(const QString &message);
|
||||
|
||||
public:
|
||||
static const QString ServiceName;
|
||||
static const QString ServicePath;
|
||||
|
||||
private:
|
||||
BlackMisc::Aviation::CAtcStationList m_atcOnline;
|
||||
BlackMisc::Aviation::CAtcStationList m_atcBooked;
|
||||
QString m_foo;
|
||||
QStringList m_fooStrings;
|
||||
|
||||
public slots:
|
||||
|
||||
/*!
|
||||
* \brief FooSlot
|
||||
* \param baz
|
||||
*/
|
||||
void fooSlot(const QString &baz); // generated interface methods are "const &QString", so this must match
|
||||
|
||||
/*!
|
||||
* \brief FooSlotRet, with return value
|
||||
* \param baz
|
||||
* \return
|
||||
*/
|
||||
QString fooSlotRet(const QString &baz);
|
||||
|
||||
/*!
|
||||
* \brief Update booked controllers
|
||||
* \param condition
|
||||
* \param values
|
||||
*/
|
||||
void updateBookedControllers(const BlackMisc::CValueMap &condition, const BlackMisc::CValueMap &values)
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
qDebug() << " condition" << condition;
|
||||
qDebug() << " values" << values;
|
||||
m_atcBooked.applyIf(condition, values);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Update online controllers
|
||||
* \param condition
|
||||
* \param values
|
||||
*/
|
||||
void updateOnlineControllers(const BlackMisc::CValueMap &condition, const BlackMisc::CValueMap &values)
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
qDebug() << " condition" << condition;
|
||||
qDebug() << " values" << values;
|
||||
m_atcOnline.applyIf(condition, values);
|
||||
}
|
||||
|
||||
public:
|
||||
/*!
|
||||
* \brief Default constructor
|
||||
*/
|
||||
CDataContext(QObject *parent = nullptr) : QObject(parent) {}
|
||||
|
||||
/*!
|
||||
* \brief ctor for Qt meta system
|
||||
* \param other
|
||||
*/
|
||||
CDataContext(const CDataContext &other) :
|
||||
QObject(), m_atcOnline(other.m_atcOnline), m_atcBooked(other.m_atcBooked), m_foo(other.m_foo), m_fooStrings(other.fooStrings())
|
||||
{
|
||||
// void
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief With link to server
|
||||
* \param server
|
||||
*/
|
||||
CDataContext(BlackCore::CDBusServer *server);
|
||||
|
||||
/*!
|
||||
* \brief The "central" ATC list with online ATC controllers
|
||||
* \return
|
||||
*/
|
||||
BlackMisc::Aviation::CAtcStationList &onlineControllers()
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
return m_atcOnline;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief The "central" ATC list with online ATC controllers
|
||||
* \return
|
||||
*/
|
||||
const BlackMisc::Aviation::CAtcStationList &onlineControllers() const
|
||||
{
|
||||
return m_atcOnline;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Another ATC list, maybe all booked controllers
|
||||
* \return
|
||||
*/
|
||||
const BlackMisc::Aviation::CAtcStationList &bookedControllers() const
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
return m_atcBooked;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Replace value by new values, but keep object itself intact
|
||||
* \param newValues
|
||||
*/
|
||||
void setBookedControllers(const BlackMisc::Aviation::CAtcStationList &newValues)
|
||||
{
|
||||
// problem concurrent updates
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
this->m_atcBooked = newValues;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Replace value by new values, but keep object itself intact
|
||||
* \param newValues
|
||||
*/
|
||||
void setOnlineControllers(const BlackMisc::Aviation::CAtcStationList &newValues)
|
||||
{
|
||||
// problem concurrent updates
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
this->m_atcOnline = newValues;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Some property which would be local only
|
||||
* \return
|
||||
*/
|
||||
const QString &foo() const
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
return m_foo;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Some foo strings
|
||||
* \return
|
||||
*/
|
||||
const QStringList &fooStrings() const
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
return m_fooStrings;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Set n foo strings
|
||||
* \param number
|
||||
*/
|
||||
void setFooStrings(int number)
|
||||
{
|
||||
this->m_fooStrings.clear();
|
||||
for (int i = 0; i < number; i++)
|
||||
{
|
||||
QString foo("I am foo ");
|
||||
foo.append(QString::number(i));
|
||||
this->m_fooStrings.append(foo);
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
Q_DECLARE_METATYPE(BlackMiscTest::CDataContext)
|
||||
|
||||
#endif // guard
|
||||
@@ -1,20 +0,0 @@
|
||||
#include "dummysignalslot.h"
|
||||
|
||||
namespace BlackMiscTest
|
||||
{
|
||||
|
||||
/*
|
||||
* Constructor
|
||||
*/
|
||||
CDummySignalSlot::CDummySignalSlot(const QString &name, QObject *parent) : QObject(parent), m_name(name)
|
||||
{}
|
||||
|
||||
/*
|
||||
* Dummy slot
|
||||
*/
|
||||
void CDummySignalSlot::slotCDummy(const QString &saySomething)
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO << "name:" << this->m_name << "received:" << saySomething;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
#ifndef BLACKMISCTEST_DUMMYSIGNALSLOT_H
|
||||
#define BLACKMISCTEST_DUMMYSIGNALSLOT_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QDebug>
|
||||
|
||||
namespace BlackMiscTest
|
||||
{
|
||||
|
||||
/*!
|
||||
* \brief Dummy class to hook a signal or slot
|
||||
*/
|
||||
class CDummySignalSlot : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
/*!
|
||||
* \brief CDummySignalSlot
|
||||
* \param parent
|
||||
*/
|
||||
CDummySignalSlot(const QString &name, QObject *parent = 0);
|
||||
|
||||
signals:
|
||||
/*!
|
||||
* \brief Test signal
|
||||
* \param saySomething
|
||||
*/
|
||||
void signalCDummy(const QString &saySomething);
|
||||
public slots:
|
||||
/*!
|
||||
* \brief Test slot
|
||||
* \param saySomething
|
||||
*/
|
||||
void slotCDummy(const QString &saySomething);
|
||||
|
||||
private:
|
||||
QString m_name;
|
||||
|
||||
};
|
||||
}
|
||||
#endif // BLACKMISCTEST_DUMMYSIGNALSLOT_H
|
||||
@@ -65,10 +65,6 @@ int main(int argc, char *argv[])
|
||||
|
||||
qDebug() << "1 .. Run testservice to test data transfer" << addressTcp;
|
||||
qDebug() << "1sb. Run testservice via session bus";
|
||||
qDebug() << "2 .. Data context example (via TCP)" << addressTcp;
|
||||
qDebug() << "2sb. Data context example (via session bus)";
|
||||
qDebug() << "3 .. Data context example, only server (via TCP)" << addressTcp;
|
||||
qDebug() << "3sb. Data context example, only server (via session bus)";
|
||||
qDebug() << "----- Change address / port (no validation, do before starting server)";
|
||||
qDebug() << "loop Address to loopback, 127.0.0.1";
|
||||
qDebug() << "ip some IP address, e.g 192.168.100.100";
|
||||
@@ -107,16 +103,11 @@ int main(int argc, char *argv[])
|
||||
|
||||
// start DBus
|
||||
address = QString(useSessionBusForServer ? "session" : addressTcp); // testing with real transfer
|
||||
bool startClient = !mode.startsWith('3');
|
||||
if (mode.contains("sb", Qt::CaseInsensitive)) address = "session";
|
||||
if (mode.startsWith("1"))
|
||||
{
|
||||
mode = "testservice";
|
||||
}
|
||||
else if (mode.startsWith('2') || mode.startsWith('3'))
|
||||
{
|
||||
mode = "context";
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
@@ -142,17 +133,13 @@ int main(int argc, char *argv[])
|
||||
args << ip;
|
||||
args << port;
|
||||
}
|
||||
if (startClient) BlackMiscTest::ServiceTool::startNewProcess(executable, args, &a);
|
||||
BlackMiscTest::ServiceTool::startNewProcess(executable, args, &a);
|
||||
|
||||
// run tests
|
||||
if (mode == "testservice")
|
||||
{
|
||||
BlackMiscTest::ServiceTool::dataTransferTestServer(dBusServer);
|
||||
}
|
||||
else if (mode == "context")
|
||||
{
|
||||
BlackMiscTest::ServiceTool::contextTestServer(dBusServer);
|
||||
}
|
||||
|
||||
// loop
|
||||
return a.exec();
|
||||
@@ -167,10 +154,6 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
BlackMiscTest::ServiceTool::dataTransferTestClient(address);
|
||||
}
|
||||
else if (cmdlineArgs.contains("context", Qt::CaseInsensitive))
|
||||
{
|
||||
BlackMiscTest::ServiceTool::contextTestClient(address);
|
||||
}
|
||||
|
||||
// loop
|
||||
return a.exec();
|
||||
|
||||
@@ -11,3 +11,14 @@ Set search path for plugins: env.var. QT_PLUGIN_PATH
|
||||
Done automatically (qmake), but if required manually
|
||||
Interface: qdbusxml2cpp blackbus.testservice.xml -p itestservice
|
||||
Adaptor: qdbusxml2cpp blackbus.testservice.xml -a atestservice
|
||||
|
||||
-- Removed after changing to "handwritten" interface
|
||||
|
||||
# Causes nmake to run qdbusxml2cpp to automatically generate the dbus adaptor and interface classes,
|
||||
# then automatically adds them to the sources to compile
|
||||
# DBUS_ADAPTORS += BlackMiscTest.Testservice.xml BlackMiscTest.Datacontext.xml
|
||||
# DBUS_INTERFACES += BlackMiscTest.Testservice.xml BlackMiscTest.Datacontext.xml
|
||||
# DBUS_INTERFACES += BlackMiscTest.Datacontext.xml
|
||||
# QDBUSXML2CPP_INTERFACE_HEADER_FLAGS = -i blackmisc/blackmiscfreefunctions.h -i blackmisc/blackmiscallvalueclasses.h
|
||||
# QDBUSXML2CPP_ADAPTOR_HEADER_FLAGS = -i blackmisc/blackmiscfreefunctions.h -i blackmisc/blackmiscallvalueclasses.h
|
||||
|
||||
|
||||
@@ -6,13 +6,6 @@ TEMPLATE = app
|
||||
CONFIG += console c++11
|
||||
CONFIG -= app_bundle
|
||||
|
||||
# Causes nmake to run qdbusxml2cpp to automatically generate the dbus adaptor and interface classes,
|
||||
# then automatically adds them to the sources to compile
|
||||
DBUS_ADAPTORS += BlackMiscTest.Testservice.xml BlackMiscTest.Datacontext.xml
|
||||
DBUS_INTERFACES += BlackMiscTest.Testservice.xml BlackMiscTest.Datacontext.xml
|
||||
QDBUSXML2CPP_INTERFACE_HEADER_FLAGS = -i blackmisc/blackmiscfreefunctions.h -i blackmisc/blackmiscallvalueclasses.h
|
||||
QDBUSXML2CPP_ADAPTOR_HEADER_FLAGS = -i blackmisc/blackmiscfreefunctions.h -i blackmisc/blackmiscallvalueclasses.h
|
||||
|
||||
DEPENDPATH += . ../../src/blackmisc ../../src/blackcore
|
||||
INCLUDEPATH += . ../../src
|
||||
|
||||
@@ -27,4 +20,4 @@ DESTDIR = ../../bin
|
||||
HEADERS += *.h
|
||||
SOURCES += *.cpp
|
||||
|
||||
OTHER_FILES += readme.txt BlackMiscTest.Testservice.xml BlackMiscTest.Datacontext.xml
|
||||
OTHER_FILES += *.txt *.xml
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
#include "servicetool.h"
|
||||
#include "testservice.h"
|
||||
#include "testservice_adaptor.h"
|
||||
#include "testservice_interface.h"
|
||||
#include "datacontext.h"
|
||||
#include "datacontext_interface.h"
|
||||
#include "datacontext_adaptor.h"
|
||||
#include "blackcore/dbus_server.h"
|
||||
#include "blackmisc/valuemap.h"
|
||||
#include "blackmisc/nwserver.h"
|
||||
@@ -97,45 +93,6 @@ namespace BlackMiscTest
|
||||
ServiceTool::sendDataToTestservice(p2pConnection);
|
||||
}
|
||||
|
||||
/*
|
||||
* Context data transfer test server
|
||||
*/
|
||||
void ServiceTool::contextTestServer(BlackCore::CDBusServer *dBusServer)
|
||||
{
|
||||
// init data context
|
||||
CDataContext *dataContext = new CDataContext(dBusServer);
|
||||
|
||||
// create a object which can be connected to signals / slots
|
||||
CDummySignalSlot *serverSignalSlot = new CDummySignalSlot("server", QCoreApplication::instance());
|
||||
|
||||
// Adaptor based on context objext
|
||||
DatacontextAdaptor *dataContextAdaptor = new DatacontextAdaptor(dataContext); // needs to be created in same thread
|
||||
|
||||
// Run server loop:
|
||||
// This happens in a different thread, because server needs event loop for
|
||||
// its signal and slots
|
||||
QtConcurrent::run(ServiceTool::serverLoop, dBusServer, dataContext, dataContextAdaptor, serverSignalSlot); // QFuture<void> future
|
||||
qDebug() << "Server event loop, pid:" << ServiceTool::getPid();
|
||||
}
|
||||
|
||||
/*
|
||||
* Context data transfer test client
|
||||
*/
|
||||
void ServiceTool::contextTestClient(const QString &address)
|
||||
{
|
||||
// create a object which can be connected to signals / slots
|
||||
CDummySignalSlot *clientSignalSlot = new CDummySignalSlot("client", QCoreApplication::instance());
|
||||
|
||||
// connection
|
||||
QDBusConnection p2pConnection = address == "session" ?
|
||||
QDBusConnection::sessionBus() :
|
||||
QDBusConnection::connectToPeer(address, "p2pConnection");
|
||||
|
||||
// run client loop
|
||||
QtConcurrent::run(ServiceTool::clientLoop, p2pConnection, clientSignalSlot); // QFuture<void> future
|
||||
qDebug() << "Client event loop, pid:" << ServiceTool::getPid();
|
||||
}
|
||||
|
||||
/*
|
||||
* Get callsign
|
||||
*/
|
||||
@@ -182,8 +139,6 @@ namespace BlackMiscTest
|
||||
Testservice *ServiceTool::registerTestservice(QDBusConnection &connection, QObject *parent)
|
||||
{
|
||||
Testservice *pTestservice = new Testservice(parent); // just a QObject with signals / slots and Q_CLASSINFO("D-Bus Interface", some service name)
|
||||
TestserviceAdaptor *pTestserviceAdaptor = new TestserviceAdaptor(pTestservice);
|
||||
|
||||
if (!connection.registerService(Testservice::ServiceName))
|
||||
{
|
||||
QDBusError err = connection.lastError();
|
||||
@@ -194,14 +149,13 @@ namespace BlackMiscTest
|
||||
qFatal("Could not register service!");
|
||||
}
|
||||
|
||||
if (!connection.registerObject(Testservice::ServicePath, pTestservice))
|
||||
if (!connection.registerObject(Testservice::ServicePath, pTestservice, QDBusConnection::ExportAllSlots | QDBusConnection::ExportAllSignals | QDBusConnection::ExportAdaptors))
|
||||
{
|
||||
qFatal("Could not register service object!");
|
||||
}
|
||||
|
||||
qDebug() << "Registration running as pid:" << ServiceTool::getPid();
|
||||
if (pTestservice) qDebug() << "Service registered";
|
||||
if (pTestserviceAdaptor) qDebug() << "Adaptor object registered";
|
||||
|
||||
QString service; // service not needed
|
||||
if (connection.connect(
|
||||
@@ -223,7 +177,7 @@ namespace BlackMiscTest
|
||||
void ServiceTool::sendDataToTestservice(const QDBusConnection &connection)
|
||||
{
|
||||
// on the client's side
|
||||
BlackmisctestTestserviceInterface testserviceInterface(Testservice::ServiceName, Testservice::ServicePath, connection);
|
||||
TestServiceInterface testserviceInterface(Testservice::ServiceName, Testservice::ServicePath, connection);
|
||||
|
||||
CSpeed speed(200, BlackMisc::PhysicalQuantities::CSpeedUnit::km_h());
|
||||
CAltitude al(1000, CAltitude::MeanSeaLevel, CLengthUnit::ft());
|
||||
@@ -308,16 +262,23 @@ namespace BlackMiscTest
|
||||
CCallsign callsign("d-ambz");
|
||||
testserviceInterface.receiveCallsign(callsign);
|
||||
qDebug() << "Send callsign via interface" << callsign;
|
||||
|
||||
CCoordinateGeodetic geoPos = CCoordinateGeodetic::fromWgs84("48° 21′ 13″ N", "11° 47′ 09″ E", CLength(1487, CLengthUnit::ft())); // Munich
|
||||
CAtcStation station(CCallsign("eddm_twr"), CUser("123456", "Joe Doe"),
|
||||
CAtcStation station(CCallsign("eddm_twr"), CUser("123456", "Joe Controller"),
|
||||
CFrequency(118.7, CFrequencyUnit::MHz()),
|
||||
geoPos, CLength(50, CLengthUnit::km()));
|
||||
|
||||
testserviceInterface.receiveAtcStation(station);
|
||||
qDebug() << "Send ATC station via interface" << station;
|
||||
|
||||
station = testserviceInterface.pingAtcStation(station);
|
||||
qDebug() << "Pinged ATC station via interface" << station;
|
||||
CAtcStation stationReceived = testserviceInterface.pingAtcStation(station);
|
||||
qDebug() << "Pinged ATC station via interface"
|
||||
<< ((station == stationReceived) ? "OK" : "ERROR!") << stationReceived;
|
||||
|
||||
CAircraftSituation situation;
|
||||
CAircraft aircraft(callsign, CUser("123456", "Joe Pilot"), situation);
|
||||
CAircraft aircraftReceived = testserviceInterface.pingAircraft(aircraft);
|
||||
qDebug() << "Pinged aircraft via interface"
|
||||
<< ((aircraft == aircraftReceived) ? "OK" : "ERROR!") << aircraftReceived;
|
||||
|
||||
CAtcStationList AtcStationList;
|
||||
AtcStationList.push_back(station);
|
||||
@@ -464,225 +425,4 @@ namespace BlackMiscTest
|
||||
if (ch == 'x') loop = false;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Send data to testservice, this sends data to the slots on the server
|
||||
*/
|
||||
void ServiceTool::serverLoop(BlackCore::CDBusServer *server, CDataContext *dataContext, DatacontextAdaptor *dataContextAdaptor, CDummySignalSlot *dummySignalSlot)
|
||||
{
|
||||
QThread::msleep(3 * 1000); // let the client conncect
|
||||
qDebug() << "Running on server here" << ServiceTool::getPid();
|
||||
CCoordinateGeodetic geoPos = CCoordinateGeodetic::fromWgs84("48° 21′ 13″ N", "11° 47′ 09″ E", CLength(1487, CLengthUnit::ft())); // Munich
|
||||
CAtcStation station(CCallsign("eddm_twr"), CUser("123456", "Server"),
|
||||
CFrequency(118.7, CFrequencyUnit::MHz()),
|
||||
geoPos, CLength(50, CLengthUnit::km()));
|
||||
CAtcStationList stationList;
|
||||
QTextStream qtin(stdin);
|
||||
QString line;
|
||||
|
||||
// we can hook up signal slot
|
||||
if (QObject::connect(dataContext, SIGNAL(fooSignal(QString)),
|
||||
dummySignalSlot, SLOT(slotCDummy(QString))))
|
||||
{
|
||||
qDebug() << "Hooked up foo signal";
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << "Hook up of foo signal failed!!!";
|
||||
}
|
||||
|
||||
//
|
||||
// Server loop
|
||||
//
|
||||
while (line != "x")
|
||||
{
|
||||
// set a random callsign
|
||||
station.setCallsign(ServiceTool::getRandomCallsign());
|
||||
|
||||
// do what we got to do
|
||||
if (line == "1")
|
||||
{
|
||||
stationList.push_back(station);
|
||||
dataContextAdaptor->setQpAtcOnlineList(stationList);
|
||||
dataContextAdaptor->setQpAtcBookedList(stationList);
|
||||
}
|
||||
else if (line == "2")
|
||||
{
|
||||
stationList.push_back(station);
|
||||
dataContext->setBookedControllers(stationList);
|
||||
dataContext->setOnlineControllers(stationList);
|
||||
}
|
||||
else if (line.startsWith("3"))
|
||||
{
|
||||
int end = (line == "3l") ? 1000 : 1;
|
||||
for (int i = 0; i < end; i++)
|
||||
{
|
||||
station.setCallsign(ServiceTool::getRandomCallsign());
|
||||
dataContext->onlineControllers().push_back(station); // non const version
|
||||
}
|
||||
}
|
||||
else if (line == "4")
|
||||
{
|
||||
// Signal sending is not transparent
|
||||
qDebug() << "emit foo signal as Qt signal";
|
||||
emit dataContext->fooSignal(QDateTime::currentDateTime().toString());
|
||||
// emit dataContextAdaptor->fooSignal(QDateTime::currentDateTime().toString());
|
||||
}
|
||||
else if (line == "5")
|
||||
{
|
||||
QDBusMessage signal = QDBusMessage::createSignal(
|
||||
CDataContext::ServicePath,
|
||||
CDataContext::ServiceName,
|
||||
"fooSignal");
|
||||
signal << QDateTime::currentDateTime().toString(); // parameter
|
||||
|
||||
// With server use the server's connection which is only available once a connection has been established
|
||||
// otherwise use the given connection which allows to use this method with session/system bus
|
||||
QDBusConnection serverConnection = server->getDbusConnections().first();
|
||||
if (serverConnection.send(signal))
|
||||
{
|
||||
qDebug() << "emit foo signal as DBus signal on server connection " << serverConnection.name();
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << "some issue with DBus signal on server connection" << serverConnection.name();
|
||||
}
|
||||
}
|
||||
else if (line == "6")
|
||||
{
|
||||
dataContext->setFooStrings(1000);
|
||||
}
|
||||
|
||||
// display current status
|
||||
qDebug() << "-------------";
|
||||
qDebug() << "ATC booked";
|
||||
qDebug() << dataContext->bookedControllers().toQString();
|
||||
qDebug() << "-------------";
|
||||
qDebug() << "ATC online";
|
||||
qDebug() << dataContext->onlineControllers().toQString();
|
||||
qDebug() << "-------------";
|
||||
qDebug() << "Foos";
|
||||
qDebug() << dataContext->fooStrings();
|
||||
qDebug() << "-------------";
|
||||
|
||||
// next round? Server
|
||||
qDebug() << "Key x to exit";
|
||||
qDebug() << "1 .. new list via property on adaptor";
|
||||
qDebug() << "2 .. new list via context";
|
||||
qDebug() << "3 .. append 1 to online controllers in context"; // add to reference
|
||||
qDebug() << "3l . append 1000 to context";
|
||||
qDebug() << "4 .. send Foo signal as Qt signal";
|
||||
qDebug() << "5 .. send Foo signal as DBus signal";
|
||||
qDebug() << "6 .. set 1000 Foo objects";
|
||||
|
||||
line = qtin.readLine();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Send data to testservice, this sends data to the slots on the server
|
||||
*/
|
||||
void ServiceTool::clientLoop(QDBusConnection &connection, CDummySignalSlot *dummyObjectSignalSlot)
|
||||
{
|
||||
// Service name does not matter when using P2P, it is only required using session/system bus
|
||||
// Using a literal here ("foo"), crashes the app
|
||||
BlackmisctestDatacontextInterface dataContextInterface(BlackCore::CDBusServer::ServiceName, CDataContext::ServicePath, connection);
|
||||
if (dummyObjectSignalSlot)
|
||||
{
|
||||
const QString signalName("fooSignal");
|
||||
if (connection.connect(BlackCore::CDBusServer::ServiceName, CDataContext::ServicePath, CDataContext::ServiceName, signalName, dummyObjectSignalSlot, SLOT(slotCDummy(QString))))
|
||||
{
|
||||
qDebug() << "Hooked up foo signal on connection";
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << "Hook up of foo signal failed on connection!!!";
|
||||
}
|
||||
|
||||
|
||||
// we can hook up signal slot
|
||||
if (dataContextInterface.connect(&dataContextInterface, SIGNAL(fooSignal(QString)),
|
||||
dummyObjectSignalSlot, SLOT(slotCDummy(QString))))
|
||||
{
|
||||
qDebug() << "Hooked up foo signal on interface";
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << "Hook up of foo signal failed on interface!!!";
|
||||
}
|
||||
}
|
||||
|
||||
qDebug() << "Running on client here, pid:" << ServiceTool::getPid();
|
||||
CCoordinateGeodetic geoPos = CCoordinateGeodetic::fromWgs84("48° 21′ 13″ N", "11° 47′ 09″ E", CLength(1487, CLengthUnit::ft())); // Munich
|
||||
CAtcStation station(CCallsign("eddm_twr"), CUser("654321", "client"),
|
||||
CFrequency(118.7, CFrequencyUnit::MHz()),
|
||||
geoPos, CLength(50, CLengthUnit::km()));
|
||||
QTextStream qtin(stdin);
|
||||
QString line;
|
||||
|
||||
//
|
||||
// Server loop
|
||||
//
|
||||
while (line != "x")
|
||||
{
|
||||
// set a random callsign
|
||||
station.setCallsign(ServiceTool::getRandomCallsign());
|
||||
|
||||
// do what we got to do
|
||||
if (line == "1")
|
||||
{
|
||||
// retrieves all stations, add one, and sends them back
|
||||
CAtcStationList stations = dataContextInterface.qpAtcBookedList();
|
||||
stations.push_back(station);
|
||||
dataContextInterface.setQpAtcBookedList(stations);
|
||||
|
||||
stations = dataContextInterface.qpAtcOnlineList();
|
||||
stations.push_back(station);
|
||||
dataContextInterface.setQpAtcOnlineList(stations);
|
||||
}
|
||||
else if (line == "3")
|
||||
{
|
||||
// this will not change anything
|
||||
dataContextInterface.qpAtcBookedList().push_back(station);
|
||||
dataContextInterface.qpAtcOnlineList().push_back(station);
|
||||
}
|
||||
else if (line == "5")
|
||||
{
|
||||
emit dataContextInterface.fooSignal("Directly called on interface on client");
|
||||
}
|
||||
else if (line.startsWith("7") && line.length() > 1)
|
||||
{
|
||||
CCallsign callsign(line.mid(1));
|
||||
CValueMap condition;
|
||||
condition.addValue(CAtcStation::IndexCallsign, callsign);
|
||||
CValueMap value;
|
||||
value.addValue(CAtcStation::IndexBookedFrom, QDateTime::currentDateTimeUtc().addDays(1));
|
||||
value.addValue(CAtcStation::IndexBookedUntil, QDateTime::currentDateTimeUtc().addDays(2));
|
||||
qDebug() << " condition" << condition;
|
||||
qDebug() << " values" << value;
|
||||
dataContextInterface.updateOnlineControllers(condition, value);
|
||||
}
|
||||
|
||||
// display current status
|
||||
qDebug() << "-------------";
|
||||
qDebug() << "ATC booked";
|
||||
qDebug() << dataContextInterface.qpAtcBookedList().toQString(); // as property
|
||||
qDebug() << "-------------";
|
||||
qDebug() << "ATC online";
|
||||
qDebug() << dataContextInterface.qpAtcOnlineList().toQString(); // as property
|
||||
qDebug() << "-------------";
|
||||
qDebug() << "Foos";
|
||||
qDebug() << dataContextInterface.qpFooStrings();
|
||||
qDebug() << "-------------";
|
||||
|
||||
// next round? Client
|
||||
qDebug() << "Key x to exit";
|
||||
qDebug() << "1 .. add new list via property on interface";
|
||||
qDebug() << "3 .. append 1 to controllers in context (not expected to change anything)"; // add to reference
|
||||
qDebug() << "5 .. foo signal directly on interface";
|
||||
qDebug() << "7x . 7<callsign>, update if, e.g. 7EDDM_TWR";
|
||||
|
||||
line = qtin.readLine();
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
@@ -2,21 +2,17 @@
|
||||
#define BLACKMISCTEST_SERVICETOOL_H
|
||||
|
||||
#include "blackcore/dbus_server.h"
|
||||
#include "datacontext.h"
|
||||
#include "dummysignalslot.h"
|
||||
#include "blackmisc/avatcstationlist.h"
|
||||
#include <QCoreApplication>
|
||||
#include <QProcess>
|
||||
#include <QDBusConnection>
|
||||
|
||||
class DatacontextAdaptor;
|
||||
|
||||
namespace BlackMiscTest
|
||||
{
|
||||
|
||||
class Testservice; // forward declaration
|
||||
|
||||
/*!
|
||||
* \brief Supporting functions for running the tests
|
||||
* \brief Supporting / helper functions for running the tests
|
||||
*/
|
||||
class ServiceTool
|
||||
{
|
||||
@@ -44,18 +40,6 @@ namespace BlackMiscTest
|
||||
*/
|
||||
static void dataTransferTestServer(BlackCore::CDBusServer *dBusServer);
|
||||
|
||||
/*!
|
||||
* \brief Context test, server side
|
||||
* \param dBusServer
|
||||
*/
|
||||
static void contextTestServer(BlackCore::CDBusServer *dBusServer);
|
||||
|
||||
/*!
|
||||
* \brief Context test, client side
|
||||
* \param address
|
||||
*/
|
||||
static void contextTestClient(const QString &address);
|
||||
|
||||
/*!
|
||||
* \brief Start a new process
|
||||
* \param executable
|
||||
@@ -85,21 +69,6 @@ namespace BlackMiscTest
|
||||
*/
|
||||
static Testservice *registerTestservice(QDBusConnection &connection, QObject *parent = 0);
|
||||
|
||||
/*!
|
||||
* \brief Server loop
|
||||
* \param server
|
||||
* \param dataContext
|
||||
* \param dataContextAdaptor
|
||||
* \param dummySignalSlot
|
||||
*/
|
||||
static void serverLoop(BlackCore::CDBusServer *server, CDataContext *dataContext, DatacontextAdaptor *dataContextAdaptor, CDummySignalSlot *dummySignalSlot);
|
||||
|
||||
/*!
|
||||
* \brief Client loop
|
||||
* \param connection
|
||||
*/
|
||||
static void clientLoop(QDBusConnection &connection, CDummySignalSlot *dummyObjectSignalSlot);
|
||||
|
||||
/*!
|
||||
* \brief Get a random callsign
|
||||
* \return
|
||||
|
||||
@@ -250,4 +250,11 @@ namespace BlackMiscTest
|
||||
return station;
|
||||
}
|
||||
|
||||
/*
|
||||
* Ping aircraft
|
||||
*/
|
||||
BlackMisc::Aviation::CAircraft Testservice::pingAircraft(const BlackMisc::Aviation::CAircraft &aircraft)
|
||||
{
|
||||
return aircraft;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
@@ -157,6 +157,13 @@ namespace BlackMiscTest
|
||||
*/
|
||||
BlackMisc::Aviation::CAtcStation pingAtcStation(const BlackMisc::Aviation::CAtcStation &station);
|
||||
|
||||
/*!
|
||||
* \brief Ping aircraft
|
||||
* \param aircraft
|
||||
* \return
|
||||
*/
|
||||
BlackMisc::Aviation::CAircraft pingAircraft(const BlackMisc::Aviation::CAircraft &aircraft);
|
||||
|
||||
/*!
|
||||
* \brief Receive callsign
|
||||
* \param callsign
|
||||
@@ -216,7 +223,7 @@ namespace BlackMiscTest
|
||||
* \brief Constructor
|
||||
* \param parent
|
||||
*/
|
||||
explicit Testservice(QObject *parent = 0);
|
||||
explicit Testservice(QObject *parent = nullptr);
|
||||
|
||||
private:
|
||||
BlackMisc::Aviation::CAtcStationList m_someAtcStations;
|
||||
|
||||
11
samples/blackmiscdbus/testservice_interface.cpp
Normal file
11
samples/blackmiscdbus/testservice_interface.cpp
Normal file
@@ -0,0 +1,11 @@
|
||||
#include "testservice_interface.h"
|
||||
|
||||
namespace BlackMiscTest
|
||||
{
|
||||
TestServiceInterface::TestServiceInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent)
|
||||
: QDBusAbstractInterface(service, path, staticInterfaceName(), connection, parent)
|
||||
{}
|
||||
|
||||
TestServiceInterface::~TestServiceInterface()
|
||||
{}
|
||||
}
|
||||
227
samples/blackmiscdbus/testservice_interface.h
Normal file
227
samples/blackmiscdbus/testservice_interface.h
Normal file
@@ -0,0 +1,227 @@
|
||||
#ifndef BLACKMISCTEST_TESTSERVICE_INTERFACE_H
|
||||
#define BLACKMISCTEST_TESTSERVICE_INTERFACE_H
|
||||
|
||||
#include "blackmisc/blackmiscfreefunctions.h"
|
||||
#include "blackmisc/blackmiscallvalueclasses.h"
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QByteArray>
|
||||
#include <QtCore/QList>
|
||||
#include <QtCore/QMap>
|
||||
#include <QtCore/QString>
|
||||
#include <QtCore/QStringList>
|
||||
#include <QtCore/QVariant>
|
||||
#include <QtDBus/QtDBus>
|
||||
|
||||
namespace BlackMiscTest
|
||||
{
|
||||
|
||||
/*!
|
||||
* \brief Proxy class for interface blackmisctest.testservice
|
||||
*/
|
||||
class TestServiceInterface: public QDBusAbstractInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
static inline const char *staticInterfaceName() { return "blackmisctest.testservice"; }
|
||||
|
||||
public:
|
||||
//! \brief Constructor
|
||||
TestServiceInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0);
|
||||
|
||||
//! \brief Destructor
|
||||
~TestServiceInterface();
|
||||
|
||||
public Q_SLOTS:
|
||||
|
||||
//! \brief DBus calls
|
||||
//! @{
|
||||
inline QDBusPendingReply<BlackMisc::Aviation::CAtcStation> getAtcStation()
|
||||
{
|
||||
QList<QVariant> argumentList;
|
||||
return asyncCallWithArgumentList(QLatin1String("getAtcStation"), argumentList);
|
||||
}
|
||||
|
||||
inline QDBusPendingReply<BlackMisc::Aviation::CAtcStationList> getAtcStationList(int number)
|
||||
{
|
||||
QList<QVariant> argumentList;
|
||||
argumentList << QVariant::fromValue(number);
|
||||
return asyncCallWithArgumentList(QLatin1String("getAtcStationList"), argumentList);
|
||||
}
|
||||
|
||||
inline QDBusPendingReply<QList<QDBusObjectPath> > getObjectPaths(int number)
|
||||
{
|
||||
QList<QVariant> argumentList;
|
||||
argumentList << QVariant::fromValue(number);
|
||||
return asyncCallWithArgumentList(QLatin1String("getObjectPaths"), argumentList);
|
||||
}
|
||||
|
||||
inline QDBusPendingReply<BlackMisc::PhysicalQuantities::CSpeed> getSpeed()
|
||||
{
|
||||
QList<QVariant> argumentList;
|
||||
return asyncCallWithArgumentList(QLatin1String("getSpeed"), argumentList);
|
||||
}
|
||||
|
||||
inline QDBusPendingReply<BlackMisc::Aviation::CAltitude> pingAltitude(BlackMisc::Aviation::CAltitude altitude)
|
||||
{
|
||||
QList<QVariant> argumentList;
|
||||
argumentList << QVariant::fromValue(altitude);
|
||||
return asyncCallWithArgumentList(QLatin1String("pingAltitude"), argumentList);
|
||||
}
|
||||
|
||||
inline QDBusPendingReply<BlackMisc::Aviation::CAtcStation> pingAtcStation(BlackMisc::Aviation::CAtcStation station)
|
||||
{
|
||||
QList<QVariant> argumentList;
|
||||
argumentList << QVariant::fromValue(station);
|
||||
return asyncCallWithArgumentList(QLatin1String("pingAtcStation"), argumentList);
|
||||
}
|
||||
|
||||
inline QDBusPendingReply<BlackMisc::Aviation::CAircraft> pingAircraft(BlackMisc::Aviation::CAircraft aircraft)
|
||||
{
|
||||
QList<QVariant> argumentList;
|
||||
argumentList << QVariant::fromValue(aircraft);
|
||||
return asyncCallWithArgumentList(QLatin1String("pingAircraft"), argumentList);
|
||||
}
|
||||
|
||||
inline QDBusPendingReply<BlackMisc::Aviation::CAtcStationList> pingAtcStationList(BlackMisc::Aviation::CAtcStationList AtcStationList)
|
||||
{
|
||||
QList<QVariant> argumentList;
|
||||
argumentList << QVariant::fromValue(AtcStationList);
|
||||
return asyncCallWithArgumentList(QLatin1String("pingAtcStationList"), argumentList);
|
||||
}
|
||||
|
||||
inline QDBusPendingReply<BlackMisc::PhysicalQuantities::CSpeed> pingSpeed(BlackMisc::PhysicalQuantities::CSpeed speed)
|
||||
{
|
||||
QList<QVariant> argumentList;
|
||||
argumentList << QVariant::fromValue(speed);
|
||||
return asyncCallWithArgumentList(QLatin1String("pingSpeed"), argumentList);
|
||||
}
|
||||
|
||||
inline QDBusPendingReply<> receiveAltitude(BlackMisc::Aviation::CAltitude altitude)
|
||||
{
|
||||
QList<QVariant> argumentList;
|
||||
argumentList << QVariant::fromValue(altitude);
|
||||
return asyncCallWithArgumentList(QLatin1String("receiveAltitude"), argumentList);
|
||||
}
|
||||
|
||||
inline QDBusPendingReply<> receiveAtcStation(BlackMisc::Aviation::CAtcStation station)
|
||||
{
|
||||
QList<QVariant> argumentList;
|
||||
argumentList << QVariant::fromValue(station);
|
||||
return asyncCallWithArgumentList(QLatin1String("receiveAtcStation"), argumentList);
|
||||
}
|
||||
|
||||
inline QDBusPendingReply<> receiveAtcStationList(BlackMisc::Aviation::CAtcStationList AtcStationList)
|
||||
{
|
||||
QList<QVariant> argumentList;
|
||||
argumentList << QVariant::fromValue(AtcStationList);
|
||||
return asyncCallWithArgumentList(QLatin1String("receiveAtcStationList"), argumentList);
|
||||
}
|
||||
|
||||
inline QDBusPendingReply<> receiveCallsign(BlackMisc::Aviation::CCallsign callsign)
|
||||
{
|
||||
QList<QVariant> argumentList;
|
||||
argumentList << QVariant::fromValue(callsign);
|
||||
return asyncCallWithArgumentList(QLatin1String("receiveCallsign"), argumentList);
|
||||
}
|
||||
|
||||
inline QDBusPendingReply<> receiveComUnit(BlackMisc::Aviation::CComSystem comUnit)
|
||||
{
|
||||
QList<QVariant> argumentList;
|
||||
argumentList << QVariant::fromValue(comUnit);
|
||||
return asyncCallWithArgumentList(QLatin1String("receiveComUnit"), argumentList);
|
||||
}
|
||||
|
||||
inline QDBusPendingReply<> receiveGeoPosition(BlackMisc::Geo::CCoordinateGeodetic geo)
|
||||
{
|
||||
QList<QVariant> argumentList;
|
||||
argumentList << QVariant::fromValue(geo);
|
||||
return asyncCallWithArgumentList(QLatin1String("receiveGeoPosition"), argumentList);
|
||||
}
|
||||
|
||||
inline QDBusPendingReply<> receiveLength(BlackMisc::PhysicalQuantities::CLength length)
|
||||
{
|
||||
QList<QVariant> argumentList;
|
||||
argumentList << QVariant::fromValue(length);
|
||||
return asyncCallWithArgumentList(QLatin1String("receiveLength"), argumentList);
|
||||
}
|
||||
|
||||
inline QDBusPendingReply<> receiveLengthsQl(const QVariantList &lengthsList)
|
||||
{
|
||||
QList<QVariant> argumentList;
|
||||
argumentList << QVariant::fromValue(lengthsList);
|
||||
return asyncCallWithArgumentList(QLatin1String("receiveLengthsQl"), argumentList);
|
||||
}
|
||||
|
||||
inline QDBusPendingReply<> receiveLengthsQvl(const QVariantList &lengthsVariantList)
|
||||
{
|
||||
QList<QVariant> argumentList;
|
||||
argumentList << QVariant::fromValue(lengthsVariantList);
|
||||
return asyncCallWithArgumentList(QLatin1String("receiveLengthsQvl"), argumentList);
|
||||
}
|
||||
|
||||
inline QDBusPendingReply<> receiveList(const QList<double> &list)
|
||||
{
|
||||
QList<QVariant> argumentList;
|
||||
argumentList << QVariant::fromValue(list);
|
||||
return asyncCallWithArgumentList(QLatin1String("receiveList"), argumentList);
|
||||
}
|
||||
|
||||
inline QDBusPendingReply<> receiveMatrix(BlackMisc::Math::CMatrix3x3 matrix)
|
||||
{
|
||||
QList<QVariant> argumentList;
|
||||
argumentList << QVariant::fromValue(matrix);
|
||||
return asyncCallWithArgumentList(QLatin1String("receiveMatrix"), argumentList);
|
||||
}
|
||||
|
||||
inline QDBusPendingReply<> receiveSpeed(BlackMisc::PhysicalQuantities::CSpeed speed)
|
||||
{
|
||||
QList<QVariant> argumentList;
|
||||
argumentList << QVariant::fromValue(speed);
|
||||
return asyncCallWithArgumentList(QLatin1String("receiveSpeed"), argumentList);
|
||||
}
|
||||
|
||||
inline QDBusPendingReply<> receiveStringMessage(const QString &message)
|
||||
{
|
||||
QList<QVariant> argumentList;
|
||||
argumentList << QVariant::fromValue(message);
|
||||
return asyncCallWithArgumentList(QLatin1String("receiveStringMessage"), argumentList);
|
||||
}
|
||||
|
||||
inline QDBusPendingReply<> receiveTrack(BlackMisc::Aviation::CTrack track)
|
||||
{
|
||||
QList<QVariant> argumentList;
|
||||
argumentList << QVariant::fromValue(track);
|
||||
return asyncCallWithArgumentList(QLatin1String("receiveTrack"), argumentList);
|
||||
}
|
||||
|
||||
inline QDBusPendingReply<> receiveTransponder(BlackMisc::Aviation::CTransponder transponder)
|
||||
{
|
||||
QList<QVariant> argumentList;
|
||||
argumentList << QVariant::fromValue(transponder);
|
||||
return asyncCallWithArgumentList(QLatin1String("receiveTransponder"), argumentList);
|
||||
}
|
||||
|
||||
inline QDBusPendingReply<> receiveValueMap(BlackMisc::CValueMap valueMap)
|
||||
{
|
||||
QList<QVariant> argumentList;
|
||||
argumentList << QVariant::fromValue(valueMap);
|
||||
return asyncCallWithArgumentList(QLatin1String("receiveValueMap"), argumentList);
|
||||
}
|
||||
|
||||
inline QDBusPendingReply<> receiveVariant(const QDBusVariant &variant, int localMetyType)
|
||||
{
|
||||
QList<QVariant> argumentList;
|
||||
argumentList << QVariant::fromValue(variant) << QVariant::fromValue(localMetyType);
|
||||
return asyncCallWithArgumentList(QLatin1String("receiveVariant"), argumentList);
|
||||
}
|
||||
//! @}
|
||||
|
||||
|
||||
Q_SIGNALS:
|
||||
//! \brief send message
|
||||
void sendStringMessage(const QString &message);
|
||||
};
|
||||
} // namespace
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user