From c789e90e59c8abdc9477e1fa2c0d94902f37f359 Mon Sep 17 00:00:00 2001 From: hpeter Date: Thu, 17 Mar 2022 18:39:07 +0100 Subject: [PATCH] Error color yellow on Forbidden Airways Currently only hardcoded --- Constant.hpp | 1 + analyzeFP.cpp | 21 +++++++++++++++++---- analyzeFP.hpp | 2 +- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/Constant.hpp b/Constant.hpp index 1541e83..9e81f57 100644 --- a/Constant.hpp +++ b/Constant.hpp @@ -12,6 +12,7 @@ const int TAG_FUNC_ON_OFF = 102; const COLORREF TAG_GREEN = RGB(0, 190, 0); const COLORREF TAG_GREY = RGB(128, 128, 128); const COLORREF TAG_RED = RGB(190, 0, 0); +const COLORREF TAG_YELLOW = RGB(220, 220, 0); inline static bool startsWith(const char *pre, const char *str) { diff --git a/analyzeFP.cpp b/analyzeFP.cpp index 6e4127b..8037651 100644 --- a/analyzeFP.cpp +++ b/analyzeFP.cpp @@ -433,7 +433,12 @@ void CVFPCPlugin::OnGetTagItem(CFlightPlan FlightPlan, CRadarTarget RadarTarget, strcpy_s(sItemString, 16, "OK!"); } else { - string code = getFails(messageBuffer); + string code; int count; + tie(code, count) = getFails(messageBuffer); + + if (messageBuffer["FORBIDDEN_FL"].find_first_of("Failed") == 0 && count == 1) + *pRGB = TAG_YELLOW; + else *pRGB = TAG_RED; strcpy_s(sItemString, 16, code.c_str()); } @@ -449,7 +454,8 @@ void CVFPCPlugin::OnGetTagItem(CFlightPlan FlightPlan, CRadarTarget RadarTarget, *pRGB = TAG_RED; if (ItemCode == TAG_ITEM_FPCHECK_IF_FAILED) { - string code = getFails(messageBuffer); + string code; int count; + tie(code, count) = getFails(messageBuffer); strcpy_s(sItemString, 16, code.c_str()); } else @@ -523,8 +529,10 @@ void CVFPCPlugin::checkFPDetail() { sendMessage(messageBuffer["CS"], buffer); } -string CVFPCPlugin::getFails(vector messageBuffer) { +pair CVFPCPlugin::getFails(map messageBuffer) { vector fails; + int failCount = 0; + fails.push_back("FPL"); if (messageBuffer.find("STATUS") != messageBuffer.end()) { @@ -542,24 +550,29 @@ string CVFPCPlugin::getFails(vector messageBuffer) { if (messageBuffer["DIRECTION"].find_first_of("Failed") == 0) { fails.push_back("E/O"); + failCount++; } if (messageBuffer["MIN_FL"].find_first_of("Failed") == 0) { fails.push_back("MIN"); + failCount++; } if (messageBuffer["MAX_FL"].find_first_of("Failed") == 0) { fails.push_back("MAX"); + failCount++; } if (messageBuffer["FORBIDDEN_FL"].find_first_of("Failed") == 0) { fails.push_back("FLR"); + failCount++; } if (messageBuffer["NAVIGATION"].find_first_of("Failed") == 0) { fails.push_back("NAV"); + failCount++; } std::size_t couldnt = disCount; while (couldnt >= fails.size()) couldnt -= fails.size(); - return fails[couldnt]; + return pair(fails[couldnt], failCount); } void CVFPCPlugin::OnTimer(int Counter) { diff --git a/analyzeFP.hpp b/analyzeFP.hpp index 0b05909..93f5120 100644 --- a/analyzeFP.hpp +++ b/analyzeFP.hpp @@ -119,7 +119,7 @@ class CVFPCPlugin : virtual void checkFPDetail(); - virtual string getFails(map messageBuffer); + virtual pair getFails(map messageBuffer); virtual void OnTimer(int Count);