mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-16 18:35:35 +08:00
Ref T778, fix getRemoteAircraftData
* send waterFlags as DBus int * waterFlags.clear() * CDBusMessage::appendArgument(const std::vector<bool> &array) squash! Ref T778, fix getRemoteAircraftData
This commit is contained in:
committed by
Mat Sutcliffe
parent
b5d100b71b
commit
6ceb91ac4f
@@ -159,13 +159,19 @@ namespace BlackSimPlugin
|
|||||||
if (!reply.isError())
|
if (!reply.isError())
|
||||||
{
|
{
|
||||||
const QStringList callsigns = reply.argumentAt<0>();
|
const QStringList callsigns = reply.argumentAt<0>();
|
||||||
const QList<double> latitudesDeg = reply.argumentAt<1>();
|
const QList<double> latitudesDeg = reply.argumentAt<1>();
|
||||||
const QList<double> longitudesDeg = reply.argumentAt<2>();
|
const QList<double> longitudesDeg = reply.argumentAt<2>();
|
||||||
const QList<double> elevationsM = reply.argumentAt<3>();
|
const QList<double> elevationsM = reply.argumentAt<3>();
|
||||||
const QList<bool> waterFlags = reply.argumentAt<4>();
|
const QList<bool> waterFlags = reply.argumentAt<4>();
|
||||||
const QList<double> verticalOffsets = reply.argumentAt<5>();
|
const QList<double> verticalOffsets = reply.argumentAt<5>();
|
||||||
|
|
||||||
setter(callsigns, latitudesDeg, longitudesDeg, elevationsM, waterFlags, verticalOffsets);
|
setter(callsigns, latitudesDeg, longitudesDeg, elevationsM, waterFlags, verticalOffsets);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const QString errorMsg = reply.error().message();
|
||||||
|
CLogMessage(this).warning(u"XSwiftBus DBus error getRemoteAircraftData: %1") << errorMsg;
|
||||||
|
}
|
||||||
watcher->deleteLater();
|
watcher->deleteLater();
|
||||||
};
|
};
|
||||||
m_dbusInterface->callDBusAsync(QLatin1String("getRemoteAircraftData"), callback, callsigns);
|
m_dbusInterface->callDBusAsync(QLatin1String("getRemoteAircraftData"), callback, callsigns);
|
||||||
|
|||||||
@@ -109,6 +109,24 @@ namespace XSwiftBus
|
|||||||
dbus_message_iter_append_basic(&m_messageIterator, DBUS_TYPE_DOUBLE, &value);
|
dbus_message_iter_append_basic(&m_messageIterator, DBUS_TYPE_DOUBLE, &value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CDBusMessage::appendArgument(const std::vector<bool> &array)
|
||||||
|
{
|
||||||
|
// array.data() not existing for bool
|
||||||
|
// changing dbus_message_iter_open_container here affects DBus signature
|
||||||
|
// using int16 creates signature "n", mismatch on swift side
|
||||||
|
// using int32 creates signature "i"
|
||||||
|
// there are also xml files for the signature: src/xswiftbus/org.swift_project.xswiftbus.traffic.xml
|
||||||
|
// discussion: https://discordapp.com/channels/539048679160676382/539925070550794240/698552502831939676
|
||||||
|
|
||||||
|
DBusMessageIter arrayIterator;
|
||||||
|
dbus_message_iter_open_container(&m_messageIterator, DBUS_TYPE_ARRAY, DBUS_TYPE_BOOLEAN_AS_STRING, &arrayIterator);
|
||||||
|
|
||||||
|
const std::vector<unsigned> ints(array.begin(), array.end());
|
||||||
|
const unsigned *ptr = ints.data();
|
||||||
|
dbus_message_iter_append_fixed_array(&arrayIterator, DBUS_TYPE_BOOLEAN, &ptr, static_cast<int>(array.size()));
|
||||||
|
dbus_message_iter_close_container(&m_messageIterator, &arrayIterator);
|
||||||
|
}
|
||||||
|
|
||||||
void CDBusMessage::appendArgument(const std::vector<double> &array)
|
void CDBusMessage::appendArgument(const std::vector<double> &array)
|
||||||
{
|
{
|
||||||
DBusMessageIter arrayIterator;
|
DBusMessageIter arrayIterator;
|
||||||
|
|||||||
@@ -76,6 +76,7 @@ namespace XSwiftBus
|
|||||||
void appendArgument(const std::string &value);
|
void appendArgument(const std::string &value);
|
||||||
void appendArgument(int value);
|
void appendArgument(int value);
|
||||||
void appendArgument(double value);
|
void appendArgument(double value);
|
||||||
|
void appendArgument(const std::vector<bool> &array);
|
||||||
void appendArgument(const std::vector<double> &array);
|
void appendArgument(const std::vector<double> &array);
|
||||||
void appendArgument(const std::vector<std::string> &array);
|
void appendArgument(const std::vector<std::string> &array);
|
||||||
//! @}
|
//! @}
|
||||||
|
|||||||
@@ -498,6 +498,7 @@ namespace XSwiftBus
|
|||||||
longitudesDeg.clear();
|
longitudesDeg.clear();
|
||||||
elevationsM.clear();
|
elevationsM.clear();
|
||||||
verticalOffsets.clear();
|
verticalOffsets.clear();
|
||||||
|
waterFlags.clear();
|
||||||
|
|
||||||
for (const auto &requestedCallsign : requestedCallsigns)
|
for (const auto &requestedCallsign : requestedCallsigns)
|
||||||
{
|
{
|
||||||
@@ -800,7 +801,7 @@ namespace XSwiftBus
|
|||||||
std::vector<double> latitudesDeg;
|
std::vector<double> latitudesDeg;
|
||||||
std::vector<double> longitudesDeg;
|
std::vector<double> longitudesDeg;
|
||||||
std::vector<double> elevationsM;
|
std::vector<double> elevationsM;
|
||||||
std::vector<bool> waterFlags;
|
std::vector<bool> waterFlags;
|
||||||
std::vector<double> verticalOffsets;
|
std::vector<double> verticalOffsets;
|
||||||
getRemoteAircraftData(callsigns, latitudesDeg, longitudesDeg, elevationsM, waterFlags, verticalOffsets);
|
getRemoteAircraftData(callsigns, latitudesDeg, longitudesDeg, elevationsM, waterFlags, verticalOffsets);
|
||||||
CDBusMessage reply = CDBusMessage::createReply(sender, serial);
|
CDBusMessage reply = CDBusMessage::createReply(sender, serial);
|
||||||
@@ -809,6 +810,7 @@ namespace XSwiftBus
|
|||||||
reply.appendArgument(latitudesDeg);
|
reply.appendArgument(latitudesDeg);
|
||||||
reply.appendArgument(longitudesDeg);
|
reply.appendArgument(longitudesDeg);
|
||||||
reply.appendArgument(elevationsM);
|
reply.appendArgument(elevationsM);
|
||||||
|
reply.appendArgument(waterFlags);
|
||||||
reply.appendArgument(verticalOffsets);
|
reply.appendArgument(verticalOffsets);
|
||||||
sendDBusMessage(reply);
|
sendDBusMessage(reply);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user