Skip to content

Commit

Permalink
Edit missed approach alarm scratchpad behaviour
Browse files Browse the repository at this point in the history
* Immediately clear message strings to avoid clogging space
  • Loading branch information
EightSmart committed Jul 14, 2024
1 parent f0de3c1 commit d26cf7d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
7 changes: 5 additions & 2 deletions MissedApproach/MissedApproachAlarm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -461,9 +461,10 @@ void MissedApproachAlarm::OnFlightPlanControllerAssignedDataUpdate(CFlightPlan F
MissedApproachPlugin ma;
CFlightPlanData data = FlightPlan.GetFlightPlanData();
CFlightPlanControllerAssignedData controllerData = FlightPlan.GetControllerAssignedData();
string scratchPadString = controllerData.GetScratchPadString();

//Filter from scratchpad message
if (strstr(controllerData.GetScratchPadString(), "\\MISS") == NULL) return;
if (scratchPadString.find("MISAP_") == string::npos) return;

//Handle tower case first
if (!selectedAcftData.empty()) {
Expand All @@ -476,7 +477,9 @@ void MissedApproachAlarm::OnFlightPlanControllerAssignedDataUpdate(CFlightPlan F
//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());
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());
}
Expand Down
25 changes: 13 additions & 12 deletions MissedApproach/MissedApproachPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ void MissedApproachPlugin::initMissedApproach(const char* callsign) {
data = fpl.GetFlightPlanData();
controllerData = fpl.GetControllerAssignedData();
string buf = controllerData.GetScratchPadString();
buf.append("\\MISS");
buf.insert(0, "MISAP_");
controllerData.SetScratchPadString(buf.c_str());
}

Expand All @@ -53,11 +53,9 @@ void MissedApproachPlugin::ackMissedApproach(const char* callsign) {
controllerData = fpl.GetControllerAssignedData();

string buf = controllerData.GetScratchPadString();
if (buf.find("\\MISS") != string::npos) {
buf.append("\\ACK\\");
buf.append(myself.GetPositionId());
controllerData.SetScratchPadString(buf.c_str());
}
buf.append("MISAP-ACK_");
buf.append(myself.GetPositionId());
controllerData.SetScratchPadString(buf.c_str());
//couldn't find it, handle error
}

Expand All @@ -69,15 +67,15 @@ void MissedApproachPlugin::resetMissedApproach(const char* callsign) {
controllerData = fpl.GetControllerAssignedData();
string buf = controllerData.GetScratchPadString();
size_t index;
string miss = "\\MISS";
string ack = "\\ACK";
string miss = "MISAP_";
string ack = "ACK_";
index = buf.find(miss);
if (index != string::npos) {
buf.erase(index, miss.length());
}
index = buf.find(ack);
if (index != string::npos) {
buf.erase(index, ack.length()+4);
buf.erase(index, ack.length()+3);
}
controllerData.SetScratchPadString(buf.c_str());
//couldn't find it, handle error
Expand Down Expand Up @@ -121,10 +119,13 @@ bool MissedApproachPlugin::matchArrivalAirport(const char* arrivalArpt) {

const char* MissedApproachPlugin::checkForAck(const char* callsign) {
CFlightPlanControllerAssignedData controllerData = FlightPlanSelect(callsign).GetControllerAssignedData();
const char* ptr = strstr(controllerData.GetScratchPadString(), "\\MISS\\ACK\\");
const char* ptr = strstr(controllerData.GetScratchPadString(), "MISAP-ACK_");
if (ptr != NULL) {
ptr = ptr + strlen("\\MISS\\ACK\\");
return (ptr != NULL && strlen(ptr) == 3) ? ptr : "???";
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) == 3) ? ptr : "??";
}
return NULL;
}

0 comments on commit d26cf7d

Please sign in to comment.