mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-27 02:55:44 +08:00
Ref T275, allow to disable airspace watchdog (needed when debugging to avoid timeouts)
This commit is contained in:
@@ -160,10 +160,12 @@ namespace BlackCore
|
|||||||
const qint64 atcTimeoutMs = m_timeoutAtc.valueInteger(CTimeUnit::ms());
|
const qint64 atcTimeoutMs = m_timeoutAtc.valueInteger(CTimeUnit::ms());
|
||||||
const qint64 timeoutAircraftEpochMs = currentTimeMsEpoch - aircraftTimeoutMs;
|
const qint64 timeoutAircraftEpochMs = currentTimeMsEpoch - aircraftTimeoutMs;
|
||||||
const qint64 timeoutAtcEpochMs = currentTimeMsEpoch - atcTimeoutMs;
|
const qint64 timeoutAtcEpochMs = currentTimeMsEpoch - atcTimeoutMs;
|
||||||
|
const bool enabled = m_enabledWatchdog;
|
||||||
|
|
||||||
const QList<CCallsign> callsignsAircraft = m_aircraftCallsignTimestamps.keys();
|
const QList<CCallsign> callsignsAircraft = m_aircraftCallsignTimestamps.keys();
|
||||||
for (const CCallsign &callsign : callsignsAircraft) // clazy:exclude=container-anti-pattern,range-loop
|
for (const CCallsign &callsign : callsignsAircraft) // clazy:exclude=container-anti-pattern,range-loop
|
||||||
{
|
{
|
||||||
|
if (!enabled) { m_aircraftCallsignTimestamps[callsign] = timeoutAircraftEpochMs + 1000; } // fake value so it can be re-enabled
|
||||||
const qint64 tsv = m_aircraftCallsignTimestamps.value(callsign);
|
const qint64 tsv = m_aircraftCallsignTimestamps.value(callsign);
|
||||||
if (tsv > timeoutAircraftEpochMs) { continue; }
|
if (tsv > timeoutAircraftEpochMs) { continue; }
|
||||||
CLogMessage(this).debug() << "Aircraft " << callsign.toQString() << "timed out! " << (currentTimeMsEpoch - tsv) << "ms";
|
CLogMessage(this).debug() << "Aircraft " << callsign.toQString() << "timed out! " << (currentTimeMsEpoch - tsv) << "ms";
|
||||||
@@ -174,6 +176,7 @@ namespace BlackCore
|
|||||||
const QList<CCallsign> callsignsAtc = m_atcCallsignTimestamps.keys();
|
const QList<CCallsign> callsignsAtc = m_atcCallsignTimestamps.keys();
|
||||||
for (const CCallsign &callsign : callsignsAtc) // clazy:exclude=container-anti-pattern,range-loop
|
for (const CCallsign &callsign : callsignsAtc) // clazy:exclude=container-anti-pattern,range-loop
|
||||||
{
|
{
|
||||||
|
if (!enabled) { m_aircraftCallsignTimestamps[callsign] = timeoutAtcEpochMs + 1000; } // fake value so it can be re-enabled
|
||||||
const qint64 tsv = m_aircraftCallsignTimestamps.value(callsign);
|
const qint64 tsv = m_aircraftCallsignTimestamps.value(callsign);
|
||||||
if (m_atcCallsignTimestamps.value(callsign) > timeoutAtcEpochMs) { continue; }
|
if (m_atcCallsignTimestamps.value(callsign) > timeoutAtcEpochMs) { continue; }
|
||||||
CLogMessage(this).debug() << "ATC " << callsign.toQString() << "timed out! " << (currentTimeMsEpoch - tsv) << "ms";
|
CLogMessage(this).debug() << "ATC " << callsign.toQString() << "timed out! " << (currentTimeMsEpoch - tsv) << "ms";
|
||||||
|
|||||||
@@ -29,6 +29,7 @@
|
|||||||
#include <QReadWriteLock>
|
#include <QReadWriteLock>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
|
#include <atomic>
|
||||||
|
|
||||||
namespace BlackMisc
|
namespace BlackMisc
|
||||||
{
|
{
|
||||||
@@ -67,6 +68,9 @@ namespace BlackCore
|
|||||||
INetwork *network,
|
INetwork *network,
|
||||||
CAirspaceMonitor *airspaceMonitorParent);
|
CAirspaceMonitor *airspaceMonitorParent);
|
||||||
|
|
||||||
|
//! Destructor
|
||||||
|
virtual ~CAirspaceAnalyzer();
|
||||||
|
|
||||||
//! Get the latest snapshot
|
//! Get the latest snapshot
|
||||||
//! \threadsafe
|
//! \threadsafe
|
||||||
BlackMisc::Simulation::CAirspaceAircraftSnapshot getLatestAirspaceAircraftSnapshot() const;
|
BlackMisc::Simulation::CAirspaceAircraftSnapshot getLatestAirspaceAircraftSnapshot() const;
|
||||||
@@ -74,10 +78,10 @@ namespace BlackCore
|
|||||||
//! Render restrictions in simulator
|
//! Render restrictions in simulator
|
||||||
void setSimulatorRenderRestrictionsChanged(bool restricted, bool enabled, int maxAircraft, const BlackMisc::PhysicalQuantities::CLength &maxRenderedDistance);
|
void setSimulatorRenderRestrictionsChanged(bool restricted, bool enabled, int maxAircraft, const BlackMisc::PhysicalQuantities::CLength &maxRenderedDistance);
|
||||||
|
|
||||||
//! Destructor
|
//! Enable/disable watchdog
|
||||||
virtual ~CAirspaceAnalyzer();
|
//! \remark primarily for debugging, where stopping at a breakpoint can cause multiple timeouts
|
||||||
|
void setEnabledWatchdog(bool enabled) { m_enabledWatchdog = enabled; }
|
||||||
|
|
||||||
public slots:
|
|
||||||
//! Clear
|
//! Clear
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
@@ -126,6 +130,7 @@ namespace BlackCore
|
|||||||
BlackMisc::PhysicalQuantities::CTime m_timeoutAircraft = { 15, BlackMisc::PhysicalQuantities::CTimeUnit::s() }; //!< Timeout value for watchdog functionality
|
BlackMisc::PhysicalQuantities::CTime m_timeoutAircraft = { 15, BlackMisc::PhysicalQuantities::CTimeUnit::s() }; //!< Timeout value for watchdog functionality
|
||||||
BlackMisc::PhysicalQuantities::CTime m_timeoutAtc = { 50, BlackMisc::PhysicalQuantities::CTimeUnit::s() }; //!< Timeout value for watchdog functionality
|
BlackMisc::PhysicalQuantities::CTime m_timeoutAtc = { 50, BlackMisc::PhysicalQuantities::CTimeUnit::s() }; //!< Timeout value for watchdog functionality
|
||||||
qint64 m_lastWatchdogCallMsSinceEpoch; //!< when last called
|
qint64 m_lastWatchdogCallMsSinceEpoch; //!< when last called
|
||||||
|
std::atomic_bool m_enabledWatchdog { true }; //!< watchdog enabled
|
||||||
|
|
||||||
// snapshot
|
// snapshot
|
||||||
BlackMisc::Simulation::CAirspaceAircraftSnapshot m_latestAircraftSnapshot;
|
BlackMisc::Simulation::CAirspaceAircraftSnapshot m_latestAircraftSnapshot;
|
||||||
|
|||||||
@@ -303,6 +303,14 @@ namespace BlackCore
|
|||||||
m_bookingsRequested = true;
|
m_bookingsRequested = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CAirspaceMonitor::enableWatchdog(bool enable)
|
||||||
|
{
|
||||||
|
if (this->analyzer())
|
||||||
|
{
|
||||||
|
this->analyzer()->setEnabled(enable);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CAirspaceMonitor::testCreateDummyOnlineAtcStations(int number)
|
void CAirspaceMonitor::testCreateDummyOnlineAtcStations(int number)
|
||||||
{
|
{
|
||||||
if (number < 1) { return; }
|
if (number < 1) { return; }
|
||||||
|
|||||||
@@ -118,6 +118,9 @@ namespace BlackCore
|
|||||||
//! Analyzer
|
//! Analyzer
|
||||||
CAirspaceAnalyzer *analyzer() const { return m_analyzer; }
|
CAirspaceAnalyzer *analyzer() const { return m_analyzer; }
|
||||||
|
|
||||||
|
//! \copydoc CAirspaceAnalyzer::setEnabled
|
||||||
|
void enableWatchdog(bool enable);
|
||||||
|
|
||||||
//! Gracefully shut down, e.g. for thread safety
|
//! Gracefully shut down, e.g. for thread safety
|
||||||
void gracefulShutdown();
|
void gracefulShutdown();
|
||||||
|
|
||||||
|
|||||||
@@ -235,7 +235,7 @@ namespace BlackCore
|
|||||||
{
|
{
|
||||||
Q_UNUSED(originator;)
|
Q_UNUSED(originator;)
|
||||||
if (commandLine.isEmpty()) { return false; }
|
if (commandLine.isEmpty()) { return false; }
|
||||||
static const QStringList cmds({ ".msg", ".m", ".altos", ".altoffset" });
|
static const QStringList cmds({ ".msg", ".m", ".altos", ".altoffset", ".watchdog" });
|
||||||
CSimpleCommandParser parser(cmds);
|
CSimpleCommandParser parser(cmds);
|
||||||
parser.parse(commandLine);
|
parser.parse(commandLine);
|
||||||
if (!parser.isKnownCommand()) { return false; }
|
if (!parser.isKnownCommand()) { return false; }
|
||||||
@@ -316,10 +316,11 @@ namespace BlackCore
|
|||||||
this->sendTextMessages(tml);
|
this->sendTextMessages(tml);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (parser.matchesCommand(".altos", ".altoffet"))
|
else if (parser.matchesCommand(".altos", ".altoffset"))
|
||||||
{
|
{
|
||||||
if (!m_airspace) { return false; }
|
if (!m_airspace) { return false; }
|
||||||
if (parser.countParts() < 2) { return false; }
|
if (parser.countParts() < 2) { return false; }
|
||||||
|
|
||||||
const CCallsign cs(parser.part(1));
|
const CCallsign cs(parser.part(1));
|
||||||
if (!m_airspace->isAircraftInRange(cs))
|
if (!m_airspace->isAircraftInRange(cs))
|
||||||
{
|
{
|
||||||
@@ -332,17 +333,23 @@ namespace BlackCore
|
|||||||
{
|
{
|
||||||
os.parseFromString(parser.part(2));
|
os.parseFromString(parser.part(2));
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool added = this->testAddAltitudeOffset(cs, os);
|
const bool added = this->testAddAltitudeOffset(cs, os);
|
||||||
if (added)
|
if (added) { CLogMessage(this).info("Added altitude offset %1 for %2") << os.valueRoundedWithUnit(2) << cs.asString(); }
|
||||||
{
|
else { CLogMessage(this).info("Removed altitude offset %1") << cs.asString(); }
|
||||||
CLogMessage(this).info("Added altitude offset %1 for %2") << os.valueRoundedWithUnit(2) << cs.asString();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
CLogMessage(this).info("Removed altitude offset %1") << cs.asString();
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
else if (parser.matchesCommand(".watchdog"))
|
||||||
|
{
|
||||||
|
if (!m_airspace) { return false; }
|
||||||
|
if (parser.countParts() < 2) { return false; }
|
||||||
|
|
||||||
|
const bool watchdog = parser.toBool(1, true);
|
||||||
|
m_airspace->enableWatchdog(watchdog);
|
||||||
|
CLogMessage(this).info("Enabled watchdog: %1") << boolToYesNo(watchdog);
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -201,9 +201,10 @@ namespace BlackCore
|
|||||||
{
|
{
|
||||||
if (BlackMisc::CSimpleCommandParser::registered("BlackCore::CContextNetwork")) { return; }
|
if (BlackMisc::CSimpleCommandParser::registered("BlackCore::CContextNetwork")) { return; }
|
||||||
BlackMisc::CSimpleCommandParser::registerCommand({".m", "alias: .msg"});
|
BlackMisc::CSimpleCommandParser::registerCommand({".m", "alias: .msg"});
|
||||||
BlackMisc::CSimpleCommandParser::registerCommand({".m message <text>", "send text message"});
|
BlackMisc::CSimpleCommandParser::registerCommand({".m message text", "send text message"});
|
||||||
BlackMisc::CSimpleCommandParser::registerCommand({".m callsign message <text>", "send text message"});
|
BlackMisc::CSimpleCommandParser::registerCommand({".m callsign message text", "send text message"});
|
||||||
BlackMisc::CSimpleCommandParser::registerCommand({".altos callsign offsetvalue", "set altitude offset value (testing)"});
|
BlackMisc::CSimpleCommandParser::registerCommand({".altos callsign offsetvalue", "set altitude offset value (testing)"});
|
||||||
|
BlackMisc::CSimpleCommandParser::registerCommand({".watchdog on|off", "enable/disable network watchdog (testing)"});
|
||||||
}
|
}
|
||||||
|
|
||||||
//! \publicsection
|
//! \publicsection
|
||||||
|
|||||||
Reference in New Issue
Block a user