Skip to content

Commit

Permalink
Error color yellow on Forbidden Airways
Browse files Browse the repository at this point in the history
Currently only hardcoded
  • Loading branch information
hpeter2 committed Mar 17, 2022
1 parent 19a0acb commit c789e90
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
1 change: 1 addition & 0 deletions Constant.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
21 changes: 17 additions & 4 deletions analyzeFP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand All @@ -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
Expand Down Expand Up @@ -523,8 +529,10 @@ void CVFPCPlugin::checkFPDetail() {
sendMessage(messageBuffer["CS"], buffer);
}

string CVFPCPlugin::getFails(vector<string> messageBuffer) {
pair<string, int> CVFPCPlugin::getFails(map<string, string> messageBuffer) {
vector<string> fails;
int failCount = 0;

fails.push_back("FPL");

if (messageBuffer.find("STATUS") != messageBuffer.end()) {
Expand All @@ -542,24 +550,29 @@ string CVFPCPlugin::getFails(vector<string> 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<string, int>(fails[couldnt], failCount);
}

void CVFPCPlugin::OnTimer(int Counter) {
Expand Down
2 changes: 1 addition & 1 deletion analyzeFP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ class CVFPCPlugin :

virtual void checkFPDetail();

virtual string getFails(map<string, string> messageBuffer);
virtual pair<string, int> getFails(map<string, string> messageBuffer);

virtual void OnTimer(int Count);

Expand Down

0 comments on commit c789e90

Please sign in to comment.