Skip to content

Commit

Permalink
Allow multiple missed approach acknowledgements
Browse files Browse the repository at this point in the history
* Avoid cluttering scratchpad string
* Refactor checking to be called on controller data update instead of screen refresh
  • Loading branch information
EightSmart committed Jul 21, 2024
1 parent 02b45be commit b6d7e16
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 35 deletions.
45 changes: 22 additions & 23 deletions MissedApproach/MissedApproachAlarm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -361,13 +361,6 @@ void MissedApproachAlarm::drawIndicatorUnit(HDC hDC, HKCPDisplay* Display) {
}
else {
dc.FillSolidRect(buttonReset, BUTTON_RED_ON);
//Check for acknowledgement
const char* ackStationBuf = ma.checkForAck(selectedAcftData[0].c_str());
if (!selectedAcftData.empty() && ackStationBuf != NULL) {
actButtonState = 2;
resetButtonState = 1;
ackStation = ackStationBuf;
}
}
dc.SelectObject(&fontLabelSmall);
dc.SetTextColor(BLACK);
Expand Down Expand Up @@ -464,25 +457,31 @@ void MissedApproachAlarm::OnFlightPlanControllerAssignedDataUpdate(CFlightPlan F
CFlightPlanControllerAssignedData controllerData = FlightPlan.GetControllerAssignedData();
string scratchPadString = controllerData.GetScratchPadString();

//Filter from scratchpad message
if (scratchPadString.find("MISAP_") == string::npos) return;

//Handle tower case first
if (!selectedAcftData.empty()) {
if (ma.matchArrivalAirport(selectedAcftData[1].c_str())) {
actButtonState = 1;
resetButtonState = -1;
if (scratchPadString.find("MISAP-ACK_") != string::npos) {
//Check for acknowledgement (Tower)
if (!selectedAcftData.empty()) {
actButtonState = 2;
resetButtonState = 1;
ackStation = ma.checkForAck(scratchPadString);
}
return;
scratchPadString.erase(0, strlen("MISAP-ACK_AP"));
controllerData.SetScratchPadString(scratchPadString.c_str());
}
//Don't add to vector unless runway is selected and active
if (find(activeMAPPRunways.begin(), activeMAPPRunways.end(), data.GetArrivalRwy()) == activeMAPPRunways.end()) return;
else if (scratchPadString.find("MISAP_") != string::npos) {
// Trigger Alarm (TWR)
actButtonState = 1;
resetButtonState = -1;

scratchPadString.erase(0, strlen("MISAP_"));
controllerData.SetScratchPadString(scratchPadString.c_str());
; missedAcftData.push_back(FlightPlan.GetCallsign());
missedAcftData.push_back(data.GetDestination());
missedAcftData.push_back(data.GetArrivalRwy());
// Trigger alarm (APP)
scratchPadString.erase(0, strlen("MISAP_"));
controllerData.SetScratchPadString(scratchPadString.c_str());

// Don't add to vector unless runway is selected and active
if (find(activeMAPPRunways.begin(), activeMAPPRunways.end(), data.GetArrivalRwy()) == activeMAPPRunways.end()) return;
missedAcftData.push_back(FlightPlan.GetCallsign());
missedAcftData.push_back(data.GetDestination());
missedAcftData.push_back(data.GetArrivalRwy());
}
}

//---OnMoveScreenObject---------------------------------------------
Expand Down
13 changes: 2 additions & 11 deletions MissedApproach/MissedApproachPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,6 @@ bool MissedApproachPlugin::matchArrivalAirport(const char* arrivalArpt) {
return true;
}

const char* MissedApproachPlugin::checkForAck(const char* callsign) {
CFlightPlanControllerAssignedData controllerData = FlightPlanSelect(callsign).GetControllerAssignedData();
const char* ptr = strstr(controllerData.GetScratchPadString(), "MISAP-ACK_");
if (ptr != NULL) {
string scratchPadString = ptr;
ptr = ptr + strlen("MISAP-ACK_");
scratchPadString.erase(0, strlen("MISAP-ACK_AP"));
controllerData.SetScratchPadString(scratchPadString.c_str());
return (ptr != NULL && strlen(ptr) == 2) ? ptr : "??";
}
return NULL;
string MissedApproachPlugin::checkForAck(string scratchPadString) {
return scratchPadString.substr(10, 2);
}
2 changes: 1 addition & 1 deletion MissedApproach/MissedApproachPlugin.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ class MissedApproachPlugin :

bool matchArrivalAirport(const char* arrivalArpt);

const char* checkForAck(const char* callsign);
string checkForAck(string scratchPadString);

};

0 comments on commit b6d7e16

Please sign in to comment.