Ref T723 [xswiftbus] Expose configuration to enable/disable TCAS traffic

This commit is contained in:
Mat Sutcliffe
2019-12-27 21:40:15 +00:00
parent 8d204cded1
commit 0f6b7d910e
6 changed files with 31 additions and 0 deletions

View File

@@ -41,6 +41,11 @@ namespace BlackMisc
m_debug = on;
}
void CXSwiftBusConfigWriter::setTcasEnabled(bool on)
{
m_tcas = on;
}
void CXSwiftBusConfigWriter::updateInAllXPlaneVersions()
{
updateInXPlane9();
@@ -85,6 +90,9 @@ namespace BlackMisc
ts << endl;
ts << "# Render phase debugging - to help diagnose crashes" << endl;
ts << "debug = " << boolToOnOff(m_debug) << endl;
ts << endl;
ts << "# TCAS traffic - to disable in case of crashes" << endl;
ts << "tcas = " << boolToOnOff(m_debug) << endl;
}
}
} // ns

View File

@@ -36,6 +36,9 @@ namespace BlackMisc
//! Set debug on/off
void setDebugMode(bool on);
//! Set TCAS on/off
void setTcasEnabled(bool on);
//! Update xswiftbus.conf in all known X-Plane versions (XP9 - XP11 are supported)
void updateInAllXPlaneVersions();
@@ -56,6 +59,7 @@ namespace BlackMisc
QString m_dbusAddress = "127.0.0.1";
QString m_dbusPort = "45001";
bool m_debug = false;
bool m_tcas = true;
};
}
}

View File

@@ -60,6 +60,7 @@ namespace XSwiftBus
else if (stringCompareCaseInsensitive(key, "dbusAddress")) { valid = parseDBusAddress(value); }
else if (stringCompareCaseInsensitive(key, "dbusPort")) { valid = parseDBusPort(value); }
else if (stringCompareCaseInsensitive(key, "debug")) { valid = parseDebug(value); }
else if (stringCompareCaseInsensitive(key, "tcasTraffic")) { valid = parseTcas(value); }
else
{
WARNING_LOG("xswiftbus.conf line " + std::to_string(lineNo) + ": Unknown variable " + value + "!");
@@ -129,6 +130,12 @@ namespace XSwiftBus
return true;
}
bool CConfig::parseTcas(const std::string &value)
{
m_tcas = stringCompareCaseInsensitive(value, "on");
return true;
}
std::string CConfig::dbusModeToString(DBusMode mode)
{
switch (mode)

View File

@@ -53,11 +53,15 @@ namespace XSwiftBus
//! Get debug on/off
bool getDebugMode() const { return m_debug; }
//! Get tcas traffic on/off
bool getTcasEnabled() const { return m_tcas; }
private:
bool parseDBusMode(const std::string &value);
bool parseDBusAddress(const std::string &value);
bool parseDBusPort(const std::string &value);
bool parseDebug(const std::string &value);
bool parseTcas(const std::string &value);
static std::string dbusModeToString(DBusMode mode);
@@ -66,6 +70,7 @@ namespace XSwiftBus
std::string m_dbusAddress = "127.0.0.1";
int m_dbusPort = 45001;
bool m_debug = false;
bool m_tcas = true;
};
} // ns

View File

@@ -255,6 +255,10 @@ namespace XSwiftBus
{
return s_instance->getConfig().getDebugMode() ? 1 : 0;
}
else if (strcmp(section, "debug") == 0 && strcmp(name, "tcas_traffic") == 0)
{
return s_instance->getConfig().getTcasEnabled() ? 1 : 0;
}
return def;
}

View File

@@ -9,3 +9,6 @@ dbusPort = 45001
# Render phase debugging - to help diagnose crashes
debug = off
# TCAS traffic - to disable in case of crashes
tcas = on