mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-12 23:35:33 +08:00
[TCAS] Fixed "mixed" values for debug/TCAS xswiftbus.conf file
Also only update if simulator XPlane is not connected, otherwise values are updated there This allows to update the values BEFORE XPlane starts and avoids a restart
This commit is contained in:
committed by
Mat Sutcliffe
parent
2607ebd7c6
commit
3d1dad989e
@@ -121,8 +121,8 @@ namespace BlackMisc
|
||||
document.AddMember(JsonDrawingLabels, m_drawingLabels, a);
|
||||
document.AddMember(JsonBundleTaxiLandingLights, m_bundleTaxiLandingLights, a);
|
||||
document.AddMember(JsonFollowAircraftDistanceM, m_followAircraftDistanceM, a);
|
||||
document.AddMember(JsonLogRenderPhases, m_logRenderPhases, a);
|
||||
document.AddMember(JsonTcas, m_tcasEnabled, a);
|
||||
document.AddMember(JsonLogRenderPhases, m_logRenderPhases, a);
|
||||
document.AddMember(JsonTcas, m_tcasEnabled, a);
|
||||
document.AddMember(JsonTerrainProbe, m_terrainProbeEnabled, a);
|
||||
|
||||
// document[CXSwiftBusSettingsQtFree::JsonDBusServerAddress].SetString(StringRef(m_dBusServerAddress.c_str(), m_dBusServerAddress.size()));
|
||||
|
||||
@@ -73,11 +73,15 @@ namespace BlackMisc
|
||||
|
||||
void CXSwiftBusConfigWriter::writeTo(const QString &filePath)
|
||||
{
|
||||
// writing the file here (UI side) allows to overwrite the values
|
||||
// before XPlane is started
|
||||
// TCAS/log values MUST be changed before startup of the plugin
|
||||
QString configFilePath = filePath + "/xswiftbus.conf";
|
||||
QFile configFile(configFilePath);
|
||||
configFile.remove();
|
||||
if (configFile.open(QIODevice::WriteOnly))
|
||||
{
|
||||
// this code should be similar to XSwiftBus config.cpp
|
||||
QTextStream ts(&configFile);
|
||||
ts << "# DBus Mode - Options: p2p, session" << endl;
|
||||
ts << "dbusMode = " << m_dbusMode << endl;
|
||||
@@ -92,7 +96,12 @@ namespace BlackMisc
|
||||
ts << "debug = " << boolToOnOff(m_debug) << endl;
|
||||
ts << endl;
|
||||
ts << "# TCAS traffic - to disable in case of crashes" << endl;
|
||||
ts << "tcas = " << boolToOnOff(m_debug) << endl;
|
||||
ts << "tcas = " << boolToOnOff(m_tcas) << endl;
|
||||
|
||||
// add comment as information
|
||||
ts << endl;
|
||||
ts << "# Updated by CXSwiftBusConfigWriter " << QDateTime::currentDateTimeUtc().toString("yyyyMMddHHmmss") << " ";
|
||||
ts << endl;
|
||||
}
|
||||
}
|
||||
} // ns
|
||||
|
||||
@@ -55,11 +55,11 @@ namespace BlackMisc
|
||||
void writeTo(const QString &filePath);
|
||||
|
||||
private:
|
||||
QString m_dbusMode = "p2p";
|
||||
QString m_dbusMode = "p2p";
|
||||
QString m_dbusAddress = "127.0.0.1";
|
||||
QString m_dbusPort = "45001";
|
||||
bool m_debug = false;
|
||||
bool m_tcas = true;
|
||||
QString m_dbusPort = "45001";
|
||||
bool m_debug = false;
|
||||
bool m_tcas = true;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,9 +6,10 @@
|
||||
* or distributed except according to the terms contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "simulatorxplaneconfigwindow.h"
|
||||
#include "blackcore/application.h"
|
||||
#include "ui_simulatorxplaneconfigwindow.h"
|
||||
#include "simulatorxplaneconfigwindow.h"
|
||||
#include "blackcore/context/contextsimulator.h"
|
||||
#include "blackgui/guiapplication.h"
|
||||
#include "blackmisc/simulation/xplane/xswiftbusconfigwriter.h"
|
||||
|
||||
#include <QComboBox>
|
||||
@@ -16,6 +17,7 @@
|
||||
#include <vector>
|
||||
|
||||
using namespace BlackGui;
|
||||
using namespace BlackCore::Context;
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Simulation::Settings;
|
||||
using namespace BlackMisc::Simulation::XPlane;
|
||||
@@ -48,16 +50,25 @@ namespace BlackSimPlugin
|
||||
|
||||
void CSimulatorXPlaneConfigWindow::onSettingsAccepted()
|
||||
{
|
||||
if (!sGui || sGui->isShuttingDown()) { return; }
|
||||
|
||||
const CXSwiftBusSettings s = m_xSwiftBusServerSettings.getThreadLocal();
|
||||
const CXSwiftBusSettings changed = this->getSettingsFromUI();
|
||||
if (s != changed)
|
||||
{
|
||||
m_xSwiftBusServerSettings.set(changed);
|
||||
CXSwiftBusConfigWriter xswiftbusConfigWriter;
|
||||
xswiftbusConfigWriter.setDBusAddress(changed.getDBusServerAddressQt());
|
||||
xswiftbusConfigWriter.setDebugMode(s.isLogRenderPhases());
|
||||
xswiftbusConfigWriter.setTcasEnabled(s.isTcasEnabled());
|
||||
xswiftbusConfigWriter.updateInAllXPlaneVersions();
|
||||
|
||||
// this writes to a local XPlane directory
|
||||
// if swift runs distributed it does nothing
|
||||
// if XPlane is connected the settings will be written from config.cpp
|
||||
if (!sGui->getIContextSimulator() || !sGui->getIContextSimulator()->isSimulatorSimulating())
|
||||
{
|
||||
CXSwiftBusConfigWriter xswiftbusConfigWriter;
|
||||
xswiftbusConfigWriter.setDBusAddress(changed.getDBusServerAddressQt());
|
||||
xswiftbusConfigWriter.setDebugMode(changed.isLogRenderPhases());
|
||||
xswiftbusConfigWriter.setTcasEnabled(changed.isTcasEnabled());
|
||||
xswiftbusConfigWriter.updateInAllXPlaneVersions();
|
||||
}
|
||||
}
|
||||
this->close();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user