From d2305f3104eee0add31152f8633973b53c64564f Mon Sep 17 00:00:00 2001 From: legoboyvdlp R Date: Sun, 29 Dec 2019 21:37:52 +0000 Subject: [PATCH 01/51] Add Octal's FMGC back in, extend with LAT REV page --- A320-main.xml | 3 + Models/Instruments/MCDU/MCDU.nas | 440 ++- Models/Instruments/MCDU/res/mcdu.svg | 3296 +++++++++-------- Models/Instruments/ND/canvas/A3XX_ND.nas | 4 +- .../Instruments/ND/canvas/A3XX_ND_drivers.nas | 211 +- Models/Instruments/ND/canvas/ND_config.nas | 38 +- Models/Instruments/ND/canvas/helpers.nas | 274 +- Models/Instruments/ND/canvas/loaders.nas | 136 +- .../ND/canvas/map/ALT-profile.scontroller | 2 +- .../Instruments/ND/canvas/map/APS.scontroller | 2 +- .../Instruments/ND/canvas/map/APT.scontroller | 2 +- .../ND/canvas/map/DEBUG.lcontroller | 104 +- Models/Instruments/ND/canvas/map/DEBUG.symbol | 28 +- .../ND/canvas/map/DECEL.lcontroller | 42 +- .../ND/canvas/map/DECEL.scontroller | 2 +- Models/Instruments/ND/canvas/map/DECEL.symbol | 28 +- .../Instruments/ND/canvas/map/RTE.lcontroller | 18 +- .../Instruments/ND/canvas/map/RTE.scontroller | 2 +- .../ND/canvas/map/RWY-profile.symbol | 120 +- .../ND/canvas/map/SPD-profile.lcontroller | 64 +- .../ND/canvas/map/SPD-profile.scontroller | 2 +- .../ND/canvas/map/SPD-profile.symbol | 10 +- .../ND/canvas/map/VOR-airbus.lcontroller | 82 +- .../ND/canvas/map/VOR-airbus.symbol | 58 +- .../ND/canvas/map/WPT-airbus.lcontroller | 228 +- .../ND/canvas/map/WPT-airbus.symbol | 242 +- Models/Instruments/ND/canvas/style.nas | 42 +- Nasal/FMGC/FMGC-b.nas | 23 +- Nasal/FMGC/FMGC.nas | 21 +- Nasal/FMGC/flightplan.nas | 314 ++ Nasal/MCDU/F-PLN.nas | 536 +++ Nasal/MCDU/INITA.nas | 5 +- Nasal/MCDU/LATREV.nas | 98 + Nasal/MCDU/MCDU.nas | 161 +- Nasal/Sim/libraries.nas | 1 + Systems/fmgc-drivers.xml | 2 +- 36 files changed, 4202 insertions(+), 2439 deletions(-) create mode 100644 Nasal/FMGC/flightplan.nas create mode 100644 Nasal/MCDU/F-PLN.nas create mode 100644 Nasal/MCDU/LATREV.nas diff --git a/A320-main.xml b/A320-main.xml index 356ab950..912044b7 100644 --- a/A320-main.xml +++ b/A320-main.xml @@ -1870,11 +1870,13 @@ Aircraft/A320-family/Nasal/FMGC/FCU.nas + Aircraft/A320-family/Nasal/FMGC/flightplan.nas Aircraft/A320-family/Nasal/FMGC/FMGC.nas Aircraft/A320-family/Nasal/FMGC/FMGC-b.nas Aircraft/A320-family/Nasal/FMGC/FMGC-c.nas + Aircraft/A320-family/Nasal/MCDU/LATREV.nas Aircraft/A320-family/Nasal/MCDU/MCDU.nas Aircraft/A320-family/Nasal/MCDU/INITA.nas Aircraft/A320-family/Nasal/MCDU/INITB.nas @@ -1885,6 +1887,7 @@ Aircraft/A320-family/Nasal/MCDU/RADNAV.nas Aircraft/A320-family/Nasal/MCDU/DATA.nas Aircraft/A320-family/Nasal/MCDU/STATUS.nas + Aircraft/A320-family/Nasal/MCDU/F-PLN.nas Aircraft/A320-family/Models/Instruments/PFD/PFD.nas diff --git a/Models/Instruments/MCDU/MCDU.nas b/Models/Instruments/MCDU/MCDU.nas index daa64326..fa283693 100644 --- a/Models/Instruments/MCDU/MCDU.nas +++ b/Models/Instruments/MCDU/MCDU.nas @@ -6,11 +6,25 @@ var MCDU_1 = nil; var MCDU_2 = nil; var MCDU1_display = nil; var MCDU2_display = nil; +var myLatRev = nil; var default = "BoeingCDU-Large.ttf"; var symbol = "helvetica_medium.txf"; var normal = 70; var small = 56; var page = ""; +var fplnLineSize = 0; +var fplnl1 = ""; +var fplnl1s = ""; +var fplnl2 = ""; +var fplnl2s = ""; +var fplnl3 = ""; +var fplnl3s = ""; +var fplnl4 = ""; +var fplnl4s = ""; +var fplnl5 = ""; +var fplnl5s = ""; +var fplnl6 = ""; +var fplnl6s = ""; setprop("/MCDUC/colors/wht/r", 1); setprop("/MCDUC/colors/wht/g", 1); setprop("/MCDUC/colors/wht/b", 1); @@ -27,9 +41,13 @@ setprop("/MCDUC/colors/yel/r", 0.9333); setprop("/MCDUC/colors/yel/g", 0.9333); setprop("/MCDUC/colors/yel/b", 0.0000); +var WHITE = [1.0000,1.0000,1.0000]; +var GREEN = [0.0509,0.7529,0.2941]; +var BLUE = [0.0901,0.6039,0.7176]; +var AMBER = [0.7333,0.3803,0.0000]; +var YELLOW = [0.9333,0.9333,0.0000]; + # Fetch nodes: -var ac1 = props.globals.getNode("/systems/electrical/bus/ac-1", 1); -var ac2 = props.globals.getNode("/systems/electrical/bus/ac-2", 1); var mcdu1_lgt = props.globals.getNode("/controls/lighting/DU/mcdu1", 1); var mcdu2_lgt = props.globals.getNode("/controls/lighting/DU/mcdu2", 1); var acType = props.globals.getNode("/MCDUC/type", 1); @@ -92,6 +110,7 @@ var engOutAcc = props.globals.getNode("/FMGC/internal/eng-out-reduc", 1); var engOutAccSet = props.globals.getNode("/MCDUC/reducacc-set", 1); var transAlt = props.globals.getNode("/FMGC/internal/trans-alt", 1); var managedSpeed = props.globals.getNode("/it-autoflight/input/spd-managed", 1); +var TMPYActive = [props.globals.getNode("/FMGC/internal/tmpy-active[0]"), props.globals.getNode("/FMGC/internal/tmpy-active[1]")]; # Fetch nodes into vectors var pageProp = [props.globals.getNode("/MCDU[0]/page", 1), props.globals.getNode("/MCDU[1]/page", 1)]; @@ -150,16 +169,16 @@ var canvas_MCDU_base = { "Simple_L1_Arrow","Simple_L2_Arrow","Simple_L3_Arrow","Simple_L4_Arrow","Simple_L5_Arrow","Simple_L6_Arrow","Simple_R1","Simple_R2","Simple_R3","Simple_R4","Simple_R5","Simple_R6","Simple_R1S","Simple_R2S","Simple_R3S","Simple_R4S","Simple_R5S", "Simple_R6S","Simple_R1_Arrow","Simple_R2_Arrow","Simple_R3_Arrow","Simple_R4_Arrow","Simple_R5_Arrow","Simple_R6_Arrow","Simple_C1","Simple_C2","Simple_C3","Simple_C4","Simple_C5","Simple_C6","Simple_C1S","Simple_C2S","Simple_C3S","Simple_C4S", "Simple_C5S","Simple_C6S","INITA","INITA_CoRoute","INITA_FltNbr","INITA_CostIndex","INITA_CruiseFLTemp","INITA_FromTo","INITA_InitRequest","INITA_AlignIRS","INITB","INITB_ZFWCG","INITB_ZFW","INITB_ZFW_S","INITB_Block","PERFTO","PERFTO_V1","PERFTO_VR", - "PERFTO_V2","PERFTO_FE","PERFTO_SE","PERFTO_OE"]; + "PERFTO_V2","PERFTO_FE","PERFTO_SE","PERFTO_OE","FPLN","FPLN_From","FPLN_TMPY_group","FPLN_Callsign","FPLN_L1","FPLN_L2","FPLN_L3","FPLN_L4","FPLN_L5","FPLN_L6","FPLN_L1S","FPLN_L2S","FPLN_L3S","FPLN_L4S","FPLN_L5S","FPLN_L6S","FPLN_6_group"]; }, update: func() { - if (ac1.getValue() >= 110 and mcdu1_lgt.getValue() > 0.01) { + if (systems.ELEC.Bus.ac1.getValue() >= 110 and mcdu1_lgt.getValue() > 0.01) { MCDU_1.update(); MCDU_1.page.show(); } else { MCDU_1.page.hide(); } - if (ac2.getValue() >= 110 and mcdu2_lgt.getValue() > 0.01) { + if (systems.ELEC.Bus.ac2.getValue() >= 110 and mcdu2_lgt.getValue() > 0.01) { MCDU_2.update(); MCDU_2.page.show(); } else { @@ -168,10 +187,174 @@ var canvas_MCDU_base = { }, updateCommon: func(i) { page = pageProp[i].getValue(); - if (page == "MCDU") { + if (page == "F-PLNA" or page == "F-PLNB") { + if (!pageSwitch[i].getBoolValue()) { + me["Simple"].hide(); + me["Simple_Center"].hide(); + me["FPLN"].show(); + me["INITA"].hide(); + me["INITB"].hide(); + me["PERFTO"].hide(); + me["Simple_PageNum"].hide(); + me["ArrowLeft"].show(); + me["ArrowRight"].show(); + + pageSwitch[i].setBoolValue(1); + } + + if (flightNumSet.getValue()) { + me["FPLN_Callsign"].setText(flightNum.getValue()); + me["FPLN_Callsign"].show(); + } else { + me["FPLN_Callsign"].hide(); + } + + fplnLineSize = size(mcdu.FPLNLines[i].output); + + if (fplnLineSize >= 1) { + fplnl1 = mcdu.FPLNLines[i].output[0].getText(); + if (fplnl1 != "") { + me["FPLN_L1"].setColor(mcdu.FPLNLines[i].output[0].getColor(i)); + me["FPLN_L1"].setText(fplnl1); + me["FPLN_L1"].show(); + } else { + me["FPLN_L1"].hide(); + } + fplnl1s = mcdu.FPLNLines[i].output[0].getSubText(i); + if (fplnl1s != "") { + me["FPLN_L1S"].setText(fplnl1s); + me["FPLN_L1S"].show(); + } else { + me["FPLN_L1S"].hide(); + } + } else { + me["FPLN_L1"].hide(); + me["FPLN_L1S"].hide(); + } + + if (fplnLineSize >= 2) { + fplnl2 = mcdu.FPLNLines[i].output[1].getText(); + if (fplnl2 != "") { + me["FPLN_L2"].setColor(mcdu.FPLNLines[i].output[1].getColor(i)); + me["FPLN_L2"].setText(fplnl2); + me["FPLN_L2"].show(); + } else { + me["FPLN_L2"].hide(); + } + fplnl2s = mcdu.FPLNLines[i].output[1].getSubText(i); + if (fplnl2s != "") { + me["FPLN_L2S"].setText(fplnl2s); + me["FPLN_L2S"].show(); + } else { + me["FPLN_L2S"].hide(); + } + } else { + me["FPLN_L2"].hide(); + me["FPLN_L2S"].hide(); + } + + if (fplnLineSize >= 3) { + fplnl3 = mcdu.FPLNLines[i].output[2].getText(); + if (fplnl3 != "") { + me["FPLN_L3"].setColor(mcdu.FPLNLines[i].output[2].getColor(i)); + me["FPLN_L3"].setText(fplnl3); + me["FPLN_L3"].show(); + } else { + me["FPLN_L3"].hide(); + } + fplnl3s = mcdu.FPLNLines[i].output[2].getSubText(i); + if (fplnl3s != "") { + me["FPLN_L3S"].setText(fplnl3s); + me["FPLN_L3S"].show(); + } else { + me["FPLN_L3S"].hide(); + } + } else { + me["FPLN_L3"].hide(); + me["FPLN_L3S"].hide(); + } + + if (fplnLineSize >= 4) { + fplnl4 = mcdu.FPLNLines[i].output[3].getText(); + if (fplnl4 != "") { + me["FPLN_L4"].setColor(mcdu.FPLNLines[i].output[3].getColor(i)); + me["FPLN_L4"].setText(fplnl4); + me["FPLN_L4"].show(); + } else { + me["FPLN_L4"].hide(); + } + fplnl4s = mcdu.FPLNLines[i].output[3].getSubText(i); + if (fplnl4s != "") { + me["FPLN_L4S"].setText(fplnl4s); + me["FPLN_L4S"].show(); + } else { + me["FPLN_L4S"].hide(); + } + } else { + me["FPLN_L4"].hide(); + me["FPLN_L4S"].hide(); + } + + if (fplnLineSize >= 5) { + fplnl5 = mcdu.FPLNLines[i].output[4].getText(); + if (fplnl5 != "") { + me["FPLN_L5"].setColor(mcdu.FPLNLines[i].output[4].getColor(i)); + me["FPLN_L5"].setText(fplnl5); + me["FPLN_L5"].show(); + } else { + me["FPLN_L5"].hide(); + } + fplnl5s = mcdu.FPLNLines[i].output[4].getSubText(i); + if (fplnl5s != "") { + me["FPLN_L5S"].setText(fplnl5s); + me["FPLN_L5S"].show(); + } else { + me["FPLN_L5S"].hide(); + } + } else { + me["FPLN_L5"].hide(); + me["FPLN_L5S"].hide(); + } + + if (fplnLineSize >= 6) { + fplnl6 = mcdu.FPLNLines[i].output[5].getText(); + if (fplnl6 != "") { + me["FPLN_L6"].setColor(mcdu.FPLNLines[i].output[5].getColor(i)); + me["FPLN_L6"].setText(fplnl6); + me["FPLN_L6"].show(); + } else { + me["FPLN_L6"].hide(); + } + fplnl6s = mcdu.FPLNLines[i].output[5].getSubText(i); + if (fplnl6s != "") { + me["FPLN_L6S"].setText(fplnl6s); + me["FPLN_L6S"].show(); + } else { + me["FPLN_L6S"].hide(); + } + } else { + me["FPLN_L6"].hide(); + me["FPLN_L6S"].hide(); + } + + if (mcdu.FPLNLines[i].index == 0) { + me["FPLN_From"].show(); + } else { + me["FPLN_From"].hide(); + } + + if (TMPYActive[i].getBoolValue()) { + me["FPLN_TMPY_group"].show(); + me["FPLN_6_group"].hide(); + } else { + me["FPLN_TMPY_group"].hide(); + me["FPLN_6_group"].show(); + } + } elsif (page == "MCDU") { if (!pageSwitch[i].getBoolValue()) { me["Simple"].show(); me["Simple_Center"].hide(); + me["FPLN"].hide(); me["INITA"].hide(); me["INITB"].hide(); me["PERFTO"].hide(); @@ -253,6 +436,7 @@ var canvas_MCDU_base = { if (!pageSwitch[i].getBoolValue()) { me["Simple"].show(); me["Simple_Center"].hide(); + me["FPLN"].hide(); me["INITA"].hide(); me["INITB"].hide(); me["PERFTO"].hide(); @@ -334,6 +518,7 @@ var canvas_MCDU_base = { if (!pageSwitch[i].getBoolValue()) { me["Simple"].show(); me["Simple_Center"].hide(); + me["FPLN"].hide(); me["INITA"].hide(); me["INITB"].hide(); me["PERFTO"].hide(); @@ -413,6 +598,7 @@ var canvas_MCDU_base = { if (!pageSwitch[i].getBoolValue()) { me["Simple"].show(); me["Simple_Center"].hide(); + me["FPLN"].hide(); me["INITA"].hide(); me["INITB"].hide(); me["PERFTO"].hide(); @@ -497,6 +683,7 @@ var canvas_MCDU_base = { if (!pageSwitch[i].getBoolValue()) { me["Simple"].show(); me["Simple_Center"].show(); + me["FPLN"].hide(); me["INITA"].hide(); me["INITB"].hide(); me["PERFTO"].hide(); @@ -593,6 +780,7 @@ var canvas_MCDU_base = { if (!pageSwitch[i].getBoolValue()) { me["Simple"].show(); me["Simple_Center"].hide(); + me["FPLN"].hide(); me["INITA"].hide(); me["INITB"].hide(); me["PERFTO"].hide(); @@ -731,6 +919,7 @@ var canvas_MCDU_base = { if (!pageSwitch[i].getBoolValue()) { me["Simple"].show(); me["Simple_Center"].hide(); + me["FPLN"].hide(); me["INITA"].show(); me["INITB"].hide(); me["PERFTO"].hide(); @@ -885,6 +1074,7 @@ var canvas_MCDU_base = { if (!pageSwitch[i].getBoolValue()) { me["Simple"].show(); me["Simple_Center"].show(); + me["FPLN"].hide(); me["INITA"].hide(); me["INITB"].show(); me["PERFTO"].hide(); @@ -1014,6 +1204,7 @@ var canvas_MCDU_base = { if (!pageSwitch[i].getBoolValue()) { me["Simple"].show(); me["Simple_Center"].show(); + me["FPLN"].hide(); me["INITA"].hide(); me["INITB"].hide(); me["PERFTO"].hide(); @@ -1125,6 +1316,7 @@ var canvas_MCDU_base = { if (!pageSwitch[i].getBoolValue()) { me["Simple"].show(); me["Simple_Center"].show(); + me["FPLN"].hide(); me["INITA"].hide(); me["INITB"].hide(); me["PERFTO"].show(); @@ -1282,6 +1474,7 @@ var canvas_MCDU_base = { if (!pageSwitch[i].getBoolValue()) { me["Simple"].show(); me["Simple_Center"].show(); + me["FPLN"].hide(); me["INITA"].hide(); me["INITB"].hide(); me["PERFTO"].hide(); @@ -1399,9 +1592,244 @@ var canvas_MCDU_base = { me["Simple_C1"].setText("--- "); me["Simple_C5"].setText(" -350"); me["Simple_C1S"].setText("TIME "); + } elsif (page == "LATREV") { + if (!pageSwitch[i].getBoolValue()) { + me["Simple"].show(); + me["Simple_Center"].hide(); + me["FPLN"].hide(); + me["INITA"].hide(); + me["INITB"].hide(); + me["PERFTO"].hide(); + me["Simple_PageNum"].setText("X/X"); + me["Simple_PageNum"].hide(); + me["ArrowLeft"].hide(); + me["ArrowRight"].hide(); + + me.fontLeft(default, default, default, default, default, default); + me.fontLeftS(default, default, default, default, default, default); + me.fontRight(default, default, default, default, default, default); + me.fontRightS(default, default, default, default, default, default); + + me.fontSizeLeft(normal, normal, normal, normal, normal, normal); + me.fontSizeRight(normal, normal, normal, normal, normal, normal); + + me.colorLeftS("wht", "wht", "wht", "wht", "wht", "wht"); + me.colorLeftArrow("wht", "wht", "wht", "wht", "wht", "wht"); + me.colorRightS("wht", "wht", "wht", "wht", "wht", "wht"); + me.colorRightArrow("wht", "wht", "wht", "wht", "wht", "wht"); + + + if (myLatRev != nil) { + me["Simple_Title"].setText(sprintf("%s", myLatRev.title[0] ~ myLatRev.title[1] ~ myLatRev.title[2])); + + forindex (var matrixArrow; myLatRev.arrowsMatrix) { + if (matrixArrow == 0) { + var sign = "L"; + } else { + var sign = "R"; + } + forindex (var item; myLatRev.arrowsMatrix[matrixArrow]) { + if (myLatRev.arrowsMatrix[matrixArrow][item] == 1) { + me["Simple_" ~ sign ~ (item + 1) ~ "_Arrow"].show(); + } else { + me["Simple_" ~ sign ~ (item + 1) ~ "_Arrow"].hide(); + } + } + } + + forindex (var matrixFont; myLatRev.fontMatrix) { + if (matrixFont == 0) { + var sign = "L"; + } else { + var sign = "R"; + } + forindex (var item; myLatRev.fontMatrix[matrixFont]) { + if (myLatRev.fontMatrix[matrixFont][item] == 1) { + me["Simple_" ~ sign ~ (item + 1)].setFont(symbol); + me["Simple_" ~ sign ~ (item + 1)].setFontSize(small); + } else { + me["Simple_" ~ sign ~ (item + 1)].setFont(default); + me["Simple_" ~ sign ~ (item + 1)].setFontSize(normal); + } + } + } + + if (myLatRev.L1[0] == nil) { + me["Simple_L1"].hide(); + me["Simple_L1S"].hide(); + } else { + me["Simple_L1"].show(); + me["Simple_L1"].setText(myLatRev.L1[0]); + if (myLatRev.L1[1] != nil) { + me["Simple_L1S"].show(); + me["Simple_L1S"].setText(myLatRev.L1[1]); + } else { + me["Simple_L1S"].hide(); + } + } + + if (myLatRev.L2[0] == nil) { + me["Simple_L2"].hide(); + me["Simple_L2S"].hide(); + } else { + me["Simple_L2"].show(); + me["Simple_L2"].setText(myLatRev.L2[0]); + if (myLatRev.L2[1] != nil) { + me["Simple_L2S"].show(); + me["Simple_L2S"].setText(myLatRev.L2[1]); + } else { + me["Simple_L2S"].hide(); + } + } + + if (myLatRev.L3[0] == nil) { + me["Simple_L3"].hide(); + me["Simple_L3S"].hide(); + } else { + me["Simple_L3"].show(); + me["Simple_L3"].setText(myLatRev.L3[0]); + if (myLatRev.L3[1] != nil) { + me["Simple_L3S"].show(); + me["Simple_L3S"].setText(myLatRev.L3[1]); + } else { + me["Simple_L3S"].hide(); + } + } + + if (myLatRev.L4[0] == nil) { + me["Simple_L4"].hide(); + me["Simple_L4S"].hide(); + } else { + me["Simple_L4"].show(); + me["Simple_L4"].setText(myLatRev.L4[0]); + if (myLatRev.L4[1] != nil) { + me["Simple_L4S"].show(); + me["Simple_L4S"].setText(myLatRev.L4[1]); + } else { + me["Simple_L4S"].hide(); + } + } + + if (myLatRev.L5[0] == nil) { + me["Simple_L5"].hide(); + me["Simple_L5S"].hide(); + } else { + me["Simple_L5"].show(); + me["Simple_L5"].setText(myLatRev.L5[0]); + if (myLatRev.L5[1] != nil) { + me["Simple_L5S"].show(); + me["Simple_L5S"].setText(myLatRev.L5[1]); + } else { + me["Simple_L5S"].hide(); + } + } + + if (myLatRev.L6[0] == nil) { + me["Simple_L6"].hide(); + me["Simple_L6S"].hide(); + } else { + me["Simple_L6"].show(); + me["Simple_L6"].setText(myLatRev.L6[0]); + if (myLatRev.L6[1] != nil) { + me["Simple_L6S"].show(); + me["Simple_L6S"].setText(myLatRev.L6[1]); + } else { + me["Simple_L6S"].hide(); + } + } + me.colorLeft(myLatRev.L1[2],myLatRev.L2[2],myLatRev.L3[2],myLatRev.L4[2],myLatRev.L5[2],myLatRev.L6[2]); + + if (myLatRev.R1[0] == nil) { + me["Simple_R1"].hide(); + me["Simple_R1S"].hide(); + } else { + me["Simple_R1"].show(); + me["Simple_R1"].setText(myLatRev.R1[0]); + if (myLatRev.R1[1] != nil) { + me["Simple_R1S"].show(); + me["Simple_R1S"].setText(myLatRev.R1[1]); + } else { + me["Simple_R1S"].hide(); + } + } + + if (myLatRev.R2[0] == nil) { + me["Simple_R2"].hide(); + me["Simple_R2S"].hide(); + } else { + me["Simple_R2"].show(); + me["Simple_R2"].setText(myLatRev.R2[0]); + if (myLatRev.R2[1] != nil) { + me["Simple_R2S"].show(); + me["Simple_R2S"].setText(myLatRev.R2[1]); + } else { + me["Simple_R2S"].hide(); + } + } + + if (myLatRev.R3[0] == nil) { + me["Simple_R3"].hide(); + me["Simple_R3S"].hide(); + } else { + me["Simple_R3"].show(); + me["Simple_R3"].setText(myLatRev.R3[0]); + if (myLatRev.R3[1] != nil) { + me["Simple_R3S"].show(); + me["Simple_R3S"].setText(myLatRev.R3[1]); + } else { + me["Simple_R3S"].hide(); + } + } + + if (myLatRev.R4[0] == nil) { + me["Simple_R4"].hide(); + me["Simple_R4S"].hide(); + } else { + me["Simple_R4"].show(); + me["Simple_R4"].setText(myLatRev.R4[0]); + if (myLatRev.R4[1] != nil) { + me["Simple_R4S"].show(); + me["Simple_R4S"].setText(myLatRev.R4[1]); + } else { + me["Simple_R4S"].hide(); + } + } + + if (myLatRev.R5[0] == nil) { + me["Simple_R5"].hide(); + me["Simple_R5S"].hide(); + } else { + me["Simple_R5"].show(); + me["Simple_R5"].setText(myLatRev.R5[0]); + if (myLatRev.R5[1] != nil) { + me["Simple_R5S"].show(); + me["Simple_R5S"].setText(myLatRev.R5[1]); + } else { + me["Simple_R5S"].hide(); + } + } + + if (myLatRev.R6[0] == nil) { + me["Simple_R6"].hide(); + me["Simple_R6S"].hide(); + } else { + me["Simple_R6"].show(); + me["Simple_R6"].setText(myLatRev.R6[0]); + if (myLatRev.R6[1] != nil) { + me["Simple_R6S"].show(); + me["Simple_R6S"].setText(myLatRev.R6[1]); + } else { + me["Simple_R6S"].hide(); + } + } + me.colorRight(myLatRev.R1[2],myLatRev.R2[2],myLatRev.R3[2],myLatRev.R4[2],myLatRev.R5[2],myLatRev.R6[2]); + } + pageSwitch[i].setBoolValue(1); + } } else { if (!pageSwitch[i].getBoolValue()) { me["Simple"].hide(); + me["FPLN"].hide(); me["INITA"].hide(); me["INITB"].hide(); me["PERFTO"].hide(); diff --git a/Models/Instruments/MCDU/res/mcdu.svg b/Models/Instruments/MCDU/res/mcdu.svg index 6895e780..f45606fc 100644 --- a/Models/Instruments/MCDU/res/mcdu.svg +++ b/Models/Instruments/MCDU/res/mcdu.svg @@ -14,6 +14,33 @@ id="svg2" inkscape:version="0.91 r13725" sodipodi:docname="mcdu.svg"> + + + @@ -28,1455 +55,1454 @@ - - - SCRATCHPAD + x="20.138426" + y="836.87567" + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:70px;font-family:BoeingCDULarge;-inkscape-font-specification:BoeingCDULarge;text-align:start;text-anchor:start;fill:#ffffff;fill-opacity:1;">SCRATCHPAD + id="ArrowLeft"> + inkscape:connector-curvature="0" + sodipodi:nodetypes="cc" /> - - - - - - - TEXT - TEXT - TEXT - TEXT - TEXT - TEXT - TEXT - TEXT - TEXT - TEXT - TEXT - TEXT - - TITLE - X/X - - - - - TEXT - - - - - TEXT - - - - - TEXT - - - - - TEXT - - - - - TEXT - - - - - TEXT - - - - - TEXT - TEXT - TEXT - TEXT - TEXT - TEXT - TEXT - - - - - TEXT - - - - - TEXT - - - - - TEXT - - - - - TEXT - - - - - TEXT - - - - - TEXT - TEXT - TEXT - TEXT - TEXT - TEXT + id="ArrowRight" + inkscape:label="#g4241" + transform="matrix(-1,0,0,1,1911.9173,-0.2)"> + + + + inkscape:label="Simple" + id="Simple" + inkscape:groupmode="layer"> + TEXT + TEXT + TEXT + TEXT + TEXT + TEXT + TEXT + TEXT + TEXT + TEXT + TEXT + TEXT + + TITLE + X/X + + + + + TEXT + + transform="matrix(1.0000018,0,0,0.99998906,-895.98862,118.48532)"> + + + TEXT + + + + + TEXT + + + + + TEXT + + + + + TEXT + + + + + TEXT + + + + + TEXT + TEXT + TEXT + TEXT + TEXT + TEXT + TEXT + + + + + TEXT + + + + + TEXT + + + + + TEXT + + + + + TEXT + + + + + TEXT + + + + + TEXT + TEXT + TEXT + TEXT + TEXT + TEXT + + + + + + + + + + + / + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + / + + + + / + + . + / + + + + + + + + + + + + + . + + + . + + + + + + + + + - - - - - - / - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - / - - - - / - - . - / - - - - - - - - - - - - - . - - - . - - - - - - - - - - - + + + + + + - - - - - - + transform="translate(-833.84951,236.72)"> + F - S + x="309.12155" + y="187.10254" + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:70px;font-family:BoeingCDULarge;-inkscape-font-specification:BoeingCDULarge;text-align:start;text-anchor:start;fill:#ffffff;fill-opacity:1">F O + id="tspan4395" + sodipodi:role="line">S = + id="tspan4399" + x="307.8522" + y="422.15305" + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:70px;font-family:BoeingCDULarge;-inkscape-font-specification:BoeingCDULarge;text-align:start;text-anchor:start;fill:#ffffff;fill-opacity:1">O = = + = + + + FROM + CALLSIG + TEXT + TEXT + TEXT + TEXT + TEXT + TEXT + TEXT + TEXT + TEXT + TEXT + + TEXT + TEXT + + + TMPY + + ERASE + TMPY + + + + + + + + TMPY + INSERT + + + + + + + + diff --git a/Models/Instruments/ND/canvas/A3XX_ND.nas b/Models/Instruments/ND/canvas/A3XX_ND.nas index ab682866..4d82cdbb 100644 --- a/Models/Instruments/ND/canvas/A3XX_ND.nas +++ b/Models/Instruments/ND/canvas/A3XX_ND.nas @@ -5,8 +5,8 @@ # Copyright (c) 2019 Joshua Davidson (Octal450) var get_local_path = func(file){ - var aircraft_dir = split("/", getprop("/sim/aircraft-dir"))[-1]; - return "Aircraft/" ~ aircraft_dir ~ "/Models/Instruments/ND/canvas/"~ file; + var aircraft_dir = split("/", getprop("/sim/aircraft-dir"))[-1]; + return "Aircraft/" ~ aircraft_dir ~ "/Models/Instruments/ND/canvas/"~ file; }; var version = getprop("sim/version/flightgear"); diff --git a/Models/Instruments/ND/canvas/A3XX_ND_drivers.nas b/Models/Instruments/ND/canvas/A3XX_ND_drivers.nas index eca43a4e..baf7179b 100644 --- a/Models/Instruments/ND/canvas/A3XX_ND_drivers.nas +++ b/Models/Instruments/ND/canvas/A3XX_ND_drivers.nas @@ -5,107 +5,118 @@ # Copyright (c) 2019 Joshua Davidson (Octal450) var A3XXRouteDriver = { - new: func(){ - var m = { - parents: [A3XXRouteDriver], - }; - m.init(); - return m; - }, - init: func(){ - me.update(); - }, - update: func(){ - me.flightplan = flightplan(); - }, - getNumberOfFlightPlans: func(){1}, - getFlightPlanType: func(fpNum){"current"}, - getFlightPlan: func(fpNum){me.flightplan}, - getPlanSize: func(fpNum){me.flightplan.getPlanSize()}, - getWP: func(fpNum, idx){me.flightplan.getWP(idx)}, - getPlanModeWP: func(plan_wp_idx){me.flightplan.getWP(plan_wp_idx)}, - hasDiscontinuity: func(fpNum, wptID){0}, - getListeners: func(){[]}, - shouldUpdate: func 1 + new: func(){ + var m = { + parents: [A3XXRouteDriver], + }; + m.init(); + return m; + }, + init: func(){ + me.update(); + }, + update: func(){ + me.flightplan = fmgc.fp[2]; + }, + getNumberOfFlightPlans: func(){1}, + getFlightPlanType: func(fpNum){"current"}, + getFlightPlan: func(fpNum){me.flightplan}, + getPlanSize: func(fpNum){me.flightplan.getPlanSize()}, + getWP: func(fpNum, idx){me.flightplan.getWP(idx)}, + getPlanModeWP: func(plan_wp_idx){me.flightplan.getWP(plan_wp_idx)}, + hasDiscontinuity: func(fpNum, wptID){0}, + triggerSignal: func(signal){ + setprop(me.signalPath(signal),1); + setprop(me.signalPath(signal),0); + }, + signalPath: func(signal){ + "autopilot/route-manager/signals/rd-"~ signal; + }, + getListeners: func(){[ + me.signalPath("fp-added"), + me.signalPath("fp-removed") + ]}, + shouldUpdate: func 1 }; var MultiA3XXRouteDriver = { - parents: [A3XXRouteDriver], - new: func(){ - var m = { - parents: [MultiA3XXRouteDriver], - _flightplans: [], - currentFlightPlan: 0 - }; - m.init(); - return m; - }, - addFlightPlan: func(type, plan){ - append(me._flightplans, { - type: type, - flightplan: plan - }); - }, - removeFlightPlanAtIndex: func(idx){ - var sz = size(me._flightplans); - if(idx < sz){ - if(sz == 1) - me._flightplans = []; - elsif(sz == 2 and idx == 0) - me._flightplans = [me._flightplans[1]]; - elsif(sz == 2 and idx == 1) - pop(me._flightplans); - else { - var subv_l = subvec(me._flightplans, 0, idx); - var subv_r = subvec(me._flightplans, idx + 1); - me._flightplans = subv_l ~ subv_r; - } - } - me.triggerSignal("fp-added"); - }, - removeFlightPlanOfType: func(type){ - var new_vec = []; - foreach(var fp; me._flightplans){ - if(fp["type"] != type) - append(new_vec, fp); - } - me._flightplans = new_vec; - me.triggerSignal("fp-removed"); - }, - getNumberOfFlightPlans: func(){ - size(me._flightplans); - }, - getFlightPlanType: func(fpNum){ - if(fpNum >= size(me._flightplans)) return nil; - var fp = me._flightplans[fpNum]; - return fp.type; - }, - getFlightPlan: func(fpNum){ - if(fpNum >= size(me._flightplans)) return nil; - return me._flightplans[fpNum]; - }, - getPlanSize: func(fpNum){ - if(fpNum >= size(me._flightplans)) return 0; - return me._flightplans[fpNum].getPlanSize(); - }, - getWP: func(fpNum, idx){ - if(fpNum >= size(me._flightplans)) return nil; - var fp = me._flightplans[fpNum].getPlanSize(); - return fp.getWP(idx); - }, - getPlanModeWP: func(idx){ - if(me.currentFlightPlan >= size(me._flightplans)) return nil; - var fp = me._flightplans[me.currentFlightPlan]; - return fp.getWP(idx); - }, - triggerSignal: func(signal){ - setprop(me.signalPath(signal)); - }, - signalPath: func(signal){ - "autopilot/route-manager/signals/rd-"~ signal; - }, - getListeners: func(){[ - me.getSignal("fp-added"), - me.getSignal("fp-removed") - ]} + parents: [A3XXRouteDriver], + new: func(){ + var m = { + parents: [MultiA3XXRouteDriver], + _flightplans: [], + currentFlightPlan: 0 + }; + m.init(); + return m; + }, + addFlightPlan: func(type, plan){ + append(me._flightplans, { + type: type, + flightplan: plan + }); + }, + removeFlightPlanAtIndex: func(idx){ + var sz = size(me._flightplans); + if(idx < sz){ + if(sz == 1) + me._flightplans = []; + elsif(sz == 2 and idx == 0) + me._flightplans = [me._flightplans[1]]; + elsif(sz == 2 and idx == 1) + pop(me._flightplans); + else { + var subv_l = subvec(me._flightplans, 0, idx); + var subv_r = subvec(me._flightplans, idx + 1); + me._flightplans = subv_l ~ subv_r; + } + } + me.triggerSignal("fp-added"); + }, + removeFlightPlanOfType: func(type){ + var new_vec = []; + foreach(var fp; me._flightplans){ + if(fp["type"] != type) + append(new_vec, fp); + } + me._flightplans = new_vec; + me.triggerSignal("fp-removed"); + }, + getNumberOfFlightPlans: func(){ + size(me._flightplans); + }, + getFlightPlanType: func(fpNum){ + if(fpNum >= size(me._flightplans)) return nil; + var fp = me._flightplans[fpNum]; + return fp.type; + }, + getFlightPlan: func(fpNum){ + if(fpNum >= size(me._flightplans)) return nil; + return me._flightplans[fpNum]; + }, + getPlanSize: func(fpNum){ + if(fpNum >= size(me._flightplans)) return 0; + return me._flightplans[fpNum].getPlanSize(); + }, + getWP: func(fpNum, idx){ + if(fpNum >= size(me._flightplans)) return nil; + var fp = me._flightplans[fpNum].getPlanSize(); + return fp.getWP(idx); + }, + getPlanModeWP: func(idx){ + if(me.currentFlightPlan >= size(me._flightplans)) return nil; + var fp = me._flightplans[me.currentFlightPlan]; + return fp.getWP(idx); + }, + triggerSignal: func(signal){ + setprop(me.signalPath(signal), 1); + setprop(me.signalPath(signal), 0); + }, + signalPath: func(signal){ + "autopilot/route-manager/signals/rd-"~ signal; + }, + getListeners: func(){[ + me.getSignal("fp-added"), + me.getSignal("fp-removed") + ]} }; diff --git a/Models/Instruments/ND/canvas/ND_config.nas b/Models/Instruments/ND/canvas/ND_config.nas index ef122e70..af7281f8 100644 --- a/Models/Instruments/ND/canvas/ND_config.nas +++ b/Models/Instruments/ND/canvas/ND_config.nas @@ -5,23 +5,23 @@ # Copyright (c) 2019 Joshua Davidson (Octal450) canvas.NDConfig = { - properties: { - des_apt: "/autopilot/route-manager/destination/airport", - dep_apt: "/autopilot/route-manager/departure/airport", - des_rwy: "/autopilot/route-manager/destination/runway", - dep_rwy: "/autopilot/route-manager/departure/runway", - fplan_active: "autopilot/route-manager/active", - athr: "/it-autoflight/output/athr", - cur_wp: "/autopilot/route-manager/current-wp", - vnav_node: "/autopilot/route-manager/vnav/", - spd_node: "/autopilot/route-manager/spd/", - holding: "/flight-management/hold", - holding_points: "/flight-management/hold/points", - adf1_frq: "instrumentation/adf[0]/frequencies/selected-khz", - adf2_frq: "instrumentation/adf[1]/frequencies/selected-khz", - nav1_frq: "instrumentation/nav[0]/frequencies/selected-mhz", - nav2_frq: "instrumentation/nav[1]/frequencies/selected-mhz", - lat_ctrl: "/it-autoflight/output/lat", - ver_ctrl: "/it-autoflight/output/vert", - } + properties: { + des_apt: "/autopilot/route-manager/destination/airport", + dep_apt: "/autopilot/route-manager/departure/airport", + des_rwy: "/autopilot/route-manager/destination/runway", + dep_rwy: "/autopilot/route-manager/departure/runway", + fplan_active: "autopilot/route-manager/active", + athr: "/it-autoflight/output/athr", + cur_wp: "/autopilot/route-manager/current-wp", + vnav_node: "/autopilot/route-manager/vnav/", + spd_node: "/autopilot/route-manager/spd/", + holding: "/flight-management/hold", + holding_points: "/flight-management/hold/points", + adf1_frq: "instrumentation/adf[0]/frequencies/selected-khz", + adf2_frq: "instrumentation/adf[1]/frequencies/selected-khz", + nav1_frq: "instrumentation/nav[0]/frequencies/selected-mhz", + nav2_frq: "instrumentation/nav[1]/frequencies/selected-mhz", + lat_ctrl: "/it-autoflight/output/lat", + ver_ctrl: "/it-autoflight/output/vert", + } }; diff --git a/Models/Instruments/ND/canvas/helpers.nas b/Models/Instruments/ND/canvas/helpers.nas index 44eb38d2..c6a890a3 100644 --- a/Models/Instruments/ND/canvas/helpers.nas +++ b/Models/Instruments/ND/canvas/helpers.nas @@ -5,141 +5,141 @@ # Copyright (c) 2019 Joshua Davidson (Octal450) var SymbolPainter = { - aircraft_dir: nil, - getOpts: func(opts){ - if(opts == nil) opts = {}; - var defOpts = {id:nil,color:nil,scale:1,create_group:0,update_center:0}; - if(contains(opts, "id")) - defOpts.id = opts.id; - if(contains(opts, "color")) - defOpts.color = opts.color; - if(contains(opts, "scale")) - defOpts.scale = opts.scale; - if(contains(opts, "create_group")) - defOpts.create_group = opts.create_group; - if(contains(opts, "update_center")) - defOpts.update_center = opts.update_center; - return defOpts; - }, - getAircraftDir: func(){ - if(me.aircraft_dir == nil) - me.aircraft_dir = split("/", getprop("/sim/aircraft-dir"))[-1]; - return me.aircraft_dir; - }, - svgPath: func(file){ - return "Aircraft/" ~ me.getAircraftDir() ~ "/Models/Instruments/ND/canvas/res/"~file; - }, - drawFIX : func(grp, opts = nil){ - var icon_fix = nil; - opts = me.getOpts(opts); - var sym_id = opts.id; - if(sym_id != nil) - icon_fix = grp.createChild("path", sym_id); - else - icon_fix = grp.createChild("path"); - var color = opts.color; - if(color == nil){ - color = { - r: 0.69, - g: 0, - b: 0.39 - }; - } - var scale = opts.scale; - if(scale == nil) scale = 0.8; - icon_fix.moveTo(-10,0) - .lineTo(0,-17) - .lineTo(10,0) - .lineTo(0,17) - .close() - .setStrokeLineWidth(3) - .setColor(color.r,color.g,color.b) - .setScale(scale,scale); - return icon_fix; - }, - drawVOR: func(grp, opts = nil){ - opts = me.getOpts(opts); - if(opts.create_group){ - var sym_id = opts.id; - if(sym_id != nil) - grp = grp.createChild("group", sym_id); - else - grp = grp.createChild("group"); - } - var svg_path = me.svgPath("airbus_vor.svg"); - canvas.parsesvg(grp, svg_path); - var scale = opts.scale; - if(scale == nil) scale = 0.8; - grp.setScale(scale,scale); - if(opts.update_center) - grp.setTranslation(-24 * scale,-24 * scale); - if(!contains(grp, "setColor")){ - grp.setColor = func { - var layer1 = grp.getElementById("layer1"); - if(layer1 == nil) return; - var children = layer1.getChildren(); - foreach(var c; children){ - if(isa(c, canvas.Path)) - c.setColor(arg); - } - }; - } - return grp; - }, - drawNDB: func(grp, opts = nil){ - var icon_ndb = nil; - opts = me.getOpts(opts); - var sym_id = opts.id; - if(sym_id != nil) - icon_ndb = grp.createChild("path", sym_id); - else - icon_ndb = grp.createChild("path"); - var color = opts.color; - var color = opts.color; - if(color == nil){ - color = { - r: 0.69, - g: 0, - b: 0.39 - }; - } - var scale = opts.scale; - if(scale == nil) scale = 0.8; - icon_ndb.moveTo(-15,15) - .lineTo(0,-15) - .lineTo(15,15) - .close() - .setStrokeLineWidth(3) - .setColor(color.r,color.g,color.b) - .setScale(scale,scale); - return icon_ndb; - }, - drawAirport: func(grp, opts = nil){ - opts = me.getOpts(opts); - if(opts.create_group){ - var sym_id = opts.id; - if(sym_id != nil) - grp = grp.createChild("group", sym_id); - else - grp = grp.createChild("group"); - } - var svg_path = me.svgPath("airbus_airport.svg"); - canvas.parsesvg(grp, svg_path); - var scale = opts.scale; - if(scale == nil) scale = 0.8; - grp.setScale(scale,scale); - if(opts.update_center) - grp.setTranslation(-24 * scale,-24 * scale); - return grp; - }, - draw: func(type, grp, opts = nil){ - if(type == "VOR" or type == "vor") - return me.drawVOR(grp, opts); - elsif(type == "NDB" or type == "ndb") - return me.drawNDB(grp, opts); - elsif(type == "ARPT" or type == "arpt") - return me.drawAirport(grp, opts); - else - return me.drawFIX(grp, opts); - } + aircraft_dir: nil, + getOpts: func(opts){ + if(opts == nil) opts = {}; + var defOpts = {id:nil,color:nil,scale:1,create_group:0,update_center:0}; + if(contains(opts, "id")) + defOpts.id = opts.id; + if(contains(opts, "color")) + defOpts.color = opts.color; + if(contains(opts, "scale")) + defOpts.scale = opts.scale; + if(contains(opts, "create_group")) + defOpts.create_group = opts.create_group; + if(contains(opts, "update_center")) + defOpts.update_center = opts.update_center; + return defOpts; + }, + getAircraftDir: func(){ + if(me.aircraft_dir == nil) + me.aircraft_dir = split("/", getprop("/sim/aircraft-dir"))[-1]; + return me.aircraft_dir; + }, + svgPath: func(file){ + return "Aircraft/" ~ me.getAircraftDir() ~ "/Models/Instruments/ND/canvas/res/"~file; + }, + drawFIX : func(grp, opts = nil){ + var icon_fix = nil; + opts = me.getOpts(opts); + var sym_id = opts.id; + if(sym_id != nil) + icon_fix = grp.createChild("path", sym_id); + else + icon_fix = grp.createChild("path"); + var color = opts.color; + if(color == nil){ + color = { + r: 0.69, + g: 0, + b: 0.39 + }; + } + var scale = opts.scale; + if(scale == nil) scale = 0.8; + icon_fix.moveTo(-10,0) + .lineTo(0,-17) + .lineTo(10,0) + .lineTo(0,17) + .close() + .setStrokeLineWidth(3) + .setColor(color.r,color.g,color.b) + .setScale(scale,scale); + return icon_fix; + }, + drawVOR: func(grp, opts = nil){ + opts = me.getOpts(opts); + if(opts.create_group){ + var sym_id = opts.id; + if(sym_id != nil) + grp = grp.createChild("group", sym_id); + else + grp = grp.createChild("group"); + } + var svg_path = me.svgPath("airbus_vor.svg"); + canvas.parsesvg(grp, svg_path); + var scale = opts.scale; + if(scale == nil) scale = 0.8; + grp.setScale(scale,scale); + if(opts.update_center) + grp.setTranslation(-24 * scale,-24 * scale); + if(!contains(grp, "setColor")){ + grp.setColor = func { + var layer1 = grp.getElementById("layer1"); + if(layer1 == nil) return; + var children = layer1.getChildren(); + foreach(var c; children){ + if(isa(c, canvas.Path)) + c.setColor(arg); + } + }; + } + return grp; + }, + drawNDB: func(grp, opts = nil){ + var icon_ndb = nil; + opts = me.getOpts(opts); + var sym_id = opts.id; + if(sym_id != nil) + icon_ndb = grp.createChild("path", sym_id); + else + icon_ndb = grp.createChild("path"); + var color = opts.color; + var color = opts.color; + if(color == nil){ + color = { + r: 0.69, + g: 0, + b: 0.39 + }; + } + var scale = opts.scale; + if(scale == nil) scale = 0.8; + icon_ndb.moveTo(-15,15) + .lineTo(0,-15) + .lineTo(15,15) + .close() + .setStrokeLineWidth(3) + .setColor(color.r,color.g,color.b) + .setScale(scale,scale); + return icon_ndb; + }, + drawAirport: func(grp, opts = nil){ + opts = me.getOpts(opts); + if(opts.create_group){ + var sym_id = opts.id; + if(sym_id != nil) + grp = grp.createChild("group", sym_id); + else + grp = grp.createChild("group"); + } + var svg_path = me.svgPath("airbus_airport.svg"); + canvas.parsesvg(grp, svg_path); + var scale = opts.scale; + if(scale == nil) scale = 0.8; + grp.setScale(scale,scale); + if(opts.update_center) + grp.setTranslation(-24 * scale,-24 * scale); + return grp; + }, + draw: func(type, grp, opts = nil){ + if(type == "VOR" or type == "vor") + return me.drawVOR(grp, opts); + elsif(type == "NDB" or type == "ndb") + return me.drawNDB(grp, opts); + elsif(type == "ARPT" or type == "arpt") + return me.drawAirport(grp, opts); + else + return me.drawFIX(grp, opts); + } }; diff --git a/Models/Instruments/ND/canvas/loaders.nas b/Models/Instruments/ND/canvas/loaders.nas index 72b56df7..ba07c923 100644 --- a/Models/Instruments/ND/canvas/loaders.nas +++ b/Models/Instruments/ND/canvas/loaders.nas @@ -10,78 +10,78 @@ version = num(v[0]~"."~v[1]); setlistener("/nasal/canvas/loaded", func() { - ####### LOAD FILES ####### - #print("loading files"); - (func { - var aircraft_root = getprop("/sim/aircraft-dir"); + ####### LOAD FILES ####### + #print("loading files"); + (func { + var aircraft_root = getprop("/sim/aircraft-dir"); - var load = func(file, name) { - #print("Loading ..." ~ file); - if (name == nil) - var name = split("/", file)[-1]; - if (substr(name, size(name)-4) == ".draw") - name = substr(name, 0, size(name)-5); - #print("reading file"); - var code = io.readfile(file); - #print("compiling file"); - # This segfaults for some reason: - #var code = call(compile, [code], var err=[]); - var code = call(func compile(code, file), [code], var err=[]); - if (size(err)) { - #print("handling error"); - if (substr(err[0], 0, 12) == "Parse error:") { # hack around Nasal feature - var e = split(" at line ", err[0]); - if (size(e) == 2) - err[0] = string.join("", [e[0], "\n at ", file, ", line ", e[1], "\n "]); - } - for (var i = 1; (var c = caller(i)) != nil; i += 1) - err ~= subvec(c, 2, 2); - debug.printerror(err); - return; - } - #print("calling code"); - call(code, nil, nil, var hash = {}); - #debug.dump(keys(hash)); - return hash; - }; + var load = func(file, name) { + #print("Loading ..." ~ file); + if (name == nil) + var name = split("/", file)[-1]; + if (substr(name, size(name)-4) == ".draw") + name = substr(name, 0, size(name)-5); + #print("reading file"); + var code = io.readfile(file); + #print("compiling file"); + # This segfaults for some reason: + #var code = call(compile, [code], var err=[]); + var code = call(func compile(code, file), [code], var err=[]); + if (size(err)) { + #print("handling error"); + if (substr(err[0], 0, 12) == "Parse error:") { # hack around Nasal feature + var e = split(" at line ", err[0]); + if (size(e) == 2) + err[0] = string.join("", [e[0], "\n at ", file, ", line ", e[1], "\n "]); + } + for (var i = 1; (var c = caller(i)) != nil; i += 1) + err ~= subvec(c, 2, 2); + debug.printerror(err); + return; + } + #print("calling code"); + call(code, nil, nil, var hash = {}); + #debug.dump(keys(hash)); + return hash; + }; - var load_deps = func(name) { - print("Loading MapStructure Layer: "~ name); - load(aircraft_root~"/Models/Instruments/ND/map/"~name~".lcontroller", name); - load(aircraft_root~"/Models/Instruments/ND/map/"~name~".symbol", name); - if(version < 3.2) - load(aircraft_root~"/Models/Instruments/ND/map/"~name~".scontroller", name); - } + var load_deps = func(name) { + print("Loading MapStructure Layer: "~ name); + load(aircraft_root~"/Models/Instruments/ND/map/"~name~".lcontroller", name); + load(aircraft_root~"/Models/Instruments/ND/map/"~name~".symbol", name); + if(version < 3.2) + load(aircraft_root~"/Models/Instruments/ND/map/"~name~".scontroller", name); + } - #foreach( var name; ["APS","ALT-profile","SPD-profile","RTE","WPT","DECEL","NDB"] ) - #load_deps( name ); - var dep_names = [ - # With these extensions, in this order: - "lcontroller", - "symbol", - "scontroller", - "controller", - ]; - var map_root = aircraft_root~"/Models/Instruments/ND/canvas/map/"; - var files = directory(map_root); - var deps = {}; - foreach (var d; dep_names) deps[d] = []; - foreach(var f; files){ - var ext = size(var s=split(".", f)) > 1 ? s[-1] : nil; - foreach (var d; dep_names) { - if (ext == d) { - append(deps[d], f); - break - } - } - } + #foreach( var name; ["APS","ALT-profile","SPD-profile","RTE","WPT","DECEL","NDB"] ) + #load_deps( name ); + var dep_names = [ + # With these extensions, in this order: + "lcontroller", + "symbol", + "scontroller", + "controller", + ]; + var map_root = aircraft_root~"/Models/Instruments/ND/canvas/map/"; + var files = directory(map_root); + var deps = {}; + foreach (var d; dep_names) deps[d] = []; + foreach(var f; files){ + var ext = size(var s=split(".", f)) > 1 ? s[-1] : nil; + foreach (var d; dep_names) { + if (ext == d) { + append(deps[d], f); + break + } + } + } - foreach (var d; dep_names) { - foreach (var f; deps[d]) { - var name = split(".", f)[0]; - load(map_root~f, name); - } - } + foreach (var d; dep_names) { + foreach (var f; deps[d]) { + var name = split(".", f)[0]; + load(map_root~f, name); + } + } })(); diff --git a/Models/Instruments/ND/canvas/map/ALT-profile.scontroller b/Models/Instruments/ND/canvas/map/ALT-profile.scontroller index 1bd3fee3..a880967c 100644 --- a/Models/Instruments/ND/canvas/map/ALT-profile.scontroller +++ b/Models/Instruments/ND/canvas/map/ALT-profile.scontroller @@ -8,5 +8,5 @@ var new = func(model) ; # this controller doesn't need an instance var LayerController = SymbolLayer.Controller.registry[name]; var isActive = func(model) {return 1};#LayerController.a_instance.isActive(model); var query_range = func() - die(name~".scontroller.query_range /MUST/ be provided by implementation"); + die(name~".scontroller.query_range /MUST/ be provided by implementation"); #var model = props.globals.getNode('/position'); diff --git a/Models/Instruments/ND/canvas/map/APS.scontroller b/Models/Instruments/ND/canvas/map/APS.scontroller index e82d4c0a..8af1c96f 100644 --- a/Models/Instruments/ND/canvas/map/APS.scontroller +++ b/Models/Instruments/ND/canvas/map/APS.scontroller @@ -8,5 +8,5 @@ var new = func(model) ; # this controller doesn't need an instance var LayerController = canvas.SymbolLayer.Controller.registry[name]; var isActive = func(model) {return 1};#LayerController.a_instance.isActive(model); var query_range = func() - die(name~".scontroller.query_range /MUST/ be provided by implementation"); + die(name~".scontroller.query_range /MUST/ be provided by implementation"); #var model = props.globals.getNode('/position'); diff --git a/Models/Instruments/ND/canvas/map/APT.scontroller b/Models/Instruments/ND/canvas/map/APT.scontroller index d41a6049..48ed05d7 100644 --- a/Models/Instruments/ND/canvas/map/APT.scontroller +++ b/Models/Instruments/ND/canvas/map/APT.scontroller @@ -11,6 +11,6 @@ var query_range = func() die(name~".scontroller.query_range /MUST/ be provided by implementation"); var getpos = func(model){ - [model.lat, model.lon]; + [model.lat, model.lon]; } diff --git a/Models/Instruments/ND/canvas/map/DEBUG.lcontroller b/Models/Instruments/ND/canvas/map/DEBUG.lcontroller index 9d427ba2..3b1fce73 100644 --- a/Models/Instruments/ND/canvas/map/DEBUG.lcontroller +++ b/Models/Instruments/ND/canvas/map/DEBUG.lcontroller @@ -6,66 +6,66 @@ var __self__ = caller(0)[0]; canvas.SymbolLayer.Controller.add(name, __self__); canvas.SymbolLayer.add(name, { - parents: [canvas.MultiSymbolLayer], - type: name, # Symbol type - df_controller: __self__, # controller to use by default -- this one - df_options: { - update_t : 'autopilot/route-manager/debug/update_t', - listen: ['update_t'] - }, - df_style: { - default_color: [1,0,0], - } + parents: [canvas.MultiSymbolLayer], + type: name, # Symbol type + df_controller: __self__, # controller to use by default -- this one + df_options: { + update_t : 'autopilot/route-manager/debug/update_t', + listen: ['update_t'] + }, + df_style: { + default_color: [1,0,0], + } }); var new = func(layer) { - var m = { - parents: [__self__], - layer: layer, - map: layer.map, - listeners: [], - }; - layer.searcher._equals = func(a,b) a.equals(b); + var m = { + parents: [__self__], + layer: layer, + map: layer.map, + listeners: [], + }; + layer.searcher._equals = func(a,b) a.equals(b); - return m; + return m; }; var del = func() { - foreach (var l; me.listeners) - removelistener(l); + foreach (var l; me.listeners) + removelistener(l); }; var searchCmd = func { - var result = []; - #return result; - var node = me['node']; - if (node == nil) { - node = props.globals.getNode('autopilot/route-manager/debug/', 1); - me.node = node; - } - var points = me.node.getNode('points', 1).getChildren(); - #var count = getprop('autopilot/route-manager/debug/num') or 0; - var count = size(points); - #print('Map DEBUG: querying '~ count ~' results.'); - for(var idx = 0; idx < count; idx += 1){ - var point = points[idx]; - #var id = getprop('autopilot/route-manager/debug/point['~idx~']/id'); - #var lat = getprop('autopilot/route-manager/debug/point['~idx~']/lat'); - #var lon = getprop('autopilot/route-manager/debug/point['~idx~']/lon'); - var id = point.getValue('id'); - var lat = point.getValue('lat'); - var lon = point.getValue('lon'); - if (id == nil or id == '') continue; - #print('Map DEBUG: found '~ id ~' debug point.'); - var model = { - id: id, - lat: lat, - lon: lon, - equals: func(o){ - me.id == o.id and me.lat == o.lat and me.lon == o.lon - } - }; - append(result, model); - } - return result; + var result = []; + #return result; + var node = me['node']; + if (node == nil) { + node = props.globals.getNode('autopilot/route-manager/debug/', 1); + me.node = node; + } + var points = me.node.getNode('points', 1).getChildren(); + #var count = getprop('autopilot/route-manager/debug/num') or 0; + var count = size(points); + #print('Map DEBUG: querying '~ count ~' results.'); + for(var idx = 0; idx < count; idx += 1){ + var point = points[idx]; + #var id = getprop('autopilot/route-manager/debug/point['~idx~']/id'); + #var lat = getprop('autopilot/route-manager/debug/point['~idx~']/lat'); + #var lon = getprop('autopilot/route-manager/debug/point['~idx~']/lon'); + var id = point.getValue('id'); + var lat = point.getValue('lat'); + var lon = point.getValue('lon'); + if (id == nil or id == '') continue; + #print('Map DEBUG: found '~ id ~' debug point.'); + var model = { + id: id, + lat: lat, + lon: lon, + equals: func(o){ + me.id == o.id and me.lat == o.lat and me.lon == o.lon + } + }; + append(result, model); + } + return result; } diff --git a/Models/Instruments/ND/canvas/map/DEBUG.symbol b/Models/Instruments/ND/canvas/map/DEBUG.symbol index b58444d7..12fc978f 100644 --- a/Models/Instruments/ND/canvas/map/DEBUG.symbol +++ b/Models/Instruments/ND/canvas/map/DEBUG.symbol @@ -8,20 +8,20 @@ canvas.DotSym.makeinstance( name, __self__ ); var element_type = "group"; var init = func { - me.text_wps = me.element.createChild("text", "dbg-text-" ~ me.model.id) - .setDrawMode( canvas.Text.TEXT ) - .setText(me.model.id) - .setFont("LiberationFonts/LiberationSans-Regular.ttf") - .setFontSize(28) - .setTranslation(25,15) - .setColor(1,0,0); - me.text_alt = nil; - me.sym = me.element.createChild("path"). - setStrokeLineWidth(4). - moveTo(-16,0). - arcSmallCW(16,16,0,32,0). - arcSmallCW(16,16,0,-32,0). - setColor(1,0,0); + me.text_wps = me.element.createChild("text", "dbg-text-" ~ me.model.id) + .setDrawMode( canvas.Text.TEXT ) + .setText(me.model.id) + .setFont("LiberationFonts/LiberationSans-Regular.ttf") + .setFontSize(28) + .setTranslation(25,15) + .setColor(1,0,0); + me.text_alt = nil; + me.sym = me.element.createChild("path"). + setStrokeLineWidth(4). + moveTo(-16,0). + arcSmallCW(16,16,0,32,0). + arcSmallCW(16,16,0,-32,0). + setColor(1,0,0); } var draw = func{ diff --git a/Models/Instruments/ND/canvas/map/DECEL.lcontroller b/Models/Instruments/ND/canvas/map/DECEL.lcontroller index a4ec57a1..8a5d302a 100644 --- a/Models/Instruments/ND/canvas/map/DECEL.lcontroller +++ b/Models/Instruments/ND/canvas/map/DECEL.lcontroller @@ -6,32 +6,32 @@ var __self__ = caller(0)[0]; canvas.SymbolLayer.Controller.add(name, __self__); canvas.SymbolLayer.add(name, { - parents: [MultiSymbolLayer], - type: name, # Symbol type - df_controller: __self__, # controller to use by default -- this one - df_options : { # default configuration options - decel_node: "/autopilot/route-manager/vnav/decel/" - } + parents: [MultiSymbolLayer], + type: name, # Symbol type + df_controller: __self__, # controller to use by default -- this one + df_options : { # default configuration options + decel_node: "/autopilot/route-manager/vnav/decel/" + } }); var new = func(layer) { - var m = { - parents: [__self__], - layer: layer, - map: layer.map, - listeners: [], - }; - layer.searcher._equals = func(a,b) a.getName() == b.getName(); - return m; + var m = { + parents: [__self__], + layer: layer, + map: layer.map, + listeners: [], + }; + layer.searcher._equals = func(a,b) a.getName() == b.getName(); + return m; }; var del = func() { - foreach (var l; me.listeners) - removelistener(l); + foreach (var l; me.listeners) + removelistener(l); }; var searchCmd = func { - var results = []; - var symNode = props.globals.getNode(me.layer.options.decel_node); - if (symNode != nil and symNode.getValue('longitude-deg') != nil) - append(results, symNode); - return results; + var results = []; + var symNode = props.globals.getNode(me.layer.options.decel_node); + if (symNode != nil and symNode.getValue('longitude-deg') != nil) + append(results, symNode); + return results; } diff --git a/Models/Instruments/ND/canvas/map/DECEL.scontroller b/Models/Instruments/ND/canvas/map/DECEL.scontroller index 4e749b10..7d66482a 100644 --- a/Models/Instruments/ND/canvas/map/DECEL.scontroller +++ b/Models/Instruments/ND/canvas/map/DECEL.scontroller @@ -8,5 +8,5 @@ var new = func(model) ; # this controller doesn't need an instance var LayerController = canvas.SymbolLayer.Controller.registry[name]; var isActive = func(model) {return 1};#LayerController.a_instance.isActive(model); var query_range = func() - die(name~".scontroller.query_range /MUST/ be provided by implementation"); + die(name~".scontroller.query_range /MUST/ be provided by implementation"); #var model = props.globals.getNode('/position'); diff --git a/Models/Instruments/ND/canvas/map/DECEL.symbol b/Models/Instruments/ND/canvas/map/DECEL.symbol index cc39fd65..c0a65b20 100644 --- a/Models/Instruments/ND/canvas/map/DECEL.symbol +++ b/Models/Instruments/ND/canvas/map/DECEL.symbol @@ -12,21 +12,21 @@ canvas.DotSym.makeinstance( name, __self__ ); var element_type = "group"; var init = func { - var svg_path = me.getStyle('svg_path'); - if(svg_path == nil) - svg_path = get_local_path('res/airbus_decel.svg'); - me.decel_grp = me.element.createChild("group","decel"); - canvas.parsesvg(me.decel_grp, svg_path); - me.decel_grp.set('z-index', 5); + var svg_path = me.getStyle('svg_path'); + if(svg_path == nil) + svg_path = get_local_path('res/airbus_decel.svg'); + me.decel_grp = me.element.createChild("group","decel"); + canvas.parsesvg(me.decel_grp, svg_path); + me.decel_grp.set('z-index', 5); } var draw = func{ - if(me.decel_grp != nil){ - var spd_ctrl = getprop(me.options.spd_ctrl); - var spd_managed = (spd_ctrl == me.options.managed_val); - if(spd_managed) - me.decel_grp.setColor(me.style.managed_color); - else - me.decel_grp.setColor(me.style.selected_color); - } + if(me.decel_grp != nil){ + var spd_ctrl = getprop(me.options.spd_ctrl); + var spd_managed = (spd_ctrl == me.options.managed_val); + if(spd_managed) + me.decel_grp.setColor(me.style.managed_color); + else + me.decel_grp.setColor(me.style.selected_color); + } } diff --git a/Models/Instruments/ND/canvas/map/RTE.lcontroller b/Models/Instruments/ND/canvas/map/RTE.lcontroller index 7c4979d7..04dd5eab 100644 --- a/Models/Instruments/ND/canvas/map/RTE.lcontroller +++ b/Models/Instruments/ND/canvas/map/RTE.lcontroller @@ -12,9 +12,9 @@ SymbolLayer.add(name, { type: name, # Symbol type df_controller: __self__, # controller to use by default -- this one df_options: { # default configuration options - active_node: "/autopilot/route-manager/active", - current_wp_node: "/autopilot/route-manager/current-wp", - wp_num: "/autopilot/route-manager/route/num", + active_node: "/FMGC/flightplan[2]/active", + current_wp_node: "/FMGC/flightplan[2]/current-wp", + wp_num: "/FMGC/flightplan[2]/num", display_inactive_rte: 0 } }); @@ -74,12 +74,12 @@ var searchCmd = func { path = [{},{lon:leg.wp_lon, lat:leg.wp_lat}]; else path = leg.path(); - if(i == (fpSize - 1) and !discontinuity){# WORKAROUND FOR FG BUG - var ltype = leg.wp_type; - var path_l = size(path); - if(ltype != 'runway' and path_l >= 2) - path = subvec(path, 0, 1) ~ subvec(path, path_l - 1, 1); - } +# if(i == (fpSize - 1) and !discontinuity){# WORKAROUND FOR FG BUG -- we don't need it anymore (I think)! +# var ltype = leg.wp_type; +# var path_l = size(path); +# if(ltype != 'runway' and path_l >= 2) +# path = subvec(path, 0, 1) ~ subvec(path, path_l - 1, 1); +# } coords ~= path; discontinuity = driver.hasDiscontinuity(idx, leg); } diff --git a/Models/Instruments/ND/canvas/map/RTE.scontroller b/Models/Instruments/ND/canvas/map/RTE.scontroller index 7890370b..968becb8 100644 --- a/Models/Instruments/ND/canvas/map/RTE.scontroller +++ b/Models/Instruments/ND/canvas/map/RTE.scontroller @@ -8,5 +8,5 @@ var new = func(model) ; # this controller doesn't need an instance var LayerController = canvas.SymbolLayer.Controller.registry[name]; var isActive = func(model) {return 1};#LayerController.a_instance.isActive(model); var query_range = func() - die(name~".scontroller.query_range /MUST/ be provided by implementation"); + die(name~".scontroller.query_range /MUST/ be provided by implementation"); #var model = props.globals.getNode('/position'); diff --git a/Models/Instruments/ND/canvas/map/RWY-profile.symbol b/Models/Instruments/ND/canvas/map/RWY-profile.symbol index 41987a75..59ce331e 100644 --- a/Models/Instruments/ND/canvas/map/RWY-profile.symbol +++ b/Models/Instruments/ND/canvas/map/RWY-profile.symbol @@ -9,72 +9,72 @@ DotSym.makeinstance( name, __self__ ); var element_type = "group"; var style = { # style to use by default - zoom: 20, - color: [1,1,1], - center_line_len: 0.75, - line_width: 3 + zoom: 20, + color: [1,1,1], + center_line_len: 0.75, + line_width: 3 }; SymbolLayer.get(name).df_style = style; #var already_drawn = 0; var init = func { - #if(me.already_drawn) return; - var lat = me.model.lat; - var lon = me.model.lon; - var rwyhdg = me.model.heading; - var width = me.model.width; - var length = me.model.length; - var group = me.element; - var ctr_len = length * me.getStyle('center_line_len', 0.75); - var crds = []; - var coord = geo.Coord.new(); - width = width * me.getStyle('zoom', 20); # Else rwy is too thin to be visible - var line_w = me.getStyle('line_width', 3); - var color = me.getStyle('color', [1,1,1]); - coord.set_latlon(lat, lon); - coord.apply_course_distance(rwyhdg, -(ctr_len / 2)); - append(crds,"N"~coord.lat()); - append(crds,"E"~coord.lon()); - coord.apply_course_distance(rwyhdg, (ctr_len)); - append(crds,"N"~coord.lat()); - append(crds,"E"~coord.lon()); - icon_rwy = group.createChild("path", "rwy-cl") - .setStrokeLineWidth(line_w) - .setDataGeo([2,4],crds) - .setColor(color); - #.setStrokeDashArray([10, 20, 10, 20, 10]); - #icon_rwy.hide(); - var crds = []; - coord.set_latlon(lat, lon); - append(crds,"N"~coord.lat()); - append(crds,"E"~coord.lon()); - coord.apply_course_distance(rwyhdg + 90, width/2); - append(crds,"N"~coord.lat()); - append(crds,"E"~coord.lon()); - coord.apply_course_distance(rwyhdg, length); - append(crds,"N"~coord.lat()); - append(crds,"E"~coord.lon()); - icon_rwy = group.createChild("path", "rwy") - .setStrokeLineWidth(line_w) - .setDataGeo([2,4,4],crds) - .setColor(color); - var crds = []; - append(crds,"N"~coord.lat()); - append(crds,"E"~coord.lon()); - coord.apply_course_distance(rwyhdg - 90, width); - append(crds,"N"~coord.lat()); - append(crds,"E"~coord.lon()); - coord.apply_course_distance(rwyhdg, -length); - append(crds,"N"~coord.lat()); - append(crds,"E"~coord.lon()); - coord.apply_course_distance(rwyhdg + 90, width / 2); - append(crds,"N"~coord.lat()); - append(crds,"E"~coord.lon()); - icon_rwy = group.createChild("path", "rwy") - .setStrokeLineWidth(line_w) - .setDataGeo([2,4,4,4],crds) - .setColor(color); + #if(me.already_drawn) return; + var lat = me.model.lat; + var lon = me.model.lon; + var rwyhdg = me.model.heading; + var width = me.model.width; + var length = me.model.length; + var group = me.element; + var ctr_len = length * me.getStyle('center_line_len', 0.75); + var crds = []; + var coord = geo.Coord.new(); + width = width * me.getStyle('zoom', 20); # Else rwy is too thin to be visible + var line_w = me.getStyle('line_width', 3); + var color = me.getStyle('color', [1,1,1]); + coord.set_latlon(lat, lon); + coord.apply_course_distance(rwyhdg, -(ctr_len / 2)); + append(crds,"N"~coord.lat()); + append(crds,"E"~coord.lon()); + coord.apply_course_distance(rwyhdg, (ctr_len)); + append(crds,"N"~coord.lat()); + append(crds,"E"~coord.lon()); + icon_rwy = group.createChild("path", "rwy-cl") + .setStrokeLineWidth(line_w) + .setDataGeo([2,4],crds) + .setColor(color); + #.setStrokeDashArray([10, 20, 10, 20, 10]); + #icon_rwy.hide(); + var crds = []; + coord.set_latlon(lat, lon); + append(crds,"N"~coord.lat()); + append(crds,"E"~coord.lon()); + coord.apply_course_distance(rwyhdg + 90, width/2); + append(crds,"N"~coord.lat()); + append(crds,"E"~coord.lon()); + coord.apply_course_distance(rwyhdg, length); + append(crds,"N"~coord.lat()); + append(crds,"E"~coord.lon()); + icon_rwy = group.createChild("path", "rwy") + .setStrokeLineWidth(line_w) + .setDataGeo([2,4,4],crds) + .setColor(color); + var crds = []; + append(crds,"N"~coord.lat()); + append(crds,"E"~coord.lon()); + coord.apply_course_distance(rwyhdg - 90, width); + append(crds,"N"~coord.lat()); + append(crds,"E"~coord.lon()); + coord.apply_course_distance(rwyhdg, -length); + append(crds,"N"~coord.lat()); + append(crds,"E"~coord.lon()); + coord.apply_course_distance(rwyhdg + 90, width / 2); + append(crds,"N"~coord.lat()); + append(crds,"E"~coord.lon()); + icon_rwy = group.createChild("path", "rwy") + .setStrokeLineWidth(line_w) + .setDataGeo([2,4,4,4],crds) + .setColor(color); }; var draw = func{} diff --git a/Models/Instruments/ND/canvas/map/SPD-profile.lcontroller b/Models/Instruments/ND/canvas/map/SPD-profile.lcontroller index 65d08ad6..f4a6d392 100644 --- a/Models/Instruments/ND/canvas/map/SPD-profile.lcontroller +++ b/Models/Instruments/ND/canvas/map/SPD-profile.lcontroller @@ -5,47 +5,47 @@ var parents = [canvas.SymbolLayer.Controller]; var __self__ = caller(0)[0]; var _options = { # default configuration options - alts: [100,140,250,260,'wp'] + alts: [100,140,250,260,'wp'] }; canvas.SymbolLayer.Controller.add(name, __self__); canvas.SymbolLayer.add(name, { - parents: [MultiSymbolLayer], - type: name, # Symbol type - df_controller: __self__, # controller to use by default -- this one - df_options: _options + parents: [MultiSymbolLayer], + type: name, # Symbol type + df_controller: __self__, # controller to use by default -- this one + df_options: _options }); var new = func(layer) { - var m = { - parents: [__self__], - layer: layer, - #map: layer.map, - listeners: [], - }; - layer.searcher._equals = func(a,b) a.getName() == b.getName(); - #append(m.listeners, setlistener(layer.options.fplan_active, func m.layer.update() )); - #m.addVisibilityListener(); + var m = { + parents: [__self__], + layer: layer, + #map: layer.map, + listeners: [], + }; + layer.searcher._equals = func(a,b) a.getName() == b.getName(); + #append(m.listeners, setlistener(layer.options.fplan_active, func m.layer.update() )); + #m.addVisibilityListener(); - return m; + return m; }; var del = func() { - foreach (var l; me.listeners) - removelistener(l); + foreach (var l; me.listeners) + removelistener(l); }; var searchCmd = func { - var results = []; - var spdNode = props.globals.getNode(me.layer.options.spd_node); - if (spdNode != nil) { - var limits = spdNode.getChildren(); - foreach (var limit; limits) { - #t = 'spd-change-point' ~ '-' ~ alt; - #print('SPD-Controller, search for '~t); - #var n = spdNode.getNode(t); - if (limit != nil and limit.getValue('longitude-deg') != nil){ - #print('SPD-Controller -> Append'); - append(results, limit); - } - } - } - return results; + var results = []; + var spdNode = props.globals.getNode(me.layer.options.spd_node); + if (spdNode != nil) { + var limits = spdNode.getChildren(); + foreach (var limit; limits) { + #t = 'spd-change-point' ~ '-' ~ alt; + #print('SPD-Controller, search for '~t); + #var n = spdNode.getNode(t); + if (limit != nil and limit.getValue('longitude-deg') != nil){ + #print('SPD-Controller -> Append'); + append(results, limit); + } + } + } + return results; } diff --git a/Models/Instruments/ND/canvas/map/SPD-profile.scontroller b/Models/Instruments/ND/canvas/map/SPD-profile.scontroller index 191945db..018d3633 100644 --- a/Models/Instruments/ND/canvas/map/SPD-profile.scontroller +++ b/Models/Instruments/ND/canvas/map/SPD-profile.scontroller @@ -8,5 +8,5 @@ var new = func(model) ; # this controller doesn't need an instance var LayerController = canvas.SymbolLayer.Controller.registry[name]; var isActive = func(model) {return 1};#LayerController.a_instance.isActive(model); var query_range = func() - die(name~".scontroller.query_range /MUST/ be provided by implementation"); + die(name~".scontroller.query_range /MUST/ be provided by implementation"); #var model = props.globals.getNode('/position'); diff --git a/Models/Instruments/ND/canvas/map/SPD-profile.symbol b/Models/Instruments/ND/canvas/map/SPD-profile.symbol index deffbafe..96aefdff 100644 --- a/Models/Instruments/ND/canvas/map/SPD-profile.symbol +++ b/Models/Instruments/ND/canvas/map/SPD-profile.symbol @@ -32,9 +32,9 @@ var draw = func{ # var name = me.model.getName(); # var sym_group = me.element.getElementById(name); # sym_group.set('z-index', 5); - if(me.spd_sym == nil){ - me.spd_sym = me.getElementById("airbus-spd-sym"); - me.spd_sym.setTranslation(-24, -24).set('z-index', 5); - } - + if(me.spd_sym == nil){ + me.spd_sym = me.getElementById("airbus-spd-sym"); + me.spd_sym.setTranslation(-24, -24).set('z-index', 5); + } + } diff --git a/Models/Instruments/ND/canvas/map/VOR-airbus.lcontroller b/Models/Instruments/ND/canvas/map/VOR-airbus.lcontroller index 75290cc3..f254aacc 100644 --- a/Models/Instruments/ND/canvas/map/VOR-airbus.lcontroller +++ b/Models/Instruments/ND/canvas/map/VOR-airbus.lcontroller @@ -5,58 +5,58 @@ var parents = [SymbolLayer.Controller]; var __self__ = caller(0)[0]; SymbolLayer.Controller.add(name, __self__); SymbolLayer.add(name, { - parents: [NavaidSymbolLayer], - type: name, # Symbol type - df_controller: __self__, # controller to use by default -- this one - df_options: { - vor1_frq: 'instrumentation/nav[2]/frequencies/selected-mhz', - vor2_frq: 'instrumentation/nav[3]/frequencies/selected-mhz' - }, - df_style: { - scale: 1 - } + parents: [NavaidSymbolLayer], + type: name, # Symbol type + df_controller: __self__, # controller to use by default -- this one + df_options: { + vor1_frq: 'instrumentation/nav[2]/frequencies/selected-mhz', + vor2_frq: 'instrumentation/nav[3]/frequencies/selected-mhz' + }, + df_style: { + scale: 1 + } }); var new = func(layer) { - var m = { - parents: [__self__], - layer: layer, - map: layer.map, - active_vors: [], - navNs: props.globals.getNode("instrumentation").getChildren("nav"), - listeners: [], - query_type:'vor', - }; - setsize(m.active_vors, size(m.navNs)); - foreach (var navN; m.navNs) { - append(m.listeners, setlistener( - navN.getNode("frequencies/selected-mhz"), - func m.changed_freq() - )); - } - #call(debug.dump, keys(layer)); - m.changed_freq(update:0); - m.addVisibilityListener(); + var m = { + parents: [__self__], + layer: layer, + map: layer.map, + active_vors: [], + navNs: props.globals.getNode("instrumentation").getChildren("nav"), + listeners: [], + query_type:'vor', + }; + setsize(m.active_vors, size(m.navNs)); + foreach (var navN; m.navNs) { + append(m.listeners, setlistener( + navN.getNode("frequencies/selected-mhz"), + func m.changed_freq() + )); + } + #call(debug.dump, keys(layer)); + m.changed_freq(update:0); + m.addVisibilityListener(); - return m; + return m; }; var del = func() { - printlog(_MP_dbg_lvl, name,".lcontroller.del()"); - foreach (var l; me.listeners) - removelistener(l); + printlog(_MP_dbg_lvl, name,".lcontroller.del()"); + foreach (var l; me.listeners) + removelistener(l); }; # Controller methods var isActive = func(model) { - var my_freq = model.frequency/100; - foreach (var freq; me.active_vors) - if (freq == my_freq) return 1; - return 0; + var my_freq = model.frequency/100; + foreach (var freq; me.active_vors) + if (freq == my_freq) return 1; + return 0; }; var changed_freq = func(update=1) { - #debug.dump(me.active_vors); - foreach (var navN; me.navNs) - me.active_vors[ navN.getIndex() ] = navN.getValue("frequencies/selected-mhz"); - if (update) me.layer.update(); + #debug.dump(me.active_vors); + foreach (var navN; me.navNs) + me.active_vors[ navN.getIndex() ] = navN.getValue("frequencies/selected-mhz"); + if (update) me.layer.update(); }; var searchCmd = NavaidSymbolLayer.make('vor'); \ No newline at end of file diff --git a/Models/Instruments/ND/canvas/map/VOR-airbus.symbol b/Models/Instruments/ND/canvas/map/VOR-airbus.symbol index bdd8f7ca..4782fbb6 100644 --- a/Models/Instruments/ND/canvas/map/VOR-airbus.symbol +++ b/Models/Instruments/ND/canvas/map/VOR-airbus.symbol @@ -11,33 +11,33 @@ var svg_path = get_local_path('res/airbus_vor.svg'); var vor_sym = nil; var draw = func{ - if(me.vor_sym == nil) - me.vor_sym = me.element.getElementById("airbus-vor-sym"); - me.vor_sym.setTranslation(-24,-24); - if(me.text_vor == nil){ - var transl = me.getStyle('translation', [25,10]); - var text_color = me.getStyle('text_color', [1,1,1]); - me.text_vor = me.element.createChild("text") - .setDrawMode( canvas.Text.TEXT ) - .setText(me.model.id) - .setFont("LiberationFonts/LiberationSans-Regular.ttf") - .setFontSize(28) - .setColor(text_color) - .setTranslation(transl); - } - - var frq = me.model.frequency; - if(frq != nil){ - var dfcolor = me.getStyle('color', [0.9,0,0.47]); - var tuned_color = me.getStyle('tuned_color', [0,0.62,0.84]); - frq = frq / 100; - var vor1_frq = getprop(me.options.vor1_frq); - var vor2_frq = getprop(me.options.vor2_frq); - if(vor1_frq == frq or vor2_frq == frq){ - me.element.setColor(tuned_color); - } else { - me.element.setColor(dfcolor); - } - } - me.text_vor.setColor(me.getStyle('text_color', [1,1,1])); + if(me.vor_sym == nil) + me.vor_sym = me.element.getElementById("airbus-vor-sym"); + me.vor_sym.setTranslation(-24,-24); + if(me.text_vor == nil){ + var transl = me.getStyle('translation', [25,10]); + var text_color = me.getStyle('text_color', [1,1,1]); + me.text_vor = me.element.createChild("text") + .setDrawMode( canvas.Text.TEXT ) + .setText(me.model.id) + .setFont("LiberationFonts/LiberationSans-Regular.ttf") + .setFontSize(28) + .setColor(text_color) + .setTranslation(transl); + } + + var frq = me.model.frequency; + if(frq != nil){ + var dfcolor = me.getStyle('color', [0.9,0,0.47]); + var tuned_color = me.getStyle('tuned_color', [0,0.62,0.84]); + frq = frq / 100; + var vor1_frq = getprop(me.options.vor1_frq); + var vor2_frq = getprop(me.options.vor2_frq); + if(vor1_frq == frq or vor2_frq == frq){ + me.element.setColor(tuned_color); + } else { + me.element.setColor(dfcolor); + } + } + me.text_vor.setColor(me.getStyle('text_color', [1,1,1])); } \ No newline at end of file diff --git a/Models/Instruments/ND/canvas/map/WPT-airbus.lcontroller b/Models/Instruments/ND/canvas/map/WPT-airbus.lcontroller index 2ca8d845..7f510dc4 100644 --- a/Models/Instruments/ND/canvas/map/WPT-airbus.lcontroller +++ b/Models/Instruments/ND/canvas/map/WPT-airbus.lcontroller @@ -6,132 +6,132 @@ var __self__ = caller(0)[0]; canvas.SymbolLayer.Controller.add(name, __self__); canvas.SymbolLayer.add(name, { - parents: [canvas.MultiSymbolLayer], - type: name, # Symbol type - df_controller: __self__, # controller to use by default -- this one - df_options: { # default configuration options - fix_symbol: func(group){ - group.createChild('path') - .moveTo(-10,0) - .lineTo(0,-17) - .lineTo(10,0) - .lineTo(0,17) - .close() - .setStrokeLineWidth(3) - .setColor(1,1,1) - .setScale(1,1); - }, - vor_symbol: 'Nasal/canvas/map/Airbus/Images/airbus_vor.svg', - airport_symbol: 'Nasal/canvas/map/Airbus/Images/airbus_airport.svg', - ndb_symbol: func(group){ - group.createChild('path') - .moveTo(-15,15) - .lineTo(0,-15) - .lineTo(15,15) - .close() - .setStrokeLineWidth(3) - #.setColor(0.69,0,0.39) - #.setTranslation(-24, -24), - .setScale(1,1); - } - }, - df_style: { - active_wp_color: [0.4,0.7,0.4], - current_wp_color: [1,1,1], - translation: { - 'airport': [-24,-24], - 'vor': [-24,-24] - } - }, - toggle_cstr: 0 + parents: [canvas.MultiSymbolLayer], + type: name, # Symbol type + df_controller: __self__, # controller to use by default -- this one + df_options: { # default configuration options + fix_symbol: func(group){ + group.createChild('path') + .moveTo(-10,0) + .lineTo(0,-17) + .lineTo(10,0) + .lineTo(0,17) + .close() + .setStrokeLineWidth(3) + .setColor(1,1,1) + .setScale(1); + }, + vor_symbol: 'Nasal/canvas/map/Airbus/Images/airbus_vor.svg', + airport_symbol: 'Nasal/canvas/map/Airbus/Images/airbus_airport.svg', + ndb_symbol: func(group){ + group.createChild('path') + .moveTo(-15,15) + .lineTo(0,-15) + .lineTo(15,15) + .close() + .setStrokeLineWidth(3) + #.setColor(0.69,0,0.39) + #.setTranslation(-24, -24), + .setScale(1,1); + } + }, + df_style: { + active_wp_color: [0.4,0.7,0.4], + current_wp_color: [1,1,1], + translation: { + 'airport': [-24,-24], + 'vor': [-24,-24] + } + }, + toggle_cstr: 0 }); var new = func(layer) { - var m = { - parents: [__self__], - layer: layer, - map: layer.map, - listeners: [], - }; - layer.searcher._equals = func(a,b) a.equals(b); - var driver = opt_member(m.layer.options, 'route_driver'); - if(driver == nil){ - driver = RouteDriver.new(); - } - var driver_listeners = driver.getListeners(); - foreach(var listener; driver_listeners){ - append(m.listeners, setlistener(listener, func m.layer.update())); - } - m.route_driver = driver; - return m; + var m = { + parents: [__self__], + layer: layer, + map: layer.map, + listeners: [], + }; + layer.searcher._equals = func(a,b) a.equals(b); + var driver = opt_member(m.layer.options, 'route_driver'); + if(driver == nil){ + driver = RouteDriver.new(); + } + var driver_listeners = driver.getListeners(); + foreach(var listener; driver_listeners){ + append(m.listeners, setlistener(listener, func m.layer.update())); + } + m.route_driver = driver; + return m; }; var del = func() { - foreach (var l; me.listeners) - removelistener(l); + foreach (var l; me.listeners) + removelistener(l); }; var WPTModel = { - new: func(fp, idx) { - var m = { parents:[WPTModel] }; - var wp = fp.getWP(idx); + new: func(fp, idx) { + var m = { parents:[WPTModel] }; + var wp = fp.getWP(idx); - m.id = wp.id; - m.name = wp.wp_name; - m.alt = wp.alt_cstr; - m.spd = wp.speed_cstr; - m.type = wp.wp_type; + m.id = wp.id; + m.name = wp.wp_name; + m.alt = wp.alt_cstr; + m.spd = wp.speed_cstr; + m.type = wp.wp_type; - (m.lat,m.lon) = (wp.wp_lat,wp.wp_lon); - var is_rwy = (m.type == 'runway'); - var id_len = size(m.id); - if(!is_rwy and id_len < 5){ - if(id_len == 4 and airportinfo(m.id) != nil) - m.navtype = 'airport'; - else { - var navaid = nil; - foreach(var t; ['vor', 'ndb']){ - navaid = navinfo(m.lat, m.lon, t, m.id); - if(navaid != nil and size(navaid)){ - m.navtype = t; - break; - } - } - if(navaid == nil or !size(navaid)) m.navtype = 'fix'; - } - } else { - m.navtype = (is_rwy ? 'rwy' : 'fix'); - } - - m.wp = wp; - idx = wp.index; - m.idx = idx; - m.is_departure = (idx == 0 and is_rwy); - m.is_destination = (idx > 0 and is_rwy); - return m; - }, - equals: func(other) { - # this is set on symbol init, so use this for equality... - me.name == other.name and me.alt == other.alt and - me.type == other.type and me.idx == other.idx and - me.navtype == other.navtype - }, + (m.lat,m.lon) = (wp.wp_lat,wp.wp_lon); + var is_rwy = (m.type == 'runway'); + var id_len = size(m.id); + if(!is_rwy and id_len < 5){ + if(id_len == 4 and airportinfo(m.id) != nil) + m.navtype = 'airport'; + else { + var navaid = nil; + foreach(var t; ['vor', 'ndb']){ + navaid = navinfo(m.lat, m.lon, t, m.id); + if(navaid != nil and size(navaid)){ + m.navtype = t; + break; + } + } + if(navaid == nil or !size(navaid)) m.navtype = 'fix'; + } + } else { + m.navtype = (is_rwy ? 'rwy' : 'fix'); + } + + m.wp = wp; + idx = wp.index; + m.idx = idx; + m.is_departure = (idx == 0 and is_rwy); + m.is_destination = (idx > 0 and is_rwy); + return m; + }, + equals: func(other) { + # this is set on symbol init, so use this for equality... + me.name == other.name and me.alt == other.alt and + me.type == other.type and me.idx == other.idx and + me.navtype == other.navtype + }, }; var searchCmd = func { - var driver = me.route_driver; - if(!driver.shouldUpdate()) return []; - driver.update(); - var result = []; - var planCount = driver.getNumberOfFlightPlans(); - for(var idx = 0; idx < planCount; idx += 1){ - var fp = driver.getFlightPlan(idx); - if(fp == nil) continue; - var fpSize = fp.getPlanSize(idx); - for (var i = 0; i < fpSize; i+=1){ - if(!driver.shouldUpdate()) return[]; - append(result, WPTModel.new(fp, i)); - } - } - return result; + var driver = me.route_driver; + if(!driver.shouldUpdate()) return []; + driver.update(); + var result = []; + var planCount = driver.getNumberOfFlightPlans(); + for(var idx = 0; idx < planCount; idx += 1){ + var fp = driver.getFlightPlan(idx); + if(fp == nil) continue; + var fpSize = fp.getPlanSize(idx); + for (var i = 0; i < fpSize; i+=1){ + if(!driver.shouldUpdate()) return[]; + append(result, WPTModel.new(fp, i)); + } + } + return result; } diff --git a/Models/Instruments/ND/canvas/map/WPT-airbus.symbol b/Models/Instruments/ND/canvas/map/WPT-airbus.symbol index 29f6fe26..439e8e1e 100644 --- a/Models/Instruments/ND/canvas/map/WPT-airbus.symbol +++ b/Models/Instruments/ND/canvas/map/WPT-airbus.symbol @@ -8,130 +8,130 @@ canvas.DotSym.makeinstance( name, __self__ ); var element_type = "group"; var init = func { - var name = me.model.name; - var alt = me.model.alt; - var spd = me.model.spd; - var wp_group = me.element; - me.alt_path = nil; + var name = me.model.name; + var alt = me.model.alt; + var spd = me.model.spd; + var wp_group = me.element; + me.alt_path = nil; - var colors = [ - 'wp_color', - 'current_wp_color', - 'constraint_color', - 'active_constraint_color', - 'missed_constraint_color' - ]; - foreach(col; colors){ - me[col] = me.getStyle(col, me.getOption(col)); - } + var colors = [ + 'wp_color', + 'current_wp_color', + 'constraint_color', + 'active_constraint_color', + 'missed_constraint_color' + ]; + foreach(col; colors){ + me[col] = me.getStyle(col, me.getOption(col)); + } - var idLen = size(me.model.id); - var draw_sym = nil; - var navtype = me.model.navtype; - if (navtype == nil) navtype = 'fix'; - if(navtype == 'airport') - draw_sym = me.options.airport_symbol; - elsif(navtype == 'vor') - draw_sym = me.options.vor_symbol; - elsif(navtype == 'ndb') - draw_sym = me.options.ndb_symbol; - else - draw_sym = me.options.fix_symbol; - me.wp_sym = me.element.createChild('group', 'wp-'~ me.model.idx); - if(typeof(draw_sym) == 'func') - draw_sym(me.wp_sym); - elsif(typeof(draw_sym) == 'scalar') - canvas.parsesvg(me.wp_sym, draw_sym); - var translation = me.getStyle('translation', {}); - if(contains(translation, navtype)){ - me.wp_sym.setTranslation(translation[navtype]); - } - me.text_wps = wp_group.createChild("text", "wp-text-" ~ me.model.idx) - .setDrawMode( canvas.Text.TEXT ) - .setText(me.model.name) - .setFont("LiberationFonts/LiberationSans-Regular.ttf") - .setFontSize(28) - .setTranslation(25,15) - .setColor(1,1,1); - me.text_alt = nil; - if(alt > 0 or spd > 0){ - var cstr_txt = "\n"; - if(alt > 0){ - if(alt > 10000) - cstr_txt ~= sprintf('FL%3.0f', int(alt / 100)); - else - cstr_txt ~= sprintf('%4.0f', int(alt)); - } - if(spd > 0){ - if(alt > 0) cstr_txt ~= "\n"; - if(spd <= 1) - cstr_txt ~= sprintf('%1.2fM', spd); - else - cstr_txt ~= sprintf('%3.0fKT', int(spd)); - } - me.text_alt = wp_group.createChild("text", "wp-alt-text-" ~ me.model.idx) - .setDrawMode( canvas.Text.TEXT ) - .setText(cstr_txt) - .setFont("LiberationFonts/LiberationSans-Regular.ttf") - .setFontSize(28) - .setTranslation(25,15); - } + var idLen = size(me.model.id); + var draw_sym = nil; + var navtype = me.model.navtype; + if (navtype == nil) navtype = 'fix'; + if(navtype == 'airport') + draw_sym = me.options.airport_symbol; + elsif(navtype == 'vor') + draw_sym = me.options.vor_symbol; + elsif(navtype == 'ndb') + draw_sym = me.options.ndb_symbol; + else + draw_sym = me.options.fix_symbol; + me.wp_sym = me.element.createChild('group', 'wp-'~ me.model.idx); + if(typeof(draw_sym) == 'func') + draw_sym(me.wp_sym); + elsif(typeof(draw_sym) == 'scalar') + canvas.parsesvg(me.wp_sym, draw_sym); + var translation = me.getStyle('translation', {}); + if(contains(translation, navtype)){ + me.wp_sym.setTranslation(translation[navtype]); + } + me.text_wps = wp_group.createChild("text", "wp-text-" ~ me.model.idx) + .setDrawMode( canvas.Text.TEXT ) + .setText(me.model.name) + .setFont("LiberationFonts/LiberationSans-Regular.ttf") + .setFontSize(28) + .setTranslation(25,15) + .setColor(1,1,1); + me.text_alt = nil; + if(alt > 0 or spd > 0){ + var cstr_txt = "\n"; + if(alt > 0){ + if(alt > 10000) + cstr_txt ~= sprintf('FL%3d', int(alt / 100)); + else + cstr_txt ~= sprintf('%4d', int(alt)); + } + if(spd > 0){ + if(alt > 0) cstr_txt ~= "\n"; + if(spd <= 1) + cstr_txt ~= sprintf('%4.2fM', spd); + else + cstr_txt ~= sprintf('%3dKT', int(spd)); + } + me.text_alt = wp_group.createChild("text", "wp-alt-text-" ~ me.model.idx) + .setDrawMode( canvas.Text.TEXT ) + .setText(cstr_txt) + .setFont("LiberationFonts/LiberationSans-Regular.ttf") + .setFontSize(28) + .setTranslation(25,15); + } } var draw = func{ - var wp_group = me.element; - var alt = me.model.alt; - var i = me.model.idx; - var vnav_actv = getprop(me.options.ver_ctrl) == me.options.managed_val; - var curwp = getprop(me.options.current_wp); - if(alt > 0){ - var wp_d = me.model.wp.distance_along_route; - var lvl_off_at = getprop(me.options.level_off_alt); - if(lvl_off_at == nil) lvl_off_at = 0; - if(me.alt_path == nil){ - me.alt_path = wp_group.createChild("path"). - setStrokeLineWidth(4). - moveTo(-22,0). - arcSmallCW(22,22,0,44,0). - arcSmallCW(22,22,0,-44,0); - } - if(vnav_actv){ - if(lvl_off_at and (lvl_off_at - wp_d) > 0.5 and curwp == i) - me.alt_path.setColor(me.missed_constraint_color); - else - me.alt_path.setColor(me.active_constraint_color); - } - else - me.alt_path.setColor(me.constraint_color); - if(me.layer.toggle_cstr) - me.alt_path.show(); - else - me.alt_path.hide(); - } else { - if(me.alt_path != nil) me.alt_path.hide(); - } - wp_group.set("z-index",4); - #var sym = me.element.getElementById('wp-' ~ me.model.idx); - if(alt > 0 and me.text_alt != nil){ - if(vnav_actv) - me.text_alt.setColor(me.active_constraint_color); - else - me.text_alt.setColor(me.constraint_color); - } - if(i == curwp) { - me.wp_sym.setColor(me.current_wp_color); - me.text_wps.setColor(me.current_wp_color); - } else { - me.wp_sym.setColor(me.wp_color); - me.text_wps.setColor(me.wp_color); - } - if(me.model.is_departure or me.model.is_destination){ - var prop = (me.model.is_departure ? 'departure' : 'destination'); - var rwy = getprop("/autopilot/route-manager/"~prop~"/runway"); - if(rwy != nil and size(rwy) > 0){ - me.wp_sym.hide(); - } else { - me.wp_sym.show(); - } - } + var wp_group = me.element; + var alt = me.model.alt; + var i = me.model.idx; + var vnav_actv = getprop(me.options.ver_ctrl) == me.options.managed_val; + var curwp = getprop(me.options.current_wp); + if(alt > 0){ + var wp_d = me.model.wp.distance_along_route; + var lvl_off_at = getprop(me.options.level_off_alt); + if(lvl_off_at == nil) lvl_off_at = 0; + if(me.alt_path == nil){ + me.alt_path = wp_group.createChild("path"). + setStrokeLineWidth(4). + moveTo(-22,0). + arcSmallCW(22,22,0,44,0). + arcSmallCW(22,22,0,-44,0); + } + if(vnav_actv){ + if(lvl_off_at and (lvl_off_at - wp_d) > 0.5 and curwp == i) + me.alt_path.setColor(me.missed_constraint_color); + else + me.alt_path.setColor(me.active_constraint_color); + } + else + me.alt_path.setColor(me.constraint_color); + if(me.layer.toggle_cstr) + me.alt_path.show(); + else + me.alt_path.hide(); + } else { + if(me.alt_path != nil) me.alt_path.hide(); + } + wp_group.set("z-index",4); + #var sym = me.element.getElementById('wp-' ~ me.model.idx); + if(alt > 0 and me.text_alt != nil){ + if(vnav_actv) + me.text_alt.setColor(me.active_constraint_color); + else + me.text_alt.setColor(me.constraint_color); + } + if(i == curwp) { + me.wp_sym.setColor(me.current_wp_color); + me.text_wps.setColor(me.current_wp_color); + } else { + me.wp_sym.setColor(me.wp_color); + me.text_wps.setColor(me.wp_color); + } + if(me.model.is_departure or me.model.is_destination){ + var prop = (me.model.is_departure ? 'departure' : 'destination'); + var rwy = getprop("/autopilot/route-manager/"~prop~"/runway"); + if(rwy != nil and size(rwy) > 0){ + me.wp_sym.hide(); + } else { + me.wp_sym.show(); + } + } } diff --git a/Models/Instruments/ND/canvas/style.nas b/Models/Instruments/ND/canvas/style.nas index 7c452162..25d6a4f0 100644 --- a/Models/Instruments/ND/canvas/style.nas +++ b/Models/Instruments/ND/canvas/style.nas @@ -46,12 +46,12 @@ canvas.NDStyles["Airbus"] = { # that the lateral flight mode is managed. # You can easily override these options before creating the ND, example: # canvas.NDStyles["Airbus"].options.defaults.fplan_active = "my/autpilot/f-plan/active" - fplan_active: "autopilot/route-manager/active", + fplan_active: "/FMGC/flightplan[2]/active", lat_ctrl: "/it-autoflight/output/lat", managed_val: 1, ver_ctrl: "/it-autoflight/output/vert", spd_ctrl: "/flight-management/control/spd-ctrl", - current_wp: "/autopilot/route-manager/current-wp", + current_wp: "/FMGC/flightplan[2]/current-wp", ap1: "/it-autoflight/output/ap1", ap2: "/it-autoflight/output/ap2", nav1_frq: "/instrumentation/nav[0]/frequencies/selected-mhz", @@ -740,11 +740,11 @@ canvas.NDStyles["Airbus"] = { id: "wpActiveId", impl: { init: func(nd,symbol), - predicate: func(nd) getprop("/autopilot/route-manager/wp/id") != nil and - getprop("autopilot/route-manager/active") and + predicate: func(nd) getprop("/FMGC/flightplan[2]/current-leg") != nil and + getprop("FMGC/flightplan[2]/active") and nd.in_mode("toggle_display_mode", ["MAP", "PLAN"]), is_true: func(nd) { - nd.symbols.wpActiveId.setText(getprop("/autopilot/route-manager/wp/id")); + nd.symbols.wpActiveId.setText(getprop("/FMGC/flightplan[2]/current-leg")); nd.symbols.wpActiveId.show(); }, is_false: func(nd) nd.symbols.wpActiveId.hide(), @@ -754,12 +754,16 @@ canvas.NDStyles["Airbus"] = { id: "wpActiveCrs", impl: { init: func(nd,symbol), - predicate: func(nd) getprop("/autopilot/route-manager/wp/id") != nil and - getprop("autopilot/route-manager/active") and + predicate: func(nd) getprop("/FMGC/flightplan[2]/current-leg") != nil and + getprop("FMGC/flightplan[2]/active") and nd.in_mode("toggle_display_mode", ["MAP", "PLAN"]), is_true: func(nd) { #var cur_wp = getprop("autopilot/route-manager/current-wp"); - var deg = int(getprop("/autopilot/route-manager/wp/bearing-deg")); + if (nd.get_switch("toggle_true_north")) { + var deg = math.round(getprop("/FMGC/flightplan[2]/current-leg-course")); + } else { + var deg = math.round(getprop("/FMGC/flightplan[2]/current-leg-course-mag")); + } nd.symbols.wpActiveCrs.setText((deg or "")~"°"); nd.symbols.wpActiveCrs.show(); }, @@ -770,11 +774,11 @@ canvas.NDStyles["Airbus"] = { id: "wpActiveDist", impl: { init: func(nd,symbol), - predicate: func(nd) getprop("/autopilot/route-manager/wp/dist") != nil and - getprop("autopilot/route-manager/active") and + predicate: func(nd) getprop("/FMGC/flightplan[2]/current-leg-dist") != nil and + getprop("FMGC/flightplan[2]/active") and nd.in_mode("toggle_display_mode", ["MAP", "PLAN"]), is_true: func(nd) { - var dst = getprop("/autopilot/route-manager/wp/dist"); + var dst = getprop("/FMGC/flightplan[2]/current-leg-dist"); nd.symbols.wpActiveDist.setText(sprintf("%3.01f",dst)); nd.symbols.wpActiveDist.show(); }, @@ -785,10 +789,10 @@ canvas.NDStyles["Airbus"] = { id: "wpActiveDistLbl", impl: { init: func(nd,symbol), - predicate: func(nd) getprop("/autopilot/route-manager/wp/dist") != nil and getprop("autopilot/route-manager/active") and nd.in_mode("toggle_display_mode", ["MAP", "PLAN"]), + predicate: func(nd) getprop("/FMGC/flightplan[2]/current-leg-dist") != nil and getprop("FMGC/flightplan[2]/active") and nd.in_mode("toggle_display_mode", ["MAP", "PLAN"]), is_true: func(nd) { nd.symbols.wpActiveDistLbl.show(); - if(getprop("/autopilot/route-manager/wp/dist") > 1000) + if(getprop("/FMGC/flightplan[2]/current-leg-dist") > 1000) nd.symbols.wpActiveDistLbl.setText(" NM"); }, is_false: func(nd) nd.symbols.wpActiveDistLbl.hide(), @@ -798,7 +802,7 @@ canvas.NDStyles["Airbus"] = { id: "eta", impl: { init: func(nd,symbol), - predicate: func(nd) getprop("autopilot/route-manager/wp/eta") != nil and getprop("autopilot/route-manager/active") and nd.in_mode("toggle_display_mode", ["MAP", "PLAN"]), + predicate: func(nd) getprop("autopilot/route-manager/wp/eta") != nil and getprop("FMGC/flightplan[2]/active") and nd.in_mode("toggle_display_mode", ["MAP", "PLAN"]), is_true: func(nd) { var etaSec = getprop("/sim/time/utc/day-seconds")+ getprop("autopilot/route-manager/wp/eta-seconds"); @@ -1679,7 +1683,7 @@ canvas.NDStyles["Airbus"] = { init: func(nd,symbol), predicate: func(nd) (nd.get_switch("toggle_display_mode") == "MAP" and !nd.get_switch("toggle_centered")), is_true: func(nd){ - var active = getprop("autopilot/route-manager/active"); + var active = getprop("FMGC/flightplan[2]/active"); var lat_ctrl = getprop(nd.options.defaults.lat_ctrl); var managed_v = nd.options.defaults.managed_val; var is_managed = (lat_ctrl == managed_v); @@ -1708,7 +1712,7 @@ canvas.NDStyles["Airbus"] = { init: func(nd,symbol), predicate: func(nd) (nd.get_switch("toggle_display_mode") == "MAP" and !nd.get_switch("toggle_centered")), is_true: func(nd){ - var active = getprop("autopilot/route-manager/active"); + var active = getprop("FMGC/flightplan[2]/active"); var lat_ctrl = getprop(nd.options.defaults.lat_ctrl); var managed_v = nd.options.defaults.managed_val; var is_managed = (lat_ctrl == managed_v); @@ -1737,7 +1741,7 @@ canvas.NDStyles["Airbus"] = { init: func(nd,symbol), predicate: func(nd) (nd.get_switch("toggle_display_mode") == "MAP" and nd.get_switch("toggle_centered")), is_true: func(nd){ - var active = getprop("autopilot/route-manager/active"); + var active = getprop("FMGC/flightplan[2]/active"); var lat_ctrl = getprop(nd.options.defaults.lat_ctrl); var managed_v = nd.options.defaults.managed_val; var is_managed = (lat_ctrl == managed_v); @@ -1766,7 +1770,7 @@ canvas.NDStyles["Airbus"] = { init: func(nd,symbol), predicate: func(nd) (nd.get_switch("toggle_display_mode") == "MAP" and nd.get_switch("toggle_centered")), is_true: func(nd){ - var active = getprop("autopilot/route-manager/active"); + var active = getprop("FMGC/flightplan[2]/active"); var lat_ctrl = getprop(nd.options.defaults.lat_ctrl); var managed_v = nd.options.defaults.managed_val; var is_managed = (lat_ctrl == managed_v); @@ -1795,7 +1799,7 @@ canvas.NDStyles["Airbus"] = { init: func(nd,symbol), predicate: func(nd) (nd.in_mode("toggle_display_mode", ["MAP", "PLAN"])), is_true: func(nd){ - var active = getprop("autopilot/route-manager/active"); + var active = getprop("FMGC/flightplan[2]/active"); var lat_ctrl = getprop(nd.options.defaults.lat_ctrl); var managed_v = nd.options.defaults.managed_val; var is_managed = (lat_ctrl == managed_v); diff --git a/Nasal/FMGC/FMGC-b.nas b/Nasal/FMGC/FMGC-b.nas index f7b8be0e..a8817970 100644 --- a/Nasal/FMGC/FMGC-b.nas +++ b/Nasal/FMGC/FMGC-b.nas @@ -48,10 +48,10 @@ var Radio = { }; var FPLN = { - active: props.globals.getNode("/autopilot/route-manager/active", 1), + active: props.globals.getNode("/FMGC/flightplan[2]/active", 1), activeTemp: 0, currentCourse: 0, - currentWP: props.globals.getNode("/autopilot/route-manager/current-wp", 1), + currentWP: props.globals.getNode("/FMGC/flightplan[2]/current-wp", 1), currentWPTemp: 0, deltaAngle: 0, deltaAngleRad: 0, @@ -59,12 +59,12 @@ var FPLN = { maxBank: 0, maxBankLimit: 0, nextCourse: 0, - num: props.globals.getNode("/autopilot/route-manager/route/num", 1), + num: props.globals.getNode("/FMGC/flightplan[2]/num", 1), numTemp: 0, R: 0, radius: 0, turnDist: 0, - wp0Dist: props.globals.getNode("/autopilot/route-manager/wp/dist", 1), + wp0Dist: props.globals.getNode("/FMGC/flightplan[2]/current-leg-dist", 1), wpFlyFrom: 0, wpFlyTo: 0, }; @@ -406,12 +406,12 @@ var ITAF = { if (FPLN.wpFlyFrom < 0) { FPLN.wpFlyFrom = 0; } - FPLN.currentCourse = getprop("/autopilot/route-manager/route/wp[" ~ FPLN.wpFlyFrom ~ "]/leg-bearing-true-deg"); # Best left at getprop + FPLN.currentCourse = getprop("/FMGC/flightplan[2]/wp[" ~ FPLN.wpFlyFrom ~ "]/course"); # Best left at getprop FPLN.wpFlyTo = FPLN.currentWPTemp + 1; if (FPLN.wpFlyTo < 0) { FPLN.wpFlyTo = 0; } - FPLN.nextCourse = getprop("/autopilot/route-manager/route/wp[" ~ FPLN.wpFlyTo ~ "]/leg-bearing-true-deg"); # Best left at getprop + FPLN.nextCourse = getprop("/FMGC/flightplan[2]/wp[" ~ FPLN.wpFlyTo ~ "]/course"); # Best left at getprop FPLN.maxBankLimit = Internal.bankLimit.getValue(); FPLN.deltaAngle = math.abs(geo.normdeg180(FPLN.currentCourse - FPLN.nextCourse)); @@ -433,7 +433,11 @@ var ITAF = { Internal.lnavAdvanceNm.setValue(FPLN.turnDist); if (FPLN.wp0Dist.getValue() <= FPLN.turnDist) { - FPLN.currentWP.setValue(FPLN.currentWPTemp + 1); + if (currentWP[2] < 1) { + currentWP[2] = 1; + } else if (num_out[2].getValue() > 2) { # The Airbus doesn't display anything past the previous waypoint after advancing + flightplan.advanceDelete(2); + } } } } @@ -649,7 +653,10 @@ var ITAF = { Text.vert.setValue("ALT CAP"); } else if (n == 4) { # FLCH Output.apprArm.setBoolValue(0); - if (abs(Input.altDiff) >= 125) { # SPD CLB or SPD DES + Output.vert.setValue(1); + Internal.alt.setValue(Input.alt.getValue()); + Internal.altDiff = Internal.alt.getValue() - Position.indicatedAltitudeFt.getValue(); + if (abs(Internal.altDiff) >= 250) { # SPD CLB or SPD DES if (Input.alt.getValue() >= Position.indicatedAltitudeFt.getValue()) { # Usually set Thrust Mode Selector, but we do it now due to timer lag Text.vert.setValue("SPD CLB"); } else { diff --git a/Nasal/FMGC/FMGC.nas b/Nasal/FMGC/FMGC.nas index 8b983ef8..a01452ea 100644 --- a/Nasal/FMGC/FMGC.nas +++ b/Nasal/FMGC/FMGC.nas @@ -148,24 +148,6 @@ var trimReset = func { } } -############### -# MCDU Inputs # -############### - -var updateARPT = func { - dep = getprop("/FMGC/internal/dep-arpt"); - arr = getprop("/FMGC/internal/arr-arpt"); - setprop("/autopilot/route-manager/departure/airport", dep); - setprop("/autopilot/route-manager/destination/airport", arr); - 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")); -}); - ############################ # Flight Phase and Various # ############################ @@ -248,7 +230,7 @@ var masterFMGC = maketimer(0.2, func { setprop("/FMGC/status/phase", "5"); } - if (getprop("/autopilot/route-manager/route/num") > 0 and getprop("/autopilot/route-manager/active") == 1 and getprop("/autopilot/route-manager/distance-remaining-nm") <= 15) { + if (getprop("/FMGC/flightplan[2]/num") > 0 and getprop("/FMGC/flightplan[2]/active") == 1 and getprop("/FMGC/flightplan[2]/arrival-leg-dist") <= 15) { setprop("/FMGC/internal/decel", 1); } else if (getprop("/FMGC/internal/decel") == 1 and (phase == 0 or phase == 6)) { setprop("/FMGC/internal/decel", 0); @@ -302,6 +284,7 @@ var reset_FMGC = func { alt = getprop("/it-autoflight/input/alt"); ITAF.init(); FMGCinit(); + flightplan.reset(); mcdu.MCDU_reset(0); mcdu.MCDU_reset(1); setprop("/it-autoflight/input/fd1", fd1); diff --git a/Nasal/FMGC/flightplan.nas b/Nasal/FMGC/flightplan.nas new file mode 100644 index 00000000..19d9a7a8 --- /dev/null +++ b/Nasal/FMGC/flightplan.nas @@ -0,0 +1,314 @@ +# A3XX FMGC Flightplan Driver + +# Copyright (c) 2019 Joshua Davidson (Octal450) +# This thing replaces the Route Manager, it's far from finished though + +# 0 = TEMP FP Captain MCDU +# 1 = TEMP FP First Officer MCDU +# 2 = ACTIVE FP +var fp = [createFlightplan(), createFlightplan(), createFlightplan()]; +var wpDep = nil; +var wpArr = nil; +var pos = nil; +var geoPos = nil; +var geoPosPrev = geo.Coord.new(); +var currentLegCourseDist = nil; +var courseDistanceFrom = nil; +var courseDistanceFromPrev = nil; +var sizeWP = nil; +var magTrueError = 0; +var arrivalAirportI = [0, 0, 0]; + +# Vars for MultiFlightplan +var currentWP = [nil, nil, 0]; +var currentLeg = [nil, nil, ""]; + +# Create/Fetch props.nas for MultiFlightplan +var altFeet = props.globals.getNode("/instrumentation/altimeter/indicated-altitude-ft", 1); +var active_out = [nil, nil, props.globals.initNode("/FMGC/flightplan[2]/active", 0, "BOOL")]; +var currentWP_out = [nil, nil, props.globals.initNode("/FMGC/flightplan[2]/current-wp", 0, "INT")]; +var currentLeg_out = [nil, nil, props.globals.initNode("/FMGC/flightplan[2]/current-leg", "", "STRING")]; +var currentLegCourse_out = [nil, nil, props.globals.initNode("/FMGC/flightplan[2]/current-leg-course", 0, "DOUBLE")]; +var currentLegDist_out = [nil, nil, props.globals.initNode("/FMGC/flightplan[2]/current-leg-dist", 0, "DOUBLE")]; +var currentLegCourseMag_out = [nil, nil, props.globals.initNode("/FMGC/flightplan[2]/current-leg-course-mag", 0, "DOUBLE")]; +var arrivalLegDist_out = [props.globals.initNode("/FMGC/flightplan[0]/arrival-leg-dist", 0, "DOUBLE"), props.globals.initNode("/FMGC/flightplan[1]/arrival-leg-dist", 0, "DOUBLE"), props.globals.initNode("/FMGC/flightplan[2]/arrival-leg-dist", 0, "DOUBLE")]; +var num_out = [props.globals.initNode("/FMGC/flightplan[0]/num", 0, "INT"), props.globals.initNode("/FMGC/flightplan[1]/num", 0, "INT"), props.globals.initNode("/FMGC/flightplan[2]/num", 0, "INT")]; +var toFromSet = props.globals.initNode("/FMGC/internal/tofrom-set", 0, "BOOL"); +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 TMPYActive = [props.globals.initNode("/FMGC/internal/tmpy-active[0]", 0, "BOOL"), props.globals.initNode("/FMGC/internal/tmpy-active[1]", 0, "BOOL")]; + +# Create props.nas for flightplan +# Vectors inside vectors, so we can use as many flightplans or waypoints as we want +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")]]; +var wpLat = [[props.globals.initNode("/FMGC/flightplan[0]/wp[0]/lat", 0, "DOUBLE")], [props.globals.initNode("/FMGC/flightplan[1]/wp[0]/lat", 0, "DOUBLE")], [props.globals.initNode("/FMGC/flightplan[2]/wp[0]/lat", 0, "DOUBLE")]]; +var wpLon = [[props.globals.initNode("/FMGC/flightplan[0]/wp[0]/lon", 0, "DOUBLE")], [props.globals.initNode("/FMGC/flightplan[1]/wp[0]/lon", 0, "DOUBLE")], [props.globals.initNode("/FMGC/flightplan[2]/wp[0]/lon", 0, "DOUBLE")]]; +var wpCourse = [[props.globals.initNode("/FMGC/flightplan[0]/wp[0]/course", 0, "DOUBLE")], [props.globals.initNode("/FMGC/flightplan[1]/wp[0]/course", 0, "DOUBLE")], [props.globals.initNode("/FMGC/flightplan[2]/wp[0]/course", 0, "DOUBLE")]]; +var wpDistance = [[props.globals.initNode("/FMGC/flightplan[0]/wp[0]/distance", 0, "DOUBLE")], [props.globals.initNode("/FMGC/flightplan[1]/wp[0]/distance", 0, "DOUBLE")], [props.globals.initNode("/FMGC/flightplan[2]/wp[0]/distance", 0, "DOUBLE")]]; +var wpCoursePrev = [[props.globals.initNode("/FMGC/flightplan[0]/wp[0]/course-from-prev", 0, "DOUBLE")], [props.globals.initNode("/FMGC/flightplan[1]/wp[0]/course-from-prev", 0, "DOUBLE")], [props.globals.initNode("/FMGC/flightplan[2]/wp[0]/course-from-prev", 0, "DOUBLE")]]; +var wpDistancePrev = [[props.globals.initNode("/FMGC/flightplan[0]/wp[0]/distance-from-prev", 0, "DOUBLE")], [props.globals.initNode("/FMGC/flightplan[1]/wp[0]/distance-from-prev", 0, "DOUBLE")], [props.globals.initNode("/FMGC/flightplan[2]/wp[0]/distance-from-prev", 0, "DOUBLE")]]; + +var flightplan = { + reset: func() { + TMPYActive[0].setBoolValue(0); + TMPYActive[1].setBoolValue(0); + me.reset0(); + me.reset1(); + me.reset2(); + }, + reset0: func() { + fp[0].cleanPlan(); + fp[0].departure = nil; + fp[0].destination = nil; + }, + reset1: func() { + fp[1].cleanPlan(); + fp[1].departure = nil; + fp[1].destination = nil; + }, + reset2: func() { + fp[2].cleanPlan(); + fp[2].departure = nil; + fp[2].destination = nil; + currentWP[2] = 0; + currentLeg[2] = ""; + }, + initTempFP: func(f, n) { # f is temp, n is active + fp[f] = fp[n].clone(); + TMPYActive[f].setBoolValue(1); + me.checkWPOutputs(f); + }, + eraseTempFP: func(f, n) { # f is temp, n is active + TMPYActive[f].setBoolValue(0); + if (f == 0) { + me.reset0(); + } else if (f == 1) { + me.reset1(); + } + me.checkWPOutputs(n); + }, + executeTempFP: func(f, n) { # f is temp, n is active + fp[n] = fp[f].clone(); + TMPYActive[f].setBoolValue(0); + if (f == 0) { + me.reset0(); + } else if (f == 1) { + me.reset1(); + } + me.checkWPOutputs(n); + }, + advanceDelete: func(n) { + if (num_out[n].getValue() > 2) { + if (TMPYActive[0].getBoolValue() and wpID[0][0] == wpID[n][0]) { + me.deleteWP(0, 0); + } + if (TMPYActive[1].getBoolValue() and wpID[1][0] == wpID[n][0]) { + me.deleteWP(0, 1); + } + me.deleteWP(0, n, 1); + } + }, + updateARPT: func(dep, arr, n) { + if (n == 2) { # Which flightplan? + me.reset2(); + + # Set Departure ARPT + if (dep != nil) { + fp[2].departure = airportinfo(dep); + } else { + fp[2].departure = nil; + } + + # Set Arrival ARPT + if (arr != nil) { + fp[2].destination = airportinfo(arr); + } else { + fp[2].destination = nil; + } + + currentWP[2] = 0; + } + + me.checkWPOutputs(n); + }, + # return 1 will cause NOT IN DATABASE, return 2 will cause NOT ALLOWED + insertFix: func(wp, i, n) { + var pos = findFixesByID(wp); + if (i == 0) { + return 2; + } else if (pos != nil and size(pos) > 0) { + fp[n].insertWP(createWPFrom(pos[0]), i); + me.checkWPOutputs(n); + return 0; + } else { + return 1; + } + }, + insertArpt: func(wp, i, n) { + var pos = findAirportsByICAO(wp); + if (i == 0) { + return 2; + } else if (pos != nil and size(pos) > 0) { + fp[n].insertWP(createWPFrom(pos[0]), i); + me.checkWPOutputs(n); + return 0; + } else { + return 1; + } + }, + insertNavaid: func(nav, i, n) { + var pos = findNavaidsByID(nav); + if (i == 0) { + return 2; + } else if (pos != nil and size(pos) > 0) { + fp[n].insertWP(createWPFrom(pos[0]), i); + me.checkWPOutputs(n); + return 0; + } else { + return 1; + } + }, + insertPPOS: func(n) { + fp[n].insertWP(createWP(geo.aircraft_position(), "PPOS"), 0); + me.checkWPOutputs(n); + }, + insertTP: func(n) { + fp[n].insertWP(createWP(geo.aircraft_position(), "T/P"), 0); + me.checkWPOutputs(n); + }, + deleteWP: func(i, n, t) { + var wp = wpID[n][i].getValue(); + if (t == 1) { + fp[n].deleteWP(i); + me.outputProps(); # Make sure everything is updated before we update the MCDUs. + me.updateMCDUDriver(n); + canvas_nd.A3XXRouteDriver.triggerSignal("fp-removed"); + return 0; + } else { + if (i == 0) { + return 2; + } else if (fp[n].getPlanSize() > 2 and wp != FMGCdep.getValue() and wp != FMGCarr.getValue() and wp != "T/P" and wp != "PPOS") { + fp[n].deleteWP(i); + me.outputProps(); # Make sure everything is updated before we update the MCDUs. + me.updateMCDUDriver(n); + canvas_nd.A3XXRouteDriver.triggerSignal("fp-removed"); + return 0; + } else { + return 2; + } + } + }, + checkWPOutputs: func(n) { + sizeWP = size(wpID[n]); + for (var counter = sizeWP; counter < fp[n].getPlanSize(); counter += 1) { + append(wpID[n], props.globals.initNode("/FMGC/flightplan[" ~ n ~ "]/wp[" ~ counter ~ "]/id", "", "STRING")); + append(wpLat[n], props.globals.initNode("/FMGC/flightplan[" ~ n ~ "]/wp[" ~ counter ~ "]/lat", 0, "DOUBLE")); + append(wpLon[n], props.globals.initNode("/FMGC/flightplan[" ~ n ~ "]/wp[" ~ counter ~ "]/lon", 0, "DOUBLE")); + append(wpCourse[n], props.globals.initNode("/FMGC/flightplan[" ~ n ~ "]/wp[" ~ counter ~ "]/course", 0, "DOUBLE")); + append(wpDistance[n], props.globals.initNode("/FMGC/flightplan[" ~ n ~ "]/wp[" ~ counter ~ "]/distance", 0, "DOUBLE")); + append(wpCoursePrev[n], props.globals.initNode("/FMGC/flightplan[" ~ n ~ "]/wp[" ~ counter ~ "]/course-from-prev", 0, "DOUBLE")); + append(wpDistancePrev[n], props.globals.initNode("/FMGC/flightplan[" ~ n ~ "]/wp[" ~ counter ~ "]/distance-from-prev", 0, "DOUBLE")); + } + me.outputProps(); # Make sure everything is updated before we update the MCDUs. + me.updateMCDUDriver(n); + canvas_nd.A3XXRouteDriver.triggerSignal("fp-added"); # Update the NDs + }, + updateMCDUDriver: func(n) { + for (var i = 0; i < 2; i += 1) { # Update the 2 MCDUs + if (TMPYActive[i].getBoolValue()) { + mcdu.FPLNLines[i].replacePlan(i, mcdu.TMPY, mcdu.FPLNLines[i].index); + } else { + mcdu.FPLNLines[i].replacePlan(2, mcdu.MAIN, mcdu.FPLNLines[i].index); + } + } + }, + outputProps: func() { + geoPos = geo.aircraft_position(); + + for (var n = 0; n < 3; n += 1) { # Note: Some things don't get done for TMPY (0) hence all the if (n > 1) {} + if (((n == 0 and TMPYActive[0].getBoolValue()) or (n == 1 and TMPYActive[1].getBoolValue()) or n > 1) and toFromSet.getBoolValue() and fp[n].departure != nil and fp[n].destination != nil) { + if (n > 1) { + if (currentWP[n] > fp[n].getPlanSize()) { + currentWP[n] = fp[n].getPlanSize(); + } + + if (active_out[n].getBoolValue() != 1) { + active_out[n].setBoolValue(1); + } + + currentLeg[n] = fp[n].getWP(currentWP[n]).wp_name; + + if (currentLeg_out[n].getValue() != currentLeg[n]) { + currentLeg_out[n].setValue(currentLeg[n]); + } + + currentLegCourseDist = fp[n].getWP(currentWP[n]).courseAndDistanceFrom(geoPos); + currentLegCourse_out[n].setValue(currentLegCourseDist[0]); + currentLegDist_out[n].setValue(currentLegCourseDist[1]); + + magTrueError = magHDG.getValue() - trueHDG.getValue(); + currentLegCourseMag_out[n].setValue(currentLegCourseDist[0] + magTrueError); # Convert to Magnetic + } + + if (num_out[n].getValue() != fp[n].getPlanSize()) { + num_out[n].setValue(fp[n].getPlanSize()); + } + + for (var i = 0; i < fp[n].getPlanSize(); i += 1) { + wpID[n][i].setValue(fp[n].getWP(i).wp_name); + wpLat[n][i].setValue(fp[n].getWP(i).wp_lat); + wpLon[n][i].setValue(fp[n].getWP(i).wp_lon); + courseDistanceFrom = fp[n].getWP(i).courseAndDistanceFrom(geoPos); + wpCourse[n][i].setValue(courseDistanceFrom[0]); + wpDistance[n][i].setValue(courseDistanceFrom[1]); + + if (i > 0) { # Impossible to do from the first WP + geoPosPrev.set_latlon(fp[n].getWP(i - 1).lat, fp[n].getWP(i - 1).lon, altFeet.getValue() * 0.3048); + courseDistanceFromPrev = fp[n].getWP(i).courseAndDistanceFrom(geoPosPrev); + wpCoursePrev[n][i].setValue(courseDistanceFromPrev[0]); + wpDistancePrev[n][i].setValue(courseDistanceFromPrev[1]); + } else { # So if its the first WP, we just use current position instead + wpCoursePrev[n][i].setValue(courseDistanceFrom[0]); + wpDistancePrev[n][i].setValue(courseDistanceFrom[1]); + } + + if (wpID[n][i].getValue() == FMGCarr.getValue()) { + arrivalAirportI[n] = i; + } + } + + arrivalLegDist_out[n].setValue(wpDistance[n][arrivalAirportI[n]].getValue()); + } else { + if (n > 1) { + if (active_out[n].getBoolValue() != 0) { + active_out[n].setBoolValue(0); + } + + if (currentLeg_out[n].getValue() != "") { + currentLeg_out[n].setValue(""); + } + } + + if (num_out[n].getValue() != 0) { + num_out[n].setValue(0); + } + } + + if (n > 1) { + if (currentWP[n] != nil) { + if (currentWP_out[n].getValue() != currentWP[n]) { + currentWP_out[n].setValue(currentWP[n]); + } + } else { + if (currentWP_out[n].getValue() != 0) { + currentWP_out[n].setValue(0); + } + } + } + } + }, +}; + +var outputPropsTimer = maketimer(0.1, flightplan.outputProps); diff --git a/Nasal/MCDU/F-PLN.nas b/Nasal/MCDU/F-PLN.nas new file mode 100644 index 00000000..3e841584 --- /dev/null +++ b/Nasal/MCDU/F-PLN.nas @@ -0,0 +1,536 @@ +# Airbus A3XX FMGC MCDU Bridge + +# Copyright (c) 2019 Joshua Davidson (Octal450) and Nikolai V. Chr. (Necolatis) + +# Lowercase "g" is a degree symbol in the MCDU font. + +var TMPY = 5; +var MAIN = 6; +var debug = 0; # Set to 1 to check inner functionality +var insertReturn = nil; +var active_out = [nil, nil, props.globals.getNode("/FMGC/flightplan[2]/active")]; +var num_out = [props.globals.getNode("/FMGC/flightplan[0]/num"), props.globals.getNode("/FMGC/flightplan[1]/num"), props.globals.getNode("/FMGC/flightplan[2]/num")]; +var TMPYActive = [props.globals.getNode("/FMGC/internal/tmpy-active[0]"), props.globals.getNode("/FMGC/internal/tmpy-active[1]")]; + +var clearFPLNComputer = func { + FPLNLines[0].clear(); + FPLNLines[1].clear(); +} + +var StaticText = { + new: func(computer, type) { + var in = {parents:[StaticText]}; + in.type = type; + in.computer = computer; + return in; + }, + getText: func() { + if (me.type == "discontinuity") { + return "---F-PLN DISCONTINUITY--"; + } else if (me.type == "fplnEnd") { + return "------END OF F-PLN------"; + } else if (me.type == "altnFplnEnd") { + return "----END OF ALTN F-PLN---"; + } else if (me.type == "noAltnFpln") { + return "------NO ALTN F-PLN-----"; + } else if (me.type == "empty") { + return ""; + } + }, + getColor: func() { + return canvas_mcdu.WHITE; + }, + getSubText: func() { + return ""; + }, + type: nil, + pushButtonLeft: func() { + notAllowed(me.computer.mcdu); + }, + pushButtonRight: func() { + notAllowed(me.computer.mcdu); + }, +}; + +var FPLNText = { + new: func(computer, wp, dest, fp, wpIndex) { + var in = {parents:[FPLNText]}; + in.wp = wp; + in.dest = dest; + in.fp = fp; + in.index = wpIndex; + in.computer = computer; + return in; + }, + getText: func() { + return me.wp.wp_name; + }, + getColor: func(i) { + if (TMPYActive[i].getBoolValue()) { + if (me.dest) { + return canvas_mcdu.WHITE; + } else { + return canvas_mcdu.YELLOW; + } + } else { + if (me.dest) { + return canvas_mcdu.WHITE; + } else { + return canvas_mcdu.GREEN; + } + } + }, + getSubText: func(i) { + if (me.index == 0) { + return ""; + } else if (TMPYActive[i].getBoolValue()) { + if (fmgc.arrivalAirportI[i] == me.index) { + return "DEST"; + } else { + return "C" ~ sprintf("%03d", fmgc.wpCoursePrev[me.fp][me.index].getValue()) ~ "g"; + } + } else { + if (fmgc.arrivalAirportI[2] == me.index) { + return "DEST"; + } else { + return "C" ~ sprintf("%03d", fmgc.wpCoursePrev[me.fp][me.index].getValue()) ~ "g"; + } + } + }, + wp: nil, + pushButtonLeft: func() { + var scratchpad = getprop("/MCDU[" ~ me.computer.mcdu ~ "]/scratchpad"); + if (me.computer.lines == MAIN and scratchpad != "") { + fmgc.flightplan.initTempFP(me.computer.mcdu, 2); + } + if (scratchpad == "CLR") { + if (fmgc.flightplan.deleteWP(me.index, me.computer.mcdu, 0) != 0) { + notAllowed(me.computer.mcdu); + } else { + setprop("/MCDU[" ~ me.computer.mcdu ~ "]/scratchpad-msg", 0); + setprop("/MCDU[" ~ me.computer.mcdu ~ "]/scratchpad", ""); + } + } else { + if (size(scratchpad) == 5) { + var insertReturn = fmgc.flightplan.insertFix(scratchpad, me.index, me.computer.mcdu); + if (insertReturn == 2) { + notAllowed(me.computer.mcdu); + } else if (insertReturn == 1) { + notInDataBase(me.computer.mcdu); + } else { + setprop("/MCDU[" ~ me.computer.mcdu ~ "]/scratchpad", ""); + } + } else if (size(scratchpad) == 4) { + var insertReturn = fmgc.flightplan.insertArpt(scratchpad, me.index, me.computer.mcdu); + if (insertReturn == 2) { + notAllowed(me.computer.mcdu); + } else if (insertReturn == 1) { + notInDataBase(me.computer.mcdu); + } else { + setprop("/MCDU[" ~ me.computer.mcdu ~ "]/scratchpad", ""); + } + } else if (size(scratchpad) == 3 or size(scratchpad) == 2) { + var insertReturn = fmgc.flightplan.insertNavaid(scratchpad, me.index, me.computer.mcdu); + if (insertReturn == 2) { + notAllowed(me.computer.mcdu); + } else if (insertReturn == 1) { + notInDataBase(me.computer.mcdu); + } else { + setprop("/MCDU[" ~ me.computer.mcdu ~ "]/scratchpad", ""); + } + } else if (size(scratchpad) == 1) { + formatError(me.computer.mcdu); + } else { + if (me.getText() == fmgc.fp[2].departure.id) { + if (canvas_mcdu.myLatRev != nil) { + canvas_mcdu.myLatRev.del(); + } + canvas_mcdu.myLatRev = nil; + canvas_mcdu.myLatRev = latRev.new(0, me.getText()); + } elsif (me.index == fmgc.arrivalAirportI[2]) { + if (canvas_mcdu.myLatRev != nil) { + canvas_mcdu.myLatRev.del(); + } + canvas_mcdu.myLatRev = nil; + canvas_mcdu.myLatRev = latRev.new(1, me.getText()); + } elsif (me.index == fmgc.currentWP[2]) { + if (canvas_mcdu.myLatRev != nil) { + canvas_mcdu.myLatRev.del(); + } + canvas_mcdu.myLatRev = nil; + canvas_mcdu.myLatRev = latRev.new(2, me.getText()); + } else { + if (canvas_mcdu.myLatRev != nil) { + canvas_mcdu.myLatRev.del(); + } + canvas_mcdu.myLatRev = nil; + canvas_mcdu.myLatRev = latRev.new(3, me.getText()); + } + setprop("/MCDU[" ~ me.computer.mcdu ~ "]/page", "LATREV"); + } + } + }, + pushButtonRight: func() { + notAllowed(me.computer.mcdu); + }, +}; + +var FPLNLineComputer = { + new: func(mcdu) { + var in = {parents:[FPLNLineComputer]}; + in.mcdu = mcdu; + in.planEnd = StaticText.new(in, "fplnEnd"); + in.planNoAlt = StaticText.new(in, "noAltnFpln"); + if (debug == 1) printf("%d: Line computer created.", in.mcdu); + return in; + }, + index: 0, + planList: [], + destination: nil, + destIndex: nil, + planEnd: nil, + planNoAlt: nil, + lines: nil, + output: [], + mcdu: nil, + fplnID: nil, + enableScroll: 0, + clear: func() { + me.planList = []; + me.destIndex = -1; + me.destination = nil; + me.index = 0; + me.output = []; + me.enableScroll = 0; + if (me.lines == nil) { + me.lines = MAIN; + } + me.updateScroll(); + }, + replacePlan: func(fplnID, lines, firstLineIndex) { + # Here you set another plan, do this when changing plan on display or when destination changes + if (debug == 1) printf("%d: replacePlan called for %d lines and firstLine %d", me.mcdu, lines, firstLineIndex); + var fpln = nil; + + me.planList = []; + + if (!fmgc.active_out[2].getBoolValue()) { + me.destIndex = -1; + me.destination = nil; + } else { + fpln = fmgc.fp[fplnID]; # Get the Nasal Flightplan + me.destIndex = fmgc.arrivalAirportI[fplnID]; + me.destination = FPLNText.new(me, fpln.getWP(me.destIndex), 1, fplnID, me.destIndex); + for (var j = 0; j < fpln.getPlanSize(); j += 1) { + me.dest = 0; + if (j == me.destIndex) { + me.dest = 1; + } + append(me.planList, FPLNText.new(me, fpln.getWP(j), me.dest, fplnID, j)); + } + if (debug == 1) printf("%d: dest is: %s", me.mcdu, fpln.getWP(me.destIndex).wp_name); + } + me.index = firstLineIndex; + me.lines = lines; + me.initScroll(); + }, + initScroll: func() { + me.maxItems = size(me.planList) + 2; # + 2 is for end of plan line and altn end of plan. + me.enableScroll = me.lines < me.maxItems; + me.checkIndex(); + if (debug == 1) printf("%d: scroll is %d. Size of plan is %d", me.mcdu, me.enableScroll, size(me.planList)); + me.updateScroll(); + }, + checkIndex: func() { + if (!me.enableScroll) { + me.index = 0; + if (debug == 1) printf("%d: index forced to 0",me.mcdu); + } elsif (me.index > size(me.planList) + 2 - me.lines) { + me.index = size(me.planList) + 2 - me.lines; + if (debug == 1) printf("%d: index forced to %d",me.mcdu,me.index); + } + }, + scrollDown: func() { # Scroll Up in Thales Manual + if (debug == 1) printf("%d: scroll down", me.mcdu); + me.extra = 1; + if (!me.enableScroll) { + me.index = 0; + } else { + me.index += 1; + if (me.index > size(me.planList) + 2 - me.lines) { + me.index = 0; + } + } + me.updateScroll(); + }, + scrollUp: func() { # Scroll Down in Thales Manual + if (debug == 1) printf("%d: scroll up", me.mcdu); + me.extra = 1; + if (!me.enableScroll) { + me.index = 0; + } else { + me.index -= 1; + if (me.index < 0) { + me.index = size(me.planList) + 2 - me.lines; + } + } + me.updateScroll(); + }, + updateScroll: func() { + me.output = []; + if (me.index <= size(me.planList) + 1) { + var i = 0; + me.realIndex = me.index - 1; + if (debug == 1) printf("%d: updating display from index %d", me.mcdu, me.realIndex); + for (i = me.index; i < math.min(size(me.planList), me.index + 5); i += 1) { + append(me.output, me.planList[i]); + me.realIndex = i; + } + if (debug == 1) printf("%d: populated until wp index %d", me.mcdu,me.realIndex); + if (me.realIndex < me.destIndex and me.lines == MAIN) { + # Destination has not been shown yet, now its time (if we show 6 lines) + append(me.output, me.destination); + if (debug == 1) printf("%d: added dest at bottom for total of %d lines", me.mcdu, size(me.output)); + return; + } else if (size(me.output) < me.lines) { + for (i = me.realIndex + 1; size(me.output) < me.lines and i < size(me.planList); i += 1) { + append(me.output, me.planList[i]); + me.realIndex = i; + } + if (debug == 1) printf("%d: populated after until wp index %d", me.mcdu,me.realIndex); + if (size(me.output) < me.lines) { + if (me.realIndex == size(me.planList)-1) { + # Show the end of plan + append(me.output, me.planEnd); + me.realIndex += 1; + if (debug == 1) printf("%d: added end, wp index=%d", me.mcdu, me.realIndex); + } + if (size(me.output) < me.lines and (me.realIndex == size(me.planList))) { + append(me.output, me.planNoAlt); + me.realIndex += 1; + if (debug == 1) printf("%d: added no-alt, wp index=%d", me.mcdu,me.realIndex); + if (me.enableScroll and size(me.output) < me.lines) { + # We start wrapping + for (var j = 0; size(me.output) < me.lines; j += 1) { + append(me.output, me.planList[j]); + } + } + } + } + } + } + while (size(me.output) < me.lines) { + append(me.output, StaticText.new(me, "empty")); + } + if (debug == 1) printf("%d: %d lines", me.mcdu, size(me.output)); + }, +}; + +var FPLNLines = [FPLNLineComputer.new(0), FPLNLineComputer.new(1)]; +clearFPLNComputer(); # Just in case, we have it in the clear state. + +var slewFPLN = func(d, i) { # Scrolling function. d is -1 or 1 for direction, and i is instance. + if (d == 1) { + FPLNLines[i].scrollDown(); # Scroll Up in Thales Manual + } else if (d == -1) { + FPLNLines[i].scrollUp(); # Scroll Down in Thales Manual + } +} + +# Button and Inputs +var FPLNButton = func(s, key, i) { + var scratchpad = getprop("/MCDU[" ~ i ~ "]/scratchpad"); + if (s == "L") { + if (key == 6 and TMPYActive[i].getBoolValue()) { + fmgc.flightplan.eraseTempFP(i, 2); + } else { + if (size(FPLNLines[i].output) >= key) { + FPLNLines[i].output[key - 1].pushButtonLeft(); + } + } + } else if (s == "R") { + if (key == 6 and TMPYActive[i].getBoolValue()) { + fmgc.flightplan.executeTempFP(i, 2); + } else { +# if (scratchpad != "") { +# if (size(FPLNLines[i].output) >= key) { +# FPLNLines[i].output[key - 1].pushButtonRight(); +# } +# } else { + notAllowed(i); # Remove when has functionality + # FIXME: Add VERT REV Logic +# } + } + } +} + +var notInDataBase = func(i) { + if (getprop("/MCDU[" ~ i ~ "]/scratchpad-msg") == 1) { # Messages clear after NOT IN DATABASE + setprop("/MCDU[" ~ i ~ "]/last-scratchpad", "NOT IN DATABASE"); + } else { + setprop("/MCDU[" ~ i ~ "]/last-scratchpad", getprop("/MCDU[" ~ i ~ "]/scratchpad")); + } + setprop("/MCDU[" ~ i ~ "]/scratchpad-msg", 1); + setprop("/MCDU[" ~ i ~ "]/scratchpad", "NOT IN DATABASE"); +} + +# For testing purposes only -- do not touch! +var test = func { + var fp = createFlightplan(getprop("sim/aircraft-dir")~"/plan.gpx"); + var desti = int(fp.getPlanSize()*0.5); + FPLNLines[0].replacePlan(fp,6,desti,0); + print("Display:"); + foreach(line;FPLNLines[0].output) { + printf("line: %s",line.getText()); + } + print("down");FPLNLines[0].scrollDown(); + foreach(line;FPLNLines[0].output) { + printf("line: %s",line.getText()); + } + print("down");FPLNLines[0].scrollDown(); + foreach(line;FPLNLines[0].output) { + printf("line: %s",line.getText()); + } + print("down");FPLNLines[0].scrollDown(); + foreach(line;FPLNLines[0].output) { + printf("line: %s",line.getText()); + } + print("down");FPLNLines[0].scrollDown(); + foreach(line;FPLNLines[0].output) { + printf("line: %s",line.getText()); + } + print("down");FPLNLines[0].scrollDown(); + foreach(line;FPLNLines[0].output) { + printf("line: %s",line.getText()); + } + print("down");FPLNLines[0].scrollDown(); + foreach(line;FPLNLines[0].output) { + printf("line: %s",line.getText()); + } + print("down");FPLNLines[0].scrollDown(); + foreach(line;FPLNLines[0].output) { + printf("line: %s",line.getText()); + } + print("down");FPLNLines[0].scrollDown(); + foreach(line;FPLNLines[0].output) { + printf("line: %s",line.getText()); + } + print("down");FPLNLines[0].scrollDown(); + foreach(line;FPLNLines[0].output) { + printf("line: %s",line.getText()); + } + print("down");FPLNLines[0].scrollDown(); + foreach(line;FPLNLines[0].output) { + printf("line: %s",line.getText()); + } + print("down");FPLNLines[0].scrollDown(); + foreach(line;FPLNLines[0].output) { + printf("line: %s",line.getText()); + } + print("down");FPLNLines[0].scrollDown(); + foreach(line;FPLNLines[0].output) { + printf("line: %s",line.getText()); + } + print("down");FPLNLines[0].scrollDown(); + foreach(line;FPLNLines[0].output) { + printf("line: %s",line.getText()); + } + print("down");FPLNLines[0].scrollDown(); + foreach(line;FPLNLines[0].output) { + printf("line: %s",line.getText()); + } + print("down");FPLNLines[0].scrollDown(); + foreach(line;FPLNLines[0].output) { + printf("line: %s",line.getText()); + } + print("down");FPLNLines[0].scrollDown(); + foreach(line;FPLNLines[0].output) { + printf("line: %s",line.getText()); + } + print("down");FPLNLines[0].scrollDown(); + foreach(line;FPLNLines[0].output) { + printf("line: %s",line.getText()); + } + print("down");FPLNLines[0].scrollDown(); + foreach(line;FPLNLines[0].output) { + printf("line: %s",line.getText()); + } + print("down");FPLNLines[0].scrollDown(); + foreach(line;FPLNLines[0].output) { + printf("line: %s",line.getText()); + } + print("down");FPLNLines[0].scrollDown(); + foreach(line;FPLNLines[0].output) { + printf("line: %s",line.getText()); + } + print("down");FPLNLines[0].scrollDown(); + foreach(line;FPLNLines[0].output) { + printf("line: %s",line.getText()); + } + print("down");FPLNLines[0].scrollDown(); + foreach(line;FPLNLines[0].output) { + printf("line: %s",line.getText()); + } + print("down");FPLNLines[0].scrollDown(); + foreach(line;FPLNLines[0].output) { + printf("line: %s",line.getText()); + } + print("down");FPLNLines[0].scrollDown(); + foreach(line;FPLNLines[0].output) { + printf("line: %s",line.getText()); + } + print("down");FPLNLines[0].scrollDown(); + foreach(line;FPLNLines[0].output) { + printf("line: %s",line.getText()); + } + print("up");FPLNLines[0].scrollUp(); + foreach(line;FPLNLines[0].output) { + printf("line: %s",line.getText()); + } + print("up");FPLNLines[0].scrollUp(); + foreach(line;FPLNLines[0].output) { + printf("line: %s",line.getText()); + } + print("up");FPLNLines[0].scrollUp(); + foreach(line;FPLNLines[0].output) { + printf("line: %s",line.getText()); + } + print("up");FPLNLines[0].scrollUp(); + foreach(line;FPLNLines[0].output) { + printf("line: %s",line.getText()); + } + print("up");FPLNLines[0].scrollUp(); + foreach(line;FPLNLines[0].output) { + printf("line: %s",line.getText()); + } + print("up");FPLNLines[0].scrollUp(); + foreach(line;FPLNLines[0].output) { + printf("line: %s",line.getText()); + } + print("up");FPLNLines[0].scrollUp(); + foreach(line;FPLNLines[0].output) { + printf("line: %s",line.getText()); + } + print("up");FPLNLines[0].scrollUp(); + foreach(line;FPLNLines[0].output) { + printf("line: %s",line.getText()); + } + print("up");FPLNLines[0].scrollUp(); + foreach(line;FPLNLines[0].output) { + printf("line: %s",line.getText()); + } + print("up");FPLNLines[0].scrollUp(); + foreach(line;FPLNLines[0].output) { + printf("line: %s",line.getText()); + } + print("up");FPLNLines[0].scrollUp(); + foreach(line;FPLNLines[0].output) { + printf("line: %s",line.getText()); + } + print("up");FPLNLines[0].scrollUp(); + foreach(line;FPLNLines[0].output) { + printf("line: %s",line.getText()); + } +} + +#test(); diff --git a/Nasal/MCDU/INITA.nas b/Nasal/MCDU/INITA.nas index 82aed56b..b88a759c 100644 --- a/Nasal/MCDU/INITA.nas +++ b/Nasal/MCDU/INITA.nas @@ -70,10 +70,11 @@ var initInputA = func(key, i) { } } else if (key == "R1") { if (scratchpad == "CLR") { + clearFPLNComputer(); setprop("/FMGC/internal/dep-arpt", ""); setprop("/FMGC/internal/arr-arpt", ""); setprop("/FMGC/internal/tofrom-set", 0); - fmgc.updateARPT(); + fmgc.flightplan.reset(); setprop("/MCDU[" ~ i ~ "]/scratchpad-msg", 0); setprop("/MCDU[" ~ i ~ "]/scratchpad", ""); } else { @@ -87,7 +88,7 @@ var initInputA = func(key, i) { setprop("/FMGC/internal/arr-arpt", fromto[1]); setprop("/FMGC/internal/tofrom-set", 1); setprop("/MCDU[" ~ i ~ "]/scratchpad", ""); - fmgc.updateARPT(); + fmgc.flightplan.updateARPT(fromto[0], fromto[1], 2); } else { notAllowed(i); } diff --git a/Nasal/MCDU/LATREV.nas b/Nasal/MCDU/LATREV.nas new file mode 100644 index 00000000..309e7e39 --- /dev/null +++ b/Nasal/MCDU/LATREV.nas @@ -0,0 +1,98 @@ +var latRev = { + title: [nil, nil, nil], + subtitle: [nil, nil], + fontMatrix: [[0, 0, 0, 0, 0, 0],[0, 0, 0, 0, 0, 0]], + arrowsMatrix: [[0, 0, 0, 0, 0, 0],[0, 0, 0, 0, 0, 0]], + L1: [nil, nil, "ack"], # content, title, colour + L2: [nil, nil, "ack"], + L3: [nil, nil, "ack"], + L4: [nil, nil, "ack"], + L5: [nil, nil, "ack"], + L6: [nil, nil, "ack"], + R1: [nil, nil, "ack"], + R2: [nil, nil, "ack"], + R3: [nil, nil, "ack"], + R4: [nil, nil, "ack"], + R5: [nil, nil, "ack"], + R6: [nil, nil, "ack"], + depAirport: nil, + arrAirport: nil, + new: func(type, id) { + var lr = {parents:[latRev]}; + lr.type = type; # 0 = origin 1 = destination 2 = ppos (from waypoint) 3 = generic wpt + lr.id = id; + lr._setupPageWithData(); + return lr; + }, + del: func() { + return nil; + }, + _setupPageWithData: func() { + if (me.type == 2) { + me.title = ["LAT REV", " FROM ", "PPOS"]; + me.L2 = [" OFFSET", nil, "wht"]; + me.L3 = [" HOLD", nil, "wht"]; + me.L6 = [" RETURN", nil, "wht"]; + me.R1 = ["FIX INFO ", nil, "wht"]; + me.R2 = ["[ ]°/[ ]°/[ ]", "LL XING/INCR/NO", "blu"]; + me.arrowsMatrix = [[0, 1, 1, 0, 0, 1], [1, 0, 0, 0, 0, 0]]; + me.fontMatrix = [[0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0]]; + } else { + me.title = ["LAT REV", " FROM ", me.id]; + + if (me.type == 0) { + me.depAirport = findAirportsByICAO(me.id); + me.subtitle = [dmsToString(sprintf(me.depAirport[0].lat), "lat"), dmsToString(sprintf(me.depAirport[0].lon), "lon")]; + me.L1 = [" DEPARTURE", nil, "wht"]; + me.L2 = [" OFFSET", nil, "wht"]; + me.L6 = [" RETURN", nil, "wht"]; + me.R1 = ["FIX INFO ", nil, "wht"]; + me.R2 = ["[ ]°/[ ]°/[ ]", "LL XING/INCR/NO", "blu"]; + me.R3 = ["[ ]", "NEXT WPT ", "blu"]; + me.R4 = ["[ ]", "NEW DEST", "blu"]; + me.arrowsMatrix = [[1, 1, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0]]; + me.fontMatrix = [[0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 0, 0]]; + } elsif (me.type == 1) { + me.arrAirport = findAirportsByICAO(me.id); + me.subtitle = [dmsToString(sprintf(me.arrAirport[0].lat), "lat"), dmsToString(sprintf(me.arrAirport[0].lon), "lon")]; + me.L3 = [" ALTN", nil, "wht"]; + me.L4 = [" ALTN", "ENABLE", "blu"]; + me.L6 = [" RETURN", nil, "wht"]; + me.R1 = ["ARRIVAL ", nil, "wht"]; + me.R3 = ["[ ]", "NEXT WPT ", "blu"]; + me.arrowsMatrix = [[0, 0, 1, 1, 0, 1], [1, 0, 0, 0, 0, 0]]; + me.fontMatrix = [[0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0]]; + } elsif (me.type == 3) { + if (size(me.id) == 2 or size(me.id) == 3) { + me.wpt = findNavaidsByID(me.id); + } elsif (size(me.id) == 4) { + me.wpt = findAirportsByICAO(me.id); + } elsif (size(me.id) == 5) { + me.wpt = findFixesByID(me.id); + } + me.subtitle = [dmsToString(sprintf(me.wpt[0].lat), "lat"), dmsToString(sprintf(me.wpt[0].lon), "lon")]; + me.L3 = [" HOLD", nil, "wht"]; + me.L4 = [" ALTN", "ENABLE", "blu"]; + me.L6 = [" RETURN", nil, "wht"]; + me.R1 = ["FIX INFO ", nil, "wht"]; + me.R3 = ["[ ]", "NEXT WPT ", "blu"]; + me.R4 = ["[ ]", "NEW DEST", "blu"]; + me.R5 = ["AIRWAYS ", nil, "wht"]; + me.arrowsMatrix = [[0, 0, 1, 1, 0, 1], [1, 0, 0, 0, 1, 0]]; + me.fontMatrix = [[0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 0, 0]]; + } + } + }, +}; + +var dmsToString = func(dms, type) { + var decimalSplit = split(".", dms); + var degrees = decimalSplit[0]; + var minutes = decimalSplit[1] * 60; + if (type == "lat") { + var sign = degrees >= 0 ? "N" : "S"; + } else { + var sign = degrees >= 0 ? "E" : "W"; + } + return degrees ~ "g" ~ minutes ~ " " ~ sign; +} \ No newline at end of file diff --git a/Nasal/MCDU/MCDU.nas b/Nasal/MCDU/MCDU.nas index 134eaea8..62c094fd 100644 --- a/Nasal/MCDU/MCDU.nas +++ b/Nasal/MCDU/MCDU.nas @@ -96,53 +96,59 @@ var lskbutton = func(btn, i) { setprop("/MCDU[" ~ i ~ "]/scratchpad-msg", 0); } } else if (getprop("/MCDU[" ~ i ~ "]/page") == "TO") { - perfTOInput("L1",i); + perfTOInput("L1", i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "RADNAV") { - radnavInput("L1",i); + radnavInput("L1", i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "DATA") { - dataInput("L1",i); + dataInput("L1", i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "PRINTFUNC") { - printInput("L1",i); + printInput("L1", i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "PRINTFUNC2") { - printInput2("L1",i); + printInput2("L1", i); + } else if (getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNA" or getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNB") { + FPLNButton("L", 1, i); } else { notAllowed(i); } } else if (btn == "2") { if (getprop("/MCDU[" ~ i ~ "]/page") == "INITA") { - PerfInput("L2",i); + PerfInput("L2", i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "TO") { - perfTOInput("L2",i); + perfTOInput("L2", i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "RADNAV") { - radnavInput("L2",i); + radnavInput("L2", i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "CLB") { - initInputA("L5",i); # Does the same thing as on the INIT page + initInputA("L5", i); # Does the same thing as on the INIT page } else if (getprop("/MCDU[" ~ i ~ "]/page") == "CRZ") { - initInputA("L5",i); + initInputA("L5", i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "DES") { - initInputA("L5",i); + initInputA("L5", i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "DATA") { - dataInput("L2",i); + dataInput("L2", i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "PRINTFUNC") { - printInput("L2",i); + printInput("L2", i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "PRINTFUNC2") { - printInput2("L2",i); + printInput2("L2", i); + } else if (getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNA" or getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNB") { + FPLNButton("L", 2, i); } else { notAllowed(i); } } else if (btn == "3") { if (getprop("/MCDU[" ~ i ~ "]/page") == "INITA") { - initInputA("L3",i); + initInputA("L3", i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "TO") { - perfTOInput("L3",i); + perfTOInput("L3", i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "STATUS") { - statusInput("L3",i); + statusInput("L3", i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "RADNAV") { - radnavInput("L3",i); + radnavInput("L3", i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "PRINTFUNC") { - printInput("L3",i); + printInput("L3", i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "PRINTFUNC2") { - printInput2("L3",i); + printInput2("L3", i); + } else if (getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNA" or getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNB") { + FPLNButton("L", 3, i); } else { notAllowed(i); } @@ -150,45 +156,53 @@ var lskbutton = func(btn, i) { if (getprop("/MCDU[" ~ i ~ "]/page") == "DATA") { setprop("/MCDU[" ~ i ~ "]/page", "STATUS"); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "TO") { - perfTOInput("L4",i); + perfTOInput("L4", i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "RADNAV") { - radnavInput("L4",i); + radnavInput("L4", i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "PRINTFUNC2") { - printInput2("L4",i); + printInput2("L4", i); + } else if (getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNA" or getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNB") { + FPLNButton("L", 4, i); } else { notAllowed(i); } } else if (btn == "5") { if (getprop("/MCDU[" ~ i ~ "]/page") == "INITA") { - initInputA("L5",i); + initInputA("L5", i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "TO") { - perfTOInput("L5",i); + perfTOInput("L5", i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "CLB") { - perfCLBInput("L5",i); + perfCLBInput("L5", i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "CRZ") { - perfCRZInput("L5",i); + perfCRZInput("L5", i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "DES") { - perfDESInput("L5",i); + perfDESInput("L5", i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "RADNAV") { - radnavInput("L5",i); + radnavInput("L5", i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "PRINTFUNC") { - printInput("L5",i); + printInput("L5", i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "PRINTFUNC2") { - printInput2("L5",i); + printInput2("L5", i); + } else if (getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNA" or getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNB") { + FPLNButton("L", 5, i); } else { notAllowed(i); } } else if (btn == "6") { if (getprop("/MCDU[" ~ i ~ "]/page") == "INITA") { - initInputA("L6",i); + initInputA("L6", i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "CLB") { - perfCLBInput("L6",i); + perfCLBInput("L6", i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "CRZ") { - perfCRZInput("L6",i); + perfCRZInput("L6", i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "DES") { - perfDESInput("L6",i); + perfDESInput("L6", i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "PRINTFUNC2") { - printInput2("L6",i); + printInput2("L6", i); + } else if (getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNA" or getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNB") { + FPLNButton("L", 6, i); + } else if (getprop("/MCDU[" ~ i ~ "]/page") == "LATREV") { + setprop("/MCDU[" ~ i ~ "]/page", "F-PLNA"); } else { notAllowed(i); } @@ -202,59 +216,59 @@ var lskbutton_b = func(btn, i) { var rskbutton = func(btn, i) { if (btn == "1") { if (getprop("/MCDU[" ~ i ~ "]/page") == "INITA") { - initInputA("R1",i); + initInputA("R1", i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "INITB") { - initInputB("R1",i); + initInputB("R1", i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "RADNAV") { - radnavInput("R1",i); + radnavInput("R1", i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "PRINTFUNC") { - printInput("R1",i); + printInput("R1", i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "PRINTFUNC2") { - printInput2("R1",i); + printInput2("R1", i); } else { notAllowed(i); } } else if (btn == "2") { if (getprop("/MCDU[" ~ i ~ "]/page") == "INITB") { - initInputB("R2",i); + initInputB("R2", i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "RADNAV") { - radnavInput("R2",i); + radnavInput("R2", i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "PRINTFUNC") { - printInput("R2",i); + printInput("R2", i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "PRINTFUNC2") { - printInput2("R2",i); + printInput2("R2", i); } else { notAllowed(i); } } else if (btn == "3") { if (getprop("/MCDU[" ~ i ~ "]/page") == "INITA") { - initInputA("R3",i); + initInputA("R3", i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "TO") { - perfTOInput("R3",i); + perfTOInput("R3", i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "PRINTFUNC") { - printInput("R3",i); + printInput("R3", i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "PRINTFUNC2") { - printInput2("R3",i); + printInput2("R3", i); } else { notAllowed(i); } } else if (btn == "4") { if (getprop("/MCDU[" ~ i ~ "]/page") == "TO") { - perfTOInput("R4",i); + perfTOInput("R4", i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "RADNAV") { - radnavInput("R4",i); + radnavInput("R4", i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "PRINTFUNC2") { - printInput2("R4",i); + printInput2("R4", i); } else { notAllowed(i); } } else if (btn == "5") { if (getprop("/MCDU[" ~ i ~ "]/page") == "TO") { - perfTOInput("R5",i); + perfTOInput("R5", i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "RADNAV") { - radnavInput("R5",i); + radnavInput("R5", i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "DATA") { - dataInput("R5",i); + dataInput("R5", i); } else { notAllowed(i); } @@ -268,11 +282,11 @@ var rskbutton = func(btn, i) { notAllowed(i); } } else if (getprop("/MCDU[" ~ i ~ "]/page") == "TO") { - perfTOInput("R6",i); + perfTOInput("R6", i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "CLB") { - perfCLBInput("R6",i); + perfCLBInput("R6", i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "CRZ") { - perfCRZInput("R6",i); + perfCRZInput("R6", i); } else if ((getprop("/MCDU[" ~ i ~ "]/page") == "DATA") or (getprop("/MCDU[" ~ i ~ "]/page") == "PRINTFUNC") or (getprop("/MCDU[" ~ i ~ "]/page") == "PRINTFUNC2")) { if (getprop("/MCDU[" ~ i ~ "]/scratchpad") != "AOC DISABLED") { if (getprop("/MCDU[" ~ i ~ "]/scratchpad-msg") == 1) { @@ -284,7 +298,9 @@ var rskbutton = func(btn, i) { setprop("/MCDU[" ~ i ~ "]/scratchpad-msg", 1); setprop("/MCDU[" ~ i ~ "]/scratchpad", "AOC DISABLED"); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "INITA") { - initInputA("R6",i); + initInputA("R6", i); + } else if (getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNA" or getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNB") { + FPLNButton("R", 6, i); } else { notAllowed(i); } @@ -333,9 +349,13 @@ var arrowbutton = func(btn, i) { setprop("/MCDU[" ~ i ~ "]/page", "PRINTFUNC"); } } else if (btn == "up") { - # Nothing for now + if (getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNA" or getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNB") { + slewFPLN(1, i); + } } else if (btn == "down") { - # Nothing for now + if (getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNA" or getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNB") { + slewFPLN(-1, i); + } } } @@ -363,7 +383,12 @@ var pagebutton = func(btn, i) { setprop("/MCDU[" ~ i ~ "]/scratchpad", "SELECT DESIRED SYSTEM"); setprop("/MCDU[" ~ i ~ "]/page", "MCDU"); } else if (btn == "f-pln") { - setprop("/MCDU[" ~ i ~ "]/page", "F-PLNA"); + if (active_out[2].getBoolValue()) { + setprop("/MCDU[" ~ i ~ "]/page", "F-PLNA"); + } else { + setprop("/MCDU[" ~ i ~ "]/scratchpad-msg", 1); + setprop("/MCDU[" ~ i ~ "]/scratchpad", "ERROR. INITIALIZE ROUTE"); # Should be ERROR:, but the : character doesn't show in our MCDU font right now... + } } else if (btn == "fuel-pred") { setprop("/MCDU[" ~ i ~ "]/page", "FUELPRED"); } @@ -534,6 +559,18 @@ var notAllowed = func(i) { setprop("/MCDU[" ~ i ~ "]/scratchpad", "NOT ALLOWED"); } +var formatError = func(i) { + if (getprop("/MCDU[" ~ i ~ "]/scratchpad") != "FORMAT ERROR") { + if (getprop("/MCDU[" ~ i ~ "]/scratchpad-msg") == 1) { + setprop("/MCDU[" ~ i ~ "]/last-scratchpad", ""); + } else { + setprop("/MCDU[" ~ i ~ "]/last-scratchpad", getprop("/MCDU[" ~ i ~ "]/scratchpad")); + } + } + setprop("/MCDU[" ~ i ~ "]/scratchpad-msg", 1); + setprop("/MCDU[" ~ i ~ "]/scratchpad", "FORMAT ERROR"); +} + var screenFlash = func(time, i) { var page = getprop("/MCDU[" ~ i ~ "]/page"); setprop("/MCDU[" ~ i ~ "]/page", "NONE"); diff --git a/Nasal/Sim/libraries.nas b/Nasal/Sim/libraries.nas index 3a0737c8..26b21ac2 100644 --- a/Nasal/Sim/libraries.nas +++ b/Nasal/Sim/libraries.nas @@ -205,6 +205,7 @@ var systemsInit = func { systems.eng_init(); systems.fire_init(); systems.autobrake_init(); + fmgc.flightplan.reset(); fadec.FADEC.init(); fmgc.ITAF.init(); fmgc.FMGCinit(); diff --git a/Systems/fmgc-drivers.xml b/Systems/fmgc-drivers.xml index 16346fac..97a13834 100644 --- a/Systems/fmgc-drivers.xml +++ b/Systems/fmgc-drivers.xml @@ -449,7 +449,7 @@ - /autopilot/route-manager/wp[0]/true-bearing-deg + /FMGC/flightplan[2]/current-leg-course /it-autoflight/internal/drift-angle-deg -1.0 From f2cec1416d2f6ba73e4f13faf3e22c800cf39198 Mon Sep 17 00:00:00 2001 From: legoboyvdlp R Date: Mon, 30 Dec 2019 21:24:00 +0000 Subject: [PATCH 02/51] Add working DEPARTURE page --- A320-main.xml | 3 +- Models/Instruments/MCDU/MCDU.nas | 454 ++++++++++++++++++++++++++----- Nasal/MCDU/DEPARTURE.nas | 140 ++++++++++ Nasal/MCDU/F-PLN.nas | 40 +-- Nasal/MCDU/LATREV.nas | 44 +-- Nasal/MCDU/MCDU.nas | 21 ++ 6 files changed, 603 insertions(+), 99 deletions(-) create mode 100644 Nasal/MCDU/DEPARTURE.nas diff --git a/A320-main.xml b/A320-main.xml index 912044b7..60e9dd8a 100644 --- a/A320-main.xml +++ b/A320-main.xml @@ -1876,7 +1876,8 @@ Aircraft/A320-family/Nasal/FMGC/FMGC-c.nas - Aircraft/A320-family/Nasal/MCDU/LATREV.nas + Aircraft/A320-family/Nasal/MCDU/LATREV.nas + Aircraft/A320-family/Nasal/MCDU/DEPARTURE.nas Aircraft/A320-family/Nasal/MCDU/MCDU.nas Aircraft/A320-family/Nasal/MCDU/INITA.nas Aircraft/A320-family/Nasal/MCDU/INITB.nas diff --git a/Models/Instruments/MCDU/MCDU.nas b/Models/Instruments/MCDU/MCDU.nas index fa283693..c32148b8 100644 --- a/Models/Instruments/MCDU/MCDU.nas +++ b/Models/Instruments/MCDU/MCDU.nas @@ -6,7 +6,8 @@ var MCDU_1 = nil; var MCDU_2 = nil; var MCDU1_display = nil; var MCDU2_display = nil; -var myLatRev = nil; +var myLatRev = [nil, nil]; +var myDeparture = [nil, nil]; var default = "BoeingCDU-Large.ttf"; var symbol = "helvetica_medium.txf"; var normal = 70; @@ -169,7 +170,7 @@ var canvas_MCDU_base = { "Simple_L1_Arrow","Simple_L2_Arrow","Simple_L3_Arrow","Simple_L4_Arrow","Simple_L5_Arrow","Simple_L6_Arrow","Simple_R1","Simple_R2","Simple_R3","Simple_R4","Simple_R5","Simple_R6","Simple_R1S","Simple_R2S","Simple_R3S","Simple_R4S","Simple_R5S", "Simple_R6S","Simple_R1_Arrow","Simple_R2_Arrow","Simple_R3_Arrow","Simple_R4_Arrow","Simple_R5_Arrow","Simple_R6_Arrow","Simple_C1","Simple_C2","Simple_C3","Simple_C4","Simple_C5","Simple_C6","Simple_C1S","Simple_C2S","Simple_C3S","Simple_C4S", "Simple_C5S","Simple_C6S","INITA","INITA_CoRoute","INITA_FltNbr","INITA_CostIndex","INITA_CruiseFLTemp","INITA_FromTo","INITA_InitRequest","INITA_AlignIRS","INITB","INITB_ZFWCG","INITB_ZFW","INITB_ZFW_S","INITB_Block","PERFTO","PERFTO_V1","PERFTO_VR", - "PERFTO_V2","PERFTO_FE","PERFTO_SE","PERFTO_OE","FPLN","FPLN_From","FPLN_TMPY_group","FPLN_Callsign","FPLN_L1","FPLN_L2","FPLN_L3","FPLN_L4","FPLN_L5","FPLN_L6","FPLN_L1S","FPLN_L2S","FPLN_L3S","FPLN_L4S","FPLN_L5S","FPLN_L6S","FPLN_6_group"]; + "PERFTO_V2","PERFTO_FE","PERFTO_SE","PERFTO_OE","FPLN","FPLN_From","FPLN_TMPY_group","FPLN_Callsign","FPLN_L1","FPLN_L2","FPLN_L3","FPLN_L4","FPLN_L5","FPLN_L6","FPLN_L1S","FPLN_L2S","FPLN_L3S","FPLN_L4S","FPLN_L5S","FPLN_L6S","FPLN_6_group","departureTMPY"]; }, update: func() { if (systems.ELEC.Bus.ac1.getValue() >= 110 and mcdu1_lgt.getValue() > 0.01) { @@ -210,7 +211,6 @@ var canvas_MCDU_base = { } fplnLineSize = size(mcdu.FPLNLines[i].output); - if (fplnLineSize >= 1) { fplnl1 = mcdu.FPLNLines[i].output[0].getText(); if (fplnl1 != "") { @@ -342,7 +342,6 @@ var canvas_MCDU_base = { } else { me["FPLN_From"].hide(); } - if (TMPYActive[i].getBoolValue()) { me["FPLN_TMPY_group"].show(); me["FPLN_6_group"].hide(); @@ -1595,7 +1594,7 @@ var canvas_MCDU_base = { } elsif (page == "LATREV") { if (!pageSwitch[i].getBoolValue()) { me["Simple"].show(); - me["Simple_Center"].hide(); + me["Simple_Center"].show(); me["FPLN"].hide(); me["INITA"].hide(); me["INITB"].hide(); @@ -1619,32 +1618,52 @@ var canvas_MCDU_base = { me.colorRightArrow("wht", "wht", "wht", "wht", "wht", "wht"); - if (myLatRev != nil) { - me["Simple_Title"].setText(sprintf("%s", myLatRev.title[0] ~ myLatRev.title[1] ~ myLatRev.title[2])); + if (myLatRev[i] != nil) { + me["Simple_Title"].setText(sprintf("%s", myLatRev[i].title[0] ~ myLatRev[i].title[1] ~ myLatRev[i].title[2])); - forindex (var matrixArrow; myLatRev.arrowsMatrix) { + if (myLatRev[i].subtitle[0] != nil) { + me["Simple_Center"].show(); + me["Simple_C1S"].setText(sprintf("%s", myLatRev[i].subtitle[0] ~ "/" ~ myLatRev[i].subtitle[1])); + me["Simple_C1S"].show(); + me["Simple_C1"].hide(); + me["Simple_C2"].hide(); + me["Simple_C3"].hide(); + me["Simple_C4"].hide(); + me["Simple_C5"].hide(); + me["Simple_C6"].hide(); + me["Simple_C2S"].hide(); + me["Simple_C3S"].hide(); + me["Simple_C4S"].hide(); + me["Simple_C5S"].hide(); + me["Simple_C6S"].hide(); + } else { + me["Simple_Center"].hide(); + } + forindex (var matrixArrow; myLatRev[i].arrowsMatrix) { if (matrixArrow == 0) { var sign = "L"; } else { var sign = "R"; } - forindex (var item; myLatRev.arrowsMatrix[matrixArrow]) { - if (myLatRev.arrowsMatrix[matrixArrow][item] == 1) { + forindex (var item; myLatRev[i].arrowsMatrix[matrixArrow]) { + if (myLatRev[i].arrowsMatrix[matrixArrow][item] == 1) { me["Simple_" ~ sign ~ (item + 1) ~ "_Arrow"].show(); } else { me["Simple_" ~ sign ~ (item + 1) ~ "_Arrow"].hide(); } } } + me.colorLeftArrow(myLatRev[i].arrowsColour[0][0],myLatRev[i].arrowsColour[0][1],myLatRev[i].arrowsColour[0][2],myLatRev[i].arrowsColour[0][3],myLatRev[i].arrowsColour[0][4],myLatRev[i].arrowsColour[0][5]); - forindex (var matrixFont; myLatRev.fontMatrix) { + + forindex (var matrixFont; myLatRev[i].fontMatrix) { if (matrixFont == 0) { var sign = "L"; } else { var sign = "R"; } - forindex (var item; myLatRev.fontMatrix[matrixFont]) { - if (myLatRev.fontMatrix[matrixFont][item] == 1) { + forindex (var item; myLatRev[i].fontMatrix[matrixFont]) { + if (myLatRev[i].fontMatrix[matrixFont][item] == 1) { me["Simple_" ~ sign ~ (item + 1)].setFont(symbol); me["Simple_" ~ sign ~ (item + 1)].setFontSize(small); } else { @@ -1654,175 +1673,484 @@ var canvas_MCDU_base = { } } - if (myLatRev.L1[0] == nil) { + if (myLatRev[i].L1[0] == nil) { me["Simple_L1"].hide(); me["Simple_L1S"].hide(); } else { me["Simple_L1"].show(); - me["Simple_L1"].setText(myLatRev.L1[0]); - if (myLatRev.L1[1] != nil) { + me["Simple_L1"].setText(myLatRev[i].L1[0]); + if (myLatRev[i].L1[1] != nil) { me["Simple_L1S"].show(); - me["Simple_L1S"].setText(myLatRev.L1[1]); + me["Simple_L1S"].setText(myLatRev[i].L1[1]); } else { me["Simple_L1S"].hide(); } } - if (myLatRev.L2[0] == nil) { + if (myLatRev[i].L2[0] == nil) { me["Simple_L2"].hide(); me["Simple_L2S"].hide(); } else { me["Simple_L2"].show(); - me["Simple_L2"].setText(myLatRev.L2[0]); - if (myLatRev.L2[1] != nil) { + me["Simple_L2"].setText(myLatRev[i].L2[0]); + if (myLatRev[i].L2[1] != nil) { me["Simple_L2S"].show(); - me["Simple_L2S"].setText(myLatRev.L2[1]); + me["Simple_L2S"].setText(myLatRev[i].L2[1]); } else { me["Simple_L2S"].hide(); } } - if (myLatRev.L3[0] == nil) { + if (myLatRev[i].L3[0] == nil) { me["Simple_L3"].hide(); me["Simple_L3S"].hide(); } else { me["Simple_L3"].show(); - me["Simple_L3"].setText(myLatRev.L3[0]); - if (myLatRev.L3[1] != nil) { + me["Simple_L3"].setText(myLatRev[i].L3[0]); + if (myLatRev[i].L3[1] != nil) { me["Simple_L3S"].show(); - me["Simple_L3S"].setText(myLatRev.L3[1]); + me["Simple_L3S"].setText(myLatRev[i].L3[1]); } else { me["Simple_L3S"].hide(); } } - if (myLatRev.L4[0] == nil) { + if (myLatRev[i].L4[0] == nil) { me["Simple_L4"].hide(); me["Simple_L4S"].hide(); } else { me["Simple_L4"].show(); - me["Simple_L4"].setText(myLatRev.L4[0]); - if (myLatRev.L4[1] != nil) { + me["Simple_L4"].setText(myLatRev[i].L4[0]); + if (myLatRev[i].L4[1] != nil) { me["Simple_L4S"].show(); - me["Simple_L4S"].setText(myLatRev.L4[1]); + me["Simple_L4S"].setText(myLatRev[i].L4[1]); } else { me["Simple_L4S"].hide(); } } - if (myLatRev.L5[0] == nil) { + if (myLatRev[i].L5[0] == nil) { me["Simple_L5"].hide(); me["Simple_L5S"].hide(); } else { me["Simple_L5"].show(); - me["Simple_L5"].setText(myLatRev.L5[0]); - if (myLatRev.L5[1] != nil) { + me["Simple_L5"].setText(myLatRev[i].L5[0]); + if (myLatRev[i].L5[1] != nil) { me["Simple_L5S"].show(); - me["Simple_L5S"].setText(myLatRev.L5[1]); + me["Simple_L5S"].setText(myLatRev[i].L5[1]); } else { me["Simple_L5S"].hide(); } } - if (myLatRev.L6[0] == nil) { + if (myLatRev[i].L6[0] == nil) { me["Simple_L6"].hide(); me["Simple_L6S"].hide(); } else { me["Simple_L6"].show(); - me["Simple_L6"].setText(myLatRev.L6[0]); - if (myLatRev.L6[1] != nil) { + me["Simple_L6"].setText(myLatRev[i].L6[0]); + if (myLatRev[i].L6[1] != nil) { me["Simple_L6S"].show(); - me["Simple_L6S"].setText(myLatRev.L6[1]); + me["Simple_L6S"].setText(myLatRev[i].L6[1]); } else { me["Simple_L6S"].hide(); } } - me.colorLeft(myLatRev.L1[2],myLatRev.L2[2],myLatRev.L3[2],myLatRev.L4[2],myLatRev.L5[2],myLatRev.L6[2]); + me.colorLeft(myLatRev[i].L1[2],myLatRev[i].L2[2],myLatRev[i].L3[2],myLatRev[i].L4[2],myLatRev[i].L5[2],myLatRev[i].L6[2]); - if (myLatRev.R1[0] == nil) { + if (myLatRev[i].R1[0] == nil) { me["Simple_R1"].hide(); me["Simple_R1S"].hide(); } else { me["Simple_R1"].show(); - me["Simple_R1"].setText(myLatRev.R1[0]); - if (myLatRev.R1[1] != nil) { + me["Simple_R1"].setText(myLatRev[i].R1[0]); + if (myLatRev[i].R1[1] != nil) { me["Simple_R1S"].show(); - me["Simple_R1S"].setText(myLatRev.R1[1]); + me["Simple_R1S"].setText(myLatRev[i].R1[1]); } else { me["Simple_R1S"].hide(); } } - if (myLatRev.R2[0] == nil) { + if (myLatRev[i].R2[0] == nil) { me["Simple_R2"].hide(); me["Simple_R2S"].hide(); } else { me["Simple_R2"].show(); - me["Simple_R2"].setText(myLatRev.R2[0]); - if (myLatRev.R2[1] != nil) { + me["Simple_R2"].setText(myLatRev[i].R2[0]); + if (myLatRev[i].R2[1] != nil) { me["Simple_R2S"].show(); - me["Simple_R2S"].setText(myLatRev.R2[1]); + me["Simple_R2S"].setText(myLatRev[i].R2[1]); } else { me["Simple_R2S"].hide(); } } - if (myLatRev.R3[0] == nil) { + if (myLatRev[i].R3[0] == nil) { me["Simple_R3"].hide(); me["Simple_R3S"].hide(); } else { me["Simple_R3"].show(); - me["Simple_R3"].setText(myLatRev.R3[0]); - if (myLatRev.R3[1] != nil) { + me["Simple_R3"].setText(myLatRev[i].R3[0]); + if (myLatRev[i].R3[1] != nil) { me["Simple_R3S"].show(); - me["Simple_R3S"].setText(myLatRev.R3[1]); + me["Simple_R3S"].setText(myLatRev[i].R3[1]); } else { me["Simple_R3S"].hide(); } } - if (myLatRev.R4[0] == nil) { + if (myLatRev[i].R4[0] == nil) { me["Simple_R4"].hide(); me["Simple_R4S"].hide(); } else { me["Simple_R4"].show(); - me["Simple_R4"].setText(myLatRev.R4[0]); - if (myLatRev.R4[1] != nil) { + me["Simple_R4"].setText(myLatRev[i].R4[0]); + if (myLatRev[i].R4[1] != nil) { me["Simple_R4S"].show(); - me["Simple_R4S"].setText(myLatRev.R4[1]); + me["Simple_R4S"].setText(myLatRev[i].R4[1]); } else { me["Simple_R4S"].hide(); } } - if (myLatRev.R5[0] == nil) { + if (myLatRev[i].R5[0] == nil) { me["Simple_R5"].hide(); me["Simple_R5S"].hide(); } else { me["Simple_R5"].show(); - me["Simple_R5"].setText(myLatRev.R5[0]); - if (myLatRev.R5[1] != nil) { + me["Simple_R5"].setText(myLatRev[i].R5[0]); + if (myLatRev[i].R5[1] != nil) { me["Simple_R5S"].show(); - me["Simple_R5S"].setText(myLatRev.R5[1]); + me["Simple_R5S"].setText(myLatRev[i].R5[1]); } else { me["Simple_R5S"].hide(); } } - if (myLatRev.R6[0] == nil) { + if (myLatRev[i].R6[0] == nil) { me["Simple_R6"].hide(); me["Simple_R6S"].hide(); } else { me["Simple_R6"].show(); - me["Simple_R6"].setText(myLatRev.R6[0]); - if (myLatRev.R6[1] != nil) { + me["Simple_R6"].setText(myLatRev[i].R6[0]); + if (myLatRev[i].R6[1] != nil) { me["Simple_R6S"].show(); - me["Simple_R6S"].setText(myLatRev.R6[1]); + me["Simple_R6S"].setText(myLatRev[i].R6[1]); } else { me["Simple_R6S"].hide(); } } - me.colorRight(myLatRev.R1[2],myLatRev.R2[2],myLatRev.R3[2],myLatRev.R4[2],myLatRev.R5[2],myLatRev.R6[2]); + me.colorRight(myLatRev[i].R1[2],myLatRev[i].R2[2],myLatRev[i].R3[2],myLatRev[i].R4[2],myLatRev[i].R5[2],myLatRev[i].R6[2]); + } + pageSwitch[i].setBoolValue(1); + } + } elsif (page == "DEPARTURE") { + if (!pageSwitch[i].getBoolValue()) { + me["Simple"].show(); + me["Simple_Center"].show(); + me["FPLN"].hide(); + me["INITA"].hide(); + me["INITB"].hide(); + me["PERFTO"].hide(); + me["Simple_PageNum"].setText("X/X"); + me["Simple_PageNum"].hide(); + me["ArrowLeft"].show(); + me["ArrowRight"].show(); + + me.fontLeft(default, default, default, default, default, default); + me.fontLeftS(default, default, default, default, default, default); + me.fontRight(default, default, default, default, default, default); + me.fontRightS(default, default, default, default, default, default); + + me.fontSizeLeft(normal, normal, normal, normal, normal, normal); + me.fontSizeRight(normal, normal, normal, normal, normal, normal); + + me.colorLeftS("wht", "wht", "wht", "wht", "wht", "wht"); + me.colorLeftArrow("wht", "wht", "wht", "wht", "wht", "wht"); + me.colorRightS("wht", "wht", "wht", "wht", "wht", "wht"); + me.colorRightArrow("wht", "wht", "wht", "wht", "wht", "wht"); + + + if (myDeparture[i] != nil) { + me["Simple_Title"].setText(sprintf("%s", myDeparture[i].title[0] ~ myDeparture[i].title[1] ~ myDeparture[i].title[2])); + + forindex (var matrixArrow; myDeparture[i].arrowsMatrix) { + if (matrixArrow == 0) { + var sign = "L"; + } else { + var sign = "R"; + } + forindex (var item; myDeparture[i].arrowsMatrix[matrixArrow]) { + if (myDeparture[i].arrowsMatrix[matrixArrow][item] == 1) { + me["Simple_" ~ sign ~ (item + 1) ~ "_Arrow"].show(); + } else { + me["Simple_" ~ sign ~ (item + 1) ~ "_Arrow"].hide(); + } + } + } + me.colorLeftArrow(myDeparture[i].arrowsColour[0][0],myDeparture[i].arrowsColour[0][1],myDeparture[i].arrowsColour[0][2],myDeparture[i].arrowsColour[0][3],myDeparture[i].arrowsColour[0][4],myDeparture[i].arrowsColour[0][5]); + + forindex (var matrixFont; myDeparture[i].fontMatrix) { + if (matrixFont == 0) { + var sign = "L"; + } else { + var sign = "R"; + } + forindex (var item; myDeparture[i].fontMatrix[matrixFont]) { + if (myDeparture[i].fontMatrix[matrixFont][item] == 1) { + me["Simple_" ~ sign ~ (item + 1)].setFont(symbol); + me["Simple_" ~ sign ~ (item + 1)].setFontSize(small); + } else { + me["Simple_" ~ sign ~ (item + 1)].setFont(default); + me["Simple_" ~ sign ~ (item + 1)].setFontSize(normal); + } + } + } + + if (myDeparture[i].L1[0] == nil) { + me["Simple_L1"].hide(); + me["Simple_L1S"].hide(); + } else { + me["Simple_L1"].show(); + me["Simple_L1"].setText(myDeparture[i].L1[0]); + if (myDeparture[i].L1[1] != nil) { + me["Simple_L1S"].show(); + me["Simple_L1S"].setText(myDeparture[i].L1[1]); + } else { + me["Simple_L1S"].hide(); + } + } + + if (myDeparture[i].L2[0] == nil) { + me["Simple_L2"].hide(); + me["Simple_L2S"].hide(); + } else { + me["Simple_L2"].show(); + me["Simple_L2"].setText(myDeparture[i].L2[0]); + if (myDeparture[i].L2[1] != nil) { + me["Simple_L2S"].show(); + me["Simple_L2S"].setText(myDeparture[i].L2[1]); + } else { + me["Simple_L2S"].hide(); + } + } + + if (myDeparture[i].L3[0] == nil) { + me["Simple_L3"].hide(); + me["Simple_L3S"].hide(); + } else { + me["Simple_L3"].show(); + me["Simple_L3"].setText(myDeparture[i].L3[0]); + if (myDeparture[i].L3[1] != nil) { + me["Simple_L3S"].show(); + me["Simple_L3S"].setText(myDeparture[i].L3[1]); + } else { + me["Simple_L3S"].hide(); + } + } + + if (myDeparture[i].L4[0] == nil) { + me["Simple_L4"].hide(); + me["Simple_L4S"].hide(); + } else { + me["Simple_L4"].show(); + me["Simple_L4"].setText(myDeparture[i].L4[0]); + if (myDeparture[i].L4[1] != nil) { + me["Simple_L4S"].show(); + me["Simple_L4S"].setText(myDeparture[i].L4[1]); + } else { + me["Simple_L4S"].hide(); + } + } + + if (myDeparture[i].L5[0] == nil) { + me["Simple_L5"].hide(); + me["Simple_L5S"].hide(); + } else { + me["Simple_L5"].show(); + me["Simple_L5"].setText(myDeparture[i].L5[0]); + if (myDeparture[i].L5[1] != nil) { + me["Simple_L5S"].show(); + me["Simple_L5S"].setText(myDeparture[i].L5[1]); + } else { + me["Simple_L5S"].hide(); + } + } + + if (myDeparture[i].L6[0] == nil) { + me["Simple_L6"].hide(); + me["Simple_L6S"].hide(); + } else { + me["Simple_L6"].show(); + me["Simple_L6"].setText(myDeparture[i].L6[0]); + if (myDeparture[i].L6[1] != nil) { + me["Simple_L6S"].show(); + me["Simple_L6S"].setText(myDeparture[i].L6[1]); + } else { + me["Simple_L6S"].hide(); + } + } + me.colorLeft(myDeparture[i].L1[2],myDeparture[i].L2[2],myDeparture[i].L3[2],myDeparture[i].L4[2],myDeparture[i].L5[2],myDeparture[i].L6[2]); + + if (myDeparture[i].C1[0] == nil) { + me["Simple_C1"].hide(); + me["Simple_C1S"].hide(); + } else { + me["Simple_C1"].show(); + me["Simple_C1"].setText(myDeparture[i].C1[0]); + if (myDeparture[i].C1[1] != nil) { + me["Simple_C1S"].show(); + me["Simple_C1S"].setText(myDeparture[i].C1[1]); + } else { + me["Simple_C1S"].hide(); + } + } + + if (myDeparture[i].C2[0] == nil) { + me["Simple_C2"].hide(); + me["Simple_C2S"].hide(); + } else { + me["Simple_C2"].show(); + me["Simple_C2"].setText(myDeparture[i].C2[0]); + if (myDeparture[i].C2[1] != nil) { + me["Simple_C2S"].show(); + me["Simple_C2S"].setText(myDeparture[i].C2[1]); + } else { + me["Simple_C2S"].hide(); + } + } + + if (myDeparture[i].C3[0] == nil) { + me["Simple_C3"].hide(); + me["Simple_C3S"].hide(); + } else { + me["Simple_C3"].show(); + me["Simple_C3"].setText(myDeparture[i].C3[0]); + if (myDeparture[i].C3[1] != nil) { + me["Simple_C3S"].show(); + me["Simple_C3S"].setText(myDeparture[i].C3[1]); + } else { + me["Simple_C3S"].hide(); + } + } + + if (myDeparture[i].C4[0] == nil) { + me["Simple_C4"].hide(); + me["Simple_C4S"].hide(); + } else { + me["Simple_C4"].show(); + me["Simple_C4"].setText(myDeparture[i].C4[0]); + if (myDeparture[i].C4[1] != nil) { + me["Simple_C4S"].show(); + me["Simple_C4S"].setText(myDeparture[i].C4[1]); + } else { + me["Simple_C4S"].hide(); + } + } + + if (myDeparture[i].C5[0] == nil) { + me["Simple_C5"].hide(); + me["Simple_C5S"].hide(); + } else { + me["Simple_C5"].show(); + me["Simple_C5"].setText(myDeparture[i].C5[0]); + if (myDeparture[i].C5[1] != nil) { + me["Simple_C5S"].show(); + me["Simple_C5S"].setText(myDeparture[i].C5[1]); + } else { + me["Simple_C5S"].hide(); + } + } + me.colorCenter(myDeparture[i].C1[2],myDeparture[i].C2[2],myDeparture[i].C3[2],myDeparture[i].C4[2],myDeparture[i].C5[2],myDeparture[i].C6[2]); + + me["Simple_C6"].hide(); + me["Simple_C6S"].hide(); + + if (myDeparture[i].R1[0] == nil) { + me["Simple_R1"].hide(); + me["Simple_R1S"].hide(); + } else { + me["Simple_R1"].show(); + me["Simple_R1"].setText(myDeparture[i].R1[0]); + if (myDeparture[i].R1[1] != nil) { + me["Simple_R1S"].show(); + me["Simple_R1S"].setText(myDeparture[i].R1[1]); + } else { + me["Simple_R1S"].hide(); + } + } + + if (myDeparture[i].R2[0] == nil) { + me["Simple_R2"].hide(); + me["Simple_R2S"].hide(); + } else { + me["Simple_R2"].show(); + me["Simple_R2"].setText(myDeparture[i].R2[0]); + if (myDeparture[i].R2[1] != nil) { + me["Simple_R2S"].show(); + me["Simple_R2S"].setText(myDeparture[i].R2[1]); + } else { + me["Simple_R2S"].hide(); + } + } + + if (myDeparture[i].R3[0] == nil) { + me["Simple_R3"].hide(); + me["Simple_R3S"].hide(); + } else { + me["Simple_R3"].show(); + me["Simple_R3"].setText(myDeparture[i].R3[0]); + if (myDeparture[i].R3[1] != nil) { + me["Simple_R3S"].show(); + me["Simple_R3S"].setText(myDeparture[i].R3[1]); + } else { + me["Simple_R3S"].hide(); + } + } + + if (myDeparture[i].R4[0] == nil) { + me["Simple_R4"].hide(); + me["Simple_R4S"].hide(); + } else { + me["Simple_R4"].show(); + me["Simple_R4"].setText(myDeparture[i].R4[0]); + if (myDeparture[i].R4[1] != nil) { + me["Simple_R4S"].show(); + me["Simple_R4S"].setText(myDeparture[i].R4[1]); + } else { + me["Simple_R4S"].hide(); + } + } + + if (myDeparture[i].R5[0] == nil) { + me["Simple_R5"].hide(); + me["Simple_R5S"].hide(); + } else { + me["Simple_R5"].show(); + me["Simple_R5"].setText(myDeparture[i].R5[0]); + if (myDeparture[i].R5[1] != nil) { + me["Simple_R5S"].show(); + me["Simple_R5S"].setText(myDeparture[i].R5[1]); + } else { + me["Simple_R5S"].hide(); + } + } + + if (myDeparture[i].R6[0] == nil) { + me["Simple_R6"].hide(); + me["Simple_R6S"].hide(); + } else { + me["Simple_R6"].show(); + me["Simple_R6"].setText(myDeparture[i].R6[0]); + if (myDeparture[i].R6[1] != nil) { + me["Simple_R6S"].show(); + me["Simple_R6S"].setText(myDeparture[i].R6[1]); + } else { + me["Simple_R6S"].hide(); + } + } + me.colorRight(myDeparture[i].R1[2],myDeparture[i].R2[2],myDeparture[i].R3[2],myDeparture[i].R4[2],myDeparture[i].R5[2],myDeparture[i].R6[2]); } pageSwitch[i].setBoolValue(1); } diff --git a/Nasal/MCDU/DEPARTURE.nas b/Nasal/MCDU/DEPARTURE.nas new file mode 100644 index 00000000..be7f321c --- /dev/null +++ b/Nasal/MCDU/DEPARTURE.nas @@ -0,0 +1,140 @@ +var departurePage = { + title: [nil, nil, nil], + subtitle: [nil, nil], + fontMatrix: [[0, 0, 0, 0, 0, 0],[0, 0, 0, 0, 0, 0]], + arrowsMatrix: [[0, 0, 0, 0, 0, 0],[0, 0, 0, 0, 0, 0]], + arrowsColour: [["ack", "ack", "ack", "ack", "ack", "ack"],["ack", "ack", "ack", "ack", "ack", "ack"]], + L1: [nil, nil, "ack"], # content, title, colour + L2: [nil, nil, "ack"], + L3: [nil, nil, "ack"], + L4: [nil, nil, "ack"], + L5: [nil, nil, "ack"], + L6: [nil, nil, "ack"], + C1: [nil, nil, "ack"], + C2: [nil, nil, "ack"], + C3: [nil, nil, "ack"], + C4: [nil, nil, "ack"], + C5: [nil, nil, "ack"], + C6: [nil, nil, "ack"], + R1: [nil, nil, "ack"], + R2: [nil, nil, "ack"], + R3: [nil, nil, "ack"], + R4: [nil, nil, "ack"], + R5: [nil, nil, "ack"], + R6: [nil, nil, "ack"], + depAirport: nil, + runways: nil, + selectedRunway: nil, + sids: nil, + computer: nil, + enableScroll: 0, + _runways: nil, + _sids: nil, + new: func(icao, computer) { + var lr = {parents:[departurePage]}; + lr.id = icao; + lr.computer = computer; + lr._setupPageWithData(); + lr.updateRunways(); + lr.updateActiveRunway(); + return lr; + }, + del: func() { + return nil; + }, + _setupPageWithData: func() { + me.title = ["DEPARTURE", " FROM ", left(me.id, 4)]; + if (!TMPYActive[me.computer].getBoolValue()) { + me.L6 = [" RETURN END", nil, "wht"]; + } else { + me.L6 = [" F-PLN", " TMPY", "yel"]; + me.arrowsColour[0][5] = "yel"; + } + + me.C1 = ["------- ", "SID", "wht"]; + me.R1 = ["-------", "TRANS ", "wht"]; + me.fontMatrix = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]; + me.arrowsMatrix = [[0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0]]; + me.arrowsColour = [["ack", "ack", "ack", "ack", "ack", "wht"], ["ack", "ack", "ack", "ack", "ack", "ack"]]; + }, + updateActiveRunway: func() { + if (me.selectedRunway != nil) { + if (fmgc.fp[2].departure_runway != nil) { + if (fmgc.fp[2].departure_runway.id == me.selectedRunway.id) { + me.L1 = [fmgc.fp[me.computer].departure_runway.id, " RWY", "grn"]; + } elsif (fmgc.fp[me.computer].departure_runway != nil) { + me.L1 = [fmgc.fp[me.computer].departure_runway.id, " RWY", "yel"]; + } else { + me.L1 = ["---", " RWY", "wht"]; + } + } elsif (fmgc.fp[me.computer].departure_runway != nil) { + me.L1 = [fmgc.fp[me.computer].departure_runway.id, " RWY", "yel"]; + } else { + me.L1 = ["---", " RWY", "wht"]; + } + } else { + me.L1 = ["---", " RWY", "wht"]; + } + canvas_mcdu.pageSwitch[me.computer].setBoolValue(0); + }, + updateRunways: func() { + me.depAirport = findAirportsByICAO(left(me.id, 4)); + me._runways = keys(me.depAirport[0].runways); + me.runways = sort(me._runways,func(a,b) cmp(a,b)); + + me.fourRunways = [nil, nil, nil, nil]; + + if (size(me.runways) >= 1) { + me.L2 = [" " ~ me.runways[0], nil, "blu"]; + me.C2 = [math.round(me.depAirport[0].runways[me.runways[0]].length) ~ "M", nil, "blu"]; + me.R2 = ["CRS" ~ math.round(me.depAirport[0].runways[me.runways[0]].heading), nil, "blu"]; + me.arrowsMatrix[0][1] = 1; + me.arrowsColour[0][1] = "blu"; + } + if (size(me.runways) >= 2) { + me.L3 = [" " ~ me.runways[1], nil, "blu"]; + me.C3 = [math.round(me.depAirport[0].runways[me.runways[1]].length) ~ "M", nil, "blu"]; + me.R3 = ["CRS" ~ math.round(me.depAirport[0].runways[me.runways[1]].heading), nil, "blu"]; + me.arrowsMatrix[0][2] = 1; + me.arrowsColour[0][2] = "blu"; + } + if (size(me.runways) >= 3) { + me.L4 = [" " ~ me.runways[2], nil, "blu"]; + me.C4 = [math.round(me.depAirport[0].runways[me.runways[2]].length) ~ "M", nil, "blu"]; + me.R4 = ["CRS" ~ math.round(me.depAirport[0].runways[me.runways[2]].heading), nil, "blu"]; + me.arrowsMatrix[0][3] = 1; + me.arrowsColour[0][3] = "blu"; + } + if (size(me.runways) >= 4) { + me.L5 = [" " ~ me.runways[3], nil, "blu"]; + me.C5 = [math.round(me.depAirport[0].runways[me.runways[3]].length) ~ "M", nil, "blu"]; + me.R5 = ["CRS" ~ math.round(me.depAirport[0].runways[me.runways[3]].heading), nil, "blu"]; + me.arrowsMatrix[0][4] = 1; + me.arrowsColour[0][4] = "blu"; + } + + if (size(me.runways) > 4) { + me.enableScroll = 1; + } + canvas_mcdu.pageSwitch[me.computer].setBoolValue(0); + }, + makeTmpy: func() { + if (!TMPYActive[me.computer].getBoolValue()) { + fmgc.flightplan.initTempFP(me.computer, 2); + me.L6 = [" F-PLN", " TMPY", "yel"]; + me.arrowsColour[0][5] = "yel"; + canvas_mcdu.pageSwitch[me.computer].setBoolValue(0); + } + }, + depPushbuttonLeft: func(index) { + if (size(me.runways) >= (index - 1)) { + me.selectedRunway = me.depAirport[0].runway(me.runways[index - 2]); + me.makeTmpy(); + fmgc.fp[me.computer].departure_runway = me.selectedRunway; + me.updateActiveRunway(); + fmgc.flightplan.checkWPOutputs(me.computer); + } else { + notAllowed(me.computer); + } + }, +}; \ No newline at end of file diff --git a/Nasal/MCDU/F-PLN.nas b/Nasal/MCDU/F-PLN.nas index 3e841584..7c4617df 100644 --- a/Nasal/MCDU/F-PLN.nas +++ b/Nasal/MCDU/F-PLN.nas @@ -140,33 +140,35 @@ var FPLNText = { } } else if (size(scratchpad) == 1) { formatError(me.computer.mcdu); - } else { - if (me.getText() == fmgc.fp[2].departure.id) { - if (canvas_mcdu.myLatRev != nil) { - canvas_mcdu.myLatRev.del(); + } else if (scratchpad == "") { + if (me.getText() == fmgc.fp[2].departure.id or left(me.getText(), 4) == fmgc.fp[2].departure.id) { + if (canvas_mcdu.myLatRev[me.computer.mcdu] != nil) { + canvas_mcdu.myLatRev[me.computer.mcdu].del(); } - canvas_mcdu.myLatRev = nil; - canvas_mcdu.myLatRev = latRev.new(0, me.getText()); + canvas_mcdu.myLatRev[me.computer.mcdu] = nil; + canvas_mcdu.myLatRev[me.computer.mcdu] = latRev.new(0, me.getText()); } elsif (me.index == fmgc.arrivalAirportI[2]) { - if (canvas_mcdu.myLatRev != nil) { - canvas_mcdu.myLatRev.del(); + if (canvas_mcdu.myLatRev[me.computer.mcdu] != nil) { + canvas_mcdu.myLatRev[me.computer.mcdu].del(); } - canvas_mcdu.myLatRev = nil; - canvas_mcdu.myLatRev = latRev.new(1, me.getText()); - } elsif (me.index == fmgc.currentWP[2]) { - if (canvas_mcdu.myLatRev != nil) { - canvas_mcdu.myLatRev.del(); + canvas_mcdu.myLatRev[me.computer.mcdu] = nil; + canvas_mcdu.myLatRev[me.computer.mcdu] = latRev.new(1, me.getText()); + } elsif (me.index == (fmgc.currentWP[2] - 1)) { + if (canvas_mcdu.myLatRev[me.computer.mcdu] != nil) { + canvas_mcdu.myLatRev[me.computer.mcdu].del(); } - canvas_mcdu.myLatRev = nil; - canvas_mcdu.myLatRev = latRev.new(2, me.getText()); + canvas_mcdu.myLatRev[me.computer.mcdu] = nil; + canvas_mcdu.myLatRev[me.computer.mcdu] = latRev.new(2, me.getText()); } else { - if (canvas_mcdu.myLatRev != nil) { - canvas_mcdu.myLatRev.del(); + if (canvas_mcdu.myLatRev[me.computer.mcdu] != nil) { + canvas_mcdu.myLatRev[me.computer.mcdu].del(); } - canvas_mcdu.myLatRev = nil; - canvas_mcdu.myLatRev = latRev.new(3, me.getText()); + canvas_mcdu.myLatRev[me.computer.mcdu] = nil; + canvas_mcdu.myLatRev[me.computer.mcdu] = latRev.new(3, me.getText()); } setprop("/MCDU[" ~ me.computer.mcdu ~ "]/page", "LATREV"); + } else { + notAllowed(me.computer.mcdu); } } }, diff --git a/Nasal/MCDU/LATREV.nas b/Nasal/MCDU/LATREV.nas index 309e7e39..cb241159 100644 --- a/Nasal/MCDU/LATREV.nas +++ b/Nasal/MCDU/LATREV.nas @@ -3,6 +3,7 @@ var latRev = { subtitle: [nil, nil], fontMatrix: [[0, 0, 0, 0, 0, 0],[0, 0, 0, 0, 0, 0]], arrowsMatrix: [[0, 0, 0, 0, 0, 0],[0, 0, 0, 0, 0, 0]], + arrowsColour: [["ack", "ack", "ack", "ack", "ack", "ack"],["ack", "ack", "ack", "ack", "ack", "ack"]], L1: [nil, nil, "ack"], # content, title, colour L2: [nil, nil, "ack"], L3: [nil, nil, "ack"], @@ -34,33 +35,44 @@ var latRev = { me.L3 = [" HOLD", nil, "wht"]; me.L6 = [" RETURN", nil, "wht"]; me.R1 = ["FIX INFO ", nil, "wht"]; - me.R2 = ["[ ]°/[ ]°/[ ]", "LL XING/INCR/NO", "blu"]; + me.R2 = ["[ ]°/[ ]°/[ ]", "LL XING/INCR/NO", "blu"]; me.arrowsMatrix = [[0, 1, 1, 0, 0, 1], [1, 0, 0, 0, 0, 0]]; + me.arrowsColour = [["ack", "wht", "wht", "ack", "ack", "wht"], ["wht", "ack", "ack", "ack", "ack", "ack"]]; me.fontMatrix = [[0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0]]; } else { me.title = ["LAT REV", " FROM ", me.id]; - if (me.type == 0) { - me.depAirport = findAirportsByICAO(me.id); + if (me.type == 0) { + if (size(me.id) > 4) { + me.depAirport = findAirportsByICAO(left(me.id, 4)); + } else { + me.depAirport = findAirportsByICAO(me.id); + } me.subtitle = [dmsToString(sprintf(me.depAirport[0].lat), "lat"), dmsToString(sprintf(me.depAirport[0].lon), "lon")]; me.L1 = [" DEPARTURE", nil, "wht"]; me.L2 = [" OFFSET", nil, "wht"]; me.L6 = [" RETURN", nil, "wht"]; me.R1 = ["FIX INFO ", nil, "wht"]; - me.R2 = ["[ ]°/[ ]°/[ ]", "LL XING/INCR/NO", "blu"]; - me.R3 = ["[ ]", "NEXT WPT ", "blu"]; - me.R4 = ["[ ]", "NEW DEST", "blu"]; + me.R2 = ["[ ]°/[ ]°/[ ]", "LL XING/INCR/NO", "blu"]; + me.R3 = ["[ ]", "NEXT WPT ", "blu"]; + me.R4 = ["[ ]", "NEW DEST", "blu"]; me.arrowsMatrix = [[1, 1, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0]]; + me.arrowsColour = [["wht", "wht", "ack", "ack", "ack", "wht"], ["wht", "ack", "ack", "ack", "ack", "ack"]]; me.fontMatrix = [[0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 0, 0]]; } elsif (me.type == 1) { - me.arrAirport = findAirportsByICAO(me.id); + if (size(me.id) > 4) { + me.arrAirport = findAirportsByICAO(left(me.id, 4)); + } else { + me.arrAirport = findAirportsByICAO(me.id); + } me.subtitle = [dmsToString(sprintf(me.arrAirport[0].lat), "lat"), dmsToString(sprintf(me.arrAirport[0].lon), "lon")]; me.L3 = [" ALTN", nil, "wht"]; - me.L4 = [" ALTN", "ENABLE", "blu"]; + me.L4 = [" ALTN", " ENABLE", "blu"]; me.L6 = [" RETURN", nil, "wht"]; me.R1 = ["ARRIVAL ", nil, "wht"]; - me.R3 = ["[ ]", "NEXT WPT ", "blu"]; + me.R3 = ["[ ]", "NEXT WPT ", "blu"]; me.arrowsMatrix = [[0, 0, 1, 1, 0, 1], [1, 0, 0, 0, 0, 0]]; + me.arrowsColour = [["ack", "ack", "wht", "blu", "ack", "wht"], ["wht", "ack", "ack", "ack", "ack", "ack"]]; me.fontMatrix = [[0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0]]; } elsif (me.type == 3) { if (size(me.id) == 2 or size(me.id) == 3) { @@ -72,13 +84,14 @@ var latRev = { } me.subtitle = [dmsToString(sprintf(me.wpt[0].lat), "lat"), dmsToString(sprintf(me.wpt[0].lon), "lon")]; me.L3 = [" HOLD", nil, "wht"]; - me.L4 = [" ALTN", "ENABLE", "blu"]; + me.L4 = [" ALTN", " ENABLE", "blu"]; me.L6 = [" RETURN", nil, "wht"]; me.R1 = ["FIX INFO ", nil, "wht"]; - me.R3 = ["[ ]", "NEXT WPT ", "blu"]; - me.R4 = ["[ ]", "NEW DEST", "blu"]; + me.R3 = ["[ ]", "NEXT WPT ", "blu"]; + me.R4 = ["[ ]", "NEW DEST", "blu"]; me.R5 = ["AIRWAYS ", nil, "wht"]; me.arrowsMatrix = [[0, 0, 1, 1, 0, 1], [1, 0, 0, 0, 1, 0]]; + me.arrowsColour = [["ack", "ack", "wht", "blu", "ack", "wht"], ["wht", "ack", "ack", "ack", "wht", "ack"]]; me.fontMatrix = [[0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 0, 0]]; } } @@ -86,13 +99,12 @@ var latRev = { }; var dmsToString = func(dms, type) { - var decimalSplit = split(".", dms); - var degrees = decimalSplit[0]; - var minutes = decimalSplit[1] * 60; + var degrees = int(dms); + var minutes = sprintf("%.1f",abs((dms - degrees) * 60)); if (type == "lat") { var sign = degrees >= 0 ? "N" : "S"; } else { var sign = degrees >= 0 ? "E" : "W"; } - return degrees ~ "g" ~ minutes ~ " " ~ sign; + return abs(degrees) ~ "g" ~ minutes ~ " " ~ sign; } \ No newline at end of file diff --git a/Nasal/MCDU/MCDU.nas b/Nasal/MCDU/MCDU.nas index 62c094fd..7d0520a2 100644 --- a/Nasal/MCDU/MCDU.nas +++ b/Nasal/MCDU/MCDU.nas @@ -105,6 +105,13 @@ var lskbutton = func(btn, i) { printInput("L1", i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "PRINTFUNC2") { printInput2("L1", i); + } else if (getprop("/MCDU[" ~ i ~ "]/page") == "LATREV") { + if (canvas_mcdu.myDeparture[i] != nil) { + canvas_mcdu.myDeparture[i].del(); + } + canvas_mcdu.myDeparture[i] = nil; + canvas_mcdu.myDeparture[i] = departurePage.new(canvas_mcdu.myLatRev[i].title[2], i); + setprop("/MCDU[" ~ i ~ "]/page", "DEPARTURE"); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNA" or getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNB") { FPLNButton("L", 1, i); } else { @@ -131,6 +138,8 @@ var lskbutton = func(btn, i) { printInput2("L2", i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNA" or getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNB") { FPLNButton("L", 2, i); + } else if (getprop("/MCDU[" ~ i ~ "]/page") == "DEPARTURE") { + canvas_mcdu.myDeparture[i].depPushbuttonLeft(2); } else { notAllowed(i); } @@ -149,6 +158,8 @@ var lskbutton = func(btn, i) { printInput2("L3", i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNA" or getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNB") { FPLNButton("L", 3, i); + } else if (getprop("/MCDU[" ~ i ~ "]/page") == "DEPARTURE") { + canvas_mcdu.myDeparture[i].depPushbuttonLeft(3); } else { notAllowed(i); } @@ -163,6 +174,8 @@ var lskbutton = func(btn, i) { printInput2("L4", i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNA" or getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNB") { FPLNButton("L", 4, i); + } else if (getprop("/MCDU[" ~ i ~ "]/page") == "DEPARTURE") { + canvas_mcdu.myDeparture[i].depPushbuttonLeft(4); } else { notAllowed(i); } @@ -185,6 +198,8 @@ var lskbutton = func(btn, i) { printInput2("L5", i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNA" or getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNB") { FPLNButton("L", 5, i); + } else if (getprop("/MCDU[" ~ i ~ "]/page") == "DEPARTURE") { + canvas_mcdu.myDeparture[i].depPushbuttonLeft(5); } else { notAllowed(i); } @@ -203,6 +218,12 @@ var lskbutton = func(btn, i) { FPLNButton("L", 6, i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "LATREV") { setprop("/MCDU[" ~ i ~ "]/page", "F-PLNA"); + } else if (getprop("/MCDU[" ~ i ~ "]/page") == "DEPARTURE") { + if (canvas_mcdu.TMPYActive[i].getBoolValue()) { + setprop("/MCDU[" ~ i ~ "]/page", "F-PLNA"); + } else { + setprop("/MCDU[" ~ i ~ "]/page", "LATREV"); + } } else { notAllowed(i); } From b41269af8a1cf3aadce33d40233de89ab94e7e1c Mon Sep 17 00:00:00 2001 From: legoboyvdlp R Date: Mon, 30 Dec 2019 21:24:28 +0000 Subject: [PATCH 03/51] FBW: fix stupid bug --- Nasal/FBW/it-fbw.nas | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Nasal/FBW/it-fbw.nas b/Nasal/FBW/it-fbw.nas index af4865da..4effaa00 100644 --- a/Nasal/FBW/it-fbw.nas +++ b/Nasal/FBW/it-fbw.nas @@ -179,7 +179,7 @@ var update_loop = func { FBW.Lights.elac2.setValue(1); } - if (sec1_sw and !sec1_fail and dc_ess >= 110) { + if (sec1_sw and !sec1_fail and dc_ess >= 25) { setprop("/systems/fctl/sec1", 1); setprop("/systems/failures/spoiler-l3", 0); setprop("/systems/failures/spoiler-r3", 0); @@ -193,7 +193,7 @@ var update_loop = func { setprop("/systems/failures/spoiler-r4", 1); } - if (sec2_sw and !sec2_fail and dc2 >= 110) { + if (sec2_sw and !sec2_fail and dc2 >= 25) { setprop("/systems/fctl/sec2", 1); setprop("/systems/failures/spoiler-l5", 0); setprop("/systems/failures/spoiler-r5", 0); @@ -203,7 +203,7 @@ var update_loop = func { setprop("/systems/failures/spoiler-r5", 1); } - if (sec3_sw and !sec3_fail and dc2 >= 110) { + if (sec3_sw and !sec3_fail and dc2 >= 25) { setprop("/systems/fctl/sec3", 1); setprop("/systems/failures/spoiler-l1", 0); setprop("/systems/failures/spoiler-r1", 0); From d36c9505ce618bceb3246fc4e5db7961c0a1432f Mon Sep 17 00:00:00 2001 From: legoboyvdlp R Date: Tue, 31 Dec 2019 17:48:23 +0000 Subject: [PATCH 04/51] Major improvements - discontinuity, lat rev, sequencing, etc --- Nasal/FMGC/flightplan.nas | 3 + Nasal/MCDU/ARRIVAL.nas | 163 +++++++++++++++++++++++++++++++++++++ Nasal/MCDU/DEPARTURE.nas | 50 ++++++++---- Nasal/MCDU/F-PLN.nas | 167 +++++++++++++++++++++++++++++++------- Nasal/MCDU/LATREV.nas | 110 +++++++++++++++++++++++-- Nasal/MCDU/MCDU.nas | 10 +++ Nasal/Sim/libraries.nas | 1 + 7 files changed, 456 insertions(+), 48 deletions(-) create mode 100644 Nasal/MCDU/ARRIVAL.nas diff --git a/Nasal/FMGC/flightplan.nas b/Nasal/FMGC/flightplan.nas index 19d9a7a8..58b4a8a4 100644 --- a/Nasal/FMGC/flightplan.nas +++ b/Nasal/FMGC/flightplan.nas @@ -129,6 +129,9 @@ var flightplan = { } currentWP[2] = 0; + + # Create discontinuity + fmgc.fp[2].insertWP(createDiscontinuity(), 1); } me.checkWPOutputs(n); diff --git a/Nasal/MCDU/ARRIVAL.nas b/Nasal/MCDU/ARRIVAL.nas new file mode 100644 index 00000000..ba578c47 --- /dev/null +++ b/Nasal/MCDU/ARRIVAL.nas @@ -0,0 +1,163 @@ +var arrivalPage = { + title: [nil, nil, nil], + subtitle: [nil, nil], + fontMatrix: [[0, 0, 0, 0, 0, 0],[0, 0, 0, 0, 0, 0]], + arrowsMatrix: [[0, 0, 0, 0, 0, 0],[0, 0, 0, 0, 0, 0]], + arrowsColour: [["ack", "ack", "ack", "ack", "ack", "ack"],["ack", "ack", "ack", "ack", "ack", "ack"]], + L1: [nil, nil, "ack"], # content, title, colour + L2: [nil, nil, "ack"], + L3: [nil, nil, "ack"], + L4: [nil, nil, "ack"], + L5: [nil, nil, "ack"], + L6: [nil, nil, "ack"], + C1: [nil, nil, "ack"], + C2: [nil, nil, "ack"], + C3: [nil, nil, "ack"], + C4: [nil, nil, "ack"], + C5: [nil, nil, "ack"], + C6: [nil, nil, "ack"], + R1: [nil, nil, "ack"], + R2: [nil, nil, "ack"], + R3: [nil, nil, "ack"], + R4: [nil, nil, "ack"], + R5: [nil, nil, "ack"], + R6: [nil, nil, "ack"], + arrAirport: nil, + runways: nil, + selectedRunway: nil, + sids: nil, + computer: nil, + enableScroll: 0, + scroll: 0, + _runways: nil, + _sids: nil, + new: func(icao, computer) { + var lr = {parents:[arrivalPage]}; + lr.id = icao; + lr.computer = computer; + lr._setupPageWithData(); + lr.updateRunways(); + if (fmgc.fp[2].destination_runway != nil) { + lr.selectedRunway = fmgc.fp[2].destination_runway; + } + lr.updateActiveRunway(); + return lr; + }, + del: func() { + return nil; + }, + _setupPageWithData: func() { + me.title = ["ARRIVAL", " TO ", left(me.id, 4)]; + if (!TMPYActive[me.computer].getBoolValue()) { + me.L6 = [" RETURN END", nil, "wht"]; + } else { + me.L6 = [" F-PLN", " TMPY", "yel"]; + me.arrowsColour[0][5] = "yel"; + } + + me.C1 = ["------- ", "VIA", "wht"]; + me.R1 = ["-------", "STAR ", "wht"]; + me.R1 = ["-------", "TRANS ", "wht"]; + me.fontMatrix = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]; + me.arrowsMatrix = [[0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0]]; + me.arrowsColour = [["ack", "ack", "ack", "ack", "ack", "wht"], ["ack", "ack", "ack", "ack", "ack", "ack"]]; + }, + updateActiveRunway: func() { + if (me.selectedRunway != nil) { + if (fmgc.fp[2].destination_runway != nil) { + if (fmgc.fp[2].destination_runway.id == me.selectedRunway.id) { + me.L1 = [fmgc.fp[2].destination_runway.id, " RWY", "grn"]; + } elsif (fmgc.fp[me.computer].destination_runway != nil) { + me.L1 = [fmgc.fp[me.computer].destination_runway.id, " RWY", "yel"]; + } else { + me.L1 = ["---", " RWY", "wht"]; + } + } elsif (fmgc.fp[me.computer].destination_runway != nil) { + me.L1 = [fmgc.fp[me.computer].destination_runway.id, " RWY", "yel"]; + } else { + me.L1 = ["---", " RWY", "wht"]; + } + } else { + me.L1 = ["---", " RWY", "wht"]; + } + canvas_mcdu.pageSwitch[me.computer].setBoolValue(0); + }, + updateRunways: func() { + me.arrAirport = findAirportsByICAO(left(me.id, 4)); + me._runways = keys(me.arrAirport[0].runways); + me.runways = sort(me._runways,func(a,b) cmp(a,b)); + + me.fourRunways = [nil, nil, nil, nil]; + + if (size(me.runways) >= 1) { + me.L2 = [" " ~ me.runways[0 + me.scroll], nil, "blu"]; + me.C2 = [math.round(me.arrAirport[0].runways[me.runways[0 + me.scroll]].length) ~ "M", nil, "blu"]; + me.R2 = ["CRS" ~ math.round(me.arrAirport[0].runways[me.runways[0 + me.scroll]].heading), nil, "blu"]; + me.arrowsMatrix[0][1] = 1; + me.arrowsColour[0][1] = "blu"; + } + if (size(me.runways) >= 2) { + me.L3 = [" " ~ me.runways[1 + me.scroll], nil, "blu"]; + me.C3 = [math.round(me.arrAirport[0].runways[me.runways[1 + me.scroll]].length) ~ "M", nil, "blu"]; + me.R3 = ["CRS" ~ math.round(me.arrAirport[0].runways[me.runways[1 + me.scroll]].heading), nil, "blu"]; + me.arrowsMatrix[0][2] = 1; + me.arrowsColour[0][2] = "blu"; + } + if (size(me.runways) >= 3) { + me.L4 = [" " ~ me.runways[2 + me.scroll], nil, "blu"]; + me.C4 = [math.round(me.arrAirport[0].runways[me.runways[2 + me.scroll]].length) ~ "M", nil, "blu"]; + me.R4 = ["CRS" ~ math.round(me.arrAirport[0].runways[me.runways[2 + me.scroll]].heading), nil, "blu"]; + me.arrowsMatrix[0][3] = 1; + me.arrowsColour[0][3] = "blu"; + } + if (size(me.runways) >= 4) { + me.L5 = [" " ~ me.runways[3 + me.scroll], nil, "blu"]; + me.C5 = [math.round(me.arrAirport[0].runways[me.runways[3 + me.scroll]].length) ~ "M", nil, "blu"]; + me.R5 = ["CRS" ~ math.round(me.arrAirport[0].runways[me.runways[3 + me.scroll]].heading), nil, "blu"]; + me.arrowsMatrix[0][4] = 1; + me.arrowsColour[0][4] = "blu"; + } + + if (size(me.runways) > 4) { + me.enableScroll = 1; + } + canvas_mcdu.pageSwitch[me.computer].setBoolValue(0); + }, + makeTmpy: func() { + if (!TMPYActive[me.computer].getBoolValue()) { + fmgc.flightplan.initTempFP(me.computer, 2); + me.L6 = [" F-PLN", " TMPY", "yel"]; + me.arrowsColour[0][5] = "yel"; + canvas_mcdu.pageSwitch[me.computer].setBoolValue(0); + } + }, + scrollUp: func() { + if (me.enableScroll) { + me.scroll += 1; + if (me.scroll > size(me.runways) - 4) { + me.scroll = 0; + } + me.updateRunways(); + } + }, + scrollDn: func() { + if (me.enableScroll) { + me.scroll -= 1; + if (me.scroll < 0) { + me.scroll = size(me.runways) - 4; + } + me.updateRunways(); + } + }, + depPushbuttonLeft: func(index) { + if (size(me.runways) >= (index - 1)) { + me.selectedRunway = me.arrAirport[0].runway(me.runways[index - 2 + me.scroll]); + me.makeTmpy(); + fmgc.fp[me.computer].destination_runway = me.selectedRunway; + me.updateActiveRunway(); + fmgc.flightplan.checkWPOutputs(me.computer); + } else { + notAllowed(me.computer); + } + }, +}; \ No newline at end of file diff --git a/Nasal/MCDU/DEPARTURE.nas b/Nasal/MCDU/DEPARTURE.nas index be7f321c..c23cb86b 100644 --- a/Nasal/MCDU/DEPARTURE.nas +++ b/Nasal/MCDU/DEPARTURE.nas @@ -28,6 +28,7 @@ var departurePage = { sids: nil, computer: nil, enableScroll: 0, + scroll: 0, _runways: nil, _sids: nil, new: func(icao, computer) { @@ -36,6 +37,9 @@ var departurePage = { lr.computer = computer; lr._setupPageWithData(); lr.updateRunways(); + if (fmgc.fp[2].departure_runway != nil) { + lr.selectedRunway = fmgc.fp[2].departure_runway; + } lr.updateActiveRunway(); return lr; }, @@ -61,7 +65,7 @@ var departurePage = { if (me.selectedRunway != nil) { if (fmgc.fp[2].departure_runway != nil) { if (fmgc.fp[2].departure_runway.id == me.selectedRunway.id) { - me.L1 = [fmgc.fp[me.computer].departure_runway.id, " RWY", "grn"]; + me.L1 = [fmgc.fp[2].departure_runway.id, " RWY", "grn"]; } elsif (fmgc.fp[me.computer].departure_runway != nil) { me.L1 = [fmgc.fp[me.computer].departure_runway.id, " RWY", "yel"]; } else { @@ -85,30 +89,30 @@ var departurePage = { me.fourRunways = [nil, nil, nil, nil]; if (size(me.runways) >= 1) { - me.L2 = [" " ~ me.runways[0], nil, "blu"]; - me.C2 = [math.round(me.depAirport[0].runways[me.runways[0]].length) ~ "M", nil, "blu"]; - me.R2 = ["CRS" ~ math.round(me.depAirport[0].runways[me.runways[0]].heading), nil, "blu"]; + me.L2 = [" " ~ me.runways[0 + me.scroll], nil, "blu"]; + me.C2 = [math.round(me.depAirport[0].runways[me.runways[0 + me.scroll]].length) ~ "M", nil, "blu"]; + me.R2 = ["CRS" ~ math.round(me.depAirport[0].runways[me.runways[0 + me.scroll]].heading), nil, "blu"]; me.arrowsMatrix[0][1] = 1; me.arrowsColour[0][1] = "blu"; } if (size(me.runways) >= 2) { - me.L3 = [" " ~ me.runways[1], nil, "blu"]; - me.C3 = [math.round(me.depAirport[0].runways[me.runways[1]].length) ~ "M", nil, "blu"]; - me.R3 = ["CRS" ~ math.round(me.depAirport[0].runways[me.runways[1]].heading), nil, "blu"]; + me.L3 = [" " ~ me.runways[1 + me.scroll], nil, "blu"]; + me.C3 = [math.round(me.depAirport[0].runways[me.runways[1 + me.scroll]].length) ~ "M", nil, "blu"]; + me.R3 = ["CRS" ~ math.round(me.depAirport[0].runways[me.runways[1 + me.scroll]].heading), nil, "blu"]; me.arrowsMatrix[0][2] = 1; me.arrowsColour[0][2] = "blu"; } if (size(me.runways) >= 3) { - me.L4 = [" " ~ me.runways[2], nil, "blu"]; - me.C4 = [math.round(me.depAirport[0].runways[me.runways[2]].length) ~ "M", nil, "blu"]; - me.R4 = ["CRS" ~ math.round(me.depAirport[0].runways[me.runways[2]].heading), nil, "blu"]; + me.L4 = [" " ~ me.runways[2 + me.scroll], nil, "blu"]; + me.C4 = [math.round(me.depAirport[0].runways[me.runways[2 + me.scroll]].length) ~ "M", nil, "blu"]; + me.R4 = ["CRS" ~ math.round(me.depAirport[0].runways[me.runways[2 + me.scroll]].heading), nil, "blu"]; me.arrowsMatrix[0][3] = 1; me.arrowsColour[0][3] = "blu"; } if (size(me.runways) >= 4) { - me.L5 = [" " ~ me.runways[3], nil, "blu"]; - me.C5 = [math.round(me.depAirport[0].runways[me.runways[3]].length) ~ "M", nil, "blu"]; - me.R5 = ["CRS" ~ math.round(me.depAirport[0].runways[me.runways[3]].heading), nil, "blu"]; + me.L5 = [" " ~ me.runways[3 + me.scroll], nil, "blu"]; + me.C5 = [math.round(me.depAirport[0].runways[me.runways[3 + me.scroll]].length) ~ "M", nil, "blu"]; + me.R5 = ["CRS" ~ math.round(me.depAirport[0].runways[me.runways[3 + me.scroll]].heading), nil, "blu"]; me.arrowsMatrix[0][4] = 1; me.arrowsColour[0][4] = "blu"; } @@ -126,9 +130,27 @@ var departurePage = { canvas_mcdu.pageSwitch[me.computer].setBoolValue(0); } }, + scrollUp: func() { + if (me.enableScroll) { + me.scroll += 1; + if (me.scroll > size(me.runways) - 4) { + me.scroll = 0; + } + me.updateRunways(); + } + }, + scrollDn: func() { + if (me.enableScroll) { + me.scroll -= 1; + if (me.scroll < 0) { + me.scroll = size(me.runways) - 4; + } + me.updateRunways(); + } + }, depPushbuttonLeft: func(index) { if (size(me.runways) >= (index - 1)) { - me.selectedRunway = me.depAirport[0].runway(me.runways[index - 2]); + me.selectedRunway = me.depAirport[0].runway(me.runways[index - 2 + me.scroll]); me.makeTmpy(); fmgc.fp[me.computer].departure_runway = me.selectedRunway; me.updateActiveRunway(); diff --git a/Nasal/MCDU/F-PLN.nas b/Nasal/MCDU/F-PLN.nas index 7c4617df..7e813a0f 100644 --- a/Nasal/MCDU/F-PLN.nas +++ b/Nasal/MCDU/F-PLN.nas @@ -18,10 +18,11 @@ var clearFPLNComputer = func { } var StaticText = { - new: func(computer, type) { + new: func(computer, type, index = nil) { var in = {parents:[StaticText]}; in.type = type; in.computer = computer; + in.index = index; return in; }, getText: func() { @@ -45,7 +46,48 @@ var StaticText = { }, type: nil, pushButtonLeft: func() { - notAllowed(me.computer.mcdu); + if (me.type != "discontinuity") { + notAllowed(me.computer.mcdu); + } else { + var scratchpad = getprop("/MCDU[" ~ me.computer.mcdu ~ "]/scratchpad"); + if (TMPYActive[me.computer.mcdu].getBoolValue()) { + if (scratchpad == "CLR") { + if (fmgc.flightplan.deleteWP(me.index, me.computer.mcdu, 0) != 0) { + notAllowed(me.computer.mcdu); + } else { + setprop("/MCDU[" ~ me.computer.mcdu ~ "]/scratchpad-msg", 0); + setprop("/MCDU[" ~ me.computer.mcdu ~ "]/scratchpad", ""); + } + } elsif (scratchpad == "") { + if (canvas_mcdu.myLatRev[me.computer.mcdu] != nil) { + canvas_mcdu.myLatRev[me.computer.mcdu].del(); + } + canvas_mcdu.myLatRev[me.computer.mcdu] = nil; + canvas_mcdu.myLatRev[me.computer.mcdu] = latRev.new(4, "DISCON", me.index, me.computer.mcdu); + setprop("/MCDU[" ~ me.computer.mcdu ~ "]/page", "LATREV"); + } else { + notAllowed(me.computer.mcdu); + } + } else { + if (scratchpad == "CLR") { + if (fmgc.flightplan.deleteWP(me.index, 2, 0) != 0) { + notAllowed(me.computer.mcdu); + } else { + setprop("/MCDU[" ~ me.computer.mcdu ~ "]/scratchpad-msg", 0); + setprop("/MCDU[" ~ me.computer.mcdu ~ "]/scratchpad", ""); + } + } elsif (scratchpad == "") { + if (canvas_mcdu.myLatRev[me.computer.mcdu] != nil) { + canvas_mcdu.myLatRev[me.computer.mcdu].del(); + } + canvas_mcdu.myLatRev[me.computer.mcdu] = nil; + canvas_mcdu.myLatRev[me.computer.mcdu] = latRev.new(4, "DISCON", me.index, me.computer.mcdu); + setprop("/MCDU[" ~ me.computer.mcdu ~ "]/page", "LATREV"); + } else { + notAllowed(me.computer.mcdu); + } + } + } }, pushButtonRight: func() { notAllowed(me.computer.mcdu); @@ -53,6 +95,7 @@ var StaticText = { }; var FPLNText = { + _text: nil, new: func(computer, wp, dest, fp, wpIndex) { var in = {parents:[FPLNText]}; in.wp = wp; @@ -63,7 +106,12 @@ var FPLNText = { return in; }, getText: func() { - return me.wp.wp_name; + me._text = split("-",me.wp.wp_name); + if (size(me._text) == 2) { + return me._text[0] ~ me._text[1]; + } else { + return me._text[0]; + } }, getColor: func(i) { if (TMPYActive[i].getBoolValue()) { @@ -112,7 +160,16 @@ var FPLNText = { } } else { if (size(scratchpad) == 5) { - var insertReturn = fmgc.flightplan.insertFix(scratchpad, me.index, me.computer.mcdu); + var indexWp = fmgc.fp[me.computer.mcdu].indexOfWP(findFixesByID(scratchpad)); + if (indexWp == -1) { + var insertReturn = fmgc.flightplan.insertFix(scratchpad, me.index, me.computer.mcdu); + fmgc.fp[me.computer.mcdu].insertWP(createDiscontinuity(), me.index + 1); + fmgc.flightplan.checkWPOutputs(me.computer.mcdu); + } else { + for (var i = me.index; i == indexWp; i = i + 1) { + fmgc.flightplan.deleteWP(i, me.computer.mcdu, 0); + } + } if (insertReturn == 2) { notAllowed(me.computer.mcdu); } else if (insertReturn == 1) { @@ -121,7 +178,16 @@ var FPLNText = { setprop("/MCDU[" ~ me.computer.mcdu ~ "]/scratchpad", ""); } } else if (size(scratchpad) == 4) { - var insertReturn = fmgc.flightplan.insertArpt(scratchpad, me.index, me.computer.mcdu); + var indexWp = fmgc.fp[me.computer.mcdu].indexOfWP(findAirportsByICAO(scratchpad)); + if (indexWp == -1) { + var insertReturn = fmgc.flightplan.insertArpt(scratchpad, me.index, me.computer.mcdu); + fmgc.fp[me.computer.mcdu].insertWP(createDiscontinuity(), me.index + 1); + fmgc.flightplan.checkWPOutputs(me.computer.mcdu); + } else { + for (var i = me.index; i == indexWp; i = i + 1) { + fmgc.flightplan.deleteWP(i, me.computer.mcdu, 0); + } + } if (insertReturn == 2) { notAllowed(me.computer.mcdu); } else if (insertReturn == 1) { @@ -130,7 +196,16 @@ var FPLNText = { setprop("/MCDU[" ~ me.computer.mcdu ~ "]/scratchpad", ""); } } else if (size(scratchpad) == 3 or size(scratchpad) == 2) { - var insertReturn = fmgc.flightplan.insertNavaid(scratchpad, me.index, me.computer.mcdu); + var indexWp = fmgc.fp[me.computer.mcdu].indexOfWP(findNavaidsByID(scratchpad)); + if (indexWp == -1) { + var insertReturn = fmgc.flightplan.insertNavaid(scratchpad, me.index, me.computer.mcdu); + fmgc.fp[me.computer.mcdu].insertWP(createDiscontinuity(), me.index + 1); + fmgc.flightplan.checkWPOutputs(me.computer.mcdu); + } else { + for (var i = me.index; i == indexWp; i = i + 1) { + fmgc.flightplan.deleteWP(i, me.computer.mcdu, 0); + } + } if (insertReturn == 2) { notAllowed(me.computer.mcdu); } else if (insertReturn == 1) { @@ -141,32 +216,61 @@ var FPLNText = { } else if (size(scratchpad) == 1) { formatError(me.computer.mcdu); } else if (scratchpad == "") { - if (me.getText() == fmgc.fp[2].departure.id or left(me.getText(), 4) == fmgc.fp[2].departure.id) { - if (canvas_mcdu.myLatRev[me.computer.mcdu] != nil) { - canvas_mcdu.myLatRev[me.computer.mcdu].del(); + if (!TMPYActive[me.computer.mcdu].getBoolValue()) { + if (me.getText() == fmgc.fp[2].departure.id or left(me.getText(), 4) == fmgc.fp[2].departure.id) { + if (canvas_mcdu.myLatRev[me.computer.mcdu] != nil) { + canvas_mcdu.myLatRev[me.computer.mcdu].del(); + } + canvas_mcdu.myLatRev[me.computer.mcdu] = nil; + canvas_mcdu.myLatRev[me.computer.mcdu] = latRev.new(0, me.getText(), me.index, me.computer.mcdu); + } elsif (me.index == fmgc.arrivalAirportI[2]) { + if (canvas_mcdu.myLatRev[me.computer.mcdu] != nil) { + canvas_mcdu.myLatRev[me.computer.mcdu].del(); + } + canvas_mcdu.myLatRev[me.computer.mcdu] = nil; + canvas_mcdu.myLatRev[me.computer.mcdu] = latRev.new(1, me.getText(), me.index, me.computer.mcdu); + } elsif (me.index == (fmgc.currentWP[2] - 1)) { + if (canvas_mcdu.myLatRev[me.computer.mcdu] != nil) { + canvas_mcdu.myLatRev[me.computer.mcdu].del(); + } + canvas_mcdu.myLatRev[me.computer.mcdu] = nil; + canvas_mcdu.myLatRev[me.computer.mcdu] = latRev.new(2, me.getText(), me.index, me.computer.mcdu); + } else { + if (canvas_mcdu.myLatRev[me.computer.mcdu] != nil) { + canvas_mcdu.myLatRev[me.computer.mcdu].del(); + } + canvas_mcdu.myLatRev[me.computer.mcdu] = nil; + canvas_mcdu.myLatRev[me.computer.mcdu] = latRev.new(3, me.getText(), me.index, me.computer.mcdu); # todo must not be available from lat lon / place - brg - dist / abeam etc } - canvas_mcdu.myLatRev[me.computer.mcdu] = nil; - canvas_mcdu.myLatRev[me.computer.mcdu] = latRev.new(0, me.getText()); - } elsif (me.index == fmgc.arrivalAirportI[2]) { - if (canvas_mcdu.myLatRev[me.computer.mcdu] != nil) { - canvas_mcdu.myLatRev[me.computer.mcdu].del(); - } - canvas_mcdu.myLatRev[me.computer.mcdu] = nil; - canvas_mcdu.myLatRev[me.computer.mcdu] = latRev.new(1, me.getText()); - } elsif (me.index == (fmgc.currentWP[2] - 1)) { - if (canvas_mcdu.myLatRev[me.computer.mcdu] != nil) { - canvas_mcdu.myLatRev[me.computer.mcdu].del(); - } - canvas_mcdu.myLatRev[me.computer.mcdu] = nil; - canvas_mcdu.myLatRev[me.computer.mcdu] = latRev.new(2, me.getText()); + setprop("/MCDU[" ~ me.computer.mcdu ~ "]/page", "LATREV"); } else { - if (canvas_mcdu.myLatRev[me.computer.mcdu] != nil) { - canvas_mcdu.myLatRev[me.computer.mcdu].del(); + if (me.getText() == fmgc.fp[me.computer.mcdu].departure.id or left(me.getText(), 4) == fmgc.fp[me.computer.mcdu].departure.id) { + if (canvas_mcdu.myLatRev[me.computer.mcdu] != nil) { + canvas_mcdu.myLatRev[me.computer.mcdu].del(); + } + canvas_mcdu.myLatRev[me.computer.mcdu] = nil; + canvas_mcdu.myLatRev[me.computer.mcdu] = latRev.new(0, me.getText(), me.index, me.computer.mcdu); + } elsif (me.index == fmgc.arrivalAirportI[me.computer.mcdu]) { + if (canvas_mcdu.myLatRev[me.computer.mcdu] != nil) { + canvas_mcdu.myLatRev[me.computer.mcdu].del(); + } + canvas_mcdu.myLatRev[me.computer.mcdu] = nil; + canvas_mcdu.myLatRev[me.computer.mcdu] = latRev.new(1, me.getText(), me.index, me.computer.mcdu); + } elsif (me.index == (fmgc.currentWP[2] - 1)) { # not a bug for PPOS + if (canvas_mcdu.myLatRev[me.computer.mcdu] != nil) { + canvas_mcdu.myLatRev[me.computer.mcdu].del(); + } + canvas_mcdu.myLatRev[me.computer.mcdu] = nil; + canvas_mcdu.myLatRev[me.computer.mcdu] = latRev.new(2, me.getText(), me.index, me.computer.mcdu); + } else { + if (canvas_mcdu.myLatRev[me.computer.mcdu] != nil) { + canvas_mcdu.myLatRev[me.computer.mcdu].del(); + } + canvas_mcdu.myLatRev[me.computer.mcdu] = nil; + canvas_mcdu.myLatRev[me.computer.mcdu] = latRev.new(3, me.getText(), me.index, me.computer.mcdu); # todo must not be available from lat lon / place - brg - dist / abeam etc } - canvas_mcdu.myLatRev[me.computer.mcdu] = nil; - canvas_mcdu.myLatRev[me.computer.mcdu] = latRev.new(3, me.getText()); + setprop("/MCDU[" ~ me.computer.mcdu ~ "]/page", "LATREV"); } - setprop("/MCDU[" ~ me.computer.mcdu ~ "]/page", "LATREV"); } else { notAllowed(me.computer.mcdu); } @@ -228,7 +332,12 @@ var FPLNLineComputer = { if (j == me.destIndex) { me.dest = 1; } - append(me.planList, FPLNText.new(me, fpln.getWP(j), me.dest, fplnID, j)); + var wpt = fpln.getWP(j); + if (wpt.wp_name == "DISCONTINUITY") { + append(me.planList, StaticText.new(me, "discontinuity", j)); + } else { + append(me.planList, FPLNText.new(me, fpln.getWP(j), me.dest, fplnID, j)); + } } if (debug == 1) printf("%d: dest is: %s", me.mcdu, fpln.getWP(me.destIndex).wp_name); } diff --git a/Nasal/MCDU/LATREV.nas b/Nasal/MCDU/LATREV.nas index cb241159..c82cf8ac 100644 --- a/Nasal/MCDU/LATREV.nas +++ b/Nasal/MCDU/LATREV.nas @@ -18,16 +18,31 @@ var latRev = { R6: [nil, nil, "ack"], depAirport: nil, arrAirport: nil, - new: func(type, id) { + index: nil, + computer: nil, + new: func(type, id, index, computer) { var lr = {parents:[latRev]}; - lr.type = type; # 0 = origin 1 = destination 2 = ppos (from waypoint) 3 = generic wpt + lr.type = type; # 0 = origin 1 = destination 2 = ppos (from waypoint) 3 = generic wpt, 4 = discon lr.id = id; + lr.index = index; + lr.computer = computer; lr._setupPageWithData(); + lr._checkTmpy(); return lr; }, del: func() { return nil; }, + _checkTmpy: func() { + if (TMPYActive[me.computer].getBoolValue()) { + me.L6 = [" F-PLN", " TMPY", "yel"]; + me.arrowsColour[0][5] = "yel"; + me.R2[2] = "yel"; + me.R3[2] = "yel"; + me.R4[2] = "yel"; + canvas_mcdu.pageSwitch[me.computer].setBoolValue(0); + } + }, _setupPageWithData: func() { if (me.type == 2) { me.title = ["LAT REV", " FROM ", "PPOS"]; @@ -39,6 +54,14 @@ var latRev = { me.arrowsMatrix = [[0, 1, 1, 0, 0, 1], [1, 0, 0, 0, 0, 0]]; me.arrowsColour = [["ack", "wht", "wht", "ack", "ack", "wht"], ["wht", "ack", "ack", "ack", "ack", "ack"]]; me.fontMatrix = [[0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0]]; + } elsif (me.type == 4) { + me.title = ["LAT REV", " FROM ", "DISCON"]; + me.R3 = ["[ ]", "NEXT WPT ", "blu"]; + me.R4 = ["[ ]", "NEW DEST", "blu"]; + me.L6 = [" RETURN", nil, "wht"]; + me.arrowsMatrix = [[0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0]]; + me.arrowsColour = [["ack", "ack", "ack", "ack", "ack", "wht"], ["ack", "ack", "ack", "ack", "ack", "ack"]]; + me.fontMatrix = [[0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 0, 0]]; } else { me.title = ["LAT REV", " FROM ", me.id]; @@ -54,7 +77,7 @@ var latRev = { me.L6 = [" RETURN", nil, "wht"]; me.R1 = ["FIX INFO ", nil, "wht"]; me.R2 = ["[ ]°/[ ]°/[ ]", "LL XING/INCR/NO", "blu"]; - me.R3 = ["[ ]", "NEXT WPT ", "blu"]; + me.R3 = ["[ ]", "NEXT WPT ", "blu"]; me.R4 = ["[ ]", "NEW DEST", "blu"]; me.arrowsMatrix = [[1, 1, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0]]; me.arrowsColour = [["wht", "wht", "ack", "ack", "ack", "wht"], ["wht", "ack", "ack", "ack", "ack", "ack"]]; @@ -70,7 +93,7 @@ var latRev = { me.L4 = [" ALTN", " ENABLE", "blu"]; me.L6 = [" RETURN", nil, "wht"]; me.R1 = ["ARRIVAL ", nil, "wht"]; - me.R3 = ["[ ]", "NEXT WPT ", "blu"]; + me.R3 = ["[ ]", "NEXT WPT ", "blu"]; me.arrowsMatrix = [[0, 0, 1, 1, 0, 1], [1, 0, 0, 0, 0, 0]]; me.arrowsColour = [["ack", "ack", "wht", "blu", "ack", "wht"], ["wht", "ack", "ack", "ack", "ack", "ack"]]; me.fontMatrix = [[0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0]]; @@ -87,7 +110,7 @@ var latRev = { me.L4 = [" ALTN", " ENABLE", "blu"]; me.L6 = [" RETURN", nil, "wht"]; me.R1 = ["FIX INFO ", nil, "wht"]; - me.R3 = ["[ ]", "NEXT WPT ", "blu"]; + me.R3 = ["[ ]", "NEXT WPT ", "blu"]; me.R4 = ["[ ]", "NEW DEST", "blu"]; me.R5 = ["AIRWAYS ", nil, "wht"]; me.arrowsMatrix = [[0, 0, 1, 1, 0, 1], [1, 0, 0, 0, 1, 0]]; @@ -96,6 +119,83 @@ var latRev = { } } }, + makeTmpy: func() { + if (!TMPYActive[me.computer].getBoolValue()) { + fmgc.flightplan.initTempFP(me.computer, 2); + me._checkTmpy(); + } + }, + nextWpt: func() { + me.makeTmpy(); + me.R3 = [getprop("/MCDU[" ~ me.computer ~ "]/scratchpad"), "NEXT WPT ", "yel"]; + me.fontMatrix[1][2] = 0; + + # check if it is part of the active f-pln, if so delete intermediate wpts, if not create discontinuiity after it with original wpts + if (size(me.R3[0]) == 5) { + var fix = findFixesByID(me.R3[0]); + if (fix != nil) { + var indexWp = fmgc.fp[me.computer].indexOfWP(fix[0]); + if (indexWp == -1) { + var _insert = fmgc.flightplan.insertFix(me.R3[0], me.index + 1, me.computer); + fmgc.fp[me.computer].insertWP(createDiscontinuity(), me.index + 2); + fmgc.flightplan.checkWPOutputs(me.computer); + } else { + for (var i = me.index + 1; i == indexWp; i = i + 1) { + fmgc.flightplan.deleteWP(i, me.computer, 0); + } + var _insert = fmgc.flightplan.insertFix(me.R3[0], me.index + 1, me.computer); + } + } else { + var _insert = 1; + } + } elsif (size(me.R3[0]) == 4) { + var airport = findAirportsByICAO(me.R3[0]); + if (airport != nil) { + var indexWp = fmgc.fp[me.computer].indexOfWP(fix[0]); + if (indexWp == -1) { + var _insert = fmgc.flightplan.insertArpt(me.R3[0], me.index + 1, me.computer); + fmgc.fp[me.computer].insertWP(createDiscontinuity(), me.index + 2); + fmgc.flightplan.checkWPOutputs(me.computer); + } else { + for (var i = me.index + 1; i == indexWp; i = i + 1) { + fmgc.flightplan.deleteWP(i, me.computer, 0); + } + var _insert = fmgc.flightplan.insertArpt(me.R3[0], me.index + 1, me.computer); + } + } else { + var _insert = 1; + } + } elsif (size(me.R3[0]) == 3 or size(me.R3[0]) == 2) { + var navaid = findNavaidsByID(me.R3[0]); + if (navaid != nil) { + var indexWp = fmgc.fp[me.computer].indexOfWP(navaid[0]); + if (indexWp == -1) { + var _insert = fmgc.flightplan.insertNavaid(me.R3[0], me.index + 1, me.computer); + fmgc.fp[me.computer].insertWP(createDiscontinuity(), me.index + 2); + fmgc.flightplan.checkWPOutputs(me.computer); + } else { + for (var i = me.index + 1; i == indexWp; i = i + 1) { + fmgc.flightplan.deleteWP(i, me.computer, 0); + } + var _insert = fmgc.flightplan.insertNavaid(me.R3[0], me.index + 1, me.computer); + } + } else { + var _insert = 1; + } + } else { + formatError(me.computer); + } + + if (_insert == 1) { + notInDataBase(me.computer); + } elsif (_insert == 2) { + notAllowed(me.computer); + } else { + setprop("/MCDU[" ~ me.computer ~ "]/scratchpad", ""); + fmgc.flightplan.checkWPOutputs(me.computer); + setprop("/MCDU[" ~ me.computer ~ "]/page", "F-PLNA"); + } + }, }; var dmsToString = func(dms, type) { diff --git a/Nasal/MCDU/MCDU.nas b/Nasal/MCDU/MCDU.nas index 7d0520a2..de7af3a2 100644 --- a/Nasal/MCDU/MCDU.nas +++ b/Nasal/MCDU/MCDU.nas @@ -270,6 +270,12 @@ var rskbutton = func(btn, i) { printInput("R3", i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "PRINTFUNC2") { printInput2("R3", i); + } else if (getprop("/MCDU[" ~ i ~ "]/page") == "LATREV") { + if (canvas_mcdu.myLatRev[i].type != 2) { + canvas_mcdu.myLatRev[i].nextWpt(); + } else { + notAllowed(i); + } } else { notAllowed(i); } @@ -372,10 +378,14 @@ var arrowbutton = func(btn, i) { } else if (btn == "up") { if (getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNA" or getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNB") { slewFPLN(1, i); + } else if (getprop("/MCDU[" ~ i ~ "]/page") == "DEPARTURE") { + canvas_mcdu.myDeparture[i].scrollUp(); } } else if (btn == "down") { if (getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNA" or getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNB") { slewFPLN(-1, i); + } else if (getprop("/MCDU[" ~ i ~ "]/page") == "DEPARTURE") { + canvas_mcdu.myDeparture[i].scrollDn(); } } } diff --git a/Nasal/Sim/libraries.nas b/Nasal/Sim/libraries.nas index 26b21ac2..858c391b 100644 --- a/Nasal/Sim/libraries.nas +++ b/Nasal/Sim/libraries.nas @@ -227,6 +227,7 @@ var systemsInit = func { setlistener("/sim/signals/fdm-initialized", func { systemsInit(); + fmgc.outputPropsTimer.start(); }); var systemsLoop = maketimer(0.1, func { From b6336552c832bdb8bab099dda1f7e5698e7181c0 Mon Sep 17 00:00:00 2001 From: legoboyvdlp R Date: Tue, 31 Dec 2019 17:50:21 +0000 Subject: [PATCH 05/51] Bugfix IESI - no longer flashes on init --- Models/Instruments/IESI/IESI.nas | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/Models/Instruments/IESI/IESI.nas b/Models/Instruments/IESI/IESI.nas index c50b7a6b..6f86cce8 100644 --- a/Models/Instruments/IESI/IESI.nas +++ b/Models/Instruments/IESI/IESI.nas @@ -80,27 +80,20 @@ var canvas_IESI_base = { dcess = systems.ELEC.Bus.dcEss.getValue(); dchot1 = systems.ELEC.Bus.dcHot1.getValue(); - if (dcess >= 25 or (dchot1 >= 25 and airspeed.getValue() >= 50)) { + cur_time = et.getValue(); + if (dcess >= 25 or (dchot1 >= 25 and airspeed.getValue() >= 50 and cur_time >= 5)) { IESI.page.show(); IESI.update(); if (aconfig.getValue() != 1 and iesi_init.getValue() != 1) { iesi_init.setBoolValue(1); - cur_time = et.getValue(); iesi_time.setValue(cur_time); } else if (aconfig.getValue() == 1 and iesi_init.getValue() != 1) { iesi_init.setBoolValue(1); - cur_time = et.getValue() - 87; - iesi_time.setValue(cur_time); + iesi_time.setValue(cur_time - 87); } } else { iesi_init.setBoolValue(0); - } - - if (dcess >= 25 or (dchot1 >= 25 and airspeed.getValue() >= 50)) { - IESI.page.show(); - IESI.update(); - } else { IESI.page.hide(); } }, From 848a6a7b7ffe7f49c4c11f88af1ef2e9c3d57b45 Mon Sep 17 00:00:00 2001 From: legoboyvdlp R Date: Sun, 5 Jan 2020 20:21:28 +0000 Subject: [PATCH 06/51] New FPLN --- A320-main.xml | 6 +- Models/Instruments/MCDU/MCDU.nas | 432 +++++++--- Models/Instruments/MCDU/res/mcdu.svg | 769 +++++++++--------- .../Instruments/ND/canvas/A3XX_ND_drivers.nas | 2 +- Nasal/FMGC/FMGC-b.nas | 21 +- Nasal/FMGC/FMGC.nas | 2 +- Nasal/FMGC/flightplan.nas | 522 ++++++------ Nasal/MCDU/ARRIVAL.nas | 28 +- Nasal/MCDU/DEPARTURE.nas | 440 ++++++++-- Nasal/MCDU/F-PLN-rework.nas | 314 +++++++ Nasal/MCDU/F-PLN.nas | 398 ++++----- Nasal/MCDU/INITA.nas | 4 +- Nasal/MCDU/LATREV.nas | 62 +- Nasal/MCDU/MCDU.nas | 29 +- 14 files changed, 1888 insertions(+), 1141 deletions(-) create mode 100644 Nasal/MCDU/F-PLN-rework.nas diff --git a/A320-main.xml b/A320-main.xml index f07ee068..d40d6df1 100644 --- a/A320-main.xml +++ b/A320-main.xml @@ -428,7 +428,7 @@ 300.0 - 2019.2.0 + 2019.1.2 @@ -1870,14 +1870,11 @@ Aircraft/A320-family/Nasal/FMGC/FCU.nas - Aircraft/A320-family/Nasal/FMGC/flightplan.nas Aircraft/A320-family/Nasal/FMGC/FMGC.nas Aircraft/A320-family/Nasal/FMGC/FMGC-b.nas Aircraft/A320-family/Nasal/FMGC/FMGC-c.nas - Aircraft/A320-family/Nasal/MCDU/LATREV.nas - Aircraft/A320-family/Nasal/MCDU/DEPARTURE.nas Aircraft/A320-family/Nasal/MCDU/MCDU.nas Aircraft/A320-family/Nasal/MCDU/INITA.nas Aircraft/A320-family/Nasal/MCDU/INITB.nas @@ -1888,7 +1885,6 @@ Aircraft/A320-family/Nasal/MCDU/RADNAV.nas Aircraft/A320-family/Nasal/MCDU/DATA.nas Aircraft/A320-family/Nasal/MCDU/STATUS.nas - Aircraft/A320-family/Nasal/MCDU/F-PLN.nas Aircraft/A320-family/Models/Instruments/PFD/PFD.nas diff --git a/Models/Instruments/MCDU/MCDU.nas b/Models/Instruments/MCDU/MCDU.nas index c32148b8..40939930 100644 --- a/Models/Instruments/MCDU/MCDU.nas +++ b/Models/Instruments/MCDU/MCDU.nas @@ -8,6 +8,7 @@ var MCDU1_display = nil; var MCDU2_display = nil; var myLatRev = [nil, nil]; var myDeparture = [nil, nil]; +var myFpln = [nil, nil]; var default = "BoeingCDU-Large.ttf"; var symbol = "helvetica_medium.txf"; var normal = 70; @@ -111,7 +112,6 @@ var engOutAcc = props.globals.getNode("/FMGC/internal/eng-out-reduc", 1); var engOutAccSet = props.globals.getNode("/MCDUC/reducacc-set", 1); var transAlt = props.globals.getNode("/FMGC/internal/trans-alt", 1); var managedSpeed = props.globals.getNode("/it-autoflight/input/spd-managed", 1); -var TMPYActive = [props.globals.getNode("/FMGC/internal/tmpy-active[0]"), props.globals.getNode("/FMGC/internal/tmpy-active[1]")]; # Fetch nodes into vectors var pageProp = [props.globals.getNode("/MCDU[0]/page", 1), props.globals.getNode("/MCDU[1]/page", 1)]; @@ -166,11 +166,15 @@ var canvas_MCDU_base = { return me; }, getKeys: func() { - return ["Simple","Simple_Center","Scratchpad","Simple_Title","Simple_PageNum","ArrowLeft","ArrowRight","Simple_L1","Simple_L2","Simple_L3","Simple_L4","Simple_L5","Simple_L6","Simple_L1S","Simple_L2S","Simple_L3S","Simple_L4S","Simple_L5S","Simple_L6S", - "Simple_L1_Arrow","Simple_L2_Arrow","Simple_L3_Arrow","Simple_L4_Arrow","Simple_L5_Arrow","Simple_L6_Arrow","Simple_R1","Simple_R2","Simple_R3","Simple_R4","Simple_R5","Simple_R6","Simple_R1S","Simple_R2S","Simple_R3S","Simple_R4S","Simple_R5S", - "Simple_R6S","Simple_R1_Arrow","Simple_R2_Arrow","Simple_R3_Arrow","Simple_R4_Arrow","Simple_R5_Arrow","Simple_R6_Arrow","Simple_C1","Simple_C2","Simple_C3","Simple_C4","Simple_C5","Simple_C6","Simple_C1S","Simple_C2S","Simple_C3S","Simple_C4S", - "Simple_C5S","Simple_C6S","INITA","INITA_CoRoute","INITA_FltNbr","INITA_CostIndex","INITA_CruiseFLTemp","INITA_FromTo","INITA_InitRequest","INITA_AlignIRS","INITB","INITB_ZFWCG","INITB_ZFW","INITB_ZFW_S","INITB_Block","PERFTO","PERFTO_V1","PERFTO_VR", - "PERFTO_V2","PERFTO_FE","PERFTO_SE","PERFTO_OE","FPLN","FPLN_From","FPLN_TMPY_group","FPLN_Callsign","FPLN_L1","FPLN_L2","FPLN_L3","FPLN_L4","FPLN_L5","FPLN_L6","FPLN_L1S","FPLN_L2S","FPLN_L3S","FPLN_L4S","FPLN_L5S","FPLN_L6S","FPLN_6_group","departureTMPY"]; + return ["Simple","Simple_Center","Scratchpad","Simple_Title","Simple_PageNum","ArrowLeft","ArrowRight","Simple_L1","Simple_L2","Simple_L3","Simple_L4" + ,"Simple_L5","Simple_L6","Simple_L1S","Simple_L2S","Simple_L3S","Simple_L4S","Simple_L5S","Simple_L6S", "Simple_L1_Arrow","Simple_L2_Arrow", + "Simple_L3_Arrow","Simple_L4_Arrow","Simple_L5_Arrow","Simple_L6_Arrow","Simple_R1","Simple_R2","Simple_R3","Simple_R4","Simple_R5","Simple_R6", + "Simple_R1S","Simple_R2S","Simple_R3S","Simple_R4S","Simple_R5S","Simple_R6S","Simple_R1_Arrow","Simple_R2_Arrow","Simple_R3_Arrow","Simple_R4_Arrow", + "Simple_R5_Arrow","Simple_R6_Arrow","Simple_C1","Simple_C2","Simple_C3","Simple_C4","Simple_C5","Simple_C6","Simple_C1S","Simple_C2S","Simple_C3S", + "Simple_C4S","Simple_C5S","Simple_C6S","INITA","INITA_CoRoute","INITA_FltNbr","INITA_CostIndex","INITA_CruiseFLTemp","INITA_FromTo", + "INITA_InitRequest","INITA_AlignIRS","INITB","INITB_ZFWCG","INITB_ZFW","INITB_ZFW_S","INITB_Block","PERFTO","PERFTO_V1","PERFTO_VR","PERFTO_V2", + "PERFTO_FE","PERFTO_SE","PERFTO_OE","FPLN","FPLN_From","FPLN_TMPY_group","FPLN_Callsign","departureTMPY", "arrowsDepArr","arrow1L","arrow2L","arrow3L" + ,"arrow4L","arrow5L","arrow1R","arrow2R","arrow3R","arrow4R","arrow5R"]; }, update: func() { if (systems.ELEC.Bus.ac1.getValue() >= 110 and mcdu1_lgt.getValue() > 0.01) { @@ -190,19 +194,36 @@ var canvas_MCDU_base = { page = pageProp[i].getValue(); if (page == "F-PLNA" or page == "F-PLNB") { if (!pageSwitch[i].getBoolValue()) { - me["Simple"].hide(); - me["Simple_Center"].hide(); + me["Simple"].show(); + me["Simple_Center"].show(); me["FPLN"].show(); me["INITA"].hide(); me["INITB"].hide(); me["PERFTO"].hide(); + me["Simple_Title"].hide(); me["Simple_PageNum"].hide(); me["ArrowLeft"].show(); me["ArrowRight"].show(); + me["arrowsDepArr"].hide(); + + me["Simple_L1_Arrow"].hide(); + me["Simple_L2_Arrow"].hide(); + me["Simple_L3_Arrow"].hide(); + me["Simple_L4_Arrow"].hide(); + me["Simple_L5_Arrow"].hide(); + me["Simple_L6_Arrow"].hide(); + me["Simple_R1_Arrow"].hide(); + me["Simple_R2_Arrow"].hide(); + me["Simple_R3_Arrow"].hide(); + me["Simple_R4_Arrow"].hide(); + me["Simple_R5_Arrow"].hide(); + me["Simple_R6_Arrow"].hide(); pageSwitch[i].setBoolValue(1); } + myFpln[i].update(); + if (flightNumSet.getValue()) { me["FPLN_Callsign"].setText(flightNum.getValue()); me["FPLN_Callsign"].show(); @@ -210,144 +231,272 @@ var canvas_MCDU_base = { me["FPLN_Callsign"].hide(); } - fplnLineSize = size(mcdu.FPLNLines[i].output); - if (fplnLineSize >= 1) { - fplnl1 = mcdu.FPLNLines[i].output[0].getText(); - if (fplnl1 != "") { - me["FPLN_L1"].setColor(mcdu.FPLNLines[i].output[0].getColor(i)); - me["FPLN_L1"].setText(fplnl1); - me["FPLN_L1"].show(); - } else { - me["FPLN_L1"].hide(); - } - fplnl1s = mcdu.FPLNLines[i].output[0].getSubText(i); - if (fplnl1s != "") { - me["FPLN_L1S"].setText(fplnl1s); - me["FPLN_L1S"].show(); - } else { - me["FPLN_L1S"].hide(); - } + if (myFpln[i].L1[0] == nil) { + me["Simple_L1"].hide(); + me["Simple_L1S"].hide(); } else { - me["FPLN_L1"].hide(); - me["FPLN_L1S"].hide(); + me["Simple_L1"].show(); + me["Simple_L1"].setText(myFpln[i].L1[0]); + if (myFpln[i].L1[1] != nil) { + me["Simple_L1S"].show(); + me["Simple_L1S"].setText(myFpln[i].L1[1]); + } else { + me["Simple_L1S"].hide(); + } } - if (fplnLineSize >= 2) { - fplnl2 = mcdu.FPLNLines[i].output[1].getText(); - if (fplnl2 != "") { - me["FPLN_L2"].setColor(mcdu.FPLNLines[i].output[1].getColor(i)); - me["FPLN_L2"].setText(fplnl2); - me["FPLN_L2"].show(); - } else { - me["FPLN_L2"].hide(); - } - fplnl2s = mcdu.FPLNLines[i].output[1].getSubText(i); - if (fplnl2s != "") { - me["FPLN_L2S"].setText(fplnl2s); - me["FPLN_L2S"].show(); - } else { - me["FPLN_L2S"].hide(); - } + if (myFpln[i].L2[0] == nil) { + me["Simple_L2"].hide(); + me["Simple_L2S"].hide(); } else { - me["FPLN_L2"].hide(); - me["FPLN_L2S"].hide(); + me["Simple_L2"].show(); + me["Simple_L2"].setText(myFpln[i].L2[0]); + if (myFpln[i].L2[1] != nil) { + me["Simple_L2S"].show(); + me["Simple_L2S"].setText(myFpln[i].L2[1]); + } else { + me["Simple_L2S"].hide(); + } } - if (fplnLineSize >= 3) { - fplnl3 = mcdu.FPLNLines[i].output[2].getText(); - if (fplnl3 != "") { - me["FPLN_L3"].setColor(mcdu.FPLNLines[i].output[2].getColor(i)); - me["FPLN_L3"].setText(fplnl3); - me["FPLN_L3"].show(); - } else { - me["FPLN_L3"].hide(); - } - fplnl3s = mcdu.FPLNLines[i].output[2].getSubText(i); - if (fplnl3s != "") { - me["FPLN_L3S"].setText(fplnl3s); - me["FPLN_L3S"].show(); - } else { - me["FPLN_L3S"].hide(); - } + if (myFpln[i].L3[0] == nil) { + me["Simple_L3"].hide(); + me["Simple_L3S"].hide(); } else { - me["FPLN_L3"].hide(); - me["FPLN_L3S"].hide(); + me["Simple_L3"].show(); + me["Simple_L3"].setText(myFpln[i].L3[0]); + if (myFpln[i].L3[1] != nil) { + me["Simple_L3S"].show(); + me["Simple_L3S"].setText(myFpln[i].L3[1]); + } else { + me["Simple_L3S"].hide(); + } } - if (fplnLineSize >= 4) { - fplnl4 = mcdu.FPLNLines[i].output[3].getText(); - if (fplnl4 != "") { - me["FPLN_L4"].setColor(mcdu.FPLNLines[i].output[3].getColor(i)); - me["FPLN_L4"].setText(fplnl4); - me["FPLN_L4"].show(); - } else { - me["FPLN_L4"].hide(); - } - fplnl4s = mcdu.FPLNLines[i].output[3].getSubText(i); - if (fplnl4s != "") { - me["FPLN_L4S"].setText(fplnl4s); - me["FPLN_L4S"].show(); - } else { - me["FPLN_L4S"].hide(); - } + if (myFpln[i].L4[0] == nil) { + me["Simple_L4"].hide(); + me["Simple_L4S"].hide(); } else { - me["FPLN_L4"].hide(); - me["FPLN_L4S"].hide(); + me["Simple_L4"].show(); + me["Simple_L4"].setText(myFpln[i].L4[0]); + if (myFpln[i].L4[1] != nil) { + me["Simple_L4S"].show(); + me["Simple_L4S"].setText(myFpln[i].L4[1]); + } else { + me["Simple_L4S"].hide(); + } } - if (fplnLineSize >= 5) { - fplnl5 = mcdu.FPLNLines[i].output[4].getText(); - if (fplnl5 != "") { - me["FPLN_L5"].setColor(mcdu.FPLNLines[i].output[4].getColor(i)); - me["FPLN_L5"].setText(fplnl5); - me["FPLN_L5"].show(); - } else { - me["FPLN_L5"].hide(); - } - fplnl5s = mcdu.FPLNLines[i].output[4].getSubText(i); - if (fplnl5s != "") { - me["FPLN_L5S"].setText(fplnl5s); - me["FPLN_L5S"].show(); - } else { - me["FPLN_L5S"].hide(); - } + if (myFpln[i].L5[0] == nil) { + me["Simple_L5"].hide(); + me["Simple_L5S"].hide(); } else { - me["FPLN_L5"].hide(); - me["FPLN_L5S"].hide(); + me["Simple_L5"].show(); + me["Simple_L5"].setText(myFpln[i].L5[0]); + if (myFpln[i].L5[1] != nil) { + me["Simple_L5S"].show(); + me["Simple_L5S"].setText(myFpln[i].L5[1]); + } else { + me["Simple_L5S"].hide(); + } } - if (fplnLineSize >= 6) { - fplnl6 = mcdu.FPLNLines[i].output[5].getText(); - if (fplnl6 != "") { - me["FPLN_L6"].setColor(mcdu.FPLNLines[i].output[5].getColor(i)); - me["FPLN_L6"].setText(fplnl6); - me["FPLN_L6"].show(); - } else { - me["FPLN_L6"].hide(); - } - fplnl6s = mcdu.FPLNLines[i].output[5].getSubText(i); - if (fplnl6s != "") { - me["FPLN_L6S"].setText(fplnl6s); - me["FPLN_L6S"].show(); - } else { - me["FPLN_L6S"].hide(); - } + if (myFpln[i].L6[0] == nil or fmgc.flightPlanController.temporaryFlag[i]) { + me["Simple_L6"].hide(); + me["Simple_L6S"].hide(); } else { - me["FPLN_L6"].hide(); - me["FPLN_L6S"].hide(); + me["Simple_L6"].show(); + me["Simple_L6"].setText(myFpln[i].L6[0]); + if (myFpln[i].L6[1] != nil) { + me["Simple_L6S"].show(); + me["Simple_L6S"].setText(myFpln[i].L6[1]); + } else { + me["Simple_L6S"].hide(); + } + } + me.colorLeft(myFpln[i].L1[2],myFpln[i].L2[2],myFpln[i].L3[2],myFpln[i].L4[2],myFpln[i].L5[2],myFpln[i].L6[2]); + + if (myFpln[i].C1[0] == nil) { + me["Simple_C1"].hide(); + me["Simple_C1S"].hide(); + } else { + me["Simple_C1"].show(); + me["Simple_C1"].setText(myFpln[i].C1[0]); + if (myFpln[i].C1[1] != nil) { + me["Simple_C1S"].show(); + me["Simple_C1S"].setText(myFpln[i].C1[1]); + } else { + me["Simple_C1S"].hide(); + } } - if (mcdu.FPLNLines[i].index == 0) { - me["FPLN_From"].show(); + if (myFpln[i].C2[0] == nil) { + me["Simple_C2"].hide(); + me["Simple_C2S"].hide(); } else { - me["FPLN_From"].hide(); + me["Simple_C2"].show(); + me["Simple_C2"].setText(myFpln[i].C2[0]); + if (myFpln[i].C2[1] != nil) { + me["Simple_C2S"].show(); + me["Simple_C2S"].setText(myFpln[i].C2[1]); + } else { + me["Simple_C2S"].hide(); + } } - if (TMPYActive[i].getBoolValue()) { + + if (myFpln[i].C3[0] == nil) { + me["Simple_C3"].hide(); + me["Simple_C3S"].hide(); + } else { + me["Simple_C3"].show(); + me["Simple_C3"].setText(myFpln[i].C3[0]); + if (myFpln[i].C3[1] != nil) { + me["Simple_C3S"].show(); + me["Simple_C3S"].setText(myFpln[i].C3[1]); + } else { + me["Simple_C3S"].hide(); + } + } + + if (myFpln[i].C4[0] == nil) { + me["Simple_C4"].hide(); + me["Simple_C4S"].hide(); + } else { + me["Simple_C4"].show(); + me["Simple_C4"].setText(myFpln[i].C4[0]); + if (myFpln[i].C4[1] != nil) { + me["Simple_C4S"].show(); + me["Simple_C4S"].setText(myFpln[i].C4[1]); + } else { + me["Simple_C4S"].hide(); + } + } + + if (myFpln[i].C5[0] == nil) { + me["Simple_C5"].hide(); + me["Simple_C5S"].hide(); + } else { + me["Simple_C5"].show(); + me["Simple_C5"].setText(myFpln[i].C5[0]); + if (myFpln[i].C5[1] != nil) { + me["Simple_C5S"].show(); + me["Simple_C5S"].setText(myFpln[i].C5[1]); + } else { + me["Simple_C5S"].hide(); + } + } + + if (myFpln[i].C6[0] == nil or fmgc.flightPlanController.temporaryFlag[i]) { + me["Simple_C6"].hide(); + me["Simple_C6S"].hide(); + } else { + me["Simple_C6"].show(); + me["Simple_C6"].setText(myFpln[i].C6[0]); + if (myFpln[i].C6[1] != nil) { + me["Simple_C6S"].show(); + me["Simple_C6S"].setText(myFpln[i].C6[1]); + } else { + me["Simple_C6S"].hide(); + } + } + + me.colorCenter(myFpln[i].C1[2],myFpln[i].C2[2],myFpln[i].C3[2],myFpln[i].C4[2],myFpln[i].C5[2],myFpln[i].C6[2]); + + if (myFpln[i].R1[0] == nil) { + me["Simple_R1"].hide(); + me["Simple_R1S"].hide(); + } else { + me["Simple_R1"].show(); + me["Simple_R1"].setText(myFpln[i].R1[0]); + if (myFpln[i].R1[1] != nil) { + me["Simple_R1S"].show(); + me["Simple_R1S"].setText(myFpln[i].R1[1]); + } else { + me["Simple_R1S"].hide(); + } + } + + if (myFpln[i].R2[0] == nil) { + me["Simple_R2"].hide(); + me["Simple_R2S"].hide(); + } else { + me["Simple_R2"].show(); + me["Simple_R2"].setText(myFpln[i].R2[0]); + if (myFpln[i].R2[1] != nil) { + me["Simple_R2S"].show(); + me["Simple_R2S"].setText(myFpln[i].R2[1]); + } else { + me["Simple_R2S"].hide(); + } + } + + if (myFpln[i].R3[0] == nil) { + me["Simple_R3"].hide(); + me["Simple_R3S"].hide(); + } else { + me["Simple_R3"].show(); + me["Simple_R3"].setText(myFpln[i].R3[0]); + if (myFpln[i].R3[1] != nil) { + me["Simple_R3S"].show(); + me["Simple_R3S"].setText(myFpln[i].R3[1]); + } else { + me["Simple_R3S"].hide(); + } + } + + if (myFpln[i].R4[0] == nil) { + me["Simple_R4"].hide(); + me["Simple_R4S"].hide(); + } else { + me["Simple_R4"].show(); + me["Simple_R4"].setText(myFpln[i].R4[0]); + if (myFpln[i].R4[1] != nil) { + me["Simple_R4S"].show(); + me["Simple_R4S"].setText(myFpln[i].R4[1]); + } else { + me["Simple_R4S"].hide(); + } + } + + if (myFpln[i].R5[0] == nil) { + me["Simple_R5"].hide(); + me["Simple_R5S"].hide(); + } else { + me["Simple_R5"].show(); + me["Simple_R5"].setText(myFpln[i].R5[0]); + if (myFpln[i].R5[1] != nil) { + me["Simple_R5S"].show(); + me["Simple_R5S"].setText(myFpln[i].R5[1]); + } else { + me["Simple_R5S"].hide(); + } + } + + if (myFpln[i].R6[0] == nil or fmgc.flightPlanController.temporaryFlag[i]) { + me["Simple_R6"].hide(); + me["Simple_R6S"].hide(); + } else { + me["Simple_R6"].show(); + me["Simple_R6"].setText(myFpln[i].R6[0]); + if (myFpln[i].R6[1] != nil) { + me["Simple_R6S"].show(); + me["Simple_R6S"].setText(myFpln[i].R6[1]); + } else { + me["Simple_R6S"].hide(); + } + } + me.colorRight(myFpln[i].R1[2],myFpln[i].R2[2],myFpln[i].R3[2],myFpln[i].R4[2],myFpln[i].R5[2],myFpln[i].R6[2]); + + #if (mcdu.FPLNLines[i].index == 0) { + # me["FPLN_From"].show(); + #} else { + # me["FPLN_From"].hide(); + #} + + if (fmgc.flightPlanController.temporaryFlag[i]) { me["FPLN_TMPY_group"].show(); - me["FPLN_6_group"].hide(); } else { me["FPLN_TMPY_group"].hide(); - me["FPLN_6_group"].show(); } } elsif (page == "MCDU") { if (!pageSwitch[i].getBoolValue()) { @@ -357,6 +506,7 @@ var canvas_MCDU_base = { me["INITA"].hide(); me["INITB"].hide(); me["PERFTO"].hide(); + me["arrowsDepArr"].hide(); me["Simple_Title"].setText("MCDU MENU"); me["Simple_PageNum"].setText("X/X"); me["Simple_PageNum"].hide(); @@ -439,6 +589,7 @@ var canvas_MCDU_base = { me["INITA"].hide(); me["INITB"].hide(); me["PERFTO"].hide(); + me["arrowsDepArr"].hide(); me["Simple_Title"].setText(sprintf("%s", " " ~ acType.getValue())); me["Simple_PageNum"].setText("X/X"); me["Simple_PageNum"].hide(); @@ -521,6 +672,7 @@ var canvas_MCDU_base = { me["INITA"].hide(); me["INITB"].hide(); me["PERFTO"].hide(); + me["arrowsDepArr"].hide(); me["Simple_Title"].setText("DATA INDEX"); me["Simple_PageNum"].setText("1/2"); me["Simple_PageNum"].show(); @@ -601,6 +753,7 @@ var canvas_MCDU_base = { me["INITA"].hide(); me["INITB"].hide(); me["PERFTO"].hide(); + me["arrowsDepArr"].hide(); me["Simple_Title"].setText("DATA INDEX"); me["Simple_PageNum"].setText("2/2"); me["Simple_PageNum"].show(); @@ -686,6 +839,7 @@ var canvas_MCDU_base = { me["INITA"].hide(); me["INITB"].hide(); me["PERFTO"].hide(); + me["arrowsDepArr"].hide(); me["Simple_Title"].setText("POSITION MONITOR"); me["Simple_PageNum"].setText("X/X"); me["Simple_PageNum"].hide(); @@ -783,6 +937,7 @@ var canvas_MCDU_base = { me["INITA"].hide(); me["INITB"].hide(); me["PERFTO"].hide(); + me["arrowsDepArr"].hide(); me["Simple_Title"].setText("RADIO NAV"); me["Simple_PageNum"].setText("X/X"); me["Simple_PageNum"].hide(); @@ -922,6 +1077,7 @@ var canvas_MCDU_base = { me["INITA"].show(); me["INITB"].hide(); me["PERFTO"].hide(); + me["arrowsDepArr"].hide(); me["Simple_Title"].setText("INIT"); me["Simple_PageNum"].setText("X/X"); me["Simple_PageNum"].hide(); @@ -1077,6 +1233,7 @@ var canvas_MCDU_base = { me["INITA"].hide(); me["INITB"].show(); me["PERFTO"].hide(); + me["arrowsDepArr"].hide(); me["Simple_Title"].setText("INIT"); me["Simple_PageNum"].setText("X/X"); me["Simple_PageNum"].hide(); @@ -1207,6 +1364,7 @@ var canvas_MCDU_base = { me["INITA"].hide(); me["INITB"].hide(); me["PERFTO"].hide(); + me["arrowsDepArr"].hide(); me["Simple_Title"].setText("FUEL PRED"); me["Simple_PageNum"].setText("X/X"); me["Simple_PageNum"].hide(); @@ -1319,6 +1477,7 @@ var canvas_MCDU_base = { me["INITA"].hide(); me["INITB"].hide(); me["PERFTO"].show(); + me["arrowsDepArr"].hide(); me["Simple_Title"].setText("TAKE OFF"); me["Simple_PageNum"].setText("X/X"); me["Simple_PageNum"].hide(); @@ -1477,6 +1636,7 @@ var canvas_MCDU_base = { me["INITA"].hide(); me["INITB"].hide(); me["PERFTO"].hide(); + me["arrowsDepArr"].hide(); me["Simple_Title"].setText(sprintf("%s", page)); me["Simple_PageNum"].setText("X/X"); me["Simple_PageNum"].hide(); @@ -1599,6 +1759,7 @@ var canvas_MCDU_base = { me["INITA"].hide(); me["INITB"].hide(); me["PERFTO"].hide(); + me["arrowsDepArr"].hide(); me["Simple_PageNum"].setText("X/X"); me["Simple_PageNum"].hide(); me["ArrowLeft"].hide(); @@ -1857,6 +2018,19 @@ var canvas_MCDU_base = { me["Simple_PageNum"].hide(); me["ArrowLeft"].show(); me["ArrowRight"].show(); + me["arrowsDepArr"].show(); + me["Simple_L1_Arrow"].hide(); + me["Simple_L2_Arrow"].hide(); + me["Simple_L3_Arrow"].hide(); + me["Simple_L4_Arrow"].hide(); + me["Simple_L5_Arrow"].hide(); + me["Simple_L6_Arrow"].show(); + me["Simple_R1_Arrow"].hide(); + me["Simple_R2_Arrow"].hide(); + me["Simple_R3_Arrow"].hide(); + me["Simple_R4_Arrow"].hide(); + me["Simple_R5_Arrow"].hide(); + me["Simple_R6_Arrow"].hide(); me.fontLeft(default, default, default, default, default, default); me.fontLeftS(default, default, default, default, default, default); @@ -1867,9 +2041,7 @@ var canvas_MCDU_base = { me.fontSizeRight(normal, normal, normal, normal, normal, normal); me.colorLeftS("wht", "wht", "wht", "wht", "wht", "wht"); - me.colorLeftArrow("wht", "wht", "wht", "wht", "wht", "wht"); me.colorRightS("wht", "wht", "wht", "wht", "wht", "wht"); - me.colorRightArrow("wht", "wht", "wht", "wht", "wht", "wht"); if (myDeparture[i] != nil) { @@ -1882,14 +2054,18 @@ var canvas_MCDU_base = { var sign = "R"; } forindex (var item; myDeparture[i].arrowsMatrix[matrixArrow]) { + if (item == 5) { + me["Simple_L6_Arrow"].setColor(getprop("/MCDUC/colors/" ~ myDeparture[i].arrowsColour[0][5] ~ "/r"), getprop("/MCDUC/colors/" ~ myDeparture[i].arrowsColour[0][5] ~ "/g"), getprop("/MCDUC/colors/" ~ myDeparture[i].arrowsColour[0][5] ~ "/b")); + continue; + } if (myDeparture[i].arrowsMatrix[matrixArrow][item] == 1) { - me["Simple_" ~ sign ~ (item + 1) ~ "_Arrow"].show(); + me["arrow" ~ (item + 1) ~ sign].show(); + me["arrow" ~ (item + 1) ~ sign].setColor(getprop("/MCDUC/colors/" ~ myDeparture[i].arrowsColour[matrixArrow][item] ~ "/r"), getprop("/MCDUC/colors/" ~ myDeparture[i].arrowsColour[matrixArrow][item] ~ "/g"), getprop("/MCDUC/colors/" ~ myDeparture[i].arrowsColour[matrixArrow][item] ~ "/b")); } else { - me["Simple_" ~ sign ~ (item + 1) ~ "_Arrow"].hide(); + me["arrow" ~ (item + 1) ~ sign].hide(); } } } - me.colorLeftArrow(myDeparture[i].arrowsColour[0][0],myDeparture[i].arrowsColour[0][1],myDeparture[i].arrowsColour[0][2],myDeparture[i].arrowsColour[0][3],myDeparture[i].arrowsColour[0][4],myDeparture[i].arrowsColour[0][5]); forindex (var matrixFont; myDeparture[i].fontMatrix) { if (matrixFont == 0) { diff --git a/Models/Instruments/MCDU/res/mcdu.svg b/Models/Instruments/MCDU/res/mcdu.svg index f45606fc..01e84fb9 100644 --- a/Models/Instruments/MCDU/res/mcdu.svg +++ b/Models/Instruments/MCDU/res/mcdu.svg @@ -12,8 +12,9 @@ viewBox="0 0 1024 864" version="1.1" id="svg2" - inkscape:version="0.91 r13725" - sodipodi:docname="mcdu.svg"> + inkscape:version="0.92.4 (5da689c313, 2019-01-14)" + sodipodi:docname="mcdu.svg" + inkscape:label="arrowsLeftDepArr"> @@ -57,25 +58,25 @@ id="defs373" /> SCRATCHPAD + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:70px;line-height:1.25;font-family:BoeingCDULarge;-inkscape-font-specification:BoeingCDULarge;text-align:start;text-anchor:start;fill:#ffffff;fill-opacity:1">SCRATCHPAD + id="ArrowLeft" + style="display:inline"> @@ -95,12 +96,13 @@ + transform="matrix(-1,0,0,1,1911.9173,-0.2)" + style="display:inline"> + inkscape:groupmode="layer" + style="display:inline"> TEXT TEXT + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:70px;line-height:1.25;font-family:BoeingCDULarge;-inkscape-font-specification:BoeingCDULarge;text-align:center;text-anchor:middle;fill:#ffffff;fill-opacity:1">TEXT TEXT TEXT + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:70px;line-height:1.25;font-family:BoeingCDULarge;-inkscape-font-specification:BoeingCDULarge;text-align:center;text-anchor:middle;fill:#ffffff;fill-opacity:1">TEXT TEXT TEXT + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:70px;line-height:1.25;font-family:BoeingCDULarge;-inkscape-font-specification:BoeingCDULarge;text-align:center;text-anchor:middle;fill:#ffffff;fill-opacity:1">TEXT TEXT + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:56px;line-height:1.25;font-family:BoeingCDULarge;-inkscape-font-specification:BoeingCDULarge;text-align:center;text-anchor:middle;fill:#ffffff;fill-opacity:1">TEXT TEXT TEXT + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:56px;line-height:1.25;font-family:BoeingCDULarge;-inkscape-font-specification:BoeingCDULarge;text-align:center;text-anchor:middle;fill:#ffffff;fill-opacity:1">TEXT TEXT TEXT + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:56px;line-height:1.25;font-family:BoeingCDULarge;-inkscape-font-specification:BoeingCDULarge;text-align:center;text-anchor:middle;fill:#ffffff;fill-opacity:1">TEXT TITLE X/X + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:56px;line-height:1.25;font-family:BoeingCDULarge;-inkscape-font-specification:BoeingCDULarge;text-align:center;text-anchor:middle;fill:#ffffff;fill-opacity:1">X/X TEXT + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:70px;line-height:1.25;font-family:BoeingCDULarge;-inkscape-font-specification:BoeingCDULarge;text-align:start;text-anchor:start;fill:#ffffff;fill-opacity:1">TEXT TEXT + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:70px;line-height:1.25;font-family:BoeingCDULarge;-inkscape-font-specification:BoeingCDULarge;text-align:start;text-anchor:start;fill:#ffffff;fill-opacity:1">TEXT TEXT + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:70px;line-height:1.25;font-family:BoeingCDULarge;-inkscape-font-specification:BoeingCDULarge;text-align:start;text-anchor:start;fill:#ffffff;fill-opacity:1">TEXT TEXT TEXT + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:56px;line-height:1.25;font-family:BoeingCDULarge;-inkscape-font-specification:BoeingCDULarge;text-align:start;text-anchor:start;fill:#ffffff;fill-opacity:1">TEXT TEXT TEXT + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:56px;line-height:1.25;font-family:BoeingCDULarge;-inkscape-font-specification:BoeingCDULarge;text-align:start;text-anchor:start;fill:#ffffff;fill-opacity:1">TEXT TEXT TEXT + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:56px;line-height:1.25;font-family:BoeingCDULarge;-inkscape-font-specification:BoeingCDULarge;text-align:start;text-anchor:start;fill:#ffffff;fill-opacity:1">TEXT TEXT + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:70px;line-height:1.25;font-family:BoeingCDULarge;-inkscape-font-specification:BoeingCDULarge;text-align:end;text-anchor:end;fill:#ffffff;fill-opacity:1">TEXT TEXT + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:70px;line-height:1.25;font-family:BoeingCDULarge;-inkscape-font-specification:BoeingCDULarge;text-align:end;text-anchor:end;fill:#ffffff;fill-opacity:1">TEXT TEXT + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:70px;line-height:1.25;font-family:BoeingCDULarge;-inkscape-font-specification:BoeingCDULarge;text-align:end;text-anchor:end;fill:#ffffff;fill-opacity:1">TEXT TEXT + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:56px;line-height:1.25;font-family:BoeingCDULarge;-inkscape-font-specification:BoeingCDULarge;text-align:end;text-anchor:end;fill:#ffffff;fill-opacity:1">TEXT TEXT TEXT + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:56px;line-height:1.25;font-family:BoeingCDULarge;-inkscape-font-specification:BoeingCDULarge;text-align:end;text-anchor:end;fill:#ffffff;fill-opacity:1">TEXT TEXT TEXT + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:56px;line-height:1.25;font-family:BoeingCDULarge;-inkscape-font-specification:BoeingCDULarge;text-align:end;text-anchor:end;fill:#ffffff;fill-opacity:1">TEXT + inkscape:groupmode="layer" + style="display:inline"> @@ -931,7 +897,7 @@ id="INITA_InitRequest"> @@ -960,13 +926,12 @@ + transform="translate(-216.19751)"> + transform="translate(-833.84951)"> / + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:70px;line-height:1.25;font-family:BoeingCDULarge;-inkscape-font-specification:BoeingCDULarge;text-align:end;text-anchor:end;fill:#bb6100;fill-opacity:1">/ + inkscape:groupmode="layer" + style="display:inline"> . + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:70px;line-height:1.25;font-family:BoeingCDULarge;-inkscape-font-specification:BoeingCDULarge;text-align:end;text-anchor:end;fill:#bb6100;fill-opacity:1">. / + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:70px;line-height:1.25;font-family:BoeingCDULarge;-inkscape-font-specification:BoeingCDULarge;text-align:end;text-anchor:end;fill:#bb6100;fill-opacity:1">/ @@ -1349,7 +1311,7 @@ + inkscape:groupmode="layer" + style="display:inline"> F + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:70px;line-height:1.25;font-family:BoeingCDULarge;-inkscape-font-specification:BoeingCDULarge;text-align:start;text-anchor:start;fill:#ffffff;fill-opacity:1">F S O + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:70px;line-height:1.25;font-family:BoeingCDULarge;-inkscape-font-specification:BoeingCDULarge;text-align:start;text-anchor:start;fill:#ffffff;fill-opacity:1">O = = + style="font-style:normal;font-variant:normal;font-weight:500;font-stretch:normal;font-size:63.99239731px;line-height:1.25;font-family:'Helvetica Medium';-inkscape-font-specification:'Helvetica Medium, Medium';text-align:start;text-anchor:start;fill:#ffffff;fill-opacity:1">= + inkscape:groupmode="layer" + style="display:inline"> FROM + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:56px;line-height:1.25;font-family:BoeingCDULarge;-inkscape-font-specification:BoeingCDULarge;text-align:center;text-anchor:middle;fill:#ffffff;fill-opacity:1">FROM CALLSIG - TEXT - TEXT - TEXT - TEXT - TEXT - TEXT - TEXT - TEXT - TEXT - TEXT - - TEXT - TEXT - TMPY + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:56px;line-height:1.25;font-family:BoeingCDULarge;-inkscape-font-specification:BoeingCDULarge;text-align:center;text-anchor:middle;fill:#ffff00;fill-opacity:1">TMPY ERASE TMPY + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:56px;line-height:1.25;font-family:BoeingCDULarge;-inkscape-font-specification:BoeingCDULarge;text-align:start;text-anchor:start;fill:#bb6100;fill-opacity:1">TMPY @@ -1915,28 +1694,26 @@ id="FPLN_TMPY_INSERT"> TMPY + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:56px;line-height:1.25;font-family:BoeingCDULarge;-inkscape-font-specification:BoeingCDULarge;text-align:end;text-anchor:end;fill:#bb6100;fill-opacity:1">TMPY @@ -1973,4 +1750,248 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Models/Instruments/ND/canvas/A3XX_ND_drivers.nas b/Models/Instruments/ND/canvas/A3XX_ND_drivers.nas index baf7179b..d8a41c5b 100644 --- a/Models/Instruments/ND/canvas/A3XX_ND_drivers.nas +++ b/Models/Instruments/ND/canvas/A3XX_ND_drivers.nas @@ -16,7 +16,7 @@ var A3XXRouteDriver = { me.update(); }, update: func(){ - me.flightplan = fmgc.fp[2]; + me.flightplan = fmgc.flightPlanController.flightplans[2]; }, getNumberOfFlightPlans: func(){1}, getFlightPlanType: func(fpNum){"current"}, diff --git a/Nasal/FMGC/FMGC-b.nas b/Nasal/FMGC/FMGC-b.nas index 16d2c8a9..23274bf0 100644 --- a/Nasal/FMGC/FMGC-b.nas +++ b/Nasal/FMGC/FMGC-b.nas @@ -59,8 +59,6 @@ var FPLN = { maxBank: 0, maxBankLimit: 0, nextCourse: 0, - num: props.globals.getNode("/FMGC/flightplan[2]/num", 1), - numTemp: 0, R: 0, radius: 0, turnDist: 0, @@ -376,7 +374,6 @@ var ITAF = { Velocity.trueAirspeedKtTemp = Velocity.trueAirspeedKt.getValue(); FPLN.activeTemp = FPLN.active.getValue(); FPLN.currentWPTemp = FPLN.currentWP.getValue(); - FPLN.numTemp = FPLN.num.getValue(); # Bank Limit if (Velocity.trueAirspeedKtTemp >= 420) { @@ -391,14 +388,14 @@ var ITAF = { # If in LNAV mode and route is not longer active, switch to HDG HLD if (Output.lat.getValue() == 1) { # Only evaulate the rest of the condition if we are in LNAV mode - if (FPLN.num.getValue() == 0 or !FPLN.active.getBoolValue()) { + if (FPLN.num == 0 or !FPLN.active.getBoolValue()) { me.setLatMode(3); } } # Waypoint Advance Logic - if (FPLN.numTemp > 0 and FPLN.activeTemp == 1) { - if ((FPLN.currentWPTemp + 1) < FPLN.numTemp) { + if (flightPlanController.num[2] > 0 and FPLN.activeTemp == 1) { + if ((FPLN.currentWPTemp + 1) < flightPlanController.num[2]) { Velocity.groundspeedMps = Velocity.groundspeedKt.getValue() * 0.5144444444444; FPLN.wpFlyFrom = FPLN.currentWPTemp; if (FPLN.wpFlyFrom < 0) { @@ -431,10 +428,10 @@ var ITAF = { Internal.lnavAdvanceNm.setValue(FPLN.turnDist); if (FPLN.wp0Dist.getValue() <= FPLN.turnDist) { - if (currentWP[2] < 1) { - currentWP[2] = 1; - } else if (num_out[2].getValue() > 2) { # The Airbus doesn't display anything past the previous waypoint after advancing - flightplan.advanceDelete(2); + if (flightPlanController.currentToWptIndex < 1) { + flightPlanController.currentToWptIndex = 1; + } else if (flightPlanController.num[2] > 2) { # The Airbus doesn't display anything past the previous waypoint after advancing + flightPlanController.autoSequencing(); } } } @@ -604,7 +601,7 @@ var ITAF = { Custom.showHdg.setBoolValue(1); me.armTextCheck(); } else if (n == 1) { - if (FPLN.num.getValue() > 0 and FPLN.active.getBoolValue()) { + if (flightPlanController.num[2] > 0 and FPLN.active.getBoolValue()) { Output.lnavArm.setBoolValue(1); Custom.showHdg.setBoolValue(0); me.armTextCheck(); @@ -741,7 +738,7 @@ var ITAF = { } }, checkLNAV: func(t) { - if (FPLN.num.getValue() > 0 and FPLN.active.getBoolValue() and Position.gearAglFt.getValue() >= 30) { + if (flightPlanController.num[2] > 0 and FPLN.active.getBoolValue() and Position.gearAglFt.getValue() >= 30) { me.activateLNAV(); } else if (Output.lat.getValue() != 1 and t != 1) { Output.lnavArm.setBoolValue(1); diff --git a/Nasal/FMGC/FMGC.nas b/Nasal/FMGC/FMGC.nas index c45636f6..95b2049f 100644 --- a/Nasal/FMGC/FMGC.nas +++ b/Nasal/FMGC/FMGC.nas @@ -230,7 +230,7 @@ var masterFMGC = maketimer(0.2, func { setprop("/FMGC/status/phase", "5"); } - if (getprop("/FMGC/flightplan[2]/num") > 0 and getprop("/FMGC/flightplan[2]/active") == 1 and getprop("/FMGC/flightplan[2]/arrival-leg-dist") <= 15) { + if (flightPlanController.num[2] > 0 and getprop("/FMGC/flightplan[2]/active") == 1 and flightPlanController.arrivalDist <= 15) { setprop("/FMGC/internal/decel", 1); } else if (getprop("/FMGC/internal/decel") == 1 and (phase == 0 or phase == 6)) { setprop("/FMGC/internal/decel", 0); diff --git a/Nasal/FMGC/flightplan.nas b/Nasal/FMGC/flightplan.nas index 58b4a8a4..2fce05d0 100644 --- a/Nasal/FMGC/flightplan.nas +++ b/Nasal/FMGC/flightplan.nas @@ -1,47 +1,26 @@ # A3XX FMGC Flightplan Driver +# Copyright (c) 2019 Jonathan Redpath (2019) -# Copyright (c) 2019 Joshua Davidson (Octal450) -# This thing replaces the Route Manager, it's far from finished though +var magTrueError = 0; -# 0 = TEMP FP Captain MCDU -# 1 = TEMP FP First Officer MCDU -# 2 = ACTIVE FP -var fp = [createFlightplan(), createFlightplan(), createFlightplan()]; var wpDep = nil; var wpArr = nil; var pos = nil; -var geoPos = nil; var geoPosPrev = geo.Coord.new(); var currentLegCourseDist = nil; var courseDistanceFrom = nil; var courseDistanceFromPrev = nil; var sizeWP = nil; var magTrueError = 0; -var arrivalAirportI = [0, 0, 0]; -# Vars for MultiFlightplan -var currentWP = [nil, nil, 0]; -var currentLeg = [nil, nil, ""]; - -# Create/Fetch props.nas for MultiFlightplan -var altFeet = props.globals.getNode("/instrumentation/altimeter/indicated-altitude-ft", 1); -var active_out = [nil, nil, props.globals.initNode("/FMGC/flightplan[2]/active", 0, "BOOL")]; -var currentWP_out = [nil, nil, props.globals.initNode("/FMGC/flightplan[2]/current-wp", 0, "INT")]; -var currentLeg_out = [nil, nil, props.globals.initNode("/FMGC/flightplan[2]/current-leg", "", "STRING")]; -var currentLegCourse_out = [nil, nil, props.globals.initNode("/FMGC/flightplan[2]/current-leg-course", 0, "DOUBLE")]; -var currentLegDist_out = [nil, nil, props.globals.initNode("/FMGC/flightplan[2]/current-leg-dist", 0, "DOUBLE")]; -var currentLegCourseMag_out = [nil, nil, props.globals.initNode("/FMGC/flightplan[2]/current-leg-course-mag", 0, "DOUBLE")]; -var arrivalLegDist_out = [props.globals.initNode("/FMGC/flightplan[0]/arrival-leg-dist", 0, "DOUBLE"), props.globals.initNode("/FMGC/flightplan[1]/arrival-leg-dist", 0, "DOUBLE"), props.globals.initNode("/FMGC/flightplan[2]/arrival-leg-dist", 0, "DOUBLE")]; -var num_out = [props.globals.initNode("/FMGC/flightplan[0]/num", 0, "INT"), props.globals.initNode("/FMGC/flightplan[1]/num", 0, "INT"), props.globals.initNode("/FMGC/flightplan[2]/num", 0, "INT")]; -var toFromSet = props.globals.initNode("/FMGC/internal/tofrom-set", 0, "BOOL"); +# 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 TMPYActive = [props.globals.initNode("/FMGC/internal/tmpy-active[0]", 0, "BOOL"), props.globals.initNode("/FMGC/internal/tmpy-active[1]", 0, "BOOL")]; +var toFromSet = props.globals.getNode("/FMGC/internal/tofrom-set", 1); -# Create props.nas for flightplan -# Vectors inside vectors, so we can use as many flightplans or waypoints as we want +# 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")]]; var wpLat = [[props.globals.initNode("/FMGC/flightplan[0]/wp[0]/lat", 0, "DOUBLE")], [props.globals.initNode("/FMGC/flightplan[1]/wp[0]/lat", 0, "DOUBLE")], [props.globals.initNode("/FMGC/flightplan[2]/wp[0]/lat", 0, "DOUBLE")]]; var wpLon = [[props.globals.initNode("/FMGC/flightplan[0]/wp[0]/lon", 0, "DOUBLE")], [props.globals.initNode("/FMGC/flightplan[1]/wp[0]/lon", 0, "DOUBLE")], [props.globals.initNode("/FMGC/flightplan[2]/wp[0]/lon", 0, "DOUBLE")]]; @@ -50,163 +29,194 @@ var wpDistance = [[props.globals.initNode("/FMGC/flightplan[0]/wp[0]/distance", var wpCoursePrev = [[props.globals.initNode("/FMGC/flightplan[0]/wp[0]/course-from-prev", 0, "DOUBLE")], [props.globals.initNode("/FMGC/flightplan[1]/wp[0]/course-from-prev", 0, "DOUBLE")], [props.globals.initNode("/FMGC/flightplan[2]/wp[0]/course-from-prev", 0, "DOUBLE")]]; var wpDistancePrev = [[props.globals.initNode("/FMGC/flightplan[0]/wp[0]/distance-from-prev", 0, "DOUBLE")], [props.globals.initNode("/FMGC/flightplan[1]/wp[0]/distance-from-prev", 0, "DOUBLE")], [props.globals.initNode("/FMGC/flightplan[2]/wp[0]/distance-from-prev", 0, "DOUBLE")]]; -var flightplan = { +var flightPlanController = { + flightplans: [createFlightplan(), createFlightplan(), createFlightplan()], + temporaryFlag: [0, 0], + + # These flags are only for the main flgiht-plan + active: props.globals.initNode("/FMGC/flightplan[2]/active", 0, "BOOL"), + + currentToWpt: nil, # container for the current TO waypoint ghost + currentToWptIndex: props.globals.initNode("/FMGC/flightplan[2]/current-wp", 0, "INT"), + currentToWptID: "", + courseToWpt: 0, + courseMagToWpt: 0, + distToWpt: 0, + + distanceToDest: [0, 0, 0], + num: [0, 0, 0], + arrivalIndex: [0, 0, 0], + arrivalDist: 0, + _arrivalDist: 0, + reset: func() { - TMPYActive[0].setBoolValue(0); - TMPYActive[1].setBoolValue(0); - me.reset0(); - me.reset1(); - me.reset2(); + me.temporaryFlag[0] = 0; + me.temporaryFlag[1] = 0; + me.resetFlightplan(0); + me.resetFlightplan(1); + me.resetFlightplan(2); }, - reset0: func() { - fp[0].cleanPlan(); - fp[0].departure = nil; - fp[0].destination = nil; + + resetFlightplan: func(n) { + me.flightplans[n].cleanPlan(); + me.flightplans[n].departure = nil; + me.flightplans[n].destination = nil; }, - reset1: func() { - fp[1].cleanPlan(); - fp[1].departure = nil; - fp[1].destination = nil; + + createTemporaryFlightPlan: func(n) { + me.flightplans[n] = me.flightplans[2].clone(); + me.temporaryFlag[n] = 1; + me.flightPlanChanged(n); }, - reset2: func() { - fp[2].cleanPlan(); - fp[2].departure = nil; - fp[2].destination = nil; - currentWP[2] = 0; - currentLeg[2] = ""; - }, - initTempFP: func(f, n) { # f is temp, n is active - fp[f] = fp[n].clone(); - TMPYActive[f].setBoolValue(1); - me.checkWPOutputs(f); - }, - eraseTempFP: func(f, n) { # f is temp, n is active - TMPYActive[f].setBoolValue(0); - if (f == 0) { - me.reset0(); - } else if (f == 1) { - me.reset1(); + + destroyTemporaryFlightPlan: func(n, a) { # a = 1 activate, a = 0 erase + if (a == 1) { + me.flightplans[2] = me.flightplans[n].clone(); + me.flightPlanChanged(2); } - me.checkWPOutputs(n); + me.resetFlightplan(n); + me.temporaryFlag[n] = 0; }, - executeTempFP: func(f, n) { # f is temp, n is active - fp[n] = fp[f].clone(); - TMPYActive[f].setBoolValue(0); - if (f == 0) { - me.reset0(); - } else if (f == 1) { - me.reset1(); - } - me.checkWPOutputs(n); - }, - advanceDelete: func(n) { - if (num_out[n].getValue() > 2) { - if (TMPYActive[0].getBoolValue() and wpID[0][0] == wpID[n][0]) { - me.deleteWP(0, 0); - } - if (TMPYActive[1].getBoolValue() and wpID[1][0] == wpID[n][0]) { - me.deleteWP(0, 1); - } - me.deleteWP(0, n, 1); - } - }, - updateARPT: func(dep, arr, n) { - if (n == 2) { # Which flightplan? - me.reset2(); - - # Set Departure ARPT - if (dep != nil) { - fp[2].departure = airportinfo(dep); - } else { - fp[2].departure = nil; - } - - # Set Arrival ARPT - if (arr != nil) { - fp[2].destination = airportinfo(arr); - } else { - fp[2].destination = nil; - } - - currentWP[2] = 0; - - # Create discontinuity - fmgc.fp[2].insertWP(createDiscontinuity(), 1); + + updateAirports: func(dep, arr, plan) { + me.resetFlightplan(plan); + me.flightplans[plan].departure = airportinfo(dep); + me.flightplans[plan].destination = airportinfo(arr); + if (plan == 2) { + me.currentToWptIndex.setValue(0); } - me.checkWPOutputs(n); + me.addDiscontinuity(1, plan); + me.flightPlanChanged(plan); }, - # return 1 will cause NOT IN DATABASE, return 2 will cause NOT ALLOWED - insertFix: func(wp, i, n) { - var pos = findFixesByID(wp); - if (i == 0) { - return 2; - } else if (pos != nil and size(pos) > 0) { - fp[n].insertWP(createWPFrom(pos[0]), i); - me.checkWPOutputs(n); - return 0; - } else { - return 1; + + autoSequencing: func() { + if (me.num[2] > 2) { + if (me.temporaryFlag[0] == 1 and wpID[0][0] == wpID[2][0]) { + me.deleteWP(0, 0); + } + + if (me.temporaryFlag[1] == 1 and wpID[1][0] == wpID[2][0]) { + me.deleteWP(0, 1); + } + + me.deleteWP(0, 2); } }, - insertArpt: func(wp, i, n) { - var pos = findAirportsByICAO(wp); - if (i == 0) { - return 2; - } else if (pos != nil and size(pos) > 0) { - fp[n].insertWP(createWPFrom(pos[0]), i); - me.checkWPOutputs(n); - return 0; - } else { - return 1; - } - }, - insertNavaid: func(nav, i, n) { - var pos = findNavaidsByID(nav); - if (i == 0) { - return 2; - } else if (pos != nil and size(pos) > 0) { - fp[n].insertWP(createWPFrom(pos[0]), i); - me.checkWPOutputs(n); - return 0; - } else { - return 1; - } + + # for these two remember to call flightPlanChanged + addDiscontinuity: func(index, plan) { + me.flightplans[plan].insertWP(createDiscontinuity(), index); }, + insertPPOS: func(n) { - fp[n].insertWP(createWP(geo.aircraft_position(), "PPOS"), 0); - me.checkWPOutputs(n); + me.flightplans[n].insertWP(createWP(geo.aircraft_position(), "PPOS"), 0); }, - insertTP: func(n) { - fp[n].insertWP(createWP(geo.aircraft_position(), "T/P"), 0); - me.checkWPOutputs(n); - }, - deleteWP: func(i, n, t) { - var wp = wpID[n][i].getValue(); - if (t == 1) { - fp[n].deleteWP(i); - me.outputProps(); # Make sure everything is updated before we update the MCDUs. - me.updateMCDUDriver(n); - canvas_nd.A3XXRouteDriver.triggerSignal("fp-removed"); - return 0; - } else { - if (i == 0) { - return 2; - } else if (fp[n].getPlanSize() > 2 and wp != FMGCdep.getValue() and wp != FMGCarr.getValue() and wp != "T/P" and wp != "PPOS") { - fp[n].deleteWP(i); - me.outputProps(); # Make sure everything is updated before we update the MCDUs. - me.updateMCDUDriver(n); - canvas_nd.A3XXRouteDriver.triggerSignal("fp-removed"); - return 0; + + deleteWP: func(index, n) { + var wp = wpID[n][index].getValue(); + if (wp != FMGCdep.getValue() and wp != FMGCarr.getValue() and me.flightplans[n].getPlanSize() > 2) { + if (me.flightplans[2].getWP(index).id != "DISCONTINUITY") { # if it is a discont, don't make a new one + me.flightplans[2].deleteWP(index); + if (me.flightplans[2].getWP(index).id != "DISCONTINUITY") { # else, if the next one isn't a discont, add one + me.addDiscontinuity(index, n); + } } else { - return 2; + me.flightplans[2].deleteWP(index); + } + me.flightPlanChanged(n); + } + }, + + insertAirport: func(text, index, plan, override = 0, overrideIndex = -1) { + if (index == 0) { + return 1; + } + + var airport = findAirportsByICAO(text); + if (size(airport) == 0) { + return 0; + } + + if (size(airport) == 1 or override) { + if (!override) { + if (me.flightplans[plan].indexOfWP(airport[0]) == -1) { + me.flightplans[plan].insertWP(createWPFrom(airport[0]), index); + me.flightPlanChanged(plan); + } else { + var numToDel = me.flightplans[plan].indexOfWP(airport[0]) - index; + } + } else { + if (me.flightplans[plan].indexOfWP(airport[overrideIndex]) == -1) { + me.flightplans[plan].insertWP(createWPFrom(airport[overrideIndex]), index); + me.flightPlanChanged(plan); + } else { + var numToDel = me.flightplans[plan].indexOfWP(airport[overrideIndex]) - index; + } + } + } elsif (size(airport) >= 1) { + # spawn DUPLICATE NAMES + } + }, + + insertFix: func(text, index, plan, override = 0) { # override - means always choose [0] + if (index == 0) { + return 1; + } + + var fix = findFixesByID(text); + if (size(fix) == 0) { + return 0; + } + + if (size(fix) == 1 or override) { + if (me.flightplans[plan].indexOfWP(fix[0]) == -1) { + me.flightplans[plan].insertWP(createWPFrom(fix[0]), index); + me.flightPlanChanged(plan); + } else { + var numToDel = me.flightplans[plan].indexOfWP(fix[0]) - index; } } }, - checkWPOutputs: func(n) { + + insertNavaid: func(text, index, plan, override = 0) { + if (index == 0) { + return 1; + } + + var navaid = findNavaidsByID(text); + if (size(navaid) == 0) { + return 0; + } + + if (size(navaid) == 1 or override) { + if (me.flightplans[plan].indexOfWP(navaid[0]) == -1) { + me.flightplans[plan].insertWP(createWPFrom(navaid[0]), index); + me.flightPlanChanged(plan); + } else { + var numToDel = me.flightplans[plan].indexOfWP(fix[0]) - index; + } + } + }, + + scratchpad: func(text, index, plan) { # return 0 not in database, 1 not allowed, 2 success + if (text == "CLR") { + return me.deleteWP(index); + } elsif (size(text) == 5) { + return me.insertFix(text, index, plan); + } elsif (size(text) == 4) { + return me.insertAirport(text, index, plan); + } elsif (size(text) == 3 or size(text) == 2) { + return me.insertNavatext(text, index, plan); + } else { + return 1; + } + }, + + flightPlanChanged: func(n) { sizeWP = size(wpID[n]); - for (var counter = sizeWP; counter < fp[n].getPlanSize(); counter += 1) { - append(wpID[n], props.globals.initNode("/FMGC/flightplan[" ~ n ~ "]/wp[" ~ counter ~ "]/id", "", "STRING")); + for (var counter = sizeWP; counter < me.flightplans[n].getPlanSize(); counter += 1) { # create new properties if they are required + append(wpID[n], props.globals.initNode("/FMGC/flightplan[" ~ n ~ "]/wp[" ~ counter ~ "]/text", "", "STRING")); append(wpLat[n], props.globals.initNode("/FMGC/flightplan[" ~ n ~ "]/wp[" ~ counter ~ "]/lat", 0, "DOUBLE")); append(wpLon[n], props.globals.initNode("/FMGC/flightplan[" ~ n ~ "]/wp[" ~ counter ~ "]/lon", 0, "DOUBLE")); append(wpCourse[n], props.globals.initNode("/FMGC/flightplan[" ~ n ~ "]/wp[" ~ counter ~ "]/course", 0, "DOUBLE")); @@ -214,104 +224,110 @@ var flightplan = { append(wpCoursePrev[n], props.globals.initNode("/FMGC/flightplan[" ~ n ~ "]/wp[" ~ counter ~ "]/course-from-prev", 0, "DOUBLE")); append(wpDistancePrev[n], props.globals.initNode("/FMGC/flightplan[" ~ n ~ "]/wp[" ~ counter ~ "]/distance-from-prev", 0, "DOUBLE")); } - me.outputProps(); # Make sure everything is updated before we update the MCDUs. - me.updateMCDUDriver(n); - canvas_nd.A3XXRouteDriver.triggerSignal("fp-added"); # Update the NDs + + me.updatePlans(); }, - updateMCDUDriver: func(n) { - for (var i = 0; i < 2; i += 1) { # Update the 2 MCDUs - if (TMPYActive[i].getBoolValue()) { - mcdu.FPLNLines[i].replacePlan(i, mcdu.TMPY, mcdu.FPLNLines[i].index); + + updatePlans: func() { + me.updateCurrentWaypoint(); + me._arrivalDist = 0; + for (var n = 0; n <= 2; n += 1) { + for (var wpt = 0; wpt < me.flightplans[n].getPlanSize(); wpt += 1) { # Iterate through the waypoints and update their data + var curAircraftPos = geo.aircraft_position(); # don't want to get this corrupted so make sure it is a local variable + var waypointHashStore = me.flightplans[n].getWP(wpt); + + courseDistanceFrom = waypointHashStore.courseAndDistanceFrom(curAircraftPos); + wpID[n][wpt].setValue(waypointHashStore.wp_name); + wpLat[n][wpt].setValue(waypointHashStore.wp_lat); + wpLon[n][wpt].setValue(waypointHashStore.wp_lon); + + wpCourse[n][wpt].setValue(waypointHashStore.courseAndDistanceFrom(curAircraftPos)[0]); + wpDistance[n][wpt].setValue(waypointHashStore.courseAndDistanceFrom(curAircraftPos)[1]); + + if (wpt > 0) { + if (me.flightplans[n].getWP(wpt).id == "DISCONTINUITY") { + wpCoursePrev[n][wpt].setValue(0); + wpDistancePrev[n][wpt].setValue(0); + continue; + } + + if (me.flightplans[n].getWP(wpt - 1).id == "DISCONTINUITY") { + geoPosPrev.set_latlon(me.flightplans[n].getWP(wpt - 2).lat, me.flightplans[n].getWP(wpt - 2).lon); + } else { + geoPosPrev.set_latlon(me.flightplans[n].getWP(wpt - 1).lat, me.flightplans[n].getWP(wpt - 1).lon); + } + + courseDistanceFromPrev = waypointHashStore.courseAndDistanceFrom(geoPosPrev); + wpCoursePrev[n][wpt].setValue(courseDistanceFromPrev[0]); + wpDistancePrev[n][wpt].setValue(courseDistanceFromPrev[1]); + me._arrivalDist += courseDistanceFromPrev[1]; + } else { + # use PPOS for the first waypoint + wpCoursePrev[n][wpt].setValue(courseDistanceFrom[0]); + wpDistancePrev[n][wpt].setValue(courseDistanceFrom[1]); + } + + if (wpID[n][wpt].getValue() == FMGCarr.getValue()) { + me.arrivalIndex[n] = wpt; + } + } + } + me.arrivalDist = me._arrivalDist; + me.updateMCDUDriver(n); + canvas_nd.A3XXRouteDriver.triggerSignal("fp-added"); + }, + + updateCurrentWaypoint: func() { + for (var i = 0; i <= 2; i += 1) { + if (toFromSet.getBoolValue() and me.flightplans[i].departure != nil and me.flightplans[i].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 (i == 2) { # main plan + if (!me.active.getBoolValue()) { + me.active.setValue(1); + } + + if (me.currentToWptIndex.getValue() > me.flightplans[i].getPlanSize()) { + me.currentToWptIndex.setValue(me.flightplans[i].getPlanSize()); + } + + me.currentToWpt = me.flightplans[i].getWP(me.currentToWptIndex.getValue()); + + me.currentToWptId = me.currentToWpt.wp_name; + me.courseToWpt = me.currentToWpt.courseAndDistanceFrom(curAircraftPos)[0]; + me.distToWpt = me.currentToWpt.courseAndDistanceFrom(curAircraftPos)[1]; + + magTrueError = magHDG.getValue() - trueHDG.getValue(); + me.courseMagToWpt = me.courseToWpt + magTrueError; + + return; + } + + me.num[i] = me.flightplans[i].getPlanSize(); } else { - mcdu.FPLNLines[i].replacePlan(2, mcdu.MAIN, mcdu.FPLNLines[i].index); + if (i == 2) { + if (me.active.getBoolValue()) { + me.active.setValue(0); + } + me.currentToWptID = ""; + } + me.num[i] = 0; } } }, - outputProps: func() { - geoPos = geo.aircraft_position(); - - for (var n = 0; n < 3; n += 1) { # Note: Some things don't get done for TMPY (0) hence all the if (n > 1) {} - if (((n == 0 and TMPYActive[0].getBoolValue()) or (n == 1 and TMPYActive[1].getBoolValue()) or n > 1) and toFromSet.getBoolValue() and fp[n].departure != nil and fp[n].destination != nil) { - if (n > 1) { - if (currentWP[n] > fp[n].getPlanSize()) { - currentWP[n] = fp[n].getPlanSize(); - } - - if (active_out[n].getBoolValue() != 1) { - active_out[n].setBoolValue(1); - } - - currentLeg[n] = fp[n].getWP(currentWP[n]).wp_name; - - if (currentLeg_out[n].getValue() != currentLeg[n]) { - currentLeg_out[n].setValue(currentLeg[n]); - } - - currentLegCourseDist = fp[n].getWP(currentWP[n]).courseAndDistanceFrom(geoPos); - currentLegCourse_out[n].setValue(currentLegCourseDist[0]); - currentLegDist_out[n].setValue(currentLegCourseDist[1]); - - magTrueError = magHDG.getValue() - trueHDG.getValue(); - currentLegCourseMag_out[n].setValue(currentLegCourseDist[0] + magTrueError); # Convert to Magnetic - } - - if (num_out[n].getValue() != fp[n].getPlanSize()) { - num_out[n].setValue(fp[n].getPlanSize()); - } - - for (var i = 0; i < fp[n].getPlanSize(); i += 1) { - wpID[n][i].setValue(fp[n].getWP(i).wp_name); - wpLat[n][i].setValue(fp[n].getWP(i).wp_lat); - wpLon[n][i].setValue(fp[n].getWP(i).wp_lon); - courseDistanceFrom = fp[n].getWP(i).courseAndDistanceFrom(geoPos); - wpCourse[n][i].setValue(courseDistanceFrom[0]); - wpDistance[n][i].setValue(courseDistanceFrom[1]); - - if (i > 0) { # Impossible to do from the first WP - geoPosPrev.set_latlon(fp[n].getWP(i - 1).lat, fp[n].getWP(i - 1).lon, altFeet.getValue() * 0.3048); - courseDistanceFromPrev = fp[n].getWP(i).courseAndDistanceFrom(geoPosPrev); - wpCoursePrev[n][i].setValue(courseDistanceFromPrev[0]); - wpDistancePrev[n][i].setValue(courseDistanceFromPrev[1]); - } else { # So if its the first WP, we just use current position instead - wpCoursePrev[n][i].setValue(courseDistanceFrom[0]); - wpDistancePrev[n][i].setValue(courseDistanceFrom[1]); - } - - if (wpID[n][i].getValue() == FMGCarr.getValue()) { - arrivalAirportI[n] = i; - } - } - - arrivalLegDist_out[n].setValue(wpDistance[n][arrivalAirportI[n]].getValue()); + + updateMCDUDriver: func(n) { + for (var i = 0; i <= 1; i += 1) { + if (me.temporaryFlag[i] == 1) { + mcdu.FPLNLines[i].replacePlan(i, mcdu.TMPY, mcdu.FPLNLines[i].index); } else { - if (n > 1) { - if (active_out[n].getBoolValue() != 0) { - active_out[n].setBoolValue(0); - } - - if (currentLeg_out[n].getValue() != "") { - currentLeg_out[n].setValue(""); - } - } - - if (num_out[n].getValue() != 0) { - num_out[n].setValue(0); - } - } - - if (n > 1) { - if (currentWP[n] != nil) { - if (currentWP_out[n].getValue() != currentWP[n]) { - currentWP_out[n].setValue(currentWP[n]); - } - } else { - if (currentWP_out[n].getValue() != 0) { - currentWP_out[n].setValue(0); - } + mcdu.FPLNLines[i].replacePlan(2, mcdu.MAIN, mcdu.FPLNLines[i].index); + if (canvas_mcdu.myFpln[i] != nil) { + canvas_mcdu.myFpln[i].createPlanList(); } } } }, }; -var outputPropsTimer = maketimer(0.1, flightplan.outputProps); +var flightPlanTimer = maketimer(0.1, flightPlanController, flightPlanController.updatePlans); diff --git a/Nasal/MCDU/ARRIVAL.nas b/Nasal/MCDU/ARRIVAL.nas index ba578c47..20633324 100644 --- a/Nasal/MCDU/ARRIVAL.nas +++ b/Nasal/MCDU/ARRIVAL.nas @@ -37,8 +37,8 @@ var arrivalPage = { lr.computer = computer; lr._setupPageWithData(); lr.updateRunways(); - if (fmgc.fp[2].destination_runway != nil) { - lr.selectedRunway = fmgc.fp[2].destination_runway; + if (fmgc.flightPlanController.flightplans[2].destination_runway != nil) { + lr.selectedRunway = fmgc.flightPlanController.flightplans[2].destination_runway; } lr.updateActiveRunway(); return lr; @@ -48,7 +48,7 @@ var arrivalPage = { }, _setupPageWithData: func() { me.title = ["ARRIVAL", " TO ", left(me.id, 4)]; - if (!TMPYActive[me.computer].getBoolValue()) { + if (!fmgc.flightPlanController.temporaryFlag[me.computer]) { me.L6 = [" RETURN END", nil, "wht"]; } else { me.L6 = [" F-PLN", " TMPY", "yel"]; @@ -64,16 +64,16 @@ var arrivalPage = { }, updateActiveRunway: func() { if (me.selectedRunway != nil) { - if (fmgc.fp[2].destination_runway != nil) { - if (fmgc.fp[2].destination_runway.id == me.selectedRunway.id) { - me.L1 = [fmgc.fp[2].destination_runway.id, " RWY", "grn"]; - } elsif (fmgc.fp[me.computer].destination_runway != nil) { - me.L1 = [fmgc.fp[me.computer].destination_runway.id, " RWY", "yel"]; + if (fmgc.flightPlanController.flightplans[2].destination_runway != nil) { + if (fmgc.flightPlanController.flightplans[2].destination_runway.id == me.selectedRunway.id) { + me.L1 = [fmgc.flightPlanController.flightplans[2].destination_runway.id, " RWY", "grn"]; + } elsif (fmgc.flightPlanController.flightplans[me.computer].destination_runway != nil) { + me.L1 = [fmgc.flightPlanController.flightplans[me.computer].destination_runway.id, " RWY", "yel"]; } else { me.L1 = ["---", " RWY", "wht"]; } - } elsif (fmgc.fp[me.computer].destination_runway != nil) { - me.L1 = [fmgc.fp[me.computer].destination_runway.id, " RWY", "yel"]; + } elsif (fmgc.flightPlanController.flightplans[me.computer].destination_runway != nil) { + me.L1 = [fmgc.flightPlanController.flightplans[me.computer].destination_runway.id, " RWY", "yel"]; } else { me.L1 = ["---", " RWY", "wht"]; } @@ -124,8 +124,8 @@ var arrivalPage = { canvas_mcdu.pageSwitch[me.computer].setBoolValue(0); }, makeTmpy: func() { - if (!TMPYActive[me.computer].getBoolValue()) { - fmgc.flightplan.initTempFP(me.computer, 2); + if (!fmgc.flightPlanController.temporaryFlag[me.computer]) { + fmgc.flightPlanController.createTemporaryFlightPlan(me.computer); me.L6 = [" F-PLN", " TMPY", "yel"]; me.arrowsColour[0][5] = "yel"; canvas_mcdu.pageSwitch[me.computer].setBoolValue(0); @@ -153,9 +153,9 @@ var arrivalPage = { if (size(me.runways) >= (index - 1)) { me.selectedRunway = me.arrAirport[0].runway(me.runways[index - 2 + me.scroll]); me.makeTmpy(); - fmgc.fp[me.computer].destination_runway = me.selectedRunway; + fmgc.flightPlanController.flightplans[me.computer].destination_runway = me.selectedRunway; me.updateActiveRunway(); - fmgc.flightplan.checkWPOutputs(me.computer); + fmgc.flightPlanController.checkWPOutputs(me.computer); } else { notAllowed(me.computer); } diff --git a/Nasal/MCDU/DEPARTURE.nas b/Nasal/MCDU/DEPARTURE.nas index c23cb86b..b9d4deb6 100644 --- a/Nasal/MCDU/DEPARTURE.nas +++ b/Nasal/MCDU/DEPARTURE.nas @@ -25,22 +25,25 @@ var departurePage = { depAirport: nil, runways: nil, selectedRunway: nil, + selectedSID: nil, + selectedTransition: nil, sids: nil, + transitions: nil, computer: nil, - enableScroll: 0, - scroll: 0, + enableScrollRwy: 0, + enableScrollSids: 0, + scrollRwy: 0, + scrollSids: 0, + activePage: 0, # runways, sids, trans + hasPressNoTrans: 0, # temporary _runways: nil, _sids: nil, + _transitions: nil, new: func(icao, computer) { var lr = {parents:[departurePage]}; lr.id = icao; lr.computer = computer; lr._setupPageWithData(); - lr.updateRunways(); - if (fmgc.fp[2].departure_runway != nil) { - lr.selectedRunway = fmgc.fp[2].departure_runway; - } - lr.updateActiveRunway(); return lr; }, del: func() { @@ -48,31 +51,86 @@ var departurePage = { }, _setupPageWithData: func() { me.title = ["DEPARTURE", " FROM ", left(me.id, 4)]; - if (!TMPYActive[me.computer].getBoolValue()) { + if (!fmgc.flightPlanController.temporaryFlag[me.computer]) { me.L6 = [" RETURN END", nil, "wht"]; } else { me.L6 = [" F-PLN", " TMPY", "yel"]; me.arrowsColour[0][5] = "yel"; } - me.C1 = ["------- ", "SID", "wht"]; - me.R1 = ["-------", "TRANS ", "wht"]; + if (!fmgc.flightPlanController.temporaryFlag[me.computer]) { + if (fmgc.flightPlanController.flightplans[2].departure_runway != nil) { + me.selectedRunway = fmgc.flightPlanController.flightplans[2].departure_runway; + } + if (fmgc.flightPlanController.flightplans[2].sid != nil) { + me.selectedSID = fmgc.flightPlanController.flightplans[2].sid; + } + } else { + if (fmgc.flightPlanController.flightplans[me.computer].departure_runway != nil) { + me.selectedRunway = fmgc.flightPlanController.flightplans[me.computer].departure_runway; + } elsif (fmgc.flightPlanController.flightplans[2].departure_runway != nil) { + me.selectedRunway = fmgc.flightPlanController.flightplans[2].departure_runway; + } + if (fmgc.flightPlanController.flightplans[me.computer].sid != nil) { + me.selectedSID = fmgc.flightPlanController.flightplans[me.computer].sid; + } elsif (fmgc.flightPlanController.flightplans[2].sid != nil) { + me.selectedSID = fmgc.flightPlanController.flightplans[2].sid; + } + } + me.fontMatrix = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]; me.arrowsMatrix = [[0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0]]; me.arrowsColour = [["ack", "ack", "ack", "ack", "ack", "wht"], ["ack", "ack", "ack", "ack", "ack", "ack"]]; + + if (me.activePage == 0) { + me.updateRunways(); + } else { + me.updateSIDs(); + } + + me.updateActiveRunway(); + me.updateActiveSIDs(); + me.updateActiveTransitions(); + }, + _clearPage: func() { + me.L1 = [nil, nil, "ack"]; + me.L2 = [nil, nil, "ack"]; + me.L3 = [nil, nil, "ack"]; + me.L4 = [nil, nil, "ack"]; + me.L5 = [nil, nil, "ack"]; + me.L6 = [nil, nil, "ack"]; + me.C1 = [nil, nil, "ack"]; + me.C2 = [nil, nil, "ack"]; + me.C3 = [nil, nil, "ack"]; + me.C4 = [nil, nil, "ack"]; + me.C5 = [nil, nil, "ack"]; + me.C6 = [nil, nil, "ack"]; + me.R1 = [nil, nil, "ack"]; + me.R2 = [nil, nil, "ack"]; + me.R3 = [nil, nil, "ack"]; + me.R4 = [nil, nil, "ack"]; + me.R5 = [nil, nil, "ack"]; + me.R6 = [nil, nil, "ack"]; + me.fontMatrix = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]; + me.arrowsMatrix = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]; + me.arrowsColour = [["ack", "ack", "ack", "ack", "ack", "ack"], ["ack", "ack", "ack", "ack", "ack", "ack"]]; + }, + updatePage: func() { + me._clearPage(); + me._setupPageWithData(); }, updateActiveRunway: func() { if (me.selectedRunway != nil) { - if (fmgc.fp[2].departure_runway != nil) { - if (fmgc.fp[2].departure_runway.id == me.selectedRunway.id) { - me.L1 = [fmgc.fp[2].departure_runway.id, " RWY", "grn"]; - } elsif (fmgc.fp[me.computer].departure_runway != nil) { - me.L1 = [fmgc.fp[me.computer].departure_runway.id, " RWY", "yel"]; + if (fmgc.flightPlanController.flightplans[2].departure_runway != nil) { + if (fmgc.flightPlanController.flightplans[2].departure_runway.id == me.selectedRunway.id) { + me.L1 = [fmgc.flightPlanController.flightplans[2].departure_runway.id, " RWY", "grn"]; + } elsif (fmgc.flightPlanController.flightplans[me.computer].departure_runway != nil) { + me.L1 = [fmgc.flightPlanController.flightplans[me.computer].departure_runway.id, " RWY", "yel"]; } else { me.L1 = ["---", " RWY", "wht"]; } - } elsif (fmgc.fp[me.computer].departure_runway != nil) { - me.L1 = [fmgc.fp[me.computer].departure_runway.id, " RWY", "yel"]; + } elsif (fmgc.flightPlanController.flightplans[me.computer].departure_runway != nil) { + me.L1 = [fmgc.flightPlanController.flightplans[me.computer].departure_runway.id, " RWY", "yel"]; } else { me.L1 = ["---", " RWY", "wht"]; } @@ -81,82 +139,316 @@ var departurePage = { } canvas_mcdu.pageSwitch[me.computer].setBoolValue(0); }, - updateRunways: func() { - me.depAirport = findAirportsByICAO(left(me.id, 4)); - me._runways = keys(me.depAirport[0].runways); - me.runways = sort(me._runways,func(a,b) cmp(a,b)); - - me.fourRunways = [nil, nil, nil, nil]; - - if (size(me.runways) >= 1) { - me.L2 = [" " ~ me.runways[0 + me.scroll], nil, "blu"]; - me.C2 = [math.round(me.depAirport[0].runways[me.runways[0 + me.scroll]].length) ~ "M", nil, "blu"]; - me.R2 = ["CRS" ~ math.round(me.depAirport[0].runways[me.runways[0 + me.scroll]].heading), nil, "blu"]; - me.arrowsMatrix[0][1] = 1; - me.arrowsColour[0][1] = "blu"; - } - if (size(me.runways) >= 2) { - me.L3 = [" " ~ me.runways[1 + me.scroll], nil, "blu"]; - me.C3 = [math.round(me.depAirport[0].runways[me.runways[1 + me.scroll]].length) ~ "M", nil, "blu"]; - me.R3 = ["CRS" ~ math.round(me.depAirport[0].runways[me.runways[1 + me.scroll]].heading), nil, "blu"]; - me.arrowsMatrix[0][2] = 1; - me.arrowsColour[0][2] = "blu"; - } - if (size(me.runways) >= 3) { - me.L4 = [" " ~ me.runways[2 + me.scroll], nil, "blu"]; - me.C4 = [math.round(me.depAirport[0].runways[me.runways[2 + me.scroll]].length) ~ "M", nil, "blu"]; - me.R4 = ["CRS" ~ math.round(me.depAirport[0].runways[me.runways[2 + me.scroll]].heading), nil, "blu"]; - me.arrowsMatrix[0][3] = 1; - me.arrowsColour[0][3] = "blu"; - } - if (size(me.runways) >= 4) { - me.L5 = [" " ~ me.runways[3 + me.scroll], nil, "blu"]; - me.C5 = [math.round(me.depAirport[0].runways[me.runways[3 + me.scroll]].length) ~ "M", nil, "blu"]; - me.R5 = ["CRS" ~ math.round(me.depAirport[0].runways[me.runways[3 + me.scroll]].heading), nil, "blu"]; - me.arrowsMatrix[0][4] = 1; - me.arrowsColour[0][4] = "blu"; - } - - if (size(me.runways) > 4) { - me.enableScroll = 1; + updateActiveSIDs: func() { + if (me.selectedSID != nil) { + if (fmgc.flightPlanController.flightplans[2].sid != nil) { + if (fmgc.flightPlanController.flightplans[2].sid == me.selectedSID) { + me.C1 = [fmgc.flightPlanController.flightplans[2].sid.id, "SID", "grn"]; + } elsif (fmgc.flightPlanController.flightplans[me.computer].sid != nil) { + me.C1 = [fmgc.flightPlanController.flightplans[me.computer].sid.id, "SID", "yel"]; + } else { + me.C1 = ["------- ", "SID", "wht"]; + } + } elsif (fmgc.flightPlanController.flightplans[me.computer].sid.id != nil) { + me.C1 = [fmgc.flightPlanController.flightplans[me.computer].sid.id, "SID", "yel"]; + } else { + me.C1 = ["------- ", "SID", "wht"]; + } + } else { + me.C1 = ["------- ", "SID", "wht"]; } canvas_mcdu.pageSwitch[me.computer].setBoolValue(0); }, + updateActiveTransitions: func() { + if (me.selectedTransition != nil) { + if (fmgc.flightPlanController.flightplans[2].sid_trans != nil) { + if (fmgc.flightPlanController.flightplans[2].sid_trans == me.selectedTransition) { + me.R1 = [fmgc.flightPlanController.flightplans[2].sid_trans.id, "TRANS", "grn"]; + } elsif (fmgc.flightPlanController.flightplans[me.computer].sid_trans != nil) { + me.R1 = [fmgc.flightPlanController.flightplans[me.computer].sid_trans.id, "TRANS", "yel"]; + } else { + me.R1 = ["-------", "TRANS ", "wht"]; + } + } elsif (fmgc.flightPlanController.flightplans[me.computer].sid_trans != nil) { + me.C1 = [fmgc.flightPlanController.flightplans[me.computer].sid_trans.id, "SID", "yel"]; + } else { + me.R1 = ["-------", "TRANS ", "wht"]; + } + } else { + me.R1 = ["-------", "TRANS ", "wht"]; + } + canvas_mcdu.pageSwitch[me.computer].setBoolValue(0); + }, + updateRunways: func() { + if (me.depAirport == nil) { + me.depAirport = findAirportsByICAO(left(me.id, 4)); + } + me._runways = keys(me.depAirport[0].runways); + me.runways = sort(me._runways,func(a,b) cmp(a,b)); + + if (size(me.runways) >= 1) { + me.L2 = [" " ~ me.runways[0 + me.scrollRwy], nil, "blu"]; + me.C2 = [math.round(me.depAirport[0].runways[me.runways[0 + me.scrollRwy]].length) ~ "M", "AVAILABLE RUNWAYS", "blu"]; + me.R2 = ["CRS" ~ math.round(me.depAirport[0].runways[me.runways[0 + me.scrollRwy]].heading), nil, "blu"]; + if (me.runways[0 + me.scrollRwy] != me.selectedRunway) { + me.arrowsMatrix[0][1] = 1; + me.arrowsColour[0][1] = "blu"; + } else { + me.arrowsMatrix[0][1] = 0; + me.arrowsColour[0][1] = "ack"; + } + } + if (size(me.runways) >= 2) { + me.L3 = [" " ~ me.runways[1 + me.scrollRwy], nil, "blu"]; + me.C3 = [math.round(me.depAirport[0].runways[me.runways[1 + me.scrollRwy]].length) ~ "M", nil, "blu"]; + me.R3 = ["CRS" ~ math.round(me.depAirport[0].runways[me.runways[1 + me.scrollRwy]].heading), nil, "blu"]; + if (me.runways[1 + me.scrollRwy] != me.selectedRunway) { + me.arrowsMatrix[0][2] = 1; + me.arrowsColour[0][2] = "blu"; + } else { + me.arrowsMatrix[0][2] = 0; + me.arrowsColour[0][2] = "ack"; + } + } + if (size(me.runways) >= 3) { + me.L4 = [" " ~ me.runways[2 + me.scrollRwy], nil, "blu"]; + me.C4 = [math.round(me.depAirport[0].runways[me.runways[2 + me.scrollRwy]].length) ~ "M", nil, "blu"]; + me.R4 = ["CRS" ~ math.round(me.depAirport[0].runways[me.runways[2 + me.scrollRwy]].heading), nil, "blu"]; + if (me.runways[2 + me.scrollRwy] != me.selectedRunway) { + me.arrowsMatrix[0][3] = 1; + me.arrowsColour[0][3] = "blu"; + } else { + me.arrowsMatrix[0][3] = 0; + me.arrowsColour[0][3] = "ack"; + } + } + if (size(me.runways) >= 4) { + me.L5 = [" " ~ me.runways[3 + me.scrollRwy], nil, "blu"]; + me.C5 = [math.round(me.depAirport[0].runways[me.runways[3 + me.scrollRwy]].length) ~ "M", nil, "blu"]; + me.R5 = ["CRS" ~ math.round(me.depAirport[0].runways[me.runways[3 + me.scrollRwy]].heading), nil, "blu"]; + if (me.runways[3 + me.scrollRwy] != me.selectedRunway) { + me.arrowsMatrix[0][4] = 1; + me.arrowsColour[0][4] = "blu"; + } else { + me.arrowsMatrix[0][4] = 0; + me.arrowsColour[0][4] = "ack"; + } + } + + if (size(me.runways) > 4) { + me.enableScrollRwy = 1; + } + canvas_mcdu.pageSwitch[me.computer].setBoolValue(0); + }, + updateSIDs: func() { + if (me.depAirport == nil) { + me.depAirport = findAirportsByICAO(left(me.id, 4)); + } + if (me.selectedRunway != nil) { + me._sids = me.depAirport[0].sids(me.selectedRunway.id); + } else { + me._sids = me.depAirport[0].sids(); + } + + me.sids = sort(me._sids,func(a,b) cmp(a,b)); + + if (size(me.sids) >= 1) { + me.L2 = [" " ~ me.sids[0 + me.scrollSids], "SIDS", "blu"]; + if (me.sids[0 + me.scrollSids] != me.selectedSID) { + me.arrowsMatrix[0][1] = 1; + me.arrowsColour[0][1] = "blu"; + } else { + me.arrowsMatrix[0][1] = 0; + me.arrowsColour[0][1] = "ack"; + } + } + if (size(me.sids) >= 2) { + me.L3 = [" " ~ me.sids[1 + me.scrollSids], nil, "blu"]; + if (me.sids[1 + me.scrollSids] != me.selectedSID) { + me.arrowsMatrix[0][2] = 1; + me.arrowsColour[0][2] = "blu"; + } else { + me.arrowsMatrix[0][2] = 0; + me.arrowsColour[0][2] = "ack"; + } + } + if (size(me.sids) >= 3) { + me.L4 = [" " ~ me.sids[2 + me.scrollSids], nil, "blu"]; + if (me.sids[2 + me.scrollSids] != me.selectedSID) { + me.arrowsMatrix[0][3] = 1; + me.arrowsColour[0][3] = "blu"; + } else { + me.arrowsMatrix[0][3] = 0; + me.arrowsColour[0][3] = "ack"; + } + } + if (size(me.sids) >= 4) { + me.L5 = [" " ~ me.sids[3 + me.scrollSids], nil, "blu"]; + if (me.sids[3 + me.scrollSids] != me.selectedSID) { + me.arrowsMatrix[0][4] = 1; + me.arrowsColour[0][4] = "blu"; + } else { + me.arrowsMatrix[0][4] = 0; + me.arrowsColour[0][4] = "ack"; + } + } + + me.C2 = [nil, "AVAILABLE", "wht"]; + me.R2 = [nil, "TRANS ", "wht"]; + + if (size(me.sids) > 4) { + me.enableScrollSids = 1; + } + canvas_mcdu.pageSwitch[me.computer].setBoolValue(0); + }, + updateTransitions: func() { + if (me.depAirport == nil) { + me.depAirport = findAirportsByICAO(left(me.id, 4)); + } + + me._transitions = me.depAirport[0].getSid(me.selectedSID).transitions; + me.transitions = sort(me._transitions,func(a,b) cmp(a,b)); + + if (size(me.transitions) == 0) { + me.R2 = ["NO TRANS ", "TRANS", "blu"]; + if (!me.hasPressNoTrans) { + me.arrowsMatrix[1][1] = 1; + me.arrowsColour[1][1] = "blu"; + } else { + me.arrowsMatrix[1][1] = 0; + me.arrowsColour[1][1] = "ack"; + } + } elsif (size(me.transitions) >= 1) { + me.R2 = [" " ~ me.transitions[0], "TRANS", "blu"]; + if (me.transitions[0] != me.selectedTransition) { + me.arrowsMatrix[1][1] = 1; + me.arrowsColour[1][1] = "blu"; + } else { + me.arrowsMatrix[1][1] = 0; + me.arrowsColour[1][1] = "ack"; + } + } elsif (size(me.transitions) >= 2) { + me.R3 = [" " ~ me.transitions[1], nil, "blu"]; + if (me.transitions[1] != me.selectedTransition) { + me.arrowsMatrix[1][2] = 1; + me.arrowsColour[1][2] = "blu"; + } else { + me.arrowsMatrix[1][2] = 0; + me.arrowsColour[1][2] = "ack"; + } + } elsif (size(me.transitions) >= 3) { + me.R4 = [" " ~ me.transitions[2], nil, "blu"]; + if (me.transitions[2] != me.selectedTransition) { + me.arrowsMatrix[1][3] = 1; + me.arrowsColour[1][3] = "blu"; + } else { + me.arrowsMatrix[1][3] = 0; + me.arrowsColour[1][3] = "ack"; + } + } elsif (size(me.transitions) >= 4) { + me.R5 = [" " ~ me.transitions[3], nil, "blu"]; + if (me.transitions[3] != me.selectedTransition) { + me.arrowsMatrix[1][4] = 1; + me.arrowsColour[1][4] = "blu"; + } else { + me.arrowsMatrix[1][4] = 0; + me.arrowsColour[1][4] = "ack"; + } + } + }, makeTmpy: func() { - if (!TMPYActive[me.computer].getBoolValue()) { - fmgc.flightplan.initTempFP(me.computer, 2); + if (!fmgc.flightPlanController.temporaryFlag[me.computer]) { + fmgc.flightPlanController.createTemporaryFlightPlan(me.computer); me.L6 = [" F-PLN", " TMPY", "yel"]; me.arrowsColour[0][5] = "yel"; canvas_mcdu.pageSwitch[me.computer].setBoolValue(0); } }, scrollUp: func() { - if (me.enableScroll) { - me.scroll += 1; - if (me.scroll > size(me.runways) - 4) { - me.scroll = 0; + if (me.activePage == 0) { + if (me.enableScrollRwy) { + me.scrollRwy += 1; + if (me.scrollRwy > size(me.runways) - 4) { + me.scrollRwy = 0; + } + me.updateRunways(); + } + } else { + if (me.enableScrollSids) { + me.scrollSids += 1; + if (me.scrollSids > size(me.sids) - 4) { + me.scrollSids = 0; + } + me.updateSIDs(); } - me.updateRunways(); } }, scrollDn: func() { - if (me.enableScroll) { - me.scroll -= 1; - if (me.scroll < 0) { - me.scroll = size(me.runways) - 4; + if (me.activePage == 0) { + if (me.enableScrollRwy) { + me.scrollRwy -= 1; + if (me.scrollRwy < 0) { + me.scrollRwy = size(me.runways) - 4; + } + me.updateRunways(); + } + } else { + if (me.enableScrollSids) { + me.scrollSids -= 1; + if (me.scrollSids < 0) { + me.scrollSids = size(me.sids) - 4; + } + me.updateSIDs(); } - me.updateRunways(); } }, + scrollLeft: func() { + me.activePage = !me.activePage; + me.updatePage(); + }, + scrollRight: func() { + me.activePage = !me.activePage; + me.updatePage(); + }, depPushbuttonLeft: func(index) { - if (size(me.runways) >= (index - 1)) { - me.selectedRunway = me.depAirport[0].runway(me.runways[index - 2 + me.scroll]); - me.makeTmpy(); - fmgc.fp[me.computer].departure_runway = me.selectedRunway; - me.updateActiveRunway(); - fmgc.flightplan.checkWPOutputs(me.computer); + if (me.activePage == 0) { + if (size(me.runways) >= (index - 1)) { + me.selectedRunway = me.depAirport[0].runway(me.runways[index - 2 + me.scrollRwy]); + me.makeTmpy(); + fmgc.flightPlanController.flightplans[me.computer].departure_runway = me.selectedRunway; + me.updateActiveRunway(); + me.updateRunways(); + fmgc.flightPlanController.flightPlanChanged(me.computer); + me.scrollRight(); + } else { + notAllowed(me.computer); + } } else { - notAllowed(me.computer); + if (size(me.sids) >= (index - 1)) { + me.selectedSID = me.sids[index - 2 + me.scrollSids]; + me.makeTmpy(); + fmgc.flightPlanController.flightplans[me.computer].sid = me.selectedSID; + me.updateActiveSIDs(); + me.updateSIDs(); + me.updateTransitions(); + fmgc.flightPlanController.flightPlanChanged(me.computer); + } else { + notAllowed(me.computer); + } + } + }, + depPushbuttonRight: func(index) { + if (index == 2 and size(me.transitions) == 0) { + me.hasPressNoTrans = 1; + me.updateActiveTransitions(); + me.updateTransitions(); + } else { + me.selectedTransition = me.transitions[index - 2]; + me.makeTmpy(); + fmgc.flightPlanController.flightplans[me.computer].sid_trans = me.selectedTransition; + me.updateActiveTransitions(); + me.updateTransitions(); + fmgc.flightPlanController.flightPlanChanged(me.computer); } }, }; \ No newline at end of file diff --git a/Nasal/MCDU/F-PLN-rework.nas b/Nasal/MCDU/F-PLN-rework.nas new file mode 100644 index 00000000..8237db3f --- /dev/null +++ b/Nasal/MCDU/F-PLN-rework.nas @@ -0,0 +1,314 @@ +var fplnItem = { + new: func(wp, index, plan) { + var fI = {parents:[fplnItem]}; + fI.wp = wp; + fI.index = index; + fI.plan = plan; + return fI; + }, + updateLeftText: func() { + if (me.wp.wp_name != "DISCONTINUITY") { + return [me.wp.wp_name, nil, "grn"]; + } else { + return [nil, nil, "ack"]; + } + }, + updateCenterText: func() { + if (me.wp.wp_name != "DISCONTINUITY") { + me.brg = me.getBrg(); + me.track = me.getTrack(); + return ["---- ", nil, "grn"]; + } else { + return ["---F-PLN DISCONTINUITY--", nil, "wht"]; + } + }, + updateRightText: func() { + me.spd = me.getSpd(); + me.spd = me.getAlt(); + me.spd = me.getDist(); + return [me.spd ~ "/" ~ me.alt, "-" ~ me.dist ~ "NM ", "grn"]; + }, + getBrg: func() { + return nil; + }, + getTrack: func() { + return nil; + }, + getSpd: func() { + return nil; + }, + getAlt: func() { + return nil; + }, + getDist: func() { + return nil; + }, +}; + +var fplnPage = { # this one is only created once, and then updated - remember this + fontMatrix: [[0, 0, 0, 0, 0, 0],[0, 0, 0, 0, 0, 0]], + L1: [nil, nil, "ack"], # content, title, colour + L2: [nil, nil, "ack"], + L3: [nil, nil, "ack"], + L4: [nil, nil, "ack"], + L5: [nil, nil, "ack"], + L6: [nil, nil, "ack"], + C1: [nil, nil, "ack"], + C2: [nil, nil, "ack"], + C3: [nil, nil, "ack"], + C4: [nil, nil, "ack"], + C5: [nil, nil, "ack"], + C6: [nil, nil, "ack"], + R1: [nil, nil, "ack"], + R2: [nil, nil, "ack"], + R3: [nil, nil, "ack"], + R4: [nil, nil, "ack"], + R5: [nil, nil, "ack"], + R6: [nil, nil, "ack"], + + # init conditions + # line 1 = FROM + # line 2 = TO + # line 6 = DEST + # neither pseudo nor markers may be FROM waypoint + # bearing between FROM and TO waypoints + # track between line 2 and line 3 waypoints + # name of LEG above TO waypoint - is airway identifier, or waypoint name + + # DEST in LINE 6 time prediction, distance along flightplan, and EFOB + # dashes if no predictions + planList: [], + outputList: [], + scroll: 0, + new: func(plan, computer) { + var lr = {parents:[fplnPage]}; + lr.plan = fmgc.flightPlanController.flightplans[plan]; + lr.planIndex = plan; + lr.computer = computer; + lr._setupPageWithData(); + return lr; + }, + _setupPageWithData: func() { + me.destInfo(); + me.createPlanList(); + }, + getText: func(type) { + if (me.type == "discontinuity") { + return "---F-PLN DISCONTINUITY--"; + } else if (me.type == "fplnEnd") { + return "------END OF F-PLN------"; + } else if (me.type == "altnFplnEnd") { + return "----END OF ALTN F-PLN---"; + } else if (me.type == "noAltnFpln") { + return "------NO ALTN F-PLN-----"; + } else if (me.type == "empty") { + return ""; + } + }, + createPlanList: func() { + me.planList = []; + for (var i = 0; i < me.plan.getPlanSize(); i += 1) { + append(me.planList, fplnItem.new(me.plan.getWP(i), i, me.plan)); + } + + }, + basePage: func() { + me.outputList = []; + for (var i = 0; i < size(me.planList); i += 1) { + if (i == 5) { break; } + append(me.outputList, me.planList[i + me.scroll] ); + } + if (size(me.outputList) > 1) { + me.L1 = me.outputList[0].updateLeftText(); + me.C1 = me.outputList[0].updateCenterText(); + me.C1[1] = "TIME "; + me.R1 = ["---/-----", "SPD/ALT ", "grn"]; + } + if (size(me.outputList) > 2) { + me.L2 = me.outputList[1].updateLeftText(); + me.C2 = me.outputList[1].updateCenterText(); + me.R2 = ["---/-----", nil, "grn"]; + } + if (size(me.outputList) > 3) { + me.L3 = me.outputList[2].updateLeftText(); + me.C3 = me.outputList[2].updateCenterText(); + me.R3 = ["---/-----", nil, "grn"]; + } + if (size(me.outputList) > 4) { + me.L4 = me.outputList[3].updateLeftText(); + me.C4 = me.outputList[3].updateCenterText(); + me.R4 = ["---/-----", nil, "grn"]; + } + if (size(me.outputList) > 5) { + me.L5 = me.outputList[4].updateLeftText(); + me.C5 = me.outputList[4].updateCenterText(); + me.R5 = ["---/-----", nil, "grn"]; + } + }, + destInfo: func() { + me.L6 = [me.plan.getWP(fmgc.flightPlanController.arrivalIndex[me.planIndex]).wp_name, " DEST", "wht"]; + me.C6 = ["---- " ~ int(fmgc.flightPlanController.arrivalDist), "TIME DIST", "wht"]; + me.R6 = ["--.-", "EFOB", "wht"]; + }, + update: func() { + me.destInfo(); + me.basePage(); + }, + scrollUp: func() { + if (size(me.planList) > 4) { + me.scroll += 1; + if (me.scroll > size(me.planList) - 4) { + me.scroll = 0; + } + } + }, + scrollDn: func() { + if (size(me.planList) > 4) { + me.scroll += 1; + if (me.scroll < 0) { + me.scroll = size(me.planList) - 4 + } + } + }, +}; + +var notInDataBase = func(i) { + if (getprop("/MCDU[" ~ i ~ "]/scratchpad-msg") == 1) { + setprop("/MCDU[" ~ i ~ "]/last-scratchpad", "NOT IN DATABASE"); + } else { + setprop("/MCDU[" ~ i ~ "]/last-scratchpad", getprop("/MCDU[" ~ i ~ "]/scratchpad")); + } + setprop("/MCDU[" ~ i ~ "]/scratchpad-msg", 1); + setprop("/MCDU[" ~ i ~ "]/scratchpad", "NOT IN DATABASE"); +} + + +var duplicateNamesPage = { + title: nil, + subtitle: [nil, nil], + fontMatrix: [[0, 0, 0, 0, 0, 0],[0, 0, 0, 0, 0, 0]], + arrowsMatrix: [[0, 0, 0, 0, 0, 0],[0, 0, 0, 0, 0, 0]], + arrowsColour: [["ack", "ack", "ack", "ack", "ack", "ack"],["ack", "ack", "ack", "ack", "ack", "ack"]], + L1: [nil, nil, "ack"], # content, title, colour + L2: [nil, nil, "ack"], + L3: [nil, nil, "ack"], + L4: [nil, nil, "ack"], + L5: [nil, nil, "ack"], + L6: [nil, nil, "ack"], + C1: [nil, nil, "ack"], + C2: [nil, nil, "ack"], + C3: [nil, nil, "ack"], + C4: [nil, nil, "ack"], + C5: [nil, nil, "ack"], + C6: [nil, nil, "ack"], + R1: [nil, nil, "ack"], + R2: [nil, nil, "ack"], + R3: [nil, nil, "ack"], + R4: [nil, nil, "ack"], + R5: [nil, nil, "ack"], + R6: [nil, nil, "ack"], + vector: nil, + type: nil, + computer: nil, + enableScroll: 0, + scroll: 0, + distances: [], + new: func(vector, type, computer) { + var lr = {parents:[duplicateNamesPage]}; + lr.id = vector; + lr.type = type; # 0 = other, 1 = navaid + lr.computer = computer; + lr._setupPageWithData(); + return lr; + }, + del: func() { + return nil; + }, + _setupPageWithData: func() { + me.title = "DUPLICATE NAMES"; + me.arrowsMatrix = [[0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0]]; + me.arrowsColour = [["ack", "ack", "ack", "ack", "ack", "wht"], ["ack", "ack", "ack", "ack", "ack", "ack"]]; + me.fontMatrix = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]; + + for (var i = 0; i <= size(me.vector); i += 1) { + append(distances, courseAndDistance(me.vector[i])); + } + + me.C1[1] = "LAT/LONG"; + me.R1[1] = "FREQ"; + if (size(me.vector) >= 1) { + me.L1 = [" " ~ me.vector[0 + me.scroll].id, " " ~ me.distances[0 + me.scroll] ~ "NM", "blu"]; + me.arrowsMatrix[0][0] = 1; + me.arrowsColour[0][0] = "blu"; + me.C1 = [" " ~ decimalToShortString(me.vector[0 + me.scroll].lat, "lat") ~ "/" ~ decimalToShortString(me.vector[0 + me.scroll].lon, "lon"), "LAT/LONG", "grn"]; + if (me.vector[0 + me.scroll].frequency != nil) { + me.R1 = [me.vector[0 + me.scroll].frequency, "FREQ", "grn"]; + } + } + if (size(me.vector) >= 2) { + me.L2 = [" " ~ me.vector[0 + me.scroll].id, " " ~ me.distances[1 + me.scroll] ~ "NM", "blu"]; + me.arrowsMatrix[0][1] = 1; + me.arrowsColour[0][1] = "blu"; + me.C2 = [" " ~ decimalToShortString(me.vector[1 + me.scroll].lat, "lat") ~ "/" ~ decimalToShortString(me.vector[1 + me.scroll].lon, "lon"), "LAT/LONG", "grn"]; + if (me.vector[1 + me.scroll].frequency != nil) { + me.R2 = [me.vector[1 + me.scroll].frequency, nil, "grn"]; + } + } + if (size(me.vector) >= 3) { + me.L3 = [" " ~ me.vector[0 + me.scroll].id, " " ~ me.distances[2 + me.scroll] ~ "NM", "blu"]; + me.arrowsMatrix[0][2] = 1; + me.arrowsColour[0][2] = "blu"; + me.C3 = [" " ~ decimalToShortString(me.vector[2 + me.scroll].lat, "lat") ~ "/" ~ decimalToShortString(me.vector[2 + me.scroll].lon, "lon"), "LAT/LONG", "grn"]; + if (me.vector[2 + me.scroll].frequency != nil) { + me.R3 = [me.vector[2 + me.scroll].frequency, nil, "grn"]; + } + } + if (size(me.vector) >= 4) { + me.L4 = [" " ~ me.vector[0 + me.scroll].id, " " ~ me.distances[3 + me.scroll] ~ "NM", "blu"]; + me.arrowsMatrix[0][3] = 1; + me.arrowsColour[0][3] = "blu"; + me.C4 = [" " ~ decimalToShortString(me.vector[3 + me.scroll].lat, "lat") ~ "/" ~ decimalToShortString(me.vector[3 + me.scroll].lon, "lon"), "LAT/LONG", "grn"]; + if (me.vector[3 + me.scroll].frequency != nil) { + me.R4 = [me.vector[3 + me.scroll].frequency, nil, "grn"]; + } + } + if (size(me.vector) >= 5) { + me.L5 = [" " ~ me.vector[0 + me.scroll].id, " " ~ me.distances[4 + me.scroll] ~ "NM", "blu"]; + me.arrowsMatrix[0][4] = 1; + me.arrowsColour[0][4] = "blu"; + me.C5 = [" " ~ decimalToShortString(me.vector[4 + me.scroll].lat, "lat") ~ "/" ~ decimalToShortString(me.vector[4 + me.scroll].lon, "lon"), "LAT/LONG", "grn"]; + if (me.vector[4 + me.scroll].frequency != nil) { + me.R5 = [me.vector[4 + me.scroll].frequency, nil, "grn"]; + } + } + if (size(me.vector) > 5) { me.enableScroll = 1; } + + me.L6 = [" RETURN", nil, "wht"]; + }, + scrollUp: func() { + if (me.enableScroll) { + me.scroll += 1; + if (me.scroll > size(me.vector) - 5) { + me.scroll = 0; + } + } + }, + scrollDn: func() { + if (me.enableScroll) { + me.scroll -= 1; + if (me.scroll < 0) { + me.scroll = size(me.vector) - 5; + } + } + }, +}; + +var decimalToShortString = func(dms, type) { + var degrees = split(".", dms)[0]; + if (type == "lat") { + var sign = degrees >= 0 ? "N" : "S"; + } else { + var sign = degrees >= 0 ? "E" : "W"; + } + return abs(degrees) ~ sign; +} \ No newline at end of file diff --git a/Nasal/MCDU/F-PLN.nas b/Nasal/MCDU/F-PLN.nas index 7e813a0f..85759445 100644 --- a/Nasal/MCDU/F-PLN.nas +++ b/Nasal/MCDU/F-PLN.nas @@ -8,9 +8,6 @@ var TMPY = 5; var MAIN = 6; var debug = 0; # Set to 1 to check inner functionality var insertReturn = nil; -var active_out = [nil, nil, props.globals.getNode("/FMGC/flightplan[2]/active")]; -var num_out = [props.globals.getNode("/FMGC/flightplan[0]/num"), props.globals.getNode("/FMGC/flightplan[1]/num"), props.globals.getNode("/FMGC/flightplan[2]/num")]; -var TMPYActive = [props.globals.getNode("/FMGC/internal/tmpy-active[0]"), props.globals.getNode("/FMGC/internal/tmpy-active[1]")]; var clearFPLNComputer = func { FPLNLines[0].clear(); @@ -50,14 +47,89 @@ var StaticText = { notAllowed(me.computer.mcdu); } else { var scratchpad = getprop("/MCDU[" ~ me.computer.mcdu ~ "]/scratchpad"); - if (TMPYActive[me.computer.mcdu].getBoolValue()) { + if (me.computer.lines == MAIN and scratchpad != "CLR" and scratchpad != "") { + fmgc.flightPlanController.createTemporaryFlightPlan(me.computer.mcdu); + } + if (fmgc.flightPlanController.temporaryFlag[me.computer.mcdu]) { if (scratchpad == "CLR") { - if (fmgc.flightplan.deleteWP(me.index, me.computer.mcdu, 0) != 0) { + if (fmgc.flightPlanController.deleteWP(me.index, me.computer.mcdu, 0) != 0) { notAllowed(me.computer.mcdu); } else { setprop("/MCDU[" ~ me.computer.mcdu ~ "]/scratchpad-msg", 0); setprop("/MCDU[" ~ me.computer.mcdu ~ "]/scratchpad", ""); } + } elsif (size(scratchpad) == 5) { + var fix = findFixesByID(scratchpad); + if (size(fix) >= 1) { + var indexWp = fmgc.flightPlanController.flightplans[me.computer.mcdu].indexOfWP(fix[0]); + if (indexWp == -1) { + var insertReturn = fmgc.flightPlanController.insertFix(scratchpad, me.index, me.computer.mcdu); + fmgc.flightPlanController.flightPlanChanged(me.computer.mcdu); + } else { + var numTimesDelete = indexWp - me.index; + while (numTimesDelete > 0) { + fmgc.flightPlanController.deleteWP(me.index + 1, me.computer.mcdu, 0); + numTimesDelete -= 1; + } + } + if (insertReturn == 2) { + notAllowed(me.computer.mcdu); + } else if (insertReturn == 1) { + notInDataBase(me.computer.mcdu); + } else { + setprop("/MCDU[" ~ me.computer.mcdu ~ "]/scratchpad", ""); + } + } else { + notInDataBase(me.computer.mcdu); + } + } else if (size(scratchpad) == 4) { + var arpt = findAirportsByICAO(scratchpad); + if (size(arpt) >= 1) { + var indexWp = fmgc.flightPlanController.flightplans[me.computer.mcdu].indexOfWP(arpt[0]); + if (indexWp == -1) { + var insertReturn = fmgc.flightPlanController.insertArpt(scratchpad, me.index, me.computer.mcdu); + fmgc.flightPlanController.flightPlanChanged(me.computer.mcdu); + } else { + var numTimesDelete = indexWp - me.index; + while (numTimesDelete > 0) { + fmgc.flightPlanController.deleteWP(me.index + 1, me.computer.mcdu, 0); + numTimesDelete -= 1; + } + } + if (insertReturn == 2) { + notAllowed(me.computer.mcdu); + } else if (insertReturn == 1) { + notInDataBase(me.computer.mcdu); + } else { + setprop("/MCDU[" ~ me.computer.mcdu ~ "]/scratchpad", ""); + } + } else { + notInDataBase(me.computer.mcdu); + } + } else if (size(scratchpad) == 3 or size(scratchpad) == 2) { + var navaid = findNavaidsByID(scratchpad); + if (size(navaid) >= 1) { + var indexWp = fmgc.flightPlanController.flightplans[me.computer.mcdu].indexOfWP(navaid[0]); + if (indexWp == -1) { + var insertReturn = fmgc.flightPlanController.insertNavaid(scratchpad, me.index, me.computer.mcdu); + fmgc.flightPlanController.flightPlanChanged(me.computer.mcdu); + } else { + var numTimesDelete = indexWp - me.index; + while (numTimesDelete > 0) { + fmgc.flightPlanController.deleteWP(me.index + 1, me.computer.mcdu, 0); + numTimesDelete -= 1; + } + } + if (insertReturn == 2) { + notAllowed(me.computer.mcdu); + } else if (insertReturn == 1) { + notInDataBase(me.computer.mcdu); + } else { + setprop("/MCDU[" ~ me.computer.mcdu ~ "]/scratchpad", ""); + } + } else { + notInDataBase(me.computer.mcdu); + } } elsif (scratchpad == "") { if (canvas_mcdu.myLatRev[me.computer.mcdu] != nil) { canvas_mcdu.myLatRev[me.computer.mcdu].del(); @@ -70,12 +142,14 @@ var StaticText = { } } else { if (scratchpad == "CLR") { - if (fmgc.flightplan.deleteWP(me.index, 2, 0) != 0) { + if (fmgc.flightPlanController.deleteWP(me.index, 2, 0) != 0) { notAllowed(me.computer.mcdu); } else { setprop("/MCDU[" ~ me.computer.mcdu ~ "]/scratchpad-msg", 0); setprop("/MCDU[" ~ me.computer.mcdu ~ "]/scratchpad", ""); } + } elsif (size(scratchpad) != 0) { + me.pushButtonLeft(); } elsif (scratchpad == "") { if (canvas_mcdu.myLatRev[me.computer.mcdu] != nil) { canvas_mcdu.myLatRev[me.computer.mcdu].del(); @@ -114,7 +188,7 @@ var FPLNText = { } }, getColor: func(i) { - if (TMPYActive[i].getBoolValue()) { + if (fmgc.flightPlanController.temporaryFlag[i]) { if (me.dest) { return canvas_mcdu.WHITE; } else { @@ -131,14 +205,14 @@ var FPLNText = { getSubText: func(i) { if (me.index == 0) { return ""; - } else if (TMPYActive[i].getBoolValue()) { - if (fmgc.arrivalAirportI[i] == me.index) { + } else if (fmgc.flightPlanController.temporaryFlag[i]) { + if (fmgc.flightPlanController.arrivalIndex[i] == me.index) { return "DEST"; } else { return "C" ~ sprintf("%03d", fmgc.wpCoursePrev[me.fp][me.index].getValue()) ~ "g"; } } else { - if (fmgc.arrivalAirportI[2] == me.index) { + if (fmgc.flightPlanController.arrivalIndex[2] == me.index) { return "DEST"; } else { return "C" ~ sprintf("%03d", fmgc.wpCoursePrev[me.fp][me.index].getValue()) ~ "g"; @@ -149,10 +223,10 @@ var FPLNText = { pushButtonLeft: func() { var scratchpad = getprop("/MCDU[" ~ me.computer.mcdu ~ "]/scratchpad"); if (me.computer.lines == MAIN and scratchpad != "") { - fmgc.flightplan.initTempFP(me.computer.mcdu, 2); + fmgc.flightPlanController.createTemporaryFlightPlan(me.computer.mcdu); } if (scratchpad == "CLR") { - if (fmgc.flightplan.deleteWP(me.index, me.computer.mcdu, 0) != 0) { + if (fmgc.flightPlanController.deleteWP(me.index, me.computer.mcdu, 0) != 0) { notAllowed(me.computer.mcdu); } else { setprop("/MCDU[" ~ me.computer.mcdu ~ "]/scratchpad-msg", 0); @@ -160,70 +234,91 @@ var FPLNText = { } } else { if (size(scratchpad) == 5) { - var indexWp = fmgc.fp[me.computer.mcdu].indexOfWP(findFixesByID(scratchpad)); - if (indexWp == -1) { - var insertReturn = fmgc.flightplan.insertFix(scratchpad, me.index, me.computer.mcdu); - fmgc.fp[me.computer.mcdu].insertWP(createDiscontinuity(), me.index + 1); - fmgc.flightplan.checkWPOutputs(me.computer.mcdu); - } else { - for (var i = me.index; i == indexWp; i = i + 1) { - fmgc.flightplan.deleteWP(i, me.computer.mcdu, 0); + var fix = findFixesByID(scratchpad); + if (size(fix) >= 1) { + var indexWp = fmgc.flightPlanController.flightplans[me.computer.mcdu].indexOfWP(fix[0]); + if (indexWp == -1) { + var insertReturn = fmgc.flightPlanController.insertFix(scratchpad, me.index, me.computer.mcdu); + fmgc.flightPlanController.flightplans[me.computer.mcdu].insertWP(createDiscontinuity(), me.index + 1); + fmgc.flightPlanController.flightPlanChanged(me.computer.mcdu); + } else { + var numTimesDelete = indexWp - me.index; + while (numTimesDelete > 0) { + fmgc.flightPlanController.deleteWP(me.index + 1, me.computer.mcdu, 0); + numTimesDelete -= 1; + } + } + if (insertReturn == 2) { + notAllowed(me.computer.mcdu); + } else if (insertReturn == 1) { + notInDataBase(me.computer.mcdu); + } else { + setprop("/MCDU[" ~ me.computer.mcdu ~ "]/scratchpad", ""); } - } - if (insertReturn == 2) { - notAllowed(me.computer.mcdu); - } else if (insertReturn == 1) { - notInDataBase(me.computer.mcdu); } else { - setprop("/MCDU[" ~ me.computer.mcdu ~ "]/scratchpad", ""); + notInDataBase(me.computer.mcdu); } } else if (size(scratchpad) == 4) { - var indexWp = fmgc.fp[me.computer.mcdu].indexOfWP(findAirportsByICAO(scratchpad)); - if (indexWp == -1) { - var insertReturn = fmgc.flightplan.insertArpt(scratchpad, me.index, me.computer.mcdu); - fmgc.fp[me.computer.mcdu].insertWP(createDiscontinuity(), me.index + 1); - fmgc.flightplan.checkWPOutputs(me.computer.mcdu); - } else { - for (var i = me.index; i == indexWp; i = i + 1) { - fmgc.flightplan.deleteWP(i, me.computer.mcdu, 0); + var arpt = findAirportsByICAO(scratchpad); + if (size(arpt) >= 1) { + var indexWp = fmgc.flightPlanController.flightplans[me.computer.mcdu].indexOfWP(arpt[0]); + if (indexWp == -1) { + var insertReturn = fmgc.flightPlanController.insertArpt(scratchpad, me.index, me.computer.mcdu); + fmgc.flightPlanController.flightplans[me.computer.mcdu].insertWP(createDiscontinuity(), me.index + 1); + fmgc.flightPlanController.flightPlanChanged(me.computer.mcdu); + } else { + var numTimesDelete = indexWp - me.index; + while (numTimesDelete > 0) { + fmgc.flightPlanController.deleteWP(me.index + 1, me.computer.mcdu, 0); + numTimesDelete -= 1; + } + } + if (insertReturn == 2) { + notAllowed(me.computer.mcdu); + } else if (insertReturn == 1) { + notInDataBase(me.computer.mcdu); + } else { + setprop("/MCDU[" ~ me.computer.mcdu ~ "]/scratchpad", ""); } - } - if (insertReturn == 2) { - notAllowed(me.computer.mcdu); - } else if (insertReturn == 1) { - notInDataBase(me.computer.mcdu); } else { - setprop("/MCDU[" ~ me.computer.mcdu ~ "]/scratchpad", ""); + notInDataBase(me.computer.mcdu); } } else if (size(scratchpad) == 3 or size(scratchpad) == 2) { - var indexWp = fmgc.fp[me.computer.mcdu].indexOfWP(findNavaidsByID(scratchpad)); - if (indexWp == -1) { - var insertReturn = fmgc.flightplan.insertNavaid(scratchpad, me.index, me.computer.mcdu); - fmgc.fp[me.computer.mcdu].insertWP(createDiscontinuity(), me.index + 1); - fmgc.flightplan.checkWPOutputs(me.computer.mcdu); - } else { - for (var i = me.index; i == indexWp; i = i + 1) { - fmgc.flightplan.deleteWP(i, me.computer.mcdu, 0); + var navaid = findNavaidsByID(scratchpad); + if (size(navaid) >= 1) { + var indexWp = fmgc.flightPlanController.flightplans[me.computer.mcdu].indexOfWP(navaid[0]); + if (indexWp == -1) { + var insertReturn = fmgc.flightPlanController.insertNavaid(scratchpad, me.index, me.computer.mcdu); + fmgc.flightPlanController.flightplans[me.computer.mcdu].insertWP(createDiscontinuity(), me.index + 1); + fmgc.flightPlanController.flightPlanChanged(me.computer.mcdu); + } else { + var numTimesDelete = indexWp - me.index; + while (numTimesDelete > 0) { + fmgc.flightPlanController.deleteWP(me.index + 1, me.computer.mcdu, 0); + numTimesDelete -= 1; + } + } + if (insertReturn == 2) { + notAllowed(me.computer.mcdu); + } else if (insertReturn == 1) { + notInDataBase(me.computer.mcdu); + } else { + setprop("/MCDU[" ~ me.computer.mcdu ~ "]/scratchpad", ""); } - } - if (insertReturn == 2) { - notAllowed(me.computer.mcdu); - } else if (insertReturn == 1) { - notInDataBase(me.computer.mcdu); } else { - setprop("/MCDU[" ~ me.computer.mcdu ~ "]/scratchpad", ""); + notInDataBase(me.computer.mcdu); } } else if (size(scratchpad) == 1) { formatError(me.computer.mcdu); } else if (scratchpad == "") { - if (!TMPYActive[me.computer.mcdu].getBoolValue()) { - if (me.getText() == fmgc.fp[2].departure.id or left(me.getText(), 4) == fmgc.fp[2].departure.id) { + if (!fmgc.flightPlanController.temporaryFlag[me.computer.mcdu]) { + if (me.getText() == fmgc.flightPlanController.flightplans[2].departure.id or left(me.getText(), 4) == fmgc.flightPlanController.flightplans[2].departure.id) { if (canvas_mcdu.myLatRev[me.computer.mcdu] != nil) { canvas_mcdu.myLatRev[me.computer.mcdu].del(); } canvas_mcdu.myLatRev[me.computer.mcdu] = nil; canvas_mcdu.myLatRev[me.computer.mcdu] = latRev.new(0, me.getText(), me.index, me.computer.mcdu); - } elsif (me.index == fmgc.arrivalAirportI[2]) { + } elsif (me.index == fmgc.flightPlanController.arrivalIndex[2]) { if (canvas_mcdu.myLatRev[me.computer.mcdu] != nil) { canvas_mcdu.myLatRev[me.computer.mcdu].del(); } @@ -244,13 +339,13 @@ var FPLNText = { } setprop("/MCDU[" ~ me.computer.mcdu ~ "]/page", "LATREV"); } else { - if (me.getText() == fmgc.fp[me.computer.mcdu].departure.id or left(me.getText(), 4) == fmgc.fp[me.computer.mcdu].departure.id) { + if (me.getText() == fmgc.flightPlanController.flightplans[me.computer.mcdu].departure.id or left(me.getText(), 4) == fmgc.flightPlanController.flightplans[me.computer.mcdu].departure.id) { if (canvas_mcdu.myLatRev[me.computer.mcdu] != nil) { canvas_mcdu.myLatRev[me.computer.mcdu].del(); } canvas_mcdu.myLatRev[me.computer.mcdu] = nil; canvas_mcdu.myLatRev[me.computer.mcdu] = latRev.new(0, me.getText(), me.index, me.computer.mcdu); - } elsif (me.index == fmgc.arrivalAirportI[me.computer.mcdu]) { + } elsif (me.index == fmgc.flightPlanController.arrivalIndex[me.computer.mcdu]) { if (canvas_mcdu.myLatRev[me.computer.mcdu] != nil) { canvas_mcdu.myLatRev[me.computer.mcdu].del(); } @@ -320,12 +415,12 @@ var FPLNLineComputer = { me.planList = []; - if (!fmgc.active_out[2].getBoolValue()) { + if (!fmgc.flightPlanController.active.getBoolValue()) { me.destIndex = -1; me.destination = nil; } else { - fpln = fmgc.fp[fplnID]; # Get the Nasal Flightplan - me.destIndex = fmgc.arrivalAirportI[fplnID]; + fpln = fmgc.flightPlanController.flightplans[fplnID]; # Get the Nasal Flightplan + me.destIndex = fmgc.flightPlanController.arrivalIndex[fplnID]; me.destination = FPLNText.new(me, fpln.getWP(me.destIndex), 1, fplnID, me.destIndex); for (var j = 0; j < fpln.getPlanSize(); j += 1) { me.dest = 0; @@ -452,16 +547,16 @@ var slewFPLN = func(d, i) { # Scrolling function. d is -1 or 1 for direction, an var FPLNButton = func(s, key, i) { var scratchpad = getprop("/MCDU[" ~ i ~ "]/scratchpad"); if (s == "L") { - if (key == 6 and TMPYActive[i].getBoolValue()) { - fmgc.flightplan.eraseTempFP(i, 2); + if (key == 6 and fmgc.flightPlanController.temporaryFlag[i]) { + fmgc.flightPlanController.destroyTemporaryFlightPlan(i, 0); } else { if (size(FPLNLines[i].output) >= key) { FPLNLines[i].output[key - 1].pushButtonLeft(); } } } else if (s == "R") { - if (key == 6 and TMPYActive[i].getBoolValue()) { - fmgc.flightplan.executeTempFP(i, 2); + if (key == 6 and fmgc.flightPlanController.temporaryFlag[i]) { + fmgc.flightPlanController.destroyTemporaryFlightPlan(i, 1); } else { # if (scratchpad != "") { # if (size(FPLNLines[i].output) >= key) { @@ -474,174 +569,3 @@ var FPLNButton = func(s, key, i) { } } } - -var notInDataBase = func(i) { - if (getprop("/MCDU[" ~ i ~ "]/scratchpad-msg") == 1) { # Messages clear after NOT IN DATABASE - setprop("/MCDU[" ~ i ~ "]/last-scratchpad", "NOT IN DATABASE"); - } else { - setprop("/MCDU[" ~ i ~ "]/last-scratchpad", getprop("/MCDU[" ~ i ~ "]/scratchpad")); - } - setprop("/MCDU[" ~ i ~ "]/scratchpad-msg", 1); - setprop("/MCDU[" ~ i ~ "]/scratchpad", "NOT IN DATABASE"); -} - -# For testing purposes only -- do not touch! -var test = func { - var fp = createFlightplan(getprop("sim/aircraft-dir")~"/plan.gpx"); - var desti = int(fp.getPlanSize()*0.5); - FPLNLines[0].replacePlan(fp,6,desti,0); - print("Display:"); - foreach(line;FPLNLines[0].output) { - printf("line: %s",line.getText()); - } - print("down");FPLNLines[0].scrollDown(); - foreach(line;FPLNLines[0].output) { - printf("line: %s",line.getText()); - } - print("down");FPLNLines[0].scrollDown(); - foreach(line;FPLNLines[0].output) { - printf("line: %s",line.getText()); - } - print("down");FPLNLines[0].scrollDown(); - foreach(line;FPLNLines[0].output) { - printf("line: %s",line.getText()); - } - print("down");FPLNLines[0].scrollDown(); - foreach(line;FPLNLines[0].output) { - printf("line: %s",line.getText()); - } - print("down");FPLNLines[0].scrollDown(); - foreach(line;FPLNLines[0].output) { - printf("line: %s",line.getText()); - } - print("down");FPLNLines[0].scrollDown(); - foreach(line;FPLNLines[0].output) { - printf("line: %s",line.getText()); - } - print("down");FPLNLines[0].scrollDown(); - foreach(line;FPLNLines[0].output) { - printf("line: %s",line.getText()); - } - print("down");FPLNLines[0].scrollDown(); - foreach(line;FPLNLines[0].output) { - printf("line: %s",line.getText()); - } - print("down");FPLNLines[0].scrollDown(); - foreach(line;FPLNLines[0].output) { - printf("line: %s",line.getText()); - } - print("down");FPLNLines[0].scrollDown(); - foreach(line;FPLNLines[0].output) { - printf("line: %s",line.getText()); - } - print("down");FPLNLines[0].scrollDown(); - foreach(line;FPLNLines[0].output) { - printf("line: %s",line.getText()); - } - print("down");FPLNLines[0].scrollDown(); - foreach(line;FPLNLines[0].output) { - printf("line: %s",line.getText()); - } - print("down");FPLNLines[0].scrollDown(); - foreach(line;FPLNLines[0].output) { - printf("line: %s",line.getText()); - } - print("down");FPLNLines[0].scrollDown(); - foreach(line;FPLNLines[0].output) { - printf("line: %s",line.getText()); - } - print("down");FPLNLines[0].scrollDown(); - foreach(line;FPLNLines[0].output) { - printf("line: %s",line.getText()); - } - print("down");FPLNLines[0].scrollDown(); - foreach(line;FPLNLines[0].output) { - printf("line: %s",line.getText()); - } - print("down");FPLNLines[0].scrollDown(); - foreach(line;FPLNLines[0].output) { - printf("line: %s",line.getText()); - } - print("down");FPLNLines[0].scrollDown(); - foreach(line;FPLNLines[0].output) { - printf("line: %s",line.getText()); - } - print("down");FPLNLines[0].scrollDown(); - foreach(line;FPLNLines[0].output) { - printf("line: %s",line.getText()); - } - print("down");FPLNLines[0].scrollDown(); - foreach(line;FPLNLines[0].output) { - printf("line: %s",line.getText()); - } - print("down");FPLNLines[0].scrollDown(); - foreach(line;FPLNLines[0].output) { - printf("line: %s",line.getText()); - } - print("down");FPLNLines[0].scrollDown(); - foreach(line;FPLNLines[0].output) { - printf("line: %s",line.getText()); - } - print("down");FPLNLines[0].scrollDown(); - foreach(line;FPLNLines[0].output) { - printf("line: %s",line.getText()); - } - print("down");FPLNLines[0].scrollDown(); - foreach(line;FPLNLines[0].output) { - printf("line: %s",line.getText()); - } - print("down");FPLNLines[0].scrollDown(); - foreach(line;FPLNLines[0].output) { - printf("line: %s",line.getText()); - } - print("up");FPLNLines[0].scrollUp(); - foreach(line;FPLNLines[0].output) { - printf("line: %s",line.getText()); - } - print("up");FPLNLines[0].scrollUp(); - foreach(line;FPLNLines[0].output) { - printf("line: %s",line.getText()); - } - print("up");FPLNLines[0].scrollUp(); - foreach(line;FPLNLines[0].output) { - printf("line: %s",line.getText()); - } - print("up");FPLNLines[0].scrollUp(); - foreach(line;FPLNLines[0].output) { - printf("line: %s",line.getText()); - } - print("up");FPLNLines[0].scrollUp(); - foreach(line;FPLNLines[0].output) { - printf("line: %s",line.getText()); - } - print("up");FPLNLines[0].scrollUp(); - foreach(line;FPLNLines[0].output) { - printf("line: %s",line.getText()); - } - print("up");FPLNLines[0].scrollUp(); - foreach(line;FPLNLines[0].output) { - printf("line: %s",line.getText()); - } - print("up");FPLNLines[0].scrollUp(); - foreach(line;FPLNLines[0].output) { - printf("line: %s",line.getText()); - } - print("up");FPLNLines[0].scrollUp(); - foreach(line;FPLNLines[0].output) { - printf("line: %s",line.getText()); - } - print("up");FPLNLines[0].scrollUp(); - foreach(line;FPLNLines[0].output) { - printf("line: %s",line.getText()); - } - print("up");FPLNLines[0].scrollUp(); - foreach(line;FPLNLines[0].output) { - printf("line: %s",line.getText()); - } - print("up");FPLNLines[0].scrollUp(); - foreach(line;FPLNLines[0].output) { - printf("line: %s",line.getText()); - } -} - -#test(); diff --git a/Nasal/MCDU/INITA.nas b/Nasal/MCDU/INITA.nas index b88a759c..6aa5fec3 100644 --- a/Nasal/MCDU/INITA.nas +++ b/Nasal/MCDU/INITA.nas @@ -74,7 +74,7 @@ var initInputA = func(key, i) { setprop("/FMGC/internal/dep-arpt", ""); setprop("/FMGC/internal/arr-arpt", ""); setprop("/FMGC/internal/tofrom-set", 0); - fmgc.flightplan.reset(); + fmgc.flightPlanController.reset(); setprop("/MCDU[" ~ i ~ "]/scratchpad-msg", 0); setprop("/MCDU[" ~ i ~ "]/scratchpad", ""); } else { @@ -88,7 +88,7 @@ var initInputA = func(key, i) { setprop("/FMGC/internal/arr-arpt", fromto[1]); setprop("/FMGC/internal/tofrom-set", 1); setprop("/MCDU[" ~ i ~ "]/scratchpad", ""); - fmgc.flightplan.updateARPT(fromto[0], fromto[1], 2); + fmgc.flightPlanController.updateAirports(fromto[0], fromto[1], 2); } else { notAllowed(i); } diff --git a/Nasal/MCDU/LATREV.nas b/Nasal/MCDU/LATREV.nas index c82cf8ac..3d828ce4 100644 --- a/Nasal/MCDU/LATREV.nas +++ b/Nasal/MCDU/LATREV.nas @@ -34,7 +34,7 @@ var latRev = { return nil; }, _checkTmpy: func() { - if (TMPYActive[me.computer].getBoolValue()) { + if (fmgc.flightPlanController.temporaryFlag[me.computer]) { me.L6 = [" F-PLN", " TMPY", "yel"]; me.arrowsColour[0][5] = "yel"; me.R2[2] = "yel"; @@ -120,8 +120,8 @@ var latRev = { } }, makeTmpy: func() { - if (!TMPYActive[me.computer].getBoolValue()) { - fmgc.flightplan.initTempFP(me.computer, 2); + if (!fmgc.flightPlanController.temporaryFlag[me.computer]) { + fmgc.flightPlanController.createTemporaryFlightPlan(me.computer); me._checkTmpy(); } }, @@ -133,51 +133,57 @@ var latRev = { # check if it is part of the active f-pln, if so delete intermediate wpts, if not create discontinuiity after it with original wpts if (size(me.R3[0]) == 5) { var fix = findFixesByID(me.R3[0]); - if (fix != nil) { - var indexWp = fmgc.fp[me.computer].indexOfWP(fix[0]); + if (size(fix) >= 1) { + var indexWp = fmgc.flightPlanController.flightplans[me.computer].indexOfWP(fix[0]); if (indexWp == -1) { - var _insert = fmgc.flightplan.insertFix(me.R3[0], me.index + 1, me.computer); - fmgc.fp[me.computer].insertWP(createDiscontinuity(), me.index + 2); - fmgc.flightplan.checkWPOutputs(me.computer); + var _insert = fmgc.flightPlanController.insertFix(me.R3[0], me.index + 1, me.computer); + fmgc.flightPlanController.flightplans[me.computer].insertWP(createDiscontinuity(), me.index + 2); + fmgc.flightPlanController.flightPlanChanged(me.computer); } else { - for (var i = me.index + 1; i == indexWp; i = i + 1) { - fmgc.flightplan.deleteWP(i, me.computer, 0); + var numTimesDelete = indexWp - me.index; + while (numTimesDelete > 1) { + fmgc.flightPlanController.deleteWP(me.index + 1, me.computer.mcdu, 0); + numTimesDelete -= 1; } - var _insert = fmgc.flightplan.insertFix(me.R3[0], me.index + 1, me.computer); + var _insert = 0; } } else { var _insert = 1; } } elsif (size(me.R3[0]) == 4) { var airport = findAirportsByICAO(me.R3[0]); - if (airport != nil) { - var indexWp = fmgc.fp[me.computer].indexOfWP(fix[0]); + if (size(airport) >= 1) { + var indexWp = fmgc.flightPlanController.flightplans[me.computer].indexOfWP(fix[0]); if (indexWp == -1) { - var _insert = fmgc.flightplan.insertArpt(me.R3[0], me.index + 1, me.computer); - fmgc.fp[me.computer].insertWP(createDiscontinuity(), me.index + 2); - fmgc.flightplan.checkWPOutputs(me.computer); + var _insert = fmgc.flightPlanController.insertArpt(me.R3[0], me.index + 1, me.computer); + fmgc.flightPlanController.flightplans[me.computer].insertWP(createDiscontinuity(), me.index + 2); + fmgc.flightPlanController.flightPlanChanged(me.computer); } else { - for (var i = me.index + 1; i == indexWp; i = i + 1) { - fmgc.flightplan.deleteWP(i, me.computer, 0); + var numTimesDelete = indexWp - me.index; + while (numTimesDelete > 1) { + fmgc.flightPlanController.deleteWP(me.index + 1, me.computer.mcdu, 0); + numTimesDelete -= 1; } - var _insert = fmgc.flightplan.insertArpt(me.R3[0], me.index + 1, me.computer); + var _insert = 0; } } else { var _insert = 1; } } elsif (size(me.R3[0]) == 3 or size(me.R3[0]) == 2) { var navaid = findNavaidsByID(me.R3[0]); - if (navaid != nil) { - var indexWp = fmgc.fp[me.computer].indexOfWP(navaid[0]); + if (size(navaid) >= 1) { + var indexWp = fmgc.flightPlanController.flightplans[me.computer].indexOfWP(navaid[0]); if (indexWp == -1) { - var _insert = fmgc.flightplan.insertNavaid(me.R3[0], me.index + 1, me.computer); - fmgc.fp[me.computer].insertWP(createDiscontinuity(), me.index + 2); - fmgc.flightplan.checkWPOutputs(me.computer); + var _insert = fmgc.flightPlanController.insertNavaid(me.R3[0], me.index + 1, me.computer); + fmgc.flightPlanController.flightplans[me.computer].insertWP(createDiscontinuity(), me.index + 2); + fmgc.flightPlanController.flightPlanChanged(me.computer); } else { - for (var i = me.index + 1; i == indexWp; i = i + 1) { - fmgc.flightplan.deleteWP(i, me.computer, 0); + var numTimesDelete = indexWp - me.index; + while (numTimesDelete > 1) { + fmgc.flightPlanController.deleteWP(me.index + 1, me.computer.mcdu, 0); + numTimesDelete -= 1; } - var _insert = fmgc.flightplan.insertNavaid(me.R3[0], me.index + 1, me.computer); + var _insert = 0; } } else { var _insert = 1; @@ -192,7 +198,7 @@ var latRev = { notAllowed(me.computer); } else { setprop("/MCDU[" ~ me.computer ~ "]/scratchpad", ""); - fmgc.flightplan.checkWPOutputs(me.computer); + fmgc.flightPlanController.flightPlanChanged(me.computer); setprop("/MCDU[" ~ me.computer ~ "]/page", "F-PLNA"); } }, diff --git a/Nasal/MCDU/MCDU.nas b/Nasal/MCDU/MCDU.nas index de7af3a2..f1259965 100644 --- a/Nasal/MCDU/MCDU.nas +++ b/Nasal/MCDU/MCDU.nas @@ -219,7 +219,7 @@ var lskbutton = func(btn, i) { } else if (getprop("/MCDU[" ~ i ~ "]/page") == "LATREV") { setprop("/MCDU[" ~ i ~ "]/page", "F-PLNA"); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "DEPARTURE") { - if (canvas_mcdu.TMPYActive[i].getBoolValue()) { + if (fmgc.flightPlanController.temporaryFlag[i]) { setprop("/MCDU[" ~ i ~ "]/page", "F-PLNA"); } else { setprop("/MCDU[" ~ i ~ "]/page", "LATREV"); @@ -258,6 +258,8 @@ var rskbutton = func(btn, i) { printInput("R2", i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "PRINTFUNC2") { printInput2("R2", i); + } else if (getprop("/MCDU[" ~ i ~ "]/page") == "DEPARTURE") { + canvas_mcdu.myDeparture[i].depPushbuttonRight(2); } else { notAllowed(i); } @@ -344,46 +346,46 @@ var arrowbutton = func(btn, i) { setprop("/MCDU[" ~ i ~ "]/page", "DATA2"); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "DATA2") { setprop("/MCDU[" ~ i ~ "]/page", "DATA"); - } - if (getprop("/MCDU[" ~ i ~ "]/page") == "INITA") { + } else if (getprop("/MCDU[" ~ i ~ "]/page") == "INITA") { if (getprop("/engines/engine[0]/state") != 3 and getprop("/engines/engine[1]/state") != 3) { setprop("/MCDU[" ~ i ~ "]/page", "INITB"); } } else if (getprop("/MCDU[" ~ i ~ "]/page") == "INITB") { setprop("/MCDU[" ~ i ~ "]/page", "INITA"); - } - if (getprop("/MCDU[" ~ i ~ "]/page") == "PRINTFUNC") { + } else if (getprop("/MCDU[" ~ i ~ "]/page") == "PRINTFUNC") { setprop("/MCDU[" ~ i ~ "]/page", "PRINTFUNC2"); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "PRINTFUNC2") { setprop("/MCDU[" ~ i ~ "]/page", "PRINTFUNC"); + } else if (getprop("/MCDU[" ~ i ~ "]/page") == "DEPARTURE") { + canvas_mcdu.myDeparture[i].scrollLeft(); } } else if (btn == "right") { if (getprop("/MCDU[" ~ i ~ "]/page") == "DATA") { setprop("/MCDU[" ~ i ~ "]/page", "DATA2"); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "DATA2") { setprop("/MCDU[" ~ i ~ "]/page", "DATA"); - } - if (getprop("/MCDU[" ~ i ~ "]/page") == "INITA") { + } else if (getprop("/MCDU[" ~ i ~ "]/page") == "INITA") { if (getprop("/engines/engine[0]/state") != 3 and getprop("/engines/engine[1]/state") != 3) { setprop("/MCDU[" ~ i ~ "]/page", "INITB"); } } else if (getprop("/MCDU[" ~ i ~ "]/page") == "INITB") { setprop("/MCDU[" ~ i ~ "]/page", "INITA"); - } - if (getprop("/MCDU[" ~ i ~ "]/page") == "PRINTFUNC") { + } else if (getprop("/MCDU[" ~ i ~ "]/page") == "PRINTFUNC") { setprop("/MCDU[" ~ i ~ "]/page", "PRINTFUNC2"); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "PRINTFUNC2") { setprop("/MCDU[" ~ i ~ "]/page", "PRINTFUNC"); + } else if (getprop("/MCDU[" ~ i ~ "]/page") == "DEPARTURE") { + canvas_mcdu.myDeparture[i].scrollRight(); } } else if (btn == "up") { if (getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNA" or getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNB") { - slewFPLN(1, i); + canvas_mcdu.myFpln[i].scrollUp(); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "DEPARTURE") { canvas_mcdu.myDeparture[i].scrollUp(); } } else if (btn == "down") { if (getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNA" or getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNB") { - slewFPLN(-1, i); + canvas_mcdu.myFpln[i].scrollDn(); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "DEPARTURE") { canvas_mcdu.myDeparture[i].scrollDn(); } @@ -414,7 +416,10 @@ var pagebutton = func(btn, i) { setprop("/MCDU[" ~ i ~ "]/scratchpad", "SELECT DESIRED SYSTEM"); setprop("/MCDU[" ~ i ~ "]/page", "MCDU"); } else if (btn == "f-pln") { - if (active_out[2].getBoolValue()) { + if (fmgc.flightPlanController.active.getBoolValue()) { + if (canvas_mcdu.myFpln[i] == nil) { + canvas_mcdu.myFpln[i] = fplnPage.new(2, i); + } setprop("/MCDU[" ~ i ~ "]/page", "F-PLNA"); } else { setprop("/MCDU[" ~ i ~ "]/scratchpad-msg", 1); From db6360ab9e8af405a0de52f7ccf807956324945f Mon Sep 17 00:00:00 2001 From: legoboyvdlp R Date: Sun, 5 Jan 2020 20:37:43 +0000 Subject: [PATCH 07/51] fix --- A320-main.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/A320-main.xml b/A320-main.xml index 95a79524..3a1f78ba 100644 --- a/A320-main.xml +++ b/A320-main.xml @@ -1879,11 +1879,15 @@ Aircraft/A320-family/Nasal/FMGC/FCU.nas + Aircraft/A320-family/Nasal/FMGC/flightplan.nas Aircraft/A320-family/Nasal/FMGC/FMGC.nas Aircraft/A320-family/Nasal/FMGC/FMGC-b.nas Aircraft/A320-family/Nasal/FMGC/FMGC-c.nas + Aircraft/A320-family/Nasal/MCDU/LATREV.nas + Aircraft/A320-family/Nasal/MCDU/DEPARTURE.nas + Aircraft/A320-family/Nasal/MCDU/F-PLN-rework.nas Aircraft/A320-family/Nasal/MCDU/MCDU.nas Aircraft/A320-family/Nasal/MCDU/INITA.nas Aircraft/A320-family/Nasal/MCDU/INITB.nas From 9affa52adb073cffd22465b0fbcb428c8e79e880 Mon Sep 17 00:00:00 2001 From: legoboyvdlp R Date: Tue, 7 Jan 2020 20:48:27 +0000 Subject: [PATCH 08/51] Push semi-working fpln, segfaults fg due to core bug --- Models/Instruments/MCDU/MCDU.nas | 535 ++++++++++++++++--------------- Nasal/FMGC/flightplan.nas | 128 ++++++-- Nasal/MCDU/DEPARTURE.nas | 37 ++- Nasal/MCDU/F-PLN-rework.nas | 302 +++++++++++++---- Nasal/MCDU/F-PLN.nas | 375 ---------------------- Nasal/MCDU/MCDU.nas | 14 +- Nasal/Sim/libraries.nas | 4 +- 7 files changed, 641 insertions(+), 754 deletions(-) diff --git a/Models/Instruments/MCDU/MCDU.nas b/Models/Instruments/MCDU/MCDU.nas index 40939930..cc524757 100644 --- a/Models/Instruments/MCDU/MCDU.nas +++ b/Models/Instruments/MCDU/MCDU.nas @@ -219,284 +219,293 @@ var canvas_MCDU_base = { me["Simple_R5_Arrow"].hide(); me["Simple_R6_Arrow"].hide(); + me.fontLeft(default, default, default, default, default, default); + me.fontLeftS(default, default, default, default, default, default); + me.fontRight(default, default, default, default, default, default); + me.fontRightS(default, default, default, default, default, default); + + me.fontSizeLeft(normal, normal, normal, normal, normal, normal); + me.fontSizeRight(normal, normal, normal, normal, normal, normal); pageSwitch[i].setBoolValue(1); } - myFpln[i].update(); - - if (flightNumSet.getValue()) { - me["FPLN_Callsign"].setText(flightNum.getValue()); - me["FPLN_Callsign"].show(); - } else { - me["FPLN_Callsign"].hide(); - } - - if (myFpln[i].L1[0] == nil) { - me["Simple_L1"].hide(); - me["Simple_L1S"].hide(); - } else { - me["Simple_L1"].show(); - me["Simple_L1"].setText(myFpln[i].L1[0]); - if (myFpln[i].L1[1] != nil) { - me["Simple_L1S"].show(); - me["Simple_L1S"].setText(myFpln[i].L1[1]); - } else { - me["Simple_L1S"].hide(); - } - } - - if (myFpln[i].L2[0] == nil) { - me["Simple_L2"].hide(); - me["Simple_L2S"].hide(); - } else { - me["Simple_L2"].show(); - me["Simple_L2"].setText(myFpln[i].L2[0]); - if (myFpln[i].L2[1] != nil) { - me["Simple_L2S"].show(); - me["Simple_L2S"].setText(myFpln[i].L2[1]); - } else { - me["Simple_L2S"].hide(); - } - } - - if (myFpln[i].L3[0] == nil) { - me["Simple_L3"].hide(); - me["Simple_L3S"].hide(); - } else { - me["Simple_L3"].show(); - me["Simple_L3"].setText(myFpln[i].L3[0]); - if (myFpln[i].L3[1] != nil) { - me["Simple_L3S"].show(); - me["Simple_L3S"].setText(myFpln[i].L3[1]); - } else { - me["Simple_L3S"].hide(); - } - } - - if (myFpln[i].L4[0] == nil) { - me["Simple_L4"].hide(); - me["Simple_L4S"].hide(); - } else { - me["Simple_L4"].show(); - me["Simple_L4"].setText(myFpln[i].L4[0]); - if (myFpln[i].L4[1] != nil) { - me["Simple_L4S"].show(); - me["Simple_L4S"].setText(myFpln[i].L4[1]); - } else { - me["Simple_L4S"].hide(); - } - } - - if (myFpln[i].L5[0] == nil) { - me["Simple_L5"].hide(); - me["Simple_L5S"].hide(); - } else { - me["Simple_L5"].show(); - me["Simple_L5"].setText(myFpln[i].L5[0]); - if (myFpln[i].L5[1] != nil) { - me["Simple_L5S"].show(); - me["Simple_L5S"].setText(myFpln[i].L5[1]); - } else { - me["Simple_L5S"].hide(); - } - } - - if (myFpln[i].L6[0] == nil or fmgc.flightPlanController.temporaryFlag[i]) { - me["Simple_L6"].hide(); - me["Simple_L6S"].hide(); - } else { - me["Simple_L6"].show(); - me["Simple_L6"].setText(myFpln[i].L6[0]); - if (myFpln[i].L6[1] != nil) { - me["Simple_L6S"].show(); - me["Simple_L6S"].setText(myFpln[i].L6[1]); - } else { - me["Simple_L6S"].hide(); - } - } - me.colorLeft(myFpln[i].L1[2],myFpln[i].L2[2],myFpln[i].L3[2],myFpln[i].L4[2],myFpln[i].L5[2],myFpln[i].L6[2]); - - if (myFpln[i].C1[0] == nil) { - me["Simple_C1"].hide(); - me["Simple_C1S"].hide(); - } else { - me["Simple_C1"].show(); - me["Simple_C1"].setText(myFpln[i].C1[0]); - if (myFpln[i].C1[1] != nil) { - me["Simple_C1S"].show(); - me["Simple_C1S"].setText(myFpln[i].C1[1]); - } else { - me["Simple_C1S"].hide(); - } - } - - if (myFpln[i].C2[0] == nil) { - me["Simple_C2"].hide(); - me["Simple_C2S"].hide(); - } else { - me["Simple_C2"].show(); - me["Simple_C2"].setText(myFpln[i].C2[0]); - if (myFpln[i].C2[1] != nil) { - me["Simple_C2S"].show(); - me["Simple_C2S"].setText(myFpln[i].C2[1]); - } else { - me["Simple_C2S"].hide(); - } - } - - if (myFpln[i].C3[0] == nil) { - me["Simple_C3"].hide(); - me["Simple_C3S"].hide(); - } else { - me["Simple_C3"].show(); - me["Simple_C3"].setText(myFpln[i].C3[0]); - if (myFpln[i].C3[1] != nil) { - me["Simple_C3S"].show(); - me["Simple_C3S"].setText(myFpln[i].C3[1]); - } else { - me["Simple_C3S"].hide(); - } - } - - if (myFpln[i].C4[0] == nil) { - me["Simple_C4"].hide(); - me["Simple_C4S"].hide(); - } else { - me["Simple_C4"].show(); - me["Simple_C4"].setText(myFpln[i].C4[0]); - if (myFpln[i].C4[1] != nil) { - me["Simple_C4S"].show(); - me["Simple_C4S"].setText(myFpln[i].C4[1]); - } else { - me["Simple_C4S"].hide(); - } - } - - if (myFpln[i].C5[0] == nil) { - me["Simple_C5"].hide(); - me["Simple_C5S"].hide(); - } else { - me["Simple_C5"].show(); - me["Simple_C5"].setText(myFpln[i].C5[0]); - if (myFpln[i].C5[1] != nil) { - me["Simple_C5S"].show(); - me["Simple_C5S"].setText(myFpln[i].C5[1]); - } else { - me["Simple_C5S"].hide(); - } - } - - if (myFpln[i].C6[0] == nil or fmgc.flightPlanController.temporaryFlag[i]) { - me["Simple_C6"].hide(); - me["Simple_C6S"].hide(); - } else { - me["Simple_C6"].show(); - me["Simple_C6"].setText(myFpln[i].C6[0]); - if (myFpln[i].C6[1] != nil) { - me["Simple_C6S"].show(); - me["Simple_C6S"].setText(myFpln[i].C6[1]); - } else { - me["Simple_C6S"].hide(); - } - } - - me.colorCenter(myFpln[i].C1[2],myFpln[i].C2[2],myFpln[i].C3[2],myFpln[i].C4[2],myFpln[i].C5[2],myFpln[i].C6[2]); + if (myFpln[i] != nil) { + myFpln[i].update(); - if (myFpln[i].R1[0] == nil) { - me["Simple_R1"].hide(); - me["Simple_R1S"].hide(); - } else { - me["Simple_R1"].show(); - me["Simple_R1"].setText(myFpln[i].R1[0]); - if (myFpln[i].R1[1] != nil) { - me["Simple_R1S"].show(); - me["Simple_R1S"].setText(myFpln[i].R1[1]); + if (flightNumSet.getValue()) { + me["FPLN_Callsign"].setText(flightNum.getValue()); + me["FPLN_Callsign"].show(); } else { + me["FPLN_Callsign"].hide(); + } + + if (myFpln[i].L1[0] == nil) { + me["Simple_L1"].hide(); + me["Simple_L1S"].hide(); + } else { + me["Simple_L1"].show(); + me["Simple_L1"].setText(myFpln[i].L1[0]); + if (myFpln[i].L1[1] != nil) { + me["Simple_L1S"].show(); + me["Simple_L1S"].setText(myFpln[i].L1[1]); + } else { + me["Simple_L1S"].hide(); + } + } + + if (myFpln[i].L2[0] == nil) { + me["Simple_L2"].hide(); + me["Simple_L2S"].hide(); + } else { + me["Simple_L2"].show(); + me["Simple_L2"].setText(myFpln[i].L2[0]); + if (myFpln[i].L2[1] != nil) { + me["Simple_L2S"].show(); + me["Simple_L2S"].setText(myFpln[i].L2[1]); + } else { + me["Simple_L2S"].hide(); + } + } + + if (myFpln[i].L3[0] == nil) { + me["Simple_L3"].hide(); + me["Simple_L3S"].hide(); + } else { + me["Simple_L3"].show(); + me["Simple_L3"].setText(myFpln[i].L3[0]); + if (myFpln[i].L3[1] != nil) { + me["Simple_L3S"].show(); + me["Simple_L3S"].setText(myFpln[i].L3[1]); + } else { + me["Simple_L3S"].hide(); + } + } + + if (myFpln[i].L4[0] == nil) { + me["Simple_L4"].hide(); + me["Simple_L4S"].hide(); + } else { + me["Simple_L4"].show(); + me["Simple_L4"].setText(myFpln[i].L4[0]); + if (myFpln[i].L4[1] != nil) { + me["Simple_L4S"].show(); + me["Simple_L4S"].setText(myFpln[i].L4[1]); + } else { + me["Simple_L4S"].hide(); + } + } + + if (myFpln[i].L5[0] == nil) { + me["Simple_L5"].hide(); + me["Simple_L5S"].hide(); + } else { + me["Simple_L5"].show(); + me["Simple_L5"].setText(myFpln[i].L5[0]); + if (myFpln[i].L5[1] != nil) { + me["Simple_L5S"].show(); + me["Simple_L5S"].setText(myFpln[i].L5[1]); + } else { + me["Simple_L5S"].hide(); + } + } + + if (myFpln[i].L6[0] == nil or fmgc.flightPlanController.temporaryFlag[i]) { + me["Simple_L6"].hide(); + me["Simple_L6S"].hide(); + } else { + me["Simple_L6"].show(); + me["Simple_L6"].setText(myFpln[i].L6[0]); + if (myFpln[i].L6[1] != nil) { + me["Simple_L6S"].show(); + me["Simple_L6S"].setText(myFpln[i].L6[1]); + } else { + me["Simple_L6S"].hide(); + } + } + me.colorLeft(myFpln[i].L1[2],myFpln[i].L2[2],myFpln[i].L3[2],myFpln[i].L4[2],myFpln[i].L5[2],myFpln[i].L6[2]); + + if (myFpln[i].C1[0] == nil) { + me["Simple_C1"].hide(); + me["Simple_C1S"].hide(); + } else { + me["Simple_C1"].show(); + me["Simple_C1"].setText(myFpln[i].C1[0]); + if (myFpln[i].C1[1] != nil) { + me["Simple_C1S"].show(); + me["Simple_C1S"].setText(myFpln[i].C1[1]); + } else { + me["Simple_C1S"].hide(); + } + } + + if (myFpln[i].C2[0] == nil) { + me["Simple_C2"].hide(); + me["Simple_C2S"].hide(); + } else { + me["Simple_C2"].show(); + me["Simple_C2"].setText(myFpln[i].C2[0]); + if (myFpln[i].C2[1] != nil) { + me["Simple_C2S"].show(); + me["Simple_C2S"].setText(myFpln[i].C2[1]); + } else { + me["Simple_C2S"].hide(); + } + } + + if (myFpln[i].C3[0] == nil) { + me["Simple_C3"].hide(); + me["Simple_C3S"].hide(); + } else { + me["Simple_C3"].show(); + me["Simple_C3"].setText(myFpln[i].C3[0]); + if (myFpln[i].C3[1] != nil) { + me["Simple_C3S"].show(); + me["Simple_C3S"].setText(myFpln[i].C3[1]); + } else { + me["Simple_C3S"].hide(); + } + } + + if (myFpln[i].C4[0] == nil) { + me["Simple_C4"].hide(); + me["Simple_C4S"].hide(); + } else { + me["Simple_C4"].show(); + me["Simple_C4"].setText(myFpln[i].C4[0]); + if (myFpln[i].C4[1] != nil) { + me["Simple_C4S"].show(); + me["Simple_C4S"].setText(myFpln[i].C4[1]); + } else { + me["Simple_C4S"].hide(); + } + } + + if (myFpln[i].C5[0] == nil) { + me["Simple_C5"].hide(); + me["Simple_C5S"].hide(); + } else { + me["Simple_C5"].show(); + me["Simple_C5"].setText(myFpln[i].C5[0]); + if (myFpln[i].C5[1] != nil) { + me["Simple_C5S"].show(); + me["Simple_C5S"].setText(myFpln[i].C5[1]); + } else { + me["Simple_C5S"].hide(); + } + } + + if (myFpln[i].C6[0] == nil or fmgc.flightPlanController.temporaryFlag[i]) { + me["Simple_C6"].hide(); + me["Simple_C6S"].hide(); + } else { + me["Simple_C6"].show(); + me["Simple_C6"].setText(myFpln[i].C6[0]); + if (myFpln[i].C6[1] != nil) { + me["Simple_C6S"].show(); + me["Simple_C6S"].setText(myFpln[i].C6[1]); + } else { + me["Simple_C6S"].hide(); + } + } + + me.colorCenter(myFpln[i].C1[2],myFpln[i].C2[2],myFpln[i].C3[2],myFpln[i].C4[2],myFpln[i].C5[2],myFpln[i].C6[2]); + + if (myFpln[i].R1[0] == nil) { + me["Simple_R1"].hide(); me["Simple_R1S"].hide(); - } - } - - if (myFpln[i].R2[0] == nil) { - me["Simple_R2"].hide(); - me["Simple_R2S"].hide(); - } else { - me["Simple_R2"].show(); - me["Simple_R2"].setText(myFpln[i].R2[0]); - if (myFpln[i].R2[1] != nil) { - me["Simple_R2S"].show(); - me["Simple_R2S"].setText(myFpln[i].R2[1]); } else { + me["Simple_R1"].show(); + me["Simple_R1"].setText(myFpln[i].R1[0]); + if (myFpln[i].R1[1] != nil) { + me["Simple_R1S"].show(); + me["Simple_R1S"].setText(myFpln[i].R1[1]); + } else { + me["Simple_R1S"].hide(); + } + } + + if (myFpln[i].R2[0] == nil) { + me["Simple_R2"].hide(); me["Simple_R2S"].hide(); - } - } - - if (myFpln[i].R3[0] == nil) { - me["Simple_R3"].hide(); - me["Simple_R3S"].hide(); - } else { - me["Simple_R3"].show(); - me["Simple_R3"].setText(myFpln[i].R3[0]); - if (myFpln[i].R3[1] != nil) { - me["Simple_R3S"].show(); - me["Simple_R3S"].setText(myFpln[i].R3[1]); } else { + me["Simple_R2"].show(); + me["Simple_R2"].setText(myFpln[i].R2[0]); + if (myFpln[i].R2[1] != nil) { + me["Simple_R2S"].show(); + me["Simple_R2S"].setText(myFpln[i].R2[1]); + } else { + me["Simple_R2S"].hide(); + } + } + + if (myFpln[i].R3[0] == nil) { + me["Simple_R3"].hide(); me["Simple_R3S"].hide(); - } - } - - if (myFpln[i].R4[0] == nil) { - me["Simple_R4"].hide(); - me["Simple_R4S"].hide(); - } else { - me["Simple_R4"].show(); - me["Simple_R4"].setText(myFpln[i].R4[0]); - if (myFpln[i].R4[1] != nil) { - me["Simple_R4S"].show(); - me["Simple_R4S"].setText(myFpln[i].R4[1]); } else { + me["Simple_R3"].show(); + me["Simple_R3"].setText(myFpln[i].R3[0]); + if (myFpln[i].R3[1] != nil) { + me["Simple_R3S"].show(); + me["Simple_R3S"].setText(myFpln[i].R3[1]); + } else { + me["Simple_R3S"].hide(); + } + } + + if (myFpln[i].R4[0] == nil) { + me["Simple_R4"].hide(); me["Simple_R4S"].hide(); - } - } - - if (myFpln[i].R5[0] == nil) { - me["Simple_R5"].hide(); - me["Simple_R5S"].hide(); - } else { - me["Simple_R5"].show(); - me["Simple_R5"].setText(myFpln[i].R5[0]); - if (myFpln[i].R5[1] != nil) { - me["Simple_R5S"].show(); - me["Simple_R5S"].setText(myFpln[i].R5[1]); } else { + me["Simple_R4"].show(); + me["Simple_R4"].setText(myFpln[i].R4[0]); + if (myFpln[i].R4[1] != nil) { + me["Simple_R4S"].show(); + me["Simple_R4S"].setText(myFpln[i].R4[1]); + } else { + me["Simple_R4S"].hide(); + } + } + + if (myFpln[i].R5[0] == nil) { + me["Simple_R5"].hide(); me["Simple_R5S"].hide(); - } - } - - if (myFpln[i].R6[0] == nil or fmgc.flightPlanController.temporaryFlag[i]) { - me["Simple_R6"].hide(); - me["Simple_R6S"].hide(); - } else { - me["Simple_R6"].show(); - me["Simple_R6"].setText(myFpln[i].R6[0]); - if (myFpln[i].R6[1] != nil) { - me["Simple_R6S"].show(); - me["Simple_R6S"].setText(myFpln[i].R6[1]); } else { - me["Simple_R6S"].hide(); + me["Simple_R5"].show(); + me["Simple_R5"].setText(myFpln[i].R5[0]); + if (myFpln[i].R5[1] != nil) { + me["Simple_R5S"].show(); + me["Simple_R5S"].setText(myFpln[i].R5[1]); + } else { + me["Simple_R5S"].hide(); + } + } + + if (myFpln[i].R6[0] == nil or fmgc.flightPlanController.temporaryFlag[i]) { + me["Simple_R6"].hide(); + me["Simple_R6S"].hide(); + } else { + me["Simple_R6"].show(); + me["Simple_R6"].setText(myFpln[i].R6[0]); + if (myFpln[i].R6[1] != nil) { + me["Simple_R6S"].show(); + me["Simple_R6S"].setText(myFpln[i].R6[1]); + } else { + me["Simple_R6S"].hide(); + } + } + me.colorRight(myFpln[i].R1[2],myFpln[i].R2[2],myFpln[i].R3[2],myFpln[i].R4[2],myFpln[i].R5[2],myFpln[i].R6[2]); + + #if (mcdu.FPLNLines[i].index == 0) { + # me["FPLN_From"].show(); + #} else { + # me["FPLN_From"].hide(); + #} + + if (fmgc.flightPlanController.temporaryFlag[i]) { + me["FPLN_TMPY_group"].show(); + } else { + me["FPLN_TMPY_group"].hide(); } - } - me.colorRight(myFpln[i].R1[2],myFpln[i].R2[2],myFpln[i].R3[2],myFpln[i].R4[2],myFpln[i].R5[2],myFpln[i].R6[2]); - - #if (mcdu.FPLNLines[i].index == 0) { - # me["FPLN_From"].show(); - #} else { - # me["FPLN_From"].hide(); - #} - - if (fmgc.flightPlanController.temporaryFlag[i]) { - me["FPLN_TMPY_group"].show(); - } else { - me["FPLN_TMPY_group"].hide(); } } elsif (page == "MCDU") { if (!pageSwitch[i].getBoolValue()) { @@ -1762,6 +1771,7 @@ var canvas_MCDU_base = { me["arrowsDepArr"].hide(); me["Simple_PageNum"].setText("X/X"); me["Simple_PageNum"].hide(); + me["Simple_Title"].show(); me["ArrowLeft"].hide(); me["ArrowRight"].hide(); @@ -2016,6 +2026,7 @@ var canvas_MCDU_base = { me["PERFTO"].hide(); me["Simple_PageNum"].setText("X/X"); me["Simple_PageNum"].hide(); + me["Simple_Title"].show(); me["ArrowLeft"].show(); me["ArrowRight"].show(); me["arrowsDepArr"].show(); diff --git a/Nasal/FMGC/flightplan.nas b/Nasal/FMGC/flightplan.nas index 2fce05d0..11d759ed 100644 --- a/Nasal/FMGC/flightplan.nas +++ b/Nasal/FMGC/flightplan.nas @@ -64,6 +64,7 @@ var flightPlanController = { }, createTemporaryFlightPlan: func(n) { + me.resetFlightplan(n); me.flightplans[n] = me.flightplans[2].clone(); me.temporaryFlag[n] = 1; me.flightPlanChanged(n); @@ -71,8 +72,11 @@ var flightPlanController = { destroyTemporaryFlightPlan: func(n, a) { # a = 1 activate, a = 0 erase if (a == 1) { + flightPlanTimer.stop(); + me.resetFlightplan(2); me.flightplans[2] = me.flightplans[n].clone(); me.flightPlanChanged(2); + flightPlanTimer.start(); } me.resetFlightplan(n); me.temporaryFlag[n] = 0; @@ -116,15 +120,18 @@ var flightPlanController = { deleteWP: func(index, n) { var wp = wpID[n][index].getValue(); if (wp != FMGCdep.getValue() and wp != FMGCarr.getValue() and me.flightplans[n].getPlanSize() > 2) { - if (me.flightplans[2].getWP(index).id != "DISCONTINUITY") { # if it is a discont, don't make a new one - me.flightplans[2].deleteWP(index); - if (me.flightplans[2].getWP(index).id != "DISCONTINUITY") { # else, if the next one isn't a discont, add one + if (me.flightplans[n].getWP(index).id != "DISCONTINUITY") { # if it is a discont, don't make a new one + me.flightplans[n].deleteWP(index); + if (me.flightplans[n].getWP(index).id != "DISCONTINUITY") { # else, if the next one isn't a discont, add one me.addDiscontinuity(index, n); } } else { - me.flightplans[2].deleteWP(index); + me.flightplans[n].deleteWP(index); } me.flightPlanChanged(n); + return 2; + } else { + return 1; } }, @@ -143,15 +150,27 @@ var flightPlanController = { if (me.flightplans[plan].indexOfWP(airport[0]) == -1) { me.flightplans[plan].insertWP(createWPFrom(airport[0]), index); me.flightPlanChanged(plan); + return 2; } else { var numToDel = me.flightplans[plan].indexOfWP(airport[0]) - index; + while (numToDel > 0) { + me.deleteWP(index + 1, plan, 0); + numToDel -= 1; + } + return 2; } } else { if (me.flightplans[plan].indexOfWP(airport[overrideIndex]) == -1) { me.flightplans[plan].insertWP(createWPFrom(airport[overrideIndex]), index); me.flightPlanChanged(plan); + return 2; } else { var numToDel = me.flightplans[plan].indexOfWP(airport[overrideIndex]) - index; + while (numToDel > 0) { + me.deleteWP(index + 1, plan, 0); + numToDel -= 1; + } + return 2; } } } elsif (size(airport) >= 1) { @@ -170,12 +189,35 @@ var flightPlanController = { } if (size(fix) == 1 or override) { - if (me.flightplans[plan].indexOfWP(fix[0]) == -1) { - me.flightplans[plan].insertWP(createWPFrom(fix[0]), index); - me.flightPlanChanged(plan); + if (!override) { + if (me.flightplans[plan].indexOfWP(fix[0]) == -1) { + me.flightplans[plan].insertWP(createWPFrom(fix[0]), index); + me.flightPlanChanged(plan); + return 2; + } else { + var numToDel = me.flightplans[plan].indexOfWP(fix[0]) - index; + while (numToDel > 0) { + me.deleteWP(index + 1, plan, 0); + numToDel -= 1; + } + return 2; + } } else { - var numToDel = me.flightplans[plan].indexOfWP(fix[0]) - index; + if (me.flightplans[plan].indexOfWP(fix[overrideIndex]) == -1) { + me.flightplans[plan].insertWP(createWPFrom(fix[overrideIndex]), index); + me.flightPlanChanged(plan); + return 2; + } else { + var numToDel = me.flightplans[plan].indexOfWP(fix[overrideIndex]) - index; + while (numToDel > 0) { + me.deleteWP(index + 1, plan, 0); + numToDel -= 1; + } + return 2; + } } + } elsif (size(fix) >= 1) { + # spawn DUPLICATE NAMES } }, @@ -190,24 +232,58 @@ var flightPlanController = { } if (size(navaid) == 1 or override) { - if (me.flightplans[plan].indexOfWP(navaid[0]) == -1) { - me.flightplans[plan].insertWP(createWPFrom(navaid[0]), index); - me.flightPlanChanged(plan); + if (!override) { + if (me.flightplans[plan].indexOfWP(navaid[0]) == -1) { + me.flightplans[plan].insertWP(createWPFrom(navaid[0]), index); + me.flightPlanChanged(plan); + return 2; + } else { + var numToDel = me.flightplans[plan].indexOfWP(navaid[0]) - index; + while (numToDel > 0) { + me.deleteWP(index + 1, plan, 0); + numToDel -= 1; + } + return 2; + } } else { - var numToDel = me.flightplans[plan].indexOfWP(fix[0]) - index; + if (me.flightplans[plan].indexOfWP(navaid[overrideIndex]) == -1) { + me.flightplans[plan].insertWP(createWPFrom(navaid[overrideIndex]), index); + me.flightPlanChanged(plan); + return 2; + } else { + var numToDel = me.flightplans[plan].indexOfWP(navaid[overrideIndex]) - index; + while (numToDel > 0) { + me.deleteWP(index + 1, plan, 0); + numToDel -= 1; + } + return 2; + } } + } elsif (size(navaid) >= 1) { + # spawn DUPLICATE NAMES } }, scratchpad: func(text, index, plan) { # return 0 not in database, 1 not allowed, 2 success + if (!fmgc.flightPlanController.temporaryFlag[plan]) { + if (text == "CLR" and me.flightplans[2].getWP(index).wp_name == "DISCONTINUITY") { + var thePlan = 2; + } else { + fmgc.flightPlanController.createTemporaryFlightPlan(plan); + var thePlan = plan; + } + } else { + var thePlan = plan; + } + if (text == "CLR") { - return me.deleteWP(index); + return me.deleteWP(index, thePlan); } elsif (size(text) == 5) { - return me.insertFix(text, index, plan); + return me.insertFix(text, index, thePlan); } elsif (size(text) == 4) { - return me.insertAirport(text, index, plan); + return me.insertAirport(text, index, thePlan); } elsif (size(text) == 3 or size(text) == 2) { - return me.insertNavatext(text, index, plan); + return me.insertNavaid(text, index, thePlan); } else { return 1; } @@ -224,7 +300,6 @@ var flightPlanController = { append(wpCoursePrev[n], props.globals.initNode("/FMGC/flightplan[" ~ n ~ "]/wp[" ~ counter ~ "]/course-from-prev", 0, "DOUBLE")); append(wpDistancePrev[n], props.globals.initNode("/FMGC/flightplan[" ~ n ~ "]/wp[" ~ counter ~ "]/distance-from-prev", 0, "DOUBLE")); } - me.updatePlans(); }, @@ -267,8 +342,14 @@ var flightPlanController = { wpDistancePrev[n][wpt].setValue(courseDistanceFrom[1]); } - if (wpID[n][wpt].getValue() == FMGCarr.getValue()) { + if (wpID[n][wpt].getValue() == FMGCarr.getValue() and me.arrivalIndex[n] != wpt) { me.arrivalIndex[n] = wpt; + if (canvas_mcdu.myFpln[0] != nil) { + canvas_mcdu.myFpln[0].destInfo(); + } + if (canvas_mcdu.myFpln[1] != nil) { + canvas_mcdu.myFpln[1].destInfo(); + } } } } @@ -316,15 +397,10 @@ var flightPlanController = { } }, - updateMCDUDriver: func(n) { + updateMCDUDriver: func() { for (var i = 0; i <= 1; i += 1) { - if (me.temporaryFlag[i] == 1) { - mcdu.FPLNLines[i].replacePlan(i, mcdu.TMPY, mcdu.FPLNLines[i].index); - } else { - mcdu.FPLNLines[i].replacePlan(2, mcdu.MAIN, mcdu.FPLNLines[i].index); - if (canvas_mcdu.myFpln[i] != nil) { - canvas_mcdu.myFpln[i].createPlanList(); - } + if (canvas_mcdu.myFpln[i] != nil) { + canvas_mcdu.myFpln[i].updatePlan(); } } }, diff --git a/Nasal/MCDU/DEPARTURE.nas b/Nasal/MCDU/DEPARTURE.nas index b9d4deb6..71da8d93 100644 --- a/Nasal/MCDU/DEPARTURE.nas +++ b/Nasal/MCDU/DEPARTURE.nas @@ -160,22 +160,26 @@ var departurePage = { canvas_mcdu.pageSwitch[me.computer].setBoolValue(0); }, updateActiveTransitions: func() { - if (me.selectedTransition != nil) { - if (fmgc.flightPlanController.flightplans[2].sid_trans != nil) { - if (fmgc.flightPlanController.flightplans[2].sid_trans == me.selectedTransition) { - me.R1 = [fmgc.flightPlanController.flightplans[2].sid_trans.id, "TRANS", "grn"]; + if (!me.hasPressNoTrans) { + if (me.selectedTransition != nil) { + if (fmgc.flightPlanController.flightplans[2].sid_trans != nil) { + if (fmgc.flightPlanController.flightplans[2].sid_trans == me.selectedTransition) { + me.R1 = [fmgc.flightPlanController.flightplans[2].sid_trans.id, "TRANS", "grn"]; + } elsif (fmgc.flightPlanController.flightplans[me.computer].sid_trans != nil) { + me.R1 = [fmgc.flightPlanController.flightplans[me.computer].sid_trans.id, "TRANS", "yel"]; + } else { + me.R1 = ["-------", "TRANS ", "wht"]; + } } elsif (fmgc.flightPlanController.flightplans[me.computer].sid_trans != nil) { - me.R1 = [fmgc.flightPlanController.flightplans[me.computer].sid_trans.id, "TRANS", "yel"]; + me.C1 = [fmgc.flightPlanController.flightplans[me.computer].sid_trans.id, "SID", "yel"]; } else { me.R1 = ["-------", "TRANS ", "wht"]; - } - } elsif (fmgc.flightPlanController.flightplans[me.computer].sid_trans != nil) { - me.C1 = [fmgc.flightPlanController.flightplans[me.computer].sid_trans.id, "SID", "yel"]; + } } else { me.R1 = ["-------", "TRANS ", "wht"]; } } else { - me.R1 = ["-------", "TRANS ", "wht"]; + me.R1 = ["NONE", "TRANS ", "yel"]; } canvas_mcdu.pageSwitch[me.computer].setBoolValue(0); }, @@ -319,7 +323,7 @@ var departurePage = { me.arrowsColour[1][1] = "ack"; } } elsif (size(me.transitions) >= 1) { - me.R2 = [" " ~ me.transitions[0], "TRANS", "blu"]; + me.R2 = [me.transitions[0] ~ " ", "TRANS", "blu"]; if (me.transitions[0] != me.selectedTransition) { me.arrowsMatrix[1][1] = 1; me.arrowsColour[1][1] = "blu"; @@ -328,7 +332,7 @@ var departurePage = { me.arrowsColour[1][1] = "ack"; } } elsif (size(me.transitions) >= 2) { - me.R3 = [" " ~ me.transitions[1], nil, "blu"]; + me.R3 = [me.transitions[1] ~ " ", nil, "blu"]; if (me.transitions[1] != me.selectedTransition) { me.arrowsMatrix[1][2] = 1; me.arrowsColour[1][2] = "blu"; @@ -337,7 +341,7 @@ var departurePage = { me.arrowsColour[1][2] = "ack"; } } elsif (size(me.transitions) >= 3) { - me.R4 = [" " ~ me.transitions[2], nil, "blu"]; + me.R4 = [me.transitions[2] ~ " ", nil, "blu"]; if (me.transitions[2] != me.selectedTransition) { me.arrowsMatrix[1][3] = 1; me.arrowsColour[1][3] = "blu"; @@ -346,7 +350,7 @@ var departurePage = { me.arrowsColour[1][3] = "ack"; } } elsif (size(me.transitions) >= 4) { - me.R5 = [" " ~ me.transitions[3], nil, "blu"]; + me.R5 = [me.transitions[3] ~ " ", nil, "blu"]; if (me.transitions[3] != me.selectedTransition) { me.arrowsMatrix[1][4] = 1; me.arrowsColour[1][4] = "blu"; @@ -399,6 +403,7 @@ var departurePage = { me.scrollSids = size(me.sids) - 4; } me.updateSIDs(); + me.hasPressNoTrans = 0; } } }, @@ -430,7 +435,9 @@ var departurePage = { fmgc.flightPlanController.flightplans[me.computer].sid = me.selectedSID; me.updateActiveSIDs(); me.updateSIDs(); + me.hasPressNoTrans = 0; me.updateTransitions(); + me.updateActiveTransitions(); fmgc.flightPlanController.flightPlanChanged(me.computer); } else { notAllowed(me.computer); @@ -442,13 +449,15 @@ var departurePage = { me.hasPressNoTrans = 1; me.updateActiveTransitions(); me.updateTransitions(); - } else { + } elsif (size(me.transitions) >= (index - 1)) { me.selectedTransition = me.transitions[index - 2]; me.makeTmpy(); fmgc.flightPlanController.flightplans[me.computer].sid_trans = me.selectedTransition; me.updateActiveTransitions(); me.updateTransitions(); fmgc.flightPlanController.flightPlanChanged(me.computer); + } else { + notAllowed(me.computer); } }, }; \ No newline at end of file diff --git a/Nasal/MCDU/F-PLN-rework.nas b/Nasal/MCDU/F-PLN-rework.nas index 8237db3f..3e64ab34 100644 --- a/Nasal/MCDU/F-PLN-rework.nas +++ b/Nasal/MCDU/F-PLN-rework.nas @@ -1,32 +1,55 @@ var fplnItem = { - new: func(wp, index, plan) { + new: func(wp, index, plan, computer, colour = "grn") { var fI = {parents:[fplnItem]}; fI.wp = wp; fI.index = index; fI.plan = plan; + fI.computer = computer; + fI.colour = colour; return fI; }, updateLeftText: func() { - if (me.wp.wp_name != "DISCONTINUITY") { - return [me.wp.wp_name, nil, "grn"]; + if (me.wp != nil) { + if (me.wp.wp_name != "DISCONTINUITY") { + var wptName = split("-", me.wp.wp_name); + if (size(wptName) == 2) { + return[wptName[0] ~ wptName[1], nil, me.colour]; + } else { + return [me.wp.wp_name, nil, me.colour]; + } + } else { + return [nil, nil, "ack"]; + } } else { - return [nil, nil, "ack"]; + return ["problem", nil, "ack"]; } }, updateCenterText: func() { - if (me.wp.wp_name != "DISCONTINUITY") { - me.brg = me.getBrg(); - me.track = me.getTrack(); - return ["---- ", nil, "grn"]; + if (me.wp != nil) { + if (me.wp.wp_name != "DISCONTINUITY") { + me.brg = me.getBrg(); + me.track = me.getTrack(); + return ["---- ", nil, me.colour]; + } else { + return ["---F-PLN DISCONTINUITY--", nil, "wht"]; + } } else { - return ["---F-PLN DISCONTINUITY--", nil, "wht"]; + return ["problem", nil, "ack"]; } }, updateRightText: func() { - me.spd = me.getSpd(); - me.spd = me.getAlt(); - me.spd = me.getDist(); - return [me.spd ~ "/" ~ me.alt, "-" ~ me.dist ~ "NM ", "grn"]; + if (me.wp != nil) { + if (me.wp.wp_name != "DISCONTINUITY") { + me.spd = me.getSpd(); + me.alt = me.getAlt(); + me.dist = me.getDist(); + return [me.spd ~ "/" ~ me.alt, " " ~ me.dist ~ "NM ", me.colour]; + } else { + return [nil, nil, "ack"]; + } + } else { + return ["problem", nil, "ack"]; + } }, getBrg: func() { return nil; @@ -35,13 +58,70 @@ var fplnItem = { return nil; }, getSpd: func() { - return nil; + return "---"; }, getAlt: func() { - return nil; + return "-----"; }, getDist: func() { - return nil; + return "--"; + }, + pushButtonLeft: func() { + if (canvas_mcdu.myLatRev[me.computer] != nil) { + canvas_mcdu.myLatRev[me.computer].del(); + } + canvas_mcdu.myLatRev[me.computer] = nil; + if (me.wp.wp_name == "DISCONTINUITY") { + canvas_mcdu.myLatRev[me.computer] = latRev.new(4, "DISCON", me.index, me.computer); + } elsif (fmgc.flightPlanController.temporaryFlag[me.computer]) { + if (left(me.wp.wp_name, 4) == fmgc.flightPlanController.flightplans[me.computer].departure.id) { + canvas_mcdu.myLatRev[me.computer] = latRev.new(0, left(me.wp.wp_name, 4), me.index, me.computer); + } elsif (me.index == fmgc.flightPlanController.arrivalIndex[me.computer]) { + canvas_mcdu.myLatRev[me.computer] = latRev.new(1, left(me.wp.wp_name, 4), me.index, me.computer); + } elsif (me.index == (fmgc.flightPlanController.currentToWptIndex.getValue() - 1)) { + canvas_mcdu.myLatRev[me.computer] = latRev.new(2, me.wp.wp_name, me.index, me.computer); + } else { + canvas_mcdu.myLatRev[me.computer] = latRev.new(3, me.wp.wp_name, me.index, me.computer); + } + } else { + if (left(me.wp.wp_name, 4) == fmgc.flightPlanController.flightplans[2].departure.id) { + canvas_mcdu.myLatRev[me.computer] = latRev.new(0, left(me.wp.wp_name, 4), me.index, me.computer); + } elsif (me.index == fmgc.flightPlanController.arrivalIndex[2]) { + canvas_mcdu.myLatRev[me.computer] = latRev.new(1, left(me.wp.wp_name, 4), me.index, me.computer); + } elsif (me.index == (fmgc.flightPlanController.currentToWptIndex.getValue() - 1)) { + canvas_mcdu.myLatRev[me.computer] = latRev.new(2, me.wp.wp_name, me.index, me.computer); + } else { + canvas_mcdu.myLatRev[me.computer] = latRev.new(3, me.wp.wp_name, me.index, me.computer); + } + } + setprop("/MCDU[" ~ me.computer ~ "]/page", "LATREV"); + }, + pushButtonRight: func() { + notAllowed(me.computer); + }, +}; + +var staticText = { + new: func(computer, text) { + var sT = {parents:[staticText]}; + sT.computer = computer; + sT.text = text; + return sT; + }, + updateLeftText: func() { + return [nil, nil, "ack"]; + }, + updateCenterText: func() { + return [me.text, nil, "wht"]; + }, + updateRightText: func() { + return [nil, nil, "ack"]; + }, + pushButtonLeft: func() { + notAllowed(me.computer); + }, + pushButtonRight: func() { + notAllowed(me.computer); }, }; @@ -80,69 +160,110 @@ var fplnPage = { # this one is only created once, and then updated - remember th planList: [], outputList: [], scroll: 0, + temporaryFlagFpln: 0, new: func(plan, computer) { - var lr = {parents:[fplnPage]}; - lr.plan = fmgc.flightPlanController.flightplans[plan]; - lr.planIndex = plan; - lr.computer = computer; - lr._setupPageWithData(); - return lr; + var fp = {parents:[fplnPage]}; + fp.plan = fmgc.flightPlanController.flightplans[plan]; + fp.planIndex = plan; + fp.computer = computer; + fp.planList = []; + fp.outputList = []; + return fp; }, _setupPageWithData: func() { me.destInfo(); me.createPlanList(); }, + updatePlan: func() { + if (!fmgc.flightPlanController.temporaryFlag[me.computer]) { + me.planIndex = 2; + me.plan = fmgc.flightPlanController.flightplans[2]; + me.temporaryFlagFpln = 0; + } else { + me.planIndex = me.computer; + me.plan = fmgc.flightPlanController.flightplans[me.computer]; + me.temporaryFlagFpln = 1; + } + me._setupPageWithData(); + }, getText: func(type) { - if (me.type == "discontinuity") { - return "---F-PLN DISCONTINUITY--"; - } else if (me.type == "fplnEnd") { + if (type == "fplnEnd") { return "------END OF F-PLN------"; - } else if (me.type == "altnFplnEnd") { + } else if (type == "altnFplnEnd") { return "----END OF ALTN F-PLN---"; - } else if (me.type == "noAltnFpln") { + } else if (type == "noAltnFpln") { return "------NO ALTN F-PLN-----"; - } else if (me.type == "empty") { + } else if (type == "empty") { return ""; } }, createPlanList: func() { me.planList = []; - for (var i = 0; i < me.plan.getPlanSize(); i += 1) { - append(me.planList, fplnItem.new(me.plan.getWP(i), i, me.plan)); + if (me.temporaryFlagFpln) { + for (var i = 0; i < me.plan.getPlanSize(); i += 1) { + append(me.planList, fplnItem.new(me.plan.getWP(i), i, me.plan, me.computer, "yel")); + } + } else { + for (var i = 0; i < me.plan.getPlanSize(); i += 1) { + append(me.planList, fplnItem.new(me.plan.getWP(i), i, me.plan, me.computer)); + } } - + append(me.planList, staticText.new(me.computer, me.getText("fplnEnd"))); + append(me.planList, staticText.new(me.computer, me.getText("noAltnFpln"))); + me.update(); }, basePage: func() { me.outputList = []; - for (var i = 0; i < size(me.planList); i += 1) { - if (i == 5) { break; } + for (var i = 0; i + me.scroll < size(me.planList); i += 1) { append(me.outputList, me.planList[i + me.scroll] ); + if (size(me.outputList) == 5) { break; } } - if (size(me.outputList) > 1) { + if (size(me.outputList) >= 1) { me.L1 = me.outputList[0].updateLeftText(); me.C1 = me.outputList[0].updateCenterText(); me.C1[1] = "TIME "; - me.R1 = ["---/-----", "SPD/ALT ", "grn"]; + me.R1 = me.outputList[0].updateRightText(); + me.R1[1] = "SPD/ALT "; + } else { + me.L1 = [nil, nil, "ack"]; + me.C1 = [nil, nil, "ack"]; + me.R1 = [nil, nil, "ack"]; } - if (size(me.outputList) > 2) { + if (size(me.outputList) >= 2) { me.L2 = me.outputList[1].updateLeftText(); me.C2 = me.outputList[1].updateCenterText(); - me.R2 = ["---/-----", nil, "grn"]; + me.R2 = me.outputList[1].updateRightText(); + } else { + me.L2 = [nil, nil, "ack"]; + me.C2 = [nil, nil, "ack"]; + me.R2 = [nil, nil, "ack"]; } - if (size(me.outputList) > 3) { + if (size(me.outputList) >= 3) { me.L3 = me.outputList[2].updateLeftText(); me.C3 = me.outputList[2].updateCenterText(); - me.R3 = ["---/-----", nil, "grn"]; + me.R3 = me.outputList[2].updateRightText(); + } else { + me.L3 = [nil, nil, "ack"]; + me.C3 = [nil, nil, "ack"]; + me.R3 = [nil, nil, "ack"]; } - if (size(me.outputList) > 4) { + if (size(me.outputList) >= 4) { me.L4 = me.outputList[3].updateLeftText(); me.C4 = me.outputList[3].updateCenterText(); - me.R4 = ["---/-----", nil, "grn"]; + me.R4 = me.outputList[3].updateRightText(); + } else { + me.L4 = [nil, nil, "ack"]; + me.C4 = [nil, nil, "ack"]; + me.R4 = [nil, nil, "ack"]; } - if (size(me.outputList) > 5) { + if (size(me.outputList) >= 5) { me.L5 = me.outputList[4].updateLeftText(); me.C5 = me.outputList[4].updateCenterText(); - me.R5 = ["---/-----", nil, "grn"]; + me.R5 = me.outputList[4].updateRightText(); + } else { + me.L5 = [nil, nil, "ack"]; + me.C5 = [nil, nil, "ack"]; + me.R5 = [nil, nil, "ack"]; } }, destInfo: func() { @@ -151,27 +272,72 @@ var fplnPage = { # this one is only created once, and then updated - remember th me.R6 = ["--.-", "EFOB", "wht"]; }, update: func() { - me.destInfo(); me.basePage(); }, scrollUp: func() { - if (size(me.planList) > 4) { + if (size(me.planList) > 5) { me.scroll += 1; - if (me.scroll > size(me.planList) - 4) { + if (me.scroll > size(me.planList) - 5) { me.scroll = 0; } + } else { + me.scroll = 0; } }, scrollDn: func() { - if (size(me.planList) > 4) { - me.scroll += 1; + if (size(me.planList) > 5) { + me.scroll -= 1; if (me.scroll < 0) { - me.scroll = size(me.planList) - 4 + me.scroll = size(me.planList) - 5; + } + } else { + me.scroll = 0; + } + }, + pushButtonLeft: func(index) { + if (index == 1 and size(getprop("/MCDU[" ~ me.computer ~ "]/scratchpad")) > 0) { + notAllowed(me.computer); + return; + } + if (index == 6) { + if (fmgc.flightPlanController.temporaryFlag[me.computer]) { + fmgc.flightPlanController.destroyTemporaryFlightPlan(me.computer, 0); + } else { + notAllowed(me.computer); + } + } else { + if (size(me.outputList) >= index) { + if (size(getprop("/MCDU[" ~ me.computer ~ "]/scratchpad")) > 0) { + var returny = fmgc.flightPlanController.scratchpad(getprop("/MCDU[" ~ me.computer ~ "]/scratchpad"), (index - 1 + me.scroll), me.computer); + if (returny == 0) { + notInDataBase(me.computer); + } elsif (returny == 1) { + notAllowed(me.computer); + } else { + setprop("/MCDU[" ~ me.computer ~ "]/scratchpad-msg", ""); + setprop("/MCDU[" ~ me.computer ~ "]/scratchpad", ""); + } + } else { + me.outputList[index - 1 + me.scroll].pushButtonLeft(); + } + } else { + notAllowed(me.computer); } } }, + pushButtonRight: func(index) { + if (index == 6) { + if (fmgc.flightPlanController.temporaryFlag[me.computer]) { + fmgc.flightPlanController.destroyTemporaryFlightPlan(me.computer, 1); + } else { + notAllowed(me.computer); + } + } else { + notAllowed(me.computer); + } + }, }; - + var notInDataBase = func(i) { if (getprop("/MCDU[" ~ i ~ "]/scratchpad-msg") == 1) { setprop("/MCDU[" ~ i ~ "]/last-scratchpad", "NOT IN DATABASE"); @@ -214,12 +380,12 @@ var duplicateNamesPage = { scroll: 0, distances: [], new: func(vector, type, computer) { - var lr = {parents:[duplicateNamesPage]}; - lr.id = vector; - lr.type = type; # 0 = other, 1 = navaid - lr.computer = computer; - lr._setupPageWithData(); - return lr; + var fp = {parents:[duplicateNamesPage]}; + fp.id = vector; + fp.type = type; # 0 = other, 1 = navaid + fp.computer = computer; + fp._setupPageWithData(); + return fp; }, del: func() { return nil; @@ -286,20 +452,20 @@ var duplicateNamesPage = { me.L6 = [" RETURN", nil, "wht"]; }, scrollUp: func() { - if (me.enableScroll) { - me.scroll += 1; - if (me.scroll > size(me.vector) - 5) { - me.scroll = 0; - } - } + #if (me.enableScroll) { + # me.scroll += 1; + # if (me.scroll > size(me.vector) - 5) { + # me.scroll = 0; + # } + #} }, scrollDn: func() { - if (me.enableScroll) { - me.scroll -= 1; - if (me.scroll < 0) { - me.scroll = size(me.vector) - 5; - } - } + #if (me.enableScroll) { + # me.scroll -= 1; + # if (me.scroll < 0) { + # me.scroll = size(me.vector) - 5; + # } + #} }, }; diff --git a/Nasal/MCDU/F-PLN.nas b/Nasal/MCDU/F-PLN.nas index 85759445..52398beb 100644 --- a/Nasal/MCDU/F-PLN.nas +++ b/Nasal/MCDU/F-PLN.nas @@ -1,47 +1,4 @@ -# Airbus A3XX FMGC MCDU Bridge -# Copyright (c) 2019 Joshua Davidson (Octal450) and Nikolai V. Chr. (Necolatis) - -# Lowercase "g" is a degree symbol in the MCDU font. - -var TMPY = 5; -var MAIN = 6; -var debug = 0; # Set to 1 to check inner functionality -var insertReturn = nil; - -var clearFPLNComputer = func { - FPLNLines[0].clear(); - FPLNLines[1].clear(); -} - -var StaticText = { - new: func(computer, type, index = nil) { - var in = {parents:[StaticText]}; - in.type = type; - in.computer = computer; - in.index = index; - return in; - }, - getText: func() { - if (me.type == "discontinuity") { - return "---F-PLN DISCONTINUITY--"; - } else if (me.type == "fplnEnd") { - return "------END OF F-PLN------"; - } else if (me.type == "altnFplnEnd") { - return "----END OF ALTN F-PLN---"; - } else if (me.type == "noAltnFpln") { - return "------NO ALTN F-PLN-----"; - } else if (me.type == "empty") { - return ""; - } - }, - getColor: func() { - return canvas_mcdu.WHITE; - }, - getSubText: func() { - return ""; - }, - type: nil, pushButtonLeft: func() { if (me.type != "discontinuity") { notAllowed(me.computer.mcdu); @@ -163,218 +120,6 @@ var StaticText = { } } }, - pushButtonRight: func() { - notAllowed(me.computer.mcdu); - }, -}; - -var FPLNText = { - _text: nil, - new: func(computer, wp, dest, fp, wpIndex) { - var in = {parents:[FPLNText]}; - in.wp = wp; - in.dest = dest; - in.fp = fp; - in.index = wpIndex; - in.computer = computer; - return in; - }, - getText: func() { - me._text = split("-",me.wp.wp_name); - if (size(me._text) == 2) { - return me._text[0] ~ me._text[1]; - } else { - return me._text[0]; - } - }, - getColor: func(i) { - if (fmgc.flightPlanController.temporaryFlag[i]) { - if (me.dest) { - return canvas_mcdu.WHITE; - } else { - return canvas_mcdu.YELLOW; - } - } else { - if (me.dest) { - return canvas_mcdu.WHITE; - } else { - return canvas_mcdu.GREEN; - } - } - }, - getSubText: func(i) { - if (me.index == 0) { - return ""; - } else if (fmgc.flightPlanController.temporaryFlag[i]) { - if (fmgc.flightPlanController.arrivalIndex[i] == me.index) { - return "DEST"; - } else { - return "C" ~ sprintf("%03d", fmgc.wpCoursePrev[me.fp][me.index].getValue()) ~ "g"; - } - } else { - if (fmgc.flightPlanController.arrivalIndex[2] == me.index) { - return "DEST"; - } else { - return "C" ~ sprintf("%03d", fmgc.wpCoursePrev[me.fp][me.index].getValue()) ~ "g"; - } - } - }, - wp: nil, - pushButtonLeft: func() { - var scratchpad = getprop("/MCDU[" ~ me.computer.mcdu ~ "]/scratchpad"); - if (me.computer.lines == MAIN and scratchpad != "") { - fmgc.flightPlanController.createTemporaryFlightPlan(me.computer.mcdu); - } - if (scratchpad == "CLR") { - if (fmgc.flightPlanController.deleteWP(me.index, me.computer.mcdu, 0) != 0) { - notAllowed(me.computer.mcdu); - } else { - setprop("/MCDU[" ~ me.computer.mcdu ~ "]/scratchpad-msg", 0); - setprop("/MCDU[" ~ me.computer.mcdu ~ "]/scratchpad", ""); - } - } else { - if (size(scratchpad) == 5) { - var fix = findFixesByID(scratchpad); - if (size(fix) >= 1) { - var indexWp = fmgc.flightPlanController.flightplans[me.computer.mcdu].indexOfWP(fix[0]); - if (indexWp == -1) { - var insertReturn = fmgc.flightPlanController.insertFix(scratchpad, me.index, me.computer.mcdu); - fmgc.flightPlanController.flightplans[me.computer.mcdu].insertWP(createDiscontinuity(), me.index + 1); - fmgc.flightPlanController.flightPlanChanged(me.computer.mcdu); - } else { - var numTimesDelete = indexWp - me.index; - while (numTimesDelete > 0) { - fmgc.flightPlanController.deleteWP(me.index + 1, me.computer.mcdu, 0); - numTimesDelete -= 1; - } - } - if (insertReturn == 2) { - notAllowed(me.computer.mcdu); - } else if (insertReturn == 1) { - notInDataBase(me.computer.mcdu); - } else { - setprop("/MCDU[" ~ me.computer.mcdu ~ "]/scratchpad", ""); - } - } else { - notInDataBase(me.computer.mcdu); - } - } else if (size(scratchpad) == 4) { - var arpt = findAirportsByICAO(scratchpad); - if (size(arpt) >= 1) { - var indexWp = fmgc.flightPlanController.flightplans[me.computer.mcdu].indexOfWP(arpt[0]); - if (indexWp == -1) { - var insertReturn = fmgc.flightPlanController.insertArpt(scratchpad, me.index, me.computer.mcdu); - fmgc.flightPlanController.flightplans[me.computer.mcdu].insertWP(createDiscontinuity(), me.index + 1); - fmgc.flightPlanController.flightPlanChanged(me.computer.mcdu); - } else { - var numTimesDelete = indexWp - me.index; - while (numTimesDelete > 0) { - fmgc.flightPlanController.deleteWP(me.index + 1, me.computer.mcdu, 0); - numTimesDelete -= 1; - } - } - if (insertReturn == 2) { - notAllowed(me.computer.mcdu); - } else if (insertReturn == 1) { - notInDataBase(me.computer.mcdu); - } else { - setprop("/MCDU[" ~ me.computer.mcdu ~ "]/scratchpad", ""); - } - } else { - notInDataBase(me.computer.mcdu); - } - } else if (size(scratchpad) == 3 or size(scratchpad) == 2) { - var navaid = findNavaidsByID(scratchpad); - if (size(navaid) >= 1) { - var indexWp = fmgc.flightPlanController.flightplans[me.computer.mcdu].indexOfWP(navaid[0]); - if (indexWp == -1) { - var insertReturn = fmgc.flightPlanController.insertNavaid(scratchpad, me.index, me.computer.mcdu); - fmgc.flightPlanController.flightplans[me.computer.mcdu].insertWP(createDiscontinuity(), me.index + 1); - fmgc.flightPlanController.flightPlanChanged(me.computer.mcdu); - } else { - var numTimesDelete = indexWp - me.index; - while (numTimesDelete > 0) { - fmgc.flightPlanController.deleteWP(me.index + 1, me.computer.mcdu, 0); - numTimesDelete -= 1; - } - } - if (insertReturn == 2) { - notAllowed(me.computer.mcdu); - } else if (insertReturn == 1) { - notInDataBase(me.computer.mcdu); - } else { - setprop("/MCDU[" ~ me.computer.mcdu ~ "]/scratchpad", ""); - } - } else { - notInDataBase(me.computer.mcdu); - } - } else if (size(scratchpad) == 1) { - formatError(me.computer.mcdu); - } else if (scratchpad == "") { - if (!fmgc.flightPlanController.temporaryFlag[me.computer.mcdu]) { - if (me.getText() == fmgc.flightPlanController.flightplans[2].departure.id or left(me.getText(), 4) == fmgc.flightPlanController.flightplans[2].departure.id) { - if (canvas_mcdu.myLatRev[me.computer.mcdu] != nil) { - canvas_mcdu.myLatRev[me.computer.mcdu].del(); - } - canvas_mcdu.myLatRev[me.computer.mcdu] = nil; - canvas_mcdu.myLatRev[me.computer.mcdu] = latRev.new(0, me.getText(), me.index, me.computer.mcdu); - } elsif (me.index == fmgc.flightPlanController.arrivalIndex[2]) { - if (canvas_mcdu.myLatRev[me.computer.mcdu] != nil) { - canvas_mcdu.myLatRev[me.computer.mcdu].del(); - } - canvas_mcdu.myLatRev[me.computer.mcdu] = nil; - canvas_mcdu.myLatRev[me.computer.mcdu] = latRev.new(1, me.getText(), me.index, me.computer.mcdu); - } elsif (me.index == (fmgc.currentWP[2] - 1)) { - if (canvas_mcdu.myLatRev[me.computer.mcdu] != nil) { - canvas_mcdu.myLatRev[me.computer.mcdu].del(); - } - canvas_mcdu.myLatRev[me.computer.mcdu] = nil; - canvas_mcdu.myLatRev[me.computer.mcdu] = latRev.new(2, me.getText(), me.index, me.computer.mcdu); - } else { - if (canvas_mcdu.myLatRev[me.computer.mcdu] != nil) { - canvas_mcdu.myLatRev[me.computer.mcdu].del(); - } - canvas_mcdu.myLatRev[me.computer.mcdu] = nil; - canvas_mcdu.myLatRev[me.computer.mcdu] = latRev.new(3, me.getText(), me.index, me.computer.mcdu); # todo must not be available from lat lon / place - brg - dist / abeam etc - } - setprop("/MCDU[" ~ me.computer.mcdu ~ "]/page", "LATREV"); - } else { - if (me.getText() == fmgc.flightPlanController.flightplans[me.computer.mcdu].departure.id or left(me.getText(), 4) == fmgc.flightPlanController.flightplans[me.computer.mcdu].departure.id) { - if (canvas_mcdu.myLatRev[me.computer.mcdu] != nil) { - canvas_mcdu.myLatRev[me.computer.mcdu].del(); - } - canvas_mcdu.myLatRev[me.computer.mcdu] = nil; - canvas_mcdu.myLatRev[me.computer.mcdu] = latRev.new(0, me.getText(), me.index, me.computer.mcdu); - } elsif (me.index == fmgc.flightPlanController.arrivalIndex[me.computer.mcdu]) { - if (canvas_mcdu.myLatRev[me.computer.mcdu] != nil) { - canvas_mcdu.myLatRev[me.computer.mcdu].del(); - } - canvas_mcdu.myLatRev[me.computer.mcdu] = nil; - canvas_mcdu.myLatRev[me.computer.mcdu] = latRev.new(1, me.getText(), me.index, me.computer.mcdu); - } elsif (me.index == (fmgc.currentWP[2] - 1)) { # not a bug for PPOS - if (canvas_mcdu.myLatRev[me.computer.mcdu] != nil) { - canvas_mcdu.myLatRev[me.computer.mcdu].del(); - } - canvas_mcdu.myLatRev[me.computer.mcdu] = nil; - canvas_mcdu.myLatRev[me.computer.mcdu] = latRev.new(2, me.getText(), me.index, me.computer.mcdu); - } else { - if (canvas_mcdu.myLatRev[me.computer.mcdu] != nil) { - canvas_mcdu.myLatRev[me.computer.mcdu].del(); - } - canvas_mcdu.myLatRev[me.computer.mcdu] = nil; - canvas_mcdu.myLatRev[me.computer.mcdu] = latRev.new(3, me.getText(), me.index, me.computer.mcdu); # todo must not be available from lat lon / place - brg - dist / abeam etc - } - setprop("/MCDU[" ~ me.computer.mcdu ~ "]/page", "LATREV"); - } - } else { - notAllowed(me.computer.mcdu); - } - } - }, - pushButtonRight: func() { - notAllowed(me.computer.mcdu); - }, -}; var FPLNLineComputer = { new: func(mcdu) { @@ -447,125 +192,5 @@ var FPLNLineComputer = { if (debug == 1) printf("%d: scroll is %d. Size of plan is %d", me.mcdu, me.enableScroll, size(me.planList)); me.updateScroll(); }, - checkIndex: func() { - if (!me.enableScroll) { - me.index = 0; - if (debug == 1) printf("%d: index forced to 0",me.mcdu); - } elsif (me.index > size(me.planList) + 2 - me.lines) { - me.index = size(me.planList) + 2 - me.lines; - if (debug == 1) printf("%d: index forced to %d",me.mcdu,me.index); - } - }, - scrollDown: func() { # Scroll Up in Thales Manual - if (debug == 1) printf("%d: scroll down", me.mcdu); - me.extra = 1; - if (!me.enableScroll) { - me.index = 0; - } else { - me.index += 1; - if (me.index > size(me.planList) + 2 - me.lines) { - me.index = 0; - } - } - me.updateScroll(); - }, - scrollUp: func() { # Scroll Down in Thales Manual - if (debug == 1) printf("%d: scroll up", me.mcdu); - me.extra = 1; - if (!me.enableScroll) { - me.index = 0; - } else { - me.index -= 1; - if (me.index < 0) { - me.index = size(me.planList) + 2 - me.lines; - } - } - me.updateScroll(); - }, - updateScroll: func() { - me.output = []; - if (me.index <= size(me.planList) + 1) { - var i = 0; - me.realIndex = me.index - 1; - if (debug == 1) printf("%d: updating display from index %d", me.mcdu, me.realIndex); - for (i = me.index; i < math.min(size(me.planList), me.index + 5); i += 1) { - append(me.output, me.planList[i]); - me.realIndex = i; - } - if (debug == 1) printf("%d: populated until wp index %d", me.mcdu,me.realIndex); - if (me.realIndex < me.destIndex and me.lines == MAIN) { - # Destination has not been shown yet, now its time (if we show 6 lines) - append(me.output, me.destination); - if (debug == 1) printf("%d: added dest at bottom for total of %d lines", me.mcdu, size(me.output)); - return; - } else if (size(me.output) < me.lines) { - for (i = me.realIndex + 1; size(me.output) < me.lines and i < size(me.planList); i += 1) { - append(me.output, me.planList[i]); - me.realIndex = i; - } - if (debug == 1) printf("%d: populated after until wp index %d", me.mcdu,me.realIndex); - if (size(me.output) < me.lines) { - if (me.realIndex == size(me.planList)-1) { - # Show the end of plan - append(me.output, me.planEnd); - me.realIndex += 1; - if (debug == 1) printf("%d: added end, wp index=%d", me.mcdu, me.realIndex); - } - if (size(me.output) < me.lines and (me.realIndex == size(me.planList))) { - append(me.output, me.planNoAlt); - me.realIndex += 1; - if (debug == 1) printf("%d: added no-alt, wp index=%d", me.mcdu,me.realIndex); - if (me.enableScroll and size(me.output) < me.lines) { - # We start wrapping - for (var j = 0; size(me.output) < me.lines; j += 1) { - append(me.output, me.planList[j]); - } - } - } - } - } - } - while (size(me.output) < me.lines) { - append(me.output, StaticText.new(me, "empty")); - } - if (debug == 1) printf("%d: %d lines", me.mcdu, size(me.output)); - }, }; -var FPLNLines = [FPLNLineComputer.new(0), FPLNLineComputer.new(1)]; -clearFPLNComputer(); # Just in case, we have it in the clear state. - -var slewFPLN = func(d, i) { # Scrolling function. d is -1 or 1 for direction, and i is instance. - if (d == 1) { - FPLNLines[i].scrollDown(); # Scroll Up in Thales Manual - } else if (d == -1) { - FPLNLines[i].scrollUp(); # Scroll Down in Thales Manual - } -} - -# Button and Inputs -var FPLNButton = func(s, key, i) { - var scratchpad = getprop("/MCDU[" ~ i ~ "]/scratchpad"); - if (s == "L") { - if (key == 6 and fmgc.flightPlanController.temporaryFlag[i]) { - fmgc.flightPlanController.destroyTemporaryFlightPlan(i, 0); - } else { - if (size(FPLNLines[i].output) >= key) { - FPLNLines[i].output[key - 1].pushButtonLeft(); - } - } - } else if (s == "R") { - if (key == 6 and fmgc.flightPlanController.temporaryFlag[i]) { - fmgc.flightPlanController.destroyTemporaryFlightPlan(i, 1); - } else { -# if (scratchpad != "") { -# if (size(FPLNLines[i].output) >= key) { -# FPLNLines[i].output[key - 1].pushButtonRight(); -# } -# } else { - notAllowed(i); # Remove when has functionality - # FIXME: Add VERT REV Logic -# } - } - } -} diff --git a/Nasal/MCDU/MCDU.nas b/Nasal/MCDU/MCDU.nas index f1259965..ad76acc4 100644 --- a/Nasal/MCDU/MCDU.nas +++ b/Nasal/MCDU/MCDU.nas @@ -113,7 +113,7 @@ var lskbutton = func(btn, i) { canvas_mcdu.myDeparture[i] = departurePage.new(canvas_mcdu.myLatRev[i].title[2], i); setprop("/MCDU[" ~ i ~ "]/page", "DEPARTURE"); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNA" or getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNB") { - FPLNButton("L", 1, i); + canvas_mcdu.myFpln[i].pushButtonLeft(1); } else { notAllowed(i); } @@ -137,7 +137,7 @@ var lskbutton = func(btn, i) { } else if (getprop("/MCDU[" ~ i ~ "]/page") == "PRINTFUNC2") { printInput2("L2", i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNA" or getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNB") { - FPLNButton("L", 2, i); + canvas_mcdu.myFpln[i].pushButtonLeft(2); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "DEPARTURE") { canvas_mcdu.myDeparture[i].depPushbuttonLeft(2); } else { @@ -157,7 +157,7 @@ var lskbutton = func(btn, i) { } else if (getprop("/MCDU[" ~ i ~ "]/page") == "PRINTFUNC2") { printInput2("L3", i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNA" or getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNB") { - FPLNButton("L", 3, i); + canvas_mcdu.myFpln[i].pushButtonLeft(3); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "DEPARTURE") { canvas_mcdu.myDeparture[i].depPushbuttonLeft(3); } else { @@ -173,7 +173,7 @@ var lskbutton = func(btn, i) { } else if (getprop("/MCDU[" ~ i ~ "]/page") == "PRINTFUNC2") { printInput2("L4", i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNA" or getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNB") { - FPLNButton("L", 4, i); + canvas_mcdu.myFpln[i].pushButtonLeft(4); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "DEPARTURE") { canvas_mcdu.myDeparture[i].depPushbuttonLeft(4); } else { @@ -197,7 +197,7 @@ var lskbutton = func(btn, i) { } else if (getprop("/MCDU[" ~ i ~ "]/page") == "PRINTFUNC2") { printInput2("L5", i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNA" or getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNB") { - FPLNButton("L", 5, i); + canvas_mcdu.myFpln[i].pushButtonLeft(5); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "DEPARTURE") { canvas_mcdu.myDeparture[i].depPushbuttonLeft(5); } else { @@ -215,7 +215,7 @@ var lskbutton = func(btn, i) { } else if (getprop("/MCDU[" ~ i ~ "]/page") == "PRINTFUNC2") { printInput2("L6", i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNA" or getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNB") { - FPLNButton("L", 6, i); + canvas_mcdu.myFpln[i].pushButtonLeft(6); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "LATREV") { setprop("/MCDU[" ~ i ~ "]/page", "F-PLNA"); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "DEPARTURE") { @@ -329,7 +329,7 @@ var rskbutton = func(btn, i) { } else if (getprop("/MCDU[" ~ i ~ "]/page") == "INITA") { initInputA("R6", i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNA" or getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNB") { - FPLNButton("R", 6, i); + canvas_mcdu.myFpln[i].pushButtonRight(6); } else { notAllowed(i); } diff --git a/Nasal/Sim/libraries.nas b/Nasal/Sim/libraries.nas index b81a471a..f1026c16 100644 --- a/Nasal/Sim/libraries.nas +++ b/Nasal/Sim/libraries.nas @@ -205,7 +205,7 @@ var systemsInit = func { systems.eng_init(); systems.fire_init(); systems.autobrake_init(); - fmgc.flightplan.reset(); + fmgc.flightPlanController.reset(); fadec.FADEC.init(); fmgc.ITAF.init(); fmgc.FMGCinit(); @@ -227,7 +227,7 @@ var systemsInit = func { setlistener("/sim/signals/fdm-initialized", func { systemsInit(); - fmgc.outputPropsTimer.start(); + fmgc.flightPlanTimer.start(); }); var systemsLoop = maketimer(0.1, func { From ec68189ce14dbae0ace3d6b5c52ede5dfb526496 Mon Sep 17 00:00:00 2001 From: legoboyvdlp R Date: Sat, 11 Jan 2020 13:30:08 +0000 Subject: [PATCH 09/51] Many improvements --- A320-main.xml | 1 + Models/Instruments/MCDU/MCDU.nas | 316 +++++++++++++++++++++- Nasal/FMGC/flightplan.nas | 82 ++++-- Nasal/MCDU/ARRIVAL.nas | 440 +++++++++++++++++++++++++------ Nasal/MCDU/DEPARTURE.nas | 13 +- Nasal/MCDU/F-PLN-rework.nas | 95 ++++--- Nasal/MCDU/LATREV.nas | 28 ++ Nasal/MCDU/MCDU.nas | 18 +- 8 files changed, 862 insertions(+), 131 deletions(-) diff --git a/A320-main.xml b/A320-main.xml index d230156e..845aaa4f 100644 --- a/A320-main.xml +++ b/A320-main.xml @@ -1887,6 +1887,7 @@ Aircraft/A320-family/Nasal/MCDU/LATREV.nas Aircraft/A320-family/Nasal/MCDU/DEPARTURE.nas + Aircraft/A320-family/Nasal/MCDU/ARRIVAL.nas Aircraft/A320-family/Nasal/MCDU/F-PLN-rework.nas Aircraft/A320-family/Nasal/MCDU/MCDU.nas Aircraft/A320-family/Nasal/MCDU/INITA.nas diff --git a/Models/Instruments/MCDU/MCDU.nas b/Models/Instruments/MCDU/MCDU.nas index cc524757..ca5a832a 100644 --- a/Models/Instruments/MCDU/MCDU.nas +++ b/Models/Instruments/MCDU/MCDU.nas @@ -8,7 +8,9 @@ var MCDU1_display = nil; var MCDU2_display = nil; var myLatRev = [nil, nil]; var myDeparture = [nil, nil]; +var myArrival = [nil, nil]; var myFpln = [nil, nil]; +var myDuplicate = [nil, nil]; var default = "BoeingCDU-Large.ttf"; var symbol = "helvetica_medium.txf"; var normal = 70; @@ -230,7 +232,6 @@ var canvas_MCDU_base = { } if (myFpln[i] != nil) { - myFpln[i].update(); if (flightNumSet.getValue()) { me["FPLN_Callsign"].setText(flightNum.getValue()); @@ -2341,6 +2342,319 @@ var canvas_MCDU_base = { } pageSwitch[i].setBoolValue(1); } + } elsif (page == "DUPLICATENAMES") { + if (!pageSwitch[i].getBoolValue()) { + me["Simple"].show(); + me["Simple_Center"].show(); + me["FPLN"].hide(); + me["INITA"].hide(); + me["INITB"].hide(); + me["PERFTO"].hide(); + me["arrowsDepArr"].hide(); + me["Simple_PageNum"].setText("X/X"); + me["Simple_PageNum"].hide(); + me["Simple_Title"].show(); + me["ArrowLeft"].hide(); + me["ArrowRight"].hide(); + + me.fontLeft(default, default, default, default, default, default); + me.fontLeftS(default, default, default, default, default, default); + me.fontRight(default, default, default, default, default, default); + me.fontRightS(default, default, default, default, default, default); + + me.fontSizeLeft(normal, normal, normal, normal, normal, normal); + me.fontSizeRight(normal, normal, normal, normal, normal, normal); + + me.colorLeftS("wht", "wht", "wht", "wht", "wht", "wht"); + me.colorLeftArrow("wht", "wht", "wht", "wht", "wht", "wht"); + me.colorRightS("wht", "wht", "wht", "wht", "wht", "wht"); + me.colorRightArrow("wht", "wht", "wht", "wht", "wht", "wht"); + + + if (myDuplicate[i] != nil) { + me["Simple_Title"].setText(sprintf("%s", myDuplicate[i].title)); + + forindex (var matrixArrow; myDuplicate[i].arrowsMatrix) { + if (matrixArrow == 0) { + var sign = "L"; + } else { + var sign = "R"; + } + forindex (var item; myDuplicate[i].arrowsMatrix[matrixArrow]) { + if (myDuplicate[i].arrowsMatrix[matrixArrow][item] == 1) { + me["Simple_" ~ sign ~ (item + 1) ~ "_Arrow"].show(); + } else { + me["Simple_" ~ sign ~ (item + 1) ~ "_Arrow"].hide(); + } + } + } + me.colorLeftArrow(myDuplicate[i].arrowsColour[0][0],myDuplicate[i].arrowsColour[0][1],myDuplicate[i].arrowsColour[0][2],myDuplicate[i].arrowsColour[0][3],myDuplicate[i].arrowsColour[0][4],myDuplicate[i].arrowsColour[0][5]); + + + forindex (var matrixFont; myDuplicate[i].fontMatrix) { + if (matrixFont == 0) { + var sign = "L"; + } else { + var sign = "R"; + } + forindex (var item; myDuplicate[i].fontMatrix[matrixFont]) { + if (myDuplicate[i].fontMatrix[matrixFont][item] == 1) { + me["Simple_" ~ sign ~ (item + 1)].setFont(symbol); + me["Simple_" ~ sign ~ (item + 1)].setFontSize(small); + } else { + me["Simple_" ~ sign ~ (item + 1)].setFont(default); + me["Simple_" ~ sign ~ (item + 1)].setFontSize(normal); + } + } + } + + if (myDuplicate[i].L1[0] == nil) { + me["Simple_L1"].hide(); + me["Simple_L1S"].hide(); + } else { + me["Simple_L1"].show(); + me["Simple_L1"].setText(myDuplicate[i].L1[0]); + if (myDuplicate[i].L1[1] != nil) { + me["Simple_L1S"].show(); + me["Simple_L1S"].setText(myDuplicate[i].L1[1]); + } else { + me["Simple_L1S"].hide(); + } + } + + if (myDuplicate[i].L2[0] == nil) { + me["Simple_L2"].hide(); + me["Simple_L2S"].hide(); + } else { + me["Simple_L2"].show(); + me["Simple_L2"].setText(myDuplicate[i].L2[0]); + if (myDuplicate[i].L2[1] != nil) { + me["Simple_L2S"].show(); + me["Simple_L2S"].setText(myDuplicate[i].L2[1]); + } else { + me["Simple_L2S"].hide(); + } + } + + if (myDuplicate[i].L3[0] == nil) { + me["Simple_L3"].hide(); + me["Simple_L3S"].hide(); + } else { + me["Simple_L3"].show(); + me["Simple_L3"].setText(myDuplicate[i].L3[0]); + if (myDuplicate[i].L3[1] != nil) { + me["Simple_L3S"].show(); + me["Simple_L3S"].setText(myDuplicate[i].L3[1]); + } else { + me["Simple_L3S"].hide(); + } + } + + if (myDuplicate[i].L4[0] == nil) { + me["Simple_L4"].hide(); + me["Simple_L4S"].hide(); + } else { + me["Simple_L4"].show(); + me["Simple_L4"].setText(myDuplicate[i].L4[0]); + if (myDuplicate[i].L4[1] != nil) { + me["Simple_L4S"].show(); + me["Simple_L4S"].setText(myDuplicate[i].L4[1]); + } else { + me["Simple_L4S"].hide(); + } + } + + if (myDuplicate[i].L5[0] == nil) { + me["Simple_L5"].hide(); + me["Simple_L5S"].hide(); + } else { + me["Simple_L5"].show(); + me["Simple_L5"].setText(myDuplicate[i].L5[0]); + if (myDuplicate[i].L5[1] != nil) { + me["Simple_L5S"].show(); + me["Simple_L5S"].setText(myDuplicate[i].L5[1]); + } else { + me["Simple_L5S"].hide(); + } + } + + if (myDuplicate[i].L6[0] == nil) { + me["Simple_L6"].hide(); + me["Simple_L6S"].hide(); + } else { + me["Simple_L6"].show(); + me["Simple_L6"].setText(myDuplicate[i].L6[0]); + if (myDuplicate[i].L6[1] != nil) { + me["Simple_L6S"].show(); + me["Simple_L6S"].setText(myDuplicate[i].L6[1]); + } else { + me["Simple_L6S"].hide(); + } + } + me.colorLeft(myDuplicate[i].L1[2],myDuplicate[i].L2[2],myDuplicate[i].L3[2],myDuplicate[i].L4[2],myDuplicate[i].L5[2],myDuplicate[i].L6[2]); + + + if (myDuplicate[i].C1[0] == nil) { + me["Simple_C1"].hide(); + me["Simple_C1S"].hide(); + } else { + me["Simple_C1"].show(); + me["Simple_C1"].setText(myDuplicate[i].C1[0]); + if (myDuplicate[i].C1[1] != nil) { + me["Simple_C1S"].show(); + me["Simple_C1S"].setText(myDuplicate[i].C1[1]); + } else { + me["Simple_C1S"].hide(); + } + } + + if (myDuplicate[i].C2[0] == nil) { + me["Simple_C2"].hide(); + me["Simple_C2S"].hide(); + } else { + me["Simple_C2"].show(); + me["Simple_C2"].setText(myDuplicate[i].C2[0]); + if (myDuplicate[i].C2[1] != nil) { + me["Simple_C2S"].show(); + me["Simple_C2S"].setText(myDuplicate[i].C2[1]); + } else { + me["Simple_C2S"].hide(); + } + } + + if (myDuplicate[i].C3[0] == nil) { + me["Simple_C3"].hide(); + me["Simple_C3S"].hide(); + } else { + me["Simple_C3"].show(); + me["Simple_C3"].setText(myDuplicate[i].C3[0]); + if (myDuplicate[i].C3[1] != nil) { + me["Simple_C3S"].show(); + me["Simple_C3S"].setText(myDuplicate[i].C3[1]); + } else { + me["Simple_C3S"].hide(); + } + } + + if (myDuplicate[i].C4[0] == nil) { + me["Simple_C4"].hide(); + me["Simple_C4S"].hide(); + } else { + me["Simple_C4"].show(); + me["Simple_C4"].setText(myDuplicate[i].C4[0]); + if (myDuplicate[i].C4[1] != nil) { + me["Simple_C4S"].show(); + me["Simple_C4S"].setText(myDuplicate[i].C4[1]); + } else { + me["Simple_C4S"].hide(); + } + } + + if (myDuplicate[i].C5[0] == nil) { + me["Simple_C5"].hide(); + me["Simple_C5S"].hide(); + } else { + me["Simple_C5"].show(); + me["Simple_C5"].setText(myDuplicate[i].C5[0]); + if (myDuplicate[i].C5[1] != nil) { + me["Simple_C5S"].show(); + me["Simple_C5S"].setText(myDuplicate[i].C5[1]); + } else { + me["Simple_C5S"].hide(); + } + } + me.colorCenter(myDuplicate[i].C1[2],myDuplicate[i].C2[2],myDuplicate[i].C3[2],myDuplicate[i].C4[2],myDuplicate[i].C5[2],myDuplicate[i].C6[2]); + + me["Simple_C6"].hide(); + me["Simple_C6S"].hide(); + + if (myDuplicate[i].R1[0] == nil) { + me["Simple_R1"].hide(); + me["Simple_R1S"].hide(); + } else { + me["Simple_R1"].show(); + me["Simple_R1"].setText(myDuplicate[i].R1[0]); + if (myDuplicate[i].R1[1] != nil) { + me["Simple_R1S"].show(); + me["Simple_R1S"].setText(myDuplicate[i].R1[1]); + } else { + me["Simple_R1S"].hide(); + } + } + + if (myDuplicate[i].R2[0] == nil) { + me["Simple_R2"].hide(); + me["Simple_R2S"].hide(); + } else { + me["Simple_R2"].show(); + me["Simple_R2"].setText(myDuplicate[i].R2[0]); + if (myDuplicate[i].R2[1] != nil) { + me["Simple_R2S"].show(); + me["Simple_R2S"].setText(myDuplicate[i].R2[1]); + } else { + me["Simple_R2S"].hide(); + } + } + + if (myDuplicate[i].R3[0] == nil) { + me["Simple_R3"].hide(); + me["Simple_R3S"].hide(); + } else { + me["Simple_R3"].show(); + me["Simple_R3"].setText(myDuplicate[i].R3[0]); + if (myDuplicate[i].R3[1] != nil) { + me["Simple_R3S"].show(); + me["Simple_R3S"].setText(myDuplicate[i].R3[1]); + } else { + me["Simple_R3S"].hide(); + } + } + + if (myDuplicate[i].R4[0] == nil) { + me["Simple_R4"].hide(); + me["Simple_R4S"].hide(); + } else { + me["Simple_R4"].show(); + me["Simple_R4"].setText(myDuplicate[i].R4[0]); + if (myDuplicate[i].R4[1] != nil) { + me["Simple_R4S"].show(); + me["Simple_R4S"].setText(myDuplicate[i].R4[1]); + } else { + me["Simple_R4S"].hide(); + } + } + + if (myDuplicate[i].R5[0] == nil) { + me["Simple_R5"].hide(); + me["Simple_R5S"].hide(); + } else { + me["Simple_R5"].show(); + me["Simple_R5"].setText(myDuplicate[i].R5[0]); + if (myDuplicate[i].R5[1] != nil) { + me["Simple_R5S"].show(); + me["Simple_R5S"].setText(myDuplicate[i].R5[1]); + } else { + me["Simple_R5S"].hide(); + } + } + + if (myDuplicate[i].R6[0] == nil) { + me["Simple_R6"].hide(); + me["Simple_R6S"].hide(); + } else { + me["Simple_R6"].show(); + me["Simple_R6"].setText(myDuplicate[i].R6[0]); + if (myDuplicate[i].R6[1] != nil) { + me["Simple_R6S"].show(); + me["Simple_R6S"].setText(myDuplicate[i].R6[1]); + } else { + me["Simple_R6S"].hide(); + } + } + me.colorRight(myDuplicate[i].R1[2],myDuplicate[i].R2[2],myDuplicate[i].R3[2],myDuplicate[i].R4[2],myDuplicate[i].R5[2],myDuplicate[i].R6[2]); + } + pageSwitch[i].setBoolValue(1); + } } else { if (!pageSwitch[i].getBoolValue()) { me["Simple"].hide(); diff --git a/Nasal/FMGC/flightplan.nas b/Nasal/FMGC/flightplan.nas index 11d759ed..f9b466bd 100644 --- a/Nasal/FMGC/flightplan.nas +++ b/Nasal/FMGC/flightplan.nas @@ -117,10 +117,10 @@ var flightPlanController = { me.flightplans[n].insertWP(createWP(geo.aircraft_position(), "PPOS"), 0); }, - deleteWP: func(index, n) { + deleteWP: func(index, n, a = 0) { # a = 1, means adding a waypoint via deleting intermediate var wp = wpID[n][index].getValue(); if (wp != FMGCdep.getValue() and wp != FMGCarr.getValue() and me.flightplans[n].getPlanSize() > 2) { - if (me.flightplans[n].getWP(index).id != "DISCONTINUITY") { # if it is a discont, don't make a new one + 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); if (me.flightplans[n].getWP(index).id != "DISCONTINUITY") { # else, if the next one isn't a discont, add one me.addDiscontinuity(index, n); @@ -128,7 +128,8 @@ var flightPlanController = { } else { me.flightplans[n].deleteWP(index); } - me.flightPlanChanged(n); + me.updatePlans(); + canvas_nd.A3XXRouteDriver.triggerSignal("fp-removed"); return 2; } else { return 1; @@ -154,7 +155,7 @@ var flightPlanController = { } else { var numToDel = me.flightplans[plan].indexOfWP(airport[0]) - index; while (numToDel > 0) { - me.deleteWP(index + 1, plan, 0); + me.deleteWP(index + 1, plan, 1); numToDel -= 1; } return 2; @@ -167,18 +168,24 @@ var flightPlanController = { } else { var numToDel = me.flightplans[plan].indexOfWP(airport[overrideIndex]) - index; while (numToDel > 0) { - me.deleteWP(index + 1, plan, 0); + me.deleteWP(index + 1, plan, 1); numToDel -= 1; } return 2; } } } elsif (size(airport) >= 1) { - # spawn DUPLICATE NAMES + if (canvas_mcdu.myDeparture[plan] != nil) { + canvas_mcdu.myDeparture[plan].del(); + } + canvas_mcdu.myDeparture[plan] = nil; + canvas_mcdu.myDuplicate[plan] = mcdu.duplicateNamesPage.new(airport, index, 0, plan); + setprop("/MCDU[" ~ plan ~ "]/page", "DUPLICATENAMES"); + return 2; } }, - insertFix: func(text, index, plan, override = 0) { # override - means always choose [0] + insertFix: func(text, index, plan, override = 0, overrideIndex = -1) { # override - means always choose [0] if (index == 0) { return 1; } @@ -197,7 +204,7 @@ var flightPlanController = { } else { var numToDel = me.flightplans[plan].indexOfWP(fix[0]) - index; while (numToDel > 0) { - me.deleteWP(index + 1, plan, 0); + me.deleteWP(index + 1, plan, 1); numToDel -= 1; } return 2; @@ -210,18 +217,53 @@ var flightPlanController = { } else { var numToDel = me.flightplans[plan].indexOfWP(fix[overrideIndex]) - index; while (numToDel > 0) { - me.deleteWP(index + 1, plan, 0); + me.deleteWP(index + 1, plan, 1); numToDel -= 1; } return 2; } } } elsif (size(fix) >= 1) { - # spawn DUPLICATE NAMES + if (canvas_mcdu.myDeparture[plan] != nil) { + canvas_mcdu.myDeparture[plan].del(); + } + canvas_mcdu.myDeparture[plan] = nil; + canvas_mcdu.myDuplicate[plan] = mcdu.duplicateNamesPage.new(fix, index, 0, plan); + setprop("/MCDU[" ~ plan ~ "]/page", "DUPLICATENAMES"); + return 2; } }, - insertNavaid: func(text, index, plan, override = 0) { + insertLatLonFix: func(text, index, plan) { + if (index == 0) { + return 1; + } + + var lat = split("/", text)[0]; + var lon = split("/", text)[1]; + var latDecimal = mcdu.stringToDegrees(lat, "lat"); + var lonDecimal = mcdu.stringToDegrees(lon, "lon"); + + if (latDecimal > 90 or latDecimal < -90 or lonDecimal > 180 or lonDecimal < -180) { + return 1; + } + + var myWpLatLon = createWP(latDecimal, lonDecimal, "LL" ~ index); + if (me.flightplans[plan].indexOfWP(myWpLatLon) == -1) { + me.flightplans[plan].insertWP(myWpLatLon, index); + me.flightPlanChanged(plan); + return 2; + } else { + var numToDel = me.flightplans[plan].indexOfWP(myWpLatLon) - index; + while (numToDel > 0) { + me.deleteWP(index + 1, plan, 1); + numToDel -= 1; + } + return 2; + } + }, + + insertNavaid: func(text, index, plan, override = 0, overrideIndex = -1) { if (index == 0) { return 1; } @@ -240,7 +282,7 @@ var flightPlanController = { } else { var numToDel = me.flightplans[plan].indexOfWP(navaid[0]) - index; while (numToDel > 0) { - me.deleteWP(index + 1, plan, 0); + me.deleteWP(index + 1, plan, 1); numToDel -= 1; } return 2; @@ -253,14 +295,20 @@ var flightPlanController = { } else { var numToDel = me.flightplans[plan].indexOfWP(navaid[overrideIndex]) - index; while (numToDel > 0) { - me.deleteWP(index + 1, plan, 0); + me.deleteWP(index + 1, plan, 1); numToDel -= 1; } return 2; } } } elsif (size(navaid) >= 1) { - # spawn DUPLICATE NAMES + if (canvas_mcdu.myDeparture[plan] != nil) { + canvas_mcdu.myDeparture[plan].del(); + } + canvas_mcdu.myDeparture[plan] = nil; + canvas_mcdu.myDuplicate[plan] = mcdu.duplicateNamesPage.new(navaid, index, 1, plan); + setprop("/MCDU[" ~ plan ~ "]/page", "DUPLICATENAMES"); + return 2; } }, @@ -277,7 +325,9 @@ var flightPlanController = { } if (text == "CLR") { - return me.deleteWP(index, thePlan); + return me.deleteWP(index, thePlan, 0); + } elsif (size(text) == 16) { + return me.insertLatLonFix(text, index, thePlan); } elsif (size(text) == 5) { return me.insertFix(text, index, thePlan); } elsif (size(text) == 4) { @@ -301,6 +351,7 @@ var flightPlanController = { append(wpDistancePrev[n], props.globals.initNode("/FMGC/flightplan[" ~ n ~ "]/wp[" ~ counter ~ "]/distance-from-prev", 0, "DOUBLE")); } me.updatePlans(); + canvas_nd.A3XXRouteDriver.triggerSignal("fp-added"); }, updatePlans: func() { @@ -355,7 +406,6 @@ var flightPlanController = { } me.arrivalDist = me._arrivalDist; me.updateMCDUDriver(n); - canvas_nd.A3XXRouteDriver.triggerSignal("fp-added"); }, updateCurrentWaypoint: func() { diff --git a/Nasal/MCDU/ARRIVAL.nas b/Nasal/MCDU/ARRIVAL.nas index 20633324..72557b61 100644 --- a/Nasal/MCDU/ARRIVAL.nas +++ b/Nasal/MCDU/ARRIVAL.nas @@ -25,22 +25,27 @@ var arrivalPage = { arrAirport: nil, runways: nil, selectedRunway: nil, - sids: nil, + selectedVIA: nil, + selectedSTAR: nil, + selectedTransition: nil, + stars: nil, + transitions: nil, + vias: nil, computer: nil, - enableScroll: 0, - scroll: 0, - _runways: nil, - _sids: nil, + enableScrollApproach: 0, + enableScrollStars: 0, + scrollApproach: 0, + scrollStars: 0, + activePage: 0, # runways, stars, trans + hasPressNoTrans: 0, # temporary + _approaches: nil, + _stars: nil, + _transitions: nil, new: func(icao, computer) { var lr = {parents:[arrivalPage]}; lr.id = icao; lr.computer = computer; lr._setupPageWithData(); - lr.updateRunways(); - if (fmgc.flightPlanController.flightplans[2].destination_runway != nil) { - lr.selectedRunway = fmgc.flightPlanController.flightplans[2].destination_runway; - } - lr.updateActiveRunway(); return lr; }, del: func() { @@ -48,6 +53,31 @@ var arrivalPage = { }, _setupPageWithData: func() { me.title = ["ARRIVAL", " TO ", left(me.id, 4)]; + + if (!fmgc.flightPlanController.temporaryFlag[me.computer]) { + if (fmgc.flightPlanController.flightplans[2].destination_runway != nil) { + me.selectedRunway = fmgc.flightPlanController.flightplans[2].destination_runway; + } + if (fmgc.flightPlanController.flightplans[2].star != nil) { + me.selectedSTAR = fmgc.flightPlanController.flightplans[2].star; + } + } else { + if (fmgc.flightPlanController.flightplans[me.computer].destination_runway != nil) { + me.selectedRunway = fmgc.flightPlanController.flightplans[me.computer].destination_runway; + } elsif (fmgc.flightPlanController.flightplans[2].destination_runway != nil) { + me.selectedRunway = fmgc.flightPlanController.flightplans[2].destination_runway; + } + if (fmgc.flightPlanController.flightplans[me.computer].star != nil) { + me.selectedSTAR = fmgc.flightPlanController.flightplans[me.computer].star; + } elsif (fmgc.flightPlanController.flightplans[2].star != nil) { + me.selectedSTAR = fmgc.flightPlanController.flightplans[2].star; + } + } + + me.fontMatrix = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]; + me.arrowsMatrix = [[0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0]]; + me.arrowsColour = [["ack", "ack", "ack", "ack", "ack", "wht"], ["ack", "ack", "ack", "ack", "ack", "ack"]]; + if (!fmgc.flightPlanController.temporaryFlag[me.computer]) { me.L6 = [" RETURN END", nil, "wht"]; } else { @@ -55,74 +85,273 @@ var arrivalPage = { me.arrowsColour[0][5] = "yel"; } - me.C1 = ["------- ", "VIA", "wht"]; - me.R1 = ["-------", "STAR ", "wht"]; - me.R1 = ["-------", "TRANS ", "wht"]; + if (me.activePage == 0) { + me.updateApproaches(); + } else { + me.updateSTARs(); + } + + me.updateActiveRunway(); + me.updateActiveSTARs(); + me.updateActiveTransitions(); + }, + _clearPage: func() { + me.L1 = [nil, nil, "ack"]; + me.L2 = [nil, nil, "ack"]; + me.L3 = [nil, nil, "ack"]; + me.L4 = [nil, nil, "ack"]; + me.L5 = [nil, nil, "ack"]; + me.L6 = [nil, nil, "ack"]; + me.C1 = [nil, nil, "ack"]; + me.C2 = [nil, nil, "ack"]; + me.C3 = [nil, nil, "ack"]; + me.C4 = [nil, nil, "ack"]; + me.C5 = [nil, nil, "ack"]; + me.C6 = [nil, nil, "ack"]; + me.R1 = [nil, nil, "ack"]; + me.R2 = [nil, nil, "ack"]; + me.R3 = [nil, nil, "ack"]; + me.R4 = [nil, nil, "ack"]; + me.R5 = [nil, nil, "ack"]; + me.R6 = [nil, nil, "ack"]; me.fontMatrix = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]; - me.arrowsMatrix = [[0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0]]; - me.arrowsColour = [["ack", "ack", "ack", "ack", "ack", "wht"], ["ack", "ack", "ack", "ack", "ack", "ack"]]; + me.arrowsMatrix = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]; + me.arrowsColour = [["ack", "ack", "ack", "ack", "ack", "ack"], ["ack", "ack", "ack", "ack", "ack", "ack"]]; + }, + updatePage: func() { + me._clearPage(); + me._setupPageWithData(); }, updateActiveRunway: func() { if (me.selectedRunway != nil) { if (fmgc.flightPlanController.flightplans[2].destination_runway != nil) { if (fmgc.flightPlanController.flightplans[2].destination_runway.id == me.selectedRunway.id) { - me.L1 = [fmgc.flightPlanController.flightplans[2].destination_runway.id, " RWY", "grn"]; + me.L1 = [fmgc.flightPlanController.flightplans[2].destination_runway.id, " APPR", "grn"]; } elsif (fmgc.flightPlanController.flightplans[me.computer].destination_runway != nil) { - me.L1 = [fmgc.flightPlanController.flightplans[me.computer].destination_runway.id, " RWY", "yel"]; + me.L1 = [fmgc.flightPlanController.flightplans[me.computer].destination_runway.id, " APPR", "yel"]; } else { - me.L1 = ["---", " RWY", "wht"]; + me.L1 = ["---", " APPR", "wht"]; } } elsif (fmgc.flightPlanController.flightplans[me.computer].destination_runway != nil) { - me.L1 = [fmgc.flightPlanController.flightplans[me.computer].destination_runway.id, " RWY", "yel"]; + me.L1 = [fmgc.flightPlanController.flightplans[me.computer].destination_runway.id, " APPR", "yel"]; } else { - me.L1 = ["---", " RWY", "wht"]; + me.L1 = ["---", " APPR", "wht"]; } } else { - me.L1 = ["---", " RWY", "wht"]; + me.L1 = ["---", " APPR", "wht"]; } canvas_mcdu.pageSwitch[me.computer].setBoolValue(0); }, - updateRunways: func() { - me.arrAirport = findAirportsByICAO(left(me.id, 4)); - me._runways = keys(me.arrAirport[0].runways); - me.runways = sort(me._runways,func(a,b) cmp(a,b)); - - me.fourRunways = [nil, nil, nil, nil]; - - if (size(me.runways) >= 1) { - me.L2 = [" " ~ me.runways[0 + me.scroll], nil, "blu"]; - me.C2 = [math.round(me.arrAirport[0].runways[me.runways[0 + me.scroll]].length) ~ "M", nil, "blu"]; - me.R2 = ["CRS" ~ math.round(me.arrAirport[0].runways[me.runways[0 + me.scroll]].heading), nil, "blu"]; - me.arrowsMatrix[0][1] = 1; - me.arrowsColour[0][1] = "blu"; - } - if (size(me.runways) >= 2) { - me.L3 = [" " ~ me.runways[1 + me.scroll], nil, "blu"]; - me.C3 = [math.round(me.arrAirport[0].runways[me.runways[1 + me.scroll]].length) ~ "M", nil, "blu"]; - me.R3 = ["CRS" ~ math.round(me.arrAirport[0].runways[me.runways[1 + me.scroll]].heading), nil, "blu"]; - me.arrowsMatrix[0][2] = 1; - me.arrowsColour[0][2] = "blu"; - } - if (size(me.runways) >= 3) { - me.L4 = [" " ~ me.runways[2 + me.scroll], nil, "blu"]; - me.C4 = [math.round(me.arrAirport[0].runways[me.runways[2 + me.scroll]].length) ~ "M", nil, "blu"]; - me.R4 = ["CRS" ~ math.round(me.arrAirport[0].runways[me.runways[2 + me.scroll]].heading), nil, "blu"]; - me.arrowsMatrix[0][3] = 1; - me.arrowsColour[0][3] = "blu"; - } - if (size(me.runways) >= 4) { - me.L5 = [" " ~ me.runways[3 + me.scroll], nil, "blu"]; - me.C5 = [math.round(me.arrAirport[0].runways[me.runways[3 + me.scroll]].length) ~ "M", nil, "blu"]; - me.R5 = ["CRS" ~ math.round(me.arrAirport[0].runways[me.runways[3 + me.scroll]].heading), nil, "blu"]; - me.arrowsMatrix[0][4] = 1; - me.arrowsColour[0][4] = "blu"; - } - - if (size(me.runways) > 4) { - me.enableScroll = 1; + updateActiveSTARs: func() { + if (me.selectedSTAR != nil) { + if (fmgc.flightPlanController.flightplans[2].star != nil) { + if (fmgc.flightPlanController.flightplans[2].star == me.selectedSTAR) { + me.C1 = [fmgc.flightPlanController.flightplans[2].star.id, "SID", "grn"]; + } elsif (fmgc.flightPlanController.flightplans[me.computer].star != nil) { + me.C1 = [fmgc.flightPlanController.flightplans[me.computer].star.id, "SID", "yel"]; + } else { + me.C1 = ["------- ", "SID", "wht"]; + } + } elsif (fmgc.flightPlanController.flightplans[me.computer].star.id != nil) { + me.C1 = [fmgc.flightPlanController.flightplans[me.computer].star.id, "SID", "yel"]; + } else { + me.C1 = ["------- ", "SID", "wht"]; + } + } else { + me.C1 = ["------- ", "SID", "wht"]; } canvas_mcdu.pageSwitch[me.computer].setBoolValue(0); }, + updateActiveTransitions: func() { + if (!me.hasPressNoTrans) { + if (me.selectedTransition != nil) { + if (fmgc.flightPlanController.flightplans[2].star_trans != nil) { + if (fmgc.flightPlanController.flightplans[2].star_trans == me.selectedTransition) { + me.R1 = [fmgc.flightPlanController.flightplans[2].star_trans.id, "TRANS", "grn"]; + } elsif (fmgc.flightPlanController.flightplans[me.computer].star_trans != nil) { + me.R1 = [fmgc.flightPlanController.flightplans[me.computer].star_trans.id, "TRANS", "yel"]; + } else { + me.R1 = ["-------", "TRANS ", "wht"]; + } + } elsif (fmgc.flightPlanController.flightplans[me.computer].star_trans != nil) { + me.C1 = [fmgc.flightPlanController.flightplans[me.computer].star_trans.id, "SID", "yel"]; + } else { + me.R1 = ["-------", "TRANS ", "wht"]; + } + } else { + me.R1 = ["-------", "TRANS ", "wht"]; + } + } else { + me.R1 = ["NONE", "TRANS ", "yel"]; + } + canvas_mcdu.pageSwitch[me.computer].setBoolValue(0); + }, + updateApproaches: func() { + if (me.arrAirport == nil) { + me.arrAirport = findAirportsByICAO(left(me.id, 4)); + } + me._approaches = keys(me.arrAirport[0].getApproachList()); + me.approaches = sort(me._approaches,func(a,b) cmp(a,b)); + + if (size(me.approaches) >= 1) { + me.L3 = [" " ~ me.approaches[0 + me.scrollApproach], " APPR", "blu"]; + me.C3 = [math.round(me.arrAirport[0].runways[me.approaches[0 + me.scrollApproach]].runways[0].length) ~ "M", "AVAILABLE ", "blu"]; + me.R3 = ["CRS" ~ math.round(me.arrAirport[0].runways[me.approaches[0 + me.scrollApproach]].runways[0].heading), nil, "blu"]; + if (me.approaches[0 + me.scrollApproach] != me.selectedRunway) { + me.arrowsMatrix[0][1] = 1; + me.arrowsColour[0][1] = "blu"; + } else { + me.arrowsMatrix[0][1] = 0; + me.arrowsColour[0][1] = "ack"; + } + } + if (size(me.approaches) >= 2) { + me.L4 = [" " ~ me.approaches[1 + me.scrollApproach], nil, "blu"]; + me.C4 = [math.round(me.arrAirport[0].runways[me.approaches[1 + me.scrollApproach]].runways[1].length) ~ "M", sprintf("%7.2f", me.arrAirport[0].runways[0 + me.scrollApproach].ils_frequency_mhz), "blu"]; + me.R4 = ["CRS" ~ math.round(me.arrAirport[0].runways[me.approaches[1 + me.scrollApproach]].runways[1].heading), nil, "blu"]; + if (me.approaches[1 + me.scrollApproach] != me.selectedRunway) { + me.arrowsMatrix[0][2] = 1; + me.arrowsColour[0][2] = "blu"; + } else { + me.arrowsMatrix[0][2] = 0; + me.arrowsColour[0][2] = "ack"; + } + } + if (size(me.approaches) >= 3) { + me.L5 = [" " ~ me.approaches[2 + me.scrollApproach], nil, "blu"]; + me.C5 = [math.round(me.arrAirport[0].runways[me.approaches[2 + me.scrollApproach]].runways[2].length) ~ "M", sprintf("%7.2f", me.arrAirport[0].runways[1 + me.scrollApproach].ils_frequency_mhz), "blu"]; + me.R5 = ["CRS" ~ math.round(me.arrAirport[0].runways[me.approaches[2 + me.scrollApproach]].runways[2].heading), nil, "blu"]; + me.C6[1] = sprintf("%7.2f", me.arrAirport[0].runways[2 + me.scrollApproach].ils_frequency_mhz); + if (me.approaches[2 + me.scrollApproach] != me.selectedRunway) { + me.arrowsMatrix[0][2] = 1; + me.arrowsColour[0][2] = "blu"; + } else { + me.arrowsMatrix[0][2] = 0; + me.arrowsColour[0][2] = "ack"; + } + } + + if (size(me.approaches) > 3) { + me.enableScrollApproach = 1; + } + canvas_mcdu.pageSwitch[me.computer].setBoolValue(0); + }, + updateSTARs: func() { + if (me.arrAirport == nil) { + me.arrAirport = findAirportsByICAO(left(me.id, 4)); + } + if (me.selectedRunway != nil) { + me._stars = me.arrAirport[0].stars(me.selectedRunway.id); + } else { + me._stars = me.arrAirport[0].stars(); + } + + me.stars = sort(me._stars,func(a,b) cmp(a,b)); + + if (size(me.stars) >= 1) { + me.L2 = [" " ~ me.stars[0 + me.scrollStars], "STARS", "blu"]; + if (me.stars[0 + me.scrollStars] != me.selectedSTAR) { + me.arrowsMatrix[0][1] = 1; + me.arrowsColour[0][1] = "blu"; + } else { + me.arrowsMatrix[0][1] = 0; + me.arrowsColour[0][1] = "ack"; + } + } + if (size(me.stars) >= 2) { + me.L3 = [" " ~ me.stars[1 + me.scrollStars], nil, "blu"]; + if (me.stars[1 + me.scrollStars] != me.selectedSTAR) { + me.arrowsMatrix[0][2] = 1; + me.arrowsColour[0][2] = "blu"; + } else { + me.arrowsMatrix[0][2] = 0; + me.arrowsColour[0][2] = "ack"; + } + } + if (size(me.stars) >= 3) { + me.L4 = [" " ~ me.stars[2 + me.scrollStars], nil, "blu"]; + if (me.stars[2 + me.scrollStars] != me.selectedSTAR) { + me.arrowsMatrix[0][3] = 1; + me.arrowsColour[0][3] = "blu"; + } else { + me.arrowsMatrix[0][3] = 0; + me.arrowsColour[0][3] = "ack"; + } + } + if (size(me.stars) >= 4) { + me.L5 = [" " ~ me.stars[3 + me.scrollStars], nil, "blu"]; + if (me.stars[3 + me.scrollStars] != me.selectedSTAR) { + me.arrowsMatrix[0][4] = 1; + me.arrowsColour[0][4] = "blu"; + } else { + me.arrowsMatrix[0][4] = 0; + me.arrowsColour[0][4] = "ack"; + } + } + + me.C2 = [nil, "AVAILABLE", "wht"]; + me.R2 = [nil, "TRANS ", "wht"]; + + if (size(me.stars) > 4) { + me.enableScrollStars = 1; + } + canvas_mcdu.pageSwitch[me.computer].setBoolValue(0); + }, + updateTransitions: func() { + if (me.arrAirport == nil) { + me.arrAirport = findAirportsByICAO(left(me.id, 4)); + } + + me._transitions = me.arrAirport[0].getStar(me.selectedSTAR).transitions; + me.transitions = sort(me._transitions,func(a,b) cmp(a,b)); + + if (size(me.transitions) == 0) { + me.R2 = ["NO TRANS ", "TRANS", "blu"]; + if (!me.hasPressNoTrans) { + me.arrowsMatrix[1][1] = 1; + me.arrowsColour[1][1] = "blu"; + } else { + me.arrowsMatrix[1][1] = 0; + me.arrowsColour[1][1] = "ack"; + } + } elsif (size(me.transitions) >= 1) { + me.R2 = [me.transitions[0] ~ " ", "TRANS", "blu"]; + if (me.transitions[0] != me.selectedTransition) { + me.arrowsMatrix[1][1] = 1; + me.arrowsColour[1][1] = "blu"; + } else { + me.arrowsMatrix[1][1] = 0; + me.arrowsColour[1][1] = "ack"; + } + } elsif (size(me.transitions) >= 2) { + me.R3 = [me.transitions[1] ~ " ", nil, "blu"]; + if (me.transitions[1] != me.selectedTransition) { + me.arrowsMatrix[1][2] = 1; + me.arrowsColour[1][2] = "blu"; + } else { + me.arrowsMatrix[1][2] = 0; + me.arrowsColour[1][2] = "ack"; + } + } elsif (size(me.transitions) >= 3) { + me.R4 = [me.transitions[2] ~ " ", nil, "blu"]; + if (me.transitions[2] != me.selectedTransition) { + me.arrowsMatrix[1][3] = 1; + me.arrowsColour[1][3] = "blu"; + } else { + me.arrowsMatrix[1][3] = 0; + me.arrowsColour[1][3] = "ack"; + } + } elsif (size(me.transitions) >= 4) { + me.R5 = [me.transitions[3] ~ " ", nil, "blu"]; + if (me.transitions[3] != me.selectedTransition) { + me.arrowsMatrix[1][4] = 1; + me.arrowsColour[1][4] = "blu"; + } else { + me.arrowsMatrix[1][4] = 0; + me.arrowsColour[1][4] = "ack"; + } + } + }, makeTmpy: func() { if (!fmgc.flightPlanController.temporaryFlag[me.computer]) { fmgc.flightPlanController.createTemporaryFlightPlan(me.computer); @@ -132,30 +361,93 @@ var arrivalPage = { } }, scrollUp: func() { - if (me.enableScroll) { - me.scroll += 1; - if (me.scroll > size(me.runways) - 4) { - me.scroll = 0; + if (me.activePage == 0) { + if (me.enableScrollApproach) { + me.scrollApproach += 1; + if (me.scrollApproach > size(me.approaches) - 4) { + me.scrollApproach = 0; + } + me.updateApproaches(); + } + } else { + if (me.enableScrollStars) { + me.scrollStars += 1; + if (me.scrollStars > size(me.stars) - 4) { + me.scrollStars = 0; + } + me.updateSTARs(); } - me.updateRunways(); } }, scrollDn: func() { - if (me.enableScroll) { - me.scroll -= 1; - if (me.scroll < 0) { - me.scroll = size(me.runways) - 4; + if (me.activePage == 0) { + if (me.enableScrollApproach) { + me.scrollApproach -= 1; + if (me.scrollApproach < 0) { + me.scrollApproach = size(me.approaches) - 4; + } + me.updateApproaches(); + } + } else { + if (me.enableScrollStars) { + me.scrollStars -= 1; + if (me.scrollStars < 0) { + me.scrollStars = size(me.stars) - 4; + } + me.updateSTARs(); + me.hasPressNoTrans = 0; } - me.updateRunways(); } }, + scrollLeft: func() { + me.activePage = !me.activePage; + me.updatePage(); + }, + scrollRight: func() { + me.activePage = !me.activePage; + me.updatePage(); + }, depPushbuttonLeft: func(index) { - if (size(me.runways) >= (index - 1)) { - me.selectedRunway = me.arrAirport[0].runway(me.runways[index - 2 + me.scroll]); + if (me.activePage == 0) { + if (size(me.approaches) >= (index - 1)) { + me.selectedRunway = me.arrAirport[0].runway(me.approaches[index - 2 + me.scrollApproach]); + me.makeTmpy(); + fmgc.flightPlanController.flightplans[me.computer].destination_runway = me.selectedRunway; + me.updateActiveRunway(); + me.updateApproaches(); + fmgc.flightPlanController.flightPlanChanged(me.computer); + me.scrollRight(); + } else { + notAllowed(me.computer); + } + } else { + if (size(me.stars) >= (index - 1)) { + me.selectedSTAR = me.stars[index - 2 + me.scrollStars]; + me.makeTmpy(); + fmgc.flightPlanController.flightplans[me.computer].star = me.selectedSTAR; + me.updateActiveSTARs(); + me.updateSTARs(); + me.hasPressNoTrans = 0; + me.updateTransitions(); + me.updateActiveTransitions(); + fmgc.flightPlanController.flightPlanChanged(me.computer); + } else { + notAllowed(me.computer); + } + } + }, + depPushbuttonRight: func(index) { + if (index == 2 and size(me.transitions) == 0) { + me.hasPressNoTrans = 1; + me.updateActiveTransitions(); + me.updateTransitions(); + } elsif (size(me.transitions) >= (index - 1)) { + me.selectedTransition = me.transitions[index - 2]; me.makeTmpy(); - fmgc.flightPlanController.flightplans[me.computer].destination_runway = me.selectedRunway; - me.updateActiveRunway(); - fmgc.flightPlanController.checkWPOutputs(me.computer); + fmgc.flightPlanController.flightplans[me.computer].star_trans = me.selectedTransition; + me.updateActiveTransitions(); + me.updateTransitions(); + fmgc.flightPlanController.flightPlanChanged(me.computer); } else { notAllowed(me.computer); } diff --git a/Nasal/MCDU/DEPARTURE.nas b/Nasal/MCDU/DEPARTURE.nas index 71da8d93..de002fb2 100644 --- a/Nasal/MCDU/DEPARTURE.nas +++ b/Nasal/MCDU/DEPARTURE.nas @@ -51,12 +51,6 @@ var departurePage = { }, _setupPageWithData: func() { me.title = ["DEPARTURE", " FROM ", left(me.id, 4)]; - if (!fmgc.flightPlanController.temporaryFlag[me.computer]) { - me.L6 = [" RETURN END", nil, "wht"]; - } else { - me.L6 = [" F-PLN", " TMPY", "yel"]; - me.arrowsColour[0][5] = "yel"; - } if (!fmgc.flightPlanController.temporaryFlag[me.computer]) { if (fmgc.flightPlanController.flightplans[2].departure_runway != nil) { @@ -82,6 +76,13 @@ var departurePage = { me.arrowsMatrix = [[0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0]]; me.arrowsColour = [["ack", "ack", "ack", "ack", "ack", "wht"], ["ack", "ack", "ack", "ack", "ack", "ack"]]; + if (!fmgc.flightPlanController.temporaryFlag[me.computer]) { + me.L6 = [" RETURN END", nil, "wht"]; + } else { + me.L6 = [" F-PLN", " TMPY", "yel"]; + me.arrowsColour[0][5] = "yel"; + } + if (me.activePage == 0) { me.updateRunways(); } else { diff --git a/Nasal/MCDU/F-PLN-rework.nas b/Nasal/MCDU/F-PLN-rework.nas index 3e64ab34..5ac6dd20 100644 --- a/Nasal/MCDU/F-PLN-rework.nas +++ b/Nasal/MCDU/F-PLN-rework.nas @@ -12,10 +12,14 @@ var fplnItem = { if (me.wp != nil) { if (me.wp.wp_name != "DISCONTINUITY") { var wptName = split("-", me.wp.wp_name); - if (size(wptName) == 2) { - return[wptName[0] ~ wptName[1], nil, me.colour]; + if (wptName[0] == "VECTORS") { + return ["MANUAL", nil, me.colour]; } else { - return [me.wp.wp_name, nil, me.colour]; + if (size(wptName) == 2) { + return[wptName[0] ~ wptName[1], nil, me.colour]; + } else { + return [me.wp.wp_name, nil, me.colour]; + } } } else { return [nil, nil, "ack"]; @@ -210,7 +214,7 @@ var fplnPage = { # this one is only created once, and then updated - remember th } append(me.planList, staticText.new(me.computer, me.getText("fplnEnd"))); append(me.planList, staticText.new(me.computer, me.getText("noAltnFpln"))); - me.update(); + me.basePage(); }, basePage: func() { me.outputList = []; @@ -272,7 +276,7 @@ var fplnPage = { # this one is only created once, and then updated - remember th me.R6 = ["--.-", "EFOB", "wht"]; }, update: func() { - me.basePage(); + #me.basePage(); }, scrollUp: func() { if (size(me.planList) > 5) { @@ -378,13 +382,15 @@ var duplicateNamesPage = { computer: nil, enableScroll: 0, scroll: 0, - distances: [], - new: func(vector, type, computer) { + distances: nil, + new: func(vector, index, type, computer) { var fp = {parents:[duplicateNamesPage]}; - fp.id = vector; + fp.vector = vector; + fp.index = index; fp.type = type; # 0 = other, 1 = navaid fp.computer = computer; fp._setupPageWithData(); + fp.distances = []; return fp; }, del: func() { @@ -396,8 +402,9 @@ var duplicateNamesPage = { me.arrowsColour = [["ack", "ack", "ack", "ack", "ack", "wht"], ["ack", "ack", "ack", "ack", "ack", "ack"]]; me.fontMatrix = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]; - for (var i = 0; i <= size(me.vector); i += 1) { - append(distances, courseAndDistance(me.vector[i])); + me.distances = []; + for (var i = 0; i < size(me.vector); i += 1) { + append(me.distances, math.round(courseAndDistance(me.vector[i])[1])); } me.C1[1] = "LAT/LONG"; @@ -407,8 +414,10 @@ var duplicateNamesPage = { me.arrowsMatrix[0][0] = 1; me.arrowsColour[0][0] = "blu"; me.C1 = [" " ~ decimalToShortString(me.vector[0 + me.scroll].lat, "lat") ~ "/" ~ decimalToShortString(me.vector[0 + me.scroll].lon, "lon"), "LAT/LONG", "grn"]; - if (me.vector[0 + me.scroll].frequency != nil) { - me.R1 = [me.vector[0 + me.scroll].frequency, "FREQ", "grn"]; + if (me.type == 1) { + if (me.vector[0 + me.scroll].frequency != nil) { + me.R1 = [sprintf("%7.2f", me.vector[0 + me.scroll].frequency / 100), "FREQ", "grn"]; + } } } if (size(me.vector) >= 2) { @@ -416,8 +425,10 @@ var duplicateNamesPage = { me.arrowsMatrix[0][1] = 1; me.arrowsColour[0][1] = "blu"; me.C2 = [" " ~ decimalToShortString(me.vector[1 + me.scroll].lat, "lat") ~ "/" ~ decimalToShortString(me.vector[1 + me.scroll].lon, "lon"), "LAT/LONG", "grn"]; - if (me.vector[1 + me.scroll].frequency != nil) { - me.R2 = [me.vector[1 + me.scroll].frequency, nil, "grn"]; + if (me.type == 1) { + if (me.vector[1 + me.scroll].frequency != nil) { + me.R2 = [sprintf("%7.2f", me.vector[1 + me.scroll].frequency / 100), "FREQ", "grn"]; + } } } if (size(me.vector) >= 3) { @@ -425,8 +436,10 @@ var duplicateNamesPage = { me.arrowsMatrix[0][2] = 1; me.arrowsColour[0][2] = "blu"; me.C3 = [" " ~ decimalToShortString(me.vector[2 + me.scroll].lat, "lat") ~ "/" ~ decimalToShortString(me.vector[2 + me.scroll].lon, "lon"), "LAT/LONG", "grn"]; - if (me.vector[2 + me.scroll].frequency != nil) { - me.R3 = [me.vector[2 + me.scroll].frequency, nil, "grn"]; + if (me.type == 1) { + if (me.vector[2 + me.scroll].frequency != nil) { + me.R3 = [sprintf("%7.2f", me.vector[2 + me.scroll].frequency / 100), "FREQ", "grn"]; + } } } if (size(me.vector) >= 4) { @@ -434,8 +447,10 @@ var duplicateNamesPage = { me.arrowsMatrix[0][3] = 1; me.arrowsColour[0][3] = "blu"; me.C4 = [" " ~ decimalToShortString(me.vector[3 + me.scroll].lat, "lat") ~ "/" ~ decimalToShortString(me.vector[3 + me.scroll].lon, "lon"), "LAT/LONG", "grn"]; - if (me.vector[3 + me.scroll].frequency != nil) { - me.R4 = [me.vector[3 + me.scroll].frequency, nil, "grn"]; + if (me.type == 1) { + if (me.vector[3 + me.scroll].frequency != nil) { + me.R4 = [sprintf("%7.2f", me.vector[3 + me.scroll].frequency / 100), "FREQ", "grn"]; + } } } if (size(me.vector) >= 5) { @@ -443,8 +458,10 @@ var duplicateNamesPage = { me.arrowsMatrix[0][4] = 1; me.arrowsColour[0][4] = "blu"; me.C5 = [" " ~ decimalToShortString(me.vector[4 + me.scroll].lat, "lat") ~ "/" ~ decimalToShortString(me.vector[4 + me.scroll].lon, "lon"), "LAT/LONG", "grn"]; - if (me.vector[4 + me.scroll].frequency != nil) { - me.R5 = [me.vector[4 + me.scroll].frequency, nil, "grn"]; + if (me.type == 1) { + if (me.vector[4 + me.scroll].frequency != nil) { + me.R5 = [sprintf("%7.2f", me.vector[4 + me.scroll].frequency / 100), "FREQ", "grn"]; + } } } if (size(me.vector) > 5) { me.enableScroll = 1; } @@ -452,25 +469,37 @@ var duplicateNamesPage = { me.L6 = [" RETURN", nil, "wht"]; }, scrollUp: func() { - #if (me.enableScroll) { - # me.scroll += 1; - # if (me.scroll > size(me.vector) - 5) { - # me.scroll = 0; - # } - #} + if (me.enableScroll) { + me.scroll += 1; + if (me.scroll > size(me.vector) - 5) { + me.scroll = 0; + } + } }, scrollDn: func() { - #if (me.enableScroll) { - # me.scroll -= 1; - # if (me.scroll < 0) { - # me.scroll = size(me.vector) - 5; - # } - #} + if (me.enableScroll) { + me.scroll -= 1; + if (me.scroll < 0) { + me.scroll = size(me.vector) - 5; + } + } + }, + pushButtonLeft: func(indexSelect) { + if (size(me.vector[0].id) == 5) { + fmgc.flightPlanController.insertFix(me.vector[0].id, me.index, me.computer, 1, indexSelect - 1); + setprop("/MCDU[" ~ me.computer ~ "]/page", "F-PLNA"); + } elsif (size(me.vector[0].id) == 4) { + fmgc.flightPlanController.insertAirport(me.vector[0].id, me.index, me.computer, 1, indexSelect - 1); + setprop("/MCDU[" ~ me.computer ~ "]/page", "F-PLNA"); + } elsif (size(me.vector[0].id) == 3 or size(me.vector[0].id)== 2) { + fmgc.flightPlanController.insertNavaid(me.vector[0].id, me.index, me.computer, 1, indexSelect - 1); + setprop("/MCDU[" ~ me.computer ~ "]/page", "F-PLNA"); + } }, }; var decimalToShortString = func(dms, type) { - var degrees = split(".", dms)[0]; + var degrees = split(".", sprintf(dms))[0]; if (type == "lat") { var sign = degrees >= 0 ? "N" : "S"; } else { diff --git a/Nasal/MCDU/LATREV.nas b/Nasal/MCDU/LATREV.nas index 3d828ce4..168e446c 100644 --- a/Nasal/MCDU/LATREV.nas +++ b/Nasal/MCDU/LATREV.nas @@ -213,4 +213,32 @@ var dmsToString = func(dms, type) { var sign = degrees >= 0 ? "E" : "W"; } return abs(degrees) ~ "g" ~ minutes ~ " " ~ sign; +} + + +var stringToDegrees = func(string, type) { + if (type == "lat") { + var degrees = left(string, 2); + var minutesStr = right(string, 5); + } else { + var degrees = left(string, 3); + var minutesStr = right(string, 5); + } + + var minutes = left(minutesStr, 4); + var sign = right(minutesStr, 1); + var decimal = degrees + (minutes / 60); + if (type == "lat") { + if (sign == "N") { + return decimal; + } else { + return -decimal; + } + } else { + if (sign == "E") { + return decimal; + } else { + return -decimal; + } + } } \ No newline at end of file diff --git a/Nasal/MCDU/MCDU.nas b/Nasal/MCDU/MCDU.nas index ad76acc4..4d7ba91e 100644 --- a/Nasal/MCDU/MCDU.nas +++ b/Nasal/MCDU/MCDU.nas @@ -114,6 +114,8 @@ var lskbutton = func(btn, i) { setprop("/MCDU[" ~ i ~ "]/page", "DEPARTURE"); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNA" or getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNB") { canvas_mcdu.myFpln[i].pushButtonLeft(1); + } else if (getprop("/MCDU[" ~ i ~ "]/page") == "DUPLICATENAMES") { + canvas_mcdu.myDuplicate[i].pushButtonLeft(1); } else { notAllowed(i); } @@ -140,6 +142,8 @@ var lskbutton = func(btn, i) { canvas_mcdu.myFpln[i].pushButtonLeft(2); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "DEPARTURE") { canvas_mcdu.myDeparture[i].depPushbuttonLeft(2); + } else if (getprop("/MCDU[" ~ i ~ "]/page") == "DUPLICATENAMES") { + canvas_mcdu.myDuplicate[i].pushButtonLeft(2); } else { notAllowed(i); } @@ -160,6 +164,8 @@ var lskbutton = func(btn, i) { canvas_mcdu.myFpln[i].pushButtonLeft(3); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "DEPARTURE") { canvas_mcdu.myDeparture[i].depPushbuttonLeft(3); + } else if (getprop("/MCDU[" ~ i ~ "]/page") == "DUPLICATENAMES") { + canvas_mcdu.myDuplicate[i].pushButtonLeft(3); } else { notAllowed(i); } @@ -176,6 +182,8 @@ var lskbutton = func(btn, i) { canvas_mcdu.myFpln[i].pushButtonLeft(4); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "DEPARTURE") { canvas_mcdu.myDeparture[i].depPushbuttonLeft(4); + } else if (getprop("/MCDU[" ~ i ~ "]/page") == "DUPLICATENAMES") { + canvas_mcdu.myDuplicate[i].pushButtonLeft(4); } else { notAllowed(i); } @@ -200,6 +208,8 @@ var lskbutton = func(btn, i) { canvas_mcdu.myFpln[i].pushButtonLeft(5); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "DEPARTURE") { canvas_mcdu.myDeparture[i].depPushbuttonLeft(5); + } else if (getprop("/MCDU[" ~ i ~ "]/page") == "DUPLICATENAMES") { + canvas_mcdu.myDuplicate[i].pushButtonLeft(5); } else { notAllowed(i); } @@ -216,7 +226,7 @@ var lskbutton = func(btn, i) { printInput2("L6", i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNA" or getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNB") { canvas_mcdu.myFpln[i].pushButtonLeft(6); - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "LATREV") { + } else if (getprop("/MCDU[" ~ i ~ "]/page") == "LATREV" or getprop("/MCDU[" ~ i ~ "]/page") == "DUPLICATENAMES") { setprop("/MCDU[" ~ i ~ "]/page", "F-PLNA"); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "DEPARTURE") { if (fmgc.flightPlanController.temporaryFlag[i]) { @@ -246,6 +256,12 @@ var rskbutton = func(btn, i) { printInput("R1", i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "PRINTFUNC2") { printInput2("R1", i); + } else if (getprop("/MCDU[" ~ i ~ "/page") == "LATREV") { + if (canvas_mcdu.myArrival[i] != nil) { + canvas_mcdu.myArrival[i].del(); + } + canvas_mcdu.myArrival[i] = nil; + canvas_mcdu.myArrival[i] = arrivalPage.new(canvas_mcdu.myLatRev[i].title[2], i); } else { notAllowed(i); } From f57fe670fe9f188f00263a539124e70bf76751f1 Mon Sep 17 00:00:00 2001 From: legoboyvdlp R Date: Sat, 11 Jan 2020 14:48:18 +0000 Subject: [PATCH 10/51] Fix left pushbuttons --- Nasal/MCDU/ARRIVAL.nas | 6 +++--- Nasal/MCDU/F-PLN-rework.nas | 3 +-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/Nasal/MCDU/ARRIVAL.nas b/Nasal/MCDU/ARRIVAL.nas index 72557b61..04af05d1 100644 --- a/Nasal/MCDU/ARRIVAL.nas +++ b/Nasal/MCDU/ARRIVAL.nas @@ -91,9 +91,9 @@ var arrivalPage = { me.updateSTARs(); } - me.updateActiveRunway(); - me.updateActiveSTARs(); - me.updateActiveTransitions(); + #me.updateActiveRunway(); + #me.updateActiveSTARs(); + #me.updateActiveTransitions(); }, _clearPage: func() { me.L1 = [nil, nil, "ack"]; diff --git a/Nasal/MCDU/F-PLN-rework.nas b/Nasal/MCDU/F-PLN-rework.nas index 5ac6dd20..63c50adc 100644 --- a/Nasal/MCDU/F-PLN-rework.nas +++ b/Nasal/MCDU/F-PLN-rework.nas @@ -220,7 +220,6 @@ var fplnPage = { # this one is only created once, and then updated - remember th me.outputList = []; for (var i = 0; i + me.scroll < size(me.planList); i += 1) { append(me.outputList, me.planList[i + me.scroll] ); - if (size(me.outputList) == 5) { break; } } if (size(me.outputList) >= 1) { me.L1 = me.outputList[0].updateLeftText(); @@ -322,7 +321,7 @@ var fplnPage = { # this one is only created once, and then updated - remember th setprop("/MCDU[" ~ me.computer ~ "]/scratchpad", ""); } } else { - me.outputList[index - 1 + me.scroll].pushButtonLeft(); + me.outputList[index - 1].pushButtonLeft(); } } else { notAllowed(me.computer); From 828d2b389353e3334fef731996f530eb671545c5 Mon Sep 17 00:00:00 2001 From: legoboyvdlp R Date: Thu, 16 Jan 2020 17:08:14 +0000 Subject: [PATCH 11/51] Improvements, add ARRIVAL --- Models/Instruments/MCDU/MCDU.nas | 325 +++++++++++++++++++++++++++++++ Nasal/FMGC/flightplan.nas | 1 + Nasal/MCDU/ARRIVAL.nas | 116 ++++++----- Nasal/MCDU/DEPARTURE.nas | 5 +- Nasal/MCDU/F-PLN-rework.nas | 9 +- Nasal/MCDU/MCDU.nas | 35 +++- 6 files changed, 435 insertions(+), 56 deletions(-) diff --git a/Models/Instruments/MCDU/MCDU.nas b/Models/Instruments/MCDU/MCDU.nas index ca5a832a..11c4ef12 100644 --- a/Models/Instruments/MCDU/MCDU.nas +++ b/Models/Instruments/MCDU/MCDU.nas @@ -2655,6 +2655,331 @@ var canvas_MCDU_base = { } pageSwitch[i].setBoolValue(1); } + } elsif (page == "ARRIVAL") { + if (!pageSwitch[i].getBoolValue()) { + me["Simple"].show(); + me["Simple_Center"].show(); + me["FPLN"].hide(); + me["INITA"].hide(); + me["INITB"].hide(); + me["PERFTO"].hide(); + me["Simple_PageNum"].setText("X/X"); + me["Simple_PageNum"].hide(); + me["Simple_Title"].show(); + me["ArrowLeft"].show(); + me["ArrowRight"].show(); + me["arrowsDepArr"].show(); + me["Simple_L1_Arrow"].hide(); + me["Simple_L2_Arrow"].hide(); + me["Simple_L3_Arrow"].hide(); + me["Simple_L4_Arrow"].hide(); + me["Simple_L5_Arrow"].hide(); + me["Simple_L6_Arrow"].show(); + me["Simple_R1_Arrow"].hide(); + me["Simple_R2_Arrow"].hide(); + me["Simple_R3_Arrow"].hide(); + me["Simple_R4_Arrow"].hide(); + me["Simple_R5_Arrow"].hide(); + me["Simple_R6_Arrow"].hide(); + + me.fontLeft(default, default, default, default, default, default); + me.fontLeftS(default, default, default, default, default, default); + me.fontRight(default, default, default, default, default, default); + me.fontRightS(default, default, default, default, default, default); + + me.fontSizeLeft(normal, normal, normal, normal, normal, normal); + me.fontSizeRight(normal, normal, normal, normal, normal, normal); + + me.colorLeftS("wht", "wht", "wht", "wht", "wht", "wht"); + me.colorRightS("wht", "wht", "wht", "wht", "wht", "wht"); + + + if (myArrival[i] != nil) { + me["Simple_Title"].setText(sprintf("%s", myArrival[i].title[0] ~ myArrival[i].title[1] ~ myArrival[i].title[2])); + + forindex (var matrixArrow; myArrival[i].arrowsMatrix) { + if (matrixArrow == 0) { + var sign = "L"; + } else { + var sign = "R"; + } + forindex (var item; myArrival[i].arrowsMatrix[matrixArrow]) { + if (item == 5) { + me["Simple_L6_Arrow"].setColor(getprop("/MCDUC/colors/" ~ myArrival[i].arrowsColour[0][5] ~ "/r"), getprop("/MCDUC/colors/" ~ myArrival[i].arrowsColour[0][5] ~ "/g"), getprop("/MCDUC/colors/" ~ myArrival[i].arrowsColour[0][5] ~ "/b")); + continue; + } + if (myArrival[i].arrowsMatrix[matrixArrow][item] == 1) { + me["arrow" ~ (item + 1) ~ sign].show(); + me["arrow" ~ (item + 1) ~ sign].setColor(getprop("/MCDUC/colors/" ~ myArrival[i].arrowsColour[matrixArrow][item] ~ "/r"), getprop("/MCDUC/colors/" ~ myArrival[i].arrowsColour[matrixArrow][item] ~ "/g"), getprop("/MCDUC/colors/" ~ myArrival[i].arrowsColour[matrixArrow][item] ~ "/b")); + } else { + me["arrow" ~ (item + 1) ~ sign].hide(); + } + } + } + + forindex (var matrixFont; myArrival[i].fontMatrix) { + if (matrixFont == 0) { + var sign = "L"; + } else { + var sign = "R"; + } + forindex (var item; myArrival[i].fontMatrix[matrixFont]) { + if (myArrival[i].fontMatrix[matrixFont][item] == 1) { + me["Simple_" ~ sign ~ (item + 1)].setFont(symbol); + me["Simple_" ~ sign ~ (item + 1)].setFontSize(small); + } else { + me["Simple_" ~ sign ~ (item + 1)].setFont(default); + me["Simple_" ~ sign ~ (item + 1)].setFontSize(normal); + } + } + } + + if (myArrival[i].L1[0] == nil) { + me["Simple_L1"].hide(); + me["Simple_L1S"].hide(); + } else { + me["Simple_L1"].show(); + me["Simple_L1"].setText(myArrival[i].L1[0]); + if (myArrival[i].L1[1] != nil) { + me["Simple_L1S"].show(); + me["Simple_L1S"].setText(myArrival[i].L1[1]); + } else { + me["Simple_L1S"].hide(); + } + } + + if (myArrival[i].L2[0] == nil) { + me["Simple_L2"].hide(); + me["Simple_L2S"].hide(); + } else { + me["Simple_L2"].show(); + me["Simple_L2"].setText(myArrival[i].L2[0]); + if (myArrival[i].L2[1] != nil) { + me["Simple_L2S"].show(); + me["Simple_L2S"].setText(myArrival[i].L2[1]); + } else { + me["Simple_L2S"].hide(); + } + } + + if (myArrival[i].L3[0] == nil) { + me["Simple_L3"].hide(); + me["Simple_L3S"].hide(); + } else { + me["Simple_L3"].show(); + me["Simple_L3"].setText(myArrival[i].L3[0]); + if (myArrival[i].L3[1] != nil) { + me["Simple_L3S"].show(); + me["Simple_L3S"].setText(myArrival[i].L3[1]); + } else { + me["Simple_L3S"].hide(); + } + } + + if (myArrival[i].L4[0] == nil) { + me["Simple_L4"].hide(); + me["Simple_L4S"].hide(); + } else { + me["Simple_L4"].show(); + me["Simple_L4"].setText(myArrival[i].L4[0]); + if (myArrival[i].L4[1] != nil) { + me["Simple_L4S"].show(); + me["Simple_L4S"].setText(myArrival[i].L4[1]); + } else { + me["Simple_L4S"].hide(); + } + } + + if (myArrival[i].L5[0] == nil) { + me["Simple_L5"].hide(); + me["Simple_L5S"].hide(); + } else { + me["Simple_L5"].show(); + me["Simple_L5"].setText(myArrival[i].L5[0]); + if (myArrival[i].L5[1] != nil) { + me["Simple_L5S"].show(); + me["Simple_L5S"].setText(myArrival[i].L5[1]); + } else { + me["Simple_L5S"].hide(); + } + } + + if (myArrival[i].L6[0] == nil) { + me["Simple_L6"].hide(); + me["Simple_L6S"].hide(); + } else { + me["Simple_L6"].show(); + me["Simple_L6"].setText(myArrival[i].L6[0]); + if (myArrival[i].L6[1] != nil) { + me["Simple_L6S"].show(); + me["Simple_L6S"].setText(myArrival[i].L6[1]); + } else { + me["Simple_L6S"].hide(); + } + } + me.colorLeft(myArrival[i].L1[2],myArrival[i].L2[2],myArrival[i].L3[2],myArrival[i].L4[2],myArrival[i].L5[2],myArrival[i].L6[2]); + + if (myArrival[i].C1[0] == nil) { + me["Simple_C1"].hide(); + me["Simple_C1S"].hide(); + } else { + me["Simple_C1"].show(); + me["Simple_C1"].setText(myArrival[i].C1[0]); + if (myArrival[i].C1[1] != nil) { + me["Simple_C1S"].show(); + me["Simple_C1S"].setText(myArrival[i].C1[1]); + } else { + me["Simple_C1S"].hide(); + } + } + + if (myArrival[i].C2[0] == nil) { + me["Simple_C2"].hide(); + me["Simple_C2S"].hide(); + } else { + me["Simple_C2"].show(); + me["Simple_C2"].setText(myArrival[i].C2[0]); + if (myArrival[i].C2[1] != nil) { + me["Simple_C2S"].show(); + me["Simple_C2S"].setText(myArrival[i].C2[1]); + } else { + me["Simple_C2S"].hide(); + } + } + + if (myArrival[i].C3[0] == nil) { + me["Simple_C3"].hide(); + me["Simple_C3S"].hide(); + } else { + me["Simple_C3"].show(); + me["Simple_C3"].setText(myArrival[i].C3[0]); + if (myArrival[i].C3[1] != nil) { + me["Simple_C3S"].show(); + me["Simple_C3S"].setText(myArrival[i].C3[1]); + } else { + me["Simple_C3S"].hide(); + } + } + + if (myArrival[i].C4[0] == nil) { + me["Simple_C4"].hide(); + me["Simple_C4S"].hide(); + } else { + me["Simple_C4"].show(); + me["Simple_C4"].setText(myArrival[i].C4[0]); + if (myArrival[i].C4[1] != nil) { + me["Simple_C4S"].show(); + me["Simple_C4S"].setText(myArrival[i].C4[1]); + } else { + me["Simple_C4S"].hide(); + } + } + + if (myArrival[i].C5[0] == nil) { + me["Simple_C5"].hide(); + me["Simple_C5S"].hide(); + } else { + me["Simple_C5"].show(); + me["Simple_C5"].setText(myArrival[i].C5[0]); + if (myArrival[i].C5[1] != nil) { + me["Simple_C5S"].show(); + me["Simple_C5S"].setText(myArrival[i].C5[1]); + } else { + me["Simple_C5S"].hide(); + } + } + me.colorCenter(myArrival[i].C1[2],myArrival[i].C2[2],myArrival[i].C3[2],myArrival[i].C4[2],myArrival[i].C5[2],myArrival[i].C6[2]); + + me["Simple_C6"].hide(); + me["Simple_C6S"].hide(); + + if (myArrival[i].R1[0] == nil) { + me["Simple_R1"].hide(); + me["Simple_R1S"].hide(); + } else { + me["Simple_R1"].show(); + me["Simple_R1"].setText(myArrival[i].R1[0]); + if (myArrival[i].R1[1] != nil) { + me["Simple_R1S"].show(); + me["Simple_R1S"].setText(myArrival[i].R1[1]); + } else { + me["Simple_R1S"].hide(); + } + } + + if (myArrival[i].R2[0] == nil) { + me["Simple_R2"].hide(); + me["Simple_R2S"].hide(); + } else { + me["Simple_R2"].show(); + me["Simple_R2"].setText(myArrival[i].R2[0]); + if (myArrival[i].R2[1] != nil) { + me["Simple_R2S"].show(); + me["Simple_R2S"].setText(myArrival[i].R2[1]); + } else { + me["Simple_R2S"].hide(); + } + } + + if (myArrival[i].R3[0] == nil) { + me["Simple_R3"].hide(); + me["Simple_R3S"].hide(); + } else { + me["Simple_R3"].show(); + me["Simple_R3"].setText(myArrival[i].R3[0]); + if (myArrival[i].R3[1] != nil) { + me["Simple_R3S"].show(); + me["Simple_R3S"].setText(myArrival[i].R3[1]); + } else { + me["Simple_R3S"].hide(); + } + } + + if (myArrival[i].R4[0] == nil) { + me["Simple_R4"].hide(); + me["Simple_R4S"].hide(); + } else { + me["Simple_R4"].show(); + me["Simple_R4"].setText(myArrival[i].R4[0]); + if (myArrival[i].R4[1] != nil) { + me["Simple_R4S"].show(); + me["Simple_R4S"].setText(myArrival[i].R4[1]); + } else { + me["Simple_R4S"].hide(); + } + } + + if (myArrival[i].R5[0] == nil) { + me["Simple_R5"].hide(); + me["Simple_R5S"].hide(); + } else { + me["Simple_R5"].show(); + me["Simple_R5"].setText(myArrival[i].R5[0]); + if (myArrival[i].R5[1] != nil) { + me["Simple_R5S"].show(); + me["Simple_R5S"].setText(myArrival[i].R5[1]); + } else { + me["Simple_R5S"].hide(); + } + } + + if (myArrival[i].R6[0] == nil) { + me["Simple_R6"].hide(); + me["Simple_R6S"].hide(); + } else { + me["Simple_R6"].show(); + me["Simple_R6"].setText(myArrival[i].R6[0]); + if (myArrival[i].R6[1] != nil) { + me["Simple_R6S"].show(); + me["Simple_R6S"].setText(myArrival[i].R6[1]); + } else { + me["Simple_R6S"].hide(); + } + } + me.colorRight(myArrival[i].R1[2],myArrival[i].R2[2],myArrival[i].R3[2],myArrival[i].R4[2],myArrival[i].R5[2],myArrival[i].R6[2]); + } + pageSwitch[i].setBoolValue(1); + } } else { if (!pageSwitch[i].getBoolValue()) { me["Simple"].hide(); diff --git a/Nasal/FMGC/flightplan.nas b/Nasal/FMGC/flightplan.nas index f9b466bd..d1d9e50d 100644 --- a/Nasal/FMGC/flightplan.nas +++ b/Nasal/FMGC/flightplan.nas @@ -91,6 +91,7 @@ var flightPlanController = { } me.addDiscontinuity(1, plan); + #todo if plan = 2, kill any tmpy flightplan me.flightPlanChanged(plan); }, diff --git a/Nasal/MCDU/ARRIVAL.nas b/Nasal/MCDU/ARRIVAL.nas index 04af05d1..57fe39b6 100644 --- a/Nasal/MCDU/ARRIVAL.nas +++ b/Nasal/MCDU/ARRIVAL.nas @@ -24,7 +24,7 @@ var arrivalPage = { R6: [nil, nil, "ack"], arrAirport: nil, runways: nil, - selectedRunway: nil, + selectedApproach: nil, selectedVIA: nil, selectedSTAR: nil, selectedTransition: nil, @@ -56,16 +56,16 @@ var arrivalPage = { if (!fmgc.flightPlanController.temporaryFlag[me.computer]) { if (fmgc.flightPlanController.flightplans[2].destination_runway != nil) { - me.selectedRunway = fmgc.flightPlanController.flightplans[2].destination_runway; + me.selectedApproach = fmgc.flightPlanController.flightplans[2].destination_runway; } if (fmgc.flightPlanController.flightplans[2].star != nil) { me.selectedSTAR = fmgc.flightPlanController.flightplans[2].star; } } else { if (fmgc.flightPlanController.flightplans[me.computer].destination_runway != nil) { - me.selectedRunway = fmgc.flightPlanController.flightplans[me.computer].destination_runway; + me.selectedApproach = fmgc.flightPlanController.flightplans[me.computer].destination_runway; } elsif (fmgc.flightPlanController.flightplans[2].destination_runway != nil) { - me.selectedRunway = fmgc.flightPlanController.flightplans[2].destination_runway; + me.selectedApproach = fmgc.flightPlanController.flightplans[2].destination_runway; } if (fmgc.flightPlanController.flightplans[me.computer].star != nil) { me.selectedSTAR = fmgc.flightPlanController.flightplans[me.computer].star; @@ -91,8 +91,8 @@ var arrivalPage = { me.updateSTARs(); } - #me.updateActiveRunway(); - #me.updateActiveSTARs(); + me.updateActiveApproach(); + me.updateActiveSTARs(); #me.updateActiveTransitions(); }, _clearPage: func() { @@ -122,18 +122,18 @@ var arrivalPage = { me._clearPage(); me._setupPageWithData(); }, - updateActiveRunway: func() { - if (me.selectedRunway != nil) { - if (fmgc.flightPlanController.flightplans[2].destination_runway != nil) { - if (fmgc.flightPlanController.flightplans[2].destination_runway.id == me.selectedRunway.id) { - me.L1 = [fmgc.flightPlanController.flightplans[2].destination_runway.id, " APPR", "grn"]; - } elsif (fmgc.flightPlanController.flightplans[me.computer].destination_runway != nil) { - me.L1 = [fmgc.flightPlanController.flightplans[me.computer].destination_runway.id, " APPR", "yel"]; + updateActiveApproach: func() { + if (me.selectedApproach != nil) { + if (fmgc.flightPlanController.flightplans[2].approach != nil) { + if (fmgc.flightPlanController.flightplans[2].approach == me.selectedApproach) { + me.L1 = [fmgc.flightPlanController.flightplans[2].approach.id, " APPR", "grn"]; + } elsif (fmgc.flightPlanController.flightplans[me.computer].approach != nil) { + me.L1 = [fmgc.flightPlanController.flightplans[me.computer].approach.id, " APPR", "yel"]; } else { me.L1 = ["---", " APPR", "wht"]; } - } elsif (fmgc.flightPlanController.flightplans[me.computer].destination_runway != nil) { - me.L1 = [fmgc.flightPlanController.flightplans[me.computer].destination_runway.id, " APPR", "yel"]; + } elsif (fmgc.flightPlanController.flightplans[me.computer].approach != nil) { + me.L1 = [fmgc.flightPlanController.flightplans[me.computer].approach.id, " APPR", "yel"]; } else { me.L1 = ["---", " APPR", "wht"]; } @@ -150,15 +150,15 @@ var arrivalPage = { } elsif (fmgc.flightPlanController.flightplans[me.computer].star != nil) { me.C1 = [fmgc.flightPlanController.flightplans[me.computer].star.id, "SID", "yel"]; } else { - me.C1 = ["------- ", "SID", "wht"]; + me.C1 = ["------- ", "STAR", "wht"]; } } elsif (fmgc.flightPlanController.flightplans[me.computer].star.id != nil) { me.C1 = [fmgc.flightPlanController.flightplans[me.computer].star.id, "SID", "yel"]; } else { - me.C1 = ["------- ", "SID", "wht"]; + me.C1 = ["------- ", "STAR", "wht"]; } } else { - me.C1 = ["------- ", "SID", "wht"]; + me.C1 = ["------- ", "STAR", "wht"]; } canvas_mcdu.pageSwitch[me.computer].setBoolValue(0); }, @@ -190,44 +190,54 @@ var arrivalPage = { if (me.arrAirport == nil) { me.arrAirport = findAirportsByICAO(left(me.id, 4)); } - me._approaches = keys(me.arrAirport[0].getApproachList()); + me._approaches = me.arrAirport[0].getApproachList(); me.approaches = sort(me._approaches,func(a,b) cmp(a,b)); if (size(me.approaches) >= 1) { me.L3 = [" " ~ me.approaches[0 + me.scrollApproach], " APPR", "blu"]; - me.C3 = [math.round(me.arrAirport[0].runways[me.approaches[0 + me.scrollApproach]].runways[0].length) ~ "M", "AVAILABLE ", "blu"]; - me.R3 = ["CRS" ~ math.round(me.arrAirport[0].runways[me.approaches[0 + me.scrollApproach]].runways[0].heading), nil, "blu"]; - if (me.approaches[0 + me.scrollApproach] != me.selectedRunway) { - me.arrowsMatrix[0][1] = 1; - me.arrowsColour[0][1] = "blu"; + me.C3 = [math.round(me.arrAirport[0].runways[me.arrAirport[0].getIAP(me.approaches[0 + me.scrollApproach]).runways[0]].length) ~ "M", "AVAILABLE ", "blu"]; + me.R3 = ["CRS" ~ math.round(me.arrAirport[0].runways[me.arrAirport[0].getIAP(me.approaches[0 + me.scrollApproach]).runways[0]].heading), nil, "blu"]; + if (me.approaches[0 + me.scrollApproach] != me.selectedApproach) { + me.arrowsMatrix[0][2] = 1; + me.arrowsColour[0][2] = "blu"; } else { - me.arrowsMatrix[0][1] = 0; - me.arrowsColour[0][1] = "ack"; + me.arrowsMatrix[0][2] = 0; + me.arrowsColour[0][2] = "ack"; } } if (size(me.approaches) >= 2) { me.L4 = [" " ~ me.approaches[1 + me.scrollApproach], nil, "blu"]; - me.C4 = [math.round(me.arrAirport[0].runways[me.approaches[1 + me.scrollApproach]].runways[1].length) ~ "M", sprintf("%7.2f", me.arrAirport[0].runways[0 + me.scrollApproach].ils_frequency_mhz), "blu"]; - me.R4 = ["CRS" ~ math.round(me.arrAirport[0].runways[me.approaches[1 + me.scrollApproach]].runways[1].heading), nil, "blu"]; - if (me.approaches[1 + me.scrollApproach] != me.selectedRunway) { - me.arrowsMatrix[0][2] = 1; - me.arrowsColour[0][2] = "blu"; + if (me.arrAirport[0].getIAP(me.approaches[0 + me.scrollApproach]).radio == "ILS") { + me.C5 = [math.round(me.arrAirport[0].runways[me.arrAirport[0].getIAP(me.approaches[1 + me.scrollApproach]).runways[0]].length) ~ "M", me.arrAirport[0].runways[me.arrAirport[0].getIAP(me.approaches[0 + me.scrollApproach]).runways[0]].ils.id ~ "/" ~ sprintf("%7.2f", me.arrAirport[0].runways[me.arrAirport[0].getIAP(me.approaches[0 + me.scrollApproach]).runways[0]].ils_frequency_mhz), "blu"]; } else { - me.arrowsMatrix[0][2] = 0; - me.arrowsColour[0][2] = "ack"; + me.C5 = [math.round(me.arrAirport[0].runways[me.arrAirport[0].getIAP(me.approaches[1 + me.scrollApproach]).runways[0]].length) ~ "M", nil, "blu"]; + } + me.R4 = ["CRS" ~ math.round(me.arrAirport[0].runways[me.arrAirport[0].getIAP(me.approaches[1 + me.scrollApproach]).runways[0]].heading), nil, "blu"]; + if (me.approaches[1 + me.scrollApproach] != me.selectedApproach) { + me.arrowsMatrix[0][3] = 1; + me.arrowsColour[0][3] = "blu"; + } else { + me.arrowsMatrix[0][3] = 0; + me.arrowsColour[0][3] = "ack"; } } if (size(me.approaches) >= 3) { me.L5 = [" " ~ me.approaches[2 + me.scrollApproach], nil, "blu"]; - me.C5 = [math.round(me.arrAirport[0].runways[me.approaches[2 + me.scrollApproach]].runways[2].length) ~ "M", sprintf("%7.2f", me.arrAirport[0].runways[1 + me.scrollApproach].ils_frequency_mhz), "blu"]; - me.R5 = ["CRS" ~ math.round(me.arrAirport[0].runways[me.approaches[2 + me.scrollApproach]].runways[2].heading), nil, "blu"]; - me.C6[1] = sprintf("%7.2f", me.arrAirport[0].runways[2 + me.scrollApproach].ils_frequency_mhz); - if (me.approaches[2 + me.scrollApproach] != me.selectedRunway) { - me.arrowsMatrix[0][2] = 1; - me.arrowsColour[0][2] = "blu"; + if (me.arrAirport[0].getIAP(me.approaches[1 + me.scrollApproach]).radio == "ILS") { + me.C5 = [math.round(me.arrAirport[0].runways[me.arrAirport[0].getIAP(me.approaches[2 + me.scrollApproach]).runways[0]].length) ~ "M", me.arrAirport[0].runways[me.arrAirport[0].getIAP(me.approaches[1 + me.scrollApproach]).runways[0]].ils.id ~ "/" ~ sprintf("%7.2f", me.arrAirport[0].runways[me.arrAirport[0].getIAP(me.approaches[1 + me.scrollApproach]).runways[0]].ils_frequency_mhz), "blu"]; } else { - me.arrowsMatrix[0][2] = 0; - me.arrowsColour[0][2] = "ack"; + me.C5 = [math.round(me.arrAirport[0].runways[me.arrAirport[0].getIAP(me.approaches[2 + me.scrollApproach]).runways[0]].length) ~ "M", nil, "blu"]; + } + me.R5 = ["CRS" ~ math.round(me.arrAirport[0].runways[me.arrAirport[0].getIAP(me.approaches[2 + me.scrollApproach]).runways[0]].heading), nil, "blu"]; + if (me.arrAirport[0].getIAP(me.approaches[2 + me.scrollApproach]).radio == "ILS") { + me.C6[1] = me.arrAirport[0].runways[me.arrAirport[0].getIAP(me.approaches[2 + me.scrollApproach]).runways[0]].ils.id ~ "/" ~ sprintf("%7.2f", me.arrAirport[0].runways[me.arrAirport[0].getIAP(me.approaches[2 + me.scrollApproach]).runways[0]].ils_frequency_mhz); + } + if (me.approaches[2 + me.scrollApproach] != me.selectedApproach) { + me.arrowsMatrix[0][4] = 1; + me.arrowsColour[0][4] = "blu"; + } else { + me.arrowsMatrix[0][3] = 0; + me.arrowsColour[0][3] = "ack"; } } @@ -240,8 +250,8 @@ var arrivalPage = { if (me.arrAirport == nil) { me.arrAirport = findAirportsByICAO(left(me.id, 4)); } - if (me.selectedRunway != nil) { - me._stars = me.arrAirport[0].stars(me.selectedRunway.id); + if (me.selectedApproach != nil) { + me._stars = me.arrAirport[0].stars(me.selectedApproach.id); } else { me._stars = me.arrAirport[0].stars(); } @@ -376,6 +386,8 @@ var arrivalPage = { me.scrollStars = 0; } me.updateSTARs(); + me.hasPressNoTrans = 0; + me.updateTransitions(); } } }, @@ -396,6 +408,7 @@ var arrivalPage = { } me.updateSTARs(); me.hasPressNoTrans = 0; + me.updateTransitions(); } } }, @@ -407,13 +420,14 @@ var arrivalPage = { me.activePage = !me.activePage; me.updatePage(); }, - depPushbuttonLeft: func(index) { + arrPushbuttonLeft: func(index) { if (me.activePage == 0) { - if (size(me.approaches) >= (index - 1)) { - me.selectedRunway = me.arrAirport[0].runway(me.approaches[index - 2 + me.scrollApproach]); + if (size(me.approaches) >= (index - 1) and index != 2) { + me.selectedApproach = me.arrAirport[0].getIAP(me.approaches[index - 3 + me.scrollApproach]); me.makeTmpy(); - fmgc.flightPlanController.flightplans[me.computer].destination_runway = me.selectedRunway; - me.updateActiveRunway(); + fmgc.flightPlanController.flightplans[me.computer].destination_runway = me.arrAirport[0].runways[me.selectedApproach.runways[0]]; + fmgc.flightPlanController.flightplans[me.computer].approach = me.selectedApproach; + me.updateActiveApproach(); me.updateApproaches(); fmgc.flightPlanController.flightPlanChanged(me.computer); me.scrollRight(); @@ -422,9 +436,9 @@ var arrivalPage = { } } else { if (size(me.stars) >= (index - 1)) { - me.selectedSTAR = me.stars[index - 2 + me.scrollStars]; + me.selectedSTAR = me.stars[index - 3 + me.scrollStars]; me.makeTmpy(); - fmgc.flightPlanController.flightplans[me.computer].star = me.selectedSTAR; + fmgc.flightPlanController.flightplans[me.computer].star = me.arrAirport[0].getStar(me.selectedSTAR); me.updateActiveSTARs(); me.updateSTARs(); me.hasPressNoTrans = 0; @@ -436,7 +450,7 @@ var arrivalPage = { } } }, - depPushbuttonRight: func(index) { + arrPushbuttonRight: func(index) { if (index == 2 and size(me.transitions) == 0) { me.hasPressNoTrans = 1; me.updateActiveTransitions(); diff --git a/Nasal/MCDU/DEPARTURE.nas b/Nasal/MCDU/DEPARTURE.nas index de002fb2..2b2037a7 100644 --- a/Nasal/MCDU/DEPARTURE.nas +++ b/Nasal/MCDU/DEPARTURE.nas @@ -385,6 +385,8 @@ var departurePage = { me.scrollSids = 0; } me.updateSIDs(); + me.hasPressNoTrans = 0; + me.updateTransitions(); } } }, @@ -405,6 +407,7 @@ var departurePage = { } me.updateSIDs(); me.hasPressNoTrans = 0; + me.updateTransitions(); } } }, @@ -453,7 +456,7 @@ var departurePage = { } elsif (size(me.transitions) >= (index - 1)) { me.selectedTransition = me.transitions[index - 2]; me.makeTmpy(); - fmgc.flightPlanController.flightplans[me.computer].sid_trans = me.selectedTransition; + fmgc.flightPlanController.flightplans[me.computer].sid = me.depAirport[0].getSid(me.selectedSID).transition(me.selectedTransition); me.updateActiveTransitions(); me.updateTransitions(); fmgc.flightPlanController.flightPlanChanged(me.computer); diff --git a/Nasal/MCDU/F-PLN-rework.nas b/Nasal/MCDU/F-PLN-rework.nas index 63c50adc..2e91c962 100644 --- a/Nasal/MCDU/F-PLN-rework.nas +++ b/Nasal/MCDU/F-PLN-rework.nas @@ -270,7 +270,7 @@ var fplnPage = { # this one is only created once, and then updated - remember th } }, destInfo: func() { - me.L6 = [me.plan.getWP(fmgc.flightPlanController.arrivalIndex[me.planIndex]).wp_name, " DEST", "wht"]; + me.L6 = [left(me.plan.getWP(fmgc.flightPlanController.arrivalIndex[me.planIndex]).wp_name, 4), " DEST", "wht"]; me.C6 = ["---- " ~ int(fmgc.flightPlanController.arrivalDist), "TIME DIST", "wht"]; me.R6 = ["--.-", "EFOB", "wht"]; }, @@ -306,7 +306,12 @@ var fplnPage = { # this one is only created once, and then updated - remember th if (fmgc.flightPlanController.temporaryFlag[me.computer]) { fmgc.flightPlanController.destroyTemporaryFlightPlan(me.computer, 0); } else { - notAllowed(me.computer); + if (canvas_mcdu.myLatRev[me.computer] != nil) { + canvas_mcdu.myLatRev[me.computer].del(); + } + canvas_mcdu.myLatRev[me.computer] = nil; + canvas_mcdu.myLatRev[me.computer] = latRev.new(1, me.L6[0], fmgc.flightPlanController.arrivalIndex[me.computer], me.computer); + setprop("/MCDU[" ~ me.computer ~ "]/page", "LATREV"); } } else { if (size(me.outputList) >= index) { diff --git a/Nasal/MCDU/MCDU.nas b/Nasal/MCDU/MCDU.nas index 4d7ba91e..9203f827 100644 --- a/Nasal/MCDU/MCDU.nas +++ b/Nasal/MCDU/MCDU.nas @@ -142,6 +142,8 @@ var lskbutton = func(btn, i) { canvas_mcdu.myFpln[i].pushButtonLeft(2); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "DEPARTURE") { canvas_mcdu.myDeparture[i].depPushbuttonLeft(2); + } else if (getprop("/MCDU[" ~ i ~ "]/page") == "ARRIVAL") { + canvas_mcdu.myArrival[i].arrPushbuttonLeft(2); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "DUPLICATENAMES") { canvas_mcdu.myDuplicate[i].pushButtonLeft(2); } else { @@ -164,6 +166,8 @@ var lskbutton = func(btn, i) { canvas_mcdu.myFpln[i].pushButtonLeft(3); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "DEPARTURE") { canvas_mcdu.myDeparture[i].depPushbuttonLeft(3); + } else if (getprop("/MCDU[" ~ i ~ "]/page") == "ARRIVAL") { + canvas_mcdu.myArrival[i].arrPushbuttonLeft(3); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "DUPLICATENAMES") { canvas_mcdu.myDuplicate[i].pushButtonLeft(3); } else { @@ -182,6 +186,8 @@ var lskbutton = func(btn, i) { canvas_mcdu.myFpln[i].pushButtonLeft(4); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "DEPARTURE") { canvas_mcdu.myDeparture[i].depPushbuttonLeft(4); + } else if (getprop("/MCDU[" ~ i ~ "]/page") == "ARRIVAL") { + canvas_mcdu.myArrival[i].arrPushbuttonLeft(4); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "DUPLICATENAMES") { canvas_mcdu.myDuplicate[i].pushButtonLeft(4); } else { @@ -208,6 +214,8 @@ var lskbutton = func(btn, i) { canvas_mcdu.myFpln[i].pushButtonLeft(5); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "DEPARTURE") { canvas_mcdu.myDeparture[i].depPushbuttonLeft(5); + } else if (getprop("/MCDU[" ~ i ~ "]/page") == "ARRIVAL") { + canvas_mcdu.myArrival[i].arrPushbuttonLeft(5); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "DUPLICATENAMES") { canvas_mcdu.myDuplicate[i].pushButtonLeft(5); } else { @@ -228,7 +236,7 @@ var lskbutton = func(btn, i) { canvas_mcdu.myFpln[i].pushButtonLeft(6); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "LATREV" or getprop("/MCDU[" ~ i ~ "]/page") == "DUPLICATENAMES") { setprop("/MCDU[" ~ i ~ "]/page", "F-PLNA"); - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "DEPARTURE") { + } else if (getprop("/MCDU[" ~ i ~ "]/page") == "DEPARTURE" or getprop("/MCDU[" ~ i ~ "]/page") == "ARRIVAL") { if (fmgc.flightPlanController.temporaryFlag[i]) { setprop("/MCDU[" ~ i ~ "]/page", "F-PLNA"); } else { @@ -256,12 +264,13 @@ var rskbutton = func(btn, i) { printInput("R1", i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "PRINTFUNC2") { printInput2("R1", i); - } else if (getprop("/MCDU[" ~ i ~ "/page") == "LATREV") { + } else if (getprop("/MCDU[" ~ i ~ "]/page") == "LATREV") { if (canvas_mcdu.myArrival[i] != nil) { canvas_mcdu.myArrival[i].del(); } canvas_mcdu.myArrival[i] = nil; canvas_mcdu.myArrival[i] = arrivalPage.new(canvas_mcdu.myLatRev[i].title[2], i); + setprop("/MCDU[" ~ i ~ "]/page", "ARRIVAL"); } else { notAllowed(i); } @@ -276,6 +285,8 @@ var rskbutton = func(btn, i) { printInput2("R2", i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "DEPARTURE") { canvas_mcdu.myDeparture[i].depPushbuttonRight(2); + } else if (getprop("/MCDU[" ~ i ~ "]/page") == "ARRIVAL") { + canvas_mcdu.myArrival[i].arrPushbuttonRight(2); } else { notAllowed(i); } @@ -288,6 +299,10 @@ var rskbutton = func(btn, i) { printInput("R3", i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "PRINTFUNC2") { printInput2("R3", i); + } else if (getprop("/MCDU[" ~ i ~ "]/page") == "DEPARTURE") { + canvas_mcdu.myDeparture[i].depPushbuttonRight(3); + } else if (getprop("/MCDU[" ~ i ~ "]/page") == "ARRIVAL") { + canvas_mcdu.myArrival[i].arrPushbuttonRight(3); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "LATREV") { if (canvas_mcdu.myLatRev[i].type != 2) { canvas_mcdu.myLatRev[i].nextWpt(); @@ -304,6 +319,10 @@ var rskbutton = func(btn, i) { radnavInput("R4", i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "PRINTFUNC2") { printInput2("R4", i); + } else if (getprop("/MCDU[" ~ i ~ "]/page") == "DEPARTURE") { + canvas_mcdu.myDeparture[i].depPushbuttonRight(4); + } else if (getprop("/MCDU[" ~ i ~ "]/page") == "ARRIVAL") { + canvas_mcdu.myArrival[i].arrPushbuttonRight(4); } else { notAllowed(i); } @@ -314,6 +333,10 @@ var rskbutton = func(btn, i) { radnavInput("R5", i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "DATA") { dataInput("R5", i); + } else if (getprop("/MCDU[" ~ i ~ "]/page") == "DEPARTURE") { + canvas_mcdu.myDeparture[i].depPushbuttonRight(5); + } else if (getprop("/MCDU[" ~ i ~ "]/page") == "ARRIVAL") { + canvas_mcdu.myArrival[i].arrPushbuttonRight(5); } else { notAllowed(i); } @@ -374,6 +397,8 @@ var arrowbutton = func(btn, i) { setprop("/MCDU[" ~ i ~ "]/page", "PRINTFUNC"); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "DEPARTURE") { canvas_mcdu.myDeparture[i].scrollLeft(); + } else if (getprop("/MCDU[" ~ i ~ "]/page") == "ARRIVAL") { + canvas_mcdu.myArrival[i].scrollLeft(); } } else if (btn == "right") { if (getprop("/MCDU[" ~ i ~ "]/page") == "DATA") { @@ -392,18 +417,24 @@ var arrowbutton = func(btn, i) { setprop("/MCDU[" ~ i ~ "]/page", "PRINTFUNC"); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "DEPARTURE") { canvas_mcdu.myDeparture[i].scrollRight(); + } else if (getprop("/MCDU[" ~ i ~ "]/page") == "ARRIVAL") { + canvas_mcdu.myArrival[i].scrollRight(); } } else if (btn == "up") { if (getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNA" or getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNB") { canvas_mcdu.myFpln[i].scrollUp(); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "DEPARTURE") { canvas_mcdu.myDeparture[i].scrollUp(); + } else if (getprop("/MCDU[" ~ i ~ "]/page") == "ARRIVAL") { + canvas_mcdu.myArrival[i].scrollUp(); } } else if (btn == "down") { if (getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNA" or getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNB") { canvas_mcdu.myFpln[i].scrollDn(); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "DEPARTURE") { canvas_mcdu.myDeparture[i].scrollDn(); + } else if (getprop("/MCDU[" ~ i ~ "]/page") == "ARRIVAL") { + canvas_mcdu.myArrival[i].scrollDn(); } } } From f4e79d16e4000c79ce557311a2e907e03ae0abd4 Mon Sep 17 00:00:00 2001 From: legoboyvdlp R Date: Thu, 16 Jan 2020 21:02:35 +0000 Subject: [PATCH 12/51] Bugfix arrival page --- Nasal/FMGC/flightplan.nas | 18 ++++++++++-------- Nasal/MCDU/ARRIVAL.nas | 23 ++++++++++++----------- 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/Nasal/FMGC/flightplan.nas b/Nasal/FMGC/flightplan.nas index d1d9e50d..a0ae05e0 100644 --- a/Nasal/FMGC/flightplan.nas +++ b/Nasal/FMGC/flightplan.nas @@ -129,7 +129,7 @@ var flightPlanController = { } else { me.flightplans[n].deleteWP(index); } - me.updatePlans(); + me.flightPlanChanged(n); canvas_nd.A3XXRouteDriver.triggerSignal("fp-removed"); return 2; } else { @@ -394,13 +394,15 @@ var flightPlanController = { wpDistancePrev[n][wpt].setValue(courseDistanceFrom[1]); } - if (wpID[n][wpt].getValue() == FMGCarr.getValue() and me.arrivalIndex[n] != wpt) { - me.arrivalIndex[n] = wpt; - if (canvas_mcdu.myFpln[0] != nil) { - canvas_mcdu.myFpln[0].destInfo(); - } - if (canvas_mcdu.myFpln[1] != nil) { - canvas_mcdu.myFpln[1].destInfo(); + if (left(wpID[n][wpt].getValue(), 4) == FMGCarr.getValue()) { + if (me.arrivalIndex[n] != wpt) { # don't merge line 397 and 398 if statements + me.arrivalIndex[n] = wpt; + if (canvas_mcdu.myFpln[0] != nil) { + canvas_mcdu.myFpln[0].destInfo(); + } + if (canvas_mcdu.myFpln[1] != nil) { + canvas_mcdu.myFpln[1].destInfo(); + } } } } diff --git a/Nasal/MCDU/ARRIVAL.nas b/Nasal/MCDU/ARRIVAL.nas index 57fe39b6..9bc324da 100644 --- a/Nasal/MCDU/ARRIVAL.nas +++ b/Nasal/MCDU/ARRIVAL.nas @@ -55,17 +55,17 @@ var arrivalPage = { me.title = ["ARRIVAL", " TO ", left(me.id, 4)]; if (!fmgc.flightPlanController.temporaryFlag[me.computer]) { - if (fmgc.flightPlanController.flightplans[2].destination_runway != nil) { - me.selectedApproach = fmgc.flightPlanController.flightplans[2].destination_runway; + if (fmgc.flightPlanController.flightplans[2].approach != nil) { + me.selectedApproach = fmgc.flightPlanController.flightplans[2].approach; } if (fmgc.flightPlanController.flightplans[2].star != nil) { me.selectedSTAR = fmgc.flightPlanController.flightplans[2].star; } } else { - if (fmgc.flightPlanController.flightplans[me.computer].destination_runway != nil) { - me.selectedApproach = fmgc.flightPlanController.flightplans[me.computer].destination_runway; - } elsif (fmgc.flightPlanController.flightplans[2].destination_runway != nil) { - me.selectedApproach = fmgc.flightPlanController.flightplans[2].destination_runway; + if (fmgc.flightPlanController.flightplans[me.computer].approach != nil) { + me.selectedApproach = fmgc.flightPlanController.flightplans[me.computer].approach; + } elsif (fmgc.flightPlanController.flightplans[2].approach != nil) { + me.selectedApproach = fmgc.flightPlanController.flightplans[2].approach; } if (fmgc.flightPlanController.flightplans[me.computer].star != nil) { me.selectedSTAR = fmgc.flightPlanController.flightplans[me.computer].star; @@ -93,7 +93,7 @@ var arrivalPage = { me.updateActiveApproach(); me.updateActiveSTARs(); - #me.updateActiveTransitions(); + me.updateActiveTransitions(); }, _clearPage: func() { me.L1 = [nil, nil, "ack"]; @@ -208,9 +208,9 @@ var arrivalPage = { if (size(me.approaches) >= 2) { me.L4 = [" " ~ me.approaches[1 + me.scrollApproach], nil, "blu"]; if (me.arrAirport[0].getIAP(me.approaches[0 + me.scrollApproach]).radio == "ILS") { - me.C5 = [math.round(me.arrAirport[0].runways[me.arrAirport[0].getIAP(me.approaches[1 + me.scrollApproach]).runways[0]].length) ~ "M", me.arrAirport[0].runways[me.arrAirport[0].getIAP(me.approaches[0 + me.scrollApproach]).runways[0]].ils.id ~ "/" ~ sprintf("%7.2f", me.arrAirport[0].runways[me.arrAirport[0].getIAP(me.approaches[0 + me.scrollApproach]).runways[0]].ils_frequency_mhz), "blu"]; + me.C4 = [math.round(me.arrAirport[0].runways[me.arrAirport[0].getIAP(me.approaches[1 + me.scrollApproach]).runways[0]].length) ~ "M", me.arrAirport[0].runways[me.arrAirport[0].getIAP(me.approaches[0 + me.scrollApproach]).runways[0]].ils.id ~ "/" ~ sprintf("%7.2f", me.arrAirport[0].runways[me.arrAirport[0].getIAP(me.approaches[0 + me.scrollApproach]).runways[0]].ils_frequency_mhz), "blu"]; } else { - me.C5 = [math.round(me.arrAirport[0].runways[me.arrAirport[0].getIAP(me.approaches[1 + me.scrollApproach]).runways[0]].length) ~ "M", nil, "blu"]; + me.C4 = [math.round(me.arrAirport[0].runways[me.arrAirport[0].getIAP(me.approaches[1 + me.scrollApproach]).runways[0]].length) ~ "M", nil, "blu"]; } me.R4 = ["CRS" ~ math.round(me.arrAirport[0].runways[me.arrAirport[0].getIAP(me.approaches[1 + me.scrollApproach]).runways[0]].heading), nil, "blu"]; if (me.approaches[1 + me.scrollApproach] != me.selectedApproach) { @@ -311,7 +311,8 @@ var arrivalPage = { if (me.arrAirport == nil) { me.arrAirport = findAirportsByICAO(left(me.id, 4)); } - + debug.dump(me.selectedSTAR); + debug.dump(me.arrAirport[0]); me._transitions = me.arrAirport[0].getStar(me.selectedSTAR).transitions; me.transitions = sort(me._transitions,func(a,b) cmp(a,b)); @@ -436,7 +437,7 @@ var arrivalPage = { } } else { if (size(me.stars) >= (index - 1)) { - me.selectedSTAR = me.stars[index - 3 + me.scrollStars]; + me.selectedSTAR = me.stars[index - 2 + me.scrollStars]; me.makeTmpy(); fmgc.flightPlanController.flightplans[me.computer].star = me.arrAirport[0].getStar(me.selectedSTAR); me.updateActiveSTARs(); From 47bf534bcab4c6d90ee0fd4ab6f76712556dfffb Mon Sep 17 00:00:00 2001 From: legoboyvdlp R Date: Thu, 23 Jan 2020 14:14:48 +0000 Subject: [PATCH 13/51] Push improvements --- Nasal/FMGC/FMGC.nas | 2 +- Nasal/FMGC/flightplan.nas | 20 ++-- Nasal/MCDU/ARRIVAL.nas | 41 +++++++- Nasal/MCDU/DEPARTURE.nas | 37 ++++++- Nasal/MCDU/F-PLN-rework.nas | 14 +-- Nasal/MCDU/LATREV.nas | 70 +------------- Nasal/MCDU/VERTREV.nas | 182 +++++++++++++++++++++++++++++++++++ Sounds/A320-common-sound.xml | 4 +- 8 files changed, 278 insertions(+), 92 deletions(-) create mode 100644 Nasal/MCDU/VERTREV.nas diff --git a/Nasal/FMGC/FMGC.nas b/Nasal/FMGC/FMGC.nas index 95b2049f..664bcff0 100644 --- a/Nasal/FMGC/FMGC.nas +++ b/Nasal/FMGC/FMGC.nas @@ -286,7 +286,7 @@ var reset_FMGC = func { alt = getprop("/it-autoflight/input/alt"); ITAF.init(); FMGCinit(); - flightplan.reset(); + flightPlanController.reset(); mcdu.MCDU_reset(0); mcdu.MCDU_reset(1); setprop("/it-autoflight/input/fd1", fd1); diff --git a/Nasal/FMGC/flightplan.nas b/Nasal/FMGC/flightplan.nas index a0ae05e0..c7e05244 100644 --- a/Nasal/FMGC/flightplan.nas +++ b/Nasal/FMGC/flightplan.nas @@ -1,8 +1,6 @@ # A3XX FMGC Flightplan Driver # Copyright (c) 2019 Jonathan Redpath (2019) -var magTrueError = 0; - var wpDep = nil; var wpArr = nil; var pos = nil; @@ -39,9 +37,9 @@ var flightPlanController = { currentToWpt: nil, # container for the current TO waypoint ghost currentToWptIndex: props.globals.initNode("/FMGC/flightplan[2]/current-wp", 0, "INT"), currentToWptID: "", - courseToWpt: 0, - courseMagToWpt: 0, - distToWpt: 0, + courseToWpt: props.globals.initNode("/FMGC/flightplan[2]/current-leg-course", 0, "DOUBLE"), + courseMagToWpt: props.globals.initNode("/FMGC/flightplan[2]/current-leg-course-mag", 0, "DOUBLE"), + distToWpt: props.globals.initNode("/FMGC/flightplan[2]/current-leg-dist", 0, "DOUBLE"),, distanceToDest: [0, 0, 0], num: [0, 0, 0], @@ -123,8 +121,10 @@ var flightPlanController = { if (wp != FMGCdep.getValue() and wp != FMGCarr.getValue() 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); - if (me.flightplans[n].getWP(index).id != "DISCONTINUITY") { # else, if the next one isn't a discont, add one - me.addDiscontinuity(index, n); + if (me.flightplans[n].getWP(index) != nil) { + if (me.flightplans[n].getWP(index).id != "DISCONTINUITY") { # else, if the next one isn't a discont, add one + me.addDiscontinuity(index, n); + } } } else { me.flightplans[n].deleteWP(index); @@ -428,11 +428,11 @@ var flightPlanController = { me.currentToWpt = me.flightplans[i].getWP(me.currentToWptIndex.getValue()); me.currentToWptId = me.currentToWpt.wp_name; - me.courseToWpt = me.currentToWpt.courseAndDistanceFrom(curAircraftPos)[0]; - me.distToWpt = me.currentToWpt.courseAndDistanceFrom(curAircraftPos)[1]; + me.courseToWpt.setValue(me.currentToWpt.courseAndDistanceFrom(curAircraftPos)[0]); + me.distToWpt.setValue(me.currentToWpt.courseAndDistanceFrom(curAircraftPos)[1]); magTrueError = magHDG.getValue() - trueHDG.getValue(); - me.courseMagToWpt = me.courseToWpt + magTrueError; + me.courseMagToWpt.setValue(me.courseToWpt.getValue() + magTrueError); return; } diff --git a/Nasal/MCDU/ARRIVAL.nas b/Nasal/MCDU/ARRIVAL.nas index 9bc324da..a6daedcc 100644 --- a/Nasal/MCDU/ARRIVAL.nas +++ b/Nasal/MCDU/ARRIVAL.nas @@ -251,7 +251,7 @@ var arrivalPage = { me.arrAirport = findAirportsByICAO(left(me.id, 4)); } if (me.selectedApproach != nil) { - me._stars = me.arrAirport[0].stars(me.selectedApproach.id); + me._stars = me.arrAirport[0].stars(me.selectedApproach.runways[0]); } else { me._stars = me.arrAirport[0].stars(); } @@ -307,12 +307,35 @@ var arrivalPage = { } canvas_mcdu.pageSwitch[me.computer].setBoolValue(0); }, + clearTransitions: func() { + me.R2 = [nil, "TRANS", "wht"]; + me.R3 = [nil, "TRANS", "wht"]; + me.R4 = [nil, "TRANS", "wht"]; + me.R5 = [nil, "TRANS", "wht"]; + me.arrowsMatrix[1][1] = 0; + me.arrowsColour[1][1] = "ack"; + me.arrowsMatrix[1][2] = 0; + me.arrowsColour[1][2] = "ack"; + me.arrowsMatrix[1][3] = 0; + me.arrowsColour[1][3] = "ack"; + me.arrowsMatrix[1][4] = 0; + me.arrowsColour[1][4] = "ack"; + }, updateTransitions: func() { if (me.arrAirport == nil) { me.arrAirport = findAirportsByICAO(left(me.id, 4)); } - debug.dump(me.selectedSTAR); - debug.dump(me.arrAirport[0]); + if (me.selectedSTAR == nil) { + me.R2 = ["NO TRANS ", "TRANS", "blu"]; + if (!me.hasPressNoTrans) { + me.arrowsMatrix[1][1] = 1; + me.arrowsColour[1][1] = "blu"; + } else { + me.arrowsMatrix[1][1] = 0; + me.arrowsColour[1][1] = "ack"; + } + return; + } me._transitions = me.arrAirport[0].getStar(me.selectedSTAR).transitions; me.transitions = sort(me._transitions,func(a,b) cmp(a,b)); @@ -387,8 +410,12 @@ var arrivalPage = { me.scrollStars = 0; } me.updateSTARs(); + if (me.selectedSTAR == nil) { + me.clearTransitions(); + } else { + me.updateTransitions(); + } me.hasPressNoTrans = 0; - me.updateTransitions(); } } }, @@ -408,8 +435,12 @@ var arrivalPage = { me.scrollStars = size(me.stars) - 4; } me.updateSTARs(); + if (me.selectedSTAR == nil) { + me.clearTransitions(); + } else { + me.updateTransitions(); + } me.hasPressNoTrans = 0; - me.updateTransitions(); } } }, diff --git a/Nasal/MCDU/DEPARTURE.nas b/Nasal/MCDU/DEPARTURE.nas index 2b2037a7..50e864ed 100644 --- a/Nasal/MCDU/DEPARTURE.nas +++ b/Nasal/MCDU/DEPARTURE.nas @@ -306,11 +306,36 @@ var departurePage = { } canvas_mcdu.pageSwitch[me.computer].setBoolValue(0); }, + clearTransitions: func() { + me.R2 = [nil, "TRANS", "wht"]; + me.R3 = [nil, "TRANS", "wht"]; + me.R4 = [nil, "TRANS", "wht"]; + me.R5 = [nil, "TRANS", "wht"]; + me.arrowsMatrix[1][1] = 0; + me.arrowsColour[1][1] = "ack"; + me.arrowsMatrix[1][2] = 0; + me.arrowsColour[1][2] = "ack"; + me.arrowsMatrix[1][3] = 0; + me.arrowsColour[1][3] = "ack"; + me.arrowsMatrix[1][4] = 0; + me.arrowsColour[1][4] = "ack"; + }, updateTransitions: func() { if (me.depAirport == nil) { me.depAirport = findAirportsByICAO(left(me.id, 4)); } + if (me.selectedSID == nil) { + me.R2 = ["NO TRANS ", "TRANS", "blu"]; + if (!me.hasPressNoTrans) { + me.arrowsMatrix[1][1] = 1; + me.arrowsColour[1][1] = "blu"; + } else { + me.arrowsMatrix[1][1] = 0; + me.arrowsColour[1][1] = "ack"; + } + return; + } me._transitions = me.depAirport[0].getSid(me.selectedSID).transitions; me.transitions = sort(me._transitions,func(a,b) cmp(a,b)); @@ -385,8 +410,12 @@ var departurePage = { me.scrollSids = 0; } me.updateSIDs(); + if (me.selectedSID == nil) { + me.clearTransitions(); + } else { + me.updateTransitions(); + } me.hasPressNoTrans = 0; - me.updateTransitions(); } } }, @@ -406,8 +435,12 @@ var departurePage = { me.scrollSids = size(me.sids) - 4; } me.updateSIDs(); + if (me.selectedSID == nil) { + me.clearTransitions(); + } else { + me.updateTransitions(); + } me.hasPressNoTrans = 0; - me.updateTransitions(); } } }, diff --git a/Nasal/MCDU/F-PLN-rework.nas b/Nasal/MCDU/F-PLN-rework.nas index 2e91c962..d178058a 100644 --- a/Nasal/MCDU/F-PLN-rework.nas +++ b/Nasal/MCDU/F-PLN-rework.nas @@ -78,20 +78,20 @@ var fplnItem = { if (me.wp.wp_name == "DISCONTINUITY") { canvas_mcdu.myLatRev[me.computer] = latRev.new(4, "DISCON", me.index, me.computer); } elsif (fmgc.flightPlanController.temporaryFlag[me.computer]) { - if (left(me.wp.wp_name, 4) == fmgc.flightPlanController.flightplans[me.computer].departure.id) { - canvas_mcdu.myLatRev[me.computer] = latRev.new(0, left(me.wp.wp_name, 4), me.index, me.computer); - } elsif (me.index == fmgc.flightPlanController.arrivalIndex[me.computer]) { + if (me.index == fmgc.flightPlanController.arrivalIndex[me.computer]) { canvas_mcdu.myLatRev[me.computer] = latRev.new(1, left(me.wp.wp_name, 4), me.index, me.computer); + } if (left(me.wp.wp_name, 4) == fmgc.flightPlanController.flightplans[me.computer].departure.id) { + canvas_mcdu.myLatRev[me.computer] = latRev.new(0, left(me.wp.wp_name, 4), me.index, me.computer); } elsif (me.index == (fmgc.flightPlanController.currentToWptIndex.getValue() - 1)) { canvas_mcdu.myLatRev[me.computer] = latRev.new(2, me.wp.wp_name, me.index, me.computer); } else { canvas_mcdu.myLatRev[me.computer] = latRev.new(3, me.wp.wp_name, me.index, me.computer); } } else { - if (left(me.wp.wp_name, 4) == fmgc.flightPlanController.flightplans[2].departure.id) { - canvas_mcdu.myLatRev[me.computer] = latRev.new(0, left(me.wp.wp_name, 4), me.index, me.computer); - } elsif (me.index == fmgc.flightPlanController.arrivalIndex[2]) { + if (me.index == fmgc.flightPlanController.arrivalIndex[2]) { canvas_mcdu.myLatRev[me.computer] = latRev.new(1, left(me.wp.wp_name, 4), me.index, me.computer); + } elsif (left(me.wp.wp_name, 4) == fmgc.flightPlanController.flightplans[2].departure.id) { + canvas_mcdu.myLatRev[me.computer] = latRev.new(0, left(me.wp.wp_name, 4), me.index, me.computer); } elsif (me.index == (fmgc.flightPlanController.currentToWptIndex.getValue() - 1)) { canvas_mcdu.myLatRev[me.computer] = latRev.new(2, me.wp.wp_name, me.index, me.computer); } else { @@ -298,7 +298,7 @@ var fplnPage = { # this one is only created once, and then updated - remember th } }, pushButtonLeft: func(index) { - if (index == 1 and size(getprop("/MCDU[" ~ me.computer ~ "]/scratchpad")) > 0) { + if (left(me.L6[0], 4) == getprop("/FMGC/internal/dep-arpt") and size(getprop("/MCDU[" ~ me.computer ~ "]/scratchpad")) > 0) { notAllowed(me.computer); return; } diff --git a/Nasal/MCDU/LATREV.nas b/Nasal/MCDU/LATREV.nas index 168e446c..0100ef22 100644 --- a/Nasal/MCDU/LATREV.nas +++ b/Nasal/MCDU/LATREV.nas @@ -127,76 +127,14 @@ var latRev = { }, nextWpt: func() { me.makeTmpy(); - me.R3 = [getprop("/MCDU[" ~ me.computer ~ "]/scratchpad"), "NEXT WPT ", "yel"]; - me.fontMatrix[1][2] = 0; - # check if it is part of the active f-pln, if so delete intermediate wpts, if not create discontinuiity after it with original wpts - if (size(me.R3[0]) == 5) { - var fix = findFixesByID(me.R3[0]); - if (size(fix) >= 1) { - var indexWp = fmgc.flightPlanController.flightplans[me.computer].indexOfWP(fix[0]); - if (indexWp == -1) { - var _insert = fmgc.flightPlanController.insertFix(me.R3[0], me.index + 1, me.computer); - fmgc.flightPlanController.flightplans[me.computer].insertWP(createDiscontinuity(), me.index + 2); - fmgc.flightPlanController.flightPlanChanged(me.computer); - } else { - var numTimesDelete = indexWp - me.index; - while (numTimesDelete > 1) { - fmgc.flightPlanController.deleteWP(me.index + 1, me.computer.mcdu, 0); - numTimesDelete -= 1; - } - var _insert = 0; - } - } else { - var _insert = 1; - } - } elsif (size(me.R3[0]) == 4) { - var airport = findAirportsByICAO(me.R3[0]); - if (size(airport) >= 1) { - var indexWp = fmgc.flightPlanController.flightplans[me.computer].indexOfWP(fix[0]); - if (indexWp == -1) { - var _insert = fmgc.flightPlanController.insertArpt(me.R3[0], me.index + 1, me.computer); - fmgc.flightPlanController.flightplans[me.computer].insertWP(createDiscontinuity(), me.index + 2); - fmgc.flightPlanController.flightPlanChanged(me.computer); - } else { - var numTimesDelete = indexWp - me.index; - while (numTimesDelete > 1) { - fmgc.flightPlanController.deleteWP(me.index + 1, me.computer.mcdu, 0); - numTimesDelete -= 1; - } - var _insert = 0; - } - } else { - var _insert = 1; - } - } elsif (size(me.R3[0]) == 3 or size(me.R3[0]) == 2) { - var navaid = findNavaidsByID(me.R3[0]); - if (size(navaid) >= 1) { - var indexWp = fmgc.flightPlanController.flightplans[me.computer].indexOfWP(navaid[0]); - if (indexWp == -1) { - var _insert = fmgc.flightPlanController.insertNavaid(me.R3[0], me.index + 1, me.computer); - fmgc.flightPlanController.flightplans[me.computer].insertWP(createDiscontinuity(), me.index + 2); - fmgc.flightPlanController.flightPlanChanged(me.computer); - } else { - var numTimesDelete = indexWp - me.index; - while (numTimesDelete > 1) { - fmgc.flightPlanController.deleteWP(me.index + 1, me.computer.mcdu, 0); - numTimesDelete -= 1; - } - var _insert = 0; - } - } else { - var _insert = 1; - } - } else { - formatError(me.computer); - } - - if (_insert == 1) { + var returny = fmgc.flightPlanController.scratchpad(getprop("/MCDU[" ~ me.computer ~ "]/scratchpad"), me.index + 1, me.computer); + if (returny == 0) { notInDataBase(me.computer); - } elsif (_insert == 2) { + } elsif (returny == 1) { notAllowed(me.computer); } else { + setprop("/MCDU[" ~ me.computer ~ "]/scratchpad-msg", ""); setprop("/MCDU[" ~ me.computer ~ "]/scratchpad", ""); fmgc.flightPlanController.flightPlanChanged(me.computer); setprop("/MCDU[" ~ me.computer ~ "]/page", "F-PLNA"); diff --git a/Nasal/MCDU/VERTREV.nas b/Nasal/MCDU/VERTREV.nas new file mode 100644 index 00000000..c6478fb8 --- /dev/null +++ b/Nasal/MCDU/VERTREV.nas @@ -0,0 +1,182 @@ +var vertrev = { + title: [nil, nil, nil], + subtitle: [nil, nil], + fontMatrix: [[0, 0, 0, 0, 0, 0],[0, 0, 0, 0, 0, 0]], + arrowsMatrix: [[0, 0, 0, 0, 0, 0],[0, 0, 0, 0, 0, 0]], + arrowsColour: [["ack", "ack", "ack", "ack", "ack", "ack"],["ack", "ack", "ack", "ack", "ack", "ack"]], + L1: [nil, nil, "ack"], # content, title, colour + L2: [nil, nil, "ack"], + L3: [nil, nil, "ack"], + L4: [nil, nil, "ack"], + L5: [nil, nil, "ack"], + L6: [nil, nil, "ack"], + R1: [nil, nil, "ack"], + R2: [nil, nil, "ack"], + R3: [nil, nil, "ack"], + R4: [nil, nil, "ack"], + R5: [nil, nil, "ack"], + R6: [nil, nil, "ack"], + depAirport: nil, + arrAirport: nil, + index: nil, + computer: nil, + new: func(type, id, index, computer) { + var lr = {parents:[vertrev]}; + lr.type = type; # 0 = origin 1 = destination 2 = ppos (from waypoint) 3 = generic wpt, 4 = discon + lr.id = id; + lr.index = index; + lr.computer = computer; + lr._setupPageWithData(); + lr._checkTmpy(); + return lr; + }, + del: func() { + return nil; + }, + _checkTmpy: func() { + if (fmgc.flightPlanController.temporaryFlag[me.computer]) { + me.L6 = [" F-PLN", " TMPY", "yel"]; + me.arrowsColour[0][5] = "yel"; + me.R2[2] = "yel"; + me.R3[2] = "yel"; + me.R4[2] = "yel"; + canvas_mcdu.pageSwitch[me.computer].setBoolValue(0); + } + }, + _setupPageWithData: func() { + if (me.type == 2) { + me.title = ["VERT REV", " AT ", "PPOS"]; + me.L2 = [" OFFSET", nil, "wht"]; + me.L3 = [" HOLD", nil, "wht"]; + me.L6 = [" RETURN", nil, "wht"]; + me.R1 = ["FIX INFO ", nil, "wht"]; + me.R2 = ["[ ]°/[ ]°/[ ]", "LL XING/INCR/NO", "blu"]; + me.arrowsMatrix = [[0, 1, 1, 0, 0, 1], [1, 0, 0, 0, 0, 0]]; + me.arrowsColour = [["ack", "wht", "wht", "ack", "ack", "wht"], ["wht", "ack", "ack", "ack", "ack", "ack"]]; + me.fontMatrix = [[0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0]]; + } elsif (me.type == 4) { + me.title = ["VERT REV", " AT ", "DISCON"]; + me.R3 = ["[ ]", "NEXT WPT ", "blu"]; + me.R4 = ["[ ]", "NEW DEST", "blu"]; + me.L6 = [" RETURN", nil, "wht"]; + me.arrowsMatrix = [[0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0]]; + me.arrowsColour = [["ack", "ack", "ack", "ack", "ack", "wht"], ["ack", "ack", "ack", "ack", "ack", "ack"]]; + me.fontMatrix = [[0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 0, 0]]; + } else { + me.title = ["VERT REV", " AT ", me.id]; + + if (me.type == 0) { + if (size(me.id) > 4) { + me.depAirport = findAirportsByICAO(left(me.id, 4)); + } else { + me.depAirport = findAirportsByICAO(me.id); + } + me.subtitle = [dmsToString(sprintf(me.depAirport[0].lat), "lat"), dmsToString(sprintf(me.depAirport[0].lon), "lon")]; + me.L1 = [" DEPARTURE", nil, "wht"]; + me.L2 = [" OFFSET", nil, "wht"]; + me.L6 = [" RETURN", nil, "wht"]; + me.R1 = ["FIX INFO ", nil, "wht"]; + me.R2 = ["[ ]°/[ ]°/[ ]", "LL XING/INCR/NO", "blu"]; + me.R3 = ["[ ]", "NEXT WPT ", "blu"]; + me.R4 = ["[ ]", "NEW DEST", "blu"]; + me.arrowsMatrix = [[1, 1, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0]]; + me.arrowsColour = [["wht", "wht", "ack", "ack", "ack", "wht"], ["wht", "ack", "ack", "ack", "ack", "ack"]]; + me.fontMatrix = [[0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 0, 0]]; + } elsif (me.type == 1) { + if (size(me.id) > 4) { + me.arrAirport = findAirportsByICAO(left(me.id, 4)); + } else { + me.arrAirport = findAirportsByICAO(me.id); + } + me.subtitle = [dmsToString(sprintf(me.arrAirport[0].lat), "lat"), dmsToString(sprintf(me.arrAirport[0].lon), "lon")]; + me.L3 = [" ALTN", nil, "wht"]; + me.L4 = [" ALTN", " ENABLE", "blu"]; + me.L6 = [" RETURN", nil, "wht"]; + me.R1 = ["ARRIVAL ", nil, "wht"]; + me.R3 = ["[ ]", "NEXT WPT ", "blu"]; + me.arrowsMatrix = [[0, 0, 1, 1, 0, 1], [1, 0, 0, 0, 0, 0]]; + me.arrowsColour = [["ack", "ack", "wht", "blu", "ack", "wht"], ["wht", "ack", "ack", "ack", "ack", "ack"]]; + me.fontMatrix = [[0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0]]; + } elsif (me.type == 3) { + if (size(me.id) == 2 or size(me.id) == 3) { + me.wpt = findNavaidsByID(me.id); + } elsif (size(me.id) == 4) { + me.wpt = findAirportsByICAO(me.id); + } elsif (size(me.id) == 5) { + me.wpt = findFixesByID(me.id); + } + me.subtitle = [dmsToString(sprintf(me.wpt[0].lat), "lat"), dmsToString(sprintf(me.wpt[0].lon), "lon")]; + me.L3 = [" HOLD", nil, "wht"]; + me.L4 = [" ALTN", " ENABLE", "blu"]; + me.L6 = [" RETURN", nil, "wht"]; + me.R1 = ["FIX INFO ", nil, "wht"]; + me.R3 = ["[ ]", "NEXT WPT ", "blu"]; + me.R4 = ["[ ]", "NEW DEST", "blu"]; + me.R5 = ["AIRWAYS ", nil, "wht"]; + me.arrowsMatrix = [[0, 0, 1, 1, 0, 1], [1, 0, 0, 0, 1, 0]]; + me.arrowsColour = [["ack", "ack", "wht", "blu", "ack", "wht"], ["wht", "ack", "ack", "ack", "wht", "ack"]]; + me.fontMatrix = [[0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 0, 0]]; + } + } + }, + makeTmpy: func() { + if (!fmgc.flightPlanController.temporaryFlag[me.computer]) { + fmgc.flightPlanController.createTemporaryFlightPlan(me.computer); + me._checkTmpy(); + } + }, + nextWpt: func() { + me.makeTmpy(); + + var returny = fmgc.flightPlanController.scratchpad(getprop("/MCDU[" ~ me.computer ~ "]/scratchpad"), me.index + 1, me.computer); + if (returny == 0) { + notInDataBase(me.computer); + } elsif (returny == 1) { + notAllowed(me.computer); + } else { + setprop("/MCDU[" ~ me.computer ~ "]/scratchpad-msg", ""); + setprop("/MCDU[" ~ me.computer ~ "]/scratchpad", ""); + fmgc.flightPlanController.flightPlanChanged(me.computer); + setprop("/MCDU[" ~ me.computer ~ "]/page", "F-PLNA"); + } + }, +}; + +var dmsToString = func(dms, type) { + var degrees = int(dms); + var minutes = sprintf("%.1f",abs((dms - degrees) * 60)); + if (type == "lat") { + var sign = degrees >= 0 ? "N" : "S"; + } else { + var sign = degrees >= 0 ? "E" : "W"; + } + return abs(degrees) ~ "g" ~ minutes ~ " " ~ sign; +} + + +var stringToDegrees = func(string, type) { + if (type == "lat") { + var degrees = left(string, 2); + var minutesStr = right(string, 5); + } else { + var degrees = left(string, 3); + var minutesStr = right(string, 5); + } + + var minutes = left(minutesStr, 4); + var sign = right(minutesStr, 1); + var decimal = degrees + (minutes / 60); + if (type == "lat") { + if (sign == "N") { + return decimal; + } else { + return -decimal; + } + } else { + if (sign == "E") { + return decimal; + } else { + return -decimal; + } + } +} \ No newline at end of file diff --git a/Sounds/A320-common-sound.xml b/Sounds/A320-common-sound.xml index f7bfe05e..9c690b66 100644 --- a/Sounds/A320-common-sound.xml +++ b/Sounds/A320-common-sound.xml @@ -1557,9 +1557,11 @@ once avionics - /sim/current-view/internal /sim/sound/warnings/chime + + /sim/current-view/internal + 10 100 From ad5a12532a711f8d06c9d0799741a4ef06f41331 Mon Sep 17 00:00:00 2001 From: legoboyvdlp R Date: Thu, 23 Jan 2020 17:02:46 +0000 Subject: [PATCH 14/51] Bugfix --- Nasal/FMGC/flightplan.nas | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Nasal/FMGC/flightplan.nas b/Nasal/FMGC/flightplan.nas index c7e05244..0bcef3b3 100644 --- a/Nasal/FMGC/flightplan.nas +++ b/Nasal/FMGC/flightplan.nas @@ -394,7 +394,7 @@ var flightPlanController = { wpDistancePrev[n][wpt].setValue(courseDistanceFrom[1]); } - if (left(wpID[n][wpt].getValue(), 4) == FMGCarr.getValue()) { + 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 me.arrivalIndex[n] = wpt; if (canvas_mcdu.myFpln[0] != nil) { From af67b66bfe8dcdb0797f1f0b2ee4ecd27a819af5 Mon Sep 17 00:00:00 2001 From: legoboyvdlp R Date: Sun, 2 Feb 2020 20:34:27 +0000 Subject: [PATCH 15/51] Fix the flightplan, now will show up properly on ND (ID and course), also advancing should work now. However, _num_ doesn't advance atm? --- Nasal/FMGC/FMGC-b.nas | 12 ++++++------ Nasal/FMGC/FMGC.nas | 2 +- Nasal/FMGC/flightplan.nas | 25 ++++++++++++++++++------- 3 files changed, 25 insertions(+), 14 deletions(-) diff --git a/Nasal/FMGC/FMGC-b.nas b/Nasal/FMGC/FMGC-b.nas index 23274bf0..9eeef172 100644 --- a/Nasal/FMGC/FMGC-b.nas +++ b/Nasal/FMGC/FMGC-b.nas @@ -388,14 +388,14 @@ var ITAF = { # If in LNAV mode and route is not longer active, switch to HDG HLD if (Output.lat.getValue() == 1) { # Only evaulate the rest of the condition if we are in LNAV mode - if (FPLN.num == 0 or !FPLN.active.getBoolValue()) { + if (flightPlanController.num[2].getValue() == 0 or !FPLN.active.getBoolValue()) { me.setLatMode(3); } } # Waypoint Advance Logic - if (flightPlanController.num[2] > 0 and FPLN.activeTemp == 1) { - if ((FPLN.currentWPTemp + 1) < flightPlanController.num[2]) { + if (flightPlanController.num[2].getValue() > 0 and FPLN.activeTemp == 1) { + if ((FPLN.currentWPTemp + 1) < flightPlanController.num[2].getValue()) { Velocity.groundspeedMps = Velocity.groundspeedKt.getValue() * 0.5144444444444; FPLN.wpFlyFrom = FPLN.currentWPTemp; if (FPLN.wpFlyFrom < 0) { @@ -430,7 +430,7 @@ var ITAF = { if (FPLN.wp0Dist.getValue() <= FPLN.turnDist) { if (flightPlanController.currentToWptIndex < 1) { flightPlanController.currentToWptIndex = 1; - } else if (flightPlanController.num[2] > 2) { # The Airbus doesn't display anything past the previous waypoint after advancing + } else if (flightPlanController.num[2].getValue() > 2) { # The Airbus doesn't display anything past the previous waypoint after advancing flightPlanController.autoSequencing(); } } @@ -601,7 +601,7 @@ var ITAF = { Custom.showHdg.setBoolValue(1); me.armTextCheck(); } else if (n == 1) { - if (flightPlanController.num[2] > 0 and FPLN.active.getBoolValue()) { + if (flightPlanController.num[2].getValue() > 0 and FPLN.active.getBoolValue()) { Output.lnavArm.setBoolValue(1); Custom.showHdg.setBoolValue(0); me.armTextCheck(); @@ -738,7 +738,7 @@ var ITAF = { } }, checkLNAV: func(t) { - if (flightPlanController.num[2] > 0 and FPLN.active.getBoolValue() and Position.gearAglFt.getValue() >= 30) { + if (flightPlanController.num[2].getValue() > 0 and FPLN.active.getBoolValue() and Position.gearAglFt.getValue() >= 30) { me.activateLNAV(); } else if (Output.lat.getValue() != 1 and t != 1) { Output.lnavArm.setBoolValue(1); diff --git a/Nasal/FMGC/FMGC.nas b/Nasal/FMGC/FMGC.nas index 664bcff0..41de72d6 100644 --- a/Nasal/FMGC/FMGC.nas +++ b/Nasal/FMGC/FMGC.nas @@ -230,7 +230,7 @@ var masterFMGC = maketimer(0.2, func { setprop("/FMGC/status/phase", "5"); } - if (flightPlanController.num[2] > 0 and getprop("/FMGC/flightplan[2]/active") == 1 and flightPlanController.arrivalDist <= 15) { + if (flightPlanController.num[2].getValue() > 0 and getprop("/FMGC/flightplan[2]/active") == 1 and flightPlanController.arrivalDist <= 15) { setprop("/FMGC/internal/decel", 1); } else if (getprop("/FMGC/internal/decel") == 1 and (phase == 0 or phase == 6)) { setprop("/FMGC/internal/decel", 0); diff --git a/Nasal/FMGC/flightplan.nas b/Nasal/FMGC/flightplan.nas index 0bcef3b3..18975b05 100644 --- a/Nasal/FMGC/flightplan.nas +++ b/Nasal/FMGC/flightplan.nas @@ -36,13 +36,13 @@ var flightPlanController = { currentToWpt: nil, # container for the current TO waypoint ghost currentToWptIndex: props.globals.initNode("/FMGC/flightplan[2]/current-wp", 0, "INT"), - currentToWptID: "", + currentToWptID: props.globals.initNode("/FMGC/flightplan[2]/current-leg", "", "STRING"), courseToWpt: props.globals.initNode("/FMGC/flightplan[2]/current-leg-course", 0, "DOUBLE"), courseMagToWpt: props.globals.initNode("/FMGC/flightplan[2]/current-leg-course-mag", 0, "DOUBLE"), distToWpt: props.globals.initNode("/FMGC/flightplan[2]/current-leg-dist", 0, "DOUBLE"),, distanceToDest: [0, 0, 0], - num: [0, 0, 0], + num: [props.globals.initNode("/FMGC/flightplan[0]/num", 0, "INT"), props.globals.initNode("/FMGC/flightplan[1]/num", 0, "INT"), props.globals.initNode("/FMGC/flightplan[2]/num", 0, "INT")], arrivalIndex: [0, 0, 0], arrivalDist: 0, _arrivalDist: 0, @@ -94,7 +94,7 @@ var flightPlanController = { }, autoSequencing: func() { - if (me.num[2] > 2) { + if (me.num[2].getValue() > 2) { if (me.temporaryFlag[0] == 1 and wpID[0][0] == wpID[2][0]) { me.deleteWP(0, 0); } @@ -427,7 +427,9 @@ var flightPlanController = { me.currentToWpt = me.flightplans[i].getWP(me.currentToWptIndex.getValue()); - me.currentToWptId = me.currentToWpt.wp_name; + if (me.currentToWptID.getValue() != me.currentToWpt.wp_name) { + me.currentToWptID.setValue(me.currentToWpt.wp_name); + } me.courseToWpt.setValue(me.currentToWpt.courseAndDistanceFrom(curAircraftPos)[0]); me.distToWpt.setValue(me.currentToWpt.courseAndDistanceFrom(curAircraftPos)[1]); @@ -437,15 +439,24 @@ var flightPlanController = { return; } - me.num[i] = me.flightplans[i].getPlanSize(); + print("x"); + if (me.num[i].getValue() != me.flightplans[i].getPlanSize()) { + me.num[i].setValue(me.flightplans[i].getPlanSize()); + print("y"); + } + print("z"); } else { if (i == 2) { if (me.active.getBoolValue()) { me.active.setValue(0); } - me.currentToWptID = ""; + if (me.currentToWptID.getValue() != "") { + me.currentToWptID.setValue(""); + } + } + if (me.num[i].getValue() != 0) { + me.num[i].setValue(0); } - me.num[i] = 0; } } }, From 4f4c45782edecbea523a6751d307722edb50fdee Mon Sep 17 00:00:00 2001 From: legoboyvdlp R Date: Mon, 3 Feb 2020 17:45:00 +0000 Subject: [PATCH 16/51] Fix the num --- Nasal/FMGC/FMGC-b.nas | 4 ++-- Nasal/FMGC/flightplan.nas | 43 +++++++++++++++++++-------------------- 2 files changed, 23 insertions(+), 24 deletions(-) diff --git a/Nasal/FMGC/FMGC-b.nas b/Nasal/FMGC/FMGC-b.nas index 9eeef172..3125af6a 100644 --- a/Nasal/FMGC/FMGC-b.nas +++ b/Nasal/FMGC/FMGC-b.nas @@ -428,8 +428,8 @@ var ITAF = { Internal.lnavAdvanceNm.setValue(FPLN.turnDist); if (FPLN.wp0Dist.getValue() <= FPLN.turnDist) { - if (flightPlanController.currentToWptIndex < 1) { - flightPlanController.currentToWptIndex = 1; + if (flightPlanController.currentToWptIndex.getValue() < 1) { + flightPlanController.currentToWptIndex.setValue(1); } else if (flightPlanController.num[2].getValue() > 2) { # The Airbus doesn't display anything past the previous waypoint after advancing flightPlanController.autoSequencing(); } diff --git a/Nasal/FMGC/flightplan.nas b/Nasal/FMGC/flightplan.nas index 18975b05..afbd571c 100644 --- a/Nasal/FMGC/flightplan.nas +++ b/Nasal/FMGC/flightplan.nas @@ -373,16 +373,18 @@ var flightPlanController = { if (wpt > 0) { if (me.flightplans[n].getWP(wpt).id == "DISCONTINUITY") { - wpCoursePrev[n][wpt].setValue(0); - wpDistancePrev[n][wpt].setValue(0); - continue; + wpCoursePrev[n][wpt].setValue(0); + wpDistancePrev[n][wpt].setValue(0); + continue; } - if (me.flightplans[n].getWP(wpt - 1).id == "DISCONTINUITY") { - geoPosPrev.set_latlon(me.flightplans[n].getWP(wpt - 2).lat, me.flightplans[n].getWP(wpt - 2).lon); - } else { + #if (me.flightplans[n].getWP(wpt - 1).id == "DISCONTINUITY") { + # if (wpt >= 2) { + # geoPosPrev.set_latlon(me.flightplans[n].getWP(wpt - 2).lat, me.flightplans[n].getWP(wpt - 2).lon); + # } + #} else { geoPosPrev.set_latlon(me.flightplans[n].getWP(wpt - 1).lat, me.flightplans[n].getWP(wpt - 1).lon); - } + #} courseDistanceFromPrev = waypointHashStore.courseAndDistanceFrom(geoPosPrev); wpCoursePrev[n][wpt].setValue(courseDistanceFromPrev[0]); @@ -412,20 +414,20 @@ var flightPlanController = { }, updateCurrentWaypoint: func() { - for (var i = 0; i <= 2; i += 1) { - if (toFromSet.getBoolValue() and me.flightplans[i].departure != nil and me.flightplans[i].destination != nil) { # check if flightplan exists + 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 var curAircraftPos = geo.aircraft_position(); # don't want to get this corrupted so make sure it is a local variable - if (i == 2) { # main plan + if (india == 2) { # main plan if (!me.active.getBoolValue()) { me.active.setValue(1); } - if (me.currentToWptIndex.getValue() > me.flightplans[i].getPlanSize()) { - me.currentToWptIndex.setValue(me.flightplans[i].getPlanSize()); + if (me.currentToWptIndex.getValue() > me.flightplans[india].getPlanSize()) { + me.currentToWptIndex.setValue(me.flightplans[india].getPlanSize()); } - me.currentToWpt = me.flightplans[i].getWP(me.currentToWptIndex.getValue()); + me.currentToWpt = me.flightplans[india].getWP(me.currentToWptIndex.getValue()); if (me.currentToWptID.getValue() != me.currentToWpt.wp_name) { me.currentToWptID.setValue(me.currentToWpt.wp_name); @@ -436,17 +438,13 @@ var flightPlanController = { magTrueError = magHDG.getValue() - trueHDG.getValue(); me.courseMagToWpt.setValue(me.courseToWpt.getValue() + magTrueError); - return; } - print("x"); - if (me.num[i].getValue() != me.flightplans[i].getPlanSize()) { - me.num[i].setValue(me.flightplans[i].getPlanSize()); - print("y"); + if (me.num[india].getValue() != me.flightplans[india].getPlanSize()) { + me.num[india].setValue(me.flightplans[india].getPlanSize()); } - print("z"); } else { - if (i == 2) { + if (india == 2) { if (me.active.getBoolValue()) { me.active.setValue(0); } @@ -454,8 +452,9 @@ var flightPlanController = { me.currentToWptID.setValue(""); } } - if (me.num[i].getValue() != 0) { - me.num[i].setValue(0); + + if (me.num[india].getValue() != 0) { + me.num[india].setValue(0); } } } From 80fdd62d4baebe03d73493eda76cc08060e04e45 Mon Sep 17 00:00:00 2001 From: legoboyvdlp R Date: Mon, 3 Feb 2020 19:16:05 +0000 Subject: [PATCH 17/51] fix --- Nasal/FMGC/flightplan.nas | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Nasal/FMGC/flightplan.nas b/Nasal/FMGC/flightplan.nas index afbd571c..4c60ff75 100644 --- a/Nasal/FMGC/flightplan.nas +++ b/Nasal/FMGC/flightplan.nas @@ -103,7 +103,7 @@ var flightPlanController = { me.deleteWP(0, 1); } - me.deleteWP(0, 2); + me.deleteWP(0, 2, 0, 1); } }, @@ -116,12 +116,12 @@ var flightPlanController = { me.flightplans[n].insertWP(createWP(geo.aircraft_position(), "PPOS"), 0); }, - deleteWP: func(index, n, a = 0) { # a = 1, means adding a waypoint via deleting intermediate + deleteWP: func(index, n, a = 0, s = 0) { # a = 1, means adding a waypoint via deleting intermediate var wp = wpID[n][index].getValue(); if (wp != FMGCdep.getValue() and wp != FMGCarr.getValue() 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); - if (me.flightplans[n].getWP(index) != nil) { + if (me.flightplans[n].getWP(index) != nil and s == 0) { if (me.flightplans[n].getWP(index).id != "DISCONTINUITY") { # else, if the next one isn't a discont, add one me.addDiscontinuity(index, n); } From 5e19cbd42cf9391238d308fa2895680711ecf6f7 Mon Sep 17 00:00:00 2001 From: legoboyvdlp R Date: Tue, 11 Feb 2020 14:30:28 +0000 Subject: [PATCH 18/51] go to next waypoint, don't delete intermediate. MCDU only shows next ones, doesn't show historical ones --- Nasal/FMGC/flightplan.nas | 9 +++++---- Nasal/MCDU/F-PLN-rework.nas | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Nasal/FMGC/flightplan.nas b/Nasal/FMGC/flightplan.nas index 4c60ff75..a06bb5bf 100644 --- a/Nasal/FMGC/flightplan.nas +++ b/Nasal/FMGC/flightplan.nas @@ -96,14 +96,15 @@ var flightPlanController = { autoSequencing: func() { if (me.num[2].getValue() > 2) { if (me.temporaryFlag[0] == 1 and wpID[0][0] == wpID[2][0]) { - me.deleteWP(0, 0); + #me.deleteWP(0, 0); } if (me.temporaryFlag[1] == 1 and wpID[1][0] == wpID[2][0]) { - me.deleteWP(0, 1); + #me.deleteWP(0, 1); } - me.deleteWP(0, 2, 0, 1); + # me.deleteWP(0, 2, 0, 1); + me.currentToWptIndex.setValue(me.currentToWptIndex.getValue() + 1); } }, @@ -116,7 +117,7 @@ var flightPlanController = { me.flightplans[n].insertWP(createWP(geo.aircraft_position(), "PPOS"), 0); }, - deleteWP: func(index, n, a = 0, s = 0) { # a = 1, means adding a waypoint via deleting intermediate + deleteWP: func(index, n, a = 0, s = 0) { # a = 1, means adding a waypoint via deleting intermediate s = 1, means skip adding discontinuity var wp = wpID[n][index].getValue(); if (wp != FMGCdep.getValue() and wp != FMGCarr.getValue() 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 diff --git a/Nasal/MCDU/F-PLN-rework.nas b/Nasal/MCDU/F-PLN-rework.nas index d178058a..697d2956 100644 --- a/Nasal/MCDU/F-PLN-rework.nas +++ b/Nasal/MCDU/F-PLN-rework.nas @@ -204,11 +204,11 @@ var fplnPage = { # this one is only created once, and then updated - remember th createPlanList: func() { me.planList = []; if (me.temporaryFlagFpln) { - for (var i = 0; i < me.plan.getPlanSize(); i += 1) { + for (var i = fmgc.flightPlanController.currentToWptIndex.getValue(); i < me.plan.getPlanSize(); i += 1) { append(me.planList, fplnItem.new(me.plan.getWP(i), i, me.plan, me.computer, "yel")); } } else { - for (var i = 0; i < me.plan.getPlanSize(); i += 1) { + for (var i = fmgc.flightPlanController.currentToWptIndex.getValue(); i < me.plan.getPlanSize(); i += 1) { append(me.planList, fplnItem.new(me.plan.getWP(i), i, me.plan, me.computer)); } } From 95fca8e11e70d37c56f823ce6cd5a4d5c3e39d1e Mon Sep 17 00:00:00 2001 From: legoboyvdlp R Date: Tue, 11 Feb 2020 17:01:11 +0000 Subject: [PATCH 19/51] Revert "go to next waypoint, don't delete intermediate. MCDU only shows next ones, doesn't show historical ones" t push This reverts commit 5e19cbd42cf9391238d308fa2895680711ecf6f7. --- Nasal/FMGC/flightplan.nas | 9 ++++----- Nasal/MCDU/F-PLN-rework.nas | 4 ++-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/Nasal/FMGC/flightplan.nas b/Nasal/FMGC/flightplan.nas index a06bb5bf..4c60ff75 100644 --- a/Nasal/FMGC/flightplan.nas +++ b/Nasal/FMGC/flightplan.nas @@ -96,15 +96,14 @@ var flightPlanController = { autoSequencing: func() { if (me.num[2].getValue() > 2) { if (me.temporaryFlag[0] == 1 and wpID[0][0] == wpID[2][0]) { - #me.deleteWP(0, 0); + me.deleteWP(0, 0); } if (me.temporaryFlag[1] == 1 and wpID[1][0] == wpID[2][0]) { - #me.deleteWP(0, 1); + me.deleteWP(0, 1); } - # me.deleteWP(0, 2, 0, 1); - me.currentToWptIndex.setValue(me.currentToWptIndex.getValue() + 1); + me.deleteWP(0, 2, 0, 1); } }, @@ -117,7 +116,7 @@ var flightPlanController = { me.flightplans[n].insertWP(createWP(geo.aircraft_position(), "PPOS"), 0); }, - deleteWP: func(index, n, a = 0, s = 0) { # a = 1, means adding a waypoint via deleting intermediate s = 1, means skip adding discontinuity + deleteWP: func(index, n, a = 0, s = 0) { # a = 1, means adding a waypoint via deleting intermediate var wp = wpID[n][index].getValue(); if (wp != FMGCdep.getValue() and wp != FMGCarr.getValue() 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 diff --git a/Nasal/MCDU/F-PLN-rework.nas b/Nasal/MCDU/F-PLN-rework.nas index 697d2956..d178058a 100644 --- a/Nasal/MCDU/F-PLN-rework.nas +++ b/Nasal/MCDU/F-PLN-rework.nas @@ -204,11 +204,11 @@ var fplnPage = { # this one is only created once, and then updated - remember th createPlanList: func() { me.planList = []; if (me.temporaryFlagFpln) { - for (var i = fmgc.flightPlanController.currentToWptIndex.getValue(); i < me.plan.getPlanSize(); i += 1) { + for (var i = 0; i < me.plan.getPlanSize(); i += 1) { append(me.planList, fplnItem.new(me.plan.getWP(i), i, me.plan, me.computer, "yel")); } } else { - for (var i = fmgc.flightPlanController.currentToWptIndex.getValue(); i < me.plan.getPlanSize(); i += 1) { + for (var i = 0; i < me.plan.getPlanSize(); i += 1) { append(me.planList, fplnItem.new(me.plan.getWP(i), i, me.plan, me.computer)); } } From 470b2fbcc1c21e136659543bbbad0fffefb1b465 Mon Sep 17 00:00:00 2001 From: legoboyvdlp R Date: Sat, 7 Mar 2020 15:20:20 +0000 Subject: [PATCH 20/51] Fix the CLR button, and fix distance calculation. Needs to neglect discontinuitites still, that broke agagin --- Nasal/FMGC/flightplan.nas | 4 +++- Nasal/MCDU/F-PLN-rework.nas | 4 ---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/Nasal/FMGC/flightplan.nas b/Nasal/FMGC/flightplan.nas index 4c60ff75..342c0af6 100644 --- a/Nasal/FMGC/flightplan.nas +++ b/Nasal/FMGC/flightplan.nas @@ -389,7 +389,9 @@ var flightPlanController = { courseDistanceFromPrev = waypointHashStore.courseAndDistanceFrom(geoPosPrev); wpCoursePrev[n][wpt].setValue(courseDistanceFromPrev[0]); wpDistancePrev[n][wpt].setValue(courseDistanceFromPrev[1]); - me._arrivalDist += courseDistanceFromPrev[1]; + if (me.flightplans[n].getWP(wpt - 1).wp_type != "vectors" and me.flightplans[n].getWP(wpt - 1).wp_type != "hdgToAlt" and me.flightplans[n].getWP(wpt).wp_type != "vectors" and me.flightplans[n].getWP(wpt).wp_type != "hdgToAlt") { + me._arrivalDist += courseDistanceFromPrev[1]; + } } else { # use PPOS for the first waypoint wpCoursePrev[n][wpt].setValue(courseDistanceFrom[0]); diff --git a/Nasal/MCDU/F-PLN-rework.nas b/Nasal/MCDU/F-PLN-rework.nas index d178058a..e815c3bc 100644 --- a/Nasal/MCDU/F-PLN-rework.nas +++ b/Nasal/MCDU/F-PLN-rework.nas @@ -298,10 +298,6 @@ var fplnPage = { # this one is only created once, and then updated - remember th } }, pushButtonLeft: func(index) { - if (left(me.L6[0], 4) == getprop("/FMGC/internal/dep-arpt") and size(getprop("/MCDU[" ~ me.computer ~ "]/scratchpad")) > 0) { - notAllowed(me.computer); - return; - } if (index == 6) { if (fmgc.flightPlanController.temporaryFlag[me.computer]) { fmgc.flightPlanController.destroyTemporaryFlightPlan(me.computer, 0); From e9f9c7e106b868d33098ae6f4035f379bec1bb34 Mon Sep 17 00:00:00 2001 From: legoboyvdlp R Date: Sat, 7 Mar 2020 17:38:57 +0000 Subject: [PATCH 21/51] Fix discont --- Nasal/FMGC/flightplan.nas | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/Nasal/FMGC/flightplan.nas b/Nasal/FMGC/flightplan.nas index 342c0af6..b309e9ab 100644 --- a/Nasal/FMGC/flightplan.nas +++ b/Nasal/FMGC/flightplan.nas @@ -371,25 +371,33 @@ var flightPlanController = { wpCourse[n][wpt].setValue(waypointHashStore.courseAndDistanceFrom(curAircraftPos)[0]); wpDistance[n][wpt].setValue(waypointHashStore.courseAndDistanceFrom(curAircraftPos)[1]); + if (left(wpID[n][wpt].getValue(), 4) == FMGCarr.getValue() and wpt != 0) { + if (me.arrivalIndex[n] != wpt) { + me.arrivalIndex[n] = wpt; + } + } + if (wpt > 0) { if (me.flightplans[n].getWP(wpt).id == "DISCONTINUITY") { - wpCoursePrev[n][wpt].setValue(0); - wpDistancePrev[n][wpt].setValue(0); - continue; - } - - #if (me.flightplans[n].getWP(wpt - 1).id == "DISCONTINUITY") { - # if (wpt >= 2) { - # geoPosPrev.set_latlon(me.flightplans[n].getWP(wpt - 2).lat, me.flightplans[n].getWP(wpt - 2).lon); - # } - #} else { + if (me.flightplans[n].getWP(wpt - 1).id == "DISCONTINUITY") { + if (wpt >= 2) { + geoPosPrev.set_latlon(me.flightplans[n].getWP(wpt - 2).lat, me.flightplans[n].getWP(wpt - 2).lon); + } + } else { + geoPosPrev.set_latlon(me.flightplans[n].getWP(wpt - 1).lat, me.flightplans[n].getWP(wpt - 1).lon); + } + } elsif (me.flightplans[n].getWP(wpt - 1).id == "DISCONTINUITY") { + if (wpt >= 2) { + geoPosPrev.set_latlon(me.flightplans[n].getWP(wpt - 2).lat, me.flightplans[n].getWP(wpt - 2).lon); + } + } else { geoPosPrev.set_latlon(me.flightplans[n].getWP(wpt - 1).lat, me.flightplans[n].getWP(wpt - 1).lon); - #} + } courseDistanceFromPrev = waypointHashStore.courseAndDistanceFrom(geoPosPrev); wpCoursePrev[n][wpt].setValue(courseDistanceFromPrev[0]); wpDistancePrev[n][wpt].setValue(courseDistanceFromPrev[1]); - if (me.flightplans[n].getWP(wpt - 1).wp_type != "vectors" and me.flightplans[n].getWP(wpt - 1).wp_type != "hdgToAlt" and me.flightplans[n].getWP(wpt).wp_type != "vectors" and me.flightplans[n].getWP(wpt).wp_type != "hdgToAlt") { + if (me.flightplans[n].getWP(wpt - 1).wp_type != "vectors" and me.flightplans[n].getWP(wpt - 1).wp_type != "hdgToAlt" and me.flightplans[n].getWP(wpt).wp_type != "vectors" and me.flightplans[n].getWP(wpt).wp_type != "hdgToAlt" and wpt <= me.arrivalIndex[n]) { me._arrivalDist += courseDistanceFromPrev[1]; } } else { @@ -400,7 +408,6 @@ var flightPlanController = { 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 - me.arrivalIndex[n] = wpt; if (canvas_mcdu.myFpln[0] != nil) { canvas_mcdu.myFpln[0].destInfo(); } From fa1b7e65c053a8e5dc65bb5e6189de1e06cda862 Mon Sep 17 00:00:00 2001 From: legoboyvdlp R Date: Mon, 9 Mar 2020 18:00:22 +0000 Subject: [PATCH 22/51] vert rev --- A320-main.xml | 1 + Models/Instruments/MCDU/MCDU.nas | 301 ++++++++++++++++++++++++++++-- Nasal/FMGC/flightplan.nas | 6 +- Nasal/MCDU/F-PLN-rework.nas | 66 +++++-- Nasal/MCDU/MCDU.nas | 308 ++++++++++++++++--------------- Nasal/MCDU/VERTREV.nas | 177 +++++------------- 6 files changed, 546 insertions(+), 313 deletions(-) diff --git a/A320-main.xml b/A320-main.xml index 960330c2..2dc5fd58 100644 --- a/A320-main.xml +++ b/A320-main.xml @@ -1863,6 +1863,7 @@ Aircraft/A320-family/Nasal/MCDU/LATREV.nas + Aircraft/A320-family/Nasal/MCDU/VERTREV.nas Aircraft/A320-family/Nasal/MCDU/DEPARTURE.nas Aircraft/A320-family/Nasal/MCDU/ARRIVAL.nas Aircraft/A320-family/Nasal/MCDU/F-PLN-rework.nas diff --git a/Models/Instruments/MCDU/MCDU.nas b/Models/Instruments/MCDU/MCDU.nas index 9d331f93..12eab91b 100644 --- a/Models/Instruments/MCDU/MCDU.nas +++ b/Models/Instruments/MCDU/MCDU.nas @@ -7,6 +7,7 @@ var MCDU_2 = nil; var MCDU1_display = nil; var MCDU2_display = nil; var myLatRev = [nil, nil]; +var myVertRev = [nil, nil]; var myDeparture = [nil, nil]; var myArrival = [nil, nil]; var myFpln = [nil, nil]; @@ -29,27 +30,31 @@ var fplnl5 = ""; var fplnl5s = ""; var fplnl6 = ""; var fplnl6s = ""; -setprop("/MCDUC/colors/wht/r", 1); -setprop("/MCDUC/colors/wht/g", 1); -setprop("/MCDUC/colors/wht/b", 1); -setprop("/MCDUC/colors/grn/r", 0.0509); -setprop("/MCDUC/colors/grn/g", 0.7529); -setprop("/MCDUC/colors/grn/b", 0.2941); -setprop("/MCDUC/colors/blu/r", 0.0901); -setprop("/MCDUC/colors/blu/g", 0.6039); -setprop("/MCDUC/colors/blu/b", 0.7176); -setprop("/MCDUC/colors/amb/r", 0.7333); -setprop("/MCDUC/colors/amb/g", 0.3803); -setprop("/MCDUC/colors/amb/b", 0.0000); -setprop("/MCDUC/colors/yel/r", 0.9333); -setprop("/MCDUC/colors/yel/g", 0.9333); -setprop("/MCDUC/colors/yel/b", 0.0000); +setprop("MCDUC/colors/wht/r", 1); +setprop("MCDUC/colors/wht/g", 1); +setprop("MCDUC/colors/wht/b", 1); +setprop("MCDUC/colors/grn/r", 0.0509); +setprop("MCDUC/colors/grn/g", 0.7529); +setprop("MCDUC/colors/grn/b", 0.2941); +setprop("MCDUC/colors/blu/r", 0.0901); +setprop("MCDUC/colors/blu/g", 0.6039); +setprop("MCDUC/colors/blu/b", 0.7176); +setprop("MCDUC/colors/amb/r", 0.7333); +setprop("MCDUC/colors/amb/g", 0.3803); +setprop("MCDUC/colors/amb/b", 0.0000); +setprop("MCDUC/colors/yel/r", 0.9333); +setprop("MCDUC/colors/yel/g", 0.9333); +setprop("MCDUC/colors/yel/b", 0.0000); +setprop("MCDUC/colors/mag/r", 0.6902); +setprop("MCDUC/colors/mag/g", 0.3333); +setprop("MCDUC/colors/mag/b", 0.7541); var WHITE = [1.0000,1.0000,1.0000]; var GREEN = [0.0509,0.7529,0.2941]; var BLUE = [0.0901,0.6039,0.7176]; var AMBER = [0.7333,0.3803,0.0000]; var YELLOW = [0.9333,0.9333,0.0000]; +var MAGENTA = [0.6902,0.3333,0.7541]; # Fetch nodes: var mcdu1_lgt = props.globals.getNode("/controls/lighting/DU/mcdu1", 1); @@ -2017,6 +2022,262 @@ var canvas_MCDU_base = { } pageSwitch[i].setBoolValue(1); } + } elsif (page == "VERTREV") { + if (!pageSwitch[i].getBoolValue()) { + me["Simple"].show(); + me["Simple_Center"].show(); + me["FPLN"].hide(); + me["INITA"].hide(); + me["INITB"].hide(); + me["PERFTO"].hide(); + me["arrowsDepArr"].hide(); + me["Simple_PageNum"].setText("X/X"); + me["Simple_PageNum"].hide(); + me["Simple_Title"].show(); + me["ArrowLeft"].hide(); + me["ArrowRight"].hide(); + + me.fontLeft(default, default, default, default, default, default); + me.fontLeftS(default, default, default, default, default, default); + me.fontRight(default, default, default, default, default, default); + me.fontRightS(default, default, default, default, default, default); + + me.fontSizeLeft(normal, normal, normal, normal, normal, normal); + me.fontSizeRight(normal, normal, normal, normal, normal, normal); + + me.colorLeftS("wht", "wht", "wht", "wht", "wht", "wht"); + me.colorLeftArrow("wht", "wht", "wht", "wht", "wht", "wht"); + me.colorRightS("wht", "wht", "wht", "wht", "wht", "wht"); + me.colorRightArrow("wht", "wht", "wht", "wht", "wht", "wht"); + + + if (myVertRev[i] != nil) { + me["Simple_Title"].setText(sprintf("%s", myVertRev[i].title[0] ~ myVertRev[i].title[1] ~ myVertRev[i].title[2])); + + if (myVertRev[i].subtitle[0] != nil) { + me["Simple_Center"].show(); + me["Simple_C1S"].setText(sprintf("%s", myVertRev[i].subtitle[0] ~ "/" ~ myVertRev[i].subtitle[1])); + me["Simple_C1S"].show(); + me["Simple_C1"].hide(); + me["Simple_C2"].hide(); + me["Simple_C3"].hide(); + me["Simple_C4"].hide(); + me["Simple_C5"].hide(); + me["Simple_C6"].hide(); + me["Simple_C2S"].hide(); + me["Simple_C3S"].hide(); + me["Simple_C4S"].hide(); + me["Simple_C5S"].hide(); + me["Simple_C6S"].hide(); + } else { + me["Simple_Center"].hide(); + } + forindex (var matrixArrow; myVertRev[i].arrowsMatrix) { + if (matrixArrow == 0) { + var sign = "L"; + } else { + var sign = "R"; + } + forindex (var item; myVertRev[i].arrowsMatrix[matrixArrow]) { + if (myVertRev[i].arrowsMatrix[matrixArrow][item] == 1) { + me["Simple_" ~ sign ~ (item + 1) ~ "_Arrow"].show(); + } else { + me["Simple_" ~ sign ~ (item + 1) ~ "_Arrow"].hide(); + } + } + } + me.colorLeftArrow(myVertRev[i].arrowsColour[0][0],myVertRev[i].arrowsColour[0][1],myVertRev[i].arrowsColour[0][2],myVertRev[i].arrowsColour[0][3],myVertRev[i].arrowsColour[0][4],myVertRev[i].arrowsColour[0][5]); + + + forindex (var matrixFont; myVertRev[i].fontMatrix) { + if (matrixFont == 0) { + var sign = "L"; + } else { + var sign = "R"; + } + forindex (var item; myVertRev[i].fontMatrix[matrixFont]) { + if (myVertRev[i].fontMatrix[matrixFont][item] == 1) { + me["Simple_" ~ sign ~ (item + 1)].setFont(symbol); + me["Simple_" ~ sign ~ (item + 1)].setFontSize(small); + } else { + me["Simple_" ~ sign ~ (item + 1)].setFont(default); + me["Simple_" ~ sign ~ (item + 1)].setFontSize(normal); + } + } + } + + if (myVertRev[i].L1[0] == nil) { + me["Simple_L1"].hide(); + me["Simple_L1S"].hide(); + } else { + me["Simple_L1"].show(); + me["Simple_L1"].setText(myVertRev[i].L1[0]); + if (myVertRev[i].L1[1] != nil) { + me["Simple_L1S"].show(); + me["Simple_L1S"].setText(myVertRev[i].L1[1]); + } else { + me["Simple_L1S"].hide(); + } + } + + if (myVertRev[i].L2[0] == nil) { + me["Simple_L2"].hide(); + me["Simple_L2S"].hide(); + } else { + me["Simple_L2"].show(); + me["Simple_L2"].setText(myVertRev[i].L2[0]); + if (myVertRev[i].L2[1] != nil) { + me["Simple_L2S"].show(); + me["Simple_L2S"].setText(myVertRev[i].L2[1]); + } else { + me["Simple_L2S"].hide(); + } + } + + if (myVertRev[i].L3[0] == nil) { + me["Simple_L3"].hide(); + me["Simple_L3S"].hide(); + } else { + me["Simple_L3"].show(); + me["Simple_L3"].setText(myVertRev[i].L3[0]); + if (myVertRev[i].L3[1] != nil) { + me["Simple_L3S"].show(); + me["Simple_L3S"].setText(myVertRev[i].L3[1]); + } else { + me["Simple_L3S"].hide(); + } + } + + if (myVertRev[i].L4[0] == nil) { + me["Simple_L4"].hide(); + me["Simple_L4S"].hide(); + } else { + me["Simple_L4"].show(); + me["Simple_L4"].setText(myVertRev[i].L4[0]); + if (myVertRev[i].L4[1] != nil) { + me["Simple_L4S"].show(); + me["Simple_L4S"].setText(myVertRev[i].L4[1]); + } else { + me["Simple_L4S"].hide(); + } + } + + if (myVertRev[i].L5[0] == nil) { + me["Simple_L5"].hide(); + me["Simple_L5S"].hide(); + } else { + me["Simple_L5"].show(); + me["Simple_L5"].setText(myVertRev[i].L5[0]); + if (myVertRev[i].L5[1] != nil) { + me["Simple_L5S"].show(); + me["Simple_L5S"].setText(myVertRev[i].L5[1]); + } else { + me["Simple_L5S"].hide(); + } + } + + if (myVertRev[i].L6[0] == nil) { + me["Simple_L6"].hide(); + me["Simple_L6S"].hide(); + } else { + me["Simple_L6"].show(); + me["Simple_L6"].setText(myVertRev[i].L6[0]); + if (myVertRev[i].L6[1] != nil) { + me["Simple_L6S"].show(); + me["Simple_L6S"].setText(myVertRev[i].L6[1]); + } else { + me["Simple_L6S"].hide(); + } + } + me.colorLeft(myVertRev[i].L1[2],myVertRev[i].L2[2],myVertRev[i].L3[2],myVertRev[i].L4[2],myVertRev[i].L5[2],myVertRev[i].L6[2]); + + if (myVertRev[i].R1[0] == nil) { + me["Simple_R1"].hide(); + me["Simple_R1S"].hide(); + } else { + me["Simple_R1"].show(); + me["Simple_R1"].setText(myVertRev[i].R1[0]); + if (myVertRev[i].R1[1] != nil) { + me["Simple_R1S"].show(); + me["Simple_R1S"].setText(myVertRev[i].R1[1]); + } else { + me["Simple_R1S"].hide(); + } + } + + if (myVertRev[i].R2[0] == nil) { + me["Simple_R2"].hide(); + me["Simple_R2S"].hide(); + } else { + me["Simple_R2"].show(); + me["Simple_R2"].setText(myVertRev[i].R2[0]); + if (myVertRev[i].R2[1] != nil) { + me["Simple_R2S"].show(); + me["Simple_R2S"].setText(myVertRev[i].R2[1]); + } else { + me["Simple_R2S"].hide(); + } + } + + if (myVertRev[i].R3[0] == nil) { + me["Simple_R3"].hide(); + me["Simple_R3S"].hide(); + } else { + me["Simple_R3"].show(); + me["Simple_R3"].setText(myVertRev[i].R3[0]); + if (myVertRev[i].R3[1] != nil) { + me["Simple_R3S"].show(); + me["Simple_R3S"].setText(myVertRev[i].R3[1]); + } else { + me["Simple_R3S"].hide(); + } + } + + if (myVertRev[i].R4[0] == nil) { + me["Simple_R4"].hide(); + me["Simple_R4S"].hide(); + } else { + me["Simple_R4"].show(); + me["Simple_R4"].setText(myVertRev[i].R4[0]); + if (myVertRev[i].R4[1] != nil) { + me["Simple_R4S"].show(); + me["Simple_R4S"].setText(myVertRev[i].R4[1]); + } else { + me["Simple_R4S"].hide(); + } + } + + if (myVertRev[i].R5[0] == nil) { + me["Simple_R5"].hide(); + me["Simple_R5S"].hide(); + } else { + me["Simple_R5"].show(); + me["Simple_R5"].setText(myVertRev[i].R5[0]); + if (myVertRev[i].R5[1] != nil) { + me["Simple_R5S"].show(); + me["Simple_R5S"].setText(myVertRev[i].R5[1]); + } else { + me["Simple_R5S"].hide(); + } + } + + if (myVertRev[i].R6[0] == nil) { + me["Simple_R6"].hide(); + me["Simple_R6S"].hide(); + } else { + me["Simple_R6"].show(); + me["Simple_R6"].setText(myVertRev[i].R6[0]); + if (myVertRev[i].R6[1] != nil) { + me["Simple_R6S"].show(); + me["Simple_R6S"].setText(myVertRev[i].R6[1]); + } else { + me["Simple_R6S"].hide(); + } + } + me.colorRight(myVertRev[i].R1[2],myVertRev[i].R2[2],myVertRev[i].R3[2],myVertRev[i].R4[2],myVertRev[i].R5[2],myVertRev[i].R6[2]); + } + pageSwitch[i].setBoolValue(1); + } } elsif (page == "DEPARTURE") { if (!pageSwitch[i].getBoolValue()) { me["Simple"].show(); @@ -2067,12 +2328,12 @@ var canvas_MCDU_base = { } forindex (var item; myDeparture[i].arrowsMatrix[matrixArrow]) { if (item == 5) { - me["Simple_L6_Arrow"].setColor(getprop("/MCDUC/colors/" ~ myDeparture[i].arrowsColour[0][5] ~ "/r"), getprop("/MCDUC/colors/" ~ myDeparture[i].arrowsColour[0][5] ~ "/g"), getprop("/MCDUC/colors/" ~ myDeparture[i].arrowsColour[0][5] ~ "/b")); + me["Simple_L6_Arrow"].setColor(getprop("MCDUC/colors/" ~ myDeparture[i].arrowsColour[0][5] ~ "/r"), getprop("MCDUC/colors/" ~ myDeparture[i].arrowsColour[0][5] ~ "/g"), getprop("MCDUC/colors/" ~ myDeparture[i].arrowsColour[0][5] ~ "/b")); continue; } if (myDeparture[i].arrowsMatrix[matrixArrow][item] == 1) { me["arrow" ~ (item + 1) ~ sign].show(); - me["arrow" ~ (item + 1) ~ sign].setColor(getprop("/MCDUC/colors/" ~ myDeparture[i].arrowsColour[matrixArrow][item] ~ "/r"), getprop("/MCDUC/colors/" ~ myDeparture[i].arrowsColour[matrixArrow][item] ~ "/g"), getprop("/MCDUC/colors/" ~ myDeparture[i].arrowsColour[matrixArrow][item] ~ "/b")); + me["arrow" ~ (item + 1) ~ sign].setColor(getprop("MCDUC/colors/" ~ myDeparture[i].arrowsColour[matrixArrow][item] ~ "/r"), getprop("MCDUC/colors/" ~ myDeparture[i].arrowsColour[matrixArrow][item] ~ "/g"), getprop("MCDUC/colors/" ~ myDeparture[i].arrowsColour[matrixArrow][item] ~ "/b")); } else { me["arrow" ~ (item + 1) ~ sign].hide(); } @@ -2705,12 +2966,12 @@ var canvas_MCDU_base = { } forindex (var item; myArrival[i].arrowsMatrix[matrixArrow]) { if (item == 5) { - me["Simple_L6_Arrow"].setColor(getprop("/MCDUC/colors/" ~ myArrival[i].arrowsColour[0][5] ~ "/r"), getprop("/MCDUC/colors/" ~ myArrival[i].arrowsColour[0][5] ~ "/g"), getprop("/MCDUC/colors/" ~ myArrival[i].arrowsColour[0][5] ~ "/b")); + me["Simple_L6_Arrow"].setColor(getprop("MCDUC/colors/" ~ myArrival[i].arrowsColour[0][5] ~ "/r"), getprop("MCDUC/colors/" ~ myArrival[i].arrowsColour[0][5] ~ "/g"), getprop("MCDUC/colors/" ~ myArrival[i].arrowsColour[0][5] ~ "/b")); continue; } if (myArrival[i].arrowsMatrix[matrixArrow][item] == 1) { me["arrow" ~ (item + 1) ~ sign].show(); - me["arrow" ~ (item + 1) ~ sign].setColor(getprop("/MCDUC/colors/" ~ myArrival[i].arrowsColour[matrixArrow][item] ~ "/r"), getprop("/MCDUC/colors/" ~ myArrival[i].arrowsColour[matrixArrow][item] ~ "/g"), getprop("/MCDUC/colors/" ~ myArrival[i].arrowsColour[matrixArrow][item] ~ "/b")); + me["arrow" ~ (item + 1) ~ sign].setColor(getprop("MCDUC/colors/" ~ myArrival[i].arrowsColour[matrixArrow][item] ~ "/r"), getprop("MCDUC/colors/" ~ myArrival[i].arrowsColour[matrixArrow][item] ~ "/g"), getprop("MCDUC/colors/" ~ myArrival[i].arrowsColour[matrixArrow][item] ~ "/b")); } else { me["arrow" ~ (item + 1) ~ sign].hide(); } @@ -2996,7 +3257,7 @@ var canvas_MCDU_base = { me["Scratchpad"].setText(sprintf("%s", scratchpad[i].getValue())); }, - # ack = ignore, wht = white, grn = green, blu = blue, amb = amber, yel = yellow + # ack = ignore, wht = white, grn = green, blu = blue, amb = amber, yel = yellow, mag = magenta colorLeft: func(a, b, c, d, e, f) { if (a != "ack") { me["Simple_L1"].setColor(getprop("MCDUC/colors/" ~ a ~ "/r"), getprop("MCDUC/colors/" ~ a ~ "/g"), getprop("MCDUC/colors/" ~ a ~ "/b")); diff --git a/Nasal/FMGC/flightplan.nas b/Nasal/FMGC/flightplan.nas index b309e9ab..65a58f01 100644 --- a/Nasal/FMGC/flightplan.nas +++ b/Nasal/FMGC/flightplan.nas @@ -181,7 +181,7 @@ var flightPlanController = { } canvas_mcdu.myDeparture[plan] = nil; canvas_mcdu.myDuplicate[plan] = mcdu.duplicateNamesPage.new(airport, index, 0, plan); - setprop("/MCDU[" ~ plan ~ "]/page", "DUPLICATENAMES"); + setprop("MCDU[" ~ plan ~ "]/page", "DUPLICATENAMES"); return 2; } }, @@ -230,7 +230,7 @@ var flightPlanController = { } canvas_mcdu.myDeparture[plan] = nil; canvas_mcdu.myDuplicate[plan] = mcdu.duplicateNamesPage.new(fix, index, 0, plan); - setprop("/MCDU[" ~ plan ~ "]/page", "DUPLICATENAMES"); + setprop("MCDU[" ~ plan ~ "]/page", "DUPLICATENAMES"); return 2; } }, @@ -308,7 +308,7 @@ var flightPlanController = { } canvas_mcdu.myDeparture[plan] = nil; canvas_mcdu.myDuplicate[plan] = mcdu.duplicateNamesPage.new(navaid, index, 1, plan); - setprop("/MCDU[" ~ plan ~ "]/page", "DUPLICATENAMES"); + setprop("MCDU[" ~ plan ~ "]/page", "DUPLICATENAMES"); return 2; } }, diff --git a/Nasal/MCDU/F-PLN-rework.nas b/Nasal/MCDU/F-PLN-rework.nas index e815c3bc..a7d38f8d 100644 --- a/Nasal/MCDU/F-PLN-rework.nas +++ b/Nasal/MCDU/F-PLN-rework.nas @@ -75,6 +75,7 @@ var fplnItem = { canvas_mcdu.myLatRev[me.computer].del(); } canvas_mcdu.myLatRev[me.computer] = nil; + if (me.wp.wp_name == "DISCONTINUITY") { canvas_mcdu.myLatRev[me.computer] = latRev.new(4, "DISCON", me.index, me.computer); } elsif (fmgc.flightPlanController.temporaryFlag[me.computer]) { @@ -98,10 +99,37 @@ var fplnItem = { canvas_mcdu.myLatRev[me.computer] = latRev.new(3, me.wp.wp_name, me.index, me.computer); } } - setprop("/MCDU[" ~ me.computer ~ "]/page", "LATREV"); + setprop("MCDU[" ~ me.computer ~ "]/page", "LATREV"); }, pushButtonRight: func() { + if (canvas_mcdu.myVertRev[me.computer] != nil) { + canvas_mcdu.myVertRev[me.computer].del(); + } + canvas_mcdu.myVertRev[me.computer] = nil; notAllowed(me.computer); + + if (fmgc.flightPlanController.temporaryFlag[me.computer]) { + if (me.index == fmgc.flightPlanController.arrivalIndex[me.computer]) { + canvas_mcdu.myVertRev[me.computer] = vertRev.new(1, left(me.wp.wp_name, 4), me.index, me.computer); + } if (left(me.wp.wp_name, 4) == fmgc.flightPlanController.flightplans[me.computer].departure.id) { + notAllowed(me.computer); + } elsif (me.index == (fmgc.flightPlanController.currentToWptIndex.getValue() - 1)) { + canvas_mcdu.myVertRev[me.computer] = vertRev.new(3, me.wp.wp_name, me.index, me.computer); + } else { + canvas_mcdu.myVertRev[me.computer] = vertRev.new(2, me.wp.wp_name, me.index, me.computer); + } + } else { + if (me.index == fmgc.flightPlanController.arrivalIndex[2]) { + canvas_mcdu.myVertRev[me.computer] = vertRev.new(1, left(me.wp.wp_name, 4), me.index, me.computer); + } elsif (left(me.wp.wp_name, 4) == fmgc.flightPlanController.flightplans[2].departure.id) { + notAllowed(me.computer); + } elsif (me.index == (fmgc.flightPlanController.currentToWptIndex.getValue() - 1)) { + canvas_mcdu.myVertRev[me.computer] = vertRev.new(3, me.wp.wp_name, me.index, me.computer); + } else { + canvas_mcdu.myVertRev[me.computer] = vertRev.new(2, me.wp.wp_name, me.index, me.computer); + } + } + setprop("MCDU[" ~ me.computer ~ "]/page", "VERTREV"); }, }; @@ -307,19 +335,19 @@ var fplnPage = { # this one is only created once, and then updated - remember th } canvas_mcdu.myLatRev[me.computer] = nil; canvas_mcdu.myLatRev[me.computer] = latRev.new(1, me.L6[0], fmgc.flightPlanController.arrivalIndex[me.computer], me.computer); - setprop("/MCDU[" ~ me.computer ~ "]/page", "LATREV"); + setprop("MCDU[" ~ me.computer ~ "]/page", "LATREV"); } } else { if (size(me.outputList) >= index) { - if (size(getprop("/MCDU[" ~ me.computer ~ "]/scratchpad")) > 0) { - var returny = fmgc.flightPlanController.scratchpad(getprop("/MCDU[" ~ me.computer ~ "]/scratchpad"), (index - 1 + me.scroll), me.computer); + if (size(getprop("MCDU[" ~ me.computer ~ "]/scratchpad")) > 0) { + var returny = fmgc.flightPlanController.scratchpad(getprop("MCDU[" ~ me.computer ~ "]/scratchpad"), (index - 1 + me.scroll), me.computer); if (returny == 0) { notInDataBase(me.computer); } elsif (returny == 1) { notAllowed(me.computer); } else { - setprop("/MCDU[" ~ me.computer ~ "]/scratchpad-msg", ""); - setprop("/MCDU[" ~ me.computer ~ "]/scratchpad", ""); + setprop("MCDU[" ~ me.computer ~ "]/scratchpad-msg", ""); + setprop("MCDU[" ~ me.computer ~ "]/scratchpad", ""); } } else { me.outputList[index - 1].pushButtonLeft(); @@ -337,19 +365,27 @@ var fplnPage = { # this one is only created once, and then updated - remember th notAllowed(me.computer); } } else { - notAllowed(me.computer); + if (size(me.outputList) >= index) { + if (size(getprop("MCDU[" ~ me.computer ~ "]/scratchpad")) > 0) { + notAllowed(me.computer); + } else { + me.outputList[index - 1].pushButtonRight(); + } + } else { + notAllowed(me.computer); + } } }, }; var notInDataBase = func(i) { - if (getprop("/MCDU[" ~ i ~ "]/scratchpad-msg") == 1) { - setprop("/MCDU[" ~ i ~ "]/last-scratchpad", "NOT IN DATABASE"); + if (getprop("MCDU[" ~ i ~ "]/scratchpad-msg") == 1) { + setprop("MCDU[" ~ i ~ "]/last-scratchpad", "NOT IN DATABASE"); } else { - setprop("/MCDU[" ~ i ~ "]/last-scratchpad", getprop("/MCDU[" ~ i ~ "]/scratchpad")); + setprop("MCDU[" ~ i ~ "]/last-scratchpad", getprop("MCDU[" ~ i ~ "]/scratchpad")); } - setprop("/MCDU[" ~ i ~ "]/scratchpad-msg", 1); - setprop("/MCDU[" ~ i ~ "]/scratchpad", "NOT IN DATABASE"); + setprop("MCDU[" ~ i ~ "]/scratchpad-msg", 1); + setprop("MCDU[" ~ i ~ "]/scratchpad", "NOT IN DATABASE"); } @@ -487,13 +523,13 @@ var duplicateNamesPage = { pushButtonLeft: func(indexSelect) { if (size(me.vector[0].id) == 5) { fmgc.flightPlanController.insertFix(me.vector[0].id, me.index, me.computer, 1, indexSelect - 1); - setprop("/MCDU[" ~ me.computer ~ "]/page", "F-PLNA"); + setprop("MCDU[" ~ me.computer ~ "]/page", "F-PLNA"); } elsif (size(me.vector[0].id) == 4) { fmgc.flightPlanController.insertAirport(me.vector[0].id, me.index, me.computer, 1, indexSelect - 1); - setprop("/MCDU[" ~ me.computer ~ "]/page", "F-PLNA"); + setprop("MCDU[" ~ me.computer ~ "]/page", "F-PLNA"); } elsif (size(me.vector[0].id) == 3 or size(me.vector[0].id)== 2) { fmgc.flightPlanController.insertNavaid(me.vector[0].id, me.index, me.computer, 1, indexSelect - 1); - setprop("/MCDU[" ~ me.computer ~ "]/page", "F-PLNA"); + setprop("MCDU[" ~ me.computer ~ "]/page", "F-PLNA"); } }, }; diff --git a/Nasal/MCDU/MCDU.nas b/Nasal/MCDU/MCDU.nas index 4ce77058..89af083d 100644 --- a/Nasal/MCDU/MCDU.nas +++ b/Nasal/MCDU/MCDU.nas @@ -95,152 +95,152 @@ var lskbutton = func(btn, i) { setprop("MCDU[" ~ i ~ "]/scratchpad", ""); setprop("MCDU[" ~ i ~ "]/scratchpad-msg", 0); } - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "TO") { + } else if (getprop("MCDU[" ~ i ~ "]/page") == "TO") { perfTOInput("L1", i); - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "RADNAV") { + } else if (getprop("MCDU[" ~ i ~ "]/page") == "RADNAV") { radnavInput("L1", i); - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "DATA") { + } else if (getprop("MCDU[" ~ i ~ "]/page") == "DATA") { dataInput("L1", i); - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "PRINTFUNC") { + } else if (getprop("MCDU[" ~ i ~ "]/page") == "PRINTFUNC") { printInput("L1", i); - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "PRINTFUNC2") { + } else if (getprop("MCDU[" ~ i ~ "]/page") == "PRINTFUNC2") { printInput2("L1", i); - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "LATREV") { + } else if (getprop("MCDU[" ~ i ~ "]/page") == "LATREV") { if (canvas_mcdu.myDeparture[i] != nil) { canvas_mcdu.myDeparture[i].del(); } canvas_mcdu.myDeparture[i] = nil; canvas_mcdu.myDeparture[i] = departurePage.new(canvas_mcdu.myLatRev[i].title[2], i); - setprop("/MCDU[" ~ i ~ "]/page", "DEPARTURE"); - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNA" or getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNB") { + setprop("MCDU[" ~ i ~ "]/page", "DEPARTURE"); + } else if (getprop("MCDU[" ~ i ~ "]/page") == "F-PLNA" or getprop("MCDU[" ~ i ~ "]/page") == "F-PLNB") { canvas_mcdu.myFpln[i].pushButtonLeft(1); - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "DUPLICATENAMES") { + } else if (getprop("MCDU[" ~ i ~ "]/page") == "DUPLICATENAMES") { canvas_mcdu.myDuplicate[i].pushButtonLeft(1); } else { notAllowed(i); } } else if (btn == "2") { - if (getprop("/MCDU[" ~ i ~ "]/page") == "INITA") { + if (getprop("MCDU[" ~ i ~ "]/page") == "INITA") { PerfInput("L2", i); - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "TO") { + } else if (getprop("MCDU[" ~ i ~ "]/page") == "TO") { perfTOInput("L2", i); - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "RADNAV") { + } else if (getprop("MCDU[" ~ i ~ "]/page") == "RADNAV") { radnavInput("L2", i); - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "CLB") { + } else if (getprop("MCDU[" ~ i ~ "]/page") == "CLB") { initInputA("L5", i); # Does the same thing as on the INIT page - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "CRZ") { + } else if (getprop("MCDU[" ~ i ~ "]/page") == "CRZ") { initInputA("L5", i); - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "DES") { + } else if (getprop("MCDU[" ~ i ~ "]/page") == "DES") { initInputA("L5", i); - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "DATA") { + } else if (getprop("MCDU[" ~ i ~ "]/page") == "DATA") { dataInput("L2", i); - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "PRINTFUNC") { + } else if (getprop("MCDU[" ~ i ~ "]/page") == "PRINTFUNC") { printInput("L2", i); - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "PRINTFUNC2") { + } else if (getprop("MCDU[" ~ i ~ "]/page") == "PRINTFUNC2") { printInput2("L2", i); - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNA" or getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNB") { + } else if (getprop("MCDU[" ~ i ~ "]/page") == "F-PLNA" or getprop("MCDU[" ~ i ~ "]/page") == "F-PLNB") { canvas_mcdu.myFpln[i].pushButtonLeft(2); - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "DEPARTURE") { + } else if (getprop("MCDU[" ~ i ~ "]/page") == "DEPARTURE") { canvas_mcdu.myDeparture[i].depPushbuttonLeft(2); - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "ARRIVAL") { + } else if (getprop("MCDU[" ~ i ~ "]/page") == "ARRIVAL") { canvas_mcdu.myArrival[i].arrPushbuttonLeft(2); - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "DUPLICATENAMES") { + } else if (getprop("MCDU[" ~ i ~ "]/page") == "DUPLICATENAMES") { canvas_mcdu.myDuplicate[i].pushButtonLeft(2); } else { notAllowed(i); } } else if (btn == "3") { - if (getprop("/MCDU[" ~ i ~ "]/page") == "INITA") { + if (getprop("MCDU[" ~ i ~ "]/page") == "INITA") { initInputA("L3", i); - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "TO") { + } else if (getprop("MCDU[" ~ i ~ "]/page") == "TO") { perfTOInput("L3", i); - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "STATUS") { + } else if (getprop("MCDU[" ~ i ~ "]/page") == "STATUS") { statusInput("L3", i); - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "RADNAV") { + } else if (getprop("MCDU[" ~ i ~ "]/page") == "RADNAV") { radnavInput("L3", i); - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "PRINTFUNC") { + } else if (getprop("MCDU[" ~ i ~ "]/page") == "PRINTFUNC") { printInput("L3", i); - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "PRINTFUNC2") { + } else if (getprop("MCDU[" ~ i ~ "]/page") == "PRINTFUNC2") { printInput2("L3", i); - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNA" or getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNB") { + } else if (getprop("MCDU[" ~ i ~ "]/page") == "F-PLNA" or getprop("MCDU[" ~ i ~ "]/page") == "F-PLNB") { canvas_mcdu.myFpln[i].pushButtonLeft(3); - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "DEPARTURE") { + } else if (getprop("MCDU[" ~ i ~ "]/page") == "DEPARTURE") { canvas_mcdu.myDeparture[i].depPushbuttonLeft(3); - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "ARRIVAL") { + } else if (getprop("MCDU[" ~ i ~ "]/page") == "ARRIVAL") { canvas_mcdu.myArrival[i].arrPushbuttonLeft(3); - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "DUPLICATENAMES") { + } else if (getprop("MCDU[" ~ i ~ "]/page") == "DUPLICATENAMES") { canvas_mcdu.myDuplicate[i].pushButtonLeft(3); } else { notAllowed(i); } } else if (btn == "4") { - if (getprop("/MCDU[" ~ i ~ "]/page") == "DATA") { - setprop("/MCDU[" ~ i ~ "]/page", "STATUS"); - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "TO") { + if (getprop("MCDU[" ~ i ~ "]/page") == "DATA") { + setprop("MCDU[" ~ i ~ "]/page", "STATUS"); + } else if (getprop("MCDU[" ~ i ~ "]/page") == "TO") { perfTOInput("L4", i); - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "RADNAV") { + } else if (getprop("MCDU[" ~ i ~ "]/page") == "RADNAV") { radnavInput("L4", i); - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "PRINTFUNC2") { + } else if (getprop("MCDU[" ~ i ~ "]/page") == "PRINTFUNC2") { printInput2("L4", i); - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNA" or getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNB") { + } else if (getprop("MCDU[" ~ i ~ "]/page") == "F-PLNA" or getprop("MCDU[" ~ i ~ "]/page") == "F-PLNB") { canvas_mcdu.myFpln[i].pushButtonLeft(4); - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "DEPARTURE") { + } else if (getprop("MCDU[" ~ i ~ "]/page") == "DEPARTURE") { canvas_mcdu.myDeparture[i].depPushbuttonLeft(4); - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "ARRIVAL") { + } else if (getprop("MCDU[" ~ i ~ "]/page") == "ARRIVAL") { canvas_mcdu.myArrival[i].arrPushbuttonLeft(4); - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "DUPLICATENAMES") { + } else if (getprop("MCDU[" ~ i ~ "]/page") == "DUPLICATENAMES") { canvas_mcdu.myDuplicate[i].pushButtonLeft(4); } else { notAllowed(i); } } else if (btn == "5") { - if (getprop("/MCDU[" ~ i ~ "]/page") == "INITA") { + if (getprop("MCDU[" ~ i ~ "]/page") == "INITA") { initInputA("L5", i); - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "TO") { + } else if (getprop("MCDU[" ~ i ~ "]/page") == "TO") { perfTOInput("L5", i); - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "CLB") { + } else if (getprop("MCDU[" ~ i ~ "]/page") == "CLB") { perfCLBInput("L5", i); - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "CRZ") { + } else if (getprop("MCDU[" ~ i ~ "]/page") == "CRZ") { perfCRZInput("L5", i); - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "DES") { + } else if (getprop("MCDU[" ~ i ~ "]/page") == "DES") { perfDESInput("L5", i); - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "RADNAV") { + } else if (getprop("MCDU[" ~ i ~ "]/page") == "RADNAV") { radnavInput("L5", i); - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "PRINTFUNC") { + } else if (getprop("MCDU[" ~ i ~ "]/page") == "PRINTFUNC") { printInput("L5", i); - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "PRINTFUNC2") { + } else if (getprop("MCDU[" ~ i ~ "]/page") == "PRINTFUNC2") { printInput2("L5", i); - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNA" or getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNB") { + } else if (getprop("MCDU[" ~ i ~ "]/page") == "F-PLNA" or getprop("MCDU[" ~ i ~ "]/page") == "F-PLNB") { canvas_mcdu.myFpln[i].pushButtonLeft(5); - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "DEPARTURE") { + } else if (getprop("MCDU[" ~ i ~ "]/page") == "DEPARTURE") { canvas_mcdu.myDeparture[i].depPushbuttonLeft(5); - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "ARRIVAL") { + } else if (getprop("MCDU[" ~ i ~ "]/page") == "ARRIVAL") { canvas_mcdu.myArrival[i].arrPushbuttonLeft(5); - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "DUPLICATENAMES") { + } else if (getprop("MCDU[" ~ i ~ "]/page") == "DUPLICATENAMES") { canvas_mcdu.myDuplicate[i].pushButtonLeft(5); } else { notAllowed(i); } } else if (btn == "6") { - if (getprop("/MCDU[" ~ i ~ "]/page") == "INITA") { + if (getprop("MCDU[" ~ i ~ "]/page") == "INITA") { initInputA("L6", i); - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "CLB") { + } else if (getprop("MCDU[" ~ i ~ "]/page") == "CLB") { perfCLBInput("L6", i); - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "CRZ") { + } else if (getprop("MCDU[" ~ i ~ "]/page") == "CRZ") { perfCRZInput("L6", i); - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "DES") { + } else if (getprop("MCDU[" ~ i ~ "]/page") == "DES") { perfDESInput("L6", i); - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "PRINTFUNC2") { + } else if (getprop("MCDU[" ~ i ~ "]/page") == "PRINTFUNC2") { printInput2("L6", i); - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNA" or getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNB") { + } else if (getprop("MCDU[" ~ i ~ "]/page") == "F-PLNA" or getprop("MCDU[" ~ i ~ "]/page") == "F-PLNB") { canvas_mcdu.myFpln[i].pushButtonLeft(6); - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "LATREV" or getprop("/MCDU[" ~ i ~ "]/page") == "DUPLICATENAMES") { - setprop("/MCDU[" ~ i ~ "]/page", "F-PLNA"); - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "DEPARTURE" or getprop("/MCDU[" ~ i ~ "]/page") == "ARRIVAL") { + } else if (getprop("MCDU[" ~ i ~ "]/page") == "LATREV" or getprop("MCDU[" ~ i ~ "]/page") == "VERTREV" or getprop("MCDU[" ~ i ~ "]/page") == "DUPLICATENAMES") { + setprop("MCDU[" ~ i ~ "]/page", "F-PLNA"); + } else if (getprop("MCDU[" ~ i ~ "]/page") == "DEPARTURE" or getprop("MCDU[" ~ i ~ "]/page") == "ARRIVAL") { if (fmgc.flightPlanController.temporaryFlag[i]) { - setprop("/MCDU[" ~ i ~ "]/page", "F-PLNA"); + setprop("MCDU[" ~ i ~ "]/page", "F-PLNA"); } else { - setprop("/MCDU[" ~ i ~ "]/page", "LATREV"); + setprop("MCDU[" ~ i ~ "]/page", "LATREV"); } } else { notAllowed(i); @@ -254,89 +254,99 @@ var lskbutton_b = func(btn, i) { var rskbutton = func(btn, i) { if (btn == "1") { - if (getprop("/MCDU[" ~ i ~ "]/page") == "INITA") { + if (getprop("MCDU[" ~ i ~ "]/page") == "INITA") { initInputA("R1", i); - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "INITB") { + } else if (getprop("MCDU[" ~ i ~ "]/page") == "INITB") { initInputB("R1", i); - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "RADNAV") { + } else if (getprop("MCDU[" ~ i ~ "]/page") == "RADNAV") { radnavInput("R1", i); - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "PRINTFUNC") { + } else if (getprop("MCDU[" ~ i ~ "]/page") == "PRINTFUNC") { printInput("R1", i); - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "PRINTFUNC2") { + } else if (getprop("MCDU[" ~ i ~ "]/page") == "PRINTFUNC2") { printInput2("R1", i); - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "LATREV") { + } else if (getprop("MCDU[" ~ i ~ "]/page") == "LATREV") { if (canvas_mcdu.myArrival[i] != nil) { canvas_mcdu.myArrival[i].del(); } canvas_mcdu.myArrival[i] = nil; canvas_mcdu.myArrival[i] = arrivalPage.new(canvas_mcdu.myLatRev[i].title[2], i); - setprop("/MCDU[" ~ i ~ "]/page", "ARRIVAL"); + setprop("MCDU[" ~ i ~ "]/page", "ARRIVAL"); + } else if (getprop("MCDU[" ~ i ~ "]/page") == "F-PLNA" or getprop("MCDU[" ~ i ~ "]/page") == "F-PLNB") { + canvas_mcdu.myFpln[i].pushButtonRight(1); } else { notAllowed(i); } } else if (btn == "2") { - if (getprop("/MCDU[" ~ i ~ "]/page") == "INITB") { + if (getprop("MCDU[" ~ i ~ "]/page") == "INITB") { initInputB("R2", i); - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "RADNAV") { + } else if (getprop("MCDU[" ~ i ~ "]/page") == "RADNAV") { radnavInput("R2", i); - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "PRINTFUNC") { + } else if (getprop("MCDU[" ~ i ~ "]/page") == "PRINTFUNC") { printInput("R2", i); - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "PRINTFUNC2") { + } else if (getprop("MCDU[" ~ i ~ "]/page") == "PRINTFUNC2") { printInput2("R2", i); - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "DEPARTURE") { + } else if (getprop("MCDU[" ~ i ~ "]/page") == "DEPARTURE") { canvas_mcdu.myDeparture[i].depPushbuttonRight(2); - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "ARRIVAL") { + } else if (getprop("MCDU[" ~ i ~ "]/page") == "ARRIVAL") { canvas_mcdu.myArrival[i].arrPushbuttonRight(2); + } else if (getprop("MCDU[" ~ i ~ "]/page") == "F-PLNA" or getprop("MCDU[" ~ i ~ "]/page") == "F-PLNB") { + canvas_mcdu.myFpln[i].pushButtonRight(2); } else { notAllowed(i); } } else if (btn == "3") { - if (getprop("/MCDU[" ~ i ~ "]/page") == "INITA") { + if (getprop("MCDU[" ~ i ~ "]/page") == "INITA") { initInputA("R3", i); - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "TO") { + } else if (getprop("MCDU[" ~ i ~ "]/page") == "TO") { perfTOInput("R3", i); - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "PRINTFUNC") { + } else if (getprop("MCDU[" ~ i ~ "]/page") == "PRINTFUNC") { printInput("R3", i); - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "PRINTFUNC2") { + } else if (getprop("MCDU[" ~ i ~ "]/page") == "PRINTFUNC2") { printInput2("R3", i); - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "DEPARTURE") { + } else if (getprop("MCDU[" ~ i ~ "]/page") == "DEPARTURE") { canvas_mcdu.myDeparture[i].depPushbuttonRight(3); - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "ARRIVAL") { + } else if (getprop("MCDU[" ~ i ~ "]/page") == "ARRIVAL") { canvas_mcdu.myArrival[i].arrPushbuttonRight(3); - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "LATREV") { + } else if (getprop("MCDU[" ~ i ~ "]/page") == "LATREV") { if (canvas_mcdu.myLatRev[i].type != 2) { canvas_mcdu.myLatRev[i].nextWpt(); } else { notAllowed(i); } + } else if (getprop("MCDU[" ~ i ~ "]/page") == "F-PLNA" or getprop("MCDU[" ~ i ~ "]/page") == "F-PLNB") { + canvas_mcdu.myFpln[i].pushButtonRight(3); } else { notAllowed(i); } } else if (btn == "4") { - if (getprop("/MCDU[" ~ i ~ "]/page") == "TO") { + if (getprop("MCDU[" ~ i ~ "]/page") == "TO") { perfTOInput("R4", i); - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "RADNAV") { + } else if (getprop("MCDU[" ~ i ~ "]/page") == "RADNAV") { radnavInput("R4", i); - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "PRINTFUNC2") { + } else if (getprop("MCDU[" ~ i ~ "]/page") == "PRINTFUNC2") { printInput2("R4", i); - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "DEPARTURE") { + } else if (getprop("MCDU[" ~ i ~ "]/page") == "DEPARTURE") { canvas_mcdu.myDeparture[i].depPushbuttonRight(4); - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "ARRIVAL") { + } else if (getprop("MCDU[" ~ i ~ "]/page") == "ARRIVAL") { canvas_mcdu.myArrival[i].arrPushbuttonRight(4); + } else if (getprop("MCDU[" ~ i ~ "]/page") == "F-PLNA" or getprop("MCDU[" ~ i ~ "]/page") == "F-PLNB") { + canvas_mcdu.myFpln[i].pushButtonRight(4); } else { notAllowed(i); } } else if (btn == "5") { - if (getprop("/MCDU[" ~ i ~ "]/page") == "TO") { + if (getprop("MCDU[" ~ i ~ "]/page") == "TO") { perfTOInput("R5", i); - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "RADNAV") { + } else if (getprop("MCDU[" ~ i ~ "]/page") == "RADNAV") { radnavInput("R5", i); - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "DATA") { + } else if (getprop("MCDU[" ~ i ~ "]/page") == "DATA") { dataInput("R5", i); - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "DEPARTURE") { + } else if (getprop("MCDU[" ~ i ~ "]/page") == "DEPARTURE") { canvas_mcdu.myDeparture[i].depPushbuttonRight(5); - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "ARRIVAL") { + } else if (getprop("MCDU[" ~ i ~ "]/page") == "ARRIVAL") { canvas_mcdu.myArrival[i].arrPushbuttonRight(5); + } else if (getprop("MCDU[" ~ i ~ "]/page") == "F-PLNA" or getprop("MCDU[" ~ i ~ "]/page") == "F-PLNB") { + canvas_mcdu.myFpln[i].pushButtonRight(5); } else { notAllowed(i); } @@ -349,26 +359,28 @@ var rskbutton = func(btn, i) { } else { notAllowed(i); } - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "TO") { + } else if (getprop("MCDU[" ~ i ~ "]/page") == "TO") { perfTOInput("R6", i); - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "CLB") { + } else if (getprop("MCDU[" ~ i ~ "]/page") == "CLB") { perfCLBInput("R6", i); - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "CRZ") { + } else if (getprop("MCDU[" ~ i ~ "]/page") == "CRZ") { perfCRZInput("R6", i); - } else if ((getprop("/MCDU[" ~ i ~ "]/page") == "DATA") or (getprop("/MCDU[" ~ i ~ "]/page") == "PRINTFUNC") or (getprop("/MCDU[" ~ i ~ "]/page") == "PRINTFUNC2")) { - if (getprop("/MCDU[" ~ i ~ "]/scratchpad") != "AOC DISABLED") { - if (getprop("/MCDU[" ~ i ~ "]/scratchpad-msg") == 1) { - setprop("/MCDU[" ~ i ~ "]/last-scratchpad", ""); + } else if ((getprop("MCDU[" ~ i ~ "]/page") == "DATA") or (getprop("MCDU[" ~ i ~ "]/page") == "PRINTFUNC") or (getprop("MCDU[" ~ i ~ "]/page") == "PRINTFUNC2")) { + if (getprop("MCDU[" ~ i ~ "]/scratchpad") != "AOC DISABLED") { + if (getprop("MCDU[" ~ i ~ "]/scratchpad-msg") == 1) { + setprop("MCDU[" ~ i ~ "]/last-scratchpad", ""); } else { setprop("MCDU[" ~ i ~ "]/last-scratchpad", getprop("MCDU[" ~ i ~ "]/scratchpad")); } } - setprop("/MCDU[" ~ i ~ "]/scratchpad-msg", 1); - setprop("/MCDU[" ~ i ~ "]/scratchpad", "AOC DISABLED"); - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "INITA") { + setprop("MCDU[" ~ i ~ "]/scratchpad-msg", 1); + setprop("MCDU[" ~ i ~ "]/scratchpad", "AOC DISABLED"); + } else if (getprop("MCDU[" ~ i ~ "]/page") == "INITA") { initInputA("R6", i); - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNA" or getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNB") { + } else if (getprop("MCDU[" ~ i ~ "]/page") == "F-PLNA" or getprop("MCDU[" ~ i ~ "]/page") == "F-PLNB") { canvas_mcdu.myFpln[i].pushButtonRight(6); + } else if (getprop("MCDU[" ~ i ~ "]/page") == "VERTREV") { + setprop("MCDU/[" ~ i ~ "]/page", "F-PLNA"); } else { notAllowed(i); } @@ -381,59 +393,59 @@ var rskbutton_b = func(btn, i) { var arrowbutton = func(btn, i) { if (btn == "left") { - if (getprop("/MCDU[" ~ i ~ "]/page") == "DATA") { - setprop("/MCDU[" ~ i ~ "]/page", "DATA2"); - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "DATA2") { - setprop("/MCDU[" ~ i ~ "]/page", "DATA"); - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "INITA") { + if (getprop("MCDU[" ~ i ~ "]/page") == "DATA") { + setprop("MCDU[" ~ i ~ "]/page", "DATA2"); + } else if (getprop("MCDU[" ~ i ~ "]/page") == "DATA2") { + setprop("MCDU[" ~ i ~ "]/page", "DATA"); + } else if (getprop("MCDU[" ~ i ~ "]/page") == "INITA") { if (getprop("/engines/engine[0]/state") != 3 and getprop("/engines/engine[1]/state") != 3) { - setprop("/MCDU[" ~ i ~ "]/page", "INITB"); + setprop("MCDU[" ~ i ~ "]/page", "INITB"); } - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "INITB") { - setprop("/MCDU[" ~ i ~ "]/page", "INITA"); - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "PRINTFUNC") { - setprop("/MCDU[" ~ i ~ "]/page", "PRINTFUNC2"); - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "PRINTFUNC2") { - setprop("/MCDU[" ~ i ~ "]/page", "PRINTFUNC"); - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "DEPARTURE") { + } else if (getprop("MCDU[" ~ i ~ "]/page") == "INITB") { + setprop("MCDU[" ~ i ~ "]/page", "INITA"); + } else if (getprop("MCDU[" ~ i ~ "]/page") == "PRINTFUNC") { + setprop("MCDU[" ~ i ~ "]/page", "PRINTFUNC2"); + } else if (getprop("MCDU[" ~ i ~ "]/page") == "PRINTFUNC2") { + setprop("MCDU[" ~ i ~ "]/page", "PRINTFUNC"); + } else if (getprop("MCDU[" ~ i ~ "]/page") == "DEPARTURE") { canvas_mcdu.myDeparture[i].scrollLeft(); - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "ARRIVAL") { + } else if (getprop("MCDU[" ~ i ~ "]/page") == "ARRIVAL") { canvas_mcdu.myArrival[i].scrollLeft(); } } else if (btn == "right") { - if (getprop("/MCDU[" ~ i ~ "]/page") == "DATA") { - setprop("/MCDU[" ~ i ~ "]/page", "DATA2"); - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "DATA2") { - setprop("/MCDU[" ~ i ~ "]/page", "DATA"); - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "INITA") { + if (getprop("MCDU[" ~ i ~ "]/page") == "DATA") { + setprop("MCDU[" ~ i ~ "]/page", "DATA2"); + } else if (getprop("MCDU[" ~ i ~ "]/page") == "DATA2") { + setprop("MCDU[" ~ i ~ "]/page", "DATA"); + } else if (getprop("MCDU[" ~ i ~ "]/page") == "INITA") { if (getprop("/engines/engine[0]/state") != 3 and getprop("/engines/engine[1]/state") != 3) { - setprop("/MCDU[" ~ i ~ "]/page", "INITB"); + setprop("MCDU[" ~ i ~ "]/page", "INITB"); } - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "INITB") { - setprop("/MCDU[" ~ i ~ "]/page", "INITA"); - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "PRINTFUNC") { - setprop("/MCDU[" ~ i ~ "]/page", "PRINTFUNC2"); - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "PRINTFUNC2") { - setprop("/MCDU[" ~ i ~ "]/page", "PRINTFUNC"); - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "DEPARTURE") { + } else if (getprop("MCDU[" ~ i ~ "]/page") == "INITB") { + setprop("MCDU[" ~ i ~ "]/page", "INITA"); + } else if (getprop("MCDU[" ~ i ~ "]/page") == "PRINTFUNC") { + setprop("MCDU[" ~ i ~ "]/page", "PRINTFUNC2"); + } else if (getprop("MCDU[" ~ i ~ "]/page") == "PRINTFUNC2") { + setprop("MCDU[" ~ i ~ "]/page", "PRINTFUNC"); + } else if (getprop("MCDU[" ~ i ~ "]/page") == "DEPARTURE") { canvas_mcdu.myDeparture[i].scrollRight(); - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "ARRIVAL") { + } else if (getprop("MCDU[" ~ i ~ "]/page") == "ARRIVAL") { canvas_mcdu.myArrival[i].scrollRight(); } } else if (btn == "up") { - if (getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNA" or getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNB") { + if (getprop("MCDU[" ~ i ~ "]/page") == "F-PLNA" or getprop("MCDU[" ~ i ~ "]/page") == "F-PLNB") { canvas_mcdu.myFpln[i].scrollUp(); - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "DEPARTURE") { + } else if (getprop("MCDU[" ~ i ~ "]/page") == "DEPARTURE") { canvas_mcdu.myDeparture[i].scrollUp(); - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "ARRIVAL") { + } else if (getprop("MCDU[" ~ i ~ "]/page") == "ARRIVAL") { canvas_mcdu.myArrival[i].scrollUp(); } } else if (btn == "down") { - if (getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNA" or getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNB") { + if (getprop("MCDU[" ~ i ~ "]/page") == "F-PLNA" or getprop("MCDU[" ~ i ~ "]/page") == "F-PLNB") { canvas_mcdu.myFpln[i].scrollDn(); - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "DEPARTURE") { + } else if (getprop("MCDU[" ~ i ~ "]/page") == "DEPARTURE") { canvas_mcdu.myDeparture[i].scrollDn(); - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "ARRIVAL") { + } else if (getprop("MCDU[" ~ i ~ "]/page") == "ARRIVAL") { canvas_mcdu.myArrival[i].scrollDn(); } } @@ -467,10 +479,10 @@ var pagebutton = func(btn, i) { if (canvas_mcdu.myFpln[i] == nil) { canvas_mcdu.myFpln[i] = fplnPage.new(2, i); } - setprop("/MCDU[" ~ i ~ "]/page", "F-PLNA"); + setprop("MCDU[" ~ i ~ "]/page", "F-PLNA"); } else { - setprop("/MCDU[" ~ i ~ "]/scratchpad-msg", 1); - setprop("/MCDU[" ~ i ~ "]/scratchpad", "ERROR. INITIALIZE ROUTE"); # Should be ERROR:, but the : character doesn't show in our MCDU font right now... + setprop("MCDU[" ~ i ~ "]/scratchpad-msg", 1); + setprop("MCDU[" ~ i ~ "]/scratchpad", "ERROR. INITIALIZE ROUTE"); # Should be ERROR:, but the : character doesn't show in our MCDU font right now... } } else if (btn == "fuel-pred") { setprop("MCDU[" ~ i ~ "]/page", "FUELPRED"); @@ -643,15 +655,15 @@ var notAllowed = func(i) { } var formatError = func(i) { - if (getprop("/MCDU[" ~ i ~ "]/scratchpad") != "FORMAT ERROR") { - if (getprop("/MCDU[" ~ i ~ "]/scratchpad-msg") == 1) { - setprop("/MCDU[" ~ i ~ "]/last-scratchpad", ""); + if (getprop("MCDU[" ~ i ~ "]/scratchpad") != "FORMAT ERROR") { + if (getprop("MCDU[" ~ i ~ "]/scratchpad-msg") == 1) { + setprop("MCDU[" ~ i ~ "]/last-scratchpad", ""); } else { - setprop("/MCDU[" ~ i ~ "]/last-scratchpad", getprop("/MCDU[" ~ i ~ "]/scratchpad")); + setprop("MCDU[" ~ i ~ "]/last-scratchpad", getprop("MCDU[" ~ i ~ "]/scratchpad")); } } - setprop("/MCDU[" ~ i ~ "]/scratchpad-msg", 1); - setprop("/MCDU[" ~ i ~ "]/scratchpad", "FORMAT ERROR"); + setprop("MCDU[" ~ i ~ "]/scratchpad-msg", 1); + setprop("MCDU[" ~ i ~ "]/scratchpad", "FORMAT ERROR"); } var screenFlash = func(time, i) { diff --git a/Nasal/MCDU/VERTREV.nas b/Nasal/MCDU/VERTREV.nas index c6478fb8..0130b0bc 100644 --- a/Nasal/MCDU/VERTREV.nas +++ b/Nasal/MCDU/VERTREV.nas @@ -1,4 +1,4 @@ -var vertrev = { +var vertRev = { title: [nil, nil, nil], subtitle: [nil, nil], fontMatrix: [[0, 0, 0, 0, 0, 0],[0, 0, 0, 0, 0, 0]], @@ -21,14 +21,14 @@ var vertrev = { index: nil, computer: nil, new: func(type, id, index, computer) { - var lr = {parents:[vertrev]}; - lr.type = type; # 0 = origin 1 = destination 2 = ppos (from waypoint) 3 = generic wpt, 4 = discon - lr.id = id; - lr.index = index; - lr.computer = computer; - lr._setupPageWithData(); - lr._checkTmpy(); - return lr; + var vr = {parents:[vertRev]}; + vr.type = type; # 0 = origin 1 = destination 2 = wpt not ppos 3 = ppos 4 = cruise wpt 5 = climb wpt (3 + 4 not needed yet) + vr.id = id; + vr.index = index; + vr.computer = computer; + vr._setupPageWithData(); + vr._checkTmpy(); + return vr; }, del: func() { return nil; @@ -37,85 +37,62 @@ var vertrev = { if (fmgc.flightPlanController.temporaryFlag[me.computer]) { me.L6 = [" F-PLN", " TMPY", "yel"]; me.arrowsColour[0][5] = "yel"; - me.R2[2] = "yel"; - me.R3[2] = "yel"; - me.R4[2] = "yel"; canvas_mcdu.pageSwitch[me.computer].setBoolValue(0); } }, _setupPageWithData: func() { - if (me.type == 2) { + if (me.type == 3) { me.title = ["VERT REV", " AT ", "PPOS"]; - me.L2 = [" OFFSET", nil, "wht"]; - me.L3 = [" HOLD", nil, "wht"]; + me.L1 = ["", " EFOB=---", "wht"]; + me.R1 = ["", "EXTRA=--- ", "wht"]; + me.L2 = [" 250/10000", " CLB SPD LIM", "mag"]; + me.L4 = [" CONSTANT MACH", nil, "wht"]; + me.L5 = [" WIND DATA", nil, "wht"]; me.L6 = [" RETURN", nil, "wht"]; - me.R1 = ["FIX INFO ", nil, "wht"]; - me.R2 = ["[ ]°/[ ]°/[ ]", "LL XING/INCR/NO", "blu"]; - me.arrowsMatrix = [[0, 1, 1, 0, 0, 1], [1, 0, 0, 0, 0, 0]]; - me.arrowsColour = [["ack", "wht", "wht", "ack", "ack", "wht"], ["wht", "ack", "ack", "ack", "ack", "ack"]]; - me.fontMatrix = [[0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0]]; - } elsif (me.type == 4) { - me.title = ["VERT REV", " AT ", "DISCON"]; - me.R3 = ["[ ]", "NEXT WPT ", "blu"]; - me.R4 = ["[ ]", "NEW DEST", "blu"]; - me.L6 = [" RETURN", nil, "wht"]; - me.arrowsMatrix = [[0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0]]; - me.arrowsColour = [["ack", "ack", "ack", "ack", "ack", "wht"], ["ack", "ack", "ack", "ack", "ack", "ack"]]; - me.fontMatrix = [[0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 0, 0]]; + me.R5 = ["STEP ALTS ", nil, "wht"]; + me.arrowsMatrix = [[0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 1, 0]]; + me.arrowsColour = [["ack", "ack", "ack", "wht", "wht", "wht"], ["ack", "ack", "ack", "ack", "wht", "ack"]]; + me.fontMatrix = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]; + } if (me.type == 2) { + me.title = ["VERT REV", " AT ", me.id]; + me.L1 = ["", " EFOB=---", "wht"]; + me.R1 = ["", "EXTRA=--- ", "wht"]; + me.L2 = [" 250/10000", " CLB SPD LIM", "mag"]; + me.L3 = [" [ ]", " SPD CSTR", "blu"]; + me.L4 = [" CONSTANT MACH", nil, "wht"]; + me.L5 = [" WIND DATA", nil, "wht"]; + me.L6 = [" CLB", nil, "wht"]; + me.R2 = ["[ ] ", "UTC CSTR ", "blu"]; + me.R3 = ["[ ] ", "ALT CSTR ", "blu"]; + me.R5 = ["STEP ALTS ", nil, "wht"]; + me.R6 = ["DES ", nil, "wht"]; + me.arrowsMatrix = [[0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 1, 0]]; + me.arrowsColour = [["ack", "ack", "ack", "wht", "wht", "wht"], ["ack", "ack", "ack", "ack", "wht", "ack"]]; + me.fontMatrix = [[0, 0, 1, 0, 0, 0], [0, 1, 1, 0, 0, 0]]; } else { me.title = ["VERT REV", " AT ", me.id]; if (me.type == 0) { - if (size(me.id) > 4) { - me.depAirport = findAirportsByICAO(left(me.id, 4)); - } else { - me.depAirport = findAirportsByICAO(me.id); - } - me.subtitle = [dmsToString(sprintf(me.depAirport[0].lat), "lat"), dmsToString(sprintf(me.depAirport[0].lon), "lon")]; - me.L1 = [" DEPARTURE", nil, "wht"]; - me.L2 = [" OFFSET", nil, "wht"]; - me.L6 = [" RETURN", nil, "wht"]; - me.R1 = ["FIX INFO ", nil, "wht"]; - me.R2 = ["[ ]°/[ ]°/[ ]", "LL XING/INCR/NO", "blu"]; - me.R3 = ["[ ]", "NEXT WPT ", "blu"]; - me.R4 = ["[ ]", "NEW DEST", "blu"]; - me.arrowsMatrix = [[1, 1, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0]]; - me.arrowsColour = [["wht", "wht", "ack", "ack", "ack", "wht"], ["wht", "ack", "ack", "ack", "ack", "ack"]]; - me.fontMatrix = [[0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 0, 0]]; + # dunno } elsif (me.type == 1) { if (size(me.id) > 4) { me.arrAirport = findAirportsByICAO(left(me.id, 4)); } else { me.arrAirport = findAirportsByICAO(me.id); } - me.subtitle = [dmsToString(sprintf(me.arrAirport[0].lat), "lat"), dmsToString(sprintf(me.arrAirport[0].lon), "lon")]; - me.L3 = [" ALTN", nil, "wht"]; - me.L4 = [" ALTN", " ENABLE", "blu"]; - me.L6 = [" RETURN", nil, "wht"]; - me.R1 = ["ARRIVAL ", nil, "wht"]; - me.R3 = ["[ ]", "NEXT WPT ", "blu"]; - me.arrowsMatrix = [[0, 0, 1, 1, 0, 1], [1, 0, 0, 0, 0, 0]]; - me.arrowsColour = [["ack", "ack", "wht", "blu", "ack", "wht"], ["wht", "ack", "ack", "ack", "ack", "ack"]]; - me.fontMatrix = [[0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0]]; - } elsif (me.type == 3) { - if (size(me.id) == 2 or size(me.id) == 3) { - me.wpt = findNavaidsByID(me.id); - } elsif (size(me.id) == 4) { - me.wpt = findAirportsByICAO(me.id); - } elsif (size(me.id) == 5) { - me.wpt = findFixesByID(me.id); - } - me.subtitle = [dmsToString(sprintf(me.wpt[0].lat), "lat"), dmsToString(sprintf(me.wpt[0].lon), "lon")]; - me.L3 = [" HOLD", nil, "wht"]; - me.L4 = [" ALTN", " ENABLE", "blu"]; - me.L6 = [" RETURN", nil, "wht"]; - me.R1 = ["FIX INFO ", nil, "wht"]; - me.R3 = ["[ ]", "NEXT WPT ", "blu"]; - me.R4 = ["[ ]", "NEW DEST", "blu"]; - me.R5 = ["AIRWAYS ", nil, "wht"]; - me.arrowsMatrix = [[0, 0, 1, 1, 0, 1], [1, 0, 0, 0, 1, 0]]; - me.arrowsColour = [["ack", "ack", "wht", "blu", "ack", "wht"], ["wht", "ack", "ack", "ack", "wht", "ack"]]; - me.fontMatrix = [[0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 0, 0]]; + me.L1 = ["", " EFOB=---", "wht"]; + me.R1 = ["", "EXTRA=--- ", "wht"]; + me.L2 = [" 250/10000", " DES SPD LIM", "mag"]; + me.L4 = [" CONSTANT MACH", nil, "wht"]; + me.L5 = [" WIND DATA", nil, "wht"]; + me.L6 = [" CLB", nil, "wht"]; + me.R2 = ["[ ] ", "UTC CSTR ", "blu"]; + me.R3 = ["[ ]", "G/S INTCPT ", "grn"]; + me.R5 = ["STEP ALTS ", nil, "wht"]; + me.R6 = ["DES ", nil, "wht"]; + me.arrowsMatrix = [[0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 1, 0]]; + me.arrowsColour = [["ack", "ack", "ack", "wht", "wht", "wht"], ["ack", "ack", "ack", "ack", "wht", "ack"]]; + me.fontMatrix = [[0, 0, 1, 0, 0, 0], [0, 1, 1, 0, 0, 0]]; } } }, @@ -125,58 +102,4 @@ var vertrev = { me._checkTmpy(); } }, - nextWpt: func() { - me.makeTmpy(); - - var returny = fmgc.flightPlanController.scratchpad(getprop("/MCDU[" ~ me.computer ~ "]/scratchpad"), me.index + 1, me.computer); - if (returny == 0) { - notInDataBase(me.computer); - } elsif (returny == 1) { - notAllowed(me.computer); - } else { - setprop("/MCDU[" ~ me.computer ~ "]/scratchpad-msg", ""); - setprop("/MCDU[" ~ me.computer ~ "]/scratchpad", ""); - fmgc.flightPlanController.flightPlanChanged(me.computer); - setprop("/MCDU[" ~ me.computer ~ "]/page", "F-PLNA"); - } - }, -}; - -var dmsToString = func(dms, type) { - var degrees = int(dms); - var minutes = sprintf("%.1f",abs((dms - degrees) * 60)); - if (type == "lat") { - var sign = degrees >= 0 ? "N" : "S"; - } else { - var sign = degrees >= 0 ? "E" : "W"; - } - return abs(degrees) ~ "g" ~ minutes ~ " " ~ sign; -} - - -var stringToDegrees = func(string, type) { - if (type == "lat") { - var degrees = left(string, 2); - var minutesStr = right(string, 5); - } else { - var degrees = left(string, 3); - var minutesStr = right(string, 5); - } - - var minutes = left(minutesStr, 4); - var sign = right(minutesStr, 1); - var decimal = degrees + (minutes / 60); - if (type == "lat") { - if (sign == "N") { - return decimal; - } else { - return -decimal; - } - } else { - if (sign == "E") { - return decimal; - } else { - return -decimal; - } - } -} \ No newline at end of file +}; \ No newline at end of file From 7caf5a676e3a2e5ab32a28abcc892beebe4848e8 Mon Sep 17 00:00:00 2001 From: legoboyvdlp R Date: Thu, 19 Mar 2020 18:09:27 +0000 Subject: [PATCH 23/51] bugfixes --- Models/Instruments/MCDU/MCDU.nas | 16 +-- Nasal/MCDU/F-PLN-rework.nas | 3 +- Nasal/MCDU/F-PLN.nas | 196 ------------------------------- 3 files changed, 10 insertions(+), 205 deletions(-) delete mode 100644 Nasal/MCDU/F-PLN.nas diff --git a/Models/Instruments/MCDU/MCDU.nas b/Models/Instruments/MCDU/MCDU.nas index be5351b3..3a335b77 100644 --- a/Models/Instruments/MCDU/MCDU.nas +++ b/Models/Instruments/MCDU/MCDU.nas @@ -181,14 +181,13 @@ var canvas_MCDU_base = { }, getKeys: func() { return ["Simple","Simple_Center","Scratchpad","Simple_Title","Simple_PageNum","ArrowLeft","ArrowRight","Simple_L1","Simple_L2","Simple_L3","Simple_L4" - ,"Simple_L5","Simple_L6","Simple_L1S","Simple_L2S","Simple_L3S","Simple_L4S","Simple_L5S","Simple_L6S", "Simple_L1_Arrow","Simple_L2_Arrow", - "Simple_L3_Arrow","Simple_L4_Arrow","Simple_L5_Arrow","Simple_L6_Arrow","Simple_R1","Simple_R2","Simple_R3","Simple_R4","Simple_R5","Simple_R6", - "Simple_R1S","Simple_R2S","Simple_R3S","Simple_R4S","Simple_R5S","Simple_R6S","Simple_R1_Arrow","Simple_R2_Arrow","Simple_R3_Arrow","Simple_R4_Arrow", - "Simple_R5_Arrow","Simple_R6_Arrow","Simple_C1","Simple_C2","Simple_C3","Simple_C4","Simple_C5","Simple_C6","Simple_C1S","Simple_C2S","Simple_C3S", - "Simple_C4S","Simple_C5S","Simple_C6S","INITA","INITA_CoRoute","INITA_FltNbr","INITA_CostIndex","INITA_CruiseFLTemp","INITA_FromTo", - "INITA_InitRequest","INITA_AlignIRS","INITB","INITB_ZFWCG","INITB_ZFW","INITB_ZFW_S","INITB_Block","PERFTO","PERFTO_V1","PERFTO_VR","PERFTO_V2", - "PERFTO_FE","PERFTO_SE","PERFTO_OE","PERFAPPR","PERFAPPR_FE","PERFAPPR_SE","PERFAPPR_OE","FPLN","FPLN_From","FPLN_TMPY_group","FPLN_Callsign", - "departureTMPY", "arrowsDepArr","arrow1L","arrow2L","arrow3L","arrow4L","arrow5L","arrow1R","arrow2R","arrow3R","arrow4R","arrow5R"]; + ,"Simple_L5","Simple_L6","Simple_L0S","Simple_L1S","Simple_L2S","Simple_L3S","Simple_L4S","Simple_L5S","Simple_L6S", "Simple_L1_Arrow", + "Simple_L2_Arrow","Simple_L3_Arrow","Simple_L4_Arrow","Simple_L5_Arrow","Simple_L6_Arrow","Simple_R1","Simple_R2","Simple_R3","Simple_R4","Simple_R5", + "Simple_R6","Simple_R1S","Simple_R2S","Simple_R3S","Simple_R4S","Simple_R5S","Simple_R6S","Simple_R1_Arrow","Simple_R2_Arrow","Simple_R3_Arrow", + "Simple_R4_Arrow","Simple_R5_Arrow","Simple_R6_Arrow","Simple_C1","Simple_C2","Simple_C3","Simple_C4","Simple_C5","Simple_C6","Simple_C1S", + "Simple_C2S","Simple_C3S","Simple_C4S","Simple_C5S","Simple_C6S","INITA","INITA_CoRoute","INITA_FltNbr","INITA_CostIndex","INITA_CruiseFLTemp", + "INITA_FromTo","INITA_InitRequest","INITA_AlignIRS","INITB","INITB_ZFWCG","INITB_ZFW","INITB_ZFW_S","INITB_Block","PERFTO","PERFTO_V1","PERFTO_VR","PERFTO_V2","PERFTO_FE","PERFTO_SE","PERFTO_OE","PERFAPPR","PERFAPPR_FE","PERFAPPR_SE","PERFAPPR_OE","FPLN","FPLN_From","FPLN_TMPY_group", + "FPLN_Callsign","departureTMPY", "arrowsDepArr","arrow1L","arrow2L","arrow3L","arrow4L","arrow5L","arrow1R","arrow2R","arrow3R","arrow4R","arrow5R"]; }, update: func() { if (systems.ELEC.Bus.ac1.getValue() >= 110 and mcdu1_lgt.getValue() > 0.01) { @@ -239,6 +238,7 @@ var canvas_MCDU_base = { me.fontRightS(default, default, default, default, default, default); me.fontSizeLeft(normal, normal, normal, normal, normal, normal); + me.fontSizeCenter(normal, normal, normal, normal, normal, normal); me.fontSizeRight(normal, normal, normal, normal, normal, normal); pageSwitch[i].setBoolValue(1); } diff --git a/Nasal/MCDU/F-PLN-rework.nas b/Nasal/MCDU/F-PLN-rework.nas index a7d38f8d..b720ed79 100644 --- a/Nasal/MCDU/F-PLN-rework.nas +++ b/Nasal/MCDU/F-PLN-rework.nas @@ -106,13 +106,13 @@ var fplnItem = { canvas_mcdu.myVertRev[me.computer].del(); } canvas_mcdu.myVertRev[me.computer] = nil; - notAllowed(me.computer); if (fmgc.flightPlanController.temporaryFlag[me.computer]) { if (me.index == fmgc.flightPlanController.arrivalIndex[me.computer]) { canvas_mcdu.myVertRev[me.computer] = vertRev.new(1, left(me.wp.wp_name, 4), me.index, me.computer); } if (left(me.wp.wp_name, 4) == fmgc.flightPlanController.flightplans[me.computer].departure.id) { notAllowed(me.computer); + return; } elsif (me.index == (fmgc.flightPlanController.currentToWptIndex.getValue() - 1)) { canvas_mcdu.myVertRev[me.computer] = vertRev.new(3, me.wp.wp_name, me.index, me.computer); } else { @@ -123,6 +123,7 @@ var fplnItem = { canvas_mcdu.myVertRev[me.computer] = vertRev.new(1, left(me.wp.wp_name, 4), me.index, me.computer); } elsif (left(me.wp.wp_name, 4) == fmgc.flightPlanController.flightplans[2].departure.id) { notAllowed(me.computer); + return; } elsif (me.index == (fmgc.flightPlanController.currentToWptIndex.getValue() - 1)) { canvas_mcdu.myVertRev[me.computer] = vertRev.new(3, me.wp.wp_name, me.index, me.computer); } else { diff --git a/Nasal/MCDU/F-PLN.nas b/Nasal/MCDU/F-PLN.nas deleted file mode 100644 index 52398beb..00000000 --- a/Nasal/MCDU/F-PLN.nas +++ /dev/null @@ -1,196 +0,0 @@ - - pushButtonLeft: func() { - if (me.type != "discontinuity") { - notAllowed(me.computer.mcdu); - } else { - var scratchpad = getprop("/MCDU[" ~ me.computer.mcdu ~ "]/scratchpad"); - if (me.computer.lines == MAIN and scratchpad != "CLR" and scratchpad != "") { - fmgc.flightPlanController.createTemporaryFlightPlan(me.computer.mcdu); - } - if (fmgc.flightPlanController.temporaryFlag[me.computer.mcdu]) { - if (scratchpad == "CLR") { - if (fmgc.flightPlanController.deleteWP(me.index, me.computer.mcdu, 0) != 0) { - notAllowed(me.computer.mcdu); - } else { - setprop("/MCDU[" ~ me.computer.mcdu ~ "]/scratchpad-msg", 0); - setprop("/MCDU[" ~ me.computer.mcdu ~ "]/scratchpad", ""); - } - } elsif (size(scratchpad) == 5) { - var fix = findFixesByID(scratchpad); - if (size(fix) >= 1) { - var indexWp = fmgc.flightPlanController.flightplans[me.computer.mcdu].indexOfWP(fix[0]); - if (indexWp == -1) { - var insertReturn = fmgc.flightPlanController.insertFix(scratchpad, me.index, me.computer.mcdu); - fmgc.flightPlanController.flightPlanChanged(me.computer.mcdu); - } else { - var numTimesDelete = indexWp - me.index; - while (numTimesDelete > 0) { - fmgc.flightPlanController.deleteWP(me.index + 1, me.computer.mcdu, 0); - numTimesDelete -= 1; - } - } - if (insertReturn == 2) { - notAllowed(me.computer.mcdu); - } else if (insertReturn == 1) { - notInDataBase(me.computer.mcdu); - } else { - setprop("/MCDU[" ~ me.computer.mcdu ~ "]/scratchpad", ""); - } - } else { - notInDataBase(me.computer.mcdu); - } - } else if (size(scratchpad) == 4) { - var arpt = findAirportsByICAO(scratchpad); - if (size(arpt) >= 1) { - var indexWp = fmgc.flightPlanController.flightplans[me.computer.mcdu].indexOfWP(arpt[0]); - if (indexWp == -1) { - var insertReturn = fmgc.flightPlanController.insertArpt(scratchpad, me.index, me.computer.mcdu); - fmgc.flightPlanController.flightPlanChanged(me.computer.mcdu); - } else { - var numTimesDelete = indexWp - me.index; - while (numTimesDelete > 0) { - fmgc.flightPlanController.deleteWP(me.index + 1, me.computer.mcdu, 0); - numTimesDelete -= 1; - } - } - if (insertReturn == 2) { - notAllowed(me.computer.mcdu); - } else if (insertReturn == 1) { - notInDataBase(me.computer.mcdu); - } else { - setprop("/MCDU[" ~ me.computer.mcdu ~ "]/scratchpad", ""); - } - } else { - notInDataBase(me.computer.mcdu); - } - } else if (size(scratchpad) == 3 or size(scratchpad) == 2) { - var navaid = findNavaidsByID(scratchpad); - if (size(navaid) >= 1) { - var indexWp = fmgc.flightPlanController.flightplans[me.computer.mcdu].indexOfWP(navaid[0]); - if (indexWp == -1) { - var insertReturn = fmgc.flightPlanController.insertNavaid(scratchpad, me.index, me.computer.mcdu); - fmgc.flightPlanController.flightPlanChanged(me.computer.mcdu); - } else { - var numTimesDelete = indexWp - me.index; - while (numTimesDelete > 0) { - fmgc.flightPlanController.deleteWP(me.index + 1, me.computer.mcdu, 0); - numTimesDelete -= 1; - } - } - if (insertReturn == 2) { - notAllowed(me.computer.mcdu); - } else if (insertReturn == 1) { - notInDataBase(me.computer.mcdu); - } else { - setprop("/MCDU[" ~ me.computer.mcdu ~ "]/scratchpad", ""); - } - } else { - notInDataBase(me.computer.mcdu); - } - } elsif (scratchpad == "") { - if (canvas_mcdu.myLatRev[me.computer.mcdu] != nil) { - canvas_mcdu.myLatRev[me.computer.mcdu].del(); - } - canvas_mcdu.myLatRev[me.computer.mcdu] = nil; - canvas_mcdu.myLatRev[me.computer.mcdu] = latRev.new(4, "DISCON", me.index, me.computer.mcdu); - setprop("/MCDU[" ~ me.computer.mcdu ~ "]/page", "LATREV"); - } else { - notAllowed(me.computer.mcdu); - } - } else { - if (scratchpad == "CLR") { - if (fmgc.flightPlanController.deleteWP(me.index, 2, 0) != 0) { - notAllowed(me.computer.mcdu); - } else { - setprop("/MCDU[" ~ me.computer.mcdu ~ "]/scratchpad-msg", 0); - setprop("/MCDU[" ~ me.computer.mcdu ~ "]/scratchpad", ""); - } - } elsif (size(scratchpad) != 0) { - me.pushButtonLeft(); - } elsif (scratchpad == "") { - if (canvas_mcdu.myLatRev[me.computer.mcdu] != nil) { - canvas_mcdu.myLatRev[me.computer.mcdu].del(); - } - canvas_mcdu.myLatRev[me.computer.mcdu] = nil; - canvas_mcdu.myLatRev[me.computer.mcdu] = latRev.new(4, "DISCON", me.index, me.computer.mcdu); - setprop("/MCDU[" ~ me.computer.mcdu ~ "]/page", "LATREV"); - } else { - notAllowed(me.computer.mcdu); - } - } - } - }, - -var FPLNLineComputer = { - new: func(mcdu) { - var in = {parents:[FPLNLineComputer]}; - in.mcdu = mcdu; - in.planEnd = StaticText.new(in, "fplnEnd"); - in.planNoAlt = StaticText.new(in, "noAltnFpln"); - if (debug == 1) printf("%d: Line computer created.", in.mcdu); - return in; - }, - index: 0, - planList: [], - destination: nil, - destIndex: nil, - planEnd: nil, - planNoAlt: nil, - lines: nil, - output: [], - mcdu: nil, - fplnID: nil, - enableScroll: 0, - clear: func() { - me.planList = []; - me.destIndex = -1; - me.destination = nil; - me.index = 0; - me.output = []; - me.enableScroll = 0; - if (me.lines == nil) { - me.lines = MAIN; - } - me.updateScroll(); - }, - replacePlan: func(fplnID, lines, firstLineIndex) { - # Here you set another plan, do this when changing plan on display or when destination changes - if (debug == 1) printf("%d: replacePlan called for %d lines and firstLine %d", me.mcdu, lines, firstLineIndex); - var fpln = nil; - - me.planList = []; - - if (!fmgc.flightPlanController.active.getBoolValue()) { - me.destIndex = -1; - me.destination = nil; - } else { - fpln = fmgc.flightPlanController.flightplans[fplnID]; # Get the Nasal Flightplan - me.destIndex = fmgc.flightPlanController.arrivalIndex[fplnID]; - me.destination = FPLNText.new(me, fpln.getWP(me.destIndex), 1, fplnID, me.destIndex); - for (var j = 0; j < fpln.getPlanSize(); j += 1) { - me.dest = 0; - if (j == me.destIndex) { - me.dest = 1; - } - var wpt = fpln.getWP(j); - if (wpt.wp_name == "DISCONTINUITY") { - append(me.planList, StaticText.new(me, "discontinuity", j)); - } else { - append(me.planList, FPLNText.new(me, fpln.getWP(j), me.dest, fplnID, j)); - } - } - if (debug == 1) printf("%d: dest is: %s", me.mcdu, fpln.getWP(me.destIndex).wp_name); - } - me.index = firstLineIndex; - me.lines = lines; - me.initScroll(); - }, - initScroll: func() { - me.maxItems = size(me.planList) + 2; # + 2 is for end of plan line and altn end of plan. - me.enableScroll = me.lines < me.maxItems; - me.checkIndex(); - if (debug == 1) printf("%d: scroll is %d. Size of plan is %d", me.mcdu, me.enableScroll, size(me.planList)); - me.updateScroll(); - }, -}; - From a7d04e6338938445a7e67aeb59612a016e5a3dad Mon Sep 17 00:00:00 2001 From: legoboyvdlp R Date: Thu, 19 Mar 2020 18:39:30 +0000 Subject: [PATCH 24/51] Bugfix font size / colour --- Models/Instruments/MCDU/MCDU.nas | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Models/Instruments/MCDU/MCDU.nas b/Models/Instruments/MCDU/MCDU.nas index 3a335b77..d8753d69 100644 --- a/Models/Instruments/MCDU/MCDU.nas +++ b/Models/Instruments/MCDU/MCDU.nas @@ -508,6 +508,11 @@ var canvas_MCDU_base = { } me.colorRight(myFpln[i].R1[2],myFpln[i].R2[2],myFpln[i].R3[2],myFpln[i].R4[2],myFpln[i].R5[2],myFpln[i].R6[2]); + me.colorLeftS("wht", "wht", "wht", "wht", "wht", "wht"); + me.colorLeftArrow("wht", "wht", "wht", "wht", "wht", "wht"); + me.colorRightS("wht", "wht", "wht", "wht", "wht", "wht"); + me.colorRightArrow("wht", "wht", "wht", "wht", "wht", "wht"); + #if (mcdu.FPLNLines[i].index == 0) { # me["FPLN_From"].show(); #} else { From 3aada81966adc3502e86fc7112323d793242fedc Mon Sep 17 00:00:00 2001 From: legoboyvdlp R Date: Tue, 24 Mar 2020 16:46:27 +0000 Subject: [PATCH 25/51] FROM legend, now show UTC / altitude of FROM waypoint --- Models/Instruments/MCDU/MCDU.nas | 2 +- Models/Instruments/MCDU/res/mcdu.svg | 870 ++++++++++++++------------- Nasal/FMGC/flightplan.nas | 22 + Nasal/MCDU/F-PLN-rework.nas | 18 +- 4 files changed, 479 insertions(+), 433 deletions(-) diff --git a/Models/Instruments/MCDU/MCDU.nas b/Models/Instruments/MCDU/MCDU.nas index 02eaca25..fe66ff7c 100644 --- a/Models/Instruments/MCDU/MCDU.nas +++ b/Models/Instruments/MCDU/MCDU.nas @@ -202,7 +202,7 @@ var canvas_MCDU_base = { "Simple_R4_Arrow","Simple_R5_Arrow","Simple_R6_Arrow","Simple_C1","Simple_C2","Simple_C3","Simple_C4","Simple_C5","Simple_C6","Simple_C1S", "Simple_C2S","Simple_C3S","Simple_C4S","Simple_C5S","Simple_C6S","INITA","INITA_CoRoute","INITA_FltNbr","INITA_CostIndex","INITA_CruiseFLTemp", "INITA_FromTo","INITA_InitRequest","INITA_AlignIRS","INITB","INITB_ZFWCG","INITB_ZFW","INITB_ZFW_S","INITB_Block","PERFTO","PERFTO_V1","PERFTO_VR","PERFTO_V2","PERFTO_FE","PERFTO_SE","PERFTO_OE","PERFAPPR","PERFAPPR_FE","PERFAPPR_SE","PERFAPPR_OE","PERFGA","PERFGA_FE","PERFGA_SE","PERFGA_OE", - "FPLN","FPLN_From","FPLN_TMPY_group","FPLN_Callsign","departureTMPY", "arrowsDepArr","arrow1L","arrow2L","arrow3L","arrow4L","arrow5L","arrow1R", + "FPLN","FPLN_From","FPLN_TMPY_group","FPLN_FROM","FPLN_Callsign","departureTMPY", "arrowsDepArr","arrow1L","arrow2L","arrow3L","arrow4L","arrow5L","arrow1R", "arrow2R","arrow3R","arrow4R","arrow5R"]; }, update: func() { diff --git a/Models/Instruments/MCDU/res/mcdu.svg b/Models/Instruments/MCDU/res/mcdu.svg index 5ad19c52..cfdaef17 100644 --- a/Models/Instruments/MCDU/res/mcdu.svg +++ b/Models/Instruments/MCDU/res/mcdu.svg @@ -41,13 +41,13 @@ inkscape:window-height="705" id="namedview371" showgrid="true" - inkscape:zoom="4.1661918" - inkscape:cx="37.539162" - inkscape:cy="725.25661" + inkscape:zoom="1.5306292" + inkscape:cx="332.0077" + inkscape:cy="938.33632" inkscape:window-x="-8" inkscape:window-y="-8" inkscape:window-maximized="1" - inkscape:current-layer="Simple" + inkscape:current-layer="svg2" showguides="false" inkscape:snap-global="false" units="px" @@ -871,446 +871,460 @@ x="18.917452" id="tspan4269-7" sodipodi:role="line">TEXT + + + style="display:inline" + id="Simple-9" + inkscape:label="Simple"> - - - - - - - - - - - + + + + + + + + + + CALLSIG + + CALLSIG + x="350.9628" + id="tspan3617" + sodipodi:role="line">TMPY + id="FPLN_TMPY_ERASE" + inkscape:label="#g3715"> + ERASE TMPY - - ERASE - TMPY - - - - - - + id="tspan3629" + sodipodi:role="line">TMPY - + + + + + + + TMPY - TMPY + INSERT - - - - - - + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:70px;line-height:1.25;font-family:BoeingCDULarge;-inkscape-font-specification:BoeingCDULarge;text-align:end;text-anchor:end;fill:#bb6100;fill-opacity:1">INSERT + + + + + + FROM + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + id="arrow5L" + inkscape:label="arrow5L" + transform="matrix(1.0000008,0,0,0.99998914,-895.98809,589.53826)" + style="stroke:#bb6100;stroke-opacity:1"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -2135,7 +2149,7 @@ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:70px;line-height:1.25;font-family:BoeingCDULarge;-inkscape-font-specification:BoeingCDULarge;text-align:start;text-anchor:start;fill:#ffffff;fill-opacity:1" y="187.10254" x="399.48752" - id="tspan1079" + id="tspan339" sodipodi:role="line">F S @@ -2161,7 +2175,7 @@ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:70px;line-height:1.25;font-family:BoeingCDULarge;-inkscape-font-specification:BoeingCDULarge;text-align:start;text-anchor:start;fill:#ffffff;fill-opacity:1" y="422.15305" x="398.21817" - id="tspan1085" + id="tspan345" sodipodi:role="line">O = @@ -2187,7 +2201,7 @@ style="font-style:normal;font-variant:normal;font-weight:500;font-stretch:normal;font-size:63.9924px;line-height:1.25;font-family:'Helvetica Medium';-inkscape-font-specification:'Helvetica Medium, Medium';text-align:start;text-anchor:start;fill:#ffffff;fill-opacity:1" y="278.32764" x="478.87796" - id="tspan1091" + id="tspan351" sodipodi:role="line">= = diff --git a/Nasal/FMGC/flightplan.nas b/Nasal/FMGC/flightplan.nas index 65a58f01..980321a0 100644 --- a/Nasal/FMGC/flightplan.nas +++ b/Nasal/FMGC/flightplan.nas @@ -46,6 +46,10 @@ var flightPlanController = { arrivalIndex: [0, 0, 0], arrivalDist: 0, _arrivalDist: 0, + fromWptTime: nil, + fromWptAlt: nil, + _timeTemp: nil, + _altTemp: nil, reset: func() { me.temporaryFlag[0] = 0; @@ -94,6 +98,24 @@ var flightPlanController = { }, autoSequencing: func() { + me._timeTemp = math.round(getprop("/sim/time/utc/minute") + (getprop("/sim/time/utc/second") / 60)); + if (me._timeTemp < 10) { + me._timeTemp = "0" ~ me._timeTemp; + } + me.fromWptTime = getprop("/sim/time/utc/hour") ~ me._timeTemp; + me._altTemp = getprop("/systems/navigation/adr/output/baro-alt-corrected-1-capt"); + + if (me._altTemp > getprop("FMGC/internal/trans-alt")) { + me.fromWptAlt = "FL" ~ math.round(me._altTemp / 100); + } else { + if (me._altTemp > 0) { + me.fromWptAlt = math.round(me._altTemp); + } else { + me.fromWptAlt = "M" ~ math.round(me._altTemp); + } + } + + # todo setlistener on sim/time/warp to recompute predictions if (me.num[2].getValue() > 2) { if (me.temporaryFlag[0] == 1 and wpID[0][0] == wpID[2][0]) { me.deleteWP(0, 0); diff --git a/Nasal/MCDU/F-PLN-rework.nas b/Nasal/MCDU/F-PLN-rework.nas index b720ed79..fc843f62 100644 --- a/Nasal/MCDU/F-PLN-rework.nas +++ b/Nasal/MCDU/F-PLN-rework.nas @@ -31,9 +31,15 @@ var fplnItem = { updateCenterText: func() { if (me.wp != nil) { if (me.wp.wp_name != "DISCONTINUITY") { - me.brg = me.getBrg(); - me.track = me.getTrack(); - return ["---- ", nil, me.colour]; + if (me.index != (fmgc.flightPlanController.currentToWptIndex.getValue() - 1) or fmgc.flightPlanController.fromWptTime == nil) { + me.brg = me.getBrg(); + me.track = me.getTrack(); + return ["---- ", nil, me.colour]; + } else { + me.brg = me.getBrg(); + me.track = me.getTrack(); + return [fmgc.flightPlanController.fromWptTime ~ " ", nil, me.colour]; + } } else { return ["---F-PLN DISCONTINUITY--", nil, "wht"]; } @@ -65,7 +71,11 @@ var fplnItem = { return "---"; }, getAlt: func() { - return "-----"; + if (me.index == (fmgc.flightPlanController.currentToWptIndex.getValue() - 1) and fmgc.flightPlanController.fromWptAlt != nil) { + return " " ~ fmgc.flightPlanController.fromWptAlt; + } else { + return "-----"; + } }, getDist: func() { return "--"; From ea95889252914f31aef9f7249f20a894846bf307 Mon Sep 17 00:00:00 2001 From: legoboyvdlp R Date: Wed, 25 Mar 2020 15:05:04 +0000 Subject: [PATCH 26/51] Experimental support for cases like EGJJ --- Nasal/FMGC/flightplan.nas | 2 +- Nasal/MCDU/DEPARTURE.nas | 3 +++ Nasal/MCDU/F-PLN-rework.nas | 12 ++++++++++-- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/Nasal/FMGC/flightplan.nas b/Nasal/FMGC/flightplan.nas index 980321a0..6dc7c622 100644 --- a/Nasal/FMGC/flightplan.nas +++ b/Nasal/FMGC/flightplan.nas @@ -420,7 +420,7 @@ var flightPlanController = { wpCoursePrev[n][wpt].setValue(courseDistanceFromPrev[0]); wpDistancePrev[n][wpt].setValue(courseDistanceFromPrev[1]); if (me.flightplans[n].getWP(wpt - 1).wp_type != "vectors" and me.flightplans[n].getWP(wpt - 1).wp_type != "hdgToAlt" and me.flightplans[n].getWP(wpt).wp_type != "vectors" and me.flightplans[n].getWP(wpt).wp_type != "hdgToAlt" and wpt <= me.arrivalIndex[n]) { - me._arrivalDist += courseDistanceFromPrev[1]; + me._arrivalDist += courseDistanceFromPrev[1]; # todo - buggy. Neglect discontinuity, and should show distance to next wpt, + distance thereafter } } else { # use PPOS for the first waypoint diff --git a/Nasal/MCDU/DEPARTURE.nas b/Nasal/MCDU/DEPARTURE.nas index 50e864ed..2b1b8412 100644 --- a/Nasal/MCDU/DEPARTURE.nas +++ b/Nasal/MCDU/DEPARTURE.nas @@ -251,6 +251,9 @@ var departurePage = { } if (me.selectedRunway != nil) { me._sids = me.depAirport[0].sids(me.selectedRunway.id); + if (size(me._sids) == 0) { # account for cases such as EGJJ where runway code does not match SIDS + me._sids = me.depAirport[0].sids(); + } } else { me._sids = me.depAirport[0].sids(); } diff --git a/Nasal/MCDU/F-PLN-rework.nas b/Nasal/MCDU/F-PLN-rework.nas index fc843f62..0b5380c0 100644 --- a/Nasal/MCDU/F-PLN-rework.nas +++ b/Nasal/MCDU/F-PLN-rework.nas @@ -309,8 +309,16 @@ var fplnPage = { # this one is only created once, and then updated - remember th } }, destInfo: func() { - me.L6 = [left(me.plan.getWP(fmgc.flightPlanController.arrivalIndex[me.planIndex]).wp_name, 4), " DEST", "wht"]; - me.C6 = ["---- " ~ int(fmgc.flightPlanController.arrivalDist), "TIME DIST", "wht"]; + if (me.plan.getWP(fmgc.flightPlanController.arrivalIndex[me.planIndex]) != nil) { + me.L6 = [left(me.plan.getWP(fmgc.flightPlanController.arrivalIndex[me.planIndex]).wp_name, 4), " DEST", "wht"]; + } else { + me.L6 = ["----", " DEST", "wht"]; + } + if (fmgc.flightPlanController.arrivalDist != nil) { + me.C6 = ["---- " ~ int(fmgc.flightPlanController.arrivalDist), "TIME DIST", "wht"]; + } else { + me.C6 = ["---- ----", "TIME DIST", "wht"]; + } me.R6 = ["--.-", "EFOB", "wht"]; }, update: func() { From 35977d44860bf7f05f9d45a440d435f7ea60c007 Mon Sep 17 00:00:00 2001 From: legoboyvdlp R Date: Wed, 25 Mar 2020 20:46:04 +0000 Subject: [PATCH 27/51] Fix arrival distance calculation --- Nasal/FMGC/flightplan.nas | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Nasal/FMGC/flightplan.nas b/Nasal/FMGC/flightplan.nas index 6dc7c622..3b18bbf7 100644 --- a/Nasal/FMGC/flightplan.nas +++ b/Nasal/FMGC/flightplan.nas @@ -393,6 +393,10 @@ var flightPlanController = { wpCourse[n][wpt].setValue(waypointHashStore.courseAndDistanceFrom(curAircraftPos)[0]); wpDistance[n][wpt].setValue(waypointHashStore.courseAndDistanceFrom(curAircraftPos)[1]); + if (wpt == 1) { + me._arrivalDist += courseDistanceFrom[1]; # distance to next waypoint, therafter to end of flightplan + } + if (left(wpID[n][wpt].getValue(), 4) == FMGCarr.getValue() and wpt != 0) { if (me.arrivalIndex[n] != wpt) { me.arrivalIndex[n] = wpt; @@ -419,8 +423,10 @@ var flightPlanController = { courseDistanceFromPrev = waypointHashStore.courseAndDistanceFrom(geoPosPrev); wpCoursePrev[n][wpt].setValue(courseDistanceFromPrev[0]); wpDistancePrev[n][wpt].setValue(courseDistanceFromPrev[1]); - if (me.flightplans[n].getWP(wpt - 1).wp_type != "vectors" and me.flightplans[n].getWP(wpt - 1).wp_type != "hdgToAlt" and me.flightplans[n].getWP(wpt).wp_type != "vectors" and me.flightplans[n].getWP(wpt).wp_type != "hdgToAlt" and wpt <= me.arrivalIndex[n]) { - me._arrivalDist += courseDistanceFromPrev[1]; # todo - buggy. Neglect discontinuity, and should show distance to next wpt, + distance thereafter + if (wpt > 1) { + if (me.flightplans[n].getWP(wpt - 1).wp_type != "vectors" and me.flightplans[n].getWP(wpt - 1).wp_type != "hdgToAlt" and me.flightplans[n].getWP(wpt).wp_type != "vectors" and me.flightplans[n].getWP(wpt).wp_type != "hdgToAlt" and wpt <= me.arrivalIndex[n]) { + me._arrivalDist += courseDistanceFromPrev[1]; # todo - buggy. Neglect discontinuity + } } } else { # use PPOS for the first waypoint From 42d733745fed658d2202b7adcabe3d41d6cfc316 Mon Sep 17 00:00:00 2001 From: legoboyvdlp R Date: Wed, 25 Mar 2020 21:10:07 +0000 Subject: [PATCH 28/51] Correct bugs in the VERT REV dummy page --- Models/Instruments/MCDU/MCDU.nas | 2 ++ Nasal/MCDU/VERTREV.nas | 28 ++++++++++++++-------------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/Models/Instruments/MCDU/MCDU.nas b/Models/Instruments/MCDU/MCDU.nas index fe66ff7c..d7ddcaab 100644 --- a/Models/Instruments/MCDU/MCDU.nas +++ b/Models/Instruments/MCDU/MCDU.nas @@ -229,6 +229,8 @@ var canvas_MCDU_base = { me["INITA"].hide(); me["INITB"].hide(); me["PERFTO"].hide(); + me["PERFAPPR"].hide(); + me["PERFGA"].hide(); me["Simple_Title"].hide(); me["Simple_PageNum"].hide(); me["ArrowLeft"].show(); diff --git a/Nasal/MCDU/VERTREV.nas b/Nasal/MCDU/VERTREV.nas index 0130b0bc..2b7ff972 100644 --- a/Nasal/MCDU/VERTREV.nas +++ b/Nasal/MCDU/VERTREV.nas @@ -43,20 +43,20 @@ var vertRev = { _setupPageWithData: func() { if (me.type == 3) { me.title = ["VERT REV", " AT ", "PPOS"]; - me.L1 = ["", " EFOB=---", "wht"]; - me.R1 = ["", "EXTRA=--- ", "wht"]; + me.L1 = ["", " EFOB ---.-", "wht"]; + me.R1 = ["", "EXTRA ---.- ", "wht"]; me.L2 = [" 250/10000", " CLB SPD LIM", "mag"]; me.L4 = [" CONSTANT MACH", nil, "wht"]; me.L5 = [" WIND DATA", nil, "wht"]; me.L6 = [" RETURN", nil, "wht"]; - me.R5 = ["STEP ALTS ", nil, "wht"]; - me.arrowsMatrix = [[0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 1, 0]]; - me.arrowsColour = [["ack", "ack", "ack", "wht", "wht", "wht"], ["ack", "ack", "ack", "ack", "wht", "ack"]]; + me.R5 = ["STEP ALTS ", nil, "wht"]; + me.arrowsMatrix = [[0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 1, 1]]; + me.arrowsColour = [["ack", "ack", "ack", "wht", "wht", "wht"], ["ack", "ack", "ack", "ack", "wht", "wht"]]; me.fontMatrix = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]; } if (me.type == 2) { me.title = ["VERT REV", " AT ", me.id]; - me.L1 = ["", " EFOB=---", "wht"]; - me.R1 = ["", "EXTRA=--- ", "wht"]; + me.L1 = ["", " EFOB ---.-", "wht"]; + me.R1 = ["", "EXTRA ---.- ", "wht"]; me.L2 = [" 250/10000", " CLB SPD LIM", "mag"]; me.L3 = [" [ ]", " SPD CSTR", "blu"]; me.L4 = [" CONSTANT MACH", nil, "wht"]; @@ -66,8 +66,8 @@ var vertRev = { me.R3 = ["[ ] ", "ALT CSTR ", "blu"]; me.R5 = ["STEP ALTS ", nil, "wht"]; me.R6 = ["DES ", nil, "wht"]; - me.arrowsMatrix = [[0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 1, 0]]; - me.arrowsColour = [["ack", "ack", "ack", "wht", "wht", "wht"], ["ack", "ack", "ack", "ack", "wht", "ack"]]; + me.arrowsMatrix = [[0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 1, 1]]; + me.arrowsColour = [["ack", "ack", "ack", "wht", "wht", "wht"], ["ack", "ack", "ack", "ack", "wht", "wht"]]; me.fontMatrix = [[0, 0, 1, 0, 0, 0], [0, 1, 1, 0, 0, 0]]; } else { me.title = ["VERT REV", " AT ", me.id]; @@ -80,18 +80,18 @@ var vertRev = { } else { me.arrAirport = findAirportsByICAO(me.id); } - me.L1 = ["", " EFOB=---", "wht"]; - me.R1 = ["", "EXTRA=--- ", "wht"]; + me.L1 = ["", " EFOB ---.-", "wht"]; + me.R1 = ["", "EXTRA ---.- ", "wht"]; me.L2 = [" 250/10000", " DES SPD LIM", "mag"]; me.L4 = [" CONSTANT MACH", nil, "wht"]; me.L5 = [" WIND DATA", nil, "wht"]; me.L6 = [" CLB", nil, "wht"]; me.R2 = ["[ ] ", "UTC CSTR ", "blu"]; me.R3 = ["[ ]", "G/S INTCPT ", "grn"]; - me.R5 = ["STEP ALTS ", nil, "wht"]; + me.R5 = ["STEP ALTS ", nil, "wht"]; me.R6 = ["DES ", nil, "wht"]; - me.arrowsMatrix = [[0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 1, 0]]; - me.arrowsColour = [["ack", "ack", "ack", "wht", "wht", "wht"], ["ack", "ack", "ack", "ack", "wht", "ack"]]; + me.arrowsMatrix = [[0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 1, 1]]; + me.arrowsColour = [["ack", "ack", "ack", "wht", "wht", "wht"], ["ack", "ack", "ack", "ack", "wht", "wht"]]; me.fontMatrix = [[0, 0, 1, 0, 0, 0], [0, 1, 1, 0, 0, 0]]; } } From fa5eaa2a7a1edc5873572cff43df223e8e65ad7e Mon Sep 17 00:00:00 2001 From: legoboyvdlp R Date: Thu, 26 Mar 2020 20:40:49 +0000 Subject: [PATCH 29/51] dummy DIRTO page --- A320-main.xml | 1 + Models/Instruments/MCDU/MCDU.nas | 238 ++++++++++++++++++++++++++++++ Models/Instruments/MCDU/MCDU1.xml | 25 ++++ Models/Instruments/MCDU/MCDU2.xml | 25 ++++ Nasal/MCDU/DIRTO.nas | 50 +++++++ Nasal/MCDU/MCDU.nas | 5 + gui/dialogs/mcdu1-dlg.xml | 10 ++ gui/dialogs/mcdu2-dlg.xml | 10 ++ 8 files changed, 364 insertions(+) create mode 100644 Nasal/MCDU/DIRTO.nas diff --git a/A320-main.xml b/A320-main.xml index 66d0578f..374652f3 100644 --- a/A320-main.xml +++ b/A320-main.xml @@ -1911,6 +1911,7 @@ Aircraft/A320-family/Nasal/FMGC/FMGC-c.nas + Aircraft/A320-family/Nasal/MCDU/DIRTO.nas Aircraft/A320-family/Nasal/MCDU/LATREV.nas Aircraft/A320-family/Nasal/MCDU/VERTREV.nas Aircraft/A320-family/Nasal/MCDU/DEPARTURE.nas diff --git a/Models/Instruments/MCDU/MCDU.nas b/Models/Instruments/MCDU/MCDU.nas index d7ddcaab..e02f5bc8 100644 --- a/Models/Instruments/MCDU/MCDU.nas +++ b/Models/Instruments/MCDU/MCDU.nas @@ -11,6 +11,7 @@ var myVertRev = [nil, nil]; var myDeparture = [nil, nil]; var myArrival = [nil, nil]; var myFpln = [nil, nil]; +var myDirTo = [nil, nil]; var myDuplicate = [nil, nil]; var default = "BoeingCDU-Large.ttf"; var symbol = "helvetica_medium.txf"; @@ -3596,6 +3597,243 @@ var canvas_MCDU_base = { } pageSwitch[i].setBoolValue(1); } + } elsif (page == "DIRTO") { + if (!pageSwitch[i].getBoolValue()) { + me["Simple"].show(); + me["Simple_Center"].hide(); + me["FPLN"].hide(); + me["INITA"].hide(); + me["INITB"].hide(); + me["PERFTO"].hide(); + me["arrowsDepArr"].hide(); + me["Simple_PageNum"].setText("X/X"); + me["Simple_PageNum"].hide(); + me["Simple_Title"].show(); + me["ArrowLeft"].hide(); + me["ArrowRight"].hide(); + + me.fontLeft(default, default, default, default, default, default); + me.fontLeftS(default, default, default, default, default, default); + me.fontRight(default, default, default, default, default, default); + me.fontRightS(default, default, default, default, default, default); + + me.fontSizeLeft(normal, normal, normal, normal, normal, normal); + me.fontSizeRight(normal, normal, normal, normal, normal, normal); + + me.colorLeftS("wht", "wht", "wht", "wht", "wht", "wht"); + me.colorLeftArrow("wht", "wht", "wht", "wht", "wht", "wht"); + me.colorRightS("wht", "wht", "wht", "wht", "wht", "wht"); + me.colorRightArrow("wht", "wht", "wht", "wht", "wht", "wht"); + + if (myDirTo[i] != nil) { + me["Simple_Title"].setText(sprintf("%s", myDirTo[i].title)); + + forindex (var matrixArrow; myDirTo[i].arrowsMatrix) { + if (matrixArrow == 0) { + var sign = "L"; + } else { + var sign = "R"; + } + forindex (var item; myDirTo[i].arrowsMatrix[matrixArrow]) { + if (myDirTo[i].arrowsMatrix[matrixArrow][item] == 1) { + me["Simple_" ~ sign ~ (item + 1) ~ "_Arrow"].show(); + } else { + me["Simple_" ~ sign ~ (item + 1) ~ "_Arrow"].hide(); + } + } + } + me.colorLeftArrow(myDirTo[i].arrowsColour[0][0],myDirTo[i].arrowsColour[0][1],myDirTo[i].arrowsColour[0][2],myDirTo[i].arrowsColour[0][3],myDirTo[i].arrowsColour[0][4],myDirTo[i].arrowsColour[0][5]); + + + forindex (var matrixFont; myDirTo[i].fontMatrix) { + if (matrixFont == 0) { + var sign = "L"; + } else { + var sign = "R"; + } + forindex (var item; myDirTo[i].fontMatrix[matrixFont]) { + if (myDirTo[i].fontMatrix[matrixFont][item] == 1) { + me["Simple_" ~ sign ~ (item + 1)].setFont(symbol); + me["Simple_" ~ sign ~ (item + 1)].setFontSize(small); + } else { + me["Simple_" ~ sign ~ (item + 1)].setFont(default); + me["Simple_" ~ sign ~ (item + 1)].setFontSize(normal); + } + } + } + + if (myDirTo[i].L1[0] == nil) { + me["Simple_L1"].hide(); + me["Simple_L1S"].hide(); + } else { + me["Simple_L1"].show(); + me["Simple_L1"].setText(myDirTo[i].L1[0]); + if (myDirTo[i].L1[1] != nil) { + me["Simple_L1S"].show(); + me["Simple_L1S"].setText(myDirTo[i].L1[1]); + } else { + me["Simple_L1S"].hide(); + } + } + + if (myDirTo[i].L2[0] == nil) { + me["Simple_L2"].hide(); + me["Simple_L2S"].hide(); + } else { + me["Simple_L2"].show(); + me["Simple_L2"].setText(myDirTo[i].L2[0]); + if (myDirTo[i].L2[1] != nil) { + me["Simple_L2S"].show(); + me["Simple_L2S"].setText(myDirTo[i].L2[1]); + } else { + me["Simple_L2S"].hide(); + } + } + + if (myDirTo[i].L3[0] == nil) { + me["Simple_L3"].hide(); + me["Simple_L3S"].hide(); + } else { + me["Simple_L3"].show(); + me["Simple_L3"].setText(myDirTo[i].L3[0]); + if (myDirTo[i].L3[1] != nil) { + me["Simple_L3S"].show(); + me["Simple_L3S"].setText(myDirTo[i].L3[1]); + } else { + me["Simple_L3S"].hide(); + } + } + + if (myDirTo[i].L4[0] == nil) { + me["Simple_L4"].hide(); + me["Simple_L4S"].hide(); + } else { + me["Simple_L4"].show(); + me["Simple_L4"].setText(myDirTo[i].L4[0]); + if (myDirTo[i].L4[1] != nil) { + me["Simple_L4S"].show(); + me["Simple_L4S"].setText(myDirTo[i].L4[1]); + } else { + me["Simple_L4S"].hide(); + } + } + + if (myDirTo[i].L5[0] == nil) { + me["Simple_L5"].hide(); + me["Simple_L5S"].hide(); + } else { + me["Simple_L5"].show(); + me["Simple_L5"].setText(myDirTo[i].L5[0]); + if (myDirTo[i].L5[1] != nil) { + me["Simple_L5S"].show(); + me["Simple_L5S"].setText(myDirTo[i].L5[1]); + } else { + me["Simple_L5S"].hide(); + } + } + + if (myDirTo[i].L6[0] == nil) { + me["Simple_L6"].hide(); + me["Simple_L6S"].hide(); + } else { + me["Simple_L6"].show(); + me["Simple_L6"].setText(myDirTo[i].L6[0]); + if (myDirTo[i].L6[1] != nil) { + me["Simple_L6S"].show(); + me["Simple_L6S"].setText(myDirTo[i].L6[1]); + } else { + me["Simple_L6S"].hide(); + } + } + me.colorLeft(myDirTo[i].L1[2],myDirTo[i].L2[2],myDirTo[i].L3[2],myDirTo[i].L4[2],myDirTo[i].L5[2],myDirTo[i].L6[2]); + + if (myDirTo[i].R1[0] == nil) { + me["Simple_R1"].hide(); + me["Simple_R1S"].hide(); + } else { + me["Simple_R1"].show(); + me["Simple_R1"].setText(myDirTo[i].R1[0]); + if (myDirTo[i].R1[1] != nil) { + me["Simple_R1S"].show(); + me["Simple_R1S"].setText(myDirTo[i].R1[1]); + } else { + me["Simple_R1S"].hide(); + } + } + + if (myDirTo[i].R2[0] == nil) { + me["Simple_R2"].hide(); + me["Simple_R2S"].hide(); + } else { + me["Simple_R2"].show(); + me["Simple_R2"].setText(myDirTo[i].R2[0]); + if (myDirTo[i].R2[1] != nil) { + me["Simple_R2S"].show(); + me["Simple_R2S"].setText(myDirTo[i].R2[1]); + } else { + me["Simple_R2S"].hide(); + } + } + + if (myDirTo[i].R3[0] == nil) { + me["Simple_R3"].hide(); + me["Simple_R3S"].hide(); + } else { + me["Simple_R3"].show(); + me["Simple_R3"].setText(myDirTo[i].R3[0]); + if (myDirTo[i].R3[1] != nil) { + me["Simple_R3S"].show(); + me["Simple_R3S"].setText(myDirTo[i].R3[1]); + } else { + me["Simple_R3S"].hide(); + } + } + + if (myDirTo[i].R4[0] == nil) { + me["Simple_R4"].hide(); + me["Simple_R4S"].hide(); + } else { + me["Simple_R4"].show(); + me["Simple_R4"].setText(myDirTo[i].R4[0]); + if (myDirTo[i].R4[1] != nil) { + me["Simple_R4S"].show(); + me["Simple_R4S"].setText(myDirTo[i].R4[1]); + } else { + me["Simple_R4S"].hide(); + } + } + + if (myDirTo[i].R5[0] == nil) { + me["Simple_R5"].hide(); + me["Simple_R5S"].hide(); + } else { + me["Simple_R5"].show(); + me["Simple_R5"].setText(myDirTo[i].R5[0]); + if (myDirTo[i].R5[1] != nil) { + me["Simple_R5S"].show(); + me["Simple_R5S"].setText(myDirTo[i].R5[1]); + } else { + me["Simple_R5S"].hide(); + } + } + + if (myDirTo[i].R6[0] == nil) { + me["Simple_R6"].hide(); + me["Simple_R6S"].hide(); + } else { + me["Simple_R6"].show(); + me["Simple_R6"].setText(myDirTo[i].R6[0]); + if (myDirTo[i].R6[1] != nil) { + me["Simple_R6S"].show(); + me["Simple_R6S"].setText(myDirTo[i].R6[1]); + } else { + me["Simple_R6S"].hide(); + } + } + me.colorRight(myDirTo[i].R1[2],myDirTo[i].R2[2],myDirTo[i].R3[2],myDirTo[i].R4[2],myDirTo[i].R5[2],myDirTo[i].R6[2]); + } + pageSwitch[i].setBoolValue(1); + } } else { if (!pageSwitch[i].getBoolValue()) { me["Simple"].hide(); diff --git a/Models/Instruments/MCDU/MCDU1.xml b/Models/Instruments/MCDU/MCDU1.xml index 541b08a2..518cf4d9 100644 --- a/Models/Instruments/MCDU/MCDU1.xml +++ b/Models/Instruments/MCDU/MCDU1.xml @@ -251,6 +251,31 @@ + + pick + dir + + + false + + nasal + + + + + systems/electrical/bus/ac-1 + 110 + + + controls/lighting/DU/mcdu1 + 0.01 + + + + + + + pick L1 diff --git a/Models/Instruments/MCDU/MCDU2.xml b/Models/Instruments/MCDU/MCDU2.xml index adf05c55..015c4def 100644 --- a/Models/Instruments/MCDU/MCDU2.xml +++ b/Models/Instruments/MCDU/MCDU2.xml @@ -251,6 +251,31 @@ + + pick + dir + + + false + + nasal + + + + + systems/electrical/bus/ac-2 + 110 + + + controls/lighting/DU/mcdu2 + 0.01 + + + + + + + pick L1 diff --git a/Nasal/MCDU/DIRTO.nas b/Nasal/MCDU/DIRTO.nas new file mode 100644 index 00000000..825a314a --- /dev/null +++ b/Nasal/MCDU/DIRTO.nas @@ -0,0 +1,50 @@ +var dirTo = { + title: [nil], + subtitle: [nil, nil], + fontMatrix: [[0, 0, 0, 0, 0, 0],[0, 0, 0, 0, 0, 0]], + arrowsMatrix: [[0, 0, 0, 0, 0, 0],[0, 0, 0, 0, 0, 0]], + arrowsColour: [["ack", "ack", "ack", "ack", "ack", "ack"],["ack", "ack", "ack", "ack", "ack", "ack"]], + L1: [nil, nil, "ack"], # content, title, colour + L2: [nil, nil, "ack"], + L3: [nil, nil, "ack"], + L4: [nil, nil, "ack"], + L5: [nil, nil, "ack"], + L6: [nil, nil, "ack"], + R1: [nil, nil, "ack"], + R2: [nil, nil, "ack"], + R3: [nil, nil, "ack"], + R4: [nil, nil, "ack"], + R5: [nil, nil, "ack"], + R6: [nil, nil, "ack"], + index: nil, + computer: nil, + new: func(computer) { + var dt = {parents:[dirTo]}; + dt.computer = computer; + dt._setupPageWithData(); + return dt; + }, + del: func() { + return nil; + }, + _setupPageWithData: func() { + me.title = ["DIR TO"]; + me.L1 = [" [ ]", " WAYPOINT", "blu"]; + me.L2 = [nil, " F-PLN WPTS", "blu"]; + me.L6 = [" ERASE", " DIR TO", "yel"]; + me.R1 = ["---- --- ", "UTC DIST ", "wht"]; + me.R2 = ["DIRECT TO ", nil, "blu"]; + me.R3 = ["ABEAM PTS ", "WITH ", "blu"]; + me.R4 = ["[ ] ", "RADIAL IN ", "blu"]; + me.R5 = ["[ ] ", "RADIAL OUT ", "blu"]; + me.arrowsMatrix = [[0, 1, 1, 1, 1, 1], [0, 1, 0, 1, 0, 0]]; + me.arrowsColour = [["ack", "blu", "blu", "blu", "blu", "yel"], ["ack", "blu", "ack", "blu", "ack", "ack"]]; + me.fontMatrix = [[1, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 0]]; + canvas_mcdu.pageSwitch[me.computer].setBoolValue(0); + }, + makeTmpy: func() { + if (!fmgc.flightPlanController.temporaryFlag[me.computer]) { + fmgc.flightPlanController.createTemporaryFlightPlan(me.computer); + } + }, +}; \ No newline at end of file diff --git a/Nasal/MCDU/MCDU.nas b/Nasal/MCDU/MCDU.nas index 011ed6b4..e1fc3831 100644 --- a/Nasal/MCDU/MCDU.nas +++ b/Nasal/MCDU/MCDU.nas @@ -525,6 +525,11 @@ var pagebutton = func(btn, i) { } } else if (btn == "fuel-pred") { setprop("MCDU[" ~ i ~ "]/page", "FUELPRED"); + } else if (btn == "dirto") { + if (canvas_mcdu.myDirTo[i] == nil) { + canvas_mcdu.myDirTo[i] = dirTo.new(i); + } + setprop("MCDU[" ~ i ~ "]/page", "DIRTO"); } } } diff --git a/gui/dialogs/mcdu1-dlg.xml b/gui/dialogs/mcdu1-dlg.xml index 545235b3..82a9cfc3 100644 --- a/gui/dialogs/mcdu1-dlg.xml +++ b/gui/dialogs/mcdu1-dlg.xml @@ -292,6 +292,16 @@ DIR 25 40 + + nasal + + + + systems/electrical/bus/ac-1 + 110 + + +