mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-06 01:45:38 +08:00
refs #702, access to reverse lookup log messages per callsign
* added functions in airspace / context * allow to retrieve "aircraft in range" callsigns
This commit is contained in:
@@ -7,9 +7,10 @@
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "blackcore/aircraftmatcher.h"
|
||||
#include "blackcore/airspaceanalyzer.h"
|
||||
#include "blackcore/airspacemonitor.h"
|
||||
#include "blackcore/aircraftmatcher.h"
|
||||
#include "blackcore/matchingutils.h"
|
||||
#include "blackcore/application.h"
|
||||
#include "blackcore/network.h"
|
||||
#include "blackcore/vatsim/vatsimbookingreader.h"
|
||||
@@ -102,12 +103,23 @@ namespace BlackCore
|
||||
this->connect(this->m_analyzer, &CAirspaceAnalyzer::timeoutAtc, this, &CAirspaceMonitor::ps_atcControllerDisconnected, Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
const CLogCategoryList &CAirspaceMonitor::getLogCategories()
|
||||
{
|
||||
static const BlackMisc::CLogCategoryList cats { CLogCategory::matching(), CLogCategory::network() };
|
||||
return cats;
|
||||
}
|
||||
|
||||
CSimulatedAircraftList CAirspaceMonitor::getAircraftInRange() const
|
||||
{
|
||||
QReadLocker l(&m_lockAircraft);
|
||||
return m_aircraftInRange;
|
||||
}
|
||||
|
||||
CCallsignSet CAirspaceMonitor::getAircraftInRangeCallsigns() const
|
||||
{
|
||||
return this->getAircraftInRange().getCallsigns();
|
||||
}
|
||||
|
||||
CSimulatedAircraft CAirspaceMonitor::getAircraftInRangeForCallsign(const CCallsign &callsign) const
|
||||
{
|
||||
return this->getAircraftInRange().findFirstByCallsign(callsign);
|
||||
@@ -201,7 +213,7 @@ namespace BlackCore
|
||||
Q_UNUSED(originator);
|
||||
CPropertyIndexVariantMap vm(CSimulatedAircraft::IndexEnabled, CVariant::fromValue(enabledForRedering));
|
||||
QWriteLocker l(&m_lockAircraft);
|
||||
int c = m_aircraftInRange.applyIfCallsign(callsign, vm);
|
||||
const int c = m_aircraftInRange.applyIfCallsign(callsign, vm);
|
||||
return c > 0;
|
||||
}
|
||||
|
||||
@@ -210,7 +222,7 @@ namespace BlackCore
|
||||
Q_UNUSED(originator);
|
||||
QWriteLocker l(&m_lockAircraft);
|
||||
CPropertyIndexVariantMap vm(CSimulatedAircraft::IndexModel, CVariant::from(model));
|
||||
int c = m_aircraftInRange.applyIfCallsign(callsign, vm);
|
||||
const int c = m_aircraftInRange.applyIfCallsign(callsign, vm);
|
||||
return c > 0;
|
||||
}
|
||||
|
||||
@@ -275,14 +287,14 @@ namespace BlackCore
|
||||
CUserList CAirspaceMonitor::getUsers() const
|
||||
{
|
||||
CUserList users;
|
||||
foreach (CAtcStation station, this->m_atcStationsOnline)
|
||||
for (const CAtcStation &station : this->m_atcStationsOnline)
|
||||
{
|
||||
CUser user = station.getController();
|
||||
const CUser user = station.getController();
|
||||
users.push_back(user);
|
||||
}
|
||||
for (const CSimulatedAircraft &aircraft : this->getAircraftInRange())
|
||||
{
|
||||
CUser user = aircraft.getPilot();
|
||||
const CUser user = aircraft.getPilot();
|
||||
users.push_back(user);
|
||||
}
|
||||
return users;
|
||||
@@ -379,6 +391,24 @@ namespace BlackCore
|
||||
return stations.front();
|
||||
}
|
||||
|
||||
void CAirspaceMonitor::enableReverseLookupMessages(bool enabled)
|
||||
{
|
||||
QWriteLocker l(&m_lockMessages);
|
||||
this->m_enableReverseLookupMsgs = enabled;
|
||||
}
|
||||
|
||||
bool CAirspaceMonitor::isReverseLookupMessagesEnabled() const
|
||||
{
|
||||
QReadLocker l(&m_lockMessages);
|
||||
return this->m_enableReverseLookupMsgs;
|
||||
}
|
||||
|
||||
CStatusMessageList CAirspaceMonitor::getReverseLookupMessages(const CCallsign &callsign) const
|
||||
{
|
||||
QReadLocker l(&m_lockMessages);
|
||||
return this->m_reverseLookupMessages.value(callsign);
|
||||
}
|
||||
|
||||
void CAirspaceMonitor::requestDataUpdates()
|
||||
{
|
||||
if (!this->m_network->isConnected()) { return; }
|
||||
@@ -538,11 +568,13 @@ namespace BlackCore
|
||||
emit removedAircraft(cs);
|
||||
}
|
||||
|
||||
{ QWriteLocker l1(&m_lockParts); m_partsByCallsign.clear(); m_aircraftSupportingParts.clear(); }
|
||||
{ QWriteLocker l2(&m_lockSituations); m_situationsByCallsign.clear(); }
|
||||
// locked members
|
||||
{ QWriteLocker l(&m_lockParts); m_partsByCallsign.clear(); m_aircraftSupportingParts.clear(); }
|
||||
{ QWriteLocker l(&m_lockSituations); m_situationsByCallsign.clear(); }
|
||||
{ QWriteLocker l(&m_lockMessages); m_reverseLookupMessages.clear(); }
|
||||
{ QWriteLocker l(&m_lockAircraft); m_aircraftInRange.clear(); }
|
||||
|
||||
// non thread safe parts
|
||||
m_aircraftInRange.clear();
|
||||
m_flightPlanCache.clear();
|
||||
m_modelTemporaryCache.clear();
|
||||
}
|
||||
@@ -553,11 +585,14 @@ namespace BlackCore
|
||||
m_otherClients.clear();
|
||||
}
|
||||
|
||||
void CAirspaceMonitor::removeFromAircraftCaches(const CCallsign &callsign)
|
||||
void CAirspaceMonitor::removeFromAircraftCachesAndLogs(const CCallsign &callsign)
|
||||
{
|
||||
if (callsign.isEmpty()) { return; }
|
||||
this->m_modelTemporaryCache.remove(callsign);
|
||||
this->m_flightPlanCache.remove(callsign);
|
||||
|
||||
QWriteLocker l(&m_lockMessages);
|
||||
this->m_reverseLookupMessages.remove(callsign);
|
||||
}
|
||||
|
||||
void CAirspaceMonitor::fireDelayedReadyForModelMatching(const CCallsign &callsign, int trial, int delayMs)
|
||||
@@ -565,7 +600,8 @@ namespace BlackCore
|
||||
Q_ASSERT_X(!callsign.isEmpty(), Q_FUNC_INFO, "missing callsign");
|
||||
BlackMisc::singleShot(delayMs, QThread::currentThread(), [ = ]()
|
||||
{
|
||||
this->ps_sendReadyForModelMatching(callsign, trial + 1);
|
||||
this->addReverseLookupMessage(callsign, QString("Waiting for FSD packets, %1 trial").arg(trial));
|
||||
this->ps_sendReadyForModelMatching(callsign, trial);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -637,19 +673,32 @@ namespace BlackCore
|
||||
{
|
||||
// here we assume user has logged out, incomplete data because of traffic sim, etc.
|
||||
// aircraft is no longer in range, or ws never added to range (no position updates)
|
||||
CLogMessage(this).debug() << "Aircraft not in range anymore or never added to range " << callsign.toQString();
|
||||
const QString msg = QString("Aircraft '%1' not in range anymore or never added to range, designator '%2', airline '%3'").arg(callsign.toQString()).arg(remoteAircraft.getAircraftIcaoCodeDesignator()).arg(remoteAircraft.getAirlineIcaoCodeDesignator());
|
||||
const CStatusMessage m = CMatchingUtils::logMessage(callsign, msg, getLogCategories(), CStatusMessage::SeverityWarning);
|
||||
this->addReverseLookupMessage(callsign, m);
|
||||
CLogMessage::preformatted(m);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!validData)
|
||||
{
|
||||
// even after all the trials, still no valid data, something is wrong here
|
||||
CLogMessage(this).warning("Cannot retrieve correct data for %1") << callsign.toQString();
|
||||
const QString msg = QString("Cannot retrieve correct data for '%1', designator '%2', airline '%3'").arg(callsign.toQString()).arg(remoteAircraft.getAircraftIcaoCodeDesignator()).arg(remoteAircraft.getAirlineIcaoCodeDesignator());
|
||||
const CStatusMessage m = CMatchingUtils::logMessage(callsign, msg, getLogCategories(), CStatusMessage::SeverityWarning);
|
||||
this->addReverseLookupMessage(callsign, m);
|
||||
CLogMessage::preformatted(m);
|
||||
return; // ignore this model (crashed, logoff, ....)
|
||||
}
|
||||
Q_ASSERT_X(remoteAircraft.getCallsign() == remoteAircraft.getModel().getCallsign(), Q_FUNC_INFO, "wrong model callsign");
|
||||
emit this->readyForModelMatching(remoteAircraft);
|
||||
this->logMatching(QString("Ready for matching %1 for with model type %2").arg(callsign.toQString()).arg(remoteAircraft.getModel().getModelTypeAsString()));
|
||||
|
||||
// log message
|
||||
{
|
||||
const QString msg = QString("Ready for matching '%1' with model type '%2'").arg(callsign.toQString()).arg(remoteAircraft.getModel().getModelTypeAsString());
|
||||
const CStatusMessage m = CMatchingUtils::logMessage(callsign, msg, getLogCategories());
|
||||
this->addReverseLookupMessage(callsign, m);
|
||||
// CLogMessage::preformatted(m);
|
||||
}
|
||||
}
|
||||
|
||||
void CAirspaceMonitor::ps_atcPositionUpdate(const CCallsign &callsign, const BlackMisc::PhysicalQuantities::CFrequency &frequency, const CCoordinateGeodetic &position, const BlackMisc::PhysicalQuantities::CLength &range)
|
||||
@@ -829,6 +878,10 @@ namespace BlackCore
|
||||
if (!this->m_connected) { return; }
|
||||
if (aircraftIcaoDesignator.isEmpty() && airlineIcaoDesignator.isEmpty() && livery.isEmpty()) { return; }
|
||||
|
||||
CStatusMessageList reverseLookupMessages;
|
||||
CStatusMessageList *pReverseLookupMessages = this->isReverseLookupMessagesEnabled() ? &reverseLookupMessages : nullptr;
|
||||
CMatchingUtils::addLogDetailsToList(pReverseLookupMessages, callsign, QString("Data from network: aircraft '%1', airline '%2', livery '%3', model '%4'").arg(aircraftIcaoDesignator).arg(airlineIcaoDesignator).arg(livery).arg(modelString));
|
||||
|
||||
const CSimulatedAircraft remoteAircraft(this->getAircraftInRangeForCallsign(callsign));
|
||||
const bool existingAircraft = !remoteAircraft.getCallsign().isEmpty();
|
||||
|
||||
@@ -865,8 +918,6 @@ namespace BlackCore
|
||||
// reverse lookup, use DB data wherever possible
|
||||
// 1) If I cannot resolce the ICAO codes here, they are either wrong (most likely in most cases) or
|
||||
// 2) not in the DB yet
|
||||
CStatusMessageList reverseLookupMessages;
|
||||
CStatusMessageList *pReverseLookupMessages = this->m_logMatchingProcess ? &reverseLookupMessages : nullptr;
|
||||
if (!model.hasAircraftDesignator() && !aircraftIcaoDesignator.isEmpty())
|
||||
{
|
||||
const CAircraftIcaoCode reverseIcao = CAircraftMatcher::reverseLookupAircraftIcao(aircraftIcaoDesignator, callsign, pReverseLookupMessages);
|
||||
@@ -877,7 +928,7 @@ namespace BlackCore
|
||||
else
|
||||
{
|
||||
model.setAircraftIcaoCode(aircraftIcaoDesignator.trimmed().toUpper());
|
||||
CAircraftMatcher::logDetails(pReverseLookupMessages, callsign, QString("No DB data for aircraft %1").arg(aircraftIcaoDesignator));
|
||||
CMatchingUtils::addLogDetailsToList(pReverseLookupMessages, callsign, QString("No DB data for aircraft %1").arg(aircraftIcaoDesignator), getLogCategories());
|
||||
}
|
||||
}
|
||||
if (!model.hasAirlineDesignator() && !airlineIcaoDesignator.isEmpty())
|
||||
@@ -891,15 +942,15 @@ namespace BlackCore
|
||||
else
|
||||
{
|
||||
defaultLivery.setAirlineIcaoCode(airlineIcaoDesignator);
|
||||
CAircraftMatcher::logDetails(pReverseLookupMessages, callsign, QString("No DB data for airline %1").arg(aircraftIcaoDesignator));
|
||||
CMatchingUtils::addLogDetailsToList(pReverseLookupMessages, callsign, QString("No DB data for airline %1").arg(aircraftIcaoDesignator), getLogCategories());
|
||||
}
|
||||
}
|
||||
|
||||
// now try resolution to model from DB
|
||||
model = CAircraftMatcher::reverseLookup(model, livery, &reverseLookupMessages);
|
||||
if (this->m_logMatchingProcess && !reverseLookupMessages.isEmpty())
|
||||
if (this->m_enableReverseLookupMsgs && !reverseLookupMessages.isEmpty())
|
||||
{
|
||||
CLogMessage::preformatted(reverseLookupMessages);
|
||||
this->addReverseLookupMessages(callsign, reverseLookupMessages);
|
||||
}
|
||||
|
||||
{
|
||||
@@ -917,11 +968,36 @@ namespace BlackCore
|
||||
} // lock
|
||||
}
|
||||
|
||||
void CAirspaceMonitor::logMatching(const QString &text) const
|
||||
void CAirspaceMonitor::addReverseLookupMessages(const CCallsign &callsign, const CStatusMessageList &messages)
|
||||
{
|
||||
if (text.isEmpty()) { return; }
|
||||
if (!this->m_logMatchingProcess) { return; }
|
||||
CLogMessage(this).info(text);
|
||||
if (callsign.isEmpty()) { return; }
|
||||
if (messages.isEmpty()) { return; }
|
||||
QWriteLocker l(&m_lockMessages);
|
||||
if (!this->m_enableReverseLookupMsgs) { return; }
|
||||
if (this->m_reverseLookupMessages.contains(callsign))
|
||||
{
|
||||
CStatusMessageList &msgs = this->m_reverseLookupMessages[callsign];
|
||||
msgs.push_back(messages);
|
||||
}
|
||||
else
|
||||
{
|
||||
this->m_reverseLookupMessages.insert(callsign, messages);
|
||||
}
|
||||
}
|
||||
|
||||
void CAirspaceMonitor::addReverseLookupMessage(const CCallsign &callsign, const CStatusMessage &message)
|
||||
{
|
||||
if (callsign.isEmpty()) { return; }
|
||||
if (message.isEmpty()) { return; }
|
||||
this->addReverseLookupMessages(callsign, CStatusMessageList({ message }));
|
||||
}
|
||||
|
||||
void CAirspaceMonitor::addReverseLookupMessage(const CCallsign &callsign, const QString &message, CStatusMessage::StatusSeverity severity)
|
||||
{
|
||||
if (callsign.isEmpty()) { return; }
|
||||
if (message.isEmpty()) { return; }
|
||||
const CStatusMessage m = CMatchingUtils::logMessage(callsign, message, getLogCategories(), severity);
|
||||
this->addReverseLookupMessage(callsign, m);
|
||||
}
|
||||
|
||||
void CAirspaceMonitor::ps_aircraftUpdateReceived(const CAircraftSituation &situation, const CTransponder &transponder)
|
||||
@@ -959,7 +1035,9 @@ namespace BlackCore
|
||||
setModelFromCache = true;
|
||||
}
|
||||
|
||||
//
|
||||
// only place where aircraft is added
|
||||
//
|
||||
{
|
||||
QWriteLocker l(&m_lockAircraft);
|
||||
this->m_aircraftInRange.push_back(aircraft);
|
||||
@@ -1002,7 +1080,7 @@ namespace BlackCore
|
||||
else
|
||||
{
|
||||
// no info yet, query ICAO codes at least
|
||||
// allow some time for the data to arrive before ready for model matching
|
||||
// allow some time for the data to arrive before for model matching
|
||||
this->m_network->sendIcaoCodesQuery(callsign);
|
||||
this->fireDelayedReadyForModelMatching(callsign);
|
||||
}
|
||||
@@ -1075,7 +1153,7 @@ namespace BlackCore
|
||||
Q_ASSERT(CThreadUtils::isCurrentThreadObjectThread(this));
|
||||
|
||||
// in case of inconsistencies I always remove here
|
||||
this->removeFromAircraftCaches(callsign);
|
||||
this->removeFromAircraftCachesAndLogs(callsign);
|
||||
|
||||
{ QWriteLocker l1(&m_lockParts); m_partsByCallsign.remove(callsign); m_aircraftSupportingParts.remove(callsign); }
|
||||
{ QWriteLocker l2(&m_lockSituations); m_situationsByCallsign.remove(callsign); }
|
||||
@@ -1147,16 +1225,16 @@ namespace BlackCore
|
||||
|
||||
// list from new to old
|
||||
QWriteLocker lock(&m_lockSituations);
|
||||
CAircraftSituationList &l = this->m_situationsByCallsign[callsign];
|
||||
l.push_frontMaxElements(situation, MaxSituationsPerCallsign);
|
||||
CAircraftSituationList &situationList = this->m_situationsByCallsign[callsign];
|
||||
situationList.push_frontMaxElements(situation, MaxSituationsPerCallsign);
|
||||
|
||||
// check sort order
|
||||
Q_ASSERT_X(l.size() < 2 || l[0].getMSecsSinceEpoch() >= l[1].getMSecsSinceEpoch(), Q_FUNC_INFO, "wrong sort order");
|
||||
Q_ASSERT_X(situationList.size() < 2 || situationList[0].getMSecsSinceEpoch() >= situationList[1].getMSecsSinceEpoch(), Q_FUNC_INFO, "wrong sort order");
|
||||
|
||||
// a full position update received after an interim position update should use the time offset of the interim position
|
||||
if (l.size() >= 2 && (l[0].isInterim() || l[1].isInterim()))
|
||||
if (situationList.size() >= 2 && (situationList[0].isInterim() || situationList[1].isInterim()))
|
||||
{
|
||||
l[0].setTimeOffsetMs(std::min(l[0].getTimeOffsetMs(), l[1].getTimeOffsetMs()));
|
||||
situationList[0].setTimeOffsetMs(std::min(situationList[0].getTimeOffsetMs(), situationList[1].getTimeOffsetMs()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1166,8 +1244,8 @@ namespace BlackCore
|
||||
|
||||
// list sorted from new to old
|
||||
QWriteLocker lock(&m_lockParts);
|
||||
CAircraftPartsList &l = this->m_partsByCallsign[callsign];
|
||||
l.push_frontMaxElements(parts, MaxPartsPerCallsign);
|
||||
CAircraftPartsList &partsList = this->m_partsByCallsign[callsign];
|
||||
partsList.push_frontMaxElements(parts, MaxPartsPerCallsign);
|
||||
|
||||
if (!m_aircraftSupportingParts.contains(callsign))
|
||||
{
|
||||
@@ -1175,6 +1253,6 @@ namespace BlackCore
|
||||
}
|
||||
|
||||
// check sort order
|
||||
Q_ASSERT_X(l.size() < 2 || l[0].getMSecsSinceEpoch() >= l[1].getMSecsSinceEpoch(), Q_FUNC_INFO, "wrong sort order");
|
||||
Q_ASSERT_X(partsList.size() < 2 || partsList[0].getMSecsSinceEpoch() >= partsList[1].getMSecsSinceEpoch(), Q_FUNC_INFO, "wrong sort order");
|
||||
}
|
||||
} // namespace
|
||||
|
||||
@@ -75,10 +75,13 @@ namespace BlackCore
|
||||
//! Constructor
|
||||
CAirspaceMonitor(BlackMisc::Simulation::IOwnAircraftProvider *ownAircraft, INetwork *network, QObject *parent);
|
||||
|
||||
//! \name IRemoteAircraftProvider overrides
|
||||
//! Log categories
|
||||
static const BlackMisc::CLogCategoryList &getLogCategories();
|
||||
|
||||
//! \ingroup remoteaircraftprovider
|
||||
//! @{
|
||||
virtual BlackMisc::Simulation::CSimulatedAircraftList getAircraftInRange() const override;
|
||||
virtual BlackMisc::Aviation::CCallsignSet getAircraftInRangeCallsigns() const override;
|
||||
virtual BlackMisc::Simulation::CSimulatedAircraft getAircraftInRangeForCallsign(const BlackMisc::Aviation::CCallsign &callsign) const override;
|
||||
virtual BlackMisc::Simulation::CAircraftModel getAircraftInRangeModelForCallsign(const BlackMisc::Aviation::CCallsign &callsign) const override;
|
||||
virtual int getAircraftInRangeCount() const override;
|
||||
@@ -93,6 +96,9 @@ namespace BlackCore
|
||||
virtual bool updateFastPositionEnabled(const BlackMisc::Aviation::CCallsign &callsign, bool enableFastPositonUpdates, const BlackMisc::CIdentifier &originator) override;
|
||||
virtual bool updateAircraftRendered(const BlackMisc::Aviation::CCallsign &callsign, bool rendered, const BlackMisc::CIdentifier &originator) override;
|
||||
virtual void updateMarkAllAsNotRendered(const BlackMisc::CIdentifier &originator) override;
|
||||
virtual void enableReverseLookupMessages(bool enabled) override;
|
||||
virtual bool isReverseLookupMessagesEnabled() const override;
|
||||
virtual BlackMisc::CStatusMessageList getReverseLookupMessages(const BlackMisc::Aviation::CCallsign &callsign) const override;
|
||||
//! @}
|
||||
|
||||
//! Returns the list of users we know about
|
||||
@@ -130,9 +136,6 @@ namespace BlackCore
|
||||
//! Returns the closest ATC station operating on the given frequency, if any
|
||||
BlackMisc::Aviation::CAtcStation getAtcStationForComUnit(const BlackMisc::Aviation::CComSystem &comSystem);
|
||||
|
||||
//! Logging for matching process (see why a model is matched like it is)
|
||||
void logMatchingProcess(bool log) { this->m_logMatchingProcess = log; }
|
||||
|
||||
//! Clear the contents
|
||||
void clear();
|
||||
|
||||
@@ -205,6 +208,7 @@ namespace BlackCore
|
||||
BlackMisc::Aviation::CAtcStationList m_atcStationsBooked; //!< booked ATC stations
|
||||
BlackMisc::Network::CClientList m_otherClients; //!< client informatiom, thread safe access required
|
||||
BlackMisc::Simulation::CSimulatedAircraftList m_aircraftInRange; //!< aircraft, thread safe access required
|
||||
QMap<BlackMisc::Aviation::CCallsign, BlackMisc::CStatusMessageList> m_reverseLookupMessages;
|
||||
|
||||
// hashs, because not sorted by key but keeping order
|
||||
CSituationsPerCallsign m_situationsByCallsign; //!< situations, for performance reasons per callsign, thread safe access required
|
||||
@@ -214,16 +218,17 @@ namespace BlackCore
|
||||
QMap<BlackMisc::Aviation::CCallsign, BlackMisc::Aviation::CFlightPlan> m_flightPlanCache; //!< flight plan information retrieved any cached
|
||||
QMap<BlackMisc::Aviation::CCallsign, BlackMisc::Simulation::CAircraftModel> m_modelTemporaryCache; //!< any model information recevived from network temporarily stored until it is "completed". Will be removed when aircraft is moved to aircraft in range
|
||||
|
||||
INetwork *m_network = nullptr;
|
||||
CAirspaceAnalyzer *m_analyzer = nullptr; //!< owned analyzer
|
||||
bool m_connected = false; //!< retrieve data
|
||||
bool m_logMatchingProcess = false; //!< shall we log. information about the matching process
|
||||
INetwork *m_network = nullptr; //!< corresponding network interface
|
||||
CAirspaceAnalyzer *m_analyzer = nullptr; //!< owned analyzer
|
||||
bool m_connected = false; //!< retrieve data
|
||||
bool m_enableReverseLookupMsgs = false; //!< shall we log. information about the matching process
|
||||
|
||||
// locks
|
||||
mutable QReadWriteLock m_lockSituations; //!< lock for situations: m_situationsByCallsign
|
||||
mutable QReadWriteLock m_lockParts; //!< lock for parts: m_partsByCallsign, m_aircraftSupportingParts
|
||||
mutable QReadWriteLock m_lockAircraft; //!< lock aircraft: m_aircraftInRange
|
||||
mutable QReadWriteLock m_lockClient; //!< lock clients: m_otherClients
|
||||
mutable QReadWriteLock m_lockMessages; //!< lock for messages
|
||||
|
||||
//! Remove ATC online stations
|
||||
void removeAllOnlineAtcStations();
|
||||
@@ -234,8 +239,8 @@ namespace BlackCore
|
||||
//! Remove all other clients
|
||||
void removeAllOtherClients();
|
||||
|
||||
//! Remove data from caches
|
||||
void removeFromAircraftCaches(const BlackMisc::Aviation::CCallsign &callsign);
|
||||
//! Remove data from caches and logs
|
||||
void removeFromAircraftCachesAndLogs(const BlackMisc::Aviation::CCallsign &callsign);
|
||||
|
||||
//! Schedule a "ready for model matching"
|
||||
void fireDelayedReadyForModelMatching(const BlackMisc::Aviation::CCallsign &callsign, int trial = 1, int delayMs = 2500);
|
||||
@@ -243,9 +248,6 @@ namespace BlackCore
|
||||
//! FSD or icao query received. Here we also replace the model with a model from DB if possible (reverse lookup)
|
||||
void icaoOrFsdDataReceived(const BlackMisc::Aviation::CCallsign &callsign, const QString &aircraftIcaoDesignator, const QString &airlineIcaoDesignator, const QString &livery, const QString &modelString, BlackMisc::Simulation::CAircraftModel::ModelType type);
|
||||
|
||||
//! Log.matching
|
||||
void logMatching(const QString &text) const;
|
||||
|
||||
//! Store an aircraft situation
|
||||
//! \threadsafe
|
||||
void storeAircraftSituation(const BlackMisc::Aviation::CAircraftSituation &situation);
|
||||
@@ -254,6 +256,18 @@ namespace BlackCore
|
||||
//! \threadsafe
|
||||
void storeAircraftParts(const BlackMisc::Aviation::CCallsign &callsign, const BlackMisc::Aviation::CAircraftParts &parts);
|
||||
|
||||
//! Reverse lookup messages
|
||||
//! \threadsafe
|
||||
void addReverseLookupMessages(const BlackMisc::Aviation::CCallsign &callsign, const BlackMisc::CStatusMessageList &messages);
|
||||
|
||||
//! Reverse lookup messages
|
||||
//! \threadsafe
|
||||
void addReverseLookupMessage(const BlackMisc::Aviation::CCallsign &callsign, const BlackMisc::CStatusMessage &message);
|
||||
|
||||
//! Reverse lookup messages
|
||||
//! \threadsafe
|
||||
void addReverseLookupMessage(const BlackMisc::Aviation::CCallsign &callsign, const QString &message, BlackMisc::CStatusMessage::StatusSeverity severity = BlackMisc::CStatusMessage::SeverityInfo);
|
||||
|
||||
private slots:
|
||||
//! Create aircraft in range, this is the only place where a new aircraft should be added
|
||||
void ps_aircraftUpdateReceived(const BlackMisc::Aviation::CAircraftSituation &situation, const BlackMisc::Aviation::CTransponder &transponder);
|
||||
|
||||
@@ -173,6 +173,9 @@ namespace BlackCore
|
||||
//! Aircraft list
|
||||
virtual BlackMisc::Simulation::CSimulatedAircraftList getAircraftInRange() const = 0;
|
||||
|
||||
//! Aircraft callsigns
|
||||
virtual BlackMisc::Aviation::CCallsignSet getAircraftInRangeCallsigns() const = 0;
|
||||
|
||||
//! Aircraft for given callsign
|
||||
virtual BlackMisc::Simulation::CSimulatedAircraft getAircraftInRangeForCallsign(const BlackMisc::Aviation::CCallsign &callsign) const = 0;
|
||||
|
||||
@@ -259,6 +262,15 @@ namespace BlackCore
|
||||
//! Change fast position updates
|
||||
virtual bool updateFastPositionEnabled(const BlackMisc::Aviation::CCallsign &callsign, bool enableFastPositionSending, const BlackMisc::CIdentifier &originator) = 0;
|
||||
|
||||
//! Get reverse lookup meesages
|
||||
virtual BlackMisc::CStatusMessageList getReverseLookupMessages(const BlackMisc::Aviation::CCallsign &callsign) const = 0;
|
||||
|
||||
//! Enabled reverse lookup logging?
|
||||
virtual bool isReverseLookupMessagesEnabled() const = 0;
|
||||
|
||||
//! Enable reverse lookup logging
|
||||
virtual void enableReverseLookupMessages(bool enabled) = 0;
|
||||
|
||||
//! Create dummy ATC stations for performance tests etc.
|
||||
virtual void testCreateDummyOnlineAtcStations(int number) = 0;
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
namespace BlackCore
|
||||
{
|
||||
|
||||
//! Empty context, used during shutdown/initialization
|
||||
class BLACKCORE_EXPORT CContextNetworkEmpty : public IContextNetwork
|
||||
{
|
||||
@@ -65,6 +64,13 @@ namespace BlackCore
|
||||
return BlackMisc::Simulation::CSimulatedAircraft();
|
||||
}
|
||||
|
||||
//! \copydoc IContextNetwork::getAircraftInRangeCallsigns()
|
||||
virtual BlackMisc::Aviation::CCallsignSet getAircraftInRangeCallsigns() const override
|
||||
{
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
return BlackMisc::Aviation::CCallsignSet();
|
||||
}
|
||||
|
||||
//! \copydoc IContextNetwork::getAircraftInRangeCount
|
||||
virtual int getAircraftInRangeCount() const override
|
||||
{
|
||||
@@ -288,6 +294,27 @@ namespace BlackCore
|
||||
return BlackMisc::Aviation::CCallsignSet();
|
||||
}
|
||||
|
||||
//! \copydoc IContextNetwork::getReverseLookupMessages
|
||||
virtual BlackMisc::CStatusMessageList getReverseLookupMessages(const BlackMisc::Aviation::CCallsign &callsign) const
|
||||
{
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
Q_UNUSED(callsign);
|
||||
return BlackMisc::CStatusMessageList();
|
||||
}
|
||||
|
||||
//! \copydoc IContextNetwork::isReverseLookupMessagesEnabled
|
||||
virtual bool isReverseLookupMessagesEnabled() const
|
||||
{
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
return false;
|
||||
}
|
||||
|
||||
//! \copydoc IContextNetwork::enableReverseLookupMessages
|
||||
virtual void enableReverseLookupMessages(bool enabled)
|
||||
{
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
Q_UNUSED(enabled);
|
||||
}
|
||||
};
|
||||
} // namespace
|
||||
|
||||
|
||||
@@ -482,6 +482,12 @@ namespace BlackCore
|
||||
return this->m_airspace->getAircraftInRange();
|
||||
}
|
||||
|
||||
CCallsignSet CContextNetwork::getAircraftInRangeCallsigns() const
|
||||
{
|
||||
if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
|
||||
return this->m_airspace->getAircraftInRangeCallsigns();
|
||||
}
|
||||
|
||||
int CContextNetwork::getAircraftInRangeCount() const
|
||||
{
|
||||
if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
|
||||
@@ -500,6 +506,24 @@ namespace BlackCore
|
||||
return this->m_airspace->getAircraftInRangeModelForCallsign(callsign);
|
||||
}
|
||||
|
||||
CStatusMessageList CContextNetwork::getReverseLookupMessages(const CCallsign &callsign) const
|
||||
{
|
||||
if (this->isDebugEnabled()) { BlackMisc::CLogMessage(this, BlackMisc::CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << callsign; }
|
||||
return this->m_airspace->getReverseLookupMessages(callsign);
|
||||
}
|
||||
|
||||
bool CContextNetwork::isReverseLookupMessagesEnabled() const
|
||||
{
|
||||
if (this->isDebugEnabled()) { BlackMisc::CLogMessage(this, BlackMisc::CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
|
||||
return this->m_airspace->isReverseLookupMessagesEnabled();
|
||||
}
|
||||
|
||||
void CContextNetwork::enableReverseLookupMessages(bool enabled)
|
||||
{
|
||||
if (this->isDebugEnabled()) { BlackMisc::CLogMessage(this, BlackMisc::CLogCategory::contextSlot()).debug() << enabled; }
|
||||
return this->m_airspace->enableReverseLookupMessages(enabled);
|
||||
}
|
||||
|
||||
CAtcStation CContextNetwork::getOnlineStationForCallsign(const CCallsign &callsign) const
|
||||
{
|
||||
if (this->isDebugEnabled()) { BlackMisc::CLogMessage(this, BlackMisc::CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << callsign; }
|
||||
@@ -643,5 +667,4 @@ namespace BlackCore
|
||||
rooms.push_back(s2.getVoiceRoom());
|
||||
return rooms;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -154,6 +154,10 @@ namespace BlackCore
|
||||
//! \ingroup remoteaircraftprovider
|
||||
virtual BlackMisc::Simulation::CSimulatedAircraftList getAircraftInRange() const override;
|
||||
|
||||
//! \copydoc BlackMisc::Simulation::IRemoteAircraftProvider::getAircraftInRangeCallsigns
|
||||
//! \ingroup remoteaircraftprovider
|
||||
virtual BlackMisc::Aviation::CCallsignSet getAircraftInRangeCallsigns() const override;
|
||||
|
||||
//! \copydoc BlackMisc::Simulation::IRemoteAircraftProvider::getAircraftInRangeCount
|
||||
//! \ingroup remoteaircraftprovider
|
||||
virtual int getAircraftInRangeCount() const override;
|
||||
@@ -166,6 +170,18 @@ namespace BlackCore
|
||||
//! \ingroup remoteaircraftprovider
|
||||
virtual BlackMisc::Simulation::CAircraftModel getAircraftInRangeModelForCallsign(const BlackMisc::Aviation::CCallsign &callsign) const override;
|
||||
|
||||
//! \copydoc BlackMisc::Simulation::IRemoteAircraftProvider::getReverseLookupMessages
|
||||
//! \ingroup remoteaircraftprovider
|
||||
virtual BlackMisc::CStatusMessageList getReverseLookupMessages(const BlackMisc::Aviation::CCallsign &callsign) const override;
|
||||
|
||||
//! \copydoc BlackMisc::Simulation::IRemoteAircraftProvider::isReverseLookupLoggingEnabled
|
||||
//! \ingroup remoteaircraftprovider
|
||||
virtual bool isReverseLookupMessagesEnabled() const override;
|
||||
|
||||
//! \copydoc BlackMisc::Simulation::IRemoteAircraftProvider::enableReverseLookupLogging
|
||||
//! \ingroup remoteaircraftprovider
|
||||
virtual void enableReverseLookupMessages(bool enabled) override;
|
||||
|
||||
//! \copydoc IContextNetwork::getOnlineStationForCallsign
|
||||
virtual BlackMisc::Aviation::CAtcStation getOnlineStationForCallsign(const BlackMisc::Aviation::CCallsign &callsign) const override;
|
||||
|
||||
|
||||
@@ -114,6 +114,11 @@ namespace BlackCore
|
||||
return this->m_dBusInterface->callDBusRet<BlackMisc::Simulation::CSimulatedAircraftList>(QLatin1Literal("getAircraftInRange"));
|
||||
}
|
||||
|
||||
CCallsignSet CContextNetworkProxy::getAircraftInRangeCallsigns() const
|
||||
{
|
||||
return this->m_dBusInterface->callDBusRet<BlackMisc::Aviation::CCallsignSet>(QLatin1Literal("getAircraftInRangeCallsigns"));
|
||||
}
|
||||
|
||||
int CContextNetworkProxy::getAircraftInRangeCount() const
|
||||
{
|
||||
return this->m_dBusInterface->callDBusRet<int>(QLatin1Literal("getAircraftInRangeCount"));
|
||||
@@ -209,6 +214,21 @@ namespace BlackCore
|
||||
return this->m_dBusInterface->callDBusRet<CCallsignSet>(QLatin1Literal("getFastPositionEnabledCallsigns"));
|
||||
}
|
||||
|
||||
CStatusMessageList CContextNetworkProxy::getReverseLookupMessages(const CCallsign &callsign) const
|
||||
{
|
||||
return this->m_dBusInterface->callDBusRet<CStatusMessageList>(QLatin1Literal("getReverseLookupMessages"), callsign);
|
||||
}
|
||||
|
||||
bool CContextNetworkProxy::isReverseLookupMessagesEnabled() const
|
||||
{
|
||||
return this->m_dBusInterface->callDBusRet<bool>(QLatin1Literal("isReverseLookupLoggingEnabled"));
|
||||
}
|
||||
|
||||
void CContextNetworkProxy::enableReverseLookupMessages(bool enabled)
|
||||
{
|
||||
this->m_dBusInterface->callDBus(QLatin1Literal("enableReverseLookupLogging"), enabled);
|
||||
}
|
||||
|
||||
void CContextNetworkProxy::testCreateDummyOnlineAtcStations(int number)
|
||||
{
|
||||
this->m_dBusInterface->callDBus(QLatin1Literal("testCreateDummyOnlineAtcStations"), number);
|
||||
|
||||
@@ -95,6 +95,9 @@ namespace BlackCore
|
||||
//! \copydoc IContextNetwork::getAircraftInRange()
|
||||
virtual BlackMisc::Simulation::CSimulatedAircraftList getAircraftInRange() const override;
|
||||
|
||||
//! \copydoc IContextNetwork::getAircraftInRangeCallsigns()
|
||||
virtual BlackMisc::Aviation::CCallsignSet getAircraftInRangeCallsigns() const override;
|
||||
|
||||
//! \copydoc IContextNetwork::getAircraftInRangeCount
|
||||
virtual int getAircraftInRangeCount() const override;
|
||||
|
||||
@@ -179,12 +182,20 @@ namespace BlackCore
|
||||
//! \copydoc IContextNetwork::getFastPositionEnabledCallsigns
|
||||
virtual BlackMisc::Aviation::CCallsignSet getFastPositionEnabledCallsigns() override;
|
||||
|
||||
//! \copydoc IContextNetwork::getReverseLookupMessages
|
||||
virtual BlackMisc::CStatusMessageList getReverseLookupMessages(const BlackMisc::Aviation::CCallsign &callsign) const override;
|
||||
|
||||
//! \copydoc IContextNetwork::isReverseLookupMessagesEnabled
|
||||
virtual bool isReverseLookupMessagesEnabled() const override;
|
||||
|
||||
//! \copydoc IContextNetwork::enableReverseLookupMessages
|
||||
virtual void enableReverseLookupMessages(bool enabled) override;
|
||||
|
||||
//! \copydoc IContextNetwork::testCreateDummyOnlineAtcStations
|
||||
virtual void testCreateDummyOnlineAtcStations(int number) override;
|
||||
|
||||
//! \copydoc IContextNetwork::testAddAircraftParts
|
||||
virtual void testAddAircraftParts(const BlackMisc::Aviation::CCallsign &callsign, const BlackMisc::Aviation::CAircraftParts &parts, bool incremental) override;
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -76,9 +76,9 @@ namespace BlackCore
|
||||
this->initDBusConnection(dbusAddress);
|
||||
if (!this->m_dbusConnection.isConnected())
|
||||
{
|
||||
QString notConnected("DBus connection failed:");
|
||||
QString e = this->m_dbusConnection.lastError().message();
|
||||
if (!e.isEmpty()) notConnected.append(" ").append(e);
|
||||
QString notConnected("DBus connection failed: ");
|
||||
const QString e = this->m_dbusConnection.lastError().message();
|
||||
if (!e.isEmpty()) { notConnected.append(e); }
|
||||
Q_ASSERT_X(false, "CRuntime::init", notConnected.toUtf8().constData());
|
||||
CLogMessage(this).error(notConnected);
|
||||
}
|
||||
|
||||
@@ -28,6 +28,12 @@ namespace BlackMisc
|
||||
return this->m_remoteAircraftProvider->getAircraftInRangeCount();
|
||||
}
|
||||
|
||||
CCallsignSet CRemoteAircraftAware::getAircraftInRangeCallsigns() const
|
||||
{
|
||||
Q_ASSERT_X(this->m_remoteAircraftProvider, Q_FUNC_INFO, "No object available");
|
||||
return this->m_remoteAircraftProvider->getAircraftInRangeCallsigns();
|
||||
}
|
||||
|
||||
CSimulatedAircraft CRemoteAircraftAware::getAircraftInRangeForCallsign(const CCallsign &callsign) const
|
||||
{
|
||||
Q_ASSERT_X(this->m_remoteAircraftProvider, Q_FUNC_INFO, "No object available");
|
||||
|
||||
@@ -64,6 +64,10 @@ namespace BlackMisc
|
||||
//! \threadsafe
|
||||
virtual int getAircraftInRangeCount() const = 0;
|
||||
|
||||
//! Unique callsigns for aircraft in range
|
||||
//! \threadsafe
|
||||
virtual BlackMisc::Aviation::CCallsignSet getAircraftInRangeCallsigns() const = 0;
|
||||
|
||||
//! Current snapshot
|
||||
//! \threadsafe
|
||||
virtual BlackMisc::Simulation::CAirspaceAircraftSnapshot getLatestAirspaceAircraftSnapshot() const = 0;
|
||||
@@ -116,6 +120,18 @@ namespace BlackMisc
|
||||
//! \threadsafe
|
||||
virtual bool updateFastPositionEnabled(const BlackMisc::Aviation::CCallsign &callsign, bool enableFastPositonUpdates, const BlackMisc::CIdentifier &originator) = 0;
|
||||
|
||||
//! Get reverse lookup meesages
|
||||
//! \threadsafe
|
||||
virtual BlackMisc::CStatusMessageList getReverseLookupMessages(const BlackMisc::Aviation::CCallsign &callsign) const = 0;
|
||||
|
||||
//! Enabled reverse lookup logging?
|
||||
//! \threadsafe
|
||||
virtual bool isReverseLookupMessagesEnabled() const = 0;
|
||||
|
||||
//! Enable reverse lookup logging
|
||||
//! \threadsafe
|
||||
virtual void enableReverseLookupMessages(bool enabled) = 0;
|
||||
|
||||
//! Destructor
|
||||
virtual ~IRemoteAircraftProvider() {}
|
||||
|
||||
@@ -129,7 +145,6 @@ namespace BlackMisc
|
||||
std::function<void(const BlackMisc::Aviation::CCallsign &)> removedAircraftSlot,
|
||||
std::function<void(const BlackMisc::Simulation::CAirspaceAircraftSnapshot &)> aircraftSnapshot
|
||||
) = 0;
|
||||
|
||||
};
|
||||
|
||||
//! Class which can be directly used to access an \sa IRemoteAircraftProvider object
|
||||
@@ -142,6 +157,9 @@ namespace BlackMisc
|
||||
//! \copydoc IRemoteAircraftProvider::getAircraftInRangeCount
|
||||
int getAircraftInRangeCount() const;
|
||||
|
||||
//! \copydoc IRemoteAircraftProvider::getAircraftInRangeCallsigns
|
||||
BlackMisc::Aviation::CCallsignSet getAircraftInRangeCallsigns() const;
|
||||
|
||||
//! \copydoc IRemoteAircraftProvider::getAircraftInRangeForCallsign
|
||||
virtual BlackMisc::Simulation::CSimulatedAircraft getAircraftInRangeForCallsign(const Aviation::CCallsign &callsign) const;
|
||||
|
||||
|
||||
@@ -18,20 +18,11 @@
|
||||
|
||||
#include <QHash>
|
||||
|
||||
namespace BlackMisc {
|
||||
namespace Aviation {
|
||||
class CAircraftParts;
|
||||
class CAircraftSituation;
|
||||
} // namespace Aviation
|
||||
} // namespace BlackMisc
|
||||
|
||||
using namespace BlackMisc::Aviation;
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Simulation
|
||||
{
|
||||
|
||||
CRemoteAircraftProviderDummy::CRemoteAircraftProviderDummy(QObject *parent) : QObject(parent)
|
||||
{ }
|
||||
|
||||
@@ -45,6 +36,11 @@ namespace BlackMisc
|
||||
return m_aircraft.size();
|
||||
}
|
||||
|
||||
CCallsignSet CRemoteAircraftProviderDummy::getAircraftInRangeCallsigns() const
|
||||
{
|
||||
return m_aircraft.getCallsigns();
|
||||
}
|
||||
|
||||
CSimulatedAircraft CRemoteAircraftProviderDummy::getAircraftInRangeForCallsign(const CCallsign &callsign) const
|
||||
{
|
||||
return m_aircraft.findFirstByCallsign(callsign);
|
||||
@@ -143,6 +139,22 @@ namespace BlackMisc
|
||||
this->m_aircraft.markAllAsNotRendered();
|
||||
}
|
||||
|
||||
CStatusMessageList CRemoteAircraftProviderDummy::getReverseLookupMessages(const CCallsign &callsign) const
|
||||
{
|
||||
Q_UNUSED(callsign);
|
||||
return CStatusMessageList();
|
||||
}
|
||||
|
||||
bool CRemoteAircraftProviderDummy::isReverseLookupMessagesEnabled() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void CRemoteAircraftProviderDummy::enableReverseLookupMessages(bool enabled)
|
||||
{
|
||||
Q_UNUSED(enabled);
|
||||
}
|
||||
|
||||
void CRemoteAircraftProviderDummy::insertNewSituation(const CAircraftSituation &situation)
|
||||
{
|
||||
this->m_situations.push_front(situation);
|
||||
|
||||
@@ -59,6 +59,9 @@ namespace BlackMisc
|
||||
//! IRemoteAircraftProvider::getAircraftInRangeCount
|
||||
virtual int getAircraftInRangeCount() const override;
|
||||
|
||||
//! IRemoteAircraftProvider::getAircraftInRangeCallsigns
|
||||
virtual Aviation::CCallsignSet getAircraftInRangeCallsigns() const override;
|
||||
|
||||
//! IRemoteAircraftProvider::getAircraftInRangeForCallsign
|
||||
virtual BlackMisc::Simulation::CSimulatedAircraft getAircraftInRangeForCallsign(const BlackMisc::Aviation::CCallsign &callsign) const override;
|
||||
|
||||
@@ -107,6 +110,15 @@ namespace BlackMisc
|
||||
//! \copydoc IRemoteAircraftProvider::updateMarkAllAsNotRendered
|
||||
virtual void updateMarkAllAsNotRendered(const BlackMisc::CIdentifier &originator) override;
|
||||
|
||||
//! \copydoc IRemoteAircraftProvider::getReverseLookupMessages
|
||||
virtual BlackMisc::CStatusMessageList getReverseLookupMessages(const BlackMisc::Aviation::CCallsign &callsign) const override;
|
||||
|
||||
//! \copydoc IRemoteAircraftProvider::isReverseLookupMessagesEnabled
|
||||
virtual bool isReverseLookupMessagesEnabled() const override;
|
||||
|
||||
//! \copydoc IRemoteAircraftProvider::enableReverseLookupMessages
|
||||
virtual void enableReverseLookupMessages(bool enabled) override;
|
||||
|
||||
//! For testing, add new situation and fire signals
|
||||
void insertNewSituation(const BlackMisc::Aviation::CAircraftSituation &situation);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user