refs #613, logging for model matching

This commit is contained in:
Klaus Basan
2016-03-07 23:28:09 +01:00
committed by Mathew Sutcliffe
parent c36028ca9c
commit 3083f30576
3 changed files with 30 additions and 8 deletions

View File

@@ -618,6 +618,7 @@ namespace BlackCore
Q_ASSERT_X(!m_serverSupportsNameQuery || remoteAircraft.hasValidRealName(), Q_FUNC_INFO, "invalid model data");
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()));
}
void CAirspaceMonitor::ps_atcPositionUpdate(const CCallsign &callsign, const BlackMisc::PhysicalQuantities::CFrequency &frequency, const CCoordinateGeodetic &position, const BlackMisc::PhysicalQuantities::CLength &range)
@@ -786,7 +787,6 @@ namespace BlackCore
Q_ASSERT_X(CThreadUtils::isCurrentThreadObjectThread(this), Q_FUNC_INFO, "not in main thread");
BLACK_VERIFY_X(callsign.isValid(), Q_FUNC_INFO, "invalid callsign");
if (!callsign.isValid()) { return; }
if (!this->m_connected) { return; }
if (aircraftIcaoDesignator.isEmpty() && airlineIcaoDesignator.isEmpty() && livery.isEmpty()) { return; }
@@ -804,17 +804,17 @@ namespace BlackCore
model = m_modelCache[callsign];
}
// already matched with DB?
// already matched with DB? Means we already have DB data in cache or existing model
if (!model.canInitializeFromFsd()) { return; }
// update model string if not yet existing
if (!model.hasModelString() && !modelString.isEmpty()) { model.setModelString(modelString); }
if (model.getModelType() == CAircraftModel::TypeUnknown || model.getModelType() == CAircraftModel::TypeQueriedFromNetwork)
{
model.setModelType(type); // update type if no type yet
}
// we have no DB model yet, but do we have model string?
if (!model.hasModelString() && !modelString.isEmpty()) { model.setModelString(modelString); }
if (model.hasModelString())
{
// if we find the model here we have a fully defined DB model
@@ -894,6 +894,13 @@ namespace BlackCore
} // lock
}
void CAirspaceMonitor::logMatching(const QString &text) const
{
if (text.isEmpty()) { return; }
if (!this->m_logMatchingProcess) { return; }
CLogMessage(this).info(text);
}
void CAirspaceMonitor::ps_aircraftUpdateReceived(const CAircraftSituation &situation, const CTransponder &transponder)
{
Q_ASSERT_X(CThreadUtils::isCurrentThreadObjectThread(this), Q_FUNC_INFO, "Called in different thread");

View File

@@ -130,6 +130,9 @@ 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();
@@ -214,14 +217,15 @@ namespace BlackCore
CPartsPerCallsign m_partsByCallsign; //!< parts, for performance reasons per callsign, thread safe access required
BlackMisc::Aviation::CCallsignSet m_aircraftSupportingParts; //!< aircraft supporting parts, thread safe access required
QMap<BlackMisc::Aviation::CCallsign, BlackMisc::Aviation::CFlightPlan> m_flightPlanCache;
QMap<BlackMisc::Aviation::CCallsign, BlackMisc::Simulation::CAircraftModel> m_modelCache; //!< any model information recevived from network temporarily stored until it is "completed". Will be removed when aircraft is moved to aircraft in range
QMap<BlackMisc::Aviation::CCallsign, BlackMisc::Aviation::CFlightPlan> m_flightPlanCache; //!< flight plan information retrieved any cached
QMap<BlackMisc::Aviation::CCallsign, BlackMisc::Simulation::CAircraftModel> m_modelCache; //!< 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_serverSupportsNameQuery = false; //!< not all servers support name query
bool m_connected = false; //!< retrieve data
bool m_sendInterimPositions = false;
bool m_sendInterimPositions = false; //!< send interim positions to other clients
bool m_logMatchingProcess = false; //!< shall we log. information about the matching process
QTimer m_interimPositionUpdateTimer;
// locks
@@ -241,12 +245,15 @@ namespace BlackCore
//! Remove data from caches
void removeFromAircraftCaches(const BlackMisc::Aviation::CCallsign &callsign);
//! Schedule a ready for model matching
//! Schedule a "ready for model matching"
void fireDelayedReadyForModelMatching(const BlackMisc::Aviation::CCallsign &callsign, int trial = 1, int delayMs = 2500);
//! FSD or icao query received
//! 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);

View File

@@ -99,6 +99,13 @@ namespace BlackMisc
return cat;
}
//! Matching
static const CLogCategory &matching()
{
static const CLogCategory cat { "swift.matching" };
return cat;
}
//! Webservice with swift DB
static const CLogCategory &swiftDbWebservice()
{
@@ -121,6 +128,7 @@ namespace BlackMisc
download(),
webservice(),
mapping(),
matching(),
swiftDbWebservice(),
};
return cats;