Skip to content

Commit

Permalink
fix(mcdu): Disable alternate time predictions if fuel manually specif…
Browse files Browse the repository at this point in the history
…ied (flybywiresim#8273)

* output altTime as 0 if manual fuel input

* dash altn Time prediction if time is zero

* fix(fuel pred): dash altn time if value is 0

Update changelog

* changed fms alt time to null if manual fuel input
  • Loading branch information
BravoMike99 authored Nov 3, 2023
1 parent a74a618 commit 39b3842
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 25 deletions.
1 change: 1 addition & 0 deletions .github/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
1. [FMS] Implement CHECK SPEED MODE message - @BlueberryKing (BlueberryKing)
1. [PFD] The ILS frequency is now visible even when a LOC is not received - @tracernz (Mike)
1. [ATSU] Fixed GROUND REQ page not updating after successful station insert - @BravoMike99 (bruno_pt99)
1. [MCDU] Dash alternate time predictions if alternate fuel is manually inserted @BravoMike99 (bruno_pt99)

## 0.11.0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,20 +128,20 @@ class CDUFuelPredPage {
};

if (mcdu.altDestination) {
if (mcdu._routeAltFuelEntered) {
if (isFinite(mcdu.getRouteAltFuelWeight())) {
altFuelCell = "{sp}{sp}" + (NXUnits.kgToUser(mcdu.getRouteAltFuelWeight())).toFixed(1);
altFuelTimeCell = "{small}" + FMCMainDisplay.minutesTohhmm(mcdu.getRouteAltFuelTime()) + "{end}";
altTimeColor = "{green}";
altFuelColor = "[color]cyan";
}
} else {
const altnFuelEntered = mcdu._routeAltFuelEntered;
if (!altnFuelEntered) {
mcdu.tryUpdateRouteAlternate();
if (isFinite(mcdu.getRouteAltFuelWeight())) {
altFuelCell = "{sp}{sp}{small}" + (NXUnits.kgToUser(mcdu.getRouteAltFuelWeight())).toFixed(1);
altFuelTimeCell = FMCMainDisplay.minutesTohhmm(mcdu.getRouteAltFuelTime()) + "{end}";
}
if (isFinite(mcdu.getRouteAltFuelWeight())) {
altFuelCell = "{sp}{sp}" + (altnFuelEntered ? "" : "{small}") + (NXUnits.kgToUser(mcdu.getRouteAltFuelWeight())).toFixed(1);
altFuelColor = "[color]cyan";
const time = mcdu.getRouteAltFuelTime();
if (time) {
altFuelTimeCell = "{small}" + FMCMainDisplay.minutesTohhmm(time) + "{end}";
altTimeColor = "{green}";
altFuelColor = "[color]cyan";
} else {
altFuelTimeCell = "----";
altTimeColor = "{white}";
}
}
} else {
Expand All @@ -161,7 +161,6 @@ class CDUFuelPredPage {
altIdentCell = mcdu.altDestination.ident;
altEFOBCell = (NXUnits.kgToUser(mcdu.getAltEFOB(true))).toFixed(1);
altEFOBCellColor = mcdu.getAltEFOB(true) < mcdu._minDestFob ? "[color]amber" : "[color]green";
altTimeCellColor = "[color]green";
}

mcdu.tryUpdateRouteTrip(isFlying);
Expand All @@ -173,10 +172,18 @@ class CDUFuelPredPage {
// Should we use predicted values or liveETATo and liveUTCto?
destTimeCell = isFlying ? FMCMainDisplay.secondsToUTC(utcTime + FMCMainDisplay.minuteToSeconds(mcdu._routeTripTime))
: destTimeCell = FMCMainDisplay.minutesTohhmm(mcdu._routeTripTime);

if (mcdu.altDestination) {
altTimeCell = isFlying ? FMCMainDisplay.secondsToUTC(utcTime + FMCMainDisplay.minuteToSeconds(mcdu._routeTripTime) + FMCMainDisplay.minuteToSeconds(mcdu.getRouteAltFuelTime()))
if (mcdu.getRouteAltFuelTime()) {
altTimeCell = isFlying ? FMCMainDisplay.secondsToUTC(utcTime + FMCMainDisplay.minuteToSeconds(mcdu._routeTripTime) + FMCMainDisplay.minuteToSeconds(mcdu.getRouteAltFuelTime()))
: FMCMainDisplay.minutesTohhmm(mcdu.getRouteAltFuelTime());
altTimeCellColor = "[color]green";
} else {
altTimeCell = "----";
altTimeCellColor = "[color]white";
}
}

destEFOBCellColor = "[color]green";
destTimeCellColor = "[color]green";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -582,19 +582,21 @@ class CDUInitPage {
};

if (mcdu.altDestination) {
if (mcdu._routeAltFuelEntered) {
if (isFinite(mcdu.getRouteAltFuelWeight())) {
altnWeightCell.update(NXUnits.kgToUser(mcdu.getRouteAltFuelWeight()).toFixed(1), Column.cyan);
altnTimeCell.update(FMCMainDisplay.minutesTohhmm(mcdu.getRouteAltFuelTime()), Column.green, Column.small);
}
} else {
const altFuelEntered = mcdu._routeAltFuelEntered;
if (!altFuelEntered) {
mcdu.tryUpdateRouteAlternate();
if (isFinite(mcdu.getRouteAltFuelWeight())) {
altnWeightCell.update(NXUnits.kgToUser(mcdu.getRouteAltFuelWeight()).toFixed(1), Column.cyan, Column.small);
}
if (isFinite(mcdu.getRouteAltFuelWeight())) {
altnWeightCell.update(NXUnits.kgToUser(mcdu.getRouteAltFuelWeight()).toFixed(1), Column.cyan, altFuelEntered? Column.big : Column.small);
const time = mcdu.getRouteAltFuelTime();
if (time) {
altnTimeCell.update(FMCMainDisplay.minutesTohhmm(mcdu.getRouteAltFuelTime()), Column.green, Column.small);
altnCellDivider.updateAttributes(Column.green, Column.small);
} else {
altnTimeCell.update('----',Column.white);
altnCellDivider.updateAttributes(Column.white, altFuelEntered? Column.big : Column.small);
}
}
altnCellDivider.updateAttributes(Column.green, Column.small);
} else {
altnWeightCell.update("0.0", Column.green, Column.small);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2155,7 +2155,7 @@ class FMCMainDisplay extends BaseAirliners {
if (this.isAltFuelInRange(value)) {
this._routeAltFuelEntered = true;
this._routeAltFuelWeight = value;
this._routeAltFuelTime = FMCMainDisplay.minutesTohhmm(A32NX_FuelPred.computeUserAltTime(this._routeAltFuelWeight * 1000, 290));
this._routeAltFuelTime = null;
return true;
} else {
this.setScratchpadMessage(NXSystemMessages.entryOutOfRange);
Expand Down Expand Up @@ -2242,7 +2242,7 @@ class FMCMainDisplay extends BaseAirliners {
const deviation = (this.zeroFuelWeight + this._routeFinalFuelWeight - A32NX_FuelPred.refWeight) * A32NX_FuelPred.computeNumbers(airDistance, placeholderFl, A32NX_FuelPred.computations.CORRECTIONS, true);
if ((20 < airDistance && airDistance < 200) && (100 < placeholderFl && placeholderFl < 290)) { //This will always be true until we can setup alternate routes
this._routeAltFuelWeight = (A32NX_FuelPred.computeNumbers(airDistance, placeholderFl, A32NX_FuelPred.computations.FUEL, true) + deviation) / 1000;
this._routeAltFuelTime = A32NX_FuelPred.computeNumbers(airDistance, placeholderFl, A32NX_FuelPred.computations.TIME, true);
this._routeAltFuelTime = this._routeAltFuelEntered ? null : A32NX_FuelPred.computeNumbers(airDistance, placeholderFl, A32NX_FuelPred.computations.TIME, true);
}
}
}
Expand Down Expand Up @@ -2320,6 +2320,7 @@ class FMCMainDisplay extends BaseAirliners {
}

getRouteAltFuelTime() {

return this._routeAltFuelTime;
}

Expand Down

0 comments on commit 39b3842

Please sign in to comment.