diff --git a/.gitignore b/.gitignore index 1c3dbd18d..89049eb2f 100644 --- a/.gitignore +++ b/.gitignore @@ -50,3 +50,4 @@ cmake-build-*/ # Install folders /out/ /dist/ +CMakePresets.json diff --git a/src/plugins/simulator/fs9/simulatorfs9.cpp b/src/plugins/simulator/fs9/simulatorfs9.cpp index 0520ffba7..9cd344892 100644 --- a/src/plugins/simulator/fs9/simulatorfs9.cpp +++ b/src/plugins/simulator/fs9/simulatorfs9.cpp @@ -219,19 +219,13 @@ namespace BlackSimPlugin::Fs9 if (!this->isSimulating()) { return false; } // actually those data should be the same as ownAircraft - const CComSystem newCom1 = ownAircraft.getCom1System(); - const CComSystem newCom2 = ownAircraft.getCom2System(); const CTransponder newTransponder = ownAircraft.getTransponder(); bool changed = false; - if (newCom1.getFrequencyActive() != m_simCom1.getFrequencyActive()) { changed = true; } - if (newCom1.getFrequencyStandby() != m_simCom1.getFrequencyStandby()) { changed = true; } - if (newCom2.getFrequencyActive() != m_simCom2.getFrequencyActive()) { changed = true; } - if (newCom2.getFrequencyStandby() != m_simCom2.getFrequencyStandby()) { changed = true; } if (newTransponder.getTransponderCode() != m_simTransponder.getTransponderCode()) { changed = true; } if (newTransponder.getTransponderMode() != m_simTransponder.getTransponderMode()) { changed = true; } - m_fsuipc->write(ownAircraft); + m_fsuipc->write(newTransponder); // avoid changes of cockpit back to old values due to an outdated read back value if (changed) { m_skipCockpitUpdateCycles = SkipUpdateCyclesForCockpit; } @@ -416,25 +410,11 @@ namespace BlackSimPlugin::Fs9 // To avoid jitters, I wait some update cylces to stabilize the values if (m_skipCockpitUpdateCycles < 1) { - const auto dontOverwrite = [](const CFrequency &from, const CFrequency &to) { - // don't overwrite 8.33 kHz frequencies - return CComSystem::isExclusiveWithin8_33kHzChannel(from) && - from.valueInteger(CFrequencyUnit::kHz()) / 10 == to.valueInteger(CFrequencyUnit::kHz()) / 10; - }; - CComSystem com1 = simDataOwnAircraft.getCom1System(); - CComSystem com2 = simDataOwnAircraft.getCom2System(); + // we always use COM1 and COM2 from swift const CComSystem oldCom1 = getOwnComSystem(CComSystem::Com1); const CComSystem oldCom2 = getOwnComSystem(CComSystem::Com2); - if (dontOverwrite(oldCom1.getFrequencyActive(), com1.getFrequencyActive())) - com1.setFrequencyActive(oldCom1.getFrequencyActive()); - if (dontOverwrite(oldCom1.getFrequencyStandby(), com1.getFrequencyStandby())) - com1.setFrequencyStandby(oldCom1.getFrequencyStandby()); - if (dontOverwrite(oldCom2.getFrequencyActive(), com2.getFrequencyActive())) - com2.setFrequencyActive(oldCom2.getFrequencyActive()); - if (dontOverwrite(oldCom2.getFrequencyStandby(), com2.getFrequencyStandby())) - com2.setFrequencyStandby(oldCom2.getFrequencyStandby()); - this->updateCockpit(com1, com2, simDataOwnAircraft.getTransponder(), this->identifier()); + this->updateCockpit(oldCom1, oldCom2, simDataOwnAircraft.getTransponder(), this->identifier()); } else { diff --git a/src/plugins/simulator/fscommon/fsuipc.h b/src/plugins/simulator/fscommon/fsuipc.h index 0d00ffac8..cc045aec2 100644 --- a/src/plugins/simulator/fscommon/fsuipc.h +++ b/src/plugins/simulator/fscommon/fsuipc.h @@ -37,9 +37,6 @@ namespace BlackSimPlugin::FsCommon //! Really open, means connected and data can be sent bool isOpen() const; - //! Write aircraft - bool write(const BlackMisc::Simulation::CSimulatedAircraft &aircraft); - //! Write variables bool write(const BlackMisc::Aviation::CTransponder &xpdr); diff --git a/src/plugins/simulator/fscommon/fsuipcdummy.cpp b/src/plugins/simulator/fscommon/fsuipcdummy.cpp index a989dc58c..6dc237adf 100644 --- a/src/plugins/simulator/fscommon/fsuipcdummy.cpp +++ b/src/plugins/simulator/fscommon/fsuipcdummy.cpp @@ -43,12 +43,6 @@ namespace BlackSimPlugin return false; } - bool CFsuipc::write(const CSimulatedAircraft &aircraft) - { - Q_UNUSED(aircraft); - return false; - } - bool CFsuipc::write(const CTransponder &xpdr) { Q_UNUSED(xpdr); diff --git a/src/plugins/simulator/fscommon/fsuipcimpl.cpp b/src/plugins/simulator/fscommon/fsuipcimpl.cpp index 45121d832..ce73072d3 100644 --- a/src/plugins/simulator/fscommon/fsuipcimpl.cpp +++ b/src/plugins/simulator/fscommon/fsuipcimpl.cpp @@ -143,48 +143,21 @@ namespace BlackSimPlugin::FsCommon return false; } - bool CFsuipc::write(const CSimulatedAircraft &aircraft) - { - Q_ASSERT_X(CThreadUtils::isInThisThread(this), Q_FUNC_INFO, "Open not threadsafe"); - if (!this->isOpened()) { return false; } - - quint16 com1ActiveRaw = static_cast(aircraft.getCom1System().getFrequencyActive().value(CFrequencyUnit::MHz()) * 100); - quint16 com2ActiveRaw = static_cast(aircraft.getCom2System().getFrequencyActive().value(CFrequencyUnit::MHz()) * 100); - quint16 com1StandbyRaw = static_cast(aircraft.getCom1System().getFrequencyStandby().value(CFrequencyUnit::MHz()) * 100); - quint16 com2StandbyRaw = static_cast(aircraft.getCom2System().getFrequencyStandby().value(CFrequencyUnit::MHz()) * 100); - com1ActiveRaw = static_cast(CBcdConversions::dec2Bcd(com1ActiveRaw - 10000)); - com2ActiveRaw = static_cast(CBcdConversions::dec2Bcd(com2ActiveRaw - 10000)); - com1StandbyRaw = static_cast(CBcdConversions::dec2Bcd(com1StandbyRaw - 10000)); - com2StandbyRaw = static_cast(CBcdConversions::dec2Bcd(com2StandbyRaw - 10000)); - quint16 transponderCodeRaw = static_cast(aircraft.getTransponderCode()); - transponderCodeRaw = static_cast(CBcdConversions::dec2Bcd(transponderCodeRaw)); - - DWORD dwResult = 0; - bool ok = - FSUIPC_Write(0x034e, 2, &com1ActiveRaw, &dwResult) && - FSUIPC_Write(0x3118, 2, &com2ActiveRaw, &dwResult) && - FSUIPC_Write(0x311a, 2, &com1StandbyRaw, &dwResult) && - FSUIPC_Write(0x311c, 2, &com2StandbyRaw, &dwResult) && - FSUIPC_Write(0x0354, 2, &transponderCodeRaw, &dwResult); - if (ok) { FSUIPC_Process(&dwResult); } - - ok = ok && write(aircraft.getTransponder()); - - return ok && dwResult == 0; - } - bool CFsuipc::write(const CTransponder &xpdr) { Q_ASSERT_X(CThreadUtils::isInThisThread(this), Q_FUNC_INFO, "Open not threadsafe"); if (!this->isOpened()) { return false; } // should be the same as writing via SimConnect data area + quint16 transponderCodeRaw = static_cast(xpdr.getTransponderCode()); + transponderCodeRaw = static_cast(CBcdConversions::dec2Bcd(transponderCodeRaw)); DWORD dwResult; byte xpdrModeSb3Raw = xpdr.isInStandby() ? 1U : 0U; byte xpdrIdentSb3Raw = xpdr.isIdentifying() ? 1U : 0U; const bool ok = FSUIPC_Write(0x7b91, 1, &xpdrModeSb3Raw, &dwResult) && - FSUIPC_Write(0x7b93, 1, &xpdrIdentSb3Raw, &dwResult); + FSUIPC_Write(0x7b93, 1, &xpdrIdentSb3Raw, &dwResult) && + FSUIPC_Write(0x0354, 2, &transponderCodeRaw, &dwResult); if (ok) { FSUIPC_Process(&dwResult); } return ok && dwResult == 0; }