mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-27 19:25:49 +08:00
Regularly request remote aircraft data from X-Plane
This includes * ground elevation * model offset (to be implemented) ref T259
This commit is contained in:
committed by
Klaus Basan
parent
2ab6a96d57
commit
72497fdefc
@@ -223,6 +223,8 @@ namespace BlackSimPlugin
|
|||||||
m_xplaneData.speedBrakeRatio > 0.5, engines, m_xplaneData.onGroundAll
|
m_xplaneData.speedBrakeRatio > 0.5, engines, m_xplaneData.onGroundAll
|
||||||
};
|
};
|
||||||
updateOwnParts(parts);
|
updateOwnParts(parts);
|
||||||
|
|
||||||
|
requestRemoteAircraftDataFromXPlane();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -247,6 +249,7 @@ namespace BlackSimPlugin
|
|||||||
connect(m_service, &CXSwiftBusServiceProxy::airportsInRangeUpdated, this, &CSimulatorXPlane::ps_setAirportsInRange);
|
connect(m_service, &CXSwiftBusServiceProxy::airportsInRangeUpdated, this, &CSimulatorXPlane::ps_setAirportsInRange);
|
||||||
m_service->updateAirportsInRange();
|
m_service->updateAirportsInRange();
|
||||||
connect(m_traffic, &CXSwiftBusTrafficProxy::simFrame, this, &CSimulatorXPlane::updateRemoteAircraft);
|
connect(m_traffic, &CXSwiftBusTrafficProxy::simFrame, this, &CSimulatorXPlane::updateRemoteAircraft);
|
||||||
|
connect(m_traffic, &CXSwiftBusTrafficProxy::remoteAircraftData, this, &CSimulatorXPlane::updateRemoteAircraftFromSimulator);
|
||||||
if (m_watcher) { m_watcher->setConnection(m_conn); }
|
if (m_watcher) { m_watcher->setConnection(m_conn); }
|
||||||
loadCslPackages();
|
loadCslPackages();
|
||||||
emitSimulatorCombinedStatus();
|
emitSimulatorCombinedStatus();
|
||||||
@@ -1005,6 +1008,28 @@ namespace BlackSimPlugin
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSimulatorXPlane::requestRemoteAircraftDataFromXPlane()
|
||||||
|
{
|
||||||
|
if (!isConnected()) { return; }
|
||||||
|
m_traffic->requestRemoteAircraftData();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSimulatorXPlane::updateRemoteAircraftFromSimulator(const QString &callsign_, double latitude, double longitude, double groundElevation, double modelVerticalOffset)
|
||||||
|
{
|
||||||
|
CCallsign callsign(callsign_);
|
||||||
|
if (!m_xplaneAircrafts.contains(callsign)) { return; }
|
||||||
|
|
||||||
|
CElevationPlane elevation(CLatitude(latitude, CAngleUnit::deg()), CLongitude(longitude, CAngleUnit::deg()), CAltitude(groundElevation, CLengthUnit::m()));
|
||||||
|
elevation.setSinglePointRadius();
|
||||||
|
|
||||||
|
CInterpolationHints &hints = m_hints[callsign];
|
||||||
|
hints.setElevationPlane(elevation); // update elevation
|
||||||
|
hints.setCGAboveGround({ modelVerticalOffset, CLengthUnit::ft() }); // normally never changing, but if user changes ModelMatching update possible
|
||||||
|
|
||||||
|
// set it in the remote aircraft provider
|
||||||
|
this->updateAircraftGroundElevation(callsign, elevation);
|
||||||
|
}
|
||||||
|
|
||||||
BlackCore::ISimulator *CSimulatorXPlaneFactory::create(const CSimulatorPluginInfo &info,
|
BlackCore::ISimulator *CSimulatorXPlaneFactory::create(const CSimulatorPluginInfo &info,
|
||||||
IOwnAircraftProvider *ownAircraftProvider,
|
IOwnAircraftProvider *ownAircraftProvider,
|
||||||
IRemoteAircraftProvider *remoteAircraftProvider,
|
IRemoteAircraftProvider *remoteAircraftProvider,
|
||||||
|
|||||||
@@ -159,6 +159,9 @@ namespace BlackSimPlugin
|
|||||||
//! Send parts to simulator
|
//! Send parts to simulator
|
||||||
bool sendRemoteAircraftPartsToSimulator(const CXPlaneMPAircraft &xplaneAircraft, const BlackMisc::Aviation::CAircraftParts &parts);
|
bool sendRemoteAircraftPartsToSimulator(const CXPlaneMPAircraft &xplaneAircraft, const BlackMisc::Aviation::CAircraftParts &parts);
|
||||||
|
|
||||||
|
void requestRemoteAircraftDataFromXPlane();
|
||||||
|
void updateRemoteAircraftFromSimulator(const QString &callsign, double latitude, double longitude, double elevation, double modelVerticalOffset);
|
||||||
|
|
||||||
static constexpr bool c_driverInterpolation = true;
|
static constexpr bool c_driverInterpolation = true;
|
||||||
static constexpr int GuessRemoteAircraftPartsCycle = 20; //!< guess every n-th cycle
|
static constexpr int GuessRemoteAircraftPartsCycle = 20; //!< guess every n-th cycle
|
||||||
|
|
||||||
|
|||||||
@@ -115,5 +115,10 @@ namespace BlackSimPlugin
|
|||||||
m_dbusInterface->callDBus(QLatin1String("setInterpolatorMode"), callsign, spline);
|
m_dbusInterface->callDBus(QLatin1String("setInterpolatorMode"), callsign, spline);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CXSwiftBusTrafficProxy::requestRemoteAircraftData()
|
||||||
|
{
|
||||||
|
m_dbusInterface->callDBus(QLatin1String("requestRemoteAircraftData"));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,6 +65,9 @@ namespace BlackSimPlugin
|
|||||||
//! \copydoc XSwiftBus::CTraffic::simFrame
|
//! \copydoc XSwiftBus::CTraffic::simFrame
|
||||||
void simFrame();
|
void simFrame();
|
||||||
|
|
||||||
|
//! \copydoc XSwiftBus::CTraffic::remoteAircraftData
|
||||||
|
void remoteAircraftData(const QString &callsign, double latitude, double longitude, double elevation, double modelVerticalOffset);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
//! \copydoc XSwiftBus::CTraffic::initialize
|
//! \copydoc XSwiftBus::CTraffic::initialize
|
||||||
bool initialize();
|
bool initialize();
|
||||||
@@ -118,6 +121,9 @@ namespace BlackSimPlugin
|
|||||||
|
|
||||||
//! \copydoc XSwiftBus::CTraffic::setInterpolatorMode
|
//! \copydoc XSwiftBus::CTraffic::setInterpolatorMode
|
||||||
void setInterpolatorMode(const QString &callsign, bool spline);
|
void setInterpolatorMode(const QString &callsign, bool spline);
|
||||||
|
|
||||||
|
//! \copydoc XSwiftBus::CTraffic::requestRemoteAircraftData
|
||||||
|
void requestRemoteAircraftData();
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -380,6 +380,22 @@ namespace XSwiftBus
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CTraffic::requestRemoteAircraftData()
|
||||||
|
{
|
||||||
|
if (m_planesByCallsign.empty()) { return; }
|
||||||
|
const QList<Plane *> planes = m_planesByCallsign.values();
|
||||||
|
for (const Plane *plane : planes)
|
||||||
|
{
|
||||||
|
double lat = plane->position.lat;
|
||||||
|
double lon = plane->position.lon;
|
||||||
|
double elevation = plane->position.elevation;
|
||||||
|
double groundElevation = plane->terrainProbe.getElevation(lat, lon, elevation);
|
||||||
|
if (std::isnan(groundElevation)) { groundElevation = 0.0; }
|
||||||
|
constexpr double fudgeFactor = 3.0; //! \fixme Value should be different for each plane, derived from the CSL model geometry
|
||||||
|
emit remoteAircraftData(plane->callsign, lat, lon, groundElevation, fudgeFactor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//! memcmp function which ignores the header ("size" member) and compares only the payload (the rest of the struct)
|
//! memcmp function which ignores the header ("size" member) and compares only the payload (the rest of the struct)
|
||||||
template <typename T>
|
template <typename T>
|
||||||
int memcmpPayload(T *dst, T *src)
|
int memcmpPayload(T *dst, T *src)
|
||||||
|
|||||||
@@ -70,6 +70,9 @@ namespace XSwiftBus
|
|||||||
//! Signal emitted for each simulator rendering frame
|
//! Signal emitted for each simulator rendering frame
|
||||||
void simFrame();
|
void simFrame();
|
||||||
|
|
||||||
|
//! Remote aircraft data
|
||||||
|
void remoteAircraftData(const QString &callsign, double latitude, double longitude, double elevation, double modelVerticalOffset);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
//! Initialize the multiplayer planes rendering and return true if successful
|
//! Initialize the multiplayer planes rendering and return true if successful
|
||||||
bool initialize();
|
bool initialize();
|
||||||
@@ -124,6 +127,9 @@ namespace XSwiftBus
|
|||||||
//! Set interpolation mode for a traffic aircraft
|
//! Set interpolation mode for a traffic aircraft
|
||||||
void setInterpolatorMode(const QString &callsign, bool spline);
|
void setInterpolatorMode(const QString &callsign, bool spline);
|
||||||
|
|
||||||
|
//! Request traffic plane data. A signal remoteAircraftData will be emitted for each known plane
|
||||||
|
void requestRemoteAircraftData();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_initialized = false;
|
bool m_initialized = false;
|
||||||
bool m_enabled = false;
|
bool m_enabled = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user