mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-03 15:45:46 +08:00
[XSwiftBus] Misc. style fixes
This commit is contained in:
committed by
Mat Sutcliffe
parent
db81acf574
commit
80e97f749f
@@ -27,7 +27,7 @@ namespace XSwiftBus
|
||||
void CConfig::parse()
|
||||
{
|
||||
std::ifstream configFile(m_filePath);
|
||||
if (! configFile.is_open()) { return; }
|
||||
if (!configFile.is_open()) { return; }
|
||||
|
||||
std::string line;
|
||||
for (int lineNo = 1; std::getline(configFile, line); ++lineNo)
|
||||
@@ -42,7 +42,7 @@ namespace XSwiftBus
|
||||
continue;
|
||||
}
|
||||
|
||||
std::string key = line.substr(0, delimiterPos);
|
||||
std::string key = line.substr(0, delimiterPos);
|
||||
std::string value = line.substr(delimiterPos + 1);
|
||||
|
||||
if (key.empty() || value.empty())
|
||||
@@ -54,9 +54,9 @@ namespace XSwiftBus
|
||||
bool valid = true;
|
||||
if (stringCompareCaseInsensitive(key, "dbusMode")) { valid = parseDBusMode(value); }
|
||||
else if (stringCompareCaseInsensitive(key, "dbusAddress")) { valid = parseDBusAddress(value); }
|
||||
else if (stringCompareCaseInsensitive(key, "dbusPort")) { valid = parseDBusPort(value); }
|
||||
else if (stringCompareCaseInsensitive(key, "dbusPort")) { valid = parseDBusPort(value); }
|
||||
else if (stringCompareCaseInsensitive(key, "debug")) { valid = parseDebug(value); }
|
||||
else if (stringCompareCaseInsensitive(key, "tcas")) { valid = parseTcas(value); }
|
||||
else if (stringCompareCaseInsensitive(key, "tcas")) { valid = parseTcas(value); }
|
||||
else
|
||||
{
|
||||
WARNING_LOG("xswiftbus.conf line " + std::to_string(lineNo) + ": Unknown variable " + key + "!");
|
||||
@@ -81,8 +81,8 @@ namespace XSwiftBus
|
||||
|
||||
bool CConfig::parseDBusMode(const std::string &value)
|
||||
{
|
||||
if (stringCompareCaseInsensitive(value, "session")) { m_dbusMode = CConfig::DBusSession; return true; }
|
||||
else if (stringCompareCaseInsensitive(value, "P2P")) { m_dbusMode = CConfig::DBusP2P; return true; }
|
||||
if (stringCompareCaseInsensitive(value, "session")) { m_dbusMode = CConfig::DBusSession; return true; }
|
||||
else if (stringCompareCaseInsensitive(value, "P2P")) { m_dbusMode = CConfig::DBusP2P; return true; }
|
||||
else { return false; }
|
||||
}
|
||||
|
||||
@@ -133,9 +133,8 @@ namespace XSwiftBus
|
||||
switch (mode)
|
||||
{
|
||||
case DBusSession: return "Session";
|
||||
case DBusP2P: return "P2P";
|
||||
case DBusP2P: return "P2P";
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
} // ns
|
||||
|
||||
@@ -57,20 +57,21 @@ namespace XSwiftBus
|
||||
bool getTcasEnabled() const { return m_tcas; }
|
||||
|
||||
private:
|
||||
bool parseDBusMode(const std::string &value);
|
||||
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);
|
||||
bool parseDBusPort (const std::string &value);
|
||||
bool parseDebug (const std::string &value);
|
||||
bool parseTcas (const std::string &value);
|
||||
bool writeConfigFile () const;
|
||||
|
||||
static std::string dbusModeToString(DBusMode mode);
|
||||
|
||||
std::string m_filePath;
|
||||
DBusMode m_dbusMode = DBusP2P;
|
||||
DBusMode m_dbusMode = DBusP2P;
|
||||
std::string m_dbusAddress = "127.0.0.1";
|
||||
int m_dbusPort = 45001;
|
||||
bool m_debug = false;
|
||||
bool m_tcas = true;
|
||||
int m_dbusPort = 45001;
|
||||
bool m_debug = false;
|
||||
bool m_tcas = true;
|
||||
};
|
||||
} // ns
|
||||
|
||||
|
||||
@@ -109,7 +109,7 @@ namespace XSwiftBus
|
||||
|
||||
// FIXME: make listen address configurable
|
||||
std::string listenAddress = "tcp:host=" + m_pluginConfig.getDBusAddress() + ",port=" + std::to_string(m_pluginConfig.getDBusPort());
|
||||
if (! m_dbusP2PServer->listen(listenAddress))
|
||||
if (!m_dbusP2PServer->listen(listenAddress))
|
||||
{
|
||||
m_service->addTextMessage("XSwiftBus startup failed!", 255, 0, 0);
|
||||
return;
|
||||
|
||||
@@ -33,18 +33,18 @@ namespace XSwiftBus
|
||||
|
||||
std::vector<float> m_samples;
|
||||
float m_total = 0;
|
||||
float m_totalOverBudget = 0;
|
||||
float m_totalOverBudget = 0;
|
||||
float m_totalMetersShort = 0;
|
||||
float m_totalSecondsLate = 0;
|
||||
size_t m_lastSampleIndex = 0;
|
||||
static constexpr size_t c_maxSampleCount = 500;
|
||||
static constexpr size_t c_maxSampleCount = 500;
|
||||
static constexpr float c_framePeriodBudget = 0.05f;
|
||||
|
||||
FramePeriodSampler() : CDrawable(xplm_Phase_LastScene, false) {}
|
||||
|
||||
std::tuple<float, float, float, float> getFrameStats()
|
||||
{
|
||||
if (m_total == 0) { return {}; }
|
||||
if (m_total < 0.001f) { return {}; } // no DIV by 0
|
||||
const float fps = m_samples.size() / m_total;
|
||||
const float ratio = 1 - m_totalOverBudget / m_total;
|
||||
const float miles = m_totalMetersShort / 1852.0f;
|
||||
@@ -64,7 +64,7 @@ namespace XSwiftBus
|
||||
++m_lastSampleIndex %= c_maxSampleCount;
|
||||
if (m_samples.size() == c_maxSampleCount)
|
||||
{
|
||||
auto& oldSample = m_samples[m_lastSampleIndex];
|
||||
auto &oldSample = m_samples[m_lastSampleIndex];
|
||||
m_total -= oldSample;
|
||||
if (oldSample > c_framePeriodBudget)
|
||||
{
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace XSwiftBus
|
||||
m_provider->setSettings(settings);
|
||||
}
|
||||
|
||||
const CConfig& CSettingsAware::getConfig() const
|
||||
const CConfig &CSettingsAware::getConfig() const
|
||||
{
|
||||
return m_provider->getConfig();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user