Style and log messages

This commit is contained in:
Klaus Basan
2019-11-07 00:05:30 +01:00
committed by Mat Sutcliffe
parent 441ca41ee3
commit 5fea046c0b
6 changed files with 41 additions and 48 deletions

View File

@@ -24,10 +24,11 @@
#include <QWriteLocker>
using namespace BlackMisc;
using namespace BlackMisc::Network;
using namespace BlackMisc::Simulation;
using namespace BlackMisc::Aviation;
using namespace BlackMisc::Geo;
using namespace BlackMisc::Network;
using namespace BlackMisc::PhysicalQuantities;
using namespace BlackMisc::Simulation;
using namespace BlackCore::Fsd;
namespace BlackCore
@@ -63,7 +64,7 @@ namespace BlackCore
// Monitor
c = connect(airspaceMonitorParent, &CAirspaceMonitor::addedAircraftSituation, this, &CAirspaceAnalyzer::watchdogTouchAircraftCallsign);
Q_ASSERT(c);
Q_UNUSED(c);
Q_UNUSED(c)
// start in own thread
this->start(QThread::LowestPriority);
@@ -89,7 +90,7 @@ namespace BlackCore
void CAirspaceAnalyzer::onNetworkPositionUpdate(const CAircraftSituation &situation, const CTransponder &transponder)
{
Q_UNUSED(transponder);
Q_UNUSED(transponder)
this->watchdogTouchAircraftCallsign(situation);
}
@@ -99,17 +100,17 @@ namespace BlackCore
m_aircraftCallsignTimestamps[situation.getCallsign()] = QDateTime::currentMSecsSinceEpoch();
}
void CAirspaceAnalyzer::watchdogTouchAtcCallsign(const CCallsign &callsign, const CFrequency &frequency, const Geo::CCoordinateGeodetic &position, const CLength &range)
void CAirspaceAnalyzer::watchdogTouchAtcCallsign(const CCallsign &callsign, const CFrequency &frequency, const CCoordinateGeodetic &position, const CLength &range)
{
Q_UNUSED(frequency);
Q_UNUSED(position);
Q_UNUSED(range);
Q_UNUSED(frequency)
Q_UNUSED(position)
Q_UNUSED(range)
m_atcCallsignTimestamps[callsign] = QDateTime::currentMSecsSinceEpoch();
}
void CAirspaceAnalyzer::onConnectionStatusChanged(CConnectionStatus oldStatus, CConnectionStatus newStatus)
{
Q_UNUSED(oldStatus);
Q_UNUSED(oldStatus)
if (newStatus.isDisconnected())
{
this->clear();
@@ -164,11 +165,11 @@ namespace BlackCore
m_doNotRunAgainBefore = -1;
// checks
const qint64 aircraftTimeoutMs = m_timeoutAircraft.valueInteger(CTimeUnit::ms());
const qint64 atcTimeoutMs = m_timeoutAtc.valueInteger(CTimeUnit::ms());
const qint64 aircraftTimeoutMs = m_timeoutAircraft.valueInteger(CTimeUnit::ms());
const qint64 atcTimeoutMs = m_timeoutAtc.valueInteger(CTimeUnit::ms());
const qint64 timeoutAircraftEpochMs = currentTimeMsEpoch - aircraftTimeoutMs;
const qint64 timeoutAtcEpochMs = currentTimeMsEpoch - atcTimeoutMs;
const bool enabled = m_enabledWatchdog;
const qint64 timeoutAtcEpochMs = currentTimeMsEpoch - atcTimeoutMs;
const bool enabled = m_enabledWatchdog;
const QList<CCallsign> callsignsAircraft = m_aircraftCallsignTimestamps.keys();
for (const CCallsign &callsign : callsignsAircraft) // clazy:exclude=container-anti-pattern,range-loop

View File

@@ -69,7 +69,7 @@ namespace BlackCore
CAirspaceMonitor *airspaceMonitorParent);
//! Destructor
virtual ~CAirspaceAnalyzer();
virtual ~CAirspaceAnalyzer() override;
//! Get the latest snapshot
//! \threadsafe
@@ -128,7 +128,7 @@ namespace BlackCore
CCallsignTimestampSet m_aircraftCallsignTimestamps; //!< for watchdog (pilots)
CCallsignTimestampSet m_atcCallsignTimestamps; //!< for watchdog (ATC)
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_doNotRunAgainBefore = -1; //!< do not run again before, also used to detect debugging
std::atomic_bool m_enabledWatchdog { true }; //!< watchdog enabled

View File

@@ -729,15 +729,6 @@ namespace BlackCore
if (changedAtis) { emit this->changedAtisReceived(callsign); }
}
void CAirspaceMonitor::onAtisVoiceRoomReceived(const CCallsign &callsign, const QString &url)
{
Q_ASSERT(CThreadUtils::isCurrentThreadObjectThread(this));
if (!this->isConnectedAndNotShuttingDown()) { return; }
Q_UNUSED(url)
Q_UNUSED(callsign)
return;
}
void CAirspaceMonitor::onAtisLogoffTimeReceived(const CCallsign &callsign, const QString &zuluTime)
{
Q_ASSERT(CThreadUtils::isCurrentThreadObjectThread(this));

View File

@@ -391,9 +391,6 @@ namespace BlackCore
void onAircraftConfigReceived(const BlackMisc::Aviation::CCallsign &callsign, const QJsonObject &jsonObject, qint64 currentOffsetMs);
void onAircraftInterimUpdateReceived(const BlackMisc::Aviation::CAircraftSituation &situation);
void onConnectionStatusChanged(BlackMisc::Network::CConnectionStatus oldStatus, BlackMisc::Network::CConnectionStatus newStatus);
//! \deprecated
void onAtisVoiceRoomReceived(const BlackMisc::Aviation::CCallsign &callsign, const QString &url);
};
} // namespace

View File

@@ -7,9 +7,10 @@
*/
#include "deletepilot.h"
#include "blackmisc/logmessage.h"
using namespace BlackMisc;
namespace BlackCore
{
namespace Fsd
@@ -34,9 +35,10 @@ namespace BlackCore
{
if (tokens.size() < 1)
{
BlackMisc::CLogMessage(static_cast<DeletePilot *>(nullptr)).debug(u"Wrong number of arguments.");
CLogMessage(static_cast<DeletePilot *>(nullptr)).debug(u"Wrong number of arguments.");
return {};
};
}
// VATSIM FSD will always supply the CERTIFICATE ID when it rebroadcasts this PDU without regard for whether
// the client originally specified it. But other FSDs might not.
DeletePilot packet(tokens[0], (tokens.size() >= 2) ? tokens[1] : "");

View File

@@ -14,7 +14,9 @@
#include "directplayutils.h"
#include "fs9.h"
#include "lobbyclient.h"
#include "blackmisc/logmessage.h"
#include <QDebug>
#include <QTimer>
#include <QFile>
@@ -22,6 +24,8 @@
#include <QScopedPointer>
#include <QMutexLocker>
using namespace BlackMisc;
namespace BlackSimPlugin
{
namespace Fs9
@@ -90,20 +94,20 @@ namespace BlackSimPlugin
bool CLobbyClient::canLobbyConnect()
{
if (!m_dpLobbyClient) { return false; }
GUID appGuid = CFs9Sdk::guid();
DWORD dwSize = 0;
GUID appGuid = CFs9Sdk::guid();
DWORD dwSize = 0;
DWORD dwItems = 0;
HRESULT hr = m_dpLobbyClient->EnumLocalPrograms(&appGuid, nullptr, &dwSize, &dwItems, 0);
const HRESULT hr = m_dpLobbyClient->EnumLocalPrograms(&appGuid, nullptr, &dwSize, &dwItems, 0);
if (hr == DPNERR_BUFFERTOOSMALL)
{
QScopedArrayPointer<BYTE> memPtr (new BYTE[dwSize]);
QScopedArrayPointer<BYTE> memPtr(new BYTE[dwSize]);
DPL_APPLICATION_INFO *appInfo = reinterpret_cast<DPL_APPLICATION_INFO *>(memPtr.data());
m_dpLobbyClient->EnumLocalPrograms(&appGuid, memPtr.data(), &dwSize, &dwItems, 0);
if (dwItems > 0)
{
BlackMisc::CLogMessage(this).debug() << "Found lobby application:" << QString::fromWCharArray(appInfo->pwszApplicationName);;
CLogMessage(this).debug() << "Found lobby application:" << QString::fromWCharArray(appInfo->pwszApplicationName);
return true;
}
else
@@ -133,23 +137,20 @@ namespace BlackSimPlugin
dnConnectInfo.guidApplication = pAppGuid;
if (FAILED(hr = allocAndInitConnectSettings(address, &pAppGuid, &dnConnectInfo.pdplConnectionSettings)))
{
return S_FALSE;
}
hr = m_dpLobbyClient->ConnectApplication(&dnConnectInfo,
nullptr,
&m_applicationHandle,
INFINITE,
0);
if (FAILED(hr))
{
return hr;
}
else
{
qDebug() << "Connected!";
freeConnectSettings(dnConnectInfo.pdplConnectionSettings);
return S_OK;
}
if (FAILED(hr)) { return hr; }
CLogMessage(this).info(u"Lobby client '%1' connected!") << address;
freeConnectSettings(dnConnectInfo.pdplConnectionSettings);
return S_OK;
}
HRESULT CLobbyClient::allocAndInitConnectSettings(const QString &address, GUID *pAppGuid, DPL_CONNECTION_SETTINGS **ppdplConnectSettings)
@@ -269,7 +270,7 @@ namespace BlackSimPlugin
{
PDPL_MESSAGE_DISCONNECT pDisconnectMsg;
pDisconnectMsg = (PDPL_MESSAGE_DISCONNECT)msgBuffer;
Q_UNUSED(pDisconnectMsg);
Q_UNUSED(pDisconnectMsg)
emit disconnected();
@@ -312,10 +313,11 @@ namespace BlackSimPlugin
case DPLSESSION_HOSTMIGRATEDHERE:
message.append("Host migrated to this client"); break;
default:
message.append(QString("Unknown PDPL_MESSAGE_SESSION_STATUS: %1").arg(pStatusMsg->dwStatus));
message.append(QStringLiteral("Unknown PDPL_MESSAGE_SESSION_STATUS: %1").arg(pStatusMsg->dwStatus));
break;
}
qDebug() << message;
CLogMessage(this).info(message);
break;
}