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);