diff --git a/src/plugins/simulator/fs9/simulatorfs9.cpp b/src/plugins/simulator/fs9/simulatorfs9.cpp index 94b4b4366..49f57b181 100644 --- a/src/plugins/simulator/fs9/simulatorfs9.cpp +++ b/src/plugins/simulator/fs9/simulatorfs9.cpp @@ -45,7 +45,8 @@ namespace BlackSimPlugin::Fs9 IClientProvider *clientProvider, QObject *parent) : CSimulatorFsCommon(info, ownAircraftProvider, remoteAircraftProvider, weatherGridProvider, clientProvider, parent), m_fs9Host(fs9Host), - m_lobbyClient(lobbyClient) + m_lobbyClient(lobbyClient), + m_fsuipc(new CFsuipc(this)) { // disabled CG/elevation parts this->setSimulationProviderEnabled(false, false); @@ -73,7 +74,8 @@ namespace BlackSimPlugin::Fs9 Q_ASSERT_X(m_fsuipc, Q_FUNC_INFO, "No FSUIPC"); m_connectionHostMessages = connect(m_fs9Host.data(), &CFs9Host::customPacketReceived, this, &CSimulatorFs9::processFs9Message); - useFsuipc(true); + m_fsuipc->open(); + this->initSimulatorInternals(); m_timerId = startTimer(50); return true; @@ -88,7 +90,9 @@ namespace BlackSimPlugin::Fs9 safeKillTimer(); disconnectAllClients(); - // disconnect FSUIPC and status + if (m_fsuipc) { m_fsuipc->close(); } + + // emit status CSimulatorFsCommon::disconnectFrom(); m_simConnected = false; emitSimulatorCombinedStatus(); @@ -246,7 +250,7 @@ namespace BlackSimPlugin::Fs9 void CSimulatorFs9::dispatch() { - if (m_useFsuipc && m_fsuipc && m_fsuipc->isOpened()) + if (m_fsuipc && m_fsuipc->isOpened()) { CSimulatedAircraft fsuipcAircraft(getOwnAircraft()); const bool ok = m_fsuipc->read(fsuipcAircraft, true, true, true); @@ -410,7 +414,7 @@ namespace BlackSimPlugin::Fs9 { if (!m_simTimeSynced) { return; } if (!this->isConnected()) { return; } - if (!m_useFsuipc || !m_fsuipc) { return; } + if (!m_fsuipc) { return; } if (!m_fsuipc->isOpened()) { return; } QDateTime myDateTime = QDateTime::currentDateTimeUtc(); @@ -442,7 +446,7 @@ namespace BlackSimPlugin::Fs9 return; } - if (!m_useFsuipc || !m_fsuipc) { return; } + if (!m_fsuipc) { return; } if (!m_fsuipc->isOpened()) { return; } if (weatherGrid.isEmpty()) { diff --git a/src/plugins/simulator/fs9/simulatorfs9.h b/src/plugins/simulator/fs9/simulatorfs9.h index c23fdee3a..be29abd25 100644 --- a/src/plugins/simulator/fs9/simulatorfs9.h +++ b/src/plugins/simulator/fs9/simulatorfs9.h @@ -16,6 +16,7 @@ #include "blackmisc/simulation/simulatedaircraft.h" #include "blackmisc/simulation/simulatorplugininfo.h" #include "blackmisc/pixmap.h" +#include "plugins/simulator/fscommon/fsuipc.h" #include #include #include @@ -96,6 +97,7 @@ namespace BlackSimPlugin::Fs9 //! Sync time with user's computer void synchronizeTime(); + BlackSimPlugin::FsCommon::CFsuipc *m_fsuipc = nullptr; //!< FSUIPC QHash> m_hashFs9Clients; QMetaObject::Connection m_connectionHostMessages; bool m_simConnected = false; //!< Is simulator connected? diff --git a/src/plugins/simulator/fscommon/simulatorfscommon.cpp b/src/plugins/simulator/fscommon/simulatorfscommon.cpp index 4f5ff3228..d693a88a3 100644 --- a/src/plugins/simulator/fscommon/simulatorfscommon.cpp +++ b/src/plugins/simulator/fscommon/simulatorfscommon.cpp @@ -26,8 +26,7 @@ namespace BlackSimPlugin::FsCommon IRemoteAircraftProvider *renderedAircraftProvider, IWeatherGridProvider *weatherGridProvider, IClientProvider *clientProvider, - QObject *parent) : CSimulatorPluginCommon(info, ownAircraftProvider, renderedAircraftProvider, weatherGridProvider, clientProvider, parent), - m_fsuipc(new CFsuipc(this)) + QObject *parent) : CSimulatorPluginCommon(info, ownAircraftProvider, renderedAircraftProvider, weatherGridProvider, clientProvider, parent) { CSimulatorFsCommon::registerHelp(); } @@ -38,26 +37,6 @@ namespace BlackSimPlugin::FsCommon { CSimulatorPluginCommon::initSimulatorInternals(); m_simulatorInternals.setSimulatorVersion(this->getSimulatorVersion()); - m_simulatorInternals.setValue("fscommon/fsuipc", boolToOnOff(m_useFsuipc)); - if (m_fsuipc) - { - const QString v(m_fsuipc->getVersion()); - if (!v.isEmpty()) { m_simulatorInternals.setValue("fscommon/fsuipcversion", v); } - m_simulatorInternals.setValue("fscommon/fsuipcopen", boolToYesNo(m_fsuipc->isOpened())); - } - } - - bool CSimulatorFsCommon::parseDetails(const CSimpleCommandParser &parser) - { - // .driver fsuipc on|off - if (parser.matchesPart(1, "fsuipc") && parser.hasPart(2)) - { - const bool on = parser.toBool(2); - const bool s = this->useFsuipc(on); - CLogMessage(this, CLogCategories::cmdLine()).info(u"FSUIPC is '%1'") << boolToOnOff(s); - return s; - } - return CSimulatorPluginCommon::parseDetails(parser); } void CSimulatorFsCommon::reset() @@ -72,13 +51,10 @@ namespace BlackSimPlugin::FsCommon { if (CSimpleCommandParser::registered("BlackSimPlugin::FsCommon::CSimulatorFsCommon")) { return; } CSimpleCommandParser::registerCommand({ ".drv", "alias: .driver .plugin" }); - CSimpleCommandParser::registerCommand({ ".drv fsuipc on|off", "FSUIPC on|off if applicable" }); } bool CSimulatorFsCommon::disconnectFrom() { - if (m_fsuipc) { m_fsuipc->close(); } - // reset flags m_simPaused = false; const bool r = CSimulatorPluginCommon::disconnectFrom(); @@ -86,29 +62,6 @@ namespace BlackSimPlugin::FsCommon return r; } - bool CSimulatorFsCommon::isFsuipcOpened() const - { - return m_fsuipc && m_fsuipc->isOpened(); - } - - bool CSimulatorFsCommon::useFsuipc(bool on) - { - if (!m_fsuipc) { return false; } // no FSUIPC available - if (m_useFsuipc == on) { return m_useFsuipc; } // nothing changed - m_useFsuipc = on; - if (on) - { - m_useFsuipc = m_fsuipc->open(); - } - else - { - m_fsuipc->close(); - } - - this->initSimulatorInternals(); // update internals - return m_useFsuipc; - } - CTime CSimulatorFsCommon::getTimeSynchronizationOffset() const { return m_syncTimeOffset; diff --git a/src/plugins/simulator/fscommon/simulatorfscommon.h b/src/plugins/simulator/fscommon/simulatorfscommon.h index 17bbaf342..311d6cfb1 100644 --- a/src/plugins/simulator/fscommon/simulatorfscommon.h +++ b/src/plugins/simulator/fscommon/simulatorfscommon.h @@ -6,7 +6,6 @@ #ifndef BLACKSIMPLUGIN_FSCOMMON_SIMULATORFSCOMMON_H #define BLACKSIMPLUGIN_FSCOMMON_SIMULATORFSCOMMON_H -#include "plugins/simulator/fscommon/fsuipc.h" #include "plugins/simulator/plugincommon/simulatorplugincommon.h" #include "blackmisc/simulation/interpolator.h" #include "blackmisc/simulation/fscommon/aircraftcfgparser.h" @@ -29,12 +28,6 @@ namespace BlackSimPlugin::FsCommon //! Destructor virtual ~CSimulatorFsCommon() override; - //! FSUIPC connected? - bool isFsuipcOpened() const; - - //! FSUIPC on/off, correctly disconnecting/connecting - bool useFsuipc(bool on); - // ---------------------- ISimulator ------------------ virtual bool disconnectFrom() override; virtual bool isPaused() const override { return m_simPaused; } @@ -59,22 +52,14 @@ namespace BlackSimPlugin::FsCommon //! When swift DB data are read virtual void onSwiftDbAirportsRead() override; - //! \ingroup swiftdotcommands - //!
-        //! .drv fsuipc  on|off      FSUIPC on/off
-        //! 
- virtual bool parseDetails(const BlackMisc::CSimpleCommandParser &parser) override; - //! \copydoc BlackCore::ISimulator::reset virtual void reset() override; //! Register help static void registerHelp(); - CFsuipc *m_fsuipc = nullptr; //!< FSUIPC int m_ownAircraftUpdateCycles = 0; //!< own aircraft updates, even with 50 updates/sec long enough even for 32bit int m_skipCockpitUpdateCycles = 0; //!< skip some update cycles to allow changes in simulator cockpit to be set - bool m_useFsuipc = false; //!< use FSUIPC bool m_simPaused = false; //!< simulator paused? bool m_simTimeSynced = false; //!< time synchronized? BlackMisc::PhysicalQuantities::CTime m_syncTimeOffset; //!< time offset diff --git a/src/plugins/simulator/fsxcommon/fsxsettingscomponent.cpp b/src/plugins/simulator/fsxcommon/fsxsettingscomponent.cpp index a8977ab1b..72d77e39a 100644 --- a/src/plugins/simulator/fsxcommon/fsxsettingscomponent.cpp +++ b/src/plugins/simulator/fsxcommon/fsxsettingscomponent.cpp @@ -30,7 +30,6 @@ namespace BlackSimPlugin::FsxCommon connect(ui->cb_AddingAsSimulatedObject, &QCheckBox::released, this, &CFsxSettingsComponent::onSimulatedObjectChanged); connect(ui->cb_TraceSimConnectCalls, &QCheckBox::released, this, &CFsxSettingsComponent::onSimConnectTraceChanged); connect(ui->cb_EnableTerrainProbe, &QCheckBox::released, this, &CFsxSettingsComponent::onEnableTerrainProbeChanged); - connect(ui->cb_UseFsuipc, &QCheckBox::released, this, &CFsxSettingsComponent::onFsuipcChanged); connect(ui->cb_SBOffsets, &QCheckBox::released, this, &CFsxSettingsComponent::onSBOffsetsChanged); connect(ui->pb_CopyTerrainProbe, &QPushButton::released, this, &CFsxSettingsComponent::copyTerrainProbe); connect(ui->pb_Refresh, &QPushButton::released, this, &CFsxSettingsComponent::refresh); @@ -66,7 +65,6 @@ namespace BlackSimPlugin::FsxCommon ui->cb_TraceSimConnectCalls->setChecked(fsxOrP3D->isTraceSendId()); ui->cb_EnableTerrainProbe->setChecked(fsxOrP3D->isUsingFsxTerrainProbe()); ui->cb_SBOffsets->setChecked(fsxOrP3D->isUsingSbOffsetValues()); - ui->cb_UseFsuipc->setChecked(fsxOrP3D->isFsuipcOpened()); ui->cb_AddingAsSimulatedObject->setChecked(fsxOrP3D->isAddingAsSimulatedObjectEnabled()); } @@ -74,7 +72,6 @@ namespace BlackSimPlugin::FsxCommon ui->cb_TraceSimConnectCalls->setEnabled(localSim); ui->cb_EnableTerrainProbe->setEnabled(localSim); ui->cb_SBOffsets->setEnabled(localSim); - ui->cb_UseFsuipc->setEnabled(localSim); const bool terrainProbe = CBuildConfig::isRunningOnWindowsNtPlatform() && (CBuildConfig::buildWordSize() == 32); ui->cb_EnableTerrainProbe->setEnabled(terrainProbe); @@ -102,13 +99,6 @@ namespace BlackSimPlugin::FsxCommon fsxOrP3D->setUsingFsxTerrainProbe(ui->cb_EnableTerrainProbe->isChecked()); } - void CFsxSettingsComponent::onFsuipcChanged() - { - CSimulatorFsxCommon *fsxOrP3D = this->getFsxOrP3DSimulator(); - if (!fsxOrP3D) { return; } - fsxOrP3D->useFsuipc(ui->cb_UseFsuipc->isChecked()); - } - void CFsxSettingsComponent::onSBOffsetsChanged() { CSimulatorFsxCommon *fsxOrP3D = this->getFsxOrP3DSimulator(); diff --git a/src/plugins/simulator/fsxcommon/fsxsettingscomponent.h b/src/plugins/simulator/fsxcommon/fsxsettingscomponent.h index cc94e11c7..67ef74b45 100644 --- a/src/plugins/simulator/fsxcommon/fsxsettingscomponent.h +++ b/src/plugins/simulator/fsxcommon/fsxsettingscomponent.h @@ -55,9 +55,6 @@ namespace BlackSimPlugin::FsxCommon //! Using simulated objects void onSimulatedObjectChanged(); - //! FSUIPC setting changed - void onFsuipcChanged(); - //! Offsets on/off void onSBOffsetsChanged(); diff --git a/src/plugins/simulator/fsxcommon/fsxsettingscomponent.ui b/src/plugins/simulator/fsxcommon/fsxsettingscomponent.ui index 2a93e20a4..79e8ab9c0 100644 --- a/src/plugins/simulator/fsxcommon/fsxsettingscomponent.ui +++ b/src/plugins/simulator/fsxcommon/fsxsettingscomponent.ui @@ -51,13 +51,6 @@ - - - - - - - @@ -105,13 +98,6 @@ - - - - Enable FSUIPC support - - - @@ -140,7 +126,6 @@ cb_TraceSimConnectCalls - cb_UseFsuipc cb_SBOffsets cb_AddingAsSimulatedObject cb_EnableTerrainProbe diff --git a/src/plugins/simulator/fsxcommon/simulatorfsxcommon.cpp b/src/plugins/simulator/fsxcommon/simulatorfsxcommon.cpp index 66be92fb1..f7215cd37 100644 --- a/src/plugins/simulator/fsxcommon/simulatorfsxcommon.cpp +++ b/src/plugins/simulator/fsxcommon/simulatorfsxcommon.cpp @@ -59,7 +59,6 @@ namespace BlackSimPlugin::FsxCommon Q_ASSERT_X(sApp, Q_FUNC_INFO, "Missing global object"); m_simObjectTimer.setInterval(AddPendingAircraftIntervalMs); - m_useFsuipc = false; // default model will be set in derived class CSimulatorFsxCommon::registerHelp(); @@ -69,7 +68,6 @@ namespace BlackSimPlugin::FsxCommon CSimulatorFsxCommon::~CSimulatorFsxCommon() { this->disconnectFrom(); - // fsuipc is disconnected in CSimulatorFsCommon } bool CSimulatorFsxCommon::isConnected() const @@ -95,12 +93,6 @@ namespace BlackSimPlugin::FsxCommon return false; } - // FSUIPC too - if (m_useFsuipc) - { - m_fsuipc->open(); - } - // set structures and move on this->triggerAutoTraceSendId(); // we trace the init phase, so in case something goes wrong there this->initEvents(); @@ -127,7 +119,7 @@ namespace BlackSimPlugin::FsxCommon m_simConnected = false; } - // emit status and disconnect FSUIPC + // emit status return CSimulatorFsCommon::disconnectFrom(); } @@ -181,7 +173,6 @@ namespace BlackSimPlugin::FsxCommon if (newTransponder.getTransponderMode() != m_simTransponder.getTransponderMode()) { - // use one way to transfer XPDR ident/mode not both if (m_useSbOffsets) { byte ident = newTransponder.isIdentifying() ? 1U : 0U; // 1 is ident @@ -205,11 +196,6 @@ namespace BlackSimPlugin::FsxCommon } changed = true; } - else if (m_useFsuipc && m_fsuipc) - { - m_fsuipc->write(newTransponder); - changed = true; - } } // avoid changes of cockpit back to old values due to an outdated read back value @@ -959,18 +945,6 @@ namespace BlackSimPlugin::FsxCommon this->updateCockpit(myAircraft.getCom1System(), myAircraft.getCom2System(), xpdr, this->identifier()); } - void CSimulatorFsxCommon::updateOwnAircraftFromSimulatorFsuipc(const CTransponder &xpdr) - { - if (!m_useFsuipc) { return; } - if (m_skipCockpitUpdateCycles > 0) { return; } - const CSimulatedAircraft myAircraft(this->getOwnAircraft()); - const bool changed = (myAircraft.getTransponderMode() != xpdr.getTransponderMode()); - if (!changed) { return; } - CTransponder myXpdr = myAircraft.getTransponder(); - myXpdr.setTransponderMode(xpdr.getTransponderMode()); - this->updateCockpit(myAircraft.getCom1System(), myAircraft.getCom2System(), myXpdr, this->identifier()); - } - bool CSimulatorFsxCommon::simulatorReportedObjectAdded(DWORD objectId) { if (this->isShuttingDownOrDisconnected()) { return true; } // pretend everything is fine @@ -1518,26 +1492,6 @@ namespace BlackSimPlugin::FsxCommon return; } m_dispatchErrors = 0; - if (m_useFsuipc && m_fsuipc) - { - if (m_dispatchProcCount % 10 == 0) - { - // slow updates, here only when SB/SimConnect is disabled as those do the same thing - if (!m_useSbOffsets) - { - CSimulatedAircraft fsuipcAircraft(this->getOwnAircraft()); - const bool ok = m_fsuipc->read(fsuipcAircraft, true, false, false); - if (ok) - { - this->updateOwnAircraftFromSimulatorFsuipc(fsuipcAircraft.getTransponder()); - } - } - } - else - { - // fast - } - } } bool CSimulatorFsxCommon::physicallyAddRemoteAircraftImpl(const CSimulatedAircraft &newRemoteAircraft, CSimulatorFsxCommon::AircraftAddMode addMode, const CSimConnectObject &correspondingSimObject) diff --git a/src/plugins/simulator/fsxcommon/simulatorfsxcommon.h b/src/plugins/simulator/fsxcommon/simulatorfsxcommon.h index bda888e54..2ff2c5cbe 100644 --- a/src/plugins/simulator/fsxcommon/simulatorfsxcommon.h +++ b/src/plugins/simulator/fsxcommon/simulatorfsxcommon.h @@ -480,10 +480,6 @@ namespace BlackSimPlugin::FsxCommon //! \threadsafe void updateOwnAircraftFromSimulator(const DataDefinitionClientAreaSb &sbDataArea); - //! Update from FSUIPC - //! \threadsafe - void updateOwnAircraftFromSimulatorFsuipc(const BlackMisc::Aviation::CTransponder &xpdr); - //! An AI aircraft was added in the simulator bool simulatorReportedObjectAdded(DWORD objectId);