Refactor updateCockpit from X-Plane

X-Plane returns com frequencies in 10 kHz, so we don't have the necessary
precision for the 25 kHz spacing. By using CComSystem::setFrequencyActive
we get the rounding to the system wide spacing for free.
Without that correction we run into system wide issues in code that assumes
the correct frequency spacing is in place.

ref T399
This commit is contained in:
Roland Winklmeier
2018-10-18 14:56:25 +02:00
committed by Klaus Basan
parent 1addcf631a
commit 92790f1330

View File

@@ -224,12 +224,29 @@ namespace BlackSimPlugin
// updates
updateOwnIcaoCodes(m_xplaneData.aircraftIcaoCode, CAirlineIcaoCode());
updateOwnSituation(situation);
updateCockpit(
CComSystem::getCom1System({ m_xplaneData.com1Active, CFrequencyUnit::kHz() }, { m_xplaneData.com1Standby, CFrequencyUnit::kHz() }),
CComSystem::getCom2System({ m_xplaneData.com2Active, CFrequencyUnit::kHz() }, { m_xplaneData.com2Standby, CFrequencyUnit::kHz() }),
CTransponder::getStandardTransponder(m_xplaneData.xpdrCode, xpdrMode(m_xplaneData.xpdrMode, m_xplaneData.xpdrIdent)),
identifier()
);
// defaults
CSimulatedAircraft myAircraft(getOwnAircraft());
CComSystem com1(myAircraft.getCom1System()); // set defaults
CComSystem com2(myAircraft.getCom2System());
CTransponder transponder(myAircraft.getTransponder());
// updates
com1.setFrequencyActive(CFrequency(m_xplaneData.com1Active, CFrequencyUnit::kHz()));
com1.setFrequencyStandby(CFrequency(m_xplaneData.com1Standby, CFrequencyUnit::kHz()));
const bool changedCom1 = myAircraft.getCom1System() != com1;
com2.setFrequencyActive(CFrequency(m_xplaneData.com2Active, CFrequencyUnit::kHz()));
com2.setFrequencyStandby(CFrequency(m_xplaneData.com2Standby, CFrequencyUnit::kHz()));
const bool changedCom2 = myAircraft.getCom2System() != com2;
transponder = CTransponder::getStandardTransponder(m_xplaneData.xpdrCode, xpdrMode(m_xplaneData.xpdrMode, m_xplaneData.xpdrIdent));
const bool changedXpr = (myAircraft.getTransponderCode() != transponder.getTransponderCode());
if (changedCom1 || changedCom2 || changedXpr)
{
this->updateCockpit(com1, com2, transponder, identifier());
}
if (m_isWeatherActivated)
{