From 8793cdda358187c5b5f795b80dffa19ec6e4d36e Mon Sep 17 00:00:00 2001 From: legoboyvdlp R Date: Sat, 3 Oct 2020 16:48:31 +0100 Subject: [PATCH] Fix Simbrief parser to respect Simbrief weight option --- Nasal/FMGC/SimbriefParser.nas | 62 +++++++++++++++++++++++++---------- 1 file changed, 44 insertions(+), 18 deletions(-) diff --git a/Nasal/FMGC/SimbriefParser.nas b/Nasal/FMGC/SimbriefParser.nas index f75a56e6..5454566c 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,29 +159,50 @@ 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; setprop("/FMGC/internal/fuel-request-set", 1); setprop("/FMGC/internal/fuel-calculating", 1); setprop("/FMGC/internal/block-calculating", 0); setprop("/FMGC/internal/block-confirmed", 1); - }, }; \ No newline at end of file