From d97e80c240f7d5eaa0292fc82d347e96a6ca362f Mon Sep 17 00:00:00 2001 From: legoboyvdlp R Date: Fri, 10 Jul 2020 20:54:13 +0100 Subject: [PATCH] Bugfixes --- Models/Instruments/MCDU/MCDU.nas | 20 +++++++++----------- Nasal/FMGC/FCU.nas | 2 +- Nasal/FMGC/FMGC.nas | 25 +++++++++++++++---------- Nasal/MCDU/FUELPRED.nas | 7 ++++--- Nasal/MCDU/INITA.nas | 9 +++++---- Nasal/MCDU/INITB.nas | 7 ++++--- Nasal/MCDU/MCDU.nas | 20 ++++++++++---------- 7 files changed, 48 insertions(+), 42 deletions(-) diff --git a/Models/Instruments/MCDU/MCDU.nas b/Models/Instruments/MCDU/MCDU.nas index 392ad70e..86011e9d 100644 --- a/Models/Instruments/MCDU/MCDU.nas +++ b/Models/Instruments/MCDU/MCDU.nas @@ -103,8 +103,6 @@ var vor2CRS = props.globals.getNode("/instrumentation/nav[3]/radials/selected-de # INT-A var depArpt = props.globals.getNode("/FMGC/internal/dep-arpt", 1); var arrArpt = props.globals.getNode("/FMGC/internal/arr-arpt", 1); -var costIndex = props.globals.getNode("/FMGC/internal/cost-index", 1); -var costIndexSet = props.globals.getNode("/FMGC/internal/cost-index-set", 1); var ADIRSMCDUBTN = props.globals.getNode("/controls/adirs/mcducbtn", 1); # IRSINIT variables @@ -1086,16 +1084,16 @@ var canvas_MCDU_base = { me["Simple_L3"].hide(); } - if (!fmgc.FMGCInternal.toFromSet and costIndexSet.getValue() != 1) { + if (!fmgc.FMGCInternal.toFromSet and !fmgc.FMGCInternal.costIndexSet) { me["INITA_CostIndex"].hide(); me["Simple_L5"].setColor(1,1,1); me["Simple_L5"].show(); me["Simple_L5"].setText("---"); - } else if (costIndexSet.getValue() == 1) { + } else if (fmgc.FMGCInternal.costIndexSet) { me["INITA_CostIndex"].hide(); me["Simple_L5"].setColor(0.0901,0.6039,0.7176); me["Simple_L5"].show(); - me["Simple_L5"].setText(sprintf("%s", costIndex.getValue())); + me["Simple_L5"].setText(sprintf("%s", fmgc.FMGCInternal.costIndex)); } else { me["INITA_CostIndex"].show(); me["Simple_L5"].hide(); @@ -2519,9 +2517,9 @@ var canvas_MCDU_base = { } me["Simple_L2S"].setText(" CI"); - if (costIndexSet.getValue() == 1) { + if (fmgc.FMGCInternal.costIndexSet) { me["Simple_L2"].setColor(0.0901,0.6039,0.7176); - me["Simple_L2"].setText(sprintf(" %s", costIndex.getValue())); + me["Simple_L2"].setText(sprintf(" %s", fmgc.FMGCInternal.costIndex)); } else { me["Simple_L2"].setColor(1,1,1); me["Simple_L2"].setText(" ---"); @@ -2672,9 +2670,9 @@ var canvas_MCDU_base = { me.fontLeft(0, 0, 0, default, 0, 0); } - if (costIndexSet.getValue() == 1) { + if (fmgc.FMGCInternal.costIndexSet) { me["Simple_L2"].setColor(0.0901,0.6039,0.7176); - me["Simple_L2"].setText(sprintf(" %s", costIndex.getValue())); + me["Simple_L2"].setText(sprintf(" %s", fmgc.FMGCInternal.costIndex)); } else { me["Simple_L2"].setColor(1,1,1); me["Simple_L2"].setText(" ---"); @@ -2833,9 +2831,9 @@ var canvas_MCDU_base = { me.fontLeft(0, 0, 0, default, 0, 0); } - if (costIndexSet.getValue() == 1) { + if (fmgc.FMGCInternal.costIndexSet) { me["Simple_L2"].setColor(0.0901,0.6039,0.7176); - me["Simple_L2"].setText(sprintf(" %2.0f", costIndex.getValue())); + me["Simple_L2"].setText(sprintf(" %2.0f", fmgc.FMGCInternal.costIndex)); } else { me["Simple_L2"].setColor(1,1,1); me["Simple_L2"].setText(" ---"); diff --git a/Nasal/FMGC/FCU.nas b/Nasal/FMGC/FCU.nas index f9d709c4..36b07a56 100644 --- a/Nasal/FMGC/FCU.nas +++ b/Nasal/FMGC/FCU.nas @@ -196,7 +196,7 @@ var FCUController = { }, SPDPush: func() { if (me.FCUworking) { - if (fmgc.FMGCInternal.crzSet and getprop("FMGC/internal/cost-index-set") == 1) { + if (fmgc.FMGCInternal.crzSet and fmgc.FMGCInternal.costIndexSet) { spdManaged.setBoolValue(1); fmgc.ManagedSPD.start(); } diff --git a/Nasal/FMGC/FMGC.nas b/Nasal/FMGC/FMGC.nas index 6b1d1848..f59057ad 100644 --- a/Nasal/FMGC/FMGC.nas +++ b/Nasal/FMGC/FMGC.nas @@ -148,20 +148,24 @@ var FMGCInternal = { transAltSet: 0, # INIT A + altAirport: "", + altAirportSet: 0, + altSelected: 0, + arrApt: "", + costIndex: 0, + costIndexSet: 0, crzFt: 10000, crzFl: 0, crzSet: 0, crzTemp: 15, crzTempSet: 0, - tropo: 36090, - tropoSet: 0, flightNum: "", flightNumSet: 0, - altAirport: "", - altAirportSet: 0, - altSelected: 0, - arrApt: "", + gndTemp: 15, + gndTempSet: 0, depApt: "", + tropo: 36090, + tropoSet: 0, toFromSet: 0, }; @@ -173,9 +177,10 @@ var postInit = func() { } var FMGCNodes = { + costIndex: props.globals.initNode("/FMGC/internal/cost-index", 0, "DOUBLE"), + toFromSet: props.globals.initNode("/FMGC/internal/tofrom-set", 0, "BOOL"), v1: props.globals.initNode("/FMGC/internal/v1", 0, "DOUBLE"), v1set: props.globals.initNode("/FMGC/internal/v1-set", 0, "BOOL"), - toFromSet: props.globals.initNode("/FMGC/internal/tofrom-set", 0, "BOOL"), }; ############ @@ -889,7 +894,7 @@ var adf1 = func { ################# var ManagedSPD = maketimer(0.25, func { - if (FMGCInternal.crzSet and getprop("/FMGC/internal/cost-index-set") == 1) { + if (FMGCInternal.crzSet and FMGCInternal.costIndex) { if (getprop("/it-autoflight/input/spd-managed") == 1) { altitude = getprop("/instrumentation/altimeter/indicated-altitude-ft"); mode = getprop("/modes/pfd/fma/pitch-mode"); @@ -1109,8 +1114,8 @@ setlistener("/FMGC/internal/fuel-calculating", func() { var timer30secLanding = maketimer(1, func() { if (pts.Sim.Time.elapsedSec.getValue() > getprop("/FMGC/internal/landing-time") + 30) { setprop("/FMGC/status/phase", 7); - if (getprop("/FMGC/internal/cost-index-set")) { - setprop("/FMGC/internal/last-cost-index", getprop("/FMGC/internal/cost-index")); + if (FMGCInternal.costIndexSet) { + setprop("/FMGC/internal/last-cost-index", FMGCInternal.costIndex); } else { setprop("/FMGC/internal/last-cost-index", 0); } diff --git a/Nasal/MCDU/FUELPRED.nas b/Nasal/MCDU/FUELPRED.nas index 42c77275..b83475c2 100644 --- a/Nasal/MCDU/FUELPRED.nas +++ b/Nasal/MCDU/FUELPRED.nas @@ -218,10 +218,11 @@ var fuelPredInput = func(key, i) { mcdu_message(i, "NOT ALLOWED"); } - if (!getprop("/FMGC/internal/cost-index-set") and fmgc.FMGCInternal.toFromSet) { + if (!fmgc.FMGCInternal.costIndexSet and fmgc.FMGCInternal.toFromSet) { mcdu_message(i, "USING COST INDEX N", getprop("/FMGC/internal/last-cost-index") or 0); - setprop("/FMGC/internal/cost-index-set", 1); - setprop("/FMGC/internal/cost-index", getprop("/FMGC/internal/last-cost-index") or 0); + fmgc.FMGCInternal.costIndexSet = 1; + fmgc.FMGCInternal.costIndex = getprop("/FMGC/internal/last-cost-index") or 0; + fmgc.FMGCNodes.setValue(fmgc.FMGCInternal.costIndex); } } } else if (key == "R4") { diff --git a/Nasal/MCDU/INITA.nas b/Nasal/MCDU/INITA.nas index 0e2ad0cf..cb559c31 100644 --- a/Nasal/MCDU/INITA.nas +++ b/Nasal/MCDU/INITA.nas @@ -60,16 +60,17 @@ var initInputA = func(key, i) { } } else if (key == "L5") { if (scratchpad == "CLR") { - setprop("/FMGC/internal/cost-index", 0); - setprop("/FMGC/internal/cost-index-set", 0); + fmgc.FMGCInternal.costIndex = 0; + fmgc.FMGCInternal.costIndexSet = 0; + fmgc.FMGCNodes.costIndex.setValue(0); mcdu_scratchpad.scratchpads[i].empty(); } else { var ci = int(scratchpad); var cis = size(scratchpad); if (cis >= 1 and cis <= 3) { if (ci != nil and ci >= 0 and ci <= 999) { - setprop("/FMGC/internal/cost-index", ci); - setprop("/FMGC/internal/cost-index-set", 1); + fmgc.FMGCInternal.costIndex = ci; + fmgc.FMGCInternal.costIndexSet = 1; mcdu_scratchpad.scratchpads[i].empty(); } else { mcdu_message(i, "NOT ALLOWED"); diff --git a/Nasal/MCDU/INITB.nas b/Nasal/MCDU/INITB.nas index 17c259bd..b64cfd53 100644 --- a/Nasal/MCDU/INITB.nas +++ b/Nasal/MCDU/INITB.nas @@ -233,10 +233,11 @@ var initInputB = func(key, i) { mcdu_message(i, "NOT ALLOWED"); } - if (!getprop("/FMGC/internal/cost-index-set") and fmgc.FMGCInternal.toFromSet) { + if (!fmgc.FMGCInternal.costIndexSet and fmgc.FMGCInternal.toFromSet) { mcdu_message(i, "USING COST INDEX N", getprop("/FMGC/internal/last-cost-index") or 0); - setprop("/FMGC/internal/cost-index-set", 1); - setprop("/FMGC/internal/cost-index", getprop("/FMGC/internal/last-cost-index") or 0); + fmgc.FMGCInternal.costIndexSet = 1; + fmgc.FMGCInternal.costIndex = getprop("/FMGC/internal/last-cost-index") or 0; + fmgc.FMGCNodes.setValue(fmgc.FMGCInternal.costIndex); } } } else if (key == "R2" and !getprop("/FMGC/internal/fuel-calculating")) { diff --git a/Nasal/MCDU/MCDU.nas b/Nasal/MCDU/MCDU.nas index 1adf71d7..7106285d 100644 --- a/Nasal/MCDU/MCDU.nas +++ b/Nasal/MCDU/MCDU.nas @@ -50,28 +50,28 @@ var MCDU_reset = func(i) { setprop("/FMGC/internal/adf2freq-set", 0); # INT-A - fmgc.FMGCInternal.flightNum = ""; - fmgc.FMGCInternal.flightNumSet = 0; - fmgc.FMGCInternal.arrApt = ""; - fmgc.FMGCInternal.depApt = ""; - fmgc.FMGCInternal.toFromSet = 0; - fmgc.FMGCNodes.toFromSet.setValue(0); fmgc.FMGCInternal.altAirport = ""; fmgc.FMGCInternal.altAirportSet = 0; - setprop("/FMGC/internal/cost-index", "0"); - setprop("/FMGC/internal/cost-index-set", 0); + fmgc.FMGCInternal.arrApt = ""; + fmgc.FMGCInternal.costIndex = 0; + fmgc.FMGCInternal.costIndexSet = 0; fmgc.FMGCInternal.crzFt = 10000; fmgc.altvert(); fmgc.updateRouteManagerAlt(); fmgc.FMGCInternal.crzFl = 100; fmgc.FMGCInternal.crzSet = 0; updateCrzLvlCallback(); - fmgc.FMGCInternal.tropo = 36090; - fmgc.FMGCInternal.tropoSet = 0; fmgc.FMGCInternal.crzTemp = 15; fmgc.FMGCInternal.crzTempSet = 0; + fmgc.FMGCInternal.depApt = ""; + fmgc.FMGCInternal.flightNum = ""; + fmgc.FMGCInternal.flightNumSet = 0; fmgc.FMGCInternal.gndTemp = -99; fmgc.FMGCInternal.gndTempSet = 0; + fmgc.FMGCInternal.toFromSet = 0; + fmgc.FMGCNodes.toFromSet.setValue(0); + fmgc.FMGCInternal.tropo = 36090; + fmgc.FMGCInternal.tropoSet = 0; # IRSINIT setprop("/FMGC/internal/align-set", 0);