Fix sending the correct pressure altitude for a pilot position

* Before this commit, only the true altitude was known for an aircraft situation. The pressure altitude was not available anywhere yet.
* This caused a wrong altitude in radar clients.
* We fix this reading the pressure altitude from the simulators and set it in the own aircraft situation.
* MS Flight Simulators have the pressure altitude in the APIs available.
* For X-Plane and emulated simulator, we need to calculate it from the pressure at sea level.
* Finally, we use the new available pressure altitude to send it to the FSD server.

Maniphest Tasks: Ref T223
This commit is contained in:
Roland Winklmeier
2018-01-12 13:30:30 +01:00
committed by Klaus Basan
parent 51a90a9a71
commit de4fe44156
30 changed files with 298 additions and 43 deletions

View File

@@ -153,10 +153,15 @@ namespace BlackSimPlugin
m_service->getTransponderModeAsync(&m_xplaneData.xpdrMode);
m_service->getTransponderIdentAsync(&m_xplaneData.xpdrIdent);
m_service->getAllWheelsOnGroundAsync(&m_xplaneData.onGroundAll);
m_service->getQNHAsync(&m_xplaneData.seaLeveLPressure);
CAircraftSituation situation;
situation.setPosition({ m_xplaneData.latitude, m_xplaneData.longitude, 0 });
CAltitude altitude { m_xplaneData.altitude, CAltitude::MeanSeaLevel, CLengthUnit::m() };
situation.setAltitude({ m_xplaneData.altitude, CAltitude::MeanSeaLevel, CLengthUnit::m() });
CPressure seaLevelPressure({ m_xplaneData.seaLeveLPressure, CPressureUnit::inHg() });
CAltitude pressureAltitude(altitude.toPressureAltitude(seaLevelPressure));
situation.setPressureAltitude(pressureAltitude);
situation.setHeading({ m_xplaneData.trueHeading, CHeading::True, CAngleUnit::deg() });
situation.setPitch({ m_xplaneData.pitch, CAngleUnit::deg() });
situation.setBank({ m_xplaneData.roll, CAngleUnit::deg() });

View File

@@ -182,12 +182,13 @@ namespace BlackSimPlugin
double gearReployRatio;
QList<double> enginesN1Percentage;
double speedBrakeRatio;
double seaLeveLPressure;
} m_xplaneData;
void resetData()
{
m_xplaneData = { "", "", 0, 0, 0, 0, 0, 0, 0, false, 122800, 122800, 122800, 122800, 2000, 0, false, false, false, false,
false, false, 0, 0, {}, false
false, false, 0, 0, {}, 0.0, 0.0
};
}

View File

@@ -376,6 +376,17 @@ namespace BlackSimPlugin
}
double CXSwiftBusServiceProxy::getQNH() const
{
return m_dbusInterface->callDBusRet<double>(QLatin1String("getQNH"));
}
void CXSwiftBusServiceProxy::getQNHAsync(double *o_qnh)
{
m_dbusInterface->callDBusAsync(QLatin1String("getQNH"), setterCallback(o_qnh));
}
void CXSwiftBusServiceProxy::setCom1Active(int freq)
{
m_dbusInterface->callDBus(QLatin1String("setCom1Active"), freq);

View File

@@ -319,12 +319,17 @@ namespace BlackSimPlugin
//! @}
//! \copydoc XSwiftBus::CService::getTaxiLightsOn
//! @{
bool getTaxiLightsOn() const;
void getTaxiLightsOnAsync(bool *o_taxiLightsOn);
//! @}
//! \copydoc XSwiftBus::CService::getQNH
//! @{
double getQNH() const;
void getQNHAsync(double *o_qnh);
//! @}
//! \copydoc XSwiftBus::CService::setCom1Active
void setCom1Active(int freq);