mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-30 11:55:35 +08:00
Ref T709, send XSwiftBusSettings when driver is connected
* send from swift -> XPlane side * also send if settings on swift side are updated
This commit is contained in:
committed by
Mat Sutcliffe
parent
d1db1943ae
commit
cbd93da1c6
@@ -380,10 +380,17 @@ namespace BlackSimPlugin
|
||||
connect(m_trafficProxy, &CXSwiftBusTrafficProxy::remoteAircraftAddingFailed, this, &CSimulatorXPlane::onRemoteAircraftAddingFailed);
|
||||
if (m_watcher) { m_watcher->setConnection(m_dBusConnection); }
|
||||
m_trafficProxy->removeAllPlanes();
|
||||
|
||||
// send the settings
|
||||
this->sendXSwiftBusSettings();
|
||||
|
||||
// load CSL
|
||||
this->loadCslPackages();
|
||||
|
||||
// finish
|
||||
this->initSimulatorInternals();
|
||||
this->emitSimulatorCombinedStatus();
|
||||
|
||||
this->initSimulatorInternals();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1056,18 +1063,38 @@ namespace BlackSimPlugin
|
||||
if (!m_serviceProxy) { return false; }
|
||||
const CXSwiftBusSettings s = m_xSwiftBusServerSettings.get();
|
||||
m_serviceProxy->setSettings(s.toXSwiftBusJsonStringQt());
|
||||
CLogMessage(this).info(u"Send settings: %1") << s.toQString(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CSimulatorXPlane::receiveXSwiftBusSettings()
|
||||
CXSwiftBusSettings CSimulatorXPlane::receiveXSwiftBusSettings(bool &ok)
|
||||
{
|
||||
if (!this->isConnected()) { return false; }
|
||||
if (!m_serviceProxy) { return false; }
|
||||
ok = false;
|
||||
CXSwiftBusSettings s;
|
||||
|
||||
if (!this->isConnected()) { return s; }
|
||||
if (!m_serviceProxy) { return s; }
|
||||
|
||||
const QString json = m_serviceProxy->getSettings();
|
||||
const CXSwiftBusSettings s(json);
|
||||
Q_UNUSED(s); // DO SOMETHING WITH THE SETTINGS
|
||||
return true;
|
||||
s.parseXSwiftBusStringQt(json);
|
||||
ok = true;
|
||||
return s;
|
||||
}
|
||||
|
||||
void CSimulatorXPlane::onXSwiftBusSettingsChanged()
|
||||
{
|
||||
bool ok;
|
||||
const CXSwiftBusSettings xPlaneSide = this->receiveXSwiftBusSettings(ok);
|
||||
if (ok)
|
||||
{
|
||||
// we only send if DBus did not change
|
||||
// DBus changes would require a restart
|
||||
const CXSwiftBusSettings swiftSide = m_xSwiftBusServerSettings.get();
|
||||
if (xPlaneSide.getDBusServerAddressQt() == swiftSide.getDBusServerAddressQt())
|
||||
{
|
||||
this->sendXSwiftBusSettings();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CSimulatorXPlane::updateAirportsInRange()
|
||||
|
||||
@@ -225,11 +225,14 @@ namespace BlackSimPlugin
|
||||
|
||||
//! Send/receive settings @{
|
||||
bool sendXSwiftBusSettings();
|
||||
bool receiveXSwiftBusSettings();
|
||||
BlackMisc::Simulation::Settings::CXSwiftBusSettings receiveXSwiftBusSettings(bool &ok);
|
||||
//! @}
|
||||
|
||||
//! Settings have changed
|
||||
void onXSwiftBusSettingsChanged();
|
||||
|
||||
DBusMode m_dbusMode;
|
||||
BlackMisc::CSetting<BlackMisc::Simulation::Settings::TXSwiftBusSettings> m_xSwiftBusServerSettings { this };
|
||||
BlackMisc::CSetting<BlackMisc::Simulation::Settings::TXSwiftBusSettings> m_xSwiftBusServerSettings { this, &CSimulatorXPlane::onXSwiftBusSettingsChanged };
|
||||
static constexpr qint64 TimeoutAdding = 10000;
|
||||
QDBusConnection m_dBusConnection { "default" };
|
||||
QDBusServiceWatcher *m_watcher { nullptr };
|
||||
|
||||
@@ -165,6 +165,10 @@ namespace XSwiftBus
|
||||
void CService::setSettings(const std::string &jsonString)
|
||||
{
|
||||
m_pluginSettings.parseXSwiftBusString(jsonString);
|
||||
|
||||
XPLMDebugString("Received settings ");
|
||||
XPLMDebugString(m_pluginSettings.convertToString().c_str());
|
||||
XPLMDebugString("\n");
|
||||
}
|
||||
|
||||
void CService::readAirportsDatabase()
|
||||
|
||||
Reference in New Issue
Block a user