From 567bc6191953574c972a8cf0442e69535f7b3627 Mon Sep 17 00:00:00 2001 From: noteas <2314834661@qq.com> Date: Sat, 24 Dec 2022 10:12:55 +0800 Subject: [PATCH] Implemented MCDU AIRWAYS page, fixed #280 #283 --- Nasal/MCDU/AIRWAYS.nas | 27 +++++----- Nasal/MCDU/MCDU.nas | 109 +++++++++++++++++++++++++++++++++++++++++ README.md | 2 +- 3 files changed, 125 insertions(+), 13 deletions(-) diff --git a/Nasal/MCDU/AIRWAYS.nas b/Nasal/MCDU/AIRWAYS.nas index d14be37af..aac6abb36 100644 --- a/Nasal/MCDU/AIRWAYS.nas +++ b/Nasal/MCDU/AIRWAYS.nas @@ -23,7 +23,8 @@ var airwaysPage = { R6: [nil, nil, "ack"], scroll: 0, vector: [], - index: nil, + index: "L1", + wpIndex: nil computer: nil, titleColour: nil, new: func(computer, waypoint) { @@ -44,6 +45,7 @@ var airwaysPage = { me.R1 = [nil, "TO ", "blu"]; 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.wpIndex = me.waypoint; canvas_mcdu.pageSwitch[me.computer].setBoolValue(0); }, makeTmpy: func() { @@ -64,17 +66,18 @@ var airwaysPage = { canvas_mcdu.pageSwitch[me.computer].setBoolValue(0); } }, - updateAirways: func(index, airwayName) { - if (index == 1) { - me.L1[0] = airwayName; - } elsif (index == 2) { - me.L2[0] = airwayName; - } elsif (index == 3) { - me.L3[0] = airwayName; - } elsif (index == 4) { - me.L4[0] = airwayName; - } elsif (index == 5) { - me.L5[0] = airwayName; + updateAirways: func(name) { # Find route to waypoint by airway + var fix = findFixesByID(name); + if (fix == nil) { + return nil; } + fix = fix[0]; + var rt = airwaysRoute(me.wpIndex, fix); + if (rt == nil) { + return nil; + } + fmgc.flightPlanController.flightplans[me.computer].insertWaypoints(rt, fmgc.flightPlanController.flightplans[me.computer].indexOfWP(me.wpIndex) + 1); + me.wpIndex = rt[-1]; + return 1; }, }; \ No newline at end of file diff --git a/Nasal/MCDU/MCDU.nas b/Nasal/MCDU/MCDU.nas index 9636916e7..62746e460 100644 --- a/Nasal/MCDU/MCDU.nas +++ b/Nasal/MCDU/MCDU.nas @@ -262,6 +262,15 @@ var lskbutton = func(btn, i) { } else { mcdu_message(i, "NOT ALLOWED"); } + } else if (page == "AIRWAYS") { + if (mcdu_scratchpad.scratchpads[i].scratchpad != nil and canvas_mcdu.myAirways[i].index == "L1") { + canvas_mcdu.myAirways[i].L1 = [mcdu_scratchpad.scratchpads[i].scratchpad, " VIA", "wht"]; + canvas_mcdu.myAirways[i].index = "R1"; + canvas_mcdu.myAirways[i].R1 = ["[ ]", nil, "blu"]; + mcdu_scratchpad.scratchpads[i].empty(); + } else { + mcdu_message(i, "NOT ALLOWED"); + } } else if (page == "F-PLNA" or page == "F-PLNB") { canvas_mcdu.myFpln[i].pushButtonLeft(1); } else if (page == "DIRTO") { @@ -406,6 +415,15 @@ var lskbutton = func(btn, i) { perfDESInput("L2",i); } else if (page == "DATA") { dataInput("L2",i); + } else if (page == "AIRWAYS") { + if (mcdu_scratchpad.scratchpads[i].scratchpad != nil and canvas_mcdu.myAirways[i].index == "L2") { + canvas_mcdu.myAirways[i].L2 = [mcdu_scratchpad.scratchpads[i].scratchpad, nil, "wht"]; + canvas_mcdu.myAirways[i].index = "R2"; + canvas_mcdu.myAirways[i].R2 = ["[ ]", nil, "blu"]; + mcdu_scratchpad.scratchpads[i].empty(); + } else { + mcdu_message(i, "NOT ALLOWED"); + } } else if (page == "F-PLNA" or page == "F-PLNB") { canvas_mcdu.myFpln[i].pushButtonLeft(2); } else if (page == "DEPARTURE") { @@ -555,6 +573,15 @@ var lskbutton = func(btn, i) { } else { mcdu_message(i, "NOT ALLOWED"); } + } else if (page == "AIRWAYS") { + if (mcdu_scratchpad.scratchpads[i].scratchpad != nil and canvas_mcdu.myAirways[i].index == "L3") { + canvas_mcdu.myAirways[i].L3 = [mcdu_scratchpad.scratchpads[i].scratchpad, nil, "wht"]; + canvas_mcdu.myAirways[i].index = "R3"; + canvas_mcdu.myAirways[i].R3 = ["[ ]", nil, "blu"]; + mcdu_scratchpad.scratchpads[i].empty(); + } else { + mcdu_message(i, "NOT ALLOWED"); + } } else if (page == "DUPLICATENAMES") { canvas_mcdu.myDuplicate[i].pushButtonLeft(3); } else if (page == "COMMMENU") { @@ -662,6 +689,15 @@ var lskbutton = func(btn, i) { perfAPPRInput("L4",i); } else if (page == "RADNAV") { radnavInput("L4",i); + } else if (page == "AIRWAYS") { + if (mcdu_scratchpad.scratchpads[i].scratchpad != nil and canvas_mcdu.myAirways[i].index == "L4") { + canvas_mcdu.myAirways[i].L4 = [mcdu_scratchpad.scratchpads[i].scratchpad, nil, "wht"]; + canvas_mcdu.myAirways[i].index = "R4"; + canvas_mcdu.myAirways[i].R4 = ["[ ]", nil, "blu"]; + mcdu_scratchpad.scratchpads[i].empty(); + } else { + mcdu_message(i, "NOT ALLOWED"); + } } else if (page == "F-PLNA" or page == "F-PLNB") { canvas_mcdu.myFpln[i].pushButtonLeft(4); } else if (page == "DEPARTURE") { @@ -784,6 +820,15 @@ var lskbutton = func(btn, i) { dataInput("L5",i); } else if (page == "DATA2") { data2Input("L5",i); + } else if (page == "AIRWAYS") { + if (mcdu_scratchpad.scratchpads[i].scratchpad != nil and canvas_mcdu.myAirways[i].index == "L5") { + canvas_mcdu.myAirways[i].L5 = [mcdu_scratchpad.scratchpads[i].scratchpad, nil, "wht"]; + canvas_mcdu.myAirways[i].index = "R5"; + canvas_mcdu.myAirways[i].R5 = ["[ ]", nil, "blu"]; + mcdu_scratchpad.scratchpads[i].empty(); + } else { + mcdu_message(i, "NOT ALLOWED"); + } } else if (page == "F-PLNA" or page == "F-PLNB") { canvas_mcdu.myFpln[i].pushButtonLeft(5); } else if (page == "DEPARTURE") { @@ -937,6 +982,19 @@ var rskbutton = func(btn, i) { } else { mcdu_message(i, "NOT ALLOWED"); } + } else if (page == "AIRWAYS") { + if (mcdu_scratchpad.scratchpads[i].scratchpad != nil and canvas_mcdu.myAirways[i].index == "R1") { + canvas_mcdu.myAirways[i].R1 = [mcdu_scratchpad.scratchpads[i].scratchpad, "TO ", "wht"]; + if (canvas_mcdu.myAirways[i].updateAirways(mcdu_scratchpad.scratchpads[i].scratchpad) == nil) { + mcdu_message(i, "NOT IN DATA BASE"); + } else { + canvas_mcdu.myAirways[i].index = "L2"; + canvas_mcdu.myAirways[i].L2 = ["[ ]", nil, "blu"]; + mcdu_scratchpad.scratchpads[i].empty(); + } + } else { + mcdu_message(i, "NOT ALLOWED"); + } } else if (page == "F-PLNA" or page == "F-PLNB") { canvas_mcdu.myFpln[i].pushButtonRight(1); } else if (page == "DATA2") { @@ -1016,6 +1074,19 @@ var rskbutton = func(btn, i) { canvas_mcdu.myDeparture[i].depPushbuttonRight(2); } else if (page == "ARRIVAL") { canvas_mcdu.myArrival[i].arrPushbuttonRight(2); + } else if (page == "AIRWAYS") { + if (mcdu_scratchpad.scratchpads[i].scratchpad != nil and canvas_mcdu.myAirways[i].index == "R2") { + canvas_mcdu.myAirways[i].R2 = [mcdu_scratchpad.scratchpads[i].scratchpad, nil, "wht"]; + if (canvas_mcdu.myAirways[i].updateAirways(mcdu_scratchpad.scratchpads[i].scratchpad) == nil) { + mcdu_message(i, "NOT IN DATA BASE"); + } else { + canvas_mcdu.myAirways[i].index = "L3"; + canvas_mcdu.myAirways[i].L3 = ["[ ]", nil, "blu"]; + mcdu_scratchpad.scratchpads[i].empty(); + } + } else { + mcdu_message(i, "NOT ALLOWED"); + } } else if (page == "F-PLNA" or page == "F-PLNB") { canvas_mcdu.myFpln[i].pushButtonRight(2); } else if (page == "NOTIFICATION") { @@ -1065,6 +1136,19 @@ var rskbutton = func(btn, i) { } else { mcdu_message(i, "NOT ALLOWED"); } + } else if (page == "AIRWAYS") { + if (mcdu_scratchpad.scratchpads[i].scratchpad != nil and canvas_mcdu.myAirways[i].index == "R3") { + canvas_mcdu.myAirways[i].R3 = [mcdu_scratchpad.scratchpads[i].scratchpad, nil, "wht"]; + if (canvas_mcdu.myAirways[i].updateAirways(mcdu_scratchpad.scratchpads[i].scratchpad) == nil) { + mcdu_message(i, "NOT IN DATA BASE"); + } else { + canvas_mcdu.myAirways[i].index = "L4"; + canvas_mcdu.myAirways[i].L4 = ["[ ]", nil, "blu"]; + mcdu_scratchpad.scratchpads[i].empty(); + } + } else { + mcdu_message(i, "NOT ALLOWED"); + } } else if (page == "F-PLNA" or page == "F-PLNB") { canvas_mcdu.myFpln[i].pushButtonRight(3); } else if (page == "AOCMENU") { @@ -1148,6 +1232,19 @@ var rskbutton = func(btn, i) { canvas_mcdu.myDeparture[i].depPushbuttonRight(4); } else if (page == "ARRIVAL") { canvas_mcdu.myArrival[i].arrPushbuttonRight(4); + } else if (page == "AIRWAYS") { + if (mcdu_scratchpad.scratchpads[i].scratchpad != nil and canvas_mcdu.myAirways[i].index == "R4") { + canvas_mcdu.myAirways[i].R4 = [mcdu_scratchpad.scratchpads[i].scratchpad, nil, "wht"]; + if (canvas_mcdu.myAirways[i].updateAirways(mcdu_scratchpad.scratchpads[i].scratchpad) == nil) { + mcdu_message(i, "NOT IN DATA BASE"); + } else { + canvas_mcdu.myAirways[i].index = "L5"; + canvas_mcdu.myAirways[i].L5 = ["[ ]", nil, "blu"]; + mcdu_scratchpad.scratchpads[i].empty(); + } + } else { + mcdu_message(i, "NOT ALLOWED"); + } } else if (page == "F-PLNA" or page == "F-PLNB") { canvas_mcdu.myFpln[i].pushButtonRight(4); } else if (page == "ATIS") { @@ -1227,6 +1324,18 @@ var rskbutton = func(btn, i) { canvas_mcdu.myDeparture[i].depPushbuttonRight(5); } else if (page == "ARRIVAL") { canvas_mcdu.myArrival[i].arrPushbuttonRight(5); + } else if (page == "AIRWAYS") { + if (mcdu_scratchpad.scratchpads[i].scratchpad != nil and canvas_mcdu.myAirways[i].index == "R5") { + canvas_mcdu.myAirways[i].R5 = [mcdu_scratchpad.scratchpads[i].scratchpad, nil, "wht"]; + if (canvas_mcdu.myAirways[i].updateAirways(mcdu_scratchpad.scratchpads[i].scratchpad) == nil) { + mcdu_message(i, "NOT IN DATA BASE"); + } else { + canvas_mcdu.myAirways[i].index = nil; + mcdu_scratchpad.scratchpads[i].empty(); + } + } else { + mcdu_message(i, "NOT ALLOWED"); + } } else if (page == "F-PLNA" or page == "F-PLNB") { canvas_mcdu.myFpln[i].pushButtonRight(5); } else if (page == "LATREV") { diff --git a/README.md b/README.md index eae1fb039..aa9747bb8 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ You can find a Checklist to download and print [here](https://raw.githubusercont ## Navdata It is highly reccomended to purchase a NAVIGRAPH subscription and download their level d FMSDATA / waypoint / navaid data! If you do not wish to do that, there is older data linked below. But it won't have most of the newer procedures, and is only for a limited number of airports, as naturally it is not possible to distribute commercial data. If runway numbering changed, it is quite possible that it will not work due to FlightGear limitations in the routing code. -To install navdata, create a folder FMSDATA, and add it to your additional scenery folders, at the top of the list. Inside that folder, place all the XXXX.procedures.xml files, in the format FMSDATA/X/X/X/XXXX.procedures.xml. For instance, FMSDATA/Airports/E/G/K/EGKK.procedures.xml. +To install navdata, create a folder FMSDATA, and add it to your additional scenery folders, at the top of the list. Inside that folder, place all the XXXX.procedures.xml files, in the format FMSDATA/X/X/X/XXXX.procedures.xml. For instance, FMSDATA/Airports/E/G/K/EGKK.procedures.xml. For further details, please refer to [this](https://wiki.flightgear.org/Route_manager#SIDs_and_STARs). ## Remote MCDU If you want to run the MCDU on a your smarthphone or tablet for better realism and easier input, run FlightGear with enabled HTTP server (i.e. command line --httpd=) then go to main menu -> Instruments -> Remote MCDU.