Skip to content

Commit

Permalink
Fix bug when deleting speed constraints
Browse files Browse the repository at this point in the history
  • Loading branch information
BlueberryKing committed Jun 18, 2022
1 parent 24297b9 commit 2b808e0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -468,17 +468,10 @@ class CDUFlightPlanPage {
});
}

const flightPhaseIsBeyondDescent = mcdu.flightPhaseManager.phase >= FmgcFlightPhases.DESCENT;

let isConsideredDescentWaypoint = flightPhaseIsBeyondDescent;
if (verticalWaypoint) {
isConsideredDescentWaypoint = isConsideredDescentWaypoint || verticalWaypoint.distanceToTopOfDescent < 0;
}

addRskAt(rowI, () => mcdu.getDelaySwitchPage(),
(value, scratchpadCallback) => {
if (value === "") {
CDUVerticalRevisionPage.ShowPage(mcdu, wp, verticalWaypoint, isConsideredDescentWaypoint);
CDUVerticalRevisionPage.ShowPage(mcdu, wp, verticalWaypoint);
} else if (value === FMCMainDisplay.clrValue) {
mcdu.setScratchpadMessage(NXSystemMessages.notAllowed);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const WaypointConstraintType = Object.freeze({
});

class CDUVerticalRevisionPage {
static ShowPage(mcdu, waypoint, verticalWaypoint, isDescentWaypoint, confirmSpeed = undefined, confirmAlt = undefined, confirmCode = undefined) {
static ShowPage(mcdu, waypoint, verticalWaypoint, confirmSpeed = undefined, confirmAlt = undefined, confirmCode = undefined) {
const waypointInfo = waypoint.infos;
if (waypointInfo instanceof WayPointInfo) {
mcdu.clearDisplay();
Expand Down Expand Up @@ -118,7 +118,7 @@ class CDUVerticalRevisionPage {
}
mcdu.onLeftInput[3] = (value, scratchpadCallback) => {
if (mcdu.setPerfApprQNH(value)) {
CDUVerticalRevisionPage.ShowPage(mcdu, waypoint, confirmSpeed, confirmAlt, confirmCode);
CDUVerticalRevisionPage.ShowPage(mcdu, waypoint, verticalWaypoint, confirmSpeed, confirmAlt, confirmCode);
} else {
scratchpadCallback();
}
Expand Down Expand Up @@ -184,7 +184,7 @@ class CDUVerticalRevisionPage {
}
mcdu.descentSpeedLimitPilot = false;
}
CDUVerticalRevisionPage.ShowPage(mcdu, waypoint, verticalWaypoint, isDescentWaypoint);
CDUVerticalRevisionPage.ShowPage(mcdu, waypoint, verticalWaypoint);
return;
}

Expand Down Expand Up @@ -215,15 +215,15 @@ class CDUVerticalRevisionPage {
mcdu.descentSpeedLimitAlt = alt;
mcdu.descentSpeedLimitPilot = true;
}
CDUVerticalRevisionPage.ShowPage(mcdu, waypoint, verticalWaypoint, isDescentWaypoint);
CDUVerticalRevisionPage.ShowPage(mcdu, waypoint, verticalWaypoint);
return;
}; // SPD LIM
mcdu.onRightInput[1] = () => {}; // RTA
mcdu.onLeftInput[2] = async (value, scratchpadCallback) => {
if (value === FMCMainDisplay.clrValue) {
mcdu.flightPlanManager.setWaypointSpeed(-1, wpIndex, () => {
this.ShowPage(mcdu, waypoint);
});
}, constraintType === WaypointConstraintType.DES);
return;
}

Expand All @@ -242,20 +242,20 @@ class CDUVerticalRevisionPage {
}

if (constraintType === WaypointConstraintType.Unknown) {
CDUVerticalRevisionPage.ShowPage(mcdu, waypoint, verticalWaypoint, isDescentWaypoint, speed);
CDUVerticalRevisionPage.ShowPage(mcdu, waypoint, verticalWaypoint, speed);
return;
}

mcdu.flightPlanManager.setWaypointSpeed(speed, wpIndex, () => {
this.ShowPage(mcdu, waypoint, verticalWaypoint, isDescentWaypoint);
this.ShowPage(mcdu, waypoint, verticalWaypoint);
}, constraintType === WaypointConstraintType.DES);
}; // SPD CSTR
mcdu.onRightInput[2] = (value, scratchpadCallback) => {
if (value === FMCMainDisplay.clrValue) {
mcdu.flightPlanManager.setLegAltitudeDescription(waypoint, 0);
mcdu.flightPlanManager.setWaypointAltitude(0, wpIndex, () => {
mcdu.updateConstraints();
this.ShowPage(mcdu, waypoint, verticalWaypoint, isDescentWaypoint);
this.ShowPage(mcdu, waypoint, verticalWaypoint);
});
return;
}
Expand All @@ -277,7 +277,7 @@ class CDUVerticalRevisionPage {
}

if (constraintType === WaypointConstraintType.Unknown) {
CDUVerticalRevisionPage.ShowPage(mcdu, waypoint, verticalWaypoint, isDescentWaypoint, undefined, altitude, code);
CDUVerticalRevisionPage.ShowPage(mcdu, waypoint, verticalWaypoint, undefined, altitude, code);
return;
}

Expand Down Expand Up @@ -396,7 +396,7 @@ class CDUVerticalRevisionPage {

const type = CDUVerticalRevisionPage.constraintType(mcdu, waypoint);
if (type === WaypointConstraintType.Unknown) {
CDUVerticalRevisionPage.ShowPage(mcdu, waypoint, speed, alt, code);
CDUVerticalRevisionPage.ShowPage(mcdu, waypoint, verticalWaypoint, speed, alt, code);
return;
}

Expand Down

0 comments on commit 2b808e0

Please sign in to comment.