diff --git a/AircraftConfig/main.xml b/AircraftConfig/main.xml index d7edd304..c97e3d27 100644 --- a/AircraftConfig/main.xml +++ b/AircraftConfig/main.xml @@ -243,7 +243,7 @@ - + diff --git a/Models/Instruments/MCDU/MCDU.nas b/Models/Instruments/MCDU/MCDU.nas index bb97b5da..69bb044a 100644 --- a/Models/Instruments/MCDU/MCDU.nas +++ b/Models/Instruments/MCDU/MCDU.nas @@ -72,6 +72,7 @@ var MAGENTA = [0.6902,0.3333,0.7541]; # Fetch nodes: var mcdu_keyboard_left = props.globals.getNode("/FMGC/keyboard-left", 0); var mcdu_keyboard_right = props.globals.getNode("/FMGC/keyboard-right", 0); +var acconfig_weight_kgs = props.globals.getNode("/systems/acconfig/options/weight-kgs", 1); #ACCONFIG var mcdu1_lgt = props.globals.getNode("/controls/lighting/DU/mcdu1", 1); @@ -153,6 +154,10 @@ var pageProp = [props.globals.getNode("/MCDU[0]/page", 1), props.globals.getNode var active = [props.globals.getNode("/MCDU[0]/active", 1), props.globals.getNode("/MCDU[1]/active", 1)]; var activeAtsu = [props.globals.getNode("/MCDU[0]/atsu-active", 1), props.globals.getNode("/MCDU[1]/atsu-active", 1)]; +# Conversion factor pounds to kilogram +var LBS2KGS = 0.4535924; + + # Create Nodes: var pageSwitch = [props.globals.initNode("/MCDU[0]/internal/switch", 0, "BOOL"), props.globals.initNode("/MCDU[1]/internal/switch", 0, "BOOL")]; @@ -1450,7 +1455,7 @@ var canvas_MCDU_base = { me["Simple_L5"].setText("[ ]"); - me["Simple_L6"].setText("+4.0/+0.0"); + me["Simple_L6"].setText("+0.0/+1.0"); me["Simple_L1S"].setText(" ENG"); me["Simple_L2S"].setText(" ACTIVE NAV DATA BASE"); me["Simple_L3S"].setText(" SECOND NAV DATA BASE"); @@ -2248,7 +2253,11 @@ var canvas_MCDU_base = { } me["Simple_L1S"].setText("TAXI"); - me["Simple_L1"].setText(sprintf("%2.1f", fmgc.FMGCInternal.taxiFuel)); + if (acconfig_weight_kgs.getValue() == 1) { + me["Simple_L1"].setText(sprintf("%2.1f", fmgc.FMGCInternal.taxiFuel * LBS2KGS)); + } else { + me["Simple_L1"].setText(sprintf("%2.1f", fmgc.FMGCInternal.taxiFuel)); + } me["Simple_L2S"].setText("TRIP/TIME"); me["Simple_L3S"].setText("RTE RSV/PCT"); me["Simple_L4S"].setText("ALTN/TIME"); @@ -2274,7 +2283,11 @@ var canvas_MCDU_base = { if (fmgc.FMGCInternal.blockSet) { me["Simple_R2"].show(); me["INITB_Block"].hide(); - me["Simple_R2"].setText(sprintf("%3.1f", fmgc.FMGCInternal.block)); + if (acconfig_weight_kgs.getValue() == 1) { + me["Simple_R2"].setText(sprintf("%3.1f", fmgc.FMGCInternal.block * LBS2KGS)); + } else { + me["Simple_R2"].setText(sprintf("%3.1f", fmgc.FMGCInternal.block)); + } } else { me["Simple_R2"].hide(); me["INITB_Block"].show(); @@ -2342,7 +2355,11 @@ var canvas_MCDU_base = { me["Simple_L6"].setText("---.-"); me["Simple_R2"].show(); me["INITB_Block"].hide(); - me["Simple_R2"].setText(sprintf("%3.1f", fmgc.FMGCInternal.block)); + if (acconfig_weight_kgs.getValue() == 1) { + me["Simple_R2"].setText(sprintf("%3.1f", fmgc.FMGCInternal.block * LBS2KGS)); + } else { + me["Simple_R2"].setText(sprintf("%3.1f", fmgc.FMGCInternal.block)); + } me["Simple_R3S"].show(); me["Simple_R3"].show(); me["Simple_R3S"].setText("BLOCK"); @@ -2351,9 +2368,17 @@ var canvas_MCDU_base = { me["Simple_R3_Arrow"].setColor(AMBER); me["Simple_C4B"].show(); if (num(fmgc.FMGCInternal.tow) >= 100.0) { - me["Simple_C4B"].setText(sprintf(" %4.1f/", fmgc.FMGCInternal.tow)); + if (acconfig_weight_kgs.getValue() == 1) { + me["Simple_C4B"].setText(sprintf(" %4.1f/", fmgc.FMGCInternal.tow * LBS2KGS)); + } else { + me["Simple_C4B"].setText(sprintf(" %4.1f/", fmgc.FMGCInternal.tow)); + } } else { - me["Simple_C4B"].setText(sprintf(" %4.1f/", fmgc.FMGCInternal.tow)); + if (acconfig_weight_kgs.getValue() == 1) { + me["Simple_C4B"].setText(sprintf(" %4.1f/", fmgc.FMGCInternal.tow * LBS2KGS)); + } else { + me["Simple_C4B"].setText(sprintf(" %4.1f/", fmgc.FMGCInternal.tow)); + } } me["Simple_R4"].setText("---.-"); me["Simple_R6"].setText("---.-/----"); @@ -2387,15 +2412,27 @@ var canvas_MCDU_base = { me["Simple_L6"].setText("---.-"); me["Simple_R2"].show(); me["INITB_Block"].hide(); - me["Simple_R2"].setText(sprintf("%3.1f", fmgc.FMGCInternal.block)); + if (acconfig_weight_kgs.getValue() == 1) { + me["Simple_R2"].setText(sprintf("%3.1f", fmgc.FMGCInternal.block * LBS2KGS)); + } else { + me["Simple_R2"].setText(sprintf("%3.1f", fmgc.FMGCInternal.block)); + } me["Simple_R3S"].hide(); me["Simple_R3"].hide(); me["Simple_R3_Arrow"].hide(); me["Simple_C4B"].show(); if (num(fmgc.FMGCInternal.tow) >= 100.0) { - me["Simple_C4B"].setText(sprintf(" %4.1f/", fmgc.FMGCInternal.tow)); + if (acconfig_weight_kgs.getValue() == 1) { + me["Simple_C4B"].setText(sprintf(" %4.1f/", fmgc.FMGCInternal.tow * LBS2KGS)); + } else { + me["Simple_C4B"].setText(sprintf(" %4.1f/", fmgc.FMGCInternal.tow)); + } } else { - me["Simple_C4B"].setText(sprintf(" %4.1f/", fmgc.FMGCInternal.tow)); + if (acconfig_weight_kgs.getValue() == 1) { + me["Simple_C4B"].setText(sprintf(" %4.1f/", fmgc.FMGCInternal.tow * LBS2KGS)); + } else { + me["Simple_C4B"].setText(sprintf(" %4.1f/", fmgc.FMGCInternal.tow)); + } } me["Simple_R4"].setText("---.-"); me["Simple_R6"].setText("---.-/----"); @@ -2403,8 +2440,16 @@ var canvas_MCDU_base = { me.colorLeft("ack", "wht", "wht", "wht", "wht", "wht"); me.colorRight("ack", "blu", "ack", "wht", "ack", "wht"); } else { - me["Simple_L2"].setText(sprintf("%.1f/" ~ fmgc.FMGCInternal.tripTime, fmgc.FMGCInternal.tripFuel)); - me["Simple_L3"].setText(sprintf("%.1f", fmgc.FMGCInternal.rteRsv)); + if (acconfig_weight_kgs.getValue() == 1) { + me["Simple_L2"].setText(sprintf("%.1f/" ~ fmgc.FMGCInternal.tripTime, fmgc.FMGCInternal.tripFuel * LBS2KGS)); + } else { + me["Simple_L2"].setText(sprintf("%.1f/" ~ fmgc.FMGCInternal.tripTime, fmgc.FMGCInternal.tripFuel)); + } + if (acconfig_weight_kgs.getValue() == 1) { + me["Simple_L3"].setText(sprintf("%.1f", fmgc.FMGCInternal.rteRsv * LBS2KGS)); + } else { + me["Simple_L3"].setText(sprintf("%.1f", fmgc.FMGCInternal.rteRsv)); + } if (fmgc.FMGCInternal.rteRsvSet) { if (num(fmgc.FMGCInternal.rteRsv) > 9.9 and num(fmgc.FMGCInternal.rtePercent) > 9.9) { me["Simple_C3"].setText(sprintf("/%.1f ", fmgc.FMGCInternal.rtePercent)); @@ -2437,7 +2482,11 @@ var canvas_MCDU_base = { } } if (fmgc.FMGCInternal.altAirportSet) { - me["Simple_L4"].setText(sprintf("%.1f", fmgc.FMGCInternal.altFuel)); + if (acconfig_weight_kgs.getValue() == 1) { + me["Simple_L4"].setText(sprintf("%.1f", fmgc.FMGCInternal.altFuel * LBS2KGS)); + } else { + me["Simple_L4"].setText(sprintf("%.1f", fmgc.FMGCInternal.altFuel)); + } me["Simple_L4"].setColor(BLUE); me["Simple_C4"].show(); if (fmgc.FMGCInternal.altFuelSet) { @@ -2458,7 +2507,11 @@ var canvas_MCDU_base = { me["Simple_L4"].setColor(WHITE); me["Simple_C4"].hide(); } - me["Simple_L5"].setText(sprintf("%.1f", fmgc.FMGCInternal.finalFuel)); + if (acconfig_weight_kgs.getValue() == 1) { + me["Simple_L5"].setText(sprintf("%.1f", fmgc.FMGCInternal.finalFuel * LBS2KGS)); + } else { + me["Simple_L5"].setText(sprintf("%.1f", fmgc.FMGCInternal.finalFuel)); + } if (fmgc.FMGCInternal.finalTimeSet and fmgc.FMGCInternal.finalFuelSet) { if (num(fmgc.FMGCInternal.finalFuel) > 9.9) { me["Simple_C5"].setText(sprintf("/%s ", fmgc.FMGCInternal.finalTime)); @@ -2484,16 +2537,30 @@ var canvas_MCDU_base = { me["Simple_C5"].setText(sprintf("/%s ", fmgc.FMGCInternal.finalTime)); } } - me["Simple_L6"].setText(sprintf("%.1f", fmgc.FMGCInternal.minDestFob)); + if (acconfig_weight_kgs.getValue() == 1) { + me["Simple_L6"].setText(sprintf("%.1f", fmgc.FMGCInternal.minDestFob * LBS2KGS)); + } else { + me["Simple_L6"].setText(sprintf("%.1f", fmgc.FMGCInternal.minDestFob)); + } me["Simple_R2"].show(); me["INITB_Block"].hide(); - me["Simple_R2"].setText(sprintf("%3.1f", fmgc.FMGCInternal.block)); + if (acconfig_weight_kgs.getValue() == 1) { + me["Simple_R2"].setText(sprintf("%3.1f", fmgc.FMGCInternal.block * LBS2KGS)); + } else { + me["Simple_R2"].setText(sprintf("%3.1f", fmgc.FMGCInternal.block)); + } me["Simple_R3S"].hide(); me["Simple_R3"].hide(); me["Simple_R3_Arrow"].hide(); me["Simple_C4B"].hide(); - me["Simple_R4"].setText(sprintf("%4.1f/", fmgc.FMGCInternal.tow) ~ sprintf("%4.1f", fmgc.FMGCInternal.lw)); - me["Simple_R6"].setText(sprintf("%.1f/" ~ fmgc.FMGCInternal.extraTime, fmgc.FMGCInternal.extraFuel)); + + if (acconfig_weight_kgs.getValue() == 1) { + me["Simple_R4"].setText(sprintf("%4.1f/", fmgc.FMGCInternal.tow * LBS2KGS) ~ sprintf("%4.1f", fmgc.FMGCInternal.lw * LBS2KGS)); + me["Simple_R6"].setText(sprintf("%.1f/" ~ fmgc.FMGCInternal.extraTime, fmgc.FMGCInternal.extraFuel * LBS2KGS)); + } else { + me["Simple_R4"].setText(sprintf("%4.1f/", fmgc.FMGCInternal.tow) ~ sprintf("%4.1f", fmgc.FMGCInternal.lw)); + me["Simple_R6"].setText(sprintf("%.1f/" ~ fmgc.FMGCInternal.extraTime, fmgc.FMGCInternal.extraFuel)); + } me.colorLeft("ack", "grn", "blu", "ack", "blu", "blu"); me.colorRight("ack", "blu", "ack", "grn", "ack", "grn"); @@ -2515,9 +2582,17 @@ var canvas_MCDU_base = { if (fmgc.FMGCInternal.zfwSet) { if (fmgc.FMGCInternal.zfw < 100) { - me["Simple_C1"].setText(" " ~ sprintf("%3.1f", fmgc.FMGCInternal.zfw)); + if (acconfig_weight_kgs.getValue() == 1) { + me["Simple_C1"].setText(" " ~ sprintf("%3.1f", fmgc.FMGCInternal.zfw * LBS2KGS)); + } else { + me["Simple_C1"].setText(" " ~ sprintf("%3.1f", fmgc.FMGCInternal.zfw)); + } } else { - me["Simple_C1"].setText(" " ~ sprintf("%3.1f", fmgc.FMGCInternal.zfw)); + if (acconfig_weight_kgs.getValue() == 1) { + me["Simple_C1"].setText(" " ~ sprintf("%3.1f", fmgc.FMGCInternal.zfw * LBS2KGS)); + } else { + me["Simple_C1"].setText(" " ~ sprintf("%3.1f", fmgc.FMGCInternal.zfw)); + } } me["Simple_C1"].show(); me["INITB_ZFW"].hide(); @@ -2684,7 +2759,11 @@ var canvas_MCDU_base = { me.colorLeft("ack", "ack", "wht", "wht", "wht", "wht"); me.colorRight("ack", "ack", "ack", "wht", "wht", "wht"); } else { - me["Simple_L3"].setText(sprintf("%.1f", fmgc.FMGCInternal.rteRsv)); + if (acconfig_weight_kgs.getValue() == 1) { + me["Simple_L3"].setText(sprintf("%.1f", fmgc.FMGCInternal.rteRsv * LBS2KGS)); + } else { + me["Simple_L3"].setText(sprintf("%.1f", fmgc.FMGCInternal.rteRsv)); + } if (fmgc.FMGCInternal.rteRsvSet) { if (num(fmgc.FMGCInternal.rteRsv) > 9.9 and num(fmgc.FMGCInternal.rtePercent) > 9.9) { me["Simple_C3B"].setText(sprintf("/%.1f ", fmgc.FMGCInternal.rtePercent)); @@ -2717,7 +2796,11 @@ var canvas_MCDU_base = { } } if (fmgc.FMGCInternal.altAirportSet) { - me["Simple_L4"].setText(sprintf("%.1f", fmgc.FMGCInternal.altFuel)); + if (acconfig_weight_kgs.getValue() == 1) { + me["Simple_L4"].setText(sprintf("%.1f", fmgc.FMGCInternal.altFuel * LBS2KGS)); + } else { + me["Simple_L4"].setText(sprintf("%.1f", fmgc.FMGCInternal.altFuel)); + } me["Simple_L4"].setColor(BLUE); me["Simple_C4"].show(); if (fmgc.FMGCInternal.altFuelSet) { @@ -2738,7 +2821,11 @@ var canvas_MCDU_base = { me["Simple_L4"].setColor(WHITE); me["Simple_C4"].hide(); } - me["Simple_L5"].setText(sprintf("%.1f", fmgc.FMGCInternal.finalFuel)); + if (acconfig_weight_kgs.getValue() == 1) { + me["Simple_L5"].setText(sprintf("%.1f", fmgc.FMGCInternal.finalFuel * LBS2KGS)); + } else { + me["Simple_L5"].setText(sprintf("%.1f", fmgc.FMGCInternal.finalFuel)); + } if (fmgc.FMGCInternal.finalTimeSet and fmgc.FMGCInternal.finalFuelSet) { if (num(fmgc.FMGCInternal.finalFuel) > 9.9) { me["Simple_C5"].setText(sprintf("/%s ", fmgc.FMGCInternal.finalTime)); @@ -2764,10 +2851,17 @@ var canvas_MCDU_base = { me["Simple_C5"].setText(sprintf("/%s ", fmgc.FMGCInternal.finalTime)); } } - me["Simple_L6"].setText(sprintf("%.1f", fmgc.FMGCInternal.minDestFob)); - me["Simple_R4"].setText(sprintf("%4.1f/" ~ fmgc.FMGCInternal.fffqSensor, fmgc.FMGCInternal.fob)); - me["Simple_R5"].setText(sprintf("%4.1f/", fmgc.FMGCInternal.fuelPredGw) ~ sprintf("%4.1f", fmgc.FMGCInternal.cg)); - me["Simple_R6"].setText(sprintf("%4.1f/" ~ fmgc.FMGCInternal.extraTime, fmgc.FMGCInternal.extraFuel)); + if (acconfig_weight_kgs.getValue() == 1) { + me["Simple_L6"].setText(sprintf("%.1f", fmgc.FMGCInternal.minDestFob * LBS2KGS)); + me["Simple_R4"].setText(sprintf("%4.1f/" ~ fmgc.FMGCInternal.fffqSensor, fmgc.FMGCInternal.fob * LBS2KGS)); + me["Simple_R5"].setText(sprintf("%4.1f/", fmgc.FMGCInternal.fuelPredGw * LBS2KGS) ~ sprintf("%4.1f", fmgc.FMGCInternal.cg)); + me["Simple_R6"].setText(sprintf("%4.1f/" ~ fmgc.FMGCInternal.extraTime, fmgc.FMGCInternal.extraFuel * LBS2KGS)); + } else { + me["Simple_L6"].setText(sprintf("%.1f", fmgc.FMGCInternal.minDestFob)); + me["Simple_R4"].setText(sprintf("%4.1f/" ~ fmgc.FMGCInternal.fffqSensor, fmgc.FMGCInternal.fob)); + me["Simple_R5"].setText(sprintf("%4.1f/", fmgc.FMGCInternal.fuelPredGw) ~ sprintf("%4.1f", fmgc.FMGCInternal.cg)); + me["Simple_R6"].setText(sprintf("%4.1f/" ~ fmgc.FMGCInternal.extraTime, fmgc.FMGCInternal.extraFuel)); + } me.colorLeft("ack", "ack", "blu", "ack", "blu", "blu"); me.colorRight("ack", "ack", "blu", "grn", "grn", "grn"); @@ -2786,9 +2880,17 @@ var canvas_MCDU_base = { if (fmgc.FMGCInternal.zfwSet) { if (fmgc.FMGCInternal.zfw < 100) { - me["Simple_C3"].setText(" " ~ sprintf("%3.1f", fmgc.FMGCInternal.zfw)); + if (acconfig_weight_kgs.getValue() == 1) { + me["Simple_C3"].setText(" " ~ sprintf("%3.1f", fmgc.FMGCInternal.zfw * LBS2KGS)); + } else { + me["Simple_C3"].setText(" " ~ sprintf("%3.1f", fmgc.FMGCInternal.zfw)); + } } else { - me["Simple_C3"].setText(" " ~ sprintf("%3.1f", fmgc.FMGCInternal.zfw)); + if (acconfig_weight_kgs.getValue() == 1) { + me["Simple_C3"].setText(" " ~ sprintf("%3.1f", fmgc.FMGCInternal.zfw * LBS2KGS)); + } else { + me["Simple_C3"].setText(" " ~ sprintf("%3.1f", fmgc.FMGCInternal.zfw)); + } } me["Simple_C3"].show(); me["FUELPRED_ZFW"].hide(); diff --git a/Nasal/FMGC/SimbriefParser.nas b/Nasal/FMGC/SimbriefParser.nas index 2fecf4b1..bcedfc5a 100644 --- a/Nasal/FMGC/SimbriefParser.nas +++ b/Nasal/FMGC/SimbriefParser.nas @@ -1,6 +1,8 @@ # A3XX Simbrief Parser # Copyright (c) 2020 Jonathan Redpath (legoboyvdlp) +var LBS2KGS = 0.4535924; + var SimbriefParser = { node: nil, OFP: nil, @@ -37,6 +39,9 @@ var SimbriefParser = { me.store1 = nil; me.store2 = nil; + me.store1 = me.OFP.getChild("params"); + var units = me.store1.getChild("units").getValue(); + me.store1 = me.OFP.getChild("general"); me.store2 = me.OFP.getChild("alternate"); fmgc.FMGCInternal.flightNum = (me.store1.getChild("icao_airline").getValue() or "") ~ (me.store1.getChild("flight_number").getValue() or ""); @@ -154,31 +159,52 @@ var SimbriefParser = { # INITB me.store1 = me.OFP.getChild("fuel"); me.store2 = me.OFP.getChild("weights"); - fmgc.FMGCInternal.taxiFuel = me.store1.getChild("taxi").getValue() / 1000; - fmgc.FMGCInternal.taxiFuelSet = 1; - fmgc.FMGCInternal.altFuel = me.store1.getChild("alternate_burn").getValue() / 1000; - fmgc.FMGCInternal.altFuelSet = 1; - fmgc.FMGCInternal.finalFuel = me.store1.getChild("reserve").getValue() / 1000; - fmgc.FMGCInternal.finalFuelSet = 1; - fmgc.FMGCInternal.rteRsv = me.store1.getChild("contingency").getValue() / 1000; - fmgc.FMGCInternal.rteRsvSet = 1; - if ((me.store1.getChild("contingency").getValue() / 1000) / num(fmgc.FMGCInternal.tripFuel) * 100 <= 15.0) { - fmgc.FMGCInternal.rtePercent = (me.store1.getChild("contingency").getValue() / 1000) / num(fmgc.FMGCInternal.tripFuel) * 100; + if (units == "lbs") { + fmgc.FMGCInternal.taxiFuel = me.store1.getChild("taxi").getValue() / 1000; + fmgc.FMGCInternal.taxiFuelSet = 1; + fmgc.FMGCInternal.altFuel = me.store1.getChild("alternate_burn").getValue() / 1000; + fmgc.FMGCInternal.altFuelSet = 1; + fmgc.FMGCInternal.finalFuel = me.store1.getChild("reserve").getValue() / 1000; + fmgc.FMGCInternal.finalFuelSet = 1; + fmgc.FMGCInternal.rteRsv = me.store1.getChild("contingency").getValue() / 1000; + fmgc.FMGCInternal.rteRsvSet = 1; + if ((me.store1.getChild("contingency").getValue() / 1000) / num(fmgc.FMGCInternal.tripFuel) * 100 <= 15.0) { + fmgc.FMGCInternal.rtePercent = (me.store1.getChild("contingency").getValue() / 1000) / num(fmgc.FMGCInternal.tripFuel) * 100; + } else { + fmgc.FMGCInternal.rtePercent = 15.0 + } + fmgc.FMGCInternal.rtePercentSet = 0; + fmgc.FMGCInternal.block = me.store1.getChild("plan_ramp").getValue() / 1000; + fmgc.FMGCInternal.blockSet = 1; + fmgc.FMGCInternal.zfw = me.store2.getChild("est_zfw").getValue() / 1000; + fmgc.FMGCInternal.zfwSet = 1; + fmgc.FMGCInternal.tow = fmgc.FMGCInternal.zfw + fmgc.FMGCInternal.block - fmgc.FMGCInternal.taxiFuel; } else { - fmgc.FMGCInternal.rtePercent = 15.0 + fmgc.FMGCInternal.taxiFuel = (me.store1.getChild("taxi").getValue() / LBS2KGS) / 1000; + fmgc.FMGCInternal.taxiFuelSet = 1; + fmgc.FMGCInternal.altFuel = (me.store1.getChild("alternate_burn").getValue() / LBS2KGS) / 1000; + fmgc.FMGCInternal.altFuelSet = 1; + fmgc.FMGCInternal.finalFuel = (me.store1.getChild("reserve").getValue() / LBS2KGS) / 1000; + fmgc.FMGCInternal.finalFuelSet = 1; + fmgc.FMGCInternal.rteRsv = (me.store1.getChild("contingency").getValue() / LBS2KGS) / 1000; + fmgc.FMGCInternal.rteRsvSet = 1; + if (((me.store1.getChild("contingency").getValue() / LBS2KGS) / 1000) / num(fmgc.FMGCInternal.tripFuel) * 100 <= 15.0) { + fmgc.FMGCInternal.rtePercent = ((me.store1.getChild("contingency").getValue() / LBS2KGS) / 1000) / num(fmgc.FMGCInternal.tripFuel) * 100; + } else { + fmgc.FMGCInternal.rtePercent = 15.0 + } + fmgc.FMGCInternal.rtePercentSet = 0; + fmgc.FMGCInternal.block = (me.store1.getChild("plan_ramp").getValue() / LBS2KGS) / 1000; + fmgc.FMGCInternal.blockSet = 1; + fmgc.FMGCInternal.zfw = (me.store2.getChild("est_zfw").getValue() / LBS2KGS) / 1000; + fmgc.FMGCInternal.zfwSet = 1; + fmgc.FMGCInternal.tow = fmgc.FMGCInternal.zfw + fmgc.FMGCInternal.block - fmgc.FMGCInternal.taxiFuel; } - fmgc.FMGCInternal.rtePercentSet = 0; - fmgc.FMGCInternal.block = me.store1.getChild("plan_ramp").getValue() / 1000; - fmgc.FMGCInternal.blockSet = 1; - fmgc.FMGCInternal.zfw = me.store2.getChild("est_zfw").getValue() / 1000; - fmgc.FMGCInternal.zfwSet = 1; - fmgc.FMGCInternal.tow = fmgc.FMGCInternal.zfw + fmgc.FMGCInternal.block - fmgc.FMGCInternal.taxiFuel; fmgc.FMGCInternal.fuelRequest = 1; fmgc.FMGCInternal.fuelCalculating = 1; fmgc.fuelCalculating.setValue(1); fmgc.FMGCInternal.blockCalculating = 0; fmgc.blockCalculating.setValue(0); fmgc.FMGCInternal.blockConfirmed = 1; - }, }; \ No newline at end of file diff --git a/Nasal/MCDU/FUELPRED.nas b/Nasal/MCDU/FUELPRED.nas index fbdc1693..78d2b32e 100644 --- a/Nasal/MCDU/FUELPRED.nas +++ b/Nasal/MCDU/FUELPRED.nas @@ -16,6 +16,9 @@ var fuelPredInput = func(key, i) { mcdu_scratchpad.scratchpads[i].empty(); } else if (fmgc.FMGCInternal.tripFuel != 0) { var tf = num(scratchpad); + if (acconfig_weight_kgs.getValue() == 1) { + tf = tf / LBS2KGS; + } var tfs = size(scratchpad); if (tfs >= 2 and tfs <= 5 and find("/", scratchpad) == 0) { var perc = num(split("/", scratchpad)[1]); @@ -56,6 +59,9 @@ var fuelPredInput = func(key, i) { mcdu_scratchpad.scratchpads[i].empty(); } else if (find(".", scratchpad) != -1) { var tf = num(scratchpad); + if (acconfig_weight_kgs.getValue() == 1) { + tf = tf / LBS2KGS; + } var tfs = size(scratchpad); if (tfs >= 3 and tfs <= 4 and tf != nil and tf >= 0 and tf <= 10.0) { fmgc.FMGCInternal.altFuel = tf; @@ -81,6 +87,9 @@ var fuelPredInput = func(key, i) { mcdu_scratchpad.scratchpads[i].empty(); } else if (find(".", scratchpad) != -1) { var tf = num(scratchpad); + if (acconfig_weight_kgs.getValue() == 1) { + tf = tf / LBS2KGS; + } var tfs = size(scratchpad); if (tfs >= 3 and tfs <= 4 and tf != nil and tf >= 0 and tf <= 10.0) { fmgc.FMGCInternal.finalFuel = tf; @@ -93,6 +102,9 @@ var fuelPredInput = func(key, i) { } } else { var tf = num(scratchpad); + if (acconfig_weight_kgs.getValue() == 1) { + tf = tf / LBS2KGS; + } var tfs = size(scratchpad); if (tfs == 4 and tf != nil and ((tf >= 0 and tf <= 59) or (tf >= 100 and tf <= 130))) { fmgc.FMGCInternal.finalTime = scratchpad; @@ -113,6 +125,9 @@ var fuelPredInput = func(key, i) { mcdu_scratchpad.scratchpads[i].empty(); } else if (find(".", scratchpad) != -1) { var tf = num(scratchpad); + if (acconfig_weight_kgs.getValue() == 1) { + tf = tf / LBS2KGS; + } var tfs = size(scratchpad); if (tfs >= 3 and tfs <= 5 and tf != nil and tf >= 0 and tf <= 80.0) { fmgc.FMGCInternal.minDestFob = tf; @@ -155,6 +170,9 @@ var fuelPredInput = func(key, i) { } mcdu_scratchpad.scratchpads[i].empty(); } else if (find("/", scratchpad) != -1) { + if (acconfig_weight_kgs.getValue() == 1) { + scratchpad = scratchpad / LBS2KGS; + } var zfwi = split("/", scratchpad); var zfw = num(zfwi[0]); var zfwcg = num(zfwi[1]); @@ -196,6 +214,9 @@ var fuelPredInput = func(key, i) { mcdu_message(i, "NOT ALLOWED"); } } else if (num(scratchpad) != nil and size(scratchpad) > 0 and size(scratchpad) <= 5 and (find(".", scratchpad) == -1 or size(split(".", scratchpad)[1]) <= 1)) { + if (acconfig_weight_kgs.getValue() == 1) { + scratchpad = scratchpad / LBS2KGS; + } if (scratchpad >= zfw_min and scratchpad <= zfw_max) { fmgc.FMGCInternal.zfw = scratchpad; fmgc.FMGCInternal.zfwSet = 1; diff --git a/Nasal/MCDU/INITB.nas b/Nasal/MCDU/INITB.nas index 246dddb9..13ca2d34 100644 --- a/Nasal/MCDU/INITB.nas +++ b/Nasal/MCDU/INITB.nas @@ -2,6 +2,10 @@ # Copyright (c) 2020 Matthew Maring (mattmaring) +var acconfig_weight_kgs = props.globals.getNode("/systems/acconfig/options/weight-kgs", 1); +# Conversion factor pounds to kilogram +var LBS2KGS = 0.4535924; + var initInputB = func(key, i) { var scratchpad = mcdu_scratchpad.scratchpads[i].scratchpad; if (key == "L1" and !fmgc.FMGCInternal.fuelCalculating) { @@ -16,8 +20,11 @@ var initInputB = func(key, i) { fmgc.blockCalculating.setValue(1); } mcdu_scratchpad.scratchpads[i].empty(); - } else { + } else { var tfs = size(scratchpad); + if (acconfig_weight_kgs.getValue() == 1) { + scratchpad = scratchpad / LBS2KGS; + } if (tfs >= 1 and tfs <= 4) { if (num(scratchpad) != nil and scratchpad >= 0.0 and scratchpad <= 9.9) { fmgc.FMGCInternal.taxiFuel = scratchpad; @@ -48,6 +55,9 @@ var initInputB = func(key, i) { mcdu_scratchpad.scratchpads[i].empty(); } else if (fmgc.FMGCInternal.tripFuel != 0) { var tf = num(scratchpad); + if (acconfig_weight_kgs.getValue() == 1) { + tf = tf / LBS2KGS; + } var tfs = size(scratchpad); if (tfs >= 2 and tfs <= 5 and find("/", scratchpad) == 0) { var perc = num(split("/", scratchpad)[1]); @@ -88,6 +98,9 @@ var initInputB = func(key, i) { mcdu_scratchpad.scratchpads[i].empty(); } else if (find(".", scratchpad) != -1) { var tf = num(scratchpad); + if (acconfig_weight_kgs.getValue() == 1) { + tf = tf / LBS2KGS; + } var tfs = size(scratchpad); if (tfs >= 3 and tfs <= 4 and tf != nil and tf >= 0 and tf <= 10.0) { fmgc.FMGCInternal.altFuel = tf; @@ -113,6 +126,9 @@ var initInputB = func(key, i) { mcdu_scratchpad.scratchpads[i].empty(); } else if (find(".", scratchpad) != -1) { var tf = num(scratchpad); + if (acconfig_weight_kgs.getValue() == 1) { + tf = tf / LBS2KGS; + } var tfs = size(scratchpad); if (tfs >= 3 and tfs <= 4 and tf != nil and tf >= 0 and tf <= 10.0) { fmgc.FMGCInternal.finalFuel = tf; @@ -145,6 +161,9 @@ var initInputB = func(key, i) { mcdu_scratchpad.scratchpads[i].empty(); } else if (find(".", scratchpad) != -1) { var tf = num(scratchpad); + if (acconfig_weight_kgs.getValue() == 1) { + tf = tf / LBS2KGS; + } var tfs = size(scratchpad); if (tfs >= 3 and tfs <= 5 and tf != nil and tf >= 0 and tf <= 80.0) { fmgc.FMGCInternal.minDestFob = tf; @@ -167,6 +186,7 @@ var initInputB = func(key, i) { } else { var zfw_min = 80.6; #make based on performance var zfw_max = 134.5; #61,000 kg, make based on performance + if (size(scratchpad) == 0) { var zfw = pts.Fdm.JSBsim.Inertia.weightLbs.getValue() - pts.Consumables.Fuel.totalFuelLbs.getValue(); fmgc.FMGCInternal.zfw = sprintf("%3.1f", math.round(zfw / 1000, 0.1)); @@ -188,6 +208,9 @@ var initInputB = func(key, i) { } mcdu_scratchpad.scratchpads[i].empty(); } else if (find("/", scratchpad) != -1) { + if (acconfig_weight_kgs.getValue() == 1) { + scratchpad = scratchpad / LBS2KGS; + } var zfwi = split("/", scratchpad); var zfw = num(zfwi[0]); var zfwcg = num(zfwi[1]); @@ -230,6 +253,9 @@ var initInputB = func(key, i) { mcdu_message(i, "NOT ALLOWED"); } } else if (num(scratchpad) != nil and size(scratchpad) > 0 and size(scratchpad) <= 5 and (find(".", scratchpad) == -1 or size(split(".", scratchpad)[1]) <= 1)) { + if (acconfig_weight_kgs.getValue() == 1) { + scratchpad = scratchpad / LBS2KGS; + } if (scratchpad >= zfw_min and scratchpad <= zfw_max) { fmgc.FMGCInternal.zfw = scratchpad; fmgc.FMGCInternal.zfwSet = 1; @@ -314,6 +340,10 @@ var initInputB = func(key, i) { fmgc.FMGCInternal.blockConfirmed = 1; } } else if (tfs >= 1 and tfs <= 5) { + if (acconfig_weight_kgs.getValue() == 1) { + scratchpad = scratchpad / LBS2KGS; + } + if (num(scratchpad) != nil and scratchpad >= 1.0 and scratchpad <= maxblock) { fmgc.FMGCInternal.block = scratchpad; fmgc.FMGCInternal.blockSet = 1; diff --git a/gui/dialogs/refuel.nas b/gui/dialogs/refuel.nas index 0085ebc6..63495a6e 100644 --- a/gui/dialogs/refuel.nas +++ b/gui/dialogs/refuel.nas @@ -6,7 +6,7 @@ # Distribute under the terms of GPLv2. # Conversion factor pounds to kilogram -LBS2KGS = 0.4535924; +var LBS2KGS = 0.4535924; if (pts.Sim.aero.getValue() == "A320-200-CFM") { max_fuel = 42.8; @@ -590,25 +590,45 @@ var refuelClass = { _fuelAdjustDn: func() { target = amount.getValue(); if (target > 0) { - amount.setValue(target - 0.1); - if (target - 0.1 >= 10.0) { - me._FQI_pre.setText(sprintf("%2.1f", target - 0.1)); + if (acconfig_weight_kgs.getValue() == 1) { + amount.setValue(target - 0.1 * LBS2KGS); + if ((target - 0.1) * LBS2KGS >= 10.0) { + me._FQI_pre.setText(sprintf("%2.1f", (target - 0.1) * LBS2KGS)); + } else { + me._FQI_pre.setText(sprintf("%2.2f", (target - 0.1) * LBS2KGS)); + } + systems.fuelSvc.Nodes.requestLbs.setValue((((target - 0.1) * LBS2KGS) - math.round(pts.Consumables.Fuel.totalFuelLbs.getValue() / 1000, 0.1)) * 1000); } else { - me._FQI_pre.setText(sprintf("%2.2f", target - 0.1)); + amount.setValue(target - 0.1); + if (target - 0.1 >= 10.0) { + me._FQI_pre.setText(sprintf("%2.1f", target - 0.1)); + } else { + me._FQI_pre.setText(sprintf("%2.2f", target - 0.1)); + } + systems.fuelSvc.Nodes.requestLbs.setValue(((target - 0.1) - math.round(pts.Consumables.Fuel.totalFuelLbs.getValue() / 1000, 0.1)) * 1000); } - systems.fuelSvc.Nodes.requestLbs.setValue(((target - 0.1) - math.round(pts.Consumables.Fuel.totalFuelLbs.getValue() / 1000, 0.1)) * 1000); } }, _fuelAdjustUp: func() { target = amount.getValue(); if (target < max_fuel) { - amount.setValue(target + 0.1); - if (target + 0.1 >= 10.0) { - me._FQI_pre.setText(sprintf("%2.1f", target + 0.1)); + if (acconfig_weight_kgs.getValue() == 1) { + amount.setValue(target + 0.1); + if ((target + 0.1) * LBS2KGS >= 10.0) { + me._FQI_pre.setText(sprintf("%2.1f", (target + 0.1) * LBS2KGS)); + } else { + me._FQI_pre.setText(sprintf("%2.2f", (target + 0.1) * LBS2KGS)); + } + systems.fuelSvc.Nodes.requestLbs.setValue((((target + 0.1) * LBS2KGS) - math.round(pts.Consumables.Fuel.totalFuelLbs.getValue() / 1000, 0.1)) * 1000); } else { - me._FQI_pre.setText(sprintf("%2.2f", target + 0.1)); + amount.setValue(target + 0.1); + if (target + 0.1 >= 10.0) { + me._FQI_pre.setText(sprintf("%2.1f", target + 0.1)); + } else { + me._FQI_pre.setText(sprintf("%2.2f", target + 0.1)); + } + systems.fuelSvc.Nodes.requestLbs.setValue(((target + 0.1) - math.round(pts.Consumables.Fuel.totalFuelLbs.getValue() / 1000, 0.1)) * 1000); } - systems.fuelSvc.Nodes.requestLbs.setValue(((target + 0.1) - math.round(pts.Consumables.Fuel.totalFuelLbs.getValue() / 1000, 0.1)) * 1000); } }, _onClose: func() {