1
0
Fork 0

Better Traffic performance data warnings.

This commit is contained in:
James Turner 2015-12-22 15:15:09 -06:00
parent 7a69b9beff
commit 7644c74df9
3 changed files with 17 additions and 3 deletions

View file

@ -56,7 +56,8 @@ using std::endl;
FGAIAircraft::FGAIAircraft(FGAISchedule *ref) :
/* HOT must be disabled for AI Aircraft,
* otherwise traffic detection isn't working as expected.*/
FGAIBase(otAircraft, false)
FGAIBase(otAircraft, false),
_performance(0)
{
trafficRef = ref;
if (trafficRef) {
@ -96,6 +97,8 @@ FGAIAircraft::FGAIAircraft(FGAISchedule *ref) :
PerformanceDB* perfDB = globals->get_subsystem<PerformanceDB>();
if (perfDB) {
_performance = perfDB->getDefaultPerformance();
} else {
SG_LOG(SG_AI, SG_ALERT, "no performance DB found");
}
dt = 0;

View file

@ -80,8 +80,6 @@ PerformanceData* PerformanceDB::getDataFor(const string& acType, const string& a
return it->second;
}
SG_LOG(SG_AI, SG_INFO, "no performance data for " << acType);
it = _db.find(acClass);
if (it == _db.end()) {
return getDefaultPerformance();

View file

@ -67,6 +67,8 @@
#include <AIModel/AIAircraft.hxx>
#include <AIModel/AIFlightPlan.hxx>
#include <AIModel/AIBase.hxx>
#include <AIModel/performancedb.hxx>
#include <Airports/airport.hxx>
#include <Main/fg_init.hxx>
#include <Main/globals.hxx>
@ -317,7 +319,9 @@ private:
if (!FGAISchedule::validModelPath(mdl)) {
missingModels.insert(mdl);
#if defined(ENABLE_DEV_WARNINGS)
SG_LOG(SG_AI, SG_WARN, "TrafficMgr: Missing model path:" << mdl);
#endif
requiredAircraft = homePort = "";
return;
}
@ -579,9 +583,16 @@ void FGTrafficManager::finishInit()
SG_LOG(SG_AI, SG_INFO, "finishing AI-Traffic init");
loadHeuristics();
PerformanceDB* perfDB = globals->get_subsystem<PerformanceDB>();
// Do sorting and scoring separately, to take advantage of the "homeport" variable
BOOST_FOREACH(FGAISchedule* schedule, scheduledAircraft) {
schedule->setScore();
#if defined(ENABLE_DEV_WARNINGS)
if (!perfDB->havePerformanceDataForAircraftType(schedule->getAircraft())) {
SG_LOG(SG_AI, SG_WARN, "AI-Traffic: schedule aircraft missing performance data:" << schedule->getAircraft());
}
#endif
}
sort(scheduledAircraft.begin(), scheduledAircraft.end(),
@ -626,8 +637,10 @@ void FGTrafficManager::loadHeuristics()
break;
HeuristicMapIterator itr = heurMap.find(h.registration);
if (itr != heurMap.end()) {
#if defined(ENABLE_DEV_WARNINGS)
SG_LOG(SG_AI, SG_WARN,"Traffic Manager Warning: found duplicate tailnumber " <<
h.registration << " for AI aircraft");
#endif
} else {
heurMap[h.registration] = h;
}