diff --git a/Models/Instruments/MCDU/MCDU.nas b/Models/Instruments/MCDU/MCDU.nas index e0eebc6e..f2b8e01c 100644 --- a/Models/Instruments/MCDU/MCDU.nas +++ b/Models/Instruments/MCDU/MCDU.nas @@ -101,30 +101,12 @@ var vor1CRS = props.globals.getNode("/instrumentation/nav[2]/radials/selected-de var vor2CRS = props.globals.getNode("/instrumentation/nav[3]/radials/selected-deg", 1); # INT-A -var flightNum = props.globals.getNode("/MCDUC/flight-num", 1); -var flightNumSet = props.globals.getNode("/MCDUC/flight-num-set", 1); -var depArpt = props.globals.getNode("/FMGC/internal/dep-arpt", 1); -var arrArpt = props.globals.getNode("/FMGC/internal/arr-arpt", 1); -var toFromSet = props.globals.getNode("/FMGC/internal/tofrom-set", 1); -var alt_airport = props.globals.getNode("/FMGC/internal/alt-airport", 1); -var altSet = props.globals.getNode("/FMGC/internal/alt-set", 1); -var costIndex = props.globals.getNode("/FMGC/internal/cost-index", 1); -var costIndexSet = props.globals.getNode("/FMGC/internal/cost-index-set", 1); -var cruiseFL = props.globals.getNode("/FMGC/internal/cruise-fl", 1); -var cruiseSet = props.globals.getNode("/FMGC/internal/cruise-lvl-set", 1); -var cruiseTemp = props.globals.getNode("/FMGC/internal/cruise-temp", 1); -var cruiseTempSet = props.globals.getNode("/FMGC/internal/cruise-temp-set", 1); -var tropo = props.globals.getNode("/FMGC/internal/tropo", 1); -var tropoSet = props.globals.getNode("/FMGC/internal/tropo-set", 1); -var gndtemp = props.globals.getNode("/FMGC/internal/gndtemp", 1); -var gndtempSet = props.globals.getNode("/FMGC/internal/gndtemp-set", 1); var ADIRSMCDUBTN = props.globals.getNode("/controls/adirs/mcducbtn", 1); # IRSINIT variables var align_set = props.globals.getNode("/FMGC/internal/align-set", 1); # ROUTE SELECTION -var alt_selected = props.globals.getNode("/FMGC/internal/alt-selected", 1); # INT-B var zfwcg = props.globals.getNode("/FMGC/internal/zfwcg", 1); @@ -171,9 +153,6 @@ var fffq_sensor = props.globals.getNode("/FMGC/internal/fffq-sensor", 1); var gw = props.globals.getNode("/FMGC/internal/fuel-pred-gw", 1); var cg = props.globals.getNode("/FMGC/internal/cg", 1); -# PROG -var cruiseFL_prog = props.globals.getNode("/FMGC/internal/cruise-fl-prog", 1); - # PERF var altitude = props.globals.getNode("/instrumentation/altimeter/indicated-altitude-ft", 1); @@ -359,8 +338,8 @@ var canvas_MCDU_base = { if (myFpln[i] != nil) { - if (flightNumSet.getValue()) { - me["FPLN_Callsign"].setText(flightNum.getValue()); + if (fmgc.FMGCInternal.flightNumSet) { + me["FPLN_Callsign"].setText(fmgc.FMGCInternal.flightNum); me["FPLN_Callsign"].show(); } else { me["FPLN_Callsign"].hide(); @@ -593,7 +572,7 @@ var canvas_MCDU_base = { me["arrow5R"].setColor(getprop("/MCDUC/colors/blu/r"),getprop("/MCDUC/colors/blu/g"),getprop("/MCDUC/colors/blu/b")); } - if (getprop("/FMGC/status/phase") == 0 or getprop("/FMGC/status/phase") == 7) { + if (fmgc.FMGCInternal.phase == 0 or fmgc.FMGCInternal.phase == 7) { me["Simple_L5"].show(); me["Simple_L5S"].show(); } else { @@ -1095,53 +1074,54 @@ var canvas_MCDU_base = { pageSwitch[i].setBoolValue(1); } - if (flightNumSet.getValue() == 1) { + if (fmgc.FMGCInternal.flightNumSet) { me["INITA_FltNbr"].hide(); me["Simple_L3"].show(); } else { me["INITA_FltNbr"].show(); me["Simple_L3"].hide(); } - if (toFromSet.getValue() != 1 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(); } - if (toFromSet.getValue() != 1 and cruiseSet.getValue() != 1) { + if (!fmgc.FMGCInternal.toFromSet and !fmgc.FMGCInternal.crzSet) { me["INITA_CruiseFLTemp"].hide(); me["Simple_L6"].setColor(1,1,1); me["Simple_L6"].setText("-----/---g"); - } else if (cruiseSet.getValue() == 1 and cruiseTempSet.getValue() == 1) { + } else if (fmgc.FMGCInternal.crzSet and fmgc.FMGCInternal.crzTempSet) { me["INITA_CruiseFLTemp"].hide(); me["Simple_L6"].setColor(0.0901,0.6039,0.7176); - me["Simple_L6"].setText(sprintf("%s", "FL" ~ cruiseFL.getValue()) ~ sprintf("/%sg", cruiseTemp.getValue())); - } else if (cruiseSet.getValue() == 1) { + me["Simple_L6"].setText(sprintf("%s", "FL" ~ fmgc.FMGCInternal.crzFl) ~ sprintf("/%sg", fmgc.FMGCInternal.crzTemp)); + } else if (fmgc.FMGCInternal.crzSet) { me["INITA_CruiseFLTemp"].hide(); me["Simple_L6"].setColor(0.0901,0.6039,0.7176); - setprop("/FMGC/internal/cruise-temp", 15 - (2 * cruiseFL.getValue() / 10)); - setprop("/FMGC/internal/cruise-temp-set", 1); - me["Simple_L6"].setText(sprintf("%s", "FL" ~ cruiseFL.getValue()) ~ sprintf("/%sg", cruiseTemp.getValue())); + fmgc.FMGCInternal.crzTemp = 15 - (2 * fmgc.FMGCInternal.crzFl / 10); + fmgc.FMGCInternal.crzTempSet = 1; + me["Simple_L6"].setText(sprintf("%s", "FL" ~ fmgc.FMGCInternal.crzFl) ~ sprintf("/%sg", fmgc.FMGCInternal.crzTemp)); } else { me["INITA_CruiseFLTemp"].show(); me["Simple_L6"].setColor(0.7333,0.3803,0); me["Simple_L6"].setText(" g"); } - if (toFromSet.getValue() == 1) { + if (fmgc.FMGCInternal.toFromSet) { me["INITA_CoRoute"].hide(); me["INITA_FromTo"].hide(); me["Simple_L1"].show(); me["Simple_L2"].setColor(0.0901,0.6039,0.7176); - if (altSet.getValue() == 1) { - me["Simple_L2"].setText(alt_airport.getValue()); + if (fmgc.FMGCInternal.altAirportSet) { + me["Simple_L2"].setText(fmgc.FMGCInternal.altAirport); } else { me["Simple_L2"].setText("NONE"); } @@ -1167,24 +1147,24 @@ var canvas_MCDU_base = { me["Simple_R3"].setColor(WHITE); me.showRightArrow(0, 0, 1, 0, 0, 0); } - if (tropoSet.getValue() == 1) { + if (fmgc.FMGCInternal.tropoSet) { me["Simple_R5"].setFontSize(normal); } else { me["Simple_R5"].setFontSize(small); } me["Simple_R6S"].setText("GND TEMP"); - if (getprop("/FMGC/status/phase") == 0 and !getprop("/FMGC/internal/gndtemp-set")) { - setprop("/FMGC/internal/gndtemp", 15 - (2 * getprop("/position/gear-agl-ft") / 1000)); - me["Simple_R6"].setText(sprintf("%.0fg", gndtemp.getValue())); + if (fmgc.FMGCInternal.phase == 0 and !fmgc.FMGCInternal.gndTempSet) { + fmgc.FMGCInternal.gndTemp = 15 - (2 * getprop("/position/gear-agl-ft") / 1000); + me["Simple_R6"].setText(sprintf("%.0fg", fmgc.FMGCInternal.gndTemp)); me["Simple_R6"].setFontSize(small); } else { - if (getprop("/FMGC/internal/gndtemp-set")) { + if (fmgc.FMGCInternal.gndTempSet) { me["Simple_R6"].setFontSize(normal); } else { me["Simple_R6"].setFontSize(small); } - me["Simple_R6"].setText(sprintf("%.0fg", gndtemp.getValue())); + me["Simple_R6"].setText(sprintf("%.0fg", fmgc.FMGCInternal.gndTemp)); } me["Simple_L1S"].setText(" CO RTE"); @@ -1193,16 +1173,16 @@ var canvas_MCDU_base = { me["Simple_L5S"].setText("COST INDEX"); me["Simple_L6S"].setText("CRZ FL/TEMP"); me["Simple_L1"].setText("NONE"); - me["Simple_L3"].setText(sprintf("%s", flightNum.getValue())); + me["Simple_L3"].setText(sprintf("%s", fmgc.FMGCInternal.flightNum)); me["Simple_R1S"].setText("FROM/TO "); me["Simple_R2S"].setText("INIT "); me["Simple_R5S"].setText("TROPO"); - me["Simple_R1"].setText(sprintf("%s", depArpt.getValue() ~ "/" ~ arrArpt.getValue())); + me["Simple_R1"].setText(sprintf("%s", fmgc.FMGCInternal.depApt ~ "/" ~ fmgc.FMGCInternal.arrApt)); me["Simple_R2"].setText("REQUEST "); me["Simple_R3"].setText("IRS INIT "); me["Simple_R4"].setText("WIND "); - me["Simple_R5"].setText(sprintf("%5.0f", tropo.getValue())); + me["Simple_R5"].setText(sprintf("%5.0f", fmgc.FMGCInternal.tropo)); } else if (page == "IRSINIT") { if (!pageSwitch[i].getBoolValue()) { me["Simple"].show(); @@ -1272,7 +1252,7 @@ var canvas_MCDU_base = { me["IRSINIT_2"].hide(); } - if (toFromSet.getValue() == 1) { + if (fmgc.FMGCInternal.toFromSet) { degrees = getprop("/FMGC/internal/align-ref-lat-degrees"); minutes = getprop("/FMGC/internal/align-ref-lat-minutes"); sign = getprop("/FMGC/internal/align-ref-lat-sign"); @@ -1427,12 +1407,12 @@ var canvas_MCDU_base = { me["Simple_L1"].setText("NONE"); me["Simple_L6"].setText(" RETURN"); - if (toFromSet.getValue() == 1 and alt_selected.getValue() == 0) { - me["Simple_Title"].setText(sprintf("%s", depArpt.getValue() ~ "/" ~ arrArpt.getValue())); - } else if (toFromSet.getValue() == 0 and alt_airport.getValue() != "" and alt_selected.getValue() == 1) { - me["Simple_Title"].setText(sprintf("%s", alt_airport.getValue())); - } else if (toFromSet.getValue() == 1 and alt_airport.getValue() != "" and alt_selected.getValue() == 1) { - me["Simple_Title"].setText(sprintf("%s", arrArpt.getValue() ~ "/" ~ alt_airport.getValue())); + if (fmgc.FMGCInternal.toFromSet and !fmgc.FMGCInternal.altSelected) { + me["Simple_Title"].setText(sprintf("%s", fmgc.FMGCInternal.depApt ~ "/" ~ fmgc.FMGCInternal.arrApt)); + } else if (!fmgc.FMGCInternal.toFromSet and fmgc.FMGCInternal.altAirport != "" and fmgc.FMGCInternal.altSelected) { + me["Simple_Title"].setText(sprintf("%s", fmgc.FMGCInternal.altAirport)); + } else if (fmgc.FMGCInternal.toFromSet and fmgc.FMGCInternal.altAirport != "" and fmgc.FMGCInternal.altSelected) { + me["Simple_Title"].setText(sprintf("%s", fmgc.FMGCInternal.arrApt ~ "/" ~ fmgc.FMGCInternal.altAirport)); } else { me["Simple_Title"].setText("ROUTE SELECTION"); } @@ -1681,7 +1661,7 @@ var canvas_MCDU_base = { me["Simple_C3"].setText(sprintf("/%.1f ", rte_percent.getValue())); } } - if (altSet.getValue() == 1) { + if (fmgc.FMGCInternal.crzSet == 1) { me["Simple_L4"].setText(sprintf("%.1f", alt_fuel.getValue())); me["Simple_L4"].setColor(BLUE); me["Simple_C4"].show(); @@ -1788,7 +1768,7 @@ var canvas_MCDU_base = { me["Simple_C3"].setFontSize(small); } - if (alt_fuel_set.getValue() == 1 and altSet.getValue() == 1) { + if (alt_fuel_set.getValue() == 1 and fmgc.FMGCInternal.crzSet == 1) { me["Simple_L4"].setFontSize(normal); } else { me["Simple_L4"].setFontSize(small); @@ -1872,15 +1852,15 @@ var canvas_MCDU_base = { pageSwitch[i].setBoolValue(1); } - if (!engrdy.getBoolValue() or toFromSet.getValue() != 1) { + if (!engrdy.getBoolValue() or !fmgc.FMGCInternal.toFromSet) { me["Simple_L1"].setText("----"); } else { - me["Simple_L1"].setText(arrArpt.getValue()); + me["Simple_L1"].setText(fmgc.FMGCInternal.arrApt); } - if (!engrdy.getBoolValue() or alt_airport.getValue() == "") { + if (!engrdy.getBoolValue() or !fmgc.FMGCInternal.altAirportSet) { me["Simple_L2"].setText("----"); } else { - me["Simple_L2"].setText(alt_airport.getValue()); + me["Simple_L2"].setText(fmgc.FMGCInternal.altAirport); } me["Simple_L1S"].setText("AT"); @@ -1960,7 +1940,7 @@ var canvas_MCDU_base = { me["Simple_C3B"].setText(sprintf("/%.1f ", rte_percent.getValue())); } } - if (altSet.getValue() == 1) { + if (fmgc.FMGCInternal.crzSet == 1) { me["Simple_L4"].setText(sprintf("%.1f", alt_fuel.getValue())); me["Simple_L4"].setColor(BLUE); me["Simple_C4"].show(); @@ -2056,7 +2036,7 @@ var canvas_MCDU_base = { me["Simple_C3B"].setFontSize(small); } - if (alt_fuel_set.getValue() == 1 and altSet.getValue() == 1) { + if (alt_fuel_set.getValue() == 1 and fmgc.FMGCInternal.crzSet == 1) { me["Simple_L4"].setFontSize(normal); } else { me["Simple_L4"].setFontSize(small); @@ -2083,16 +2063,16 @@ var canvas_MCDU_base = { } } else if (page == "PROGTO" or page == "PROGCLB" or page == "PROGCRZ" or page == "PROGDES") { - if (getprop("/FMGC/status/phase") == 0 or getprop("/FMGC/status/phase") == 1) { + if (fmgc.FMGCInternal.phase == 0 or fmgc.FMGCInternal.phase == 1) { setprop("/MCDU[" ~ i ~ "]/page", "PROGTO"); page = "PROGTO"; - } else if (getprop("/FMGC/status/phase") == 2) { + } else if (fmgc.FMGCInternal.phase == 2) { setprop("/MCDU[" ~ i ~ "]/page", "PROGCLB"); page = "PROGCLB"; - } else if (getprop("/FMGC/status/phase") == 3) { + } else if (fmgc.FMGCInternal.phase == 3) { setprop("/MCDU[" ~ i ~ "]/page", "PROGCRZ"); page = "PROGCRZ"; - } else if (getprop("/FMGC/status/phase") == 4 or getprop("/FMGC/status/phase") == 5 or getprop("/FMGC/status/phase") == 6) { + } else if (fmgc.FMGCInternal.phase == 4 or fmgc.FMGCInternal.phase == 5 or fmgc.FMGCInternal.phase == 6) { setprop("/MCDU[" ~ i ~ "]/page", "PROGDES"); page = "PROGDES"; } @@ -2112,15 +2092,15 @@ var canvas_MCDU_base = { me["PERFAPPR"].hide(); me["PERFGA"].hide(); - if (flightNumSet.getValue() == 1) { + if (fmgc.FMGCInternal.flightNumSet) { if (page == "PROGTO") { - me["Simple_Title"].setText(sprintf("TAKE OFF %s", flightNum.getValue())); + me["Simple_Title"].setText(sprintf("TAKE OFF %s", fmgc.FMGCInternal.flightNum)); } else if (page == "PROGCLB") { - me["Simple_Title"].setText(sprintf("CLIMB %s", flightNum.getValue())); + me["Simple_Title"].setText(sprintf("CLIMB %s", fmgc.FMGCInternal.flightNum)); } else if (page == "PROGCRZ") { - me["Simple_Title"].setText(sprintf("CRUISE %s", flightNum.getValue())); + me["Simple_Title"].setText(sprintf("CRUISE %s", fmgc.FMGCInternal.flightNum)); } else if (page == "PROGDES") { - me["Simple_Title"].setText(sprintf("DESCENT %s", flightNum.getValue())); + me["Simple_Title"].setText(sprintf("DESCENT %s", fmgc.FMGCInternal.flightNum)); } } else { if (page == "PROGTO") { @@ -2186,11 +2166,11 @@ var canvas_MCDU_base = { pageSwitch[i].setBoolValue(1); } - if (cruiseSet.getValue() == 1 and page != "PROGDES") { - if (getprop("/it-autoflight/input/alt") > cruiseFL_prog.getValue() * 100) { + if (fmgc.FMGCInternal.crzSet and page != "PROGDES") { + if (getprop("/it-autoflight/input/alt") > fmgc.FMGCInternal.crzProg * 100) { me["Simple_L1"].setText(sprintf("%s", "FL" ~ getprop("/it-autoflight/input/alt") / 100)); } else { - me["Simple_L1"].setText(sprintf("%s", "FL" ~ cruiseFL_prog.getValue())); + me["Simple_L1"].setText(sprintf("%s", "FL" ~ fmgc.FMGCInternal.crzProg)); } } else { me["Simple_L1"].setText("----"); @@ -2306,7 +2286,7 @@ var canvas_MCDU_base = { me["Simple_L4"].setFontSize(small); } - if (getprop("/FMGC/status/phase") == 0 or getprop("/FMGC/status/phase") == 7) { + if (fmgc.FMGCInternal.phase == 0 or fmgc.FMGCInternal.phase == 7) { me["Simple_L6_Arrow"].show(); me["Simple_L6"].show(); me["Simple_L6S"].show(); @@ -2316,7 +2296,7 @@ var canvas_MCDU_base = { me["Simple_L6S"].hide(); } - if (getprop("/FMGC/status/phase") == 1) { + if (fmgc.FMGCInternal.phase == 1) { me["Simple_Title"].setColor(0.0509,0.7529,0.2941); } else { me["Simple_Title"].setColor(1, 1, 1); @@ -2389,7 +2369,7 @@ var canvas_MCDU_base = { me["Simple_R5"].setFontSize(small); } - if ((zfwSet.getValue() == 1 and blockSet.getValue() == 1) or getprop("/FMGC/status/phase") == 1) { + if ((zfwSet.getValue() == 1 and blockSet.getValue() == 1) or fmgc.FMGCInternal.phase == 1) { me["Simple_C1"].setText(sprintf("%3.0f", getprop("/FMGC/internal/computed-speeds/flap2_to"))); me["Simple_C2"].setText(sprintf("%3.0f", getprop("/FMGC/internal/computed-speeds/slat_to"))); me["Simple_C3"].setText(sprintf("%3.0f", getprop("/FMGC/internal/computed-speeds/clean_to"))); @@ -2460,7 +2440,7 @@ var canvas_MCDU_base = { pageSwitch[i].setBoolValue(1); } - if (getprop("/FMGC/status/phase") == 2) { + if (fmgc.FMGCInternal.phase == 2) { me["Simple_Title"].setColor(0.0509,0.7529,0.2941); me.showLeft(0, 0, 0, 0, 1, 0); me.showLeftS(0, 0, 0, 0, 1, 0); @@ -2490,7 +2470,7 @@ var canvas_MCDU_base = { me.colorLeft("ack", "ack", "ack", "ack", "ack", "amb"); me.colorLeftS("ack", "ack", "ack", "ack", "ack", "amb"); me.colorLeftArrow("ack", "ack", "ack", "ack", "ack", "amb"); - } else if (getprop("/FMGC/status/phase") == 5) { + } else if (fmgc.FMGCInternal.phase == 5) { me["Simple_L6S"].setText(""); me["Simple_L6"].setText(""); me.colorLeft("ack", "ack", "ack", "ack", "ack", "blu"); @@ -2535,9 +2515,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(" ---"); @@ -2626,7 +2606,7 @@ var canvas_MCDU_base = { pageSwitch[i].setBoolValue(1); } - if (getprop("/FMGC/status/phase") == 3) { + if (fmgc.FMGCInternal.phase == 3) { me["Simple_Title"].setColor(0.0509,0.7529,0.2941); if (managedSpeed.getValue() == 1) { @@ -2650,7 +2630,7 @@ var canvas_MCDU_base = { me.colorLeft("ack", "ack", "ack", "ack", "ack", "amb"); me.colorLeftS("ack", "ack", "ack", "ack", "ack", "amb"); me.colorLeftArrow("ack", "ack", "ack", "ack", "ack", "amb"); - } else if (getprop("/FMGC/status/phase") == 5) { + } else if (fmgc.FMGCInternal.phase == 5) { me["Simple_L6S"].setText(""); me["Simple_L6"].setText(""); me.colorLeft("ack", "ack", "ack", "ack", "ack", "blu"); @@ -2688,9 +2668,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(" ---"); @@ -2777,7 +2757,7 @@ var canvas_MCDU_base = { pageSwitch[i].setBoolValue(1); } - if (getprop("/FMGC/status/phase") == 4) { + if (fmgc.FMGCInternal.phase == 4) { me["Simple_Title"].setColor(0.0509,0.7529,0.2941); me.showLeft(0, 0, 0, 0, 1, 0); me.showRight(0, 1, 0, 1, 0, 0); @@ -2806,7 +2786,7 @@ var canvas_MCDU_base = { me.colorLeft("ack", "ack", "ack", "ack", "ack", "amb"); me.colorLeftS("ack", "ack", "ack", "ack", "ack", "amb"); me.colorLeftArrow("ack", "ack", "ack", "ack", "ack", "amb"); - } else if (getprop("/FMGC/status/phase") == 5) { + } else if (fmgc.FMGCInternal.phase == 5) { me["Simple_L6S"].setText(""); me["Simple_L6"].setText(""); me.colorLeft("ack", "ack", "ack", "ack", "ack", "blu"); @@ -2849,9 +2829,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(" ---"); @@ -2946,7 +2926,7 @@ var canvas_MCDU_base = { pageSwitch[i].setBoolValue(1); } - if (getprop("/FMGC/status/phase") == 5) { + if (fmgc.FMGCInternal.phase == 5) { me["Simple_Title"].setColor(0.0509,0.7529,0.2941); } else { me["Simple_Title"].setColor(1, 1, 1); @@ -3046,7 +3026,7 @@ var canvas_MCDU_base = { me["Simple_R6"].setText("PHASE "); me["Simple_L5S"].setText(" VAPP"); - if ((zfwSet.getValue() == 1 and blockSet.getValue() == 1) or getprop("/FMGC/status/phase") == 5) { + if ((zfwSet.getValue() == 1 and blockSet.getValue() == 1) or fmgc.FMGCInternal.phase == 5) { me["Simple_C1"].setText(sprintf("%3.0f", getprop("/FMGC/internal/computed-speeds/flap2_appr"))); me["Simple_C2"].setText(sprintf("%3.0f", getprop("/FMGC/internal/computed-speeds/slat_appr"))); me["Simple_C3"].setText(sprintf("%3.0f", getprop("/FMGC/internal/computed-speeds/clean_appr"))); @@ -3134,7 +3114,7 @@ var canvas_MCDU_base = { pageSwitch[i].setBoolValue(1); } - if (getprop("/FMGC/status/phase") == 6) { + if (fmgc.FMGCInternal.phase == 6) { me["Simple_Title"].setColor(0.0509,0.7529,0.2941); } else { me["Simple_Title"].setColor(1, 1, 1); @@ -3158,7 +3138,7 @@ var canvas_MCDU_base = { me["Simple_R5"].setText(sprintf("%3.0f", engOutAcc.getValue())); me["Simple_R5S"].setText("ENG OUT ACC"); - if ((zfwSet.getValue() == 1 and blockSet.getValue() == 1) or getprop("/FMGC/status/phase") == 6) { + if ((zfwSet.getValue() == 1 and blockSet.getValue() == 1) or fmgc.FMGCInternal.phase == 6) { me["Simple_C1"].setText(sprintf("%3.0f", getprop("/FMGC/internal/computed-speeds/flap2_appr"))); me["Simple_C2"].setText(sprintf("%3.0f", getprop("/FMGC/internal/computed-speeds/slat_appr"))); me["Simple_C3"].setText(sprintf("%3.0f", getprop("/FMGC/internal/computed-speeds/clean_appr"))); diff --git a/Models/Instruments/PFD/PFD.nas b/Models/Instruments/PFD/PFD.nas index a8f9b308..3604d36c 100644 --- a/Models/Instruments/PFD/PFD.nas +++ b/Models/Instruments/PFD/PFD.nas @@ -88,7 +88,6 @@ var fd_roll = props.globals.getNode("/it-autoflight/fd/roll-bar", 1); var fd_pitch = props.globals.getNode("/it-autoflight/fd/pitch-bar", 1); var decision = props.globals.getNode("/instrumentation/mk-viii/inputs/arinc429/decision-height", 1); var slip_skid = props.globals.getNode("/instrumentation/pfd/slip-skid", 1); -var FMGCphase = props.globals.getNode("/FMGC/status/phase", 1); var loc = props.globals.getNode("/instrumentation/nav[0]/heading-needle-deflection-norm", 1); var gs = props.globals.getNode("/instrumentation/nav[0]/gs-needle-deflection-norm", 1); var show_hdg = props.globals.getNode("/it-autoflight/custom/show-hdg", 1); @@ -638,7 +637,7 @@ var canvas_PFD_base = { me["QNH"].hide(); me["QNH_setting"].hide(); - if (altitude.getValue() < fmgc.FMGCInternal.transAlt and FMGCphase.getValue() == '4') { + if (altitude.getValue() < fmgc.FMGCInternal.transAlt and fmgc.FMGCInternal.phase == 4) { if (qnh_going == 0) { qnh_going = 1; } @@ -663,7 +662,7 @@ var canvas_PFD_base = { me["QNH_std"].hide(); me["QNH_box"].hide(); - if (altitude.getValue() >= fmgc.FMGCInternal.transAlt and FMGCphase.getValue() == '2') { + if (altitude.getValue() >= fmgc.FMGCInternal.transAlt and fmgc.FMGCInternal.phase == 2) { if (qnh_going == 0) { qnh_going = 1; } @@ -688,7 +687,7 @@ var canvas_PFD_base = { } else if (alt_inhg_mode.getValue() == 1) { - if (altitude.getValue() >= fmgc.FMGCInternal.transAlt and FMGCphase.getValue() == '2') { + if (altitude.getValue() >= fmgc.FMGCInternal.transAlt and fmgc.FMGCInternal.phase == 2) { if (qnh_going == 0) { qnh_going = 1; } @@ -755,7 +754,7 @@ var canvas_PFD_base = { me["AI_agl"].setText(sprintf("%s", math.round(math.clamp(gear_agl_cur, 0, 2500)))); - if (FMGCphase.getValue() < 3 or fmgc.flightPlanController.arrivalDist >= 250) { + if (fmgc.FMGCInternal.phase < 3 or fmgc.flightPlanController.arrivalDist >= 250) { me["FMA_dh_box"].hide(); me["FMA_dh"].hide(); me["FMA_dhn"].hide(); @@ -858,7 +857,7 @@ var canvas_PFD_base = { me["AI_agl_g"].setRotation(-roll_cur * D2R); - FMGCphase_act = FMGCphase.getValue(); + FMGCphase_act = fmgc.FMGCInternal.phase; if ((wow1.getValue() == 1 or wow2.getValue() == 1) and FMGCphase_act != 0 and FMGCphase_act != 1) { me["AI_stick"].show(); me["AI_stick_pos"].show(); @@ -1199,7 +1198,7 @@ var canvas_PFD_1 = { me["ASI_scale"].setTranslation(0, me.ASI * 6.6); me["ASI_max"].setTranslation(0, me.ASImax * -6.6); - if (!getprop("/FMGC/status/to-state") and FMGCphase.getValue() >= 1 and !wow1.getValue() and !wow2.getValue()) { + if (!getprop("/FMGC/status/to-state") and fmgc.FMGCInternal.phase >= 1 and !wow1.getValue() and !wow2.getValue()) { me.FMGC_vls = getprop("/FMGC/internal/computed-speeds/vls_min"); if (me.FMGC_vls <= 30) { me.VLSmin = 0 - me.ASI; @@ -1261,7 +1260,7 @@ var canvas_PFD_1 = { } tgt_ias = vapp; tgt_kts = vapp; - } else if (FMGCphase.getValue() == 6) { + } else if (fmgc.FMGCInternal.phase == 6) { clean = getprop("/FMGC/internal/computed-speeds/clean"); tgt_ias = clean; tgt_kts = clean; @@ -1337,11 +1336,11 @@ var canvas_PFD_1 = { me.SPDv1trgtdiff = tgt_v1 - ind_spd; - if (pts.Position.gearAglFt.getValue() < 55 and FMGCphase.getValue() <= 2 and me.SPDv1trgtdiff >= -42 and me.SPDv1trgtdiff <= 42) { + if (pts.Position.gearAglFt.getValue() < 55 and fmgc.FMGCInternal.phase <= 2 and me.SPDv1trgtdiff >= -42 and me.SPDv1trgtdiff <= 42) { me["v1_group"].show(); me["v1_text"].hide(); me["v1_group"].setTranslation(0, me.V1trgt * -6.6); - } else if (pts.Position.gearAglFt.getValue() < 55 and FMGCphase.getValue() <= 2) { + } else if (pts.Position.gearAglFt.getValue() < 55 and fmgc.FMGCInternal.phase <= 2) { me["v1_group"].hide(); me["v1_text"].show(); me["v1_text"].setText(sprintf("%3.0f", fmgc.FMGCInternal.v1)); @@ -1366,7 +1365,7 @@ var canvas_PFD_1 = { me.SPDvrtrgtdiff = tgt_vr - ind_spd; - if (pts.Position.gearAglFt.getValue() < 55 and FMGCphase.getValue() <= 2 and me.SPDvrtrgtdiff >= -42 and me.SPDvrtrgtdiff <= 42) { + if (pts.Position.gearAglFt.getValue() < 55 and fmgc.FMGCInternal.phase <= 2 and me.SPDvrtrgtdiff >= -42 and me.SPDvrtrgtdiff <= 42) { me["vr_speed"].show(); me["vr_speed"].setTranslation(0, me.VRtrgt * -6.6); } else { @@ -1388,11 +1387,11 @@ var canvas_PFD_1 = { me.SPDv2trgtdiff = tgt_v2 - ind_spd; - if (pts.Position.gearAglFt.getValue() < 55 and FMGCphase.getValue() <= 2 and me.SPDv2trgtdiff >= -42 and me.SPDv2trgtdiff <= 42) { + if (pts.Position.gearAglFt.getValue() < 55 and fmgc.FMGCInternal.phase <= 2 and me.SPDv2trgtdiff >= -42 and me.SPDv2trgtdiff <= 42) { me["ASI_target"].show(); me["ASI_target"].setTranslation(0, me.V2trgt * -6.6); me["ASI_digit_UP"].setText(sprintf("%3.0f", fmgc.FMGCInternal.v2)); - } else if (pts.Position.gearAglFt.getValue() < 55 and FMGCphase.getValue() <= 2) { + } else if (pts.Position.gearAglFt.getValue() < 55 and fmgc.FMGCInternal.phase <= 2) { me["ASI_target"].hide(); me["ASI_digit_UP"].setText(sprintf("%3.0f", fmgc.FMGCInternal.v2)); } @@ -1675,7 +1674,7 @@ var canvas_PFD_1 = { landing_diff_cur = landing_diff.getValue(); if (landing_diff_cur >= -565 and landing_diff_cur <= 565) { - if ((FMGCphase.getValue() == 5 or FMGCphase.getValue() == 6) and !wow1.getValue() and !wow2.getValue()) { #add std too + if ((fmgc.FMGCInternal.phase == 5 or fmgc.FMGCInternal.phase == 6) and !wow1.getValue() and !wow2.getValue()) { #add std too me["ground"].setTranslation(0, (landing_diff_cur / 100) * -48.66856); me["ground"].show(); } else { @@ -1937,7 +1936,7 @@ var canvas_PFD_2 = { me["ASI_scale"].setTranslation(0, me.ASI * 6.6); me["ASI_max"].setTranslation(0, me.ASImax * -6.6); - if (!getprop("/FMGC/status/to-state") and FMGCphase.getValue() >= 1 and !wow1.getValue() and !wow2.getValue()) { + if (!getprop("/FMGC/status/to-state") and fmgc.FMGCInternal.phase >= 1 and !wow1.getValue() and !wow2.getValue()) { me.FMGC_vls = getprop("/FMGC/internal/computed-speeds/vls_min"); if (me.FMGC_vls <= 30) { me.VLSmin = 0 - me.ASI; @@ -1999,7 +1998,7 @@ var canvas_PFD_2 = { } tgt_ias = vapp; tgt_kts = vapp; - } else if (FMGCphase.getValue() == 6) { + } else if (fmgc.FMGCInternal.phase == 6) { clean = getprop("/FMGC/internal/computed-speeds/clean"); tgt_ias = clean; tgt_kts = clean; @@ -2076,11 +2075,11 @@ var canvas_PFD_2 = { me.SPDv1trgtdiff = tgt_v1 - ind_spd; - if (pts.Position.gearAglFt.getValue() < 55 and FMGCphase.getValue() <= 2 and me.SPDv1trgtdiff >= -42 and me.SPDv1trgtdiff <= 42) { + if (pts.Position.gearAglFt.getValue() < 55 and fmgc.FMGCInternal.phase <= 2 and me.SPDv1trgtdiff >= -42 and me.SPDv1trgtdiff <= 42) { me["v1_group"].show(); me["v1_text"].hide(); me["v1_group"].setTranslation(0, me.V1trgt * -6.6); - } else if (pts.Position.gearAglFt.getValue() < 55 and FMGCphase.getValue() <= 2) { + } else if (pts.Position.gearAglFt.getValue() < 55 and fmgc.FMGCInternal.phase <= 2) { me["v1_group"].hide(); me["v1_text"].show(); me["v1_text"].setText(sprintf("%3.0f", fmgc.FMGCInternal.v1)); @@ -2105,7 +2104,7 @@ var canvas_PFD_2 = { me.SPDvrtrgtdiff = tgt_vr - ind_spd; - if (pts.Position.gearAglFt.getValue() < 55 and FMGCphase.getValue() <= 2 and me.SPDvrtrgtdiff >= -42 and me.SPDvrtrgtdiff <= 42) { + if (pts.Position.gearAglFt.getValue() < 55 and fmgc.FMGCInternal.phase <= 2 and me.SPDvrtrgtdiff >= -42 and me.SPDvrtrgtdiff <= 42) { me["vr_speed"].show(); me["vr_speed"].setTranslation(0, me.VRtrgt * -6.6); } else { @@ -2127,11 +2126,11 @@ var canvas_PFD_2 = { me.SPDv2trgtdiff = tgt_v2 - ind_spd; - if (pts.Position.gearAglFt.getValue() < 55 and FMGCphase.getValue() <= 2 and me.SPDv2trgtdiff >= -42 and me.SPDv2trgtdiff <= 42) { + if (pts.Position.gearAglFt.getValue() < 55 and fmgc.FMGCInternal.phase <= 2 and me.SPDv2trgtdiff >= -42 and me.SPDv2trgtdiff <= 42) { me["ASI_target"].show(); me["ASI_target"].setTranslation(0, me.V2trgt * -6.6); me["ASI_digit_UP"].setText(sprintf("%3.0f", fmgc.FMGCInternal.v2)); - } else if (pts.Position.gearAglFt.getValue() < 55 and FMGCphase.getValue() <= 2) { + } else if (pts.Position.gearAglFt.getValue() < 55 and fmgc.FMGCInternal.phase <= 2) { me["ASI_target"].hide(); me["ASI_digit_UP"].setText(sprintf("%3.0f", fmgc.FMGCInternal.v2)); } @@ -2413,7 +2412,7 @@ var canvas_PFD_2 = { landing_diff_cur = landing_diff.getValue(); if (landing_diff_cur >= -565 and landing_diff_cur <= 565) { - if ((FMGCphase.getValue() == 5 or FMGCphase.getValue() == 6) and !wow1.getValue() and !wow2.getValue()) { #add std too + if ((fmgc.FMGCInternal.phase == 5 or fmgc.FMGCInternal.phase == 6) and !wow1.getValue() and !wow2.getValue()) { #add std too me["ground"].setTranslation(0, (landing_diff_cur / 100) * -48.66856); me["ground"].show(); } else { diff --git a/Nasal/FMGC/FCU.nas b/Nasal/FMGC/FCU.nas index eccfaf09..36b07a56 100644 --- a/Nasal/FMGC/FCU.nas +++ b/Nasal/FMGC/FCU.nas @@ -196,7 +196,7 @@ var FCUController = { }, SPDPush: func() { if (me.FCUworking) { - if (getprop("FMGC/internal/cruise-lvl-set") == 1 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-c.nas b/Nasal/FMGC/FMGC-c.nas index dd9fe448..44eecee4 100644 --- a/Nasal/FMGC/FMGC-c.nas +++ b/Nasal/FMGC/FMGC-c.nas @@ -3,37 +3,36 @@ # Copyright (c) 2020 Josh Davidson (Octal450) -setprop("FMGC/internal/cruise-ft", 10000); -setprop("it-autoflight/internal/alt", 10000); -setprop("modes/pfd/fma/throttle-mode", " "); -setprop("modes/pfd/fma/pitch-mode", " "); -setprop("modes/pfd/fma/pitch-mode-armed", " "); -setprop("modes/pfd/fma/pitch-mode2-armed", " "); -setprop("modes/pfd/fma/roll-mode", " "); -setprop("modes/pfd/fma/roll-mode-armed", " "); -setprop("modes/pfd/fma/ap-mode", " "); -setprop("modes/pfd/fma/fd-mode", " "); -setprop("modes/pfd/fma/at-mode", " "); -setprop("modes/pfd/fma/athr-armed", 0); -setprop("modes/pfd/fma/throttle-mode-box", 0); -setprop("modes/pfd/fma/pitch-mode-box", 0); -setprop("modes/pfd/fma/pitch-mode-armed-box", 0); -setprop("modes/pfd/fma/pitch-mode2-armed-box", 0); -setprop("modes/pfd/fma/roll-mode-box", 0); -setprop("modes/pfd/fma/roll-mode-armed-box", 0); -setprop("modes/pfd/fma/ap-mode-box", 0); -setprop("modes/pfd/fma/fd-mode-box", 0); -setprop("modes/pfd/fma/athr-mode-box", 0); -setprop("modes/pfd/fma/throttle-mode-time", 0); -setprop("modes/pfd/fma/pitch-mode-time", 0); -setprop("modes/pfd/fma/pitch-mode-armed-time", 0); -setprop("modes/pfd/fma/pitch-mode2-armed-time", 0); -setprop("modes/pfd/fma/roll-mode-time", 0); -setprop("modes/pfd/fma/roll-mode-armed-time", 0); -setprop("modes/pfd/fma/ap-mode-time", 0); -setprop("modes/pfd/fma/fd-mode-time", 0); -setprop("modes/pfd/fma/athr-mode-time", 0); -setprop("modes/fcu/hdg-time", -45); +setprop("/it-autoflight/internal/alt", 10000); +setprop("/modes/pfd/fma/throttle-mode", " "); +setprop("/modes/pfd/fma/pitch-mode", " "); +setprop("/modes/pfd/fma/pitch-mode-armed", " "); +setprop("/modes/pfd/fma/pitch-mode2-armed", " "); +setprop("/modes/pfd/fma/roll-mode", " "); +setprop("/modes/pfd/fma/roll-mode-armed", " "); +setprop("/modes/pfd/fma/ap-mode", " "); +setprop("/modes/pfd/fma/fd-mode", " "); +setprop("/modes/pfd/fma/at-mode", " "); +setprop("/modes/pfd/fma/athr-armed", 0); +setprop("/modes/pfd/fma/throttle-mode-box", 0); +setprop("/modes/pfd/fma/pitch-mode-box", 0); +setprop("/modes/pfd/fma/pitch-mode-armed-box", 0); +setprop("/modes/pfd/fma/pitch-mode2-armed-box", 0); +setprop("/modes/pfd/fma/roll-mode-box", 0); +setprop("/modes/pfd/fma/roll-mode-armed-box", 0); +setprop("/modes/pfd/fma/ap-mode-box", 0); +setprop("/modes/pfd/fma/fd-mode-box", 0); +setprop("/modes/pfd/fma/athr-mode-box", 0); +setprop("/modes/pfd/fma/throttle-mode-time", 0); +setprop("/modes/pfd/fma/pitch-mode-time", 0); +setprop("/modes/pfd/fma/pitch-mode-armed-time", 0); +setprop("/modes/pfd/fma/pitch-mode2-armed-time", 0); +setprop("/modes/pfd/fma/roll-mode-time", 0); +setprop("/modes/pfd/fma/roll-mode-armed-time", 0); +setprop("/modes/pfd/fma/ap-mode-time", 0); +setprop("/modes/pfd/fma/fd-mode-time", 0); +setprop("/modes/pfd/fma/athr-mode-time", 0); +setprop("/modes/fcu/hdg-time", -45); setlistener("sim/signals/fdm-initialized", func { loopFMA.start(); @@ -43,49 +42,49 @@ setlistener("sim/signals/fdm-initialized", func { var loopFMA = maketimer(0.05, func { var state1 = getprop("systems/thrust/state1"); var state2 = getprop("systems/thrust/state2"); - var newthr = getprop("modes/pfd/fma/throttle-mode"); + var newthr = getprop("/modes/pfd/fma/throttle-mode"); var thr1 = getprop("controls/engines/engine[0]/throttle-pos"); var thr2 = getprop("controls/engines/engine[1]/throttle-pos"); if (state1 == "TOGA" or state2 == "TOGA") { if (newthr != " ") { - setprop("modes/pfd/fma/throttle-mode", " "); + setprop("/modes/pfd/fma/throttle-mode", " "); } } else if ((state1 == "MAN THR" and thr1 >= 0.83) or (state2 == "MAN THR" and thr2 >= 0.83)) { if (newthr != " ") { - setprop("modes/pfd/fma/throttle-mode", " "); + setprop("/modes/pfd/fma/throttle-mode", " "); } } else if ((state1 == "MCT" or state2 == "MCT") and getprop("systems/thrust/eng-out") != 1) { if (newthr != " ") { - setprop("modes/pfd/fma/throttle-mode", " "); + setprop("/modes/pfd/fma/throttle-mode", " "); } } else if (((state1 == "MAN THR" and thr1 < 0.83) or (state2 == "MAN THR" and thr2 < 0.83)) and getprop("systems/thrust/eng-out") != 1) { if (newthr != " ") { - setprop("modes/pfd/fma/throttle-mode", " "); + setprop("/modes/pfd/fma/throttle-mode", " "); } } else { - if ((getprop("it-autoflight/output/vert") == 4) or (getprop("it-autoflight/output/vert") == 6) or (getprop("it-autoflight/output/vert") == 7) or (getprop("it-autoflight/output/vert") == 8)) { - if (getprop("it-autoflight/output/fd1") == 0 and getprop("it-autoflight/output/fd2") == 0 and getprop("it-autoflight/output/ap1") == 0 and getprop("it-autoflight/output/ap2") == 0) { + if ((getprop("/it-autoflight/output/vert") == 4) or (getprop("/it-autoflight/output/vert") == 6) or (getprop("/it-autoflight/output/vert") == 7) or (getprop("/it-autoflight/output/vert") == 8)) { + if (getprop("/it-autoflight/output/fd1") == 0 and getprop("/it-autoflight/output/fd2") == 0 and getprop("/it-autoflight/output/ap1") == 0 and getprop("/it-autoflight/output/ap2") == 0) { loopFMA_b(); } else { - var thr = getprop("it-autoflight/output/thr-mode"); + var thr = getprop("/it-autoflight/output/thr-mode"); if (thr == 0) { loopFMA_b(); } else if (thr == 1) { if (newthr != "THR IDLE") { - setprop("modes/pfd/fma/throttle-mode", "THR IDLE"); + setprop("/modes/pfd/fma/throttle-mode", "THR IDLE"); } } else if (thr == 2) { if (state1 == "MCT" or state2 == "MCT" and getprop("systems/thrust/eng-out") == 1) { if (newthr != "THR MCT") { - setprop("modes/pfd/fma/throttle-mode", "THR MCT"); + setprop("/modes/pfd/fma/throttle-mode", "THR MCT"); } } else if (state1 == "CL" or state2 == "CL") { if (newthr != "THR CLB") { - setprop("modes/pfd/fma/throttle-mode", "THR CLB"); + setprop("/modes/pfd/fma/throttle-mode", "THR CLB"); } } else { if (newthr != "THR LVR") { - setprop("modes/pfd/fma/throttle-mode", "THR LVR"); + setprop("/modes/pfd/fma/throttle-mode", "THR LVR"); } } } @@ -96,28 +95,28 @@ var loopFMA = maketimer(0.05, func { } # A/THR Armed/Active - if (getprop("it-autoflight/output/athr") == 1 and (state1 == "MAN THR" or state2 == "MAN THR" or state1 == "MCT" or state2 == "MCT" or state1 == "TOGA" or state2 == "TOGA") and getprop("systems/thrust/eng-out") != 1) { - if (getprop("modes/pfd/fma/athr-armed") != 1) { - setprop("modes/pfd/fma/athr-armed", 1); + if (getprop("/it-autoflight/output/athr") == 1 and (state1 == "MAN THR" or state2 == "MAN THR" or state1 == "MCT" or state2 == "MCT" or state1 == "TOGA" or state2 == "TOGA") and getprop("systems/thrust/eng-out") != 1) { + if (getprop("/modes/pfd/fma/athr-armed") != 1) { + setprop("/modes/pfd/fma/athr-armed", 1); } - } else if (getprop("it-autoflight/output/athr") == 1 and ((state1 == "MAN THR" and thr1 >= 0.83) or (state2 == "MAN THR" and thr2 >= 0.83) or (state1 == "MCT" and getprop("controls/engines/thrust-limit") == "FLX") or + } else if (getprop("/it-autoflight/output/athr") == 1 and ((state1 == "MAN THR" and thr1 >= 0.83) or (state2 == "MAN THR" and thr2 >= 0.83) or (state1 == "MCT" and getprop("controls/engines/thrust-limit") == "FLX") or (state2 == "MCT" and getprop("controls/engines/thrust-limit") == "FLX") or state1 == "TOGA" or state2 == "TOGA") and getprop("systems/thrust/eng-out") == 1) { - if (getprop("modes/pfd/fma/athr-armed") != 1) { - setprop("modes/pfd/fma/athr-armed", 1); + if (getprop("/modes/pfd/fma/athr-armed") != 1) { + setprop("/modes/pfd/fma/athr-armed", 1); } } else { - if (getprop("modes/pfd/fma/athr-armed") != 0) { - setprop("modes/pfd/fma/athr-armed", 0); + if (getprop("/modes/pfd/fma/athr-armed") != 0) { + setprop("/modes/pfd/fma/athr-armed", 0); } } # SRS RWY Engagement var flx = getprop("systems/thrust/lim-flex"); - var lat = getprop("it-autoflight/mode/lat"); - var newlat = getprop("modes/pfd/fma/roll-mode"); - var vert = getprop("it-autoflight/mode/vert"); - var newvert = getprop("modes/pfd/fma/pitch-mode"); - var newvertarm = getprop("modes/pfd/fma/pitch-mode2-armed"); + var lat = getprop("/it-autoflight/mode/lat"); + var newlat = getprop("/modes/pfd/fma/roll-mode"); + var vert = getprop("/it-autoflight/mode/vert"); + var newvert = getprop("/modes/pfd/fma/pitch-mode"); + var newvertarm = getprop("/modes/pfd/fma/pitch-mode2-armed"); var thr1 = getprop("controls/engines/engine[0]/throttle-pos"); var thr2 = getprop("controls/engines/engine[1]/throttle-pos"); var wow = getprop("gear/gear[0]/wow"); @@ -125,135 +124,135 @@ var loopFMA = maketimer(0.05, func { var engstate2 = getprop("engines/engine[1]/state"); if (((state1 == "TOGA" or state2 == "TOGA") or (flx == 1 and (state1 == "MCT" or state2 == "MCT")) or (flx == 1 and ((state1 == "MAN THR" and thr1 >= 0.83) or (state2 == "MAN THR" and thr2 >= 0.83)))) and (engstate1 == 3 or engstate2 == 3)) { # RWY Engagement would go here, but automatic ILS selection is not simulated yet. - if (wow and FMGCInternal.v2set and getprop("it-autoflight/output/vert") != 7) { + if (wow and FMGCInternal.v2set and getprop("/it-autoflight/output/vert") != 7) { ITAF.setVertMode(7); - setprop("it-autoflight/mode/vert", "T/O CLB"); + setprop("/it-autoflight/mode/vert", "T/O CLB"); } } else { var gear1 = getprop("gear/gear[1]/wow"); var gear2 = getprop("gear/gear[2]/wow"); - if (getprop("it-autoflight/input/lat") == 5 and (gear1 or gear2)) { + if (getprop("/it-autoflight/input/lat") == 5 and (gear1 or gear2)) { ITAF.setLatMode(9); } - if (getprop("it-autoflight/output/vert") == 7 and (gear1 or gear2)) { + if (getprop("/it-autoflight/output/vert") == 7 and (gear1 or gear2)) { ITAF.setVertMode(9); } } - var trk = getprop("it-autoflight/custom/trk-fpa"); + var trk = getprop("/it-autoflight/custom/trk-fpa"); if (lat == "HDG" and trk == 0) { if (newlat != "HDG") { - setprop("modes/pfd/fma/roll-mode", "HDG"); + setprop("/modes/pfd/fma/roll-mode", "HDG"); } } else if (lat == "HDG" and trk == 1) { if (newlat != "TRACK") { - setprop("modes/pfd/fma/roll-mode", "TRACK"); + setprop("/modes/pfd/fma/roll-mode", "TRACK"); } } # Boxes var elapsedtime = getprop("sim/time/elapsed-sec"); - if (getprop("modes/pfd/fma/ap-mode-time") + 10 >= elapsedtime) { - setprop("modes/pfd/fma/ap-mode-box", 1); + if (getprop("/modes/pfd/fma/ap-mode-time") + 10 >= elapsedtime) { + setprop("/modes/pfd/fma/ap-mode-box", 1); } else { - setprop("modes/pfd/fma/ap-mode-box", 0); + setprop("/modes/pfd/fma/ap-mode-box", 0); } - if (getprop("modes/pfd/fma/fd-mode-time") + 10 >= elapsedtime) { - setprop("modes/pfd/fma/fd-mode-box", 1); + if (getprop("/modes/pfd/fma/fd-mode-time") + 10 >= elapsedtime) { + setprop("/modes/pfd/fma/fd-mode-box", 1); } else { - setprop("modes/pfd/fma/fd-mode-box", 0); + setprop("/modes/pfd/fma/fd-mode-box", 0); } - if (getprop("modes/pfd/fma/athr-mode-time") + 10 >= elapsedtime) { - setprop("modes/pfd/fma/athr-mode-box", 1); + if (getprop("/modes/pfd/fma/athr-mode-time") + 10 >= elapsedtime) { + setprop("/modes/pfd/fma/athr-mode-box", 1); } else { - setprop("modes/pfd/fma/athr-mode-box", 0); + setprop("/modes/pfd/fma/athr-mode-box", 0); } - if (getprop("modes/pfd/fma/throttle-mode-time") + 10 >= elapsedtime) { - setprop("modes/pfd/fma/throttle-mode-box", 1); + if (getprop("/modes/pfd/fma/throttle-mode-time") + 10 >= elapsedtime) { + setprop("/modes/pfd/fma/throttle-mode-box", 1); } else { - setprop("modes/pfd/fma/throttle-mode-box", 0); + setprop("/modes/pfd/fma/throttle-mode-box", 0); } - if (getprop("modes/pfd/fma/roll-mode-time") + 10 >= elapsedtime) { - setprop("modes/pfd/fma/roll-mode-box", 1); + if (getprop("/modes/pfd/fma/roll-mode-time") + 10 >= elapsedtime) { + setprop("/modes/pfd/fma/roll-mode-box", 1); } else { - setprop("modes/pfd/fma/roll-mode-box", 0); + setprop("/modes/pfd/fma/roll-mode-box", 0); } - if (getprop("modes/pfd/fma/pitch-mode-time") + 10 >= elapsedtime) { - setprop("modes/pfd/fma/pitch-mode-box", 1); + if (getprop("/modes/pfd/fma/pitch-mode-time") + 10 >= elapsedtime) { + setprop("/modes/pfd/fma/pitch-mode-box", 1); } else { - setprop("modes/pfd/fma/pitch-mode-box", 0); + setprop("/modes/pfd/fma/pitch-mode-box", 0); } - if (getprop("modes/pfd/fma/roll-mode-armed-time") + 10 >= elapsedtime) { - setprop("modes/pfd/fma/roll-mode-armed-box", 1); + if (getprop("/modes/pfd/fma/roll-mode-armed-time") + 10 >= elapsedtime) { + setprop("/modes/pfd/fma/roll-mode-armed-box", 1); } else { - setprop("modes/pfd/fma/roll-mode-armed-box", 0); + setprop("/modes/pfd/fma/roll-mode-armed-box", 0); } - if (getprop("modes/pfd/fma/pitch-mode-armed-time") + 10 >= elapsedtime) { - setprop("modes/pfd/fma/pitch-mode-armed-box", 1); + if (getprop("/modes/pfd/fma/pitch-mode-armed-time") + 10 >= elapsedtime) { + setprop("/modes/pfd/fma/pitch-mode-armed-box", 1); } else { - setprop("modes/pfd/fma/pitch-mode-armed-box", 0); + setprop("/modes/pfd/fma/pitch-mode-armed-box", 0); } - if (getprop("modes/pfd/fma/pitch-mode2-armed-time") + 10 >= elapsedtime) { - setprop("modes/pfd/fma/pitch-mode2-armed-box", 1); + if (getprop("/modes/pfd/fma/pitch-mode2-armed-time") + 10 >= elapsedtime) { + setprop("/modes/pfd/fma/pitch-mode2-armed-box", 1); } else { - setprop("modes/pfd/fma/pitch-mode2-armed-box", 0); + setprop("/modes/pfd/fma/pitch-mode2-armed-box", 0); } }); var loopFMA_b = func { - var newthr = getprop("modes/pfd/fma/throttle-mode"); - if (getprop("it-autoflight/input/kts-mach") == 0) { + var newthr = getprop("/modes/pfd/fma/throttle-mode"); + if (getprop("/it-autoflight/input/kts-mach") == 0) { if (newthr != "SPEED") { - setprop("modes/pfd/fma/throttle-mode", "SPEED"); + setprop("/modes/pfd/fma/throttle-mode", "SPEED"); } - } else if (getprop("it-autoflight/input/kts-mach") == 1) { + } else if (getprop("/it-autoflight/input/kts-mach") == 1) { if (newthr != "MACH") { - setprop("modes/pfd/fma/throttle-mode", "MACH"); + setprop("/modes/pfd/fma/throttle-mode", "MACH"); } } } # Master Lateral setlistener("/it-autoflight/mode/lat", func { - var lat = getprop("it-autoflight/mode/lat"); - var newlat = getprop("modes/pfd/fma/roll-mode"); + var lat = getprop("/it-autoflight/mode/lat"); + var newlat = getprop("/modes/pfd/fma/roll-mode"); if (lat == "LNAV") { if (newlat != "NAV") { - setprop("modes/pfd/fma/roll-mode", "NAV"); + setprop("/modes/pfd/fma/roll-mode", "NAV"); } } else if (lat == "LOC") { if (newlat != "LOC*" and newlat != "LOC") { - setprop("modes/pfd/fma/roll-mode", "LOC*"); + setprop("/modes/pfd/fma/roll-mode", "LOC*"); locupdate.start(); } } else if (lat == "ALGN") { if (newlat != " ") { - setprop("modes/pfd/fma/roll-mode", " "); + setprop("/modes/pfd/fma/roll-mode", " "); } } else if (lat == "RLOU") { if (newlat != " ") { - setprop("modes/pfd/fma/roll-mode", " "); + setprop("/modes/pfd/fma/roll-mode", " "); } } else if (lat == "T/O") { if (newlat != "RWY") { - setprop("modes/pfd/fma/roll-mode", "RWY"); + setprop("/modes/pfd/fma/roll-mode", "RWY"); } } else if (lat == " ") { if (newlat != " ") { - setprop("modes/pfd/fma/roll-mode", " "); + setprop("/modes/pfd/fma/roll-mode", " "); } } }); var locupdate = maketimer(0.5, func { - var lat = getprop("it-autoflight/mode/lat"); - var newlat = getprop("modes/pfd/fma/roll-mode"); - var nav_defl = getprop("instrumentation/nav[0]/heading-needle-deflection-norm"); + var lat = getprop("/it-autoflight/mode/lat"); + var newlat = getprop("/modes/pfd/fma/roll-mode"); + var nav_defl = getprop("/instrumentation/nav[0]/heading-needle-deflection-norm"); if (lat == "LOC") { if (nav_defl > -0.06 and nav_defl < 0.06) { locupdate.stop(); if (newlat != "LOC") { - setprop("modes/pfd/fma/roll-mode", "LOC"); + setprop("/modes/pfd/fma/roll-mode", "LOC"); } } } @@ -261,82 +260,82 @@ var locupdate = maketimer(0.5, func { # Master Vertical setlistener("/it-autoflight/mode/vert", func { - var vert = getprop("it-autoflight/mode/vert"); - var newvert = getprop("modes/pfd/fma/pitch-mode"); - var newvertarm = getprop("modes/pfd/fma/pitch-mode2-armed"); + var vert = getprop("/it-autoflight/mode/vert"); + var newvert = getprop("/modes/pfd/fma/pitch-mode"); + var newvertarm = getprop("/modes/pfd/fma/pitch-mode2-armed"); if (vert == "ALT HLD") { altvert(); if (newvertarm != " ") { - setprop("modes/pfd/fma/pitch-mode2-armed", " "); + setprop("/modes/pfd/fma/pitch-mode2-armed", " "); } } else if (vert == "ALT CAP") { altvert(); if (newvertarm != " ") { - setprop("modes/pfd/fma/pitch-mode2-armed", " "); + setprop("/modes/pfd/fma/pitch-mode2-armed", " "); } } else if (vert == "V/S") { if (newvert != "V/S") { - setprop("modes/pfd/fma/pitch-mode", "V/S"); + setprop("/modes/pfd/fma/pitch-mode", "V/S"); } if (newvertarm != "ALT") { - setprop("modes/pfd/fma/pitch-mode2-armed", "ALT"); + setprop("/modes/pfd/fma/pitch-mode2-armed", "ALT"); } } else if (vert == "G/S") { if (newvert != "G/S*" and newvert != "G/S") { - setprop("modes/pfd/fma/pitch-mode", "G/S*"); + setprop("/modes/pfd/fma/pitch-mode", "G/S*"); gsupdate.start(); } if (newvertarm != " ") { - setprop("modes/pfd/fma/pitch-mode2-armed", " "); + setprop("/modes/pfd/fma/pitch-mode2-armed", " "); } } else if (vert == "SPD CLB") { if (newvert != "OP CLB") { - setprop("modes/pfd/fma/pitch-mode", "OP CLB"); + setprop("/modes/pfd/fma/pitch-mode", "OP CLB"); } if (newvertarm != "ALT") { - setprop("modes/pfd/fma/pitch-mode2-armed", "ALT"); + setprop("/modes/pfd/fma/pitch-mode2-armed", "ALT"); } } else if (vert == "SPD DES") { if (newvert != "OP DES") { - setprop("modes/pfd/fma/pitch-mode", "OP DES"); + setprop("/modes/pfd/fma/pitch-mode", "OP DES"); } if (newvertarm != "ALT") { - setprop("modes/pfd/fma/pitch-mode2-armed", "ALT"); + setprop("/modes/pfd/fma/pitch-mode2-armed", "ALT"); } } else if (vert == "FPA") { if (newvert != "FPA") { - setprop("modes/pfd/fma/pitch-mode", "FPA"); + setprop("/modes/pfd/fma/pitch-mode", "FPA"); } if (newvertarm != "ALT") { - setprop("modes/pfd/fma/pitch-mode2-armed", "ALT"); + setprop("/modes/pfd/fma/pitch-mode2-armed", "ALT"); } } else if (vert == "LAND") { if (newvert != "LAND") { - setprop("modes/pfd/fma/pitch-mode", "LAND"); + setprop("/modes/pfd/fma/pitch-mode", "LAND"); } } else if (vert == "FLARE") { if (newvert != "FLARE") { - setprop("modes/pfd/fma/pitch-mode", "FLARE"); + setprop("/modes/pfd/fma/pitch-mode", "FLARE"); } } else if (vert == "ROLLOUT") { if (newvert != "ROLL OUT") { - setprop("modes/pfd/fma/pitch-mode", "ROLL OUT"); + setprop("/modes/pfd/fma/pitch-mode", "ROLL OUT"); } } else if (vert == "T/O CLB") { if (newvert != "SRS") { - setprop("modes/pfd/fma/pitch-mode", "SRS"); + setprop("/modes/pfd/fma/pitch-mode", "SRS"); } updatePitchArm2(); } else if (vert == "G/A CLB") { if (newvert != "SRS") { - setprop("modes/pfd/fma/pitch-mode", "SRS"); + setprop("/modes/pfd/fma/pitch-mode", "SRS"); } if (newvertarm != "ALT") { - setprop("modes/pfd/fma/pitch-mode2-armed", "ALT"); + setprop("/modes/pfd/fma/pitch-mode2-armed", "ALT"); } } else if (vert == " ") { if (newvert != " ") { - setprop("modes/pfd/fma/pitch-mode", " "); + setprop("/modes/pfd/fma/pitch-mode", " "); } updatePitchArm2(); } @@ -344,178 +343,175 @@ setlistener("/it-autoflight/mode/vert", func { }); var updatePitchArm2 = func { - var newvertarm = getprop("modes/pfd/fma/pitch-mode2-armed"); + var newvertarm = getprop("/modes/pfd/fma/pitch-mode2-armed"); if (newvertarm != "CLB" and FMGCInternal.v2set) { - setprop("modes/pfd/fma/pitch-mode2-armed", "CLB"); + setprop("/modes/pfd/fma/pitch-mode2-armed", "CLB"); } else if (newvertarm != " " and FMGCInternal.v2set != 1) { - setprop("modes/pfd/fma/pitch-mode2-armed", " "); + setprop("/modes/pfd/fma/pitch-mode2-armed", " "); } } var gsupdate = maketimer(0.5, func { - var vert = getprop("it-autoflight/mode/vert"); - var newvert = getprop("modes/pfd/fma/pitch-mode"); - var gs_defl = getprop("instrumentation/nav[0]/gs-needle-deflection-norm"); + var vert = getprop("/it-autoflight/mode/vert"); + var newvert = getprop("/modes/pfd/fma/pitch-mode"); + var gs_defl = getprop("/instrumentation/nav[0]/gs-needle-deflection-norm"); if (vert == "G/S") { if (gs_defl > -0.06 and gs_defl < 0.06) { gsupdate.stop(); if (newvert != "G/S") { - setprop("modes/pfd/fma/pitch-mode", "G/S"); + setprop("/modes/pfd/fma/pitch-mode", "G/S"); } } } }); var altvert = func { - var FMGCalt = getprop("FMGC/internal/cruise-ft"); - var MCPalt = getprop("it-autoflight/internal/alt"); - var ALTdif = abs(FMGCalt - MCPalt); - var vert = getprop("it-autoflight/mode/vert"); - var newvert = getprop("modes/pfd/fma/pitch-mode"); + var MCPalt = getprop("/it-autoflight/internal/alt"); + var ALTdif = abs(fmgc.FMGCInternal.crzFt - MCPalt); + var vert = getprop("/it-autoflight/mode/vert"); + var newvert = getprop("/modes/pfd/fma/pitch-mode"); if (ALTdif <= 20) { if (vert == "ALT HLD") { if (newvert != "ALT CRZ") { - setprop("modes/pfd/fma/pitch-mode", "ALT CRZ"); + setprop("/modes/pfd/fma/pitch-mode", "ALT CRZ"); } } else if (vert == "ALT CAP") { if (newvert != "ALT CRZ*") { - setprop("modes/pfd/fma/pitch-mode", "ALT CRZ*"); + setprop("/modes/pfd/fma/pitch-mode", "ALT CRZ*"); } } } else { if (vert == "ALT HLD") { if (newvert != "ALT") { - setprop("modes/pfd/fma/pitch-mode", "ALT"); + setprop("/modes/pfd/fma/pitch-mode", "ALT"); } } else if (vert == "ALT CAP") { if (newvert != "ALT*") { - setprop("modes/pfd/fma/pitch-mode", "ALT*"); + setprop("/modes/pfd/fma/pitch-mode", "ALT*"); } } } } -setlistener("/FMGC/internal/cruise-ft", altvert); - # Arm HDG or NAV setlistener("/it-autoflight/mode/arm", func { - var arm = getprop("it-autoflight/mode/arm"); - var newarm = getprop("modes/pfd/fma/roll-mode-armed"); + var arm = getprop("/it-autoflight/mode/arm"); + var newarm = getprop("/modes/pfd/fma/roll-mode-armed"); if (arm == "HDG") { if (newarm != "HDG") { - setprop("modes/pfd/fma/roll-mode-armed", " "); + setprop("/modes/pfd/fma/roll-mode-armed", " "); } } else if (arm == "LNV") { if (newarm != "NAV") { - setprop("modes/pfd/fma/roll-mode-armed", "NAV"); + setprop("/modes/pfd/fma/roll-mode-armed", "NAV"); } } else if (arm == " ") { if (newarm != " ") { - setprop("modes/pfd/fma/roll-mode-armed", " "); + setprop("/modes/pfd/fma/roll-mode-armed", " "); } } }); # Arm LOC setlistener("/it-autoflight/output/loc-armed", func { - var loca = getprop("it-autoflight/output/loc-armed"); - var newarm = getprop("modes/pfd/fma/roll-mode-armed"); + var loca = getprop("/it-autoflight/output/loc-armed"); + var newarm = getprop("/modes/pfd/fma/roll-mode-armed"); if (loca) { if (newarm != "LOC") { - setprop("modes/pfd/fma/roll-mode-armed", "LOC"); + setprop("/modes/pfd/fma/roll-mode-armed", "LOC"); } } else { if (newarm != " ") { - setprop("modes/pfd/fma/roll-mode-armed", " "); + setprop("/modes/pfd/fma/roll-mode-armed", " "); } } }); # Arm G/S setlistener("/it-autoflight/output/appr-armed", func { - var appa = getprop("it-autoflight/output/appr-armed"); - var newvert2arm = getprop("modes/pfd/fma/pitch-mode-armed"); + var appa = getprop("/it-autoflight/output/appr-armed"); + var newvert2arm = getprop("/modes/pfd/fma/pitch-mode-armed"); if (appa) { if (newvert2arm != "G/S") { - setprop("modes/pfd/fma/pitch-mode-armed", "G/S"); + setprop("/modes/pfd/fma/pitch-mode-armed", "G/S"); } } else { if (newvert2arm != " ") { - setprop("modes/pfd/fma/pitch-mode-armed", " "); + setprop("/modes/pfd/fma/pitch-mode-armed", " "); } } }); # AP var ap = func { - var ap1 = getprop("it-autoflight/output/ap1"); - var ap2 = getprop("it-autoflight/output/ap2"); - var newap = getprop("modes/pfd/fma/ap-mode"); + var ap1 = getprop("/it-autoflight/output/ap1"); + var ap2 = getprop("/it-autoflight/output/ap2"); + var newap = getprop("/modes/pfd/fma/ap-mode"); if (ap1 and ap2 and newap != "AP1+2") { - setprop("modes/pfd/fma/ap-mode", "AP 1+2"); + setprop("/modes/pfd/fma/ap-mode", "AP 1+2"); } else if (ap1 and !ap2 and newap != "AP 1") { - setprop("modes/pfd/fma/ap-mode", "AP 1"); + setprop("/modes/pfd/fma/ap-mode", "AP 1"); } else if (ap2 and !ap1 and newap != "AP 2") { - setprop("modes/pfd/fma/ap-mode", "AP 2"); + setprop("/modes/pfd/fma/ap-mode", "AP 2"); } else if (!ap1 and !ap2) { - setprop("modes/pfd/fma/ap-mode", " "); + setprop("/modes/pfd/fma/ap-mode", " "); } } # FD var fd = func { - var fd1 = getprop("it-autoflight/output/fd1"); - var fd2 = getprop("it-autoflight/output/fd2"); - var newfd = getprop("modes/pfd/fma/fd-mode"); + var fd1 = getprop("/it-autoflight/output/fd1"); + var fd2 = getprop("/it-autoflight/output/fd2"); + var newfd = getprop("/modes/pfd/fma/fd-mode"); if (fd1 and fd2 and newfd != "1FD2") { - setprop("modes/pfd/fma/fd-mode", "1 FD 2"); + setprop("/modes/pfd/fma/fd-mode", "1 FD 2"); } else if (fd1 and !fd2 and newfd != "1 FD -") { - setprop("modes/pfd/fma/fd-mode", "1 FD -"); + setprop("/modes/pfd/fma/fd-mode", "1 FD -"); } else if (fd2 and !fd1 and newfd != "- FD 2") { - setprop("modes/pfd/fma/fd-mode", "- FD 2"); + setprop("/modes/pfd/fma/fd-mode", "- FD 2"); } else if (!fd1 and !fd2) { - setprop("modes/pfd/fma/fd-mode", " "); + setprop("/modes/pfd/fma/fd-mode", " "); } } # AT var at = func { - var at = getprop("it-autoflight/output/athr"); - var newat = getprop("modes/pfd/fma/at-mode"); + var at = getprop("/it-autoflight/output/athr"); + var newat = getprop("/modes/pfd/fma/at-mode"); if (at and newat != "A/THR") { - setprop("modes/pfd/fma/at-mode", "A/THR"); + setprop("/modes/pfd/fma/at-mode", "A/THR"); } else if (!at) { - setprop("modes/pfd/fma/at-mode", " "); + setprop("/modes/pfd/fma/at-mode", " "); } } var boxchk = func { - if ((getprop("it-autoflight/output/ap1") or getprop("it-autoflight/output/ap2") or getprop("it-autoflight/output/fd1") or getprop("it-autoflight/output/fd2")) and getprop("it-autoflight/output/fma-pwr") == 0) { - setprop("it-autoflight/input/lat", 3); + if ((getprop("/it-autoflight/output/ap1") or getprop("/it-autoflight/output/ap2") or getprop("/it-autoflight/output/fd1") or getprop("/it-autoflight/output/fd2")) and getprop("/it-autoflight/output/fma-pwr") == 0) { + setprop("/it-autoflight/input/lat", 3); boxchk_b(); } } var boxchk_b = func { - var newlat = getprop("modes/pfd/fma/roll-mode"); + var newlat = getprop("/modes/pfd/fma/roll-mode"); if (newlat != " ") { - setprop("modes/pfd/fma/roll-mode-time", getprop("sim/time/elapsed-sec")); + setprop("/modes/pfd/fma/roll-mode-time", getprop("sim/time/elapsed-sec")); } - var newvert = getprop("modes/pfd/fma/pitch-mode"); + var newvert = getprop("/modes/pfd/fma/pitch-mode"); if (newvert != " ") { - setprop("modes/pfd/fma/pitch-mode-time", getprop("sim/time/elapsed-sec")); + setprop("/modes/pfd/fma/pitch-mode-time", getprop("sim/time/elapsed-sec")); } - var newarmr = getprop("modes/pfd/fma/roll-mode-armed"); + var newarmr = getprop("/modes/pfd/fma/roll-mode-armed"); if (newarmr != " ") { - setprop("modes/pfd/fma/roll-mode-armed-time", getprop("sim/time/elapsed-sec")); + setprop("/modes/pfd/fma/roll-mode-armed-time", getprop("sim/time/elapsed-sec")); } - var newarmp = getprop("modes/pfd/fma/pitch-mode-armed"); + var newarmp = getprop("/modes/pfd/fma/pitch-mode-armed"); if (newarmp != " ") { - setprop("modes/pfd/fma/pitch-mode-armed-time", getprop("sim/time/elapsed-sec")); + setprop("/modes/pfd/fma/pitch-mode-armed-time", getprop("sim/time/elapsed-sec")); } - var newarmp2 = getprop("modes/pfd/fma/pitch-mode2-armed"); + var newarmp2 = getprop("/modes/pfd/fma/pitch-mode2-armed"); if (newarmp2 != " ") { - setprop("modes/pfd/fma/pitch-mode2-armed-time", getprop("sim/time/elapsed-sec")); + setprop("/modes/pfd/fma/pitch-mode2-armed-time", getprop("sim/time/elapsed-sec")); } } @@ -542,74 +538,74 @@ setlistener("/it-autoflight/output/athr", func { # Boxes setlistener("/modes/pfd/fma/ap-mode", func { - if (getprop("modes/pfd/fma/ap-mode") != " ") { - setprop("modes/pfd/fma/ap-mode-time", getprop("sim/time/elapsed-sec")); + if (getprop("/modes/pfd/fma/ap-mode") != " ") { + setprop("/modes/pfd/fma/ap-mode-time", getprop("sim/time/elapsed-sec")); } }); setlistener("/modes/pfd/fma/fd-mode", func { - if (getprop("modes/pfd/fma/fd-mode") != " ") { - setprop("modes/pfd/fma/fd-mode-time", getprop("sim/time/elapsed-sec")); + if (getprop("/modes/pfd/fma/fd-mode") != " ") { + setprop("/modes/pfd/fma/fd-mode-time", getprop("sim/time/elapsed-sec")); } }); setlistener("/modes/pfd/fma/at-mode", func { - if (getprop("modes/pfd/fma/at-mode") != " ") { - setprop("modes/pfd/fma/throttle-mode-time", getprop("sim/time/elapsed-sec")); - setprop("modes/pfd/fma/athr-mode-time", getprop("sim/time/elapsed-sec")); + if (getprop("/modes/pfd/fma/at-mode") != " ") { + setprop("/modes/pfd/fma/throttle-mode-time", getprop("sim/time/elapsed-sec")); + setprop("/modes/pfd/fma/athr-mode-time", getprop("sim/time/elapsed-sec")); } }); setlistener("/modes/pfd/fma/athr-armed", func { - if (getprop("modes/pfd/fma/at-mode") != " ") { - setprop("modes/pfd/fma/athr-mode-time", getprop("sim/time/elapsed-sec")); + if (getprop("/modes/pfd/fma/at-mode") != " ") { + setprop("/modes/pfd/fma/athr-mode-time", getprop("sim/time/elapsed-sec")); } }); setlistener("/modes/pfd/fma/throttle-mode", func { var state1 = getprop("systems/thrust/state1"); var state2 = getprop("systems/thrust/state2"); - if (getprop("it-autoflight/output/athr") == 1 and state1 != "MCT" and state2 != "MCT" and state1 != "MAN THR" and state2 != "MAN THR" and state1 != "TOGA" and state2 != "TOGA" and state1 != "IDLE" and state2 != "IDLE" and + if (getprop("/it-autoflight/output/athr") == 1 and state1 != "MCT" and state2 != "MCT" and state1 != "MAN THR" and state2 != "MAN THR" and state1 != "TOGA" and state2 != "TOGA" and state1 != "IDLE" and state2 != "IDLE" and getprop("systems/thrust/eng-out") != 1) { - setprop("modes/pfd/fma/throttle-mode-time", getprop("sim/time/elapsed-sec")); - } else if (getprop("it-autoflight/output/athr") == 1 and state1 != "TOGA" and state2 != "TOGA" and state1 != "IDLE" and state2 != "IDLE" and getprop("systems/thrust/eng-out") == 1) { + setprop("/modes/pfd/fma/throttle-mode-time", getprop("sim/time/elapsed-sec")); + } else if (getprop("/it-autoflight/output/athr") == 1 and state1 != "TOGA" and state2 != "TOGA" and state1 != "IDLE" and state2 != "IDLE" and getprop("systems/thrust/eng-out") == 1) { if (getprop("controls/engines/engine[0]/throttle-pos") < 0.83 and getprop("controls/engines/engine[1]/throttle-pos") < 0.83) { - setprop("modes/pfd/fma/throttle-mode-time", getprop("sim/time/elapsed-sec")); + setprop("/modes/pfd/fma/throttle-mode-time", getprop("sim/time/elapsed-sec")); } } }); setlistener("/modes/pfd/fma/roll-mode", func { - var newlat = getprop("modes/pfd/fma/roll-mode"); + var newlat = getprop("/modes/pfd/fma/roll-mode"); if (newlat != " ") { - setprop("modes/pfd/fma/roll-mode-time", getprop("sim/time/elapsed-sec")); + setprop("/modes/pfd/fma/roll-mode-time", getprop("sim/time/elapsed-sec")); } }); setlistener("/modes/pfd/fma/pitch-mode", func { - var newvert = getprop("modes/pfd/fma/pitch-mode"); + var newvert = getprop("/modes/pfd/fma/pitch-mode"); if (newvert != " ") { - setprop("modes/pfd/fma/pitch-mode-time", getprop("sim/time/elapsed-sec")); + setprop("/modes/pfd/fma/pitch-mode-time", getprop("sim/time/elapsed-sec")); } }); setlistener("/modes/pfd/fma/roll-mode-armed", func { - var newarm = getprop("modes/pfd/fma/roll-mode-armed"); + var newarm = getprop("/modes/pfd/fma/roll-mode-armed"); if (newarm != " ") { - setprop("modes/pfd/fma/roll-mode-armed-time", getprop("sim/time/elapsed-sec")); + setprop("/modes/pfd/fma/roll-mode-armed-time", getprop("sim/time/elapsed-sec")); } }); setlistener("/modes/pfd/fma/pitch-mode-armed", func { - var newarm = getprop("modes/pfd/fma/pitch-mode-armed"); + var newarm = getprop("/modes/pfd/fma/pitch-mode-armed"); if (newarm != " ") { - setprop("modes/pfd/fma/pitch-mode-armed-time", getprop("sim/time/elapsed-sec")); + setprop("/modes/pfd/fma/pitch-mode-armed-time", getprop("sim/time/elapsed-sec")); } }); setlistener("/modes/pfd/fma/pitch-mode2-armed", func { - var newarm = getprop("modes/pfd/fma/pitch-mode2-armed"); + var newarm = getprop("/modes/pfd/fma/pitch-mode2-armed"); if (newarm != " ") { - setprop("modes/pfd/fma/pitch-mode2-armed-time", getprop("sim/time/elapsed-sec")); + setprop("/modes/pfd/fma/pitch-mode2-armed-time", getprop("sim/time/elapsed-sec")); } }); diff --git a/Nasal/FMGC/FMGC.nas b/Nasal/FMGC/FMGC.nas index 1925ac3e..66053ab2 100644 --- a/Nasal/FMGC/FMGC.nas +++ b/Nasal/FMGC/FMGC.nas @@ -22,7 +22,6 @@ var modelat = 0; var mode = 0; var modeI = 0; var gs = 0; -var alt = 0; var aglalt = 0; var cruiseft = 0; var cruiseft_b = 0; @@ -38,7 +37,6 @@ var targetfpa = 0; var accel_agl_ft = 0; var locarm = 0; var apprarm = 0; -var gear0 = 0; var fd1 = 0; var fd2 = 0; var spd = 0; @@ -113,11 +111,10 @@ setprop("/FMGC/internal/vor1-mcdu", "XXX/999.99"); setprop("/FMGC/internal/vor2-mcdu", "999.99/XXX"); setprop("/FMGC/internal/adf1-mcdu", "XXX/999.99"); setprop("/FMGC/internal/adf2-mcdu", "999.99/XXX"); -setprop("gear/gear[0]/wow-fmgc", 1); var FMGCinit = func { setprop("/FMGC/status/to-state", 0); - setprop("/FMGC/status/phase", 0); # 0 is Preflight 1 is Takeoff 2 is Climb 3 is Cruise 4 is Descent 5 is Decel/Approach 6 is Go Around 7 is Done + fmgc.FMGCInternal.phase = 0; # 0 is Preflight 1 is Takeoff 2 is Climb 3 is Cruise 4 is Descent 5 is Decel/Approach 6 is Go Around 7 is Done setprop("/FMGC/internal/maxspeed", 338); setprop("/FMGC/internal/mng-spd", 157); setprop("/FMGC/internal/mng-spd-cmd", 157); @@ -138,6 +135,10 @@ var FMGCinit = func { } var FMGCInternal = { + # phase logic + phase: 0, + + # PERF v1: 0, v1set: 0, vr: 0, @@ -146,9 +147,39 @@ var FMGCInternal = { v2set: 0, transAlt: 18000, transAltSet: 0, + + # INIT A + altAirport: "", + altAirportSet: 0, + altSelected: 0, + arrApt: "", + costIndex: 0, + costIndexSet: 0, + crzFt: 10000, + crzFl: 0, + crzSet: 0, + crzTemp: 15, + crzTempSet: 0, + flightNum: "", + flightNumSet: 0, + gndTemp: 15, + gndTempSet: 0, + depApt: "", + tropo: 36090, + tropoSet: 0, + toFromSet: 0, }; +var postInit = func() { + # Some properties had setlistener -- so to make sure all is o.k., we call function immediately like so: + altvert(); + updateRouteManagerAlt(); + mcdu.updateCrzLvlCallback(); +} + 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"), }; @@ -157,14 +188,13 @@ var FMGCNodes = { # FBW Trim # ############ -setlistener("/gear/gear[0]/wow-fmgc", func { +setlistener("/gear/gear[0]/wow", func { trimReset(); -}); +}, 0, 0); var trimReset = func { - gear0 = getprop("/gear/gear[0]/wow"); flaps = getprop("/controls/flight/flaps-pos"); - if (gear0 == 1 and getprop("/FMGC/status/to-state") == 0 and (flaps >= 5 or (flaps >= 4 and getprop("/instrumentation/mk-viii/inputs/discretes/momentary-flap3-override") == 1))) { + if (pts.Gear.wow[0].getBoolValue() and getprop("/FMGC/status/to-state") == 0 and (flaps >= 5 or (flaps >= 4 and getprop("/instrumentation/mk-viii/inputs/discretes/momentary-flap3-override") == 1))) { interpolate("/controls/flight/elevator-trim", 0.0, 1.5); } } @@ -174,20 +204,17 @@ var trimReset = func { ############### var updateARPT = func { - dep = getprop("/FMGC/internal/dep-arpt"); - arr = getprop("/FMGC/internal/arr-arpt"); - alt = getprop("/FMGC/internal/alt-airport"); - setprop("autopilot/route-manager/departure/airport", dep); - setprop("autopilot/route-manager/destination/airport", arr); - setprop("autopilot/route-manager/alternate/airport", alt); + setprop("autopilot/route-manager/departure/airport", fmgc.FMGCInternal.depApt); + setprop("autopilot/route-manager/destination/airport", fmgc.FMGCInternal.arrApt); + setprop("autopilot/route-manager/alternate/airport", fmgc.FMGCInternal.altAirport); if (getprop("/autopilot/route-manager/active") != 1) { fgcommand("activate-flightplan", props.Node.new({"activate": 1})); } } -setlistener("/FMGC/internal/cruise-ft", func { - setprop("autopilot/route-manager/cruise/altitude-ft", getprop("/FMGC/internal/cruise-ft")); -}); +updateRouteManagerAlt = func() { + setprop("autopilot/route-manager/cruise/altitude-ft", FMGCInternal.crzFt); +}; ######## # FUEL # @@ -238,9 +265,9 @@ var updateFuel = func { } # Calculate alternate fuel - if (!getprop("/FMGC/internal/alt-fuel-set") and getprop("/FMGC/internal/alt-set")) { + if (!getprop("/FMGC/internal/alt-fuel-set") and fmgc.FMGCInternal.altAirportSet) { #calc - } else if (getprop("/FMGC/internal/alt-fuel-set") and getprop("/FMGC/internal/alt-set")) { + } else if (getprop("/FMGC/internal/alt-fuel-set") and fmgc.FMGCInternal.altAirportSet) { #dummy calc for now alt_fuel = 1000 * num(getprop("/FMGC/internal/alt-fuel")); zfw = 1000 * getprop("/FMGC/internal/zfw"); @@ -272,9 +299,9 @@ var updateFuel = func { } # Calculate trip fuel - if (getprop("/FMGC/internal/tofrom-set") and getprop("/FMGC/internal/cruise-lvl-set") and getprop("/FMGC/internal/cruise-temp-set") and getprop("/FMGC/internal/zfw-set")) { - crz = getprop("/FMGC/internal/cruise-fl"); - temp = getprop("/FMGC/internal/cruise-temp"); + if (FMGCInternal.toFromSet and FMGCInternal.crzSet and FMGCInternal.crzTempSet and getprop("/FMGC/internal/zfw-set")) { + crz = FMGCInternal.crzFl; + temp = FMGCInternal.crzTemp; dist = flightPlanController.arrivalDist; trpWind = getprop("/FMGC/internal/trip-wind"); @@ -396,13 +423,12 @@ var masterFMGC = maketimer(0.2, func { gs = getprop("/velocities/groundspeed-kt"); alt = getprop("/instrumentation/altimeter/indicated-altitude-ft"); aglalt = pts.Position.gearAglFt.getValue(); - cruiseft = getprop("/FMGC/internal/cruise-ft"); - cruiseft_b = getprop("/FMGC/internal/cruise-ft") - 200; + # cruiseft = FMGCInternal.crzFt; + # cruiseft_b = FMGCInternal.crzFt - 200; newcruise = getprop("/it-autoflight/internal/alt"); - phase = getprop("/FMGC/status/phase"); + phase = fmgc.FMGCInternal.phase; state1 = getprop("/systems/thrust/state1"); state2 = getprop("/systems/thrust/state2"); - gear0 = getprop("/gear/gear[0]/wow"); wowl = getprop("/gear/gear[1]/wow"); wowr = getprop("/gear/gear[2]/wow"); targetalt = getprop("/it-autoflight/internal/alt"); @@ -411,7 +437,7 @@ var masterFMGC = maketimer(0.2, func { accel_agl_ft = getprop("/it-autoflight/settings/accel-agl-ft"); locarm = getprop("/it-autopilot/output/loc-armed"); apprarm = getprop("/it-autopilot/output/appr-armed"); - gear0 = getprop("/gear/gear[0]/wow"); + gear0 = pts.Gear.wow[0].getBoolValue(); ap1 = getprop("/it-autoflight/output/ap1"); ap2 = getprop("/it-autoflight/output/ap2"); flx = getprop("/systems/thrust/lim-flex"); @@ -423,62 +449,57 @@ var masterFMGC = maketimer(0.2, func { thr1 = getprop("/controls/engines/engine[0]/throttle-pos"); thr2 = getprop("/controls/engines/engine[1]/throttle-pos"); altSel = getprop("/it-autoflight/input/alt"); - crzFl = getprop("/FMGC/internal/cruise-fl"); - if (getprop("/gear/gear[0]/wow") != getprop("/gear/gear[0]/wow-fmgc")) { - setprop("gear/gear[0]/wow-fmgc", getprop("/gear/gear[0]/wow")); - } - - if ((n1_left < 85 or n1_right < 85) and gs < 90 and mode == " " and gear0 == 1 and phase == 1) { # rejected takeoff - setprop("/FMGC/status/phase", 0); + if ((n1_left < 85 or n1_right < 85) and gs < 90 and mode == " " and gear0 and FMGCInternal.phase == 1) { # rejected takeoff + FMGCInternal.phase = 0; setprop("systems/pressurization/mode", "GN"); } - if (gear0 == 1 and phase == 0 and ((n1_left >= 85 and n1_right >= 85 and mode == "SRS") or gs >= 90)) { - setprop("/FMGC/status/phase", 1); + if (gear0 and FMGCInternal.phase == 0 and ((n1_left >= 85 and n1_right >= 85 and mode == "SRS") or gs >= 90)) { + FMGCInternal.phase = 1; setprop("systems/pressurization/mode", "TO"); } - if (phase == 1 and ((mode != "SRS" and mode != " ") or alt >= accel_agl_ft)) { - setprop("/FMGC/status/phase", 2); + if (FMGCInternal.phase == 1 and ((mode != "SRS" and mode != " ") or alt >= accel_agl_ft)) { + FMGCInternal.phase = 2; setprop("systems/pressurization/mode", "TO"); } - if (phase == 2 and (mode == "ALT CRZ" or mode == "ALT CRZ*")) { - setprop("/FMGC/status/phase", 3); + if (FMGCInternal.phase == 2 and (mode == "ALT CRZ" or mode == "ALT CRZ*")) { + FMGCInternal.phase = 3; setprop("systems/pressurization/mode", "CR"); } - if (crzFl >= 200) { - if (phase == 3 and (flightPlanController.arrivalDist <= 200 or altSel < 20000)) { - setprop("/FMGC/status/phase", 4); + if (FMGCInternal.crzFl >= 200) { + if (FMGCInternal.phase == 3 and (flightPlanController.arrivalDist <= 200 or altSel < 20000)) { + FMGCInternal.phase = 4; setprop("systems/pressurization/mode", "DE"); } } else { - if (phase == 3 and (flightPlanController.arrivalDist <= 200 or altSel < (crzFl * 100))) { # todo - not sure about crzFl condition, investigate what happens! - setprop("/FMGC/status/phase", 4); + if (FMGCInternal.phase == 3 and (flightPlanController.arrivalDist <= 200 or altSel < (FMGCInternal.crzFl * 100))) { # todo - not sure about crzFl condition, investigate what happens! + FMGCInternal.phase = 4; setprop("systems/pressurization/mode", "DE"); } } - if (phase == 4 and getprop("/FMGC/internal/decel")) { - setprop("/FMGC/status/phase", 5); + if (FMGCInternal.phase == 4 and getprop("/FMGC/internal/decel")) { + FMGCInternal.phase = 5; } if (flightPlanController.num[2].getValue() > 0 and getprop("/FMGC/flightplan[2]/active") == 1 and flightPlanController.arrivalDist <= 15 and (modelat == "NAV" or modelat == "LOC" or modelat == "LOC*") and aglalt < 9500) { #todo decel pseudo waypoint setprop("/FMGC/internal/decel", 1); - } else if (getprop("/FMGC/internal/decel") == 1 and (phase == 0 or phase == 6)) { + } else if (getprop("/FMGC/internal/decel") == 1 and (FMGCInternal.phase == 0 or FMGCInternal.phase == 6)) { setprop("/FMGC/internal/decel", 0); } - if ((phase == "5") and state1 == "TOGA" and state2 == "TOGA") { - setprop("/FMGC/status/phase", 6); + if ((FMGCInternal.phase == 5) and state1 == "TOGA" and state2 == "TOGA") { + FMGCInternal.phase = 6; setprop("systems/pressurization/mode", "TO"); setprop("/it-autoflight/input/toga", 1); } - if (phase == "6" and alt >= accel_agl_ft) { # todo when insert altn or new dest - setprop("/FMGC/status/phase", 2); + if (FMGCInternal.phase == 6 and alt >= accel_agl_ft) { # todo when insert altn or new dest + FMGCInternal.phase = 2; } if (getprop("/systems/navigation/adr/computation/overspeed-vfe-spd") != 1024) { @@ -535,7 +556,7 @@ var masterFMGC = maketimer(0.2, func { } # predicted takeoff speeds - if (phase == "1") { + if (FMGCInternal.phase == 1) { setprop("/FMGC/internal/computed-speeds/clean_to", getprop("/FMGC/internal/computed-speeds/clean")); setprop("/FMGC/internal/computed-speeds/vs1g_clean_to", getprop("/FMGC/internal/computed-speeds/vs1g_clean")); setprop("/FMGC/internal/computed-speeds/vs1g_conf_2_to", getprop("/FMGC/internal/computed-speeds/vs1g_conf_2")); @@ -558,7 +579,7 @@ var masterFMGC = maketimer(0.2, func { } # predicted approach (temp go-around) speeds - if (phase == "5" or phase == "6") { + if (FMGCInternal.phase == 5 or FMGCInternal.phase == 6) { setprop("/FMGC/internal/computed-speeds/clean_appr", getprop("/FMGC/internal/computed-speeds/clean")); setprop("/FMGC/internal/computed-speeds/vs1g_clean_appr", getprop("/FMGC/internal/computed-speeds/vs1g_clean")); setprop("/FMGC/internal/computed-speeds/vs1g_conf_2_appr", getprop("/FMGC/internal/computed-speeds/vs1g_conf_2")); @@ -676,7 +697,7 @@ var masterFMGC = maketimer(0.2, func { setprop("/FMGC/internal/minspeed", getprop("/FMGC/internal/computed-speeds/vapp")); } - if (gear0 == 1 and (state1 == "MCT" or state1 == "MAN THR" or state1 == "TOGA") and (state2 == "MCT" or state2 == "MAN THR" or state2 == "TOGA") and flaps < 5) { + if (gear0 and (state1 == "MCT" or state1 == "MAN THR" or state1 == "TOGA") and (state2 == "MCT" or state2 == "MAN THR" or state2 == "TOGA") and flaps < 5) { setprop("/FMGC/status/to-state", 1); } if (pts.Position.gearAglFt.getValue() >= 55) { @@ -690,7 +711,7 @@ var masterFMGC = maketimer(0.2, func { departure_rwy = fmgc.flightPlanController.flightplans[2].departure_runway; destination_rwy = fmgc.flightPlanController.flightplans[2].destination_runway; if (destination_rwy != nil and phase >= 2) { - var airport = airportinfo(getprop("/FMGC/internal/arr-arpt")); + var airport = airportinfo(fmgc.FMGCInternal.arrApt); setprop("/FMGC/internal/ldg-elev", airport.elevation * M2FT); # eventually should be runway elevation magnetic_hdg = geo.normdeg(destination_rwy.heading - getprop("/environment/magnetic-variation-deg")); runway_ils = destination_rwy.ils_frequency_mhz; @@ -721,7 +742,7 @@ var masterFMGC = maketimer(0.2, func { }); var reset_FMGC = func { - setprop("/FMGC/status/phase", 0); + fmgc.FMGCInternal.phase = 0; fd1 = getprop("/it-autoflight/input/fd1"); fd2 = getprop("/it-autoflight/input/fd2"); spd = getprop("/it-autoflight/input/kts"); @@ -868,7 +889,7 @@ var adf1 = func { ################# var ManagedSPD = maketimer(0.25, func { - if (getprop("/FMGC/internal/cruise-lvl-set") == 1 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"); @@ -881,7 +902,7 @@ var ManagedSPD = maketimer(0.25, func { kts_sel = getprop("/it-autoflight/input/kts"); mach_sel = getprop("/it-autoflight/input/mach"); srsSPD = getprop("/it-autoflight/settings/togaspd"); - phase = getprop("/FMGC/status/phase"); # 0 is Preflight 1 is Takeoff 2 is Climb 3 is Cruise 4 is Descent 5 is Decel/Approach 6 is Go Around 7 is Done + phase = fmgc.FMGCInternal.phase; # 0 is Preflight 1 is Takeoff 2 is Climb 3 is Cruise 4 is Descent 5 is Decel/Approach 6 is Go Around 7 is Done flap = getprop("/controls/flight/flaps-pos"); maxspeed = getprop("/FMGC/internal/maxspeed"); minspeed = getprop("/FMGC/internal/minspeed"); @@ -894,22 +915,22 @@ var ManagedSPD = maketimer(0.25, func { mng_alt_mach_cmd = getprop("/FMGC/internal/mng-alt-mach"); mng_alt_mach = math.round(mng_alt_mach_cmd, 0.001); - if (mach > mng_alt_mach and (phase == 2 or phase == 3)) { + if (mach > mng_alt_mach and (FMGCInternal.phase == 2 or FMGCInternal.phase == 3)) { setprop("/FMGC/internal/mach-switchover", 1); } - if (ias > mng_alt_spd and (phase == 4 or phase == 5)) { + if (ias > mng_alt_spd and (FMGCInternal.phase == 4 or FMGCInternal.phase == 5)) { setprop("/FMGC/internal/mach-switchover", 0); } - if ((mode == " " or mode == "SRS") and (phase == 0 or phase == 1)) { + if ((mode == " " or mode == "SRS") and (FMGCInternal.phase == 0 or FMGCInternal.phase == 1)) { if (mngktsmach) { setprop("/FMGC/internal/mng-kts-mach", 0); } if (mng_spd_cmd != srsSPD) { setprop("/FMGC/internal/mng-spd-cmd", srsSPD); } - } else if ((phase == 2 or phase == 3) and altitude <= 10050) { + } else if ((FMGCInternal.phase == 2 or FMGCInternal.phase == 3) and altitude <= 10050) { if (mngktsmach) { setprop("/FMGC/internal/mng-kts-mach", 0); } @@ -918,35 +939,35 @@ var ManagedSPD = maketimer(0.25, func { } else if (mng_spd_cmd != minspeed and decel) { setprop("/FMGC/internal/mng-spd-cmd", minspeed); } - } else if ((phase == 2 or phase == 3) and altitude > 10070 and !mach_switchover) { + } else if ((FMGCInternal.phase == 2 or FMGCInternal.phase == 3) and altitude > 10070 and !mach_switchover) { if (mngktsmach) { setprop("/FMGC/internal/mng-kts-mach", 0); } if (mng_spd_cmd != mng_alt_spd) { setprop("/FMGC/internal/mng-spd-cmd", mng_alt_spd); } - } else if ((phase == 2 or phase == 3) and altitude > 10070 and mach_switchover) { + } else if ((FMGCInternal.phase == 2 or FMGCInternal.phase == 3) and altitude > 10070 and mach_switchover) { if (!mngktsmach) { setprop("/FMGC/internal/mng-kts-mach", 1); } if (mng_spd_cmd != mng_alt_mach) { setprop("/FMGC/internal/mng-spd-cmd", mng_alt_mach); } - } else if (phase == 4 and altitude > 11000 and !mach_switchover) { + } else if (FMGCInternal.phase == 4 and altitude > 11000 and !mach_switchover) { if (mngktsmach) { setprop("/FMGC/internal/mng-kts-mach", 0); } if (mng_spd_cmd != mng_alt_spd) { setprop("/FMGC/internal/mng-spd-cmd", mng_alt_spd); } - } else if (phase == 4 and altitude > 11000 and mach_switchover) { + } else if (FMGCInternal.phase == 4 and altitude > 11000 and mach_switchover) { if (!mngktsmach) { setprop("/FMGC/internal/mng-kts-mach", 1); } if (mng_spd_cmd != mng_alt_mach) { setprop("/FMGC/internal/mng-spd-cmd", mng_alt_mach); } - } else if ((phase == 4 or phase == 5 or phase == 6) and altitude > 11000 and !mach_switchover) { + } else if ((FMGCInternal.phase == 4 or FMGCInternal.phase == 5 or FMGCInternal.phase == 6) and altitude > 11000 and !mach_switchover) { if (mngktsmach) { setprop("/FMGC/internal/mng-kts-mach", 0); } @@ -955,7 +976,7 @@ var ManagedSPD = maketimer(0.25, func { } else if (mng_spd_cmd != minspeed and decel) { setprop("/FMGC/internal/mng-spd-cmd", minspeed); } - } else if ((phase == 4 or phase == 5 or phase == 6) and altitude <= 10980) { + } else if ((FMGCInternal.phase == 4 or FMGCInternal.phase == 5 or FMGCInternal.phase == 6) and altitude <= 10980) { if (mngktsmach) { setprop("/FMGC/internal/mng-kts-mach", 0); } @@ -1087,9 +1108,9 @@ setlistener("/FMGC/internal/fuel-calculating", func() { # Maketimers 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")); + fmgc.FMGCInternal.phase = 7; + if (FMGCInternal.costIndexSet) { + setprop("/FMGC/internal/last-cost-index", FMGCInternal.costIndex); } else { setprop("/FMGC/internal/last-cost-index", 0); } diff --git a/Nasal/FMGC/flightplan.nas b/Nasal/FMGC/flightplan.nas index a3909c1b..1c1e2436 100644 --- a/Nasal/FMGC/flightplan.nas +++ b/Nasal/FMGC/flightplan.nas @@ -16,9 +16,6 @@ var DEBUG_DISCONT = 0; # Props.getNode var magHDG = props.globals.getNode("/orientation/heading-magnetic-deg", 1); var trueHDG = props.globals.getNode("/orientation/heading-deg", 1); -var FMGCdep = props.globals.getNode("/FMGC/internal/dep-arpt", 1); -var FMGCarr = props.globals.getNode("/FMGC/internal/arr-arpt", 1); -var toFromSet = props.globals.getNode("/FMGC/internal/tofrom-set", 1); # Props.initNode var wpID = [[props.globals.initNode("/FMGC/flightplan[0]/wp[0]/id", "", "STRING")], [props.globals.initNode("/FMGC/flightplan[1]/wp[0]/id", "", "STRING")], [props.globals.initNode("/FMGC/flightplan[2]/wp[0]/id", "", "STRING")]]; @@ -392,7 +389,7 @@ var flightPlanController = { deleteWP: func(index, n, a = 0, s = 0) { # a = 1, means adding a waypoint via deleting intermediate. s = 1, means autosequencing var wp = wpID[n][index].getValue(); - if (((s == 0 and left(wp, 4) != FMGCdep.getValue() and left(wp, 4) != FMGCarr.getValue()) or (s == 1)) and me.flightplans[n].getPlanSize() > 2) { + if (((s == 0 and left(wp, 4) != FMGCInternal.depApt and left(wp, 4) != FMGCInternal.arrApt) or (s == 1)) and me.flightplans[n].getPlanSize() > 2) { if (me.flightplans[n].getWP(index).id != "DISCONTINUITY" and a == 0) { # if it is a discont, don't make a new one me.flightplans[n].deleteWP(index); fmgc.windController.deleteWind(n, index); @@ -792,12 +789,6 @@ var flightPlanController = { } } - if (left(wpID[n][wpt].getValue(), 4) == FMGCarr.getValue() and wpt != 0) { - if (me.arrivalIndex[n] != wpt) { - me.arrivalIndex[n] = wpt; - } - } - if (wpt > 0) { wpCoursePrev[n][wpt].setValue(me.flightplans[n].getWP(wpt).leg_bearing); wpDistancePrev[n][wpt].setValue(me.flightplans[n].getWP(wpt).leg_distance); @@ -812,8 +803,10 @@ var flightPlanController = { wpDistancePrev[n][wpt].setValue(courseDistanceFrom[1]); } - if (left(wpID[n][wpt].getValue(), 4) == FMGCarr.getValue() and wpt != 0) { - if (me.arrivalIndex[n] != wpt) { # don't merge line 397 and 398 if statements + if (left(wpID[n][wpt].getValue(), 4) == fmgc.FMGCInternal.arrApt and wpt != 0) { + if (me.arrivalIndex[n] != wpt) { + me.arrivalIndex[n] = wpt; + if (canvas_mcdu.myFpln[0] != nil) { canvas_mcdu.myFpln[0].destInfo(); } @@ -828,15 +821,16 @@ var flightPlanController = { if (me.flightplans[2].getWP(me.arrivalIndex[2]) == nil or me.flightplans[2].getWP(1) == nil) { me.arrivalDist = 9999; print(me.arrivalIndex[2]); + } else { + me.arrivalDist = me.flightplans[2].getWP(me.arrivalIndex[2]).distance_along_route - me.flightplans[2].getWP(1).leg_distance + me._arrivalDist; } - me.arrivalDist = me.flightplans[2].getWP(me.arrivalIndex[2]).distance_along_route - me.flightplans[2].getWP(1).leg_distance + me._arrivalDist; me.updateMCDUDriver(n); }, updateCurrentWaypoint: func() { for (var india = 0; india <= 2; india += 1) { - if (toFromSet.getBoolValue() and me.flightplans[india].departure != nil and me.flightplans[india].destination != nil) { # check if flightplan exists + if (FMGCInternal.toFromSet and me.flightplans[india].departure != nil and me.flightplans[india].destination != nil) { # check if flightplan exists var curAircraftPos = geo.aircraft_position(); # don't want to get this corrupted so make sure it is a local variable if (india == 2) { # main plan diff --git a/Nasal/FMGC/winds.nas b/Nasal/FMGC/winds.nas index b4c31a92..327b3831 100644 --- a/Nasal/FMGC/winds.nas +++ b/Nasal/FMGC/winds.nas @@ -316,7 +316,7 @@ var windController = { } if (canvas_mcdu.myCRZWIND[1] != nil) { if (!fmgc.flightPlanController.temporaryFlag[1]) { - if (getprop("/FMGC/internal/tofrom-set") and size(fmgc.windController.nav_indicies[2]) > 0) { + if (fmgc.FMGCInternal.toFromSet and size(fmgc.windController.nav_indicies[2]) > 0) { canvas_mcdu.myCRZWIND[1].waypoint = fmgc.flightPlanController.flightplans[2].getWP(me.nav_indicies[2][0]); canvas_mcdu.myCRZWIND[1].singleCRZ = 0; canvas_mcdu.myCRZWIND[1].cur_location = 0; @@ -326,7 +326,7 @@ var windController = { canvas_mcdu.myCRZWIND[1].cur_location = 0; } } else { - if (getprop("/FMGC/internal/tofrom-set") and size(fmgc.windController.nav_indicies[1]) > 0) { + if (fmgc.FMGCInternal.toFromSet and size(fmgc.windController.nav_indicies[1]) > 0) { canvas_mcdu.myCRZWIND[1].waypoint = fmgc.flightPlanController.flightplans[1].getWP(me.nav_indicies[1][0]); canvas_mcdu.myCRZWIND[1].singleCRZ = 0; canvas_mcdu.myCRZWIND[1].cur_location = 0; @@ -340,7 +340,7 @@ var windController = { } if (canvas_mcdu.myCRZWIND[0] != nil) { if (!fmgc.flightPlanController.temporaryFlag[0]) { - if (getprop("/FMGC/internal/tofrom-set") and size(fmgc.windController.nav_indicies[2]) > 0) { + if (fmgc.FMGCInternal.toFromSet and size(fmgc.windController.nav_indicies[2]) > 0) { canvas_mcdu.myCRZWIND[0].waypoint = fmgc.flightPlanController.flightplans[2].getWP(me.nav_indicies[2][0]); canvas_mcdu.myCRZWIND[0].singleCRZ = 0; canvas_mcdu.myCRZWIND[0].cur_location = 0; @@ -350,7 +350,7 @@ var windController = { canvas_mcdu.myCRZWIND[0].cur_location = 0; } } else { - if (getprop("/FMGC/internal/tofrom-set") and size(fmgc.windController.nav_indicies[0]) > 0) { + if (fmgc.FMGCInternal.toFromSet and size(fmgc.windController.nav_indicies[0]) > 0) { canvas_mcdu.myCRZWIND[0].waypoint = fmgc.flightPlanController.flightplans[0].getWP(me.nav_indicies[0][0]); canvas_mcdu.myCRZWIND[0].singleCRZ = 0; canvas_mcdu.myCRZWIND[0].cur_location = 0; diff --git a/Nasal/Libraries/libraries.nas b/Nasal/Libraries/libraries.nas index 739ead52..944e285d 100644 --- a/Nasal/Libraries/libraries.nas +++ b/Nasal/Libraries/libraries.nas @@ -249,6 +249,7 @@ var systemsInit = func { setlistener("/sim/signals/fdm-initialized", func { systemsInit(); + fmgc.postInit(); fmgc.flightPlanTimer.start(); fmgc.WaypointDatabase.read(); }); diff --git a/Nasal/MCDU/F-PLN.nas b/Nasal/MCDU/F-PLN.nas index 356c292a..19f4d5c5 100644 --- a/Nasal/MCDU/F-PLN.nas +++ b/Nasal/MCDU/F-PLN.nas @@ -94,7 +94,7 @@ var fplnItem = { return sprintf("%03.0f", math.round(me.trk)); }, getSpd: func() { - if (me.index == 0 and fmgc.FMGCInternal.v1set) { + if (me.index == 0 and left(me.wp.wp_name, 4) == fmgc.FMGCInternal.depApt and fmgc.FMGCInternal.v1set) { return [sprintf("%3.0f", math.round(fmgc.FMGCInternal.v1)), "mag"]; } elsif (me.wp.speed_cstr != nil and me.wp.speed_cstr != 0) { return [sprintf("%3.0f", me.wp.speed_cstr), "mag"]; @@ -103,7 +103,7 @@ var fplnItem = { } }, getAlt: func() { - if (me.index == 0 and left(me.wp.wp_name, 4) == getprop("/FMGC/internal/dep-arpt") and fmgc.flightPlanController.flightplans[me.plan].departure != nil) { + if (me.index == 0 and left(me.wp.wp_name, 4) == fmgc.FMGCInternal.depApt and fmgc.flightPlanController.flightplans[me.plan].departure != nil) { return [" " ~ sprintf("%-5.0f", math.round(fmgc.flightPlanController.flightplans[me.plan].departure.elevation * M2FT)), "mag"]; } elsif (me.index == (fmgc.flightPlanController.currentToWptIndex.getValue() - 1) and fmgc.flightPlanController.fromWptAlt != nil) { return [" " ~ fmgc.flightPlanController.fromWptAlt, "mag"]; @@ -319,7 +319,7 @@ var fplnPage = { # this one is only created once, and then updated - remember th colour = "grn"; } for (var i = 0; i < me.plan.getPlanSize(); i += 1) { - if (!me.temporaryFlagFpln and i > fmgc.flightPlanController.arrivalIndex[me.planIndex] and getprop("/FMGC/status/phase") != 6) { + if (!me.temporaryFlagFpln and i > fmgc.flightPlanController.arrivalIndex[me.planIndex] and fmgc.FMGCInternal.phase != 6) { append(me.planList, fplnItem.new(me.plan.getWP(i), i, me.planIndex, me.computer, "blu")); } else { append(me.planList, fplnItem.new(me.plan.getWP(i), i, me.planIndex, me.computer, colour)); diff --git a/Nasal/MCDU/FUELPRED.nas b/Nasal/MCDU/FUELPRED.nas index 544339da..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 getprop("/FMGC/internal/tofrom-set")) { + 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 5a9fef65..8e997de2 100644 --- a/Nasal/MCDU/INITA.nas +++ b/Nasal/MCDU/INITA.nas @@ -7,8 +7,8 @@ var initInputA = func(key, i) { var scratchpad = mcdu_scratchpad.scratchpads[i].scratchpad; if (key == "L2") { if (scratchpad == "CLR") { - setprop("/FMGC/internal/alt-airport", ""); - setprop("/FMGC/internal/alt-set", 0); + fmgc.FMGCInternal.altAirport = ""; + fmgc.FMGCInternal.altAirportSet = 0; fmgc.windController.updatePlans(); if (getprop("/FMGC/internal/block-confirmed")) { setprop("/FMGC/internal/fuel-calculating", 0); @@ -17,14 +17,14 @@ var initInputA = func(key, i) { mcdu_scratchpad.scratchpads[i].empty(); fmgc.updateARPT(); #} else if (scratchpad == "") { - #setprop("/FMGC/internal/alt-selected", 1); + #fmgc.FMGCInternal.altSelected = 1; #setprop("MCDU[" ~ i ~ "]/page", "ROUTESELECTION"); - } else if (getprop("/FMGC/internal/tofrom-set") == 1) { + } else if (fmgc.FMGCInternal.toFromSet) { if (!fmgc.flightPlanController.temporaryFlag[i]) { var tfs = size(scratchpad); if (tfs == 4) { - setprop("/FMGC/internal/alt-airport", scratchpad); - setprop("/FMGC/internal/alt-set", 1); + fmgc.FMGCInternal.altAirport = scratchpad; + fmgc.FMGCInternal.altAirportSet = 1; fmgc.windController.updatePlans(); if (getprop("/FMGC/internal/block-confirmed")) { setprop("/FMGC/internal/fuel-calculating", 0); @@ -32,7 +32,7 @@ var initInputA = func(key, i) { } mcdu_scratchpad.scratchpads[i].empty(); fmgc.updateARPT(); - #setprop("/FMGC/internal/alt-selected", 1); + #fmgc.FMGCInternal.altSelected = 1; #setprop("MCDU[" ~ i ~ "]/page", "ROUTESELECTION"); } else { mcdu_message(i, "NOT ALLOWED"); @@ -45,14 +45,14 @@ var initInputA = func(key, i) { } } else if (key == "L3") { if (scratchpad == "CLR") { - setprop("MCDUC/flight-num", ""); - setprop("MCDUC/flight-num-set", 0); + fmgc.FMGCInternal.flightNum = ""; + fmgc.FMGCInternal.flightNumSet = 0; mcdu_scratchpad.scratchpads[i].empty(); } else { var flts = size(scratchpad); if (flts >= 1 and flts <= 8) { - setprop("MCDUC/flight-num", scratchpad); - setprop("MCDUC/flight-num-set", 1); + fmgc.FMGCInternal.flightNum = scratchpad; + fmgc.FMGCInternal.flightNumSet = 1; mcdu_scratchpad.scratchpads[i].empty(); } else { mcdu_message(i, "NOT ALLOWED"); @@ -60,16 +60,18 @@ 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; + fmgc.FMGCNodes.costIndex.setValue(fmgc.FMGCInternal.costIndex); mcdu_scratchpad.scratchpads[i].empty(); } else { mcdu_message(i, "NOT ALLOWED"); @@ -80,11 +82,14 @@ var initInputA = func(key, i) { } } else if (key == "L6") { if (scratchpad == "CLR") { - setprop("/FMGC/internal/cruise-ft", 10000); - setprop("/FMGC/internal/cruise-fl", 100); - setprop("/FMGC/internal/cruise-lvl-set", 0); - setprop("/FMGC/internal/cruise-temp", 15); - setprop("/FMGC/internal/cruise-temp-set", 0); + fmgc.FMGCInternal.crzFt = 10000; + fmgc.FMGCInternal.crzFl = 100; + fmgc.altvert(); + fmgc.updateRouteManagerAlt(); + fmgc.FMGCInternal.crzSet = 0; + updateCrzLvlCallback(); + fmgc.FMGCInternal.crzTemp = 15; + fmgc.FMGCInternal.crzTempSet = 0; if (getprop("/FMGC/internal/block-confirmed")) { setprop("/FMGC/internal/fuel-calculating", 0); setprop("/FMGC/internal/fuel-calculating", 1); @@ -101,9 +106,10 @@ var initInputA = func(key, i) { } var temp = int(crztemp[1]); var temps = size(crztemp[1]); - if (crzs == 0 and temps >= 1 and temps <= 3 and temp != nil and getprop("/FMGC/internal/cruise-lvl-set")) { + if (crzs == 0 and temps >= 1 and temps <= 3 and temp != nil and fmgc.FMGCInternal.crzSet) { if (temp >= -99 and temp <= 99) { - setprop("/FMGC/internal/cruise-temp", temp); + fmgc.FMGCInternal.crzTemp = temp; + fmgc.FMGCInternal.crzTempSet = 1; if (getprop("/FMGC/internal/block-confirmed")) { setprop("/FMGC/internal/fuel-calculating", 0); setprop("/FMGC/internal/fuel-calculating", 1); @@ -114,12 +120,15 @@ var initInputA = func(key, i) { } } else if (crzs >= 1 and crzs <= 3 and crz != nil and temps >= 1 and temps <= 3 and temp != nil) { if (crz > 0 and crz <= 390 and temp >= -99 and temp <= 99) { - setprop("/FMGC/internal/cruise-ft", crz * 100); - setprop("/FMGC/internal/cruise-fl", crz); - setprop("/FMGC/internal/cruise-fl-prog", crz); - setprop("/FMGC/internal/cruise-lvl-set", 1); - setprop("/FMGC/internal/cruise-temp", temp); - setprop("/FMGC/internal/cruise-temp-set", 1); + fmgc.FMGCInternal.crzFt = crz * 100; + fmgc.FMGCInternal.crzFl = crz; + fmgc.altvert(); + fmgc.updateRouteManagerAlt(); + fmgc.FMGCInternal.crzSet = 1; + updateCrzLvlCallback(); + fmgc.FMGCInternal.crzTemp = temp; + fmgc.FMGCInternal.crzTempSet = 1; + fmgc.FMGCInternal.crzProg = crz; if (getprop("/FMGC/internal/block-confirmed")) { setprop("/FMGC/internal/fuel-calculating", 0); setprop("/FMGC/internal/fuel-calculating", 1); @@ -141,10 +150,13 @@ var initInputA = func(key, i) { } if (crzs >= 1 and crzs <= 3 and crz != nil) { if (crz > 0 and crz <= 390) { - setprop("/FMGC/internal/cruise-ft", crz * 100); - setprop("/FMGC/internal/cruise-fl", crz); - setprop("/FMGC/internal/cruise-fl-prog", crz); - setprop("/FMGC/internal/cruise-lvl-set", 1); + fmgc.FMGCInternal.crzFt = crz * 100; + fmgc.FMGCInternal.crzFl = crz; + fmgc.altvert(); + fmgc.updateRouteManagerAlt(); + fmgc.FMGCInternal.crzSet = 1; + updateCrzLvlCallback(); + fmgc.FMGCInternal.crzProg = crz; if (getprop("/FMGC/internal/block-confirmed")) { setprop("/FMGC/internal/fuel-calculating", 0); setprop("/FMGC/internal/fuel-calculating", 1); @@ -159,9 +171,10 @@ var initInputA = func(key, i) { } } else if (key == "R1") { if (scratchpad == "CLR") { - setprop("/FMGC/internal/dep-arpt", ""); - setprop("/FMGC/internal/arr-arpt", ""); - setprop("/FMGC/internal/tofrom-set", 0); + fmgc.FMGCInternal.depApt = ""; + fmgc.FMGCInternal.arrApt = ""; + fmgc.FMGCInternal.toFromSet = 0; + fmgc.FMGCNodes.toFromSet.setValue(0); setprop("/FMGC/internal/align-ref-lat", 0); setprop("/FMGC/internal/align-ref-long", 0); setprop("/FMGC/internal/align-ref-lat-edit", 0); @@ -176,7 +189,7 @@ var initInputA = func(key, i) { fmgc.windController.init(); mcdu_scratchpad.scratchpads[i].empty(); #} else if (scratchpad == "") { - #setprop("/FMGC/internal/alt-selected", 0); + #fmgc.FMGCInternal.altSelected = 0; #setprop("MCDU[" ~ i ~ "]/page", "ROUTESELECTION"); } else { if (!fmgc.flightPlanController.temporaryFlag[i]) { @@ -187,13 +200,14 @@ var initInputA = func(key, i) { var tos = size(fromto[1]); if (froms == 4 and tos == 4) { #route - setprop("/FMGC/internal/dep-arpt", fromto[0]); - setprop("/FMGC/internal/arr-arpt", fromto[1]); - setprop("/FMGC/internal/tofrom-set", 1); + fmgc.FMGCInternal.depApt = fromto[0]; + fmgc.FMGCInternal.arrApt = fromto[1]; + fmgc.FMGCInternal.toFromSet = 1; + fmgc.FMGCNodes.toFromSet.setValue(1); #scratchpad mcdu_scratchpad.scratchpads[i].empty(); fmgc.flightPlanController.updateAirports(fromto[0], fromto[1], 2); - setprop("/FMGC/internal/alt-selected", 0); + fmgc.FMGCInternal.altSelected = 0; #ref lat dms = getprop("/FMGC/flightplan[2]/wp[0]/lat"); degrees = int(dms); @@ -236,14 +250,14 @@ var initInputA = func(key, i) { setprop("MCDU[" ~ i ~ "]/page", "WINDCLB"); } else if (key == "R5") { if (scratchpad == "CLR") { - setprop("/FMGC/internal/tropo", 36090); - setprop("/FMGC/internal/tropo-set", 0); + fmgc.FMGCInternal.tropo = 36090; + fmgc.FMGCInternal.tropoSet = 0; mcdu_scratchpad.scratchpads[i].empty(); } else { var tropo = size(scratchpad); if (tropo == 5 and scratchpad <= 99990) { - setprop("FMGC/internal/tropo-set", 1); - setprop("FMGC/internal/tropo", scratchpad); + fmgc.FMGCInternal.tropo = scratchpad; + fmgc.FMGCInternal.tropoSet = 1; mcdu_scratchpad.scratchpads[i].empty(); } else { mcdu_message(i, "NOT ALLOWED"); @@ -251,11 +265,11 @@ var initInputA = func(key, i) { } } else if (key == "R6") { if (scratchpad == "CLR") { - setprop("/FMGC/internal/gndtemp-set", 0); + fmgc.FMGCInternal.gndTempSet = 0; mcdu_scratchpad.scratchpads[i].empty(); - } else if (int(scratchpad) != nil and getprop("/FMGC/status/phase") == 0 and size(scratchpad) >= 1 and size(scratchpad) <= 3 and scratchpad >= -99 and scratchpad <= 99) { - setprop("/FMGC/internal/gndtemp", scratchpad); - setprop("/FMGC/internal/gndtemp-set", 1); + } else if (int(scratchpad) != nil and fmgc.FMGCInternal.phase == 0 and size(scratchpad) >= 1 and size(scratchpad) <= 3 and scratchpad >= -99 and scratchpad <= 99) { + fmgc.FMGCInternal.gndTemp = scratchpad; + fmgc.FMGCInternal.gndTempSet = 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 0a3231a8..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 getprop("/FMGC/internal/tofrom-set")) { + 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/IRSINIT.nas b/Nasal/MCDU/IRSINIT.nas index 7ba66c6b..baabec0b 100644 --- a/Nasal/MCDU/IRSINIT.nas +++ b/Nasal/MCDU/IRSINIT.nas @@ -62,7 +62,7 @@ var initInputIRS = func(key, i) { mcdu_message(i, "NOT ALLOWED"); } } else if (key == "L1") { - if (getprop("FMGC/internal/tofrom-set")) { + if (fmgc.FMGCInternal.toFromSet) { setprop("FMGC/internal/align-ref-lat-edit", 1); setprop("FMGC/internal/align-ref-long-edit", 0); } else { @@ -73,7 +73,7 @@ var initInputIRS = func(key, i) { setprop("FMGC/internal/align-ref-long-edit", 0); setprop("MCDU[" ~ i ~ "]/page", "INITA"); } else if (key == "R1") { - if (getprop("FMGC/internal/tofrom-set")) { + if (fmgc.FMGCInternal.toFromSet) { setprop("FMGC/internal/align-ref-lat-edit", 0); setprop("FMGC/internal/align-ref-long-edit", 1); } else { @@ -82,7 +82,7 @@ var initInputIRS = func(key, i) { } else if (key == "R6") { setprop("FMGC/internal/align-ref-lat-edit", 0); setprop("FMGC/internal/align-ref-long-edit", 0); - if (getprop("FMGC/internal/tofrom-set") == 1 and getprop("systems/navigation/adr/any-adr-on") == 1) { + if (fmgc.FMGCInternal.toFromSet and getprop("systems/navigation/adr/any-adr-on") == 1) { if (getprop("FMGC/internal/align-set") == 0) { setprop("FMGC/internal/align-set", 1); } else { @@ -90,7 +90,7 @@ var initInputIRS = func(key, i) { setprop("FMGC/internal/align-set", 0); setprop("MCDU[" ~ i ~ "]/page", "INITA"); } - } else if (getprop("FMGC/internal/tofrom-set") == 0) { + } else if (!fmgc.FMGCInternal.toFromSet) { # setprop("MCDU[" ~ i ~ "]/scratchpad", "SELECT REFERENCE"); } else if (getprop("systems/navigation/adr/any-adr-on") == 0) { # setprop("MCDU[" ~ i ~ "]/scratchpad", "IRS NOT ALIGNED"); diff --git a/Nasal/MCDU/MCDU.nas b/Nasal/MCDU/MCDU.nas index 5bbbd8ed..aa6e21d5 100644 --- a/Nasal/MCDU/MCDU.nas +++ b/Nasal/MCDU/MCDU.nas @@ -50,22 +50,28 @@ var MCDU_reset = func(i) { setprop("/FMGC/internal/adf2freq-set", 0); # INT-A - setprop("MCDUC/flight-num", ""); - setprop("MCDUC/flight-num-set", 0); - setprop("/FMGC/internal/dep-arpt", ""); - setprop("/FMGC/internal/arr-arpt", ""); - setprop("/FMGC/internal/tofrom-set", 0); - setprop("/FMGC/internal/alt-airport", ""); - setprop("/FMGC/internal/alt-set", 0); - setprop("/FMGC/internal/cost-index", "0"); - setprop("/FMGC/internal/cost-index-set", 0); - setprop("/FMGC/internal/cruise-ft", 10000); - setprop("/FMGC/internal/cruise-fl", 100); - setprop("/FMGC/internal/cruise-lvl-set", 0); - setprop("/FMGC/internal/tropo", 36090); - setprop("/FMGC/internal/tropo-set", 0); - setprop("/FMGC/internal/cruise-temp", 15); - setprop("/FMGC/internal/cruise-temp-set", 0); + fmgc.FMGCInternal.altAirport = ""; + fmgc.FMGCInternal.altAirportSet = 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.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); @@ -82,7 +88,7 @@ var MCDU_reset = func(i) { setprop("/FMGC/internal/align3-done", 0); # ROUTE SELECTION - setprop("/FMGC/internal/alt-selected", 0); + fmgc.FMGCInternal.altSelected = 0; # INT-B setprop("/FMGC/internal/zfw", 0); @@ -131,7 +137,7 @@ var MCDU_reset = func(i) { setprop("/FMGC/internal/cg", 0); # PROG - setprop("/FMGC/internal/cruise-fl-prog", 100); + fmgc.FMGCInternal.crzProg = 100; # PERF @@ -606,7 +612,7 @@ var rskbutton = func(btn, i) { setprop("MCDU[" ~ i ~ "]/page", "WINDCLB"); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "WINDDES") { if (fmgc.flightPlanController.temporaryFlag[i]) { - if (getprop("/FMGC/internal/tofrom-set") and size(fmgc.windController.nav_indicies[i]) > 0) { + if (fmgc.FMGCInternal.toFromSet and size(fmgc.windController.nav_indicies[i]) > 0) { if (canvas_mcdu.myCRZWIND[i] != nil) { canvas_mcdu.myCRZWIND[i].del(); } @@ -620,7 +626,7 @@ var rskbutton = func(btn, i) { } } } else { - if (getprop("/FMGC/internal/tofrom-set") and size(fmgc.windController.nav_indicies[2]) > 0) { + if (fmgc.FMGCInternal.toFromSet and size(fmgc.windController.nav_indicies[2]) > 0) { if (canvas_mcdu.myCRZWIND[i] != nil) { canvas_mcdu.myCRZWIND[i].del(); } @@ -659,7 +665,7 @@ var rskbutton = func(btn, i) { initInputB("R5",i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "WINDCLB") { if (fmgc.flightPlanController.temporaryFlag[i]) { - if (getprop("/FMGC/internal/tofrom-set") and size(fmgc.windController.nav_indicies[i]) > 0) { + if (fmgc.FMGCInternal.toFromSet and size(fmgc.windController.nav_indicies[i]) > 0) { if (canvas_mcdu.myCRZWIND[i] != nil) { canvas_mcdu.myCRZWIND[i].del(); } @@ -673,7 +679,7 @@ var rskbutton = func(btn, i) { } } } else { - if (getprop("/FMGC/internal/tofrom-set") and size(fmgc.windController.nav_indicies[2]) > 0) { + if (fmgc.FMGCInternal.toFromSet and size(fmgc.windController.nav_indicies[2]) > 0) { if (canvas_mcdu.myCRZWIND[i] != nil) { canvas_mcdu.myCRZWIND[i].del(); } @@ -869,33 +875,33 @@ var pagebutton = func(btn, i) { if (btn == "radnav") { setprop("/MCDU[" ~ i ~ "]/page", "RADNAV"); } else if (btn == "prog") { - if (getprop("/FMGC/status/phase") == 0 or getprop("/FMGC/status/phase") == 1) { + if (fmgc.FMGCInternal.phase == 0 or fmgc.FMGCInternal.phase == 1) { setprop("MCDU[" ~ i ~ "]/page", "PROGTO"); - } else if (getprop("/FMGC/status/phase") == 2) { + } else if (fmgc.FMGCInternal.phase == 2) { setprop("MCDU[" ~ i ~ "]/page", "PROGCLB"); - } else if (getprop("/FMGC/status/phase") == 3) { + } else if (fmgc.FMGCInternal.phase == 3) { setprop("MCDU[" ~ i ~ "]/page", "PROGCRZ"); - } else if (getprop("/FMGC/status/phase") == 4 or getprop("/FMGC/status/phase") == 5 or getprop("/FMGC/status/phase") == 6) { + } else if (fmgc.FMGCInternal.phase == 4 or fmgc.FMGCInternal.phase == 5 or fmgc.FMGCInternal.phase == 6) { setprop("MCDU[" ~ i ~ "]/page", "PROGDES"); } } else if (btn == "perf") { - if (getprop("/FMGC/status/phase") == 0 or getprop("/FMGC/status/phase") == 1) { + if (fmgc.FMGCInternal.phase == 0 or fmgc.FMGCInternal.phase == 1) { setprop("MCDU[" ~ i ~ "]/page", "PERFTO"); - } else if (getprop("/FMGC/status/phase") == 2) { + } else if (fmgc.FMGCInternal.phase == 2) { setprop("MCDU[" ~ i ~ "]/page", "PERFCLB"); - } else if (getprop("/FMGC/status/phase") == 3) { + } else if (fmgc.FMGCInternal.phase == 3) { setprop("MCDU[" ~ i ~ "]/page", "PERFCRZ"); - } else if (getprop("/FMGC/status/phase") == 4) { + } else if (fmgc.FMGCInternal.phase == 4) { setprop("MCDU[" ~ i ~ "]/page", "PERFDES"); - } else if (getprop("/FMGC/status/phase") == 5) { + } else if (fmgc.FMGCInternal.phase == 5) { setprop("MCDU[" ~ i ~ "]/page", "PERFAPPR"); - } else if (getprop("/FMGC/status/phase") == 6) { + } else if (fmgc.FMGCInternal.phase == 6) { setprop("MCDU[" ~ i ~ "]/page", "PERFGA"); - } else if (getprop("/FMGC/status/phase") == 7) { + } else if (fmgc.FMGCInternal.phase == 7) { fmgc.reset_FMGC(); } } else if (btn == "init") { - if (getprop("/FMGC/status/phase") == 7) { + if (fmgc.FMGCInternal.phase == 7) { fmgc.reset_FMGC(); } setprop("/MCDU[" ~ i ~ "]/page", "INITA"); @@ -911,7 +917,7 @@ var pagebutton = func(btn, i) { canvas_mcdu.myFpln[i] = fplnPage.new(2, i); } if (btn == "airport") { - if (getprop("FMGC/status/phase") == 0 or getprop("FMGC/status/phase") == 1) { + if (fmgc.FMGCInternal.phase == 0 or fmgc.FMGCInternal.phase == 1) { canvas_mcdu.myFpln[i].scroll = 0; } else { if (fmgc.flightPlanController.temporaryFlag[i]) { diff --git a/Nasal/MCDU/PERFCLB.nas b/Nasal/MCDU/PERFCLB.nas index f57d1b7a..ee8d6536 100644 --- a/Nasal/MCDU/PERFCLB.nas +++ b/Nasal/MCDU/PERFCLB.nas @@ -6,16 +6,18 @@ var perfCLBInput = func(key, i) { var scratchpad = mcdu_scratchpad.scratchpads[i].scratchpad; if (key == "L2") { 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; + fmgc.FMGCNodes.costIndex.setValue(fmgc.FMGCInternal.costIndex); mcdu_scratchpad.scratchpads[i].empty(); } else { mcdu_message(i, "NOT ALLOWED"); @@ -25,17 +27,17 @@ var perfCLBInput = func(key, i) { } } } else if (key == "L5") { - if (getprop("/FMGC/status/phase") == 2) { + if (fmgc.FMGCInternal.phase == 2) { setprop("MCDU[" ~ i ~ "]/page", "PERFTO"); } else { mcdu_message(i, "NOT ALLOWED"); } } else if (key == "L6") { - if (getprop("/FMGC/status/phase") == 2) { + if (fmgc.FMGCInternal.phase == 2) { if (getprop("/FMGC/internal/activate-once") == 1) { if (getprop("/FMGC/internal/activate-twice") == 0) { setprop("/FMGC/internal/activate-twice", 1); - setprop("/FMGC/status/phase", 5); + fmgc.FMGCInternal.phase = 5; setprop("/FMGC/internal/decel", 1); setprop("MCDU[" ~ i ~ "]/page", "PERFAPPR"); } else { diff --git a/Nasal/MCDU/PERFCRZ.nas b/Nasal/MCDU/PERFCRZ.nas index b26af62c..5622cbb0 100644 --- a/Nasal/MCDU/PERFCRZ.nas +++ b/Nasal/MCDU/PERFCRZ.nas @@ -6,16 +6,18 @@ var perfCRZInput = func(key, i) { var scratchpad = mcdu_scratchpad.scratchpads[i].scratchpad; if (key == "L2") { 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; + fmgc.FMGCNodes.costIndex.setValue(fmgc.FMGCInternal.costIndex); mcdu_scratchpad.scratchpads[i].empty(); } else { mcdu_message(i, "NOT ALLOWED"); @@ -25,11 +27,11 @@ var perfCRZInput = func(key, i) { } } } else if (key == "L6") { - if (getprop("/FMGC/status/phase") == 3) { + if (fmgc.FMGCInternal.phase == 3) { if (getprop("/FMGC/internal/activate-once") == 1) { if (getprop("/FMGC/internal/activate-twice") == 0) { setprop("/FMGC/internal/activate-twice", 1); - setprop("/FMGC/status/phase", 5); + fmgc.FMGCInternal.phase = 5; setprop("/FMGC/internal/decel", 1); setprop("MCDU[" ~ i ~ "]/page", "PERFAPPR"); } else { diff --git a/Nasal/MCDU/PERFDES.nas b/Nasal/MCDU/PERFDES.nas index c3c5c611..608850d2 100644 --- a/Nasal/MCDU/PERFDES.nas +++ b/Nasal/MCDU/PERFDES.nas @@ -6,16 +6,18 @@ var perfDESInput = func(key, i) { var scratchpad = mcdu_scratchpad.scratchpads[i].scratchpad; if (key == "L2") { 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; + fmgc.FMGCNodes.costIndex.setValue(fmgc.FMGCInternal.costIndex); mcdu_scratchpad.scratchpads[i].empty(); } else { mcdu_message(i, "NOT ALLOWED"); @@ -25,11 +27,11 @@ var perfDESInput = func(key, i) { } } } else if (key == "L6") { - if (getprop("/FMGC/status/phase") == 4) { + if (fmgc.FMGCInternal.phase == 4) { if (getprop("/FMGC/internal/activate-once") == 1) { if (getprop("/FMGC/internal/activate-twice") == 0) { setprop("/FMGC/internal/activate-twice", 1); - setprop("/FMGC/status/phase", 5); + fmgc.FMGCInternal.phase = 5; setprop("/FMGC/internal/decel", 1); setprop("MCDU[" ~ i ~ "]/page", "PERFAPPR"); } else { diff --git a/Nasal/MCDU/PERFTO.nas b/Nasal/MCDU/PERFTO.nas index d3d1ba8d..4f647b14 100644 --- a/Nasal/MCDU/PERFTO.nas +++ b/Nasal/MCDU/PERFTO.nas @@ -6,7 +6,7 @@ var perfTOInput = func(key, i) { var scratchpad = mcdu_scratchpad.scratchpads[i].scratchpad; if (key == "L1") { - if (getprop("/FMGC/status/phase") != 1) { + if (fmgc.FMGCInternal.phase != 1) { if (scratchpad == "CLR") { fmgc.FMGCInternal.v1 = 0; fmgc.FMGCInternal.v1set = 0; @@ -35,7 +35,7 @@ var perfTOInput = func(key, i) { mcdu_message(i, "NOT ALLOWED"); } } else if (key == "L2") { - if (getprop("/FMGC/status/phase") != 1) { + if (fmgc.FMGCInternal.phase != 1) { if (scratchpad == "CLR") { fmgc.FMGCInternal.vr = 0; fmgc.FMGCInternal.vrset = 0; @@ -58,7 +58,7 @@ var perfTOInput = func(key, i) { mcdu_message(i, "NOT ALLOWED"); } } else if (key == "L3") { - if (getprop("/FMGC/status/phase") != 1) { + if (fmgc.FMGCInternal.phase != 1) { if (scratchpad == "CLR") { fmgc.FMGCInternal.v2 = 0; fmgc.FMGCInternal.v2set = 0; diff --git a/Nasal/MCDU/PROGCLB.nas b/Nasal/MCDU/PROGCLB.nas index db5fcb53..66770ddd 100644 --- a/Nasal/MCDU/PROGCLB.nas +++ b/Nasal/MCDU/PROGCLB.nas @@ -4,9 +4,9 @@ var progCLBInput = func(key, i) { var scratchpad = mcdu_scratchpad.scratchpads[i].scratchpad; if (key == "L1") { if (scratchpad == "CLR") { - setprop("/FMGC/internal/cruise-fl-prog", getprop("/FMGC/internal/cruise-fl")); - if (getprop("/FMGC/status/phase") == 5) { - setprop("/FMGC/status/phase", 3); + fmgc.FMGCInternal.crzProg = fmgc.FMGCInternal.crzFl; + if (fmgc.FMGCInternal.phase == 5) { + fmgc.FMGCInternal.phase = 3; setprop("/FMGC/internal/activate-once", 0); setprop("/FMGC/internal/activate-twice", 0); setprop("/FMGC/internal/decel", 0); @@ -14,11 +14,11 @@ var progCLBInput = func(key, i) { mcdu_scratchpad.scratchpads[i].empty(); } else if (int(scratchpad) != nil) { var crzs = size(scratchpad); - if (crzs >= 1 and crzs <= 3 and scratchpad > 0 and scratchpad <= 430 and altSet.getValue() <= scratchpad * 100) { - setprop("/FMGC/internal/cruise-fl-prog", scratchpad); + if (crzs >= 1 and crzs <= 3 and scratchpad > 0 and scratchpad <= 430 and fmgc.FMGCInternal.crzSet <= scratchpad * 100) { + fmgc.FMGCInternal.crzProg = scratchpad; mcdu_scratchpad.scratchpads[i].empty(); - if (getprop("/FMGC/status/phase") == 5) { - setprop("/FMGC/status/phase", 3); + if (fmgc.FMGCInternal.phase == 5) { + fmgc.FMGCInternal.phase = 3; setprop("/FMGC/internal/activate-once", 0); setprop("/FMGC/internal/activate-twice", 0); setprop("/FMGC/internal/decel", 0); diff --git a/Nasal/MCDU/PROGCRZ.nas b/Nasal/MCDU/PROGCRZ.nas index 38eccee2..7d188609 100644 --- a/Nasal/MCDU/PROGCRZ.nas +++ b/Nasal/MCDU/PROGCRZ.nas @@ -4,9 +4,9 @@ var progCRZInput = func(key, i) { var scratchpad = mcdu_scratchpad.scratchpads[i].scratchpad; if (key == "L1") { if (scratchpad == "CLR") { - setprop("/FMGC/internal/cruise-fl-prog", getprop("/FMGC/internal/cruise-fl")); - if (getprop("/FMGC/status/phase") == 5) { - setprop("/FMGC/status/phase", 3); + fmgc.FMGCInternal.crzProg = fmgc.FMGCInternal.crzFl; + if (fmgc.FMGCInternal.phase == 5) { + fmgc.FMGCInternal.phase = 3; setprop("/FMGC/internal/activate-once", 0); setprop("/FMGC/internal/activate-twice", 0); setprop("/FMGC/internal/decel", 0); @@ -14,11 +14,11 @@ var progCRZInput = func(key, i) { mcdu_scratchpad.scratchpads[i].empty(); } else if (int(scratchpad) != nil) { var crzs = size(scratchpad); - if (crzs >= 1 and crzs <= 3 and scratchpad > 0 and scratchpad <= 430 and altSet.getValue() <= scratchpad * 100) { - setprop("/FMGC/internal/cruise-fl-prog", scratchpad); + if (crzs >= 1 and crzs <= 3 and scratchpad > 0 and scratchpad <= 430 and fmgc.FMGCInternal.crzSet <= scratchpad * 100) { + fmgc.FMGCInternal.crzProg = scratchpad; mcdu_scratchpad.scratchpads[i].empty(); - if (getprop("/FMGC/status/phase") == 5) { - setprop("/FMGC/status/phase", 3); + if (fmgc.FMGCInternal.phase == 5) { + fmgc.FMGCInternal.phase = 3; setprop("/FMGC/internal/activate-once", 0); setprop("/FMGC/internal/activate-twice", 0); setprop("/FMGC/internal/decel", 0); diff --git a/Nasal/MCDU/PROGDES.nas b/Nasal/MCDU/PROGDES.nas index 69cbc55e..c915f35f 100644 --- a/Nasal/MCDU/PROGDES.nas +++ b/Nasal/MCDU/PROGDES.nas @@ -4,9 +4,9 @@ var progDESInput = func(key, i) { var scratchpad = mcdu_scratchpad.scratchpads[i].scratchpad; if (key == "L1") { if (scratchpad == "CLR") { - setprop("/FMGC/internal/cruise-fl-prog", getprop("/FMGC/internal/cruise-fl")); - if (getprop("/FMGC/status/phase") == 5 or getprop("/FMGC/status/phase") == 6) { - setprop("/FMGC/status/phase", 3); + fmgc.FMGCInternal.crzProg = fmgc.FMGCInternal.crzFl; + if (fmgc.FMGCInternal.phase == 5 or fmgc.FMGCInternal.phase == 6) { + fmgc.FMGCInternal.phase = 3; setprop("/FMGC/internal/activate-once", 0); setprop("/FMGC/internal/activate-twice", 0); setprop("/FMGC/internal/decel", 0); @@ -14,11 +14,11 @@ var progDESInput = func(key, i) { mcdu_scratchpad.scratchpads[i].empty(); } else if (int(scratchpad) != nil) { var crzs = size(scratchpad); - if (crzs >= 1 and crzs <= 3 and scratchpad > 0 and scratchpad <= 430 and altSet.getValue() <= scratchpad * 100) { - setprop("/FMGC/internal/cruise-fl-prog", scratchpad); + if (crzs >= 1 and crzs <= 3 and scratchpad > 0 and scratchpad <= 430 and fmgc.FMGCInternal.crzSet <= scratchpad * 100) { + fmgc.FMGCInternal.crzProg = scratchpad; mcdu_scratchpad.scratchpads[i].empty(); - if (getprop("/FMGC/status/phase") == 4 or getprop("/FMGC/status/phase") == 5 or getprop("/FMGC/status/phase") == 6) { - setprop("/FMGC/status/phase", 3); + if (fmgc.FMGCInternal.phase == 4 or fmgc.FMGCInternal.phase == 5 or fmgc.FMGCInternal.phase == 6) { + fmgc.FMGCInternal.phase = 3; setprop("/FMGC/internal/activate-once", 0); setprop("/FMGC/internal/activate-twice", 0); setprop("/FMGC/internal/decel", 0); diff --git a/Nasal/MCDU/PROGTO.nas b/Nasal/MCDU/PROGTO.nas index d3dfbd65..5e0f96d4 100644 --- a/Nasal/MCDU/PROGTO.nas +++ b/Nasal/MCDU/PROGTO.nas @@ -6,12 +6,12 @@ var progTOInput = func(key, i) { var scratchpad = mcdu_scratchpad.scratchpads[i].scratchpad; if (key == "L1") { if (scratchpad == "CLR") { - setprop("/FMGC/internal/cruise-fl-prog", getprop("/FMGC/internal/cruise-fl")); + fmgc.FMGCInternal.crzProg = fmgc.FMGCInternal.crzFl; mcdu_scratchpad.scratchpads[i].empty(); } else if (int(scratchpad) != nil) { var crzs = size(scratchpad); - if (crzs >= 1 and crzs <= 3 and scratchpad > 0 and scratchpad <= 430 and altSet.getValue() <= scratchpad * 100 and getprop("/FMGC/internal/cruise-lvl-set")) { - setprop("/FMGC/internal/cruise-fl-prog", scratchpad); + if (crzs >= 1 and crzs <= 3 and scratchpad > 0 and scratchpad <= 430 and fmgc.FMGCInternal.crzSet <= scratchpad * 100 and fmgc.FMGCInternal.crzSet) { + fmgc.FMGCInternal.crzProg = scratchpad; mcdu_scratchpad.scratchpads[i].empty(); } else { mcdu_message(i, "NOT ALLOWED"); diff --git a/Nasal/MCDU/VERTREV.nas b/Nasal/MCDU/VERTREV.nas index 86bd332b..3f73810e 100644 --- a/Nasal/MCDU/VERTREV.nas +++ b/Nasal/MCDU/VERTREV.nas @@ -126,7 +126,7 @@ var vertRev = { } }, updateR5: func() { - if (getprop("FMGC/internal/cruise-lvl-set") and (getprop("FMGC/status/phase") < 4 or getprop("FMGC/status/phase") == 7)) { + if (fmgc.FMGCInternal.crzSet and (fmgc.FMGCInternal.phase < 4 or fmgc.FMGCInternal.phase == 7)) { me.R5 = ["STEP ALTS ", nil, "wht"]; me.arrowsMatrix[1][4] = 1; } else { @@ -182,7 +182,7 @@ var vertRev = { }, }; -setlistener("FMGC/internal/cruise-lvl-set", func() { +var updateCrzLvlCallback = func () { if (canvas_mcdu.myVertRev[0] != nil) { canvas_mcdu.myVertRev[0].updateR5(); } @@ -190,9 +190,9 @@ setlistener("FMGC/internal/cruise-lvl-set", func() { if (canvas_mcdu.myVertRev[1] != nil) { canvas_mcdu.myVertRev[1].updateR5(); } -}, 0, 0); +}; -setlistener("FMGC/status/phase", func() { +var updatePhaseCallback = func() { if (canvas_mcdu.myVertRev[0] != nil) { canvas_mcdu.myVertRev[0].updateR5(); } @@ -200,4 +200,4 @@ setlistener("FMGC/status/phase", func() { if (canvas_mcdu.myVertRev[1] != nil) { canvas_mcdu.myVertRev[1].updateR5(); } -}, 0, 0); \ No newline at end of file +}; \ No newline at end of file