Group own aircraft DBus calls together

Previously all own aircraft values were request via single DBus calls.
Since DBus allows up to 8 values in its reply, use this mechanism
to group the requests and reduce the amount of single calls.
This commit is contained in:
Roland Winklmeier
2018-04-04 10:08:22 +02:00
parent d77931e5ec
commit b278d9ee2f
4 changed files with 62 additions and 39 deletions

View File

@@ -8,6 +8,7 @@
*/
#include "xswiftbusserviceproxy.h"
#include "simulatorxplane.h"
#include <QLatin1String>
@@ -25,6 +26,27 @@ namespace BlackSimPlugin
if (!dummy) { m_dbusInterface->relayParentSignals(); }
}
void CXSwiftBusServiceProxy::getOwnAircraftSituationData(XPlaneData *o_xplaneData)
{
std::function<void(QDBusPendingCallWatcher *)> callback = [this, o_xplaneData](QDBusPendingCallWatcher * watcher)
{
QDBusPendingReply<double, double, double, double, double, double, double, double> reply = *watcher;
if (!reply.isError())
{
o_xplaneData->latitude = reply.argumentAt<0>();
o_xplaneData->longitude = reply.argumentAt<1>();
o_xplaneData->altitude = reply.argumentAt<2>();
o_xplaneData->groundspeed = reply.argumentAt<3>();
o_xplaneData->pitch = reply.argumentAt<4>();
o_xplaneData->roll = reply.argumentAt<5>();
o_xplaneData->trueHeading = reply.argumentAt<6>();
o_xplaneData->seaLeveLPressure = reply.argumentAt<7>();
}
watcher->deleteLater();
};
m_dbusInterface->callDBusAsync(QLatin1String("getOwnAircraftSituationData"), callback);
}
void CXSwiftBusServiceProxy::addTextMessage(const QString &text, double red, double green, double blue)
{
m_dbusInterface->callDBus(QLatin1String("addTextMessage"), text, red, green, blue);