Implement followAircraft for X-Plane

ref T266
This commit is contained in:
Roland Winklmeier
2018-05-15 09:28:06 +02:00
committed by Klaus Basan
parent 794137fc94
commit 33963041cc
7 changed files with 41 additions and 0 deletions

View File

@@ -599,6 +599,13 @@ namespace BlackSimPlugin
return true;
}
bool CSimulatorXPlane::followAircraft(const CCallsign &callsign)
{
if (! m_trafficProxy || ! m_trafficProxy->isValid()) { return false; }
m_trafficProxy->setFollowedAircraft(callsign.toQString());
return true;
}
void CSimulatorXPlane::injectWeatherGrid(const Weather::CWeatherGrid &weatherGrid)
{
Q_ASSERT(isConnected());

View File

@@ -133,6 +133,7 @@ namespace BlackSimPlugin
virtual BlackMisc::PhysicalQuantities::CTime getTimeSynchronizationOffset() const override { return BlackMisc::PhysicalQuantities::CTime(0, BlackMisc::PhysicalQuantities::CTimeUnit::hrmin()); }
virtual bool isPhysicallyRenderedAircraft(const BlackMisc::Aviation::CCallsign &callsign) const override;
virtual BlackMisc::Aviation::CCallsignSet physicallyRenderedAircraft() const override;
virtual bool followAircraft(const BlackMisc::Aviation::CCallsign &callsign) override;
virtual void unload() override;
//! @}

View File

@@ -148,5 +148,10 @@ namespace BlackSimPlugin
};
m_dbusInterface->callDBusAsync(QLatin1String("getEelevationAtPosition"), callback, callsign.asString(), latitude, longitude, altitude);
}
void CXSwiftBusTrafficProxy::setFollowedAircraft(const QString &callsign)
{
m_dbusInterface->callDBus(QLatin1String("setFollowedAircraft"), callsign);
}
}
}

View File

@@ -136,6 +136,9 @@ namespace BlackSimPlugin
void getEelevationAtPosition(const BlackMisc::Aviation::CCallsign &callsign, double latitude, double longitude, double altitude,
const ElevationCallback &setter);
//! \copydoc XSwiftBus::CTraffic::setFollowedAircraft
void setFollowedAircraft(const QString &callsign);
private:
BlackMisc::CGenericDBusInterface *m_dbusInterface = nullptr;
};

View File

@@ -78,5 +78,8 @@ R"(<node>
<arg type="s" direction="out"/>
<arg type="d" direction="out"/>
</method>
<method name="setFollowedAircraft">
<arg name="callsign" type="s" direction="in"/>
</method>
</interface>
</node>)"

View File

@@ -393,6 +393,14 @@ namespace XSwiftBus
}
}
void CTraffic::setFollowedAircraft(const std::string &callsign)
{
auto planeIt = m_planesByCallsign.find(callsign);
if (planeIt == m_planesByCallsign.end()) { return; }
orbitRemotePlane(callsign);
}
const char *introspection_traffic =
DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE
#include "org.swift_project.xswiftbus.traffic.xml"
@@ -655,6 +663,17 @@ namespace XSwiftBus
; sendDBusMessage(reply);
});
}
else if (message.getMethodName() == "setFollowedAircraft")
{
maybeSendEmptyDBusReply(wantsReply, sender, serial);
std::string callsign;
message.beginArgumentRead();
message.getArgument(callsign);
queueDBusCall([ = ]()
{
setFollowedAircraft(callsign);
});
}
else
{
// Unknown message. Tell DBus that we cannot handle it

View File

@@ -114,6 +114,9 @@ namespace XSwiftBus
//! Get the ground elevation at an arbitrary position
double getEelevationAtPosition(const std::string &callsign, double latitude, double longitude, double altitude);
//! Sets the aircraft with callsign to be followed in plane view
void setFollowedAircraft(const std::string &callsign);
int processDBus() override;
protected: