diff --git a/Models/Instruments/MCDU/MCDU.nas b/Models/Instruments/MCDU/MCDU.nas index bfd8b704..089d51a3 100644 --- a/Models/Instruments/MCDU/MCDU.nas +++ b/Models/Instruments/MCDU/MCDU.nas @@ -3760,7 +3760,6 @@ var canvas_MCDU_base = { 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(); @@ -3787,6 +3786,12 @@ var canvas_MCDU_base = { me.colorLeftS("wht", "wht", "wht", "wht", "wht", "wht"); me.colorRightS("wht", "wht", "wht", "wht", "wht", "wht"); + if (myArrival[i].arrowsMatrix[0][1]) { + me["Simple_L2_Arrow"].setColor(getprop("/MCDUC/colors/" ~ myArrival[i].arrowsColour[0][1] ~ "/r"), getprop("/MCDUC/colors/" ~ myArrival[i].arrowsColour[0][1] ~ "/g"), getprop("/MCDUC/colors/" ~ myArrival[i].arrowsColour[0][1] ~ "/b")); + me["Simple_L2_Arrow"].show(); + } else { + me["Simple_L2_Arrow"].hide(); + } if (myArrival[i] != nil) { me["Simple_Title"].setText(sprintf("%s", myArrival[i].title[0] ~ myArrival[i].title[1] ~ myArrival[i].title[2])); @@ -3798,6 +3803,7 @@ var canvas_MCDU_base = { var sign = "R"; } forindex (var item; myArrival[i].arrowsMatrix[matrixArrow]) { + if (item == 1) { continue; } if (item == 5) { me["Simple_L6_Arrow"].setColor(getprop("/MCDUC/colors/" ~ myArrival[i].arrowsColour[0][5] ~ "/r"), getprop("/MCDUC/colors/" ~ myArrival[i].arrowsColour[0][5] ~ "/g"), getprop("/MCDUC/colors/" ~ myArrival[i].arrowsColour[0][5] ~ "/b")); continue; diff --git a/Nasal/FMGC/flightplan.nas b/Nasal/FMGC/flightplan.nas index 2e0b06c9..6aaa2665 100644 --- a/Nasal/FMGC/flightplan.nas +++ b/Nasal/FMGC/flightplan.nas @@ -7,7 +7,6 @@ var pos = nil; var geoPosPrev = geo.Coord.new(); var currentLegCourseDist = nil; var courseDistanceFrom = nil; -var courseDistanceFromPrev = nil; var sizeWP = nil; var magTrueError = 0; var storeCourse = nil; @@ -77,6 +76,11 @@ var flightPlanController = { me.flightplans[n].cleanPlan(); me.flightplans[n].departure = nil; me.flightplans[n].destination = nil; + mcdu.isNoTransArr[n] = 0; + mcdu.isNoTransDep[n] = 0; + mcdu.isNoSid[n] = 0; + mcdu.isNoStar[n] = 0; + mcdu.isNoVia[n] = 0; }, createTemporaryFlightPlan: func(n) { @@ -112,6 +116,37 @@ var flightPlanController = { flightPlanTimer.stop(); me.resetFlightplan(2); me.flightplans[2] = me.flightplans[n].clone(); + + if (mcdu.isNoSid[n] == 1) { + mcdu.isNoSid[2] = 1; + } else { + mcdu.isNoSid[2] = 0; + } + + if (mcdu.isNoStar[n] == 1) { + mcdu.isNoStar[2] = 1; + } else { + mcdu.isNoStar[2] = 0; + } + + if (mcdu.isNoVia[n] == 1) { + mcdu.isNoVia[2] = 1; + } else { + mcdu.isNoVia[2] = 0; + } + + if (mcdu.isNoTransDep[n] == 1) { + mcdu.isNoTransDep[2] = 1; + } else { + mcdu.isNoTransDep[2] = 0; + } + + if (mcdu.isNoTransArr[n] == 1) { + mcdu.isNoTransArr[2] = 1; + } else { + mcdu.isNoTransArr[2] = 0; + } + me.flightPlanChanged(2); flightPlanTimer.start(); } @@ -225,18 +260,25 @@ var flightPlanController = { if (DEBUG_DISCONT) { return; } if (force) { me.flightplans[plan].insertWP(createDiscontinuity(), index); - fmgc.windController.insertWind(plan, index, 0, "DISCONTINUITY"); } - if (index > 0) { - if (me.flightplans[plan].getWP(index).wp_name != "DISCONTINUITY" and me.flightplans[plan].getWP(index - 1).wp_name != "DISCONTINUITY") { - me.flightplans[plan].insertWP(createDiscontinuity(), index); - fmgc.windController.insertWind(plan, index, 0, "DISCONTINUITY"); + + if (me.flightplans[plan].getWP(index) != nil) { # index is not nil + if (me.flightplans[plan].getWP(index - 1) != nil) { # index -1 is also not nil + if (me.flightplans[plan].getWP(index).wp_name != "DISCONTINUITY" and me.flightplans[plan].getWP(index - 1).wp_name != "DISCONTINUITY") { + me.flightplans[plan].insertWP(createDiscontinuity(), index); + } + } else { # -1 is nil + if (me.flightplans[plan].getWP(index).wp_name != "DISCONTINUITY") { + me.flightplans[plan].insertWP(createDiscontinuity(), index); + } } - } else { - if (me.flightplans[plan].getWP(index).wp_name != "DISCONTINUITY") { + } elsif (me.flightplans[plan].getWP(index - 1) != nil) { # index is nil, -1 is not + if (me.flightplans[plan].getWP(index - 1).wp_name != "DISCONTINUITY") { me.flightplans[plan].insertWP(createDiscontinuity(), index); - fmgc.windController.insertWind(plan, index, 0, "DISCONTINUITY"); } + } else { # both are nil?? + print("Possible error in discontinuities!"); + me.flightplans[plan].insertWP(createDiscontinuity(), index); } }, @@ -757,17 +799,13 @@ var flightPlanController = { } if (wpt > 0) { - geoPosPrev.set_latlon(me.flightplans[n].getWP(wpt - 1).lat, me.flightplans[n].getWP(wpt - 1).lon); - - courseDistanceFromPrev = waypointHashStore.courseAndDistanceFrom(geoPosPrev); - wpCoursePrev[n][wpt].setValue(courseDistanceFromPrev[0]); - wpDistancePrev[n][wpt].setValue(courseDistanceFromPrev[1]); - if (wpt > 1) { - if (me.flightplans[n].getWP(wpt - 1).wp_name != "DISCONTINUITY" and me.flightplans[n].getWP(wpt).wp_name != "DISCONTINUITY" and me.flightplans[n].getWP(wpt - 1).wp_type != "vectors" and me.flightplans[n].getWP(wpt - 1).wp_type != "hdgToAlt" and me.flightplans[n].getWP(wpt).wp_type != "vectors" and me.flightplans[n].getWP(wpt).wp_type != "hdgToAlt" and wpt <= me.arrivalIndex[n]) { - # print("Adding " ~ courseDistanceFromPrev[1] ~ " miles for waypoint " ~ me.flightplans[n].getWP(wpt).wp_name); - me._arrivalDist += courseDistanceFromPrev[1]; - } - } + wpCoursePrev[n][wpt].setValue(me.flightplans[n].getWP(wpt).leg_bearing); + wpDistancePrev[n][wpt].setValue(me.flightplans[n].getWP(wpt).leg_distance); + #if (wpt > 1) { + # if (me.flightplans[n].getWP(wpt - 1).wp_name != "DISCONTINUITY" and me.flightplans[n].getWP(wpt).wp_name != "DISCONTINUITY" and me.flightplans[n].getWP(wpt - 1).wp_type != "vectors" and me.flightplans[n].getWP(wpt - 1).wp_type != "hdgToAlt" and me.flightplans[n].getWP(wpt).wp_type != "vectors" and me.flightplans[n].getWP(wpt).wp_type != "hdgToAlt" and wpt <= me.arrivalIndex[n]) { + # me._arrivalDist += courseDistanceFromPrev[1]; + # } + #} } else { # use PPOS for the first waypoint wpCoursePrev[n][wpt].setValue(courseDistanceFrom[0]); @@ -786,8 +824,7 @@ var flightPlanController = { } } } - # print("Total: " ~ me._arrivalDist); - me.arrivalDist = me._arrivalDist; + me.arrivalDist = me.flightplans[2].getWP(me.arrivalIndex[2]).distance_along_route - me.flightplans[2].getWP(1).leg_distance + me._arrivalDist; me.updateMCDUDriver(n); }, diff --git a/Nasal/FMGC/mcdu-messages.nas b/Nasal/FMGC/mcdu-messages.nas index 88b573a0..4b1a247f 100644 --- a/Nasal/FMGC/mcdu-messages.nas +++ b/Nasal/FMGC/mcdu-messages.nas @@ -174,8 +174,11 @@ var MessageController = { ]), typeIIMessages: std.Vector.new([ TypeIIMessage.new("LAT DISCONT AHEAD", "amb", 0),TypeIIMessage.new("MORE DRAG"),TypeIIMessage.new("RWY/LS MISMATCH", "amb", 0),TypeIIMessage.new("STEP DELETED"), - TypeIIMessage.new("STEP NOW"),TypeIIMessage.new("TIME TO EXIT", "amb", 0), + TypeIIMessage.new("STEP NOW"),TypeIIMessage.new("TIME TO EXIT", "amb", 0),TypeIIMessage.new("V1/VR/V2 DISAGREE", "amb", 0), + TypeIIMessage.new("TO SPEED TOO LOW", "amb", 0), ]), + + # to speed to low - new on a320, margin against vmcg / vs1g getTypeIMsgByText: func(text) { return me.getMsgByText(text, me.typeIMessages.vector); diff --git a/Nasal/MCDU/ARRIVAL.nas b/Nasal/MCDU/ARRIVAL.nas index 1ad92187..1aee5abe 100644 --- a/Nasal/MCDU/ARRIVAL.nas +++ b/Nasal/MCDU/ARRIVAL.nas @@ -1,4 +1,6 @@ -var isNoStar = [0, 0]; +var isNoStar = [0, 0, 0]; +var isNoTransArr = [0, 0, 0]; +var isNoVia = [0, 0, 0]; var arrivalPage = { title: [nil, nil, nil], @@ -31,17 +33,20 @@ var arrivalPage = { selectedVIA: nil, selectedSTAR: nil, selectedTransition: nil, - stars: nil, - transitions: nil, - vias: nil, + stars: [], + transitions: [], + vias: [], computer: nil, enableScrollApproach: 0, enableScrollStars: 0, + enableScrollVias: 0, scrollApproach: 0, scrollStars: 0, - activePage: 0, # runways, stars, trans - hasPressNoTrans: 0, # temporary + scrollVias: 0, + activePage: 0, # runways, stars, vias + oldPage: 0, _approaches: nil, + _vias: nil, _stars: nil, _transitions: nil, new: func(icao, computer) { @@ -56,39 +61,75 @@ var arrivalPage = { return nil; }, reset: func() { - isNoStar[me.computer] = 0; + me.selectedApproach = nil; me.selectedSTAR = nil; - me.hasPressNoTrans = 0; + me.selectedTransition = nil; + me.selectedVIA = nil; + isNoStar[me.computer] = 0; + isNoTransArr[me.computer] = 0; + isNoVia[me.computer] = 0; }, _setupFirstTime: func() { if (!fmgc.flightPlanController.temporaryFlag[me.computer]) { if (fmgc.flightPlanController.flightplans[2].approach != nil) { me.selectedApproach = fmgc.flightPlanController.flightplans[2].approach; + + if (getprop("/sim/version/flightgear") == "2020.2.0") { + if (fmgc.flightPlanController.flightplans[2].approach_trans != nil) { + me.selectedVIA = fmgc.flightPlanController.flightplans[2].approach_trans; + } elsif (isNoVia[2] == 1) { + me.selectedVIA = "NO VIA"; + } + } } + if (fmgc.flightPlanController.flightplans[2].star != nil) { me.selectedSTAR = fmgc.flightPlanController.flightplans[2].star; - isNoStar[me.computer] = 0; - } elsif (isNoStar[me.computer] == 1) { + isNoStar[2] = 0; + } elsif (isNoStar[2] == 1) { me.selectedSTAR = "NO STAR"; - me.hasPressNoTrans = 1; + } + + if (isNoTransArr[2]) { + me.selectedTransition = "NO TRANS"; + } elsif (fmgc.flightPlanController.flightplans[2].star != nil) { + me.selectedTransition = fmgc.flightPlanController.flightplans[2].star_trans; } } else { if (fmgc.flightPlanController.flightplans[me.computer].approach != nil) { me.selectedApproach = fmgc.flightPlanController.flightplans[me.computer].approach; + if (getprop("/sim/version/flightgear") == "2020.2.0") { + if (fmgc.flightPlanController.flightplans[me.computer].approach_trans != nil) { + me.selectedVIA = fmgc.flightPlanController.flightplans[me.computer].approach_trans; + } elsif (isNoVia[me.computer] == 1) { + me.selectedVIA = "NO VIA"; + } + } } elsif (fmgc.flightPlanController.flightplans[2].approach != nil) { me.selectedApproach = fmgc.flightPlanController.flightplans[2].approach; + if (getprop("/sim/version/flightgear") == "2020.2.0") { + if (fmgc.flightPlanController.flightplans[2].approach_trans != nil) { + me.selectedVIA = fmgc.flightPlanController.flightplans[2].approach_trans; + } + } } if (fmgc.flightPlanController.flightplans[me.computer].star != nil) { me.selectedSTAR = fmgc.flightPlanController.flightplans[me.computer].star; - me.selectedTransition = fmgc.flightPlanController.flightplans[me.computer].star_trans; isNoStar[me.computer] = 0; } elsif (fmgc.flightPlanController.flightplans[2].star != nil) { me.selectedSTAR = fmgc.flightPlanController.flightplans[2].star; - me.selectedTransition = fmgc.flightPlanController.flightplans[2].star_trans; isNoStar[me.computer] = 0; + isNoStar[2] = 0; } elsif (isNoStar[me.computer] == 1) { me.selectedSTAR = "NO STAR"; - me.hasPressNoTrans = 1; + } + + if (isNoTransArr[me.computer] or isNoTransArr[2]) { + me.selectedTransition = "NO TRANS"; + } elsif (fmgc.flightPlanController.flightplans[me.computer].star != nil) { + me.selectedTransition = fmgc.flightPlanController.flightplans[me.computer].star_trans; + } elsif (fmgc.flightPlanController.flightplans[2].star != nil) { + me.selectedTransition = fmgc.flightPlanController.flightplans[2].star_trans; } } }, @@ -99,8 +140,8 @@ var arrivalPage = { me.arrowsMatrix = [[0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0]]; me.arrowsColour = [["ack", "ack", "ack", "ack", "ack", "wht"], ["ack", "ack", "ack", "ack", "ack", "ack"]]; - if (!fmgc.flightPlanController.temporaryFlag[me.computer]) { - me.L6 = [" RETURN END", nil, "wht"]; + if (!fmgc.flightPlanController.temporaryFlag[me.computer] or me.activePage == 2) { + me.L6 = [" RETURN", nil, "wht"]; } else { me.L6 = [" F-PLN", " TMPY", "yel"]; me.arrowsColour[0][5] = "yel"; @@ -108,11 +149,17 @@ var arrivalPage = { if (me.activePage == 0) { me.updateApproaches(); - } else { + } elsif (me.activePage == 1) { me.updateSTARs(); + me.updateTransitions(); + } else { + me.updateVIAs(); } + me.checkPageType(); + me.updateActiveApproach(); + me.updateActiveVIAs(); me.updateActiveSTARs(); me.updateActiveTransitions(); }, @@ -143,101 +190,147 @@ var arrivalPage = { me._clearPage(); me._setupPageWithData(); }, + + # Functions to populate top row updateActiveApproach: func() { if (me.apprIsRwyFlag) { - if (!fmgc.flightPlanController.temporaryFlag[me.computer]) { + if (fmgc.flightPlanController.temporaryFlag[me.computer]) { if (fmgc.flightPlanController.flightplans[me.computer].destination_runway != nil) { me.L1 = [fmgc.flightPlanController.flightplans[me.computer].destination_runway.id, " APPR", "yel"]; - } elsif (fmgc.flightPlanController.flightplans[2].destination_runway != nil) { - me.L1 = [fmgc.flightPlanController.flightplans[2].destination_runway.id, " APPR", "grn"]; + } elsif (fmgc.flightPlanController.flightplans[2].destination_runway != nil and fmgc.flightPlanController.flightplans[2].destination_runway.id == me.selectedApproach.id) { + me.L1 = [fmgc.flightPlanController.flightplans[2].destination_runway.id, " APPR", "yel"]; } else { - me.L1 = ["---", " APPR", "wht"]; + me.L1 = ["-----", " APPR", "wht"]; } } else { - if (fmgc.flightPlanController.flightplans[me.computer].destination_runway != nil) { - me.L1 = [fmgc.flightPlanController.flightplans[me.computer].destination_runway.id, " APPR", "yel"]; + if (fmgc.flightPlanController.flightplans[2].destination_runway != nil) { + me.L1 = [fmgc.flightPlanController.flightplans[2].destination_runway.id, " APPR", "grn"]; } else { - me.L1 = ["---", " APPR", "wht"]; + me.L1 = ["-----", " APPR", "wht"]; } } } elsif (me.selectedApproach != nil) { - if (fmgc.flightPlanController.flightplans[2].approach != nil) { + if (fmgc.flightPlanController.temporaryFlag[me.computer]) { if (fmgc.flightPlanController.flightplans[me.computer].approach != nil) { me.L1 = [fmgc.flightPlanController.flightplans[me.computer].approach.id, " APPR", "yel"]; - } elsif (fmgc.flightPlanController.flightplans[2].approach.id == me.selectedApproach.id) { + } elsif (fmgc.flightPlanController.flightplans[2].approach != nil and fmgc.flightPlanController.flightplans[2].approach.id == me.selectedApproach.id) { + me.L1 = [fmgc.flightPlanController.flightplans[2].approach.id, " APPR", "yel"]; + } else { + me.L1 = ["-----", " APPR", "wht"]; + } + } else { + if (fmgc.flightPlanController.flightplans[2].approach != nil) { me.L1 = [fmgc.flightPlanController.flightplans[2].approach.id, " APPR", "grn"]; } else { - me.L1 = ["---", " APPR", "wht"]; - } - } elsif (fmgc.flightPlanController.flightplans[me.computer].approach != nil) { - me.L1 = [fmgc.flightPlanController.flightplans[me.computer].approach.id, " APPR", "yel"]; - } else { - me.L1 = ["---", " APPR", "wht"]; + me.L1 = ["-----", " APPR", "wht"]; + } } } else { - me.L1 = ["---", " APPR", "wht"]; + me.L1 = ["-----", " APPR", "wht"]; } canvas_mcdu.pageSwitch[me.computer].setBoolValue(0); }, + + updateActiveVIAs: func() { + if (getprop("/sim/version/flightgear") != "2020.2.0") { return; } + + if (me.selectedVIA == "NO VIA") { + if (!fmgc.flightPlanController.temporaryFlag[me.computer]) { + me.C1 = ["NONE", "VIA", "grn"]; + } else { + me.C1 = ["NONE", "VIA", "yel"]; + } + } elsif (me.selectedVIA != nil) { + if (fmgc.flightPlanController.temporaryFlag[me.computer]) { + if (fmgc.flightPlanController.flightplans[me.computer].approach_trans != nil) { + me.C1 = [fmgc.flightPlanController.flightplans[me.computer].approach_trans.id, "VIA", "yel"]; + } elsif (fmgc.flightPlanController.flightplans[2].approach_trans != nil and fmgc.flightPlanController.flightplans[2].approach_trans.id == me.selectedVIA.id) { + me.C1 = [fmgc.flightPlanController.flightplans[2].approach_trans.id, "VIA", "yel"]; + } else { + me.C1 = ["-------", "VIA", "wht"]; + } + } else { + if (fmgc.flightPlanController.flightplans[2].approach_trans != nil) { + me.C1 = [fmgc.flightPlanController.flightplans[2].approach_trans.id, "VIA", "grn"]; + } else { + me.C1 = ["-------", "VIA", "wht"]; + } + } + } else { + me.C1 = ["-------", "VIA", "wht"]; + } + canvas_mcdu.pageSwitch[me.computer].setBoolValue(0); + }, + updateActiveSTARs: func() { if (me.selectedSTAR == "NO STAR") { if (!fmgc.flightPlanController.temporaryFlag[me.computer]) { - me.C1 = ["NONE", "STAR", "grn"]; + me.R1 = ["NONE", "STAR ", "grn"]; } else { - me.C1 = ["NONE", "STAR", "yel"]; + me.R1 = ["NONE", "STAR ", "yel"]; } } elsif (me.selectedSTAR != nil) { - if (fmgc.flightPlanController.flightplans[2].star != nil) { + if (fmgc.flightPlanController.temporaryFlag[me.computer]) { if (fmgc.flightPlanController.flightplans[me.computer].star != nil) { - me.C1 = [fmgc.flightPlanController.flightplans[me.computer].star.id, "STAR", "yel"]; - } elsif (fmgc.flightPlanController.flightplans[2].star.id == me.selectedSTAR.id) { - me.C1 = [fmgc.flightPlanController.flightplans[2].star.id, "STAR", "grn"]; + me.R1 = [fmgc.flightPlanController.flightplans[me.computer].star.id, "STAR ", "yel"]; + } elsif (fmgc.flightPlanController.flightplans[2].star != nil and fmgc.flightPlanController.flightplans[2].star.id == me.selectedSTAR.id) { + me.R1 = [fmgc.flightPlanController.flightplans[2].star.id, "STAR ", "yel"]; } else { - me.C1 = ["------- ", "STAR", "wht"]; + me.R1 = ["-------", "STAR ", "wht"]; } - } elsif (fmgc.flightPlanController.flightplans[me.computer].star.id != nil) { - me.C1 = [fmgc.flightPlanController.flightplans[me.computer].star.id, "STAR", "yel"]; } else { - me.C1 = ["------- ", "STAR", "wht"]; + if (fmgc.flightPlanController.flightplans[2].star != nil) { + me.R1 = [fmgc.flightPlanController.flightplans[2].star.id, "STAR ", "grn"]; + } else { + me.R1 = ["-------", "STAR ", "wht"]; + } } } else { - me.C1 = ["------- ", "STAR", "wht"]; + me.R1 = ["-------", "STAR ", "wht"]; } canvas_mcdu.pageSwitch[me.computer].setBoolValue(0); }, + updateActiveTransitions: func() { - if (!me.hasPressNoTrans) { + if (me.selectedTransition == "NO TRANS") { + if (!fmgc.flightPlanController.temporaryFlag[me.computer]) { + me.R2 = ["NONE", "TRANS ", "grn"]; + } else { + me.R2 = ["NONE", "TRANS ", "yel"]; + } + } else { if (me.selectedTransition != nil) { - if (fmgc.flightPlanController.flightplans[2].star_trans != nil) { + if (fmgc.flightPlanController.temporaryFlag[me.computer]) { if (fmgc.flightPlanController.flightplans[me.computer].star_trans != nil) { - me.R1 = [fmgc.flightPlanController.flightplans[me.computer].star_trans.id, "TRANS", "yel"]; - } elsif (fmgc.flightPlanController.flightplans[2].star_trans.id == me.selectedTransition.id) { - me.R1 = [fmgc.flightPlanController.flightplans[2].star_trans.id, "TRANS", "grn"]; + me.R2 = [fmgc.flightPlanController.flightplans[me.computer].star_trans.id, "TRANS ", "yel"]; + } elsif (fmgc.flightPlanController.flightplans[2].star_trans != nil and fmgc.flightPlanController.flightplans[2].star_trans.id == me.selectedTransition.id) { + me.R2 = [fmgc.flightPlanController.flightplans[2].star_trans.id, "TRANS ", "yel"]; } else { - me.R1 = ["-------", "TRANS ", "wht"]; + me.R2 = ["-------", "TRANS ", "wht"]; } - } elsif (fmgc.flightPlanController.flightplans[me.computer].star_trans != nil) { - me.C1 = [fmgc.flightPlanController.flightplans[me.computer].star_trans.id, "STAR", "yel"]; - } else { - me.R1 = ["-------", "TRANS ", "wht"]; + } else { + if (fmgc.flightPlanController.flightplans[2].star_trans != nil) { + me.R2 = [fmgc.flightPlanController.flightplans[2].star_trans.id, "TRANS ", "grn"]; + } else { + me.R2 = ["-------", "TRANS ", "wht"]; + } } } else { - me.R1 = ["-------", "TRANS ", "wht"]; - } - } else { - if (!fmgc.flightPlanController.temporaryFlag[me.computer]) { - me.R1 = ["NONE", "TRANS ", "grn"]; - } else { - me.R1 = ["NONE", "TRANS ", "yel"]; + me.R2 = ["-------", "TRANS ", "wht"]; } } canvas_mcdu.pageSwitch[me.computer].setBoolValue(0); }, + updateApproaches: func() { me.apprIsRwyFlag = 0; if (me.arrAirport == nil) { me.arrAirport = findAirportsByICAO(left(me.id, 4)); } + + me.approaches = []; + me._approaches = nil; + me._approaches = me.arrAirport[0].getApproachList(); me.approaches = sort(me._approaches,func(a,b) cmp(a,b)); if (me.approaches == nil or size(me.approaches) == 0) { @@ -353,6 +446,10 @@ var arrivalPage = { if (me.arrAirport == nil) { me.arrAirport = findAirportsByICAO(left(me.id, 4)); } + + me.stars = []; + me._stars = nil; + if (me.selectedApproach != nil) { me._stars = me.arrAirport[0].stars(me.selectedApproach.runways[0]); } else { @@ -367,18 +464,8 @@ var arrivalPage = { } if (size(me.stars) >= 1) { - me.L2 = [" " ~ me.stars[0 + me.scrollStars], "STARS", "blu"]; + me.L3 = [" " ~ me.stars[0 + me.scrollStars], "STARS", "blu"]; if (me.stars[0 + me.scrollStars] != me.selectedSTAR) { - me.arrowsMatrix[0][1] = 1; - me.arrowsColour[0][1] = "blu"; - } else { - me.arrowsMatrix[0][1] = 0; - me.arrowsColour[0][1] = "ack"; - } - } - if (size(me.stars) >= 2) { - me.L3 = [" " ~ me.stars[1 + me.scrollStars], nil, "blu"]; - if (me.stars[1 + me.scrollStars] != me.selectedSTAR) { me.arrowsMatrix[0][2] = 1; me.arrowsColour[0][2] = "blu"; } else { @@ -386,9 +473,9 @@ var arrivalPage = { me.arrowsColour[0][2] = "ack"; } } - if (size(me.stars) >= 3) { - me.L4 = [" " ~ me.stars[2 + me.scrollStars], nil, "blu"]; - if (me.stars[2 + me.scrollStars] != me.selectedSTAR) { + if (size(me.stars) >= 2) { + me.L4 = [" " ~ me.stars[1 + me.scrollStars], nil, "blu"]; + if (me.stars[1 + me.scrollStars] != me.selectedSTAR) { me.arrowsMatrix[0][3] = 1; me.arrowsColour[0][3] = "blu"; } else { @@ -396,9 +483,9 @@ var arrivalPage = { me.arrowsColour[0][3] = "ack"; } } - if (size(me.stars) >= 4) { - me.L5 = [" " ~ me.stars[3 + me.scrollStars], nil, "blu"]; - if (me.stars[3 + me.scrollStars] != me.selectedSTAR) { + if (size(me.stars) >= 3) { + me.L5 = [" " ~ me.stars[2 + me.scrollStars], nil, "blu"]; + if (me.stars[2 + me.scrollStars] != me.selectedSTAR) { me.arrowsMatrix[0][4] = 1; me.arrowsColour[0][4] = "blu"; } else { @@ -407,21 +494,75 @@ var arrivalPage = { } } - me.C2 = [nil, "AVAILABLE", "wht"]; - me.R2 = [nil, "TRANS ", "wht"]; + me.C3[1] = "AVAILABLE"; + me.R3[1] = "TRANS "; - if (size(me.stars) > 4) { + if (size(me.stars) > 3) { me.enableScrollStars = 1; } canvas_mcdu.pageSwitch[me.computer].setBoolValue(0); }, + updateVIAs: func() { + if (getprop("/sim/version/flightgear") != "2020.2.0") { return; } + if (me.selectedApproach == nil or me.activePage != 2) { + me.clearVias(); + return; + } + me.vias = []; + me._vias = nil; + me._vias = me.selectedApproach.transitions; + me.vias = sort(me._vias, func(a,b) cmp(a,b)); + append(me.vias, "NO VIA"); + + if (size(me.vias) >= 1) { + me.L2 = [" " ~ me.vias[0 + me.scrollVias], " APP VIAS", "blu"]; + if (me.vias[0 + me.scrollVias] != me.selectedVIA) { + me.arrowsMatrix[0][1] = 1; + me.arrowsColour[0][1] = "blu"; + } else { + me.arrowsMatrix[0][1] = 0; + me.arrowsColour[0][1] = "ack"; + } + } + if (size(me.vias) >= 2) { + me.L3 = [" " ~ me.vias[1 + me.scrollVias], nil, "blu"]; + if (me.vias[1 + me.scrollVias] != me.selectedVIA) { + me.arrowsMatrix[0][2] = 1; + me.arrowsColour[0][2] = "blu"; + } else { + me.arrowsMatrix[0][2] = 0; + me.arrowsColour[0][2] = "ack"; + } + } + if (size(me.vias) >= 3) { + me.L4 = [" " ~ me.vias[2 + me.scrollVias], nil, "blu"]; + if (me.vias[2 + me.scrollVias] != me.selectedVIA) { + me.arrowsMatrix[0][3] = 1; + me.arrowsColour[0][3] = "blu"; + } else { + me.arrowsMatrix[0][3] = 0; + me.arrowsColour[0][3] = "ack"; + } + } + if (size(me.vias) >= 4) { + me.L5 = [" " ~ me.vias[3 + me.scrollVias], nil, "blu"]; + if (me.vias[3 + me.scrollVias] != me.selectedVIA) { + me.arrowsMatrix[0][4] = 1; + me.arrowsColour[0][4] = "blu"; + } else { + me.arrowsMatrix[0][4] = 0; + me.arrowsColour[0][4] = "ack"; + } + } + + if (size(me.vias) > 3) { + me.enableScrollVias = 1; + } + }, clearTransitions: func() { - me.R2 = [nil, "TRANS", "wht"]; - me.R3 = [nil, "TRANS", "wht"]; - me.R4 = [nil, "TRANS", "wht"]; - me.R5 = [nil, "TRANS", "wht"]; - me.arrowsMatrix[1][1] = 0; - me.arrowsColour[1][1] = "ack"; + me.R3 = [nil, nil, "wht"]; + me.R4 = [nil, nil, "wht"]; + me.R5 = [nil, nil, "wht"]; me.arrowsMatrix[1][2] = 0; me.arrowsColour[1][2] = "ack"; me.arrowsMatrix[1][3] = 0; @@ -429,67 +570,68 @@ var arrivalPage = { me.arrowsMatrix[1][4] = 0; me.arrowsColour[1][4] = "ack"; }, + clearVias: func() { + me.L2 = [nil, nil, "wht"]; + me.L3 = [nil, nil, "wht"]; + me.L4 = [nil, nil, "wht"]; + me.L5 = [nil, nil, "wht"]; + me.arrowsMatrix[0][1] = 0; + me.arrowsColour[0][1] = "ack"; + me.arrowsMatrix[0][2] = 0; + me.arrowsColour[0][2] = "ack"; + me.arrowsMatrix[0][3] = 0; + me.arrowsColour[0][3] = "ack"; + me.arrowsMatrix[0][4] = 0; + me.arrowsColour[0][4] = "ack"; + if (me.activePage == 2) { + me.activePage = me.oldPage; + } + }, updateTransitions: func() { if (me.arrAirport == nil) { me.arrAirport = findAirportsByICAO(left(me.id, 4)); } - if (me.selectedSTAR == nil) { - me.R2 = ["NO TRANS ", "TRANS", "blu"]; - if (!me.hasPressNoTrans) { - me.arrowsMatrix[1][1] = 1; - me.arrowsColour[1][1] = "blu"; - } else { - me.arrowsMatrix[1][1] = 0; - me.arrowsColour[1][1] = "ack"; - } - return; - } - if (me.selectedSTAR == "NO STAR") { + + me.transitions = []; + me._transitions = nil; + me.clearTransitions(); + if (me.selectedSTAR == nil or me.selectedSTAR == "NO STAR") { + append(me.transitions, "NO TRANS"); return; } - me._transitions = me.arrAirport[0].getStar(me.selectedSTAR).transitions; + + if (isghost(me.selectedSTAR)) { + me._transitions = me.arrAirport[0].getStar(me.selectedSTAR.id).transitions; + } else { + me._transitions = me.arrAirport[0].getStar(me.selectedSTAR).transitions; + } me.transitions = sort(me._transitions,func(a,b) cmp(a,b)); + append(me.transitions, "NO TRANS"); - 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 (size(me.transitions) >= 1) { + me.R3 = [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) { + } + if (size(me.transitions) >= 2) { + me.R4 = [me.transitions[1] ~ " ", nil, "blu"]; + if (me.transitions[1] != 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) { + } + if (size(me.transitions) >= 3) { + me.R5 = [me.transitions[2] ~ " ", nil, "blu"]; + if (me.transitions[2] != me.selectedTransition) { me.arrowsMatrix[1][4] = 1; me.arrowsColour[1][4] = "blu"; } else { @@ -497,6 +639,9 @@ var arrivalPage = { me.arrowsColour[1][4] = "ack"; } } + + # no indication it is scrollable... + canvas_mcdu.pageSwitch[me.computer].setBoolValue(0); }, makeTmpy: func() { if (!fmgc.flightPlanController.temporaryFlag[me.computer]) { @@ -510,6 +655,17 @@ var arrivalPage = { } } }, + checkPageType: func() { + if (me.activePage == 0) { + me.L2 = [nil, nil, "wht"]; + me.arrowsMatrix[0][1] = 0; + me.arrowsColour[0][1] = "wht"; + } elsif (me.activePage == 1) { + me.L2 = [" VIAS", " APPR", "wht"]; + me.arrowsMatrix[0][1] = 1; + me.arrowsColour[0][1] = "wht"; + } + }, scrollUp: func() { if (me.activePage == 0) { if (me.enableScrollApproach) { @@ -519,10 +675,10 @@ var arrivalPage = { } me.updateApproaches(); } - } else { + } elsif (me.activePage == 1) { if (me.enableScrollStars) { me.scrollStars += 1; - if (me.scrollStars > size(me.stars) - 4) { + if (me.scrollStars > size(me.stars) - 3) { me.scrollStars = 0; } me.updateSTARs(); @@ -531,7 +687,15 @@ var arrivalPage = { } else { me.updateTransitions(); } - me.hasPressNoTrans = 0; + } + } elsif (me.activePage == 2) { + if (me.enableScrollVias) { + me.scrollVias += 1; + if (me.scrollVias > size(me.vias) - 4) { + me.scrollVias = 0; + } + me.updateActiveVIAs(); + me.updateVIAs(); } } }, @@ -544,11 +708,11 @@ var arrivalPage = { } me.updateApproaches(); } - } else { + } elsif (me.activePage == 1) { if (me.enableScrollStars) { me.scrollStars -= 1; if (me.scrollStars < 0) { - me.scrollStars = size(me.stars) - 4; + me.scrollStars = size(me.stars) - 3; } me.updateSTARs(); if (me.selectedSTAR == nil or me.selectedSTAR == "NO STAR") { @@ -556,24 +720,52 @@ var arrivalPage = { } else { me.updateTransitions(); } - me.hasPressNoTrans = 0; + } + } elsif (me.activePage == 2) { + if (me.enableScrollVias) { + me.scrollVias -= 1; + if (me.scrollVias < 0) { + me.scrollVias = size(me.vias) - 4; + } + me.updateActiveVIAs(); + me.updateVIAs(); } } }, scrollLeft: func() { + if (me.activePage == 2) { return; } me.activePage = !me.activePage; + me.checkPageType(); me.updatePage(); }, scrollRight: func() { + if (me.activePage == 2) { return; } me.activePage = !me.activePage; + me.checkPageType(); me.updatePage(); }, arrPushbuttonLeft: func(index) { - if (me.activePage == 0) { - if (size(me.approaches) >= (index - 2) and index != 2) { + if (index == 2 and me.activePage == 1 and me.selectedApproach != nil) { + if (getprop("/sim/version/flightgear") != "2020.2.0") { return; } + me.oldPage = me.activePage; + me.activePage = 2; + me.updatePage(); + me.updateVIAs(); + } elsif (index == 6 and me.activePage == 2) { + me.activePage = me.oldPage; + me.oldPage = 0; + me.updatePage(); + } elsif (index == 6 and me.activePage != 2) { + if (fmgc.flightPlanController.temporaryFlag[me.computer]) { + setprop("/MCDU[" ~ me.computer ~ "]/page", "F-PLNA"); + } else { + setprop("/MCDU[" ~ me.computer ~ "]/page", "LATREV"); + } + } elsif (me.activePage == 0 and index != 6) { + if (size(me.approaches) >= (index - 2) and index != 2) { # index = 3, size = 1 if (!dirToFlag) { - me.selectedSTAR = nil; - me.hasPressNoTrans = 0; + me.selectedVIA = nil; + isNoTransArr[me.computer] = 0; isNoStar[me.computer] = 0; me.makeTmpy(); if (!me.apprIsRwyFlag) { @@ -587,20 +779,22 @@ var arrivalPage = { setprop("FMGC/internal/baro", 99999); setprop("FMGC/internal/radio", 99999); setprop("FMGC/internal/radio-no", 0); - me.updateActiveApproach(); me.updateApproaches(); + me.updatePage(); fmgc.flightPlanController.flightPlanChanged(me.computer); me.scrollRight(); + me.checkPageType(); } else { mcdu_message(me.computer, "DIR TO IN PROGRESS"); } } else { mcdu_message(me.computer, "NOT ALLOWED"); } - } else { - if (size(me.stars) >= (index - 2)) { + } elsif (me.activePage == 1 and index != 6) { + if (size(me.stars) >= (index - 2) and index != 2) { if (!dirToFlag) { - me.selectedSTAR = me.stars[index - 2 + me.scrollStars]; + me.selectedTransition = nil; + me.selectedSTAR = me.stars[index - 3 + me.scrollStars]; me.makeTmpy(); if (me.selectedSTAR != "NO STAR") { isNoStar[me.computer] = 0; @@ -612,15 +806,14 @@ var arrivalPage = { fmgc.flightPlanController.insertNOSTAR(me.computer); } } - me.updateActiveSTARs(); me.updateSTARs(); if (me.selectedSTAR != "NO STAR") { - me.hasPressNoTrans = 0; - me.updateTransitions(); + isNoTransArr[me.computer] = 0; } else { - me.hasPressNoTrans = 1; + isNoTransArr[me.computer] = 1; + me.selectedTransition = "NO TRANS"; } - me.updateActiveTransitions(); + me.updatePage(); fmgc.flightPlanController.flightPlanChanged(me.computer); } else { mcdu_message(me.computer, "DIR TO IN PROGRESS"); @@ -628,24 +821,44 @@ var arrivalPage = { } else { mcdu_message(me.computer, "NOT ALLOWED"); } + } elsif (me.activePage == 2 and index != 6) { + if (size(me.vias) >= (index - 1)) { # different!! + if (!dirToFlag) { + me.selectedVIA = me.vias[index - 2 + me.scrollVias]; + me.makeTmpy(); + if (me.selectedVIA != "NO VIA") { + isNoVia[me.computer] = 0; + fmgc.flightPlanController.flightplans[me.computer].approach_trans = me.selectedVIA; + } else { + isNoVia[me.computer] = 1; + fmgc.flightPlanController.flightplans[me.computer].approach_trans = nil; + } + me.updateVIAs(); + me.updatePage(); + fmgc.flightPlanController.flightPlanChanged(me.computer); + } else { + mcdu_message(me.computer, "DIR TO IN PROGRESS"); + } + } else { + mcdu_message(me.computer, "NOT ALLOWED"); + } + } else { + mcdu_message(me.computer, "NOT ALLOWED"); } }, arrPushbuttonRight: func(index) { - if (index == 2 and size(me.transitions) == 0) { + if (size(me.transitions) >= (index - 2)) { if (!dirToFlag) { - me.hasPressNoTrans = 1; - me.updateActiveTransitions(); - me.updateTransitions(); - } else { - mcdu_message(me.computer, "DIR TO IN PROGRESS"); - } - } elsif (size(me.transitions) >= (index - 1)) { - if (!dirToFlag) { - me.selectedTransition = me.transitions[index - 2]; + me.selectedTransition = me.transitions[index - 3]; me.makeTmpy(); - fmgc.flightPlanController.flightplans[me.computer].star_trans = me.selectedTransition; - me.updateActiveTransitions(); - me.updateTransitions(); + if (me.selectedTransition != "NO TRANS") { + isNoTransArr[me.computer] = 0; + fmgc.flightPlanController.flightplans[me.computer].star_trans = me.selectedTransition; + } else { + isNoTransArr[me.computer] = 1; + fmgc.flightPlanController.flightplans[me.computer].star_trans = nil; + } + me.updatePage(); fmgc.flightPlanController.flightPlanChanged(me.computer); } else { mcdu_message(me.computer, "DIR TO IN PROGRESS"); diff --git a/Nasal/MCDU/DEPARTURE.nas b/Nasal/MCDU/DEPARTURE.nas index a9aefb44..697361f3 100644 --- a/Nasal/MCDU/DEPARTURE.nas +++ b/Nasal/MCDU/DEPARTURE.nas @@ -1,4 +1,5 @@ -var isNoSid = [0, 0]; +var isNoSid = [0, 0, 0]; +var isNoTransDep = [0, 0, 0]; var departurePage = { title: [nil, nil, nil], @@ -29,18 +30,18 @@ var departurePage = { selectedRunway: nil, selectedSID: nil, selectedTransition: nil, - sids: nil, - transitions: nil, computer: nil, enableScrollRwy: 0, enableScrollSids: 0, scrollRwy: 0, scrollSids: 0, activePage: 0, # runways, sids, trans - hasPressNoTrans: 0, # temporary _runways: nil, _sids: nil, _transitions: nil, + runways: [], + sids: [], + transitions: [], new: func(icao, computer) { var page = {parents:[departurePage]}; page.id = icao; @@ -54,8 +55,9 @@ var departurePage = { }, reset: func() { isNoSid[me.computer] = 0; + isNoTransDep[me.computer] = 0; me.selectedSID = nil; - me.hasPressNoTrans = 0; + me.selectedTransition = nil; }, _setupFirstTime: func() { if (!fmgc.flightPlanController.temporaryFlag[me.computer]) { @@ -65,9 +67,14 @@ var departurePage = { if (fmgc.flightPlanController.flightplans[2].sid != nil) { me.selectedSID = fmgc.flightPlanController.flightplans[2].sid; isNoSid[me.computer] = 0; - } elsif (isNoSid[me.computer] == 1) { + } elsif (isNoSid[2] == 1) { me.selectedSID = "NO SID"; - me.hasPressNoTrans = 1; + } + + if (isNoTransDep[2]) { + me.selectedTransition = "NO TRANS"; + } elsif (fmgc.flightPlanController.flightplans[2].sid != nil) { + me.selectedTransition = fmgc.flightPlanController.flightplans[2].sid_trans; } } else { if (fmgc.flightPlanController.flightplans[me.computer].departure_runway != nil) { @@ -77,15 +84,20 @@ var departurePage = { } if (fmgc.flightPlanController.flightplans[me.computer].sid != nil) { me.selectedSID = fmgc.flightPlanController.flightplans[me.computer].sid; - me.selectedTransition = fmgc.flightPlanController.flightplans[me.computer].sid_trans; isNoSid[me.computer] = 0; } elsif (fmgc.flightPlanController.flightplans[2].sid != nil) { me.selectedSID = fmgc.flightPlanController.flightplans[2].sid; - me.selectedTransition = fmgc.flightPlanController.flightplans[2].sid_trans; isNoSid[me.computer] = 0; } elsif (isNoSid[me.computer] == 1) { me.selectedSID = "NO SID"; - me.hasPressNoTrans = 1; + } + + if (isNoTransDep[me.computer] or isNoTransDep[2]) { + me.selectedTransition = "NO TRANS"; + } elsif (fmgc.flightPlanController.flightplans[me.computer].sid != nil) { + me.selectedTransition = fmgc.flightPlanController.flightplans[me.computer].sid_trans; + } elsif (fmgc.flightPlanController.flightplans[2].sid != nil) { + me.selectedTransition = fmgc.flightPlanController.flightplans[2].sid_trans; } } }, @@ -107,6 +119,7 @@ var departurePage = { me.updateRunways(); } else { me.updateSIDs(); + me.updateTransitions(); } me.updateActiveRunway(); @@ -142,18 +155,20 @@ var departurePage = { }, updateActiveRunway: func() { if (me.selectedRunway != nil) { - if (fmgc.flightPlanController.flightplans[2].departure_runway != nil) { + if (fmgc.flightPlanController.temporaryFlag[me.computer]) { if (fmgc.flightPlanController.flightplans[me.computer].departure_runway != nil) { me.L1 = [fmgc.flightPlanController.flightplans[me.computer].departure_runway.id, " RWY", "yel"]; - } elsif (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[2].departure_runway != nil and fmgc.flightPlanController.flightplans[2].departure_runway.id == me.selectedRunway.id) { + me.L1 = [fmgc.flightPlanController.flightplans[2].departure_runway.id, " RWY", "yel"]; } else { me.L1 = ["---", " RWY", "wht"]; } - } 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"]; + if (fmgc.flightPlanController.flightplans[2].departure_runway != nil) { + me.L1 = [fmgc.flightPlanController.flightplans[2].departure_runway.id, " RWY", "grn"]; + } else { + me.L1 = ["---", " RWY", "wht"]; + } } } else { me.L1 = ["---", " RWY", "wht"]; @@ -168,18 +183,20 @@ var departurePage = { me.C1 = ["NONE", "SID", "yel"]; } } elsif (me.selectedSID != nil) { - if (fmgc.flightPlanController.flightplans[2].sid != nil) { + if (fmgc.flightPlanController.temporaryFlag[me.computer]) { if (fmgc.flightPlanController.flightplans[me.computer].sid != nil) { me.C1 = [fmgc.flightPlanController.flightplans[me.computer].sid.id, "SID", "yel"]; - } elsif (fmgc.flightPlanController.flightplans[2].sid.id == me.selectedSID.id) { - me.C1 = [fmgc.flightPlanController.flightplans[2].sid.id, "SID", "grn"]; + } elsif (fmgc.flightPlanController.flightplans[2].sid != nil and fmgc.flightPlanController.flightplans[2].sid.id == me.selectedSID.id) { + me.C1 = [fmgc.flightPlanController.flightplans[2].sid.id, "SID", "yel"]; } else { me.C1 = ["------- ", "SID", "wht"]; } - } elsif (fmgc.flightPlanController.flightplans[me.computer].sid != nil) { - me.C1 = [fmgc.flightPlanController.flightplans[me.computer].sid.id, "SID", "yel"]; } else { - me.C1 = ["------- ", "SID", "wht"]; + if (fmgc.flightPlanController.flightplans[2].sid != nil) { + me.C1 = [fmgc.flightPlanController.flightplans[2].sid.id, "SID", "grn"]; + } else { + me.C1 = ["------- ", "SID", "wht"]; + } } } else { me.C1 = ["------- ", "SID", "wht"]; @@ -187,30 +204,32 @@ var departurePage = { canvas_mcdu.pageSwitch[me.computer].setBoolValue(0); }, updateActiveTransitions: func() { - if (!me.hasPressNoTrans) { - if (me.selectedTransition != nil) { - if (fmgc.flightPlanController.flightplans[2].sid_trans != nil) { - if (fmgc.flightPlanController.flightplans[me.computer].sid_trans != nil) { - me.R1 = [fmgc.flightPlanController.flightplans[me.computer].sid_trans.id, "TRANS", "yel"]; - } elsif (fmgc.flightPlanController.flightplans[2].sid_trans.id == me.selectedTransition.id) { - me.R1 = [fmgc.flightPlanController.flightplans[2].sid_trans.id, "TRANS", "grn"]; - } else { - me.R1 = ["-------", "TRANS ", "wht"]; - } - } elsif (fmgc.flightPlanController.flightplans[me.computer].sid_trans != nil) { - me.R1 = [fmgc.flightPlanController.flightplans[me.computer].sid_trans.id, "SID", "yel"]; - } else { - me.R1 = ["-------", "TRANS ", "wht"]; - } - } else { - me.R1 = ["-------", "TRANS ", "wht"]; - } - } else { + if (me.selectedTransition == "NO TRANS") { if (!fmgc.flightPlanController.temporaryFlag[me.computer]) { me.R1 = ["NONE", "TRANS ", "grn"]; } else { me.R1 = ["NONE", "TRANS ", "yel"]; } + } else { + if (me.selectedTransition != nil) { + if (fmgc.flightPlanController.temporaryFlag[me.computer]) { + if (fmgc.flightPlanController.flightplans[me.computer].sid_trans != nil) { + me.R1 = [fmgc.flightPlanController.flightplans[me.computer].sid_trans.id, "TRANS", "yel"]; + } elsif (fmgc.flightPlanController.flightplans[2].sid_trans != nil and fmgc.flightPlanController.flightplans[2].sid_trans.id == me.selectedTransition.id) { + me.R1 = [fmgc.flightPlanController.flightplans[2].sid_trans.id, "TRANS", "yel"]; + } else { + me.R1 = ["-------", "TRANS ", "wht"]; + } + } else { + if (fmgc.flightPlanController.flightplans[2].sid_trans != nil) { + me.R1 = [fmgc.flightPlanController.flightplans[2].sid_trans.id, "SID", "grn"]; + } else { + me.R1 = ["-------", "TRANS ", "wht"]; + } + } + } else { + me.R1 = ["-------", "TRANS ", "wht"]; + } } canvas_mcdu.pageSwitch[me.computer].setBoolValue(0); }, @@ -218,6 +237,10 @@ var departurePage = { if (me.depAirport == nil) { me.depAirport = findAirportsByICAO(left(me.id, 4)); } + + me.runways = []; + me._runways = nil; + me._runways = keys(me.depAirport[0].runways); me.runways = sort(me._runways,func(a,b) cmp(a,b)); @@ -279,6 +302,10 @@ var departurePage = { if (me.depAirport == nil) { me.depAirport = findAirportsByICAO(left(me.id, 4)); } + + me.sids = []; + me._sids = nil; + if (me.selectedRunway != nil) { me._sids = me.depAirport[0].sids(me.selectedRunway.id); } else { @@ -334,8 +361,8 @@ var departurePage = { } } - me.C2 = [nil, "AVAILABLE", "wht"]; - me.R2 = [nil, "TRANS ", "wht"]; + me.C2[1] = "AVAILABLE"; + me.R2[1] = "TRANS "; if (size(me.sids) > 4) { me.enableScrollSids = 1; @@ -361,30 +388,22 @@ var departurePage = { me.depAirport = findAirportsByICAO(left(me.id, 4)); } - if (me.selectedSID == nil) { - me.R2 = ["NO TRANS ", "TRANS", "blu"]; - if (!me.hasPressNoTrans) { - me.arrowsMatrix[1][1] = 1; - me.arrowsColour[1][1] = "blu"; - } else { - me.arrowsMatrix[1][1] = 0; - me.arrowsColour[1][1] = "ack"; - } + me.clearTransitions(); + if (me.selectedSID == nil or me.selectedSID == "NO SID") { + append(me.transitions, "NO TRANS"); return; } + + if (isghost(me.selectedSID)) { + me._transitions = me.depAirport[0].getSid(me.selectedSID.id).transitions; + } else { + me._transitions = me.depAirport[0].getSid(me.selectedSID).transitions; + } me._transitions = me.depAirport[0].getSid(me.selectedSID).transitions; me.transitions = sort(me._transitions,func(a,b) cmp(a,b)); + append(me.transitions, "NO TRANS"); - 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) { + if (size(me.transitions) >= 1) { me.R2 = [me.transitions[0] ~ " ", "TRANS", "blu"]; if (me.transitions[0] != me.selectedTransition) { me.arrowsMatrix[1][1] = 1; @@ -421,6 +440,7 @@ var departurePage = { me.arrowsColour[1][4] = "ack"; } } + canvas_mcdu.pageSwitch[me.computer].setBoolValue(0); }, makeTmpy: func() { if (!fmgc.flightPlanController.temporaryFlag[me.computer]) { @@ -455,7 +475,6 @@ var departurePage = { } else { me.updateTransitions(); } - me.hasPressNoTrans = 0; } } }, @@ -480,7 +499,6 @@ var departurePage = { } else { me.updateTransitions(); } - me.hasPressNoTrans = 0; } } }, @@ -498,12 +516,12 @@ var departurePage = { if (!dirToFlag) { me.selectedSID = nil; isNoSid[me.computer] = 0; - me.hasPressNoTrans = 0; + isNoTransDep[me.computer] = 0; 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(); + me.updatePage(); fmgc.flightPlanController.flightPlanChanged(me.computer); me.scrollRight(); } else { @@ -519,21 +537,20 @@ var departurePage = { me.makeTmpy(); if (me.selectedSID != "NO SID") { isNoSid[me.computer] = 0; - fmgc.flightPlanController.flightplans[me.computer].sid = me.selectedSID; + fmgc.flightPlanController.flightplans[me.computer].sid = me.depAirport[0].getSid(me.selectedSID); } else { isNoSid[me.computer] = 1; fmgc.flightPlanController.flightplans[me.computer].sid = nil; fmgc.flightPlanController.insertNOSID(me.computer); } - me.updateActiveSIDs(); me.updateSIDs(); if (me.selectedSID != "NO SID") { - me.hasPressNoTrans = 0; - me.updateTransitions(); + isNoTransDep[me.computer] = 0; } else { - me.hasPressNoTrans = 1; + isNoTransDep[me.computer] = 1; + me.selectedTransition = "NO TRANS"; } - me.updateActiveTransitions(); + me.updatePage(); fmgc.flightPlanController.flightPlanChanged(me.computer); } else { mcdu_message(me.computer, "DIR TO IN PROGRESS"); @@ -544,21 +561,18 @@ var departurePage = { } }, depPushbuttonRight: func(index) { - if (index == 2 and size(me.transitions) == 0) { - if (!dirToFlag) { - me.hasPressNoTrans = 1; - me.updateActiveTransitions(); - me.updateTransitions(); - } else { - mcdu_message(me.computer, "DIR TO IN PROGRESS"); - } - } elsif (size(me.transitions) >= (index - 1)) { + if (size(me.transitions) >= (index - 1)) { if (!dirToFlag) { me.selectedTransition = me.transitions[index - 2]; me.makeTmpy(); - fmgc.flightPlanController.flightplans[me.computer].sid_trans = me.depAirport[0].getSid(me.selectedSID).transition(me.selectedTransition); - me.updateActiveTransitions(); - me.updateTransitions(); + if (me.selectedTransition != "NO TRANS") { + isNoTransDep[me.computer] = 0; + fmgc.flightPlanController.flightplans[me.computer].sid_trans = me.selectedTransition; + } else { + isNoTransDep[me.computer] = 1; + fmgc.flightPlanController.flightplans[me.computer].sid_trans = nil; + } + me.updatePage(); fmgc.flightPlanController.flightPlanChanged(me.computer); } else { mcdu_message(me.computer, "DIR TO IN PROGRESS"); diff --git a/Nasal/MCDU/F-PLN.nas b/Nasal/MCDU/F-PLN.nas index 12679a46..7b264f52 100644 --- a/Nasal/MCDU/F-PLN.nas +++ b/Nasal/MCDU/F-PLN.nas @@ -7,6 +7,7 @@ var fplnItem = { fI.computer = computer; fI.colour = colour; fI.assembledStr = [nil, nil, colour]; + fI._colour = "wht"; return fI; }, updateLeftText: func() { @@ -39,8 +40,10 @@ var fplnItem = { if (me.wp.wp_name != "DISCONTINUITY") { if (me.index == fmgc.flightPlanController.currentToWptIndex.getValue() - 1 and fmgc.flightPlanController.fromWptTime != nil) { me.assembledStr[0] = fmgc.flightPlanController.fromWptTime ~ " "; + me.assembledStr[2] = "grn"; } else { me.assembledStr[0] = "---- "; + me.assembledStr[2] = "wht"; } if (me.index == fmgc.flightPlanController.currentToWptIndex.getValue()) { @@ -65,7 +68,11 @@ var fplnItem = { me.spd = me.getSpd(); me.alt = me.getAlt(); me.dist = me.getDist(); - return [me.spd ~ "/" ~ me.alt, " " ~ me.dist ~ "NM ", me.colour]; + me._colour = "wht"; + if (me.spd[1] != "wht" or me.alt[1] != "wht") { + me._colour = "mag"; + } + return [me.spd[0] ~ "/" ~ me.alt[0], " " ~ me.dist ~ "NM ", me._colour]; } else { return [nil, nil, "ack"]; } @@ -88,18 +95,26 @@ var fplnItem = { }, getSpd: func() { if (me.index == 0 and getprop("FMGC/internal/v1-set")) { - return sprintf("%3.0f", math.round(getprop("FMGC/internal/v1"))); + return [sprintf("%3.0f", math.round(getprop("FMGC/internal/v1"))), "mag"]; + } elsif (me.wp.speed_cstr != nil and me.wp.speed_cstr != 0) { + return [sprintf("%3.0f", me.wp.speed_cstr), "mag"]; } else { - return "---"; + return ["---", "wht"]; } }, getAlt: func() { if (me.index == 0 and left(me.wp.wp_name, 4) == getprop("/FMGC/internal/dep-arpt") and fmgc.flightPlanController.flightplans[me.plan].departure != nil) { - return sprintf("%6.0f", math.round(fmgc.flightPlanController.flightplans[me.plan].departure.elevation * M2FT)); + return [" " ~ sprintf("%-5.0f", math.round(fmgc.flightPlanController.flightplans[me.plan].departure.elevation * M2FT)), "mag"]; } elsif (me.index == (fmgc.flightPlanController.currentToWptIndex.getValue() - 1) and fmgc.flightPlanController.fromWptAlt != nil) { - return " " ~ fmgc.flightPlanController.fromWptAlt; + return [" " ~ fmgc.flightPlanController.fromWptAlt, "mag"]; + } elsif (me.wp.alt_cstr != nil and me.wp.alt_cstr != 0) { + if (me.wp.alt_cstr > fmgc.FMGCInternal.transAlt) { + return [" " ~ sprintf("%-5s", "FL" ~ math.round(num(me.wp.alt_cstr) / 100)), "mag"]; + } else { + return [" " ~ sprintf("%-5.0f", me.wp.alt_cstr), "mag"]; + } } else { - return "------"; + return ["------", "wht"]; } }, getDist: func() { @@ -216,17 +231,6 @@ var fplnPage = { # this one is only created once, and then updated - remember th 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, diff --git a/Nasal/MCDU/FUELPRED.nas b/Nasal/MCDU/FUELPRED.nas index c06a5b4d..63000cf2 100644 --- a/Nasal/MCDU/FUELPRED.nas +++ b/Nasal/MCDU/FUELPRED.nas @@ -33,7 +33,9 @@ var fuelPredInput = func(key, i) { if (key == "L3" and getprop("/FMGC/internal/block-confirmed") and !getprop("/FMGC/internal/fuel-calculating")) { if (scratchpad == "CLR") { setprop("/FMGC/internal/rte-rsv", 0.05 * num(getprop("/FMGC/internal/trip-fuel"))); + setprop("/FMGC/internal/rte-rsv-set", 0); setprop("/FMGC/internal/rte-percent", 5.0); + setprop("/FMGC/internal/rte-percent-set", 0); setprop("/FMGC/internal/fuel-calculating", 1); mcdu_scratchpad.scratchpads[i].empty(); } else if (getprop("/FMGC/internal/trip-fuel") != 0) { @@ -43,17 +45,21 @@ var fuelPredInput = func(key, i) { var perc = num(split("/", scratchpad)[1]); if (perc != nil and perc >= 0.0 and perc <= 15.0) { setprop("/FMGC/internal/rte-rsv", num(perc) / 100 * num(getprop("/FMGC/internal/trip-fuel"))); + setprop("/FMGC/internal/rte-rsv-set", 0); setprop("/FMGC/internal/rte-percent", perc); + setprop("/FMGC/internal/rte-percent-set", 1); setprop("/FMGC/internal/fuel-calculating", 1); mcdu_scratchpad.scratchpads[i].empty(); } } else if (tfs >= 1 and tfs <= 4 and tf != nil and tf >= 0 and tf <= 21.7) { setprop("/FMGC/internal/rte-rsv", scratchpad); + setprop("/FMGC/internal/rte-rsv-set", 1); if (scratchpad / num(getprop("/FMGC/internal/trip-fuel")) * 100 <= 15.0) { setprop("/FMGC/internal/rte-percent", scratchpad / num(getprop("/FMGC/internal/trip-fuel")) * 100); } else { setprop("/FMGC/internal/rte-percent", 15.0); # need reasearch on this value } + setprop("/FMGC/internal/rte-percent-set", 0); setprop("/FMGC/internal/fuel-calculating", 1); mcdu_scratchpad.scratchpads[i].empty(); } else { diff --git a/Nasal/MCDU/MCDU.nas b/Nasal/MCDU/MCDU.nas index 365ea49d..3773c3ed 100644 --- a/Nasal/MCDU/MCDU.nas +++ b/Nasal/MCDU/MCDU.nas @@ -471,7 +471,9 @@ var lskbutton = func(btn, i) { canvas_mcdu.myFpln[i].pushButtonLeft(6); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "LATREV" or getprop("/MCDU[" ~ i ~ "]/page") == "VERTREV" or getprop("/MCDU[" ~ i ~ "]/page") == "DUPLICATENAMES") { setprop("/MCDU[" ~ i ~ "]/page", "F-PLNA"); - } else if (getprop("/MCDU[" ~ i ~ "]/page") == "DEPARTURE" or getprop("/MCDU[" ~ i ~ "]/page") == "ARRIVAL" or getprop("/MCDU[" ~ i ~ "]/page") == "HOLD") { + } else if (getprop("/MCDU[" ~ i ~ "]/page") == "ARRIVAL") { + canvas_mcdu.myArrival[i].arrPushbuttonLeft(6); + } else if (getprop("/MCDU[" ~ i ~ "]/page") == "DEPARTURE" or getprop("/MCDU[" ~ i ~ "]/page") == "HOLD") { if (fmgc.flightPlanController.temporaryFlag[i]) { setprop("/MCDU[" ~ i ~ "]/page", "F-PLNA"); } else { diff --git a/gui/it-gui.xml b/gui/it-gui.xml index cfb79da1..ddbe6793 100644 --- a/gui/it-gui.xml +++ b/gui/it-gui.xml @@ -1,6 +1,6 @@ - + @@ -10,21 +10,21 @@ 0.95 - 0.213 - 0.199 - 0.191 + 0.17 + 0.17 + 0.17 0.95 - 0.173 - 0.169 - 0.161 + 0.19 + 0.19 + 0.19 0.95 @@ -40,9 +40,9 @@ 0.95 - 0.2 - 0.2 - 0.2 + 0.33 + 0.33 + 0.33 0.95 @@ -58,9 +58,9 @@ 0.95 - 0.2 - 0.2 - 0.2 + 0.33 + 0.33 + 0.33 0.95 @@ -82,21 +82,21 @@ 0.95 - 0.2 - 0.2 - 0.2 + 0.33 + 0.33 + 0.33 1.0 - 0.4 - 0.4 - 0.4 + 0.33 + 0.33 + 0.33 0.95 - 0.2 - 0.2 - 0.2 + 0.33 + 0.33 + 0.33 0.95 @@ -111,21 +111,21 @@ 0.95 - 0.213 - 0.199 - 0.191 + 0.17 + 0.17 + 0.17 0.95 - 0.173 - 0.169 - 0.161 + 0.19 + 0.19 + 0.19 0.95 @@ -135,15 +135,15 @@ 0.95 - 0.9 - 0.9 - 0.9 + 0.8 + 0.58 + 0.44 0.95 - 0.2 - 0.2 - 0.2 + 0.33 + 0.33 + 0.33 0.95 @@ -159,9 +159,9 @@ 0.95 - 0.2 - 0.2 - 0.2 + 0.33 + 0.33 + 0.33 0.95 @@ -183,21 +183,21 @@ 0.95 - 0.2 - 0.2 - 0.2 + 0.33 + 0.33 + 0.33 1.0 - 0.4 - 0.4 - 0.4 + 0.33 + 0.33 + 0.33 0.95 - 0.2 - 0.2 - 0.2 + 0.33 + 0.33 + 0.33 0.95