From 9e9f9f52f62f7ada8b79cf403bf2f18f8a1bfcaa Mon Sep 17 00:00:00 2001 From: Matthew Maring <56924612+hayden2000@users.noreply.github.com> Date: Tue, 5 May 2020 09:52:11 -0400 Subject: [PATCH] Push changes to fuel predict, bugfix for reserve fuel --- Models/Instruments/MCDU/MCDU.nas | 33 +++++++++++++++++++------------- Nasal/FMGC/FMGC.nas | 6 +++++- Nasal/MCDU/FUELPRED.nas | 10 +++++++--- Nasal/MCDU/INITB.nas | 2 +- 4 files changed, 33 insertions(+), 18 deletions(-) diff --git a/Models/Instruments/MCDU/MCDU.nas b/Models/Instruments/MCDU/MCDU.nas index 91b15eee..fd59480f 100644 --- a/Models/Instruments/MCDU/MCDU.nas +++ b/Models/Instruments/MCDU/MCDU.nas @@ -1983,20 +1983,27 @@ var canvas_MCDU_base = { me["Simple_C3B"].setText(sprintf("/%.1f ", rte_percent.getValue())); } } - me["Simple_L4"].setText(sprintf("%.1f", alt_fuel.getValue())); - me["Simple_C4"].show(); - if (alt_fuel_set.getValue() == 1) { - if (num(alt_fuel.getValue()) > 9.9) { - me["Simple_C4"].setText(sprintf("/%s ", alt_time.getValue())); + if (altSet.getValue() == 1) { + me["Simple_L4"].setText(sprintf("%.1f", alt_fuel.getValue())); + me["Simple_L4"].setColor(BLUE); + me["Simple_C4"].show(); + if (alt_fuel_set.getValue() == 1) { + if (num(alt_fuel.getValue()) > 9.9) { + me["Simple_C4"].setText(sprintf("/%s ", alt_time.getValue())); + } else { + me["Simple_C4"].setText(sprintf("/%s ", alt_time.getValue())); + } } else { - me["Simple_C4"].setText(sprintf("/%s ", alt_time.getValue())); + if (num(alt_fuel.getValue()) > 9.9) { + me["Simple_C4"].setText(sprintf("/%s ", alt_time.getValue())); + } else { + me["Simple_C4"].setText(sprintf("/%s ", alt_time.getValue())); + } } } else { - if (num(alt_fuel.getValue()) > 9.9) { - me["Simple_C4"].setText(sprintf("/%s ", alt_time.getValue())); - } else { - me["Simple_C4"].setText(sprintf("/%s ", alt_time.getValue())); - } + me["Simple_L4"].setText("---.-/----"); + me["Simple_L4"].setColor(WHITE); + me["Simple_C4"].hide(); } me["Simple_L5"].setText(sprintf("%.1f", final_fuel.getValue())); if (final_time_set.getValue() == 1 and final_fuel_set.getValue() == 1) { @@ -2033,7 +2040,7 @@ var canvas_MCDU_base = { me["Simple_R5"].setText(sprintf("%4.1f/", gw.getValue()) ~ sprintf("%4.1f", cg.getValue())); me["Simple_R6"].setText(sprintf("%4.1f/" ~ extra_time.getValue(), extra_fuel.getValue())); - me.colorLeft("ack", "ack", "blu", "blu", "blu", "blu"); + me.colorLeft("ack", "ack", "blu", "ack", "blu", "blu"); me.colorRight("ack", "ack", "blu", "grn", "grn", "grn"); } @@ -2070,7 +2077,7 @@ var canvas_MCDU_base = { me["Simple_C3B"].setFontSize(small); } - if (alt_fuel_set.getValue() == 1) { + if (alt_fuel_set.getValue() == 1 and altSet.getValue() == 1) { me["Simple_L4"].setFontSize(normal); } else { me["Simple_L4"].setFontSize(small); diff --git a/Nasal/FMGC/FMGC.nas b/Nasal/FMGC/FMGC.nas index dba441bd..f97f76bd 100644 --- a/Nasal/FMGC/FMGC.nas +++ b/Nasal/FMGC/FMGC.nas @@ -279,7 +279,11 @@ var updateFuel = func { if (num(getprop("/FMGC/internal/trip-fuel")) == 0.0) { setprop("/FMGC/internal/rte-percent", 0.0); } else { - setprop("/FMGC/internal/rte-percent", num(getprop("/FMGC/internal/rte-rsv") / getprop("/FMGC/internal/trip-fuel") * 100.0)); + if (num(getprop("/FMGC/internal/rte-rsv") / getprop("/FMGC/internal/trip-fuel") * 100.0) <= 15.0) { + setprop("/FMGC/internal/rte-percent", num(getprop("/FMGC/internal/rte-rsv") / getprop("/FMGC/internal/trip-fuel") * 100.0)); + } else { + setprop("/FMGC/internal/rte-percent", 15.0); # need reasearch on this value + } } } else if (getprop("/FMGC/internal/rte-percent-set")) { setprop("/FMGC/internal/rte-rsv", num(getprop("/FMGC/internal/trip-fuel") * getprop("/FMGC/internal/rte-percent") / 100.0)); diff --git a/Nasal/MCDU/FUELPRED.nas b/Nasal/MCDU/FUELPRED.nas index 2b5dfacc..d9fb4bcc 100644 --- a/Nasal/MCDU/FUELPRED.nas +++ b/Nasal/MCDU/FUELPRED.nas @@ -48,9 +48,13 @@ var fuelPredInput = func(key, i) { setprop("/FMGC/internal/fuel-calculating", 1); setprop("/MCDU[" ~ i ~ "]/scratchpad", ""); } - } else if (tfs >= 1 and tfs <= 4 and tf != nil and tf >= 0 and tf <= 21.7 and tf / num(getprop("/FMGC/internal/trip-fuel")) <= 0.15) { + } else if (tfs >= 1 and tfs <= 4 and tf != nil and tf >= 0 and tf <= 21.7) { setprop("/FMGC/internal/rte-rsv", scratchpad); - setprop("/FMGC/internal/rte-percent", scratchpad / num(getprop("/FMGC/internal/trip-fuel")) * 100); + if (scratchpad / num(getprop("/FMGC/internal/trip-fuel")) * 100 <= 15.0) { + setprop("/FMGC/internal/rte-percent", scratchpad / num(getprop("/FMGC/internal/trip-fuel")) * 100); + } else { + setprop("/FMGC/internal/rte-percent", 15.0); # need reasearch on this value + } setprop("/FMGC/internal/fuel-calculating", 1); setprop("/MCDU[" ~ i ~ "]/scratchpad", ""); } else { @@ -59,7 +63,7 @@ var fuelPredInput = func(key, i) { } else { notAllowed(i); } - } else if (key == "L4" and getprop("/FMGC/internal/block-confirmed") and !getprop("/FMGC/internal/fuel-calculating")) { + } else if (key == "L4" and getprop("/FMGC/internal/block-confirmed") and !getprop("/FMGC/internal/fuel-calculating") and getprop("/FMGC/internal/alt-set")s) { if (scratchpad == "CLR") { setprop("/FMGC/internal/alt-fuel", 0.0); setprop("/FMGC/internal/alt-time", "0000"); diff --git a/Nasal/MCDU/INITB.nas b/Nasal/MCDU/INITB.nas index dff47044..0414804d 100644 --- a/Nasal/MCDU/INITB.nas +++ b/Nasal/MCDU/INITB.nas @@ -56,7 +56,7 @@ var initInputB = func(key, i) { } else if (tfs >= 1 and tfs <= 4 and tf != nil and tf >= 0 and tf <= 21.7) { setprop("/FMGC/internal/rte-rsv", scratchpad); setprop("/FMGC/internal/rte-rsv-set", 1); - if (scratchpad / num(getprop("/FMGC/internal/trip-fuel")) * 100 > 15.0) { + if (scratchpad / num(getprop("/FMGC/internal/trip-fuel")) * 100 <= 15.0) { setprop("/FMGC/internal/rte-percent", scratchpad / num(getprop("/FMGC/internal/trip-fuel")) * 100); } else { setprop("/FMGC/internal/rte-percent", 15.0); # need reasearch on this value