From d7718fededdb1cd8b72c84f788abd286010b4154 Mon Sep 17 00:00:00 2001 From: Jonathan Redpath Date: Mon, 27 Dec 2021 11:44:08 +0000 Subject: [PATCH] RADNAV code - use nodes or variables rather than getprop --- Models/Instruments/MCDU/MCDU.nas | 58 ++---- .../ND/canvas/framework/navdisplay.nas | 2 +- Models/Instruments/ND/canvas/style.nas | 13 +- Models/Instruments/PFD/PFD.nas | 157 +++++++------- Nasal/FMGC/FMGC.nas | 150 ++++++-------- Nasal/Libraries/property-tree-setup.nas | 6 + Nasal/MCDU/MCDU.nas | 18 +- Nasal/MCDU/RADNAV.nas | 193 +++++++++--------- Nasal/Panels/rmp.nas | 17 +- 9 files changed, 283 insertions(+), 331 deletions(-) diff --git a/Models/Instruments/MCDU/MCDU.nas b/Models/Instruments/MCDU/MCDU.nas index ece6e220..307a733a 100644 --- a/Models/Instruments/MCDU/MCDU.nas +++ b/Models/Instruments/MCDU/MCDU.nas @@ -85,26 +85,6 @@ var database1 = props.globals.getNode("/FMGC/internal/navdatabase", 1); var database2 = props.globals.getNode("/FMGC/internal/navdatabase2", 1); var databaseCode = props.globals.getNode("/FMGC/internal/navdatabasecode", 1); -# RADNAV -var vor1 = props.globals.getNode("/FMGC/internal/vor1-mcdu", 1); -var vor2 = props.globals.getNode("/FMGC/internal/vor2-mcdu", 1); -var ils1 = props.globals.getNode("/FMGC/internal/ils1-mcdu", 1); -var adf1 = props.globals.getNode("/FMGC/internal/adf1-mcdu", 1); -var adf2 = props.globals.getNode("/FMGC/internal/adf2-mcdu", 1); -var vor1FreqSet = props.globals.getNode("/FMGC/internal/vor1freq-set", 1); -var vor1CRSSet = props.globals.getNode("/FMGC/internal/vor1crs-set", 1); -var vor2FreqSet = props.globals.getNode("/FMGC/internal/vor2freq-set", 1); -var vor2CRSSet = props.globals.getNode("/FMGC/internal/vor2crs-set", 1); -var ils1FreqSet = props.globals.getNode("/FMGC/internal/ils1freq-set", 1); -var ils1CRSSet = props.globals.getNode("/FMGC/internal/ils1crs-set", 1); -var adf1FreqSet = props.globals.getNode("/FMGC/internal/adf1freq-set", 1); -var adf2FreqSet = props.globals.getNode("/FMGC/internal/adf2freq-set", 1); -var adf1Bfo = props.globals.getNode("/systems/radio/rmp[0]/bfo-active", 1); -var adf2Bfo = props.globals.getNode("/systems/radio/rmp[1]/bfo-active", 1); -var ils1CRS = props.globals.getNode("/instrumentation/nav[0]/radials/selected-deg", 1); -var vor1CRS = props.globals.getNode("/instrumentation/nav[2]/radials/selected-deg", 1); -var vor2CRS = props.globals.getNode("/instrumentation/nav[3]/radials/selected-deg", 1); - # INT-A var ADIRSMCDUBTN = props.globals.getNode("/controls/adirs/mcducbtn", 1); @@ -2607,22 +2587,22 @@ var canvas_MCDU_base = { pageSwitch[i].setBoolValue(1); } - if (vor1FreqSet.getValue() == 1) { + if (fmgc.FMGCInternal.VOR1.freqSet) { me["Simple_L1"].setFontSize(normal); } else { me["Simple_L1"].setFontSize(small); } - if (vor1CRSSet.getValue() == 1) { + if (fmgc.FMGCInternal.VOR1.crsSet) { me["Simple_L2"].setFontSize(normal); } else { me["Simple_L2"].setFontSize(small); } - if (ils1FreqSet.getValue() == 1) { + if (fmgc.FMGCInternal.ILS.freqSet) { me["Simple_L3"].setFontSize(normal); } else { me["Simple_L3"].setFontSize(small); } - if (ils1CRSSet.getValue() == 1) { + if (fmgc.FMGCInternal.ILS.crsSet) { me["Simple_L4"].setFontSize(normal); } else { me["Simple_L4"].setFontSize(small); @@ -2631,13 +2611,13 @@ var canvas_MCDU_base = { me["Simple_L6"].setText(" ADF1 BFO"); me["Simple_R6"].setText("ADF2 BFO "); - if (adf1FreqSet.getValue() == 1) { + if (fmgc.FMGCInternal.ADF1.freqSet) { me["Simple_L5"].setFont(default); me["Simple_L5"].setFontSize(normal); - me["Simple_L5"].setText(sprintf(" %s", adf1.getValue())); + me["Simple_L5"].setText(sprintf(" %s", fmgc.FMGCInternal.ADF1.mcdu)); me["Simple_L6"].show(); - if (adf1Bfo.getValue()) { + if (rmp.BFOActive[0].getValue()) { # TODO - wrong arrow me["Simple_L6_Arrow"].hide(); } else { @@ -2651,24 +2631,24 @@ var canvas_MCDU_base = { me["Simple_L6_Arrow"].hide(); } - if (vor2FreqSet.getValue() == 1) { + if (fmgc.FMGCInternal.VOR2.freqSet) { me["Simple_R1"].setFontSize(normal); } else { me["Simple_R1"].setFontSize(small); } - if (vor2CRSSet.getValue() == 1) { + if (fmgc.FMGCInternal.VOR2.crsSet) { me["Simple_R2"].setFontSize(normal); } else { me["Simple_R2"].setFontSize(small); } - if (adf2FreqSet.getValue() == 1) { + if (fmgc.FMGCInternal.ADF2.freqSet) { me["Simple_R5"].setFont(default); me["Simple_R5"].setFontSize(normal); - me["Simple_R5"].setText(sprintf("%s ", adf2.getValue())); + me["Simple_R5"].setText(sprintf("%s ", fmgc.FMGCInternal.ADF2.mcdu)); me["Simple_R6"].show(); - if (adf2Bfo.getValue()) { + if (rmp.BFOActive[1].getValue()) { # TODO - wrong arrow me["Simple_R6_Arrow"].hide(); } else { @@ -2682,22 +2662,22 @@ var canvas_MCDU_base = { me["Simple_R6_Arrow"].hide(); } - me["Simple_L1"].setText(" " ~ vor1.getValue()); - me["Simple_L2"].setText(sprintf("%03.0f", vor1CRS.getValue())); - me["Simple_L3"].setText(" " ~ ils1.getValue()); - me["Simple_L4"].setText(sprintf("%03.0f", ils1CRS.getValue())); + me["Simple_L1"].setText(" " ~ fmgc.FMGCInternal.VOR1.mcdu); + me["Simple_L2"].setText(sprintf("%03.0f", pts.Instrumentation.Nav.Radials.selectedDeg[2].getValue())); + me["Simple_L3"].setText(" " ~ fmgc.FMGCInternal.ILS.mcdu); + me["Simple_L4"].setText(sprintf("%03.0f", pts.Instrumentation.Nav.Radials.selectedDeg[0].getValue())); me["Simple_L1S"].setText("VOR1/FREQ"); me["Simple_L2S"].setText("CRS"); me["Simple_L3S"].setText("ILS /FREQ"); me["Simple_L4S"].setText("CRS"); me["Simple_L5S"].setText("ADF1/FREQ"); - me["Simple_R1"].setText(" " ~ vor2.getValue()); - me["Simple_R2"].setText(sprintf("%03.0f", vor2CRS.getValue())); + me["Simple_R1"].setText(" " ~ fmgc.FMGCInternal.VOR2.mcdu); + me["Simple_R2"].setText(sprintf("%03.0f", pts.Instrumentation.Nav.Radials.selectedDeg[3].getValue())); me["Simple_R1S"].setText("FREQ/VOR2"); me["Simple_R2S"].setText("CRS"); me["Simple_R5S"].setText("FREQ/ADF2"); - if (getprop("systems/radio/rmp[0]/nav") or getprop("systems/radio/rmp[1]/nav")) { + if (rmp.rmpNav[0].getValue() or rmp.rmpNav[1].getValue()) { me["Simple_L1"].hide(); me["Simple_L2"].hide(); me["Simple_L3"].hide(); diff --git a/Models/Instruments/ND/canvas/framework/navdisplay.nas b/Models/Instruments/ND/canvas/framework/navdisplay.nas index 2693461b..4220dcf8 100644 --- a/Models/Instruments/ND/canvas/framework/navdisplay.nas +++ b/Models/Instruments/ND/canvas/framework/navdisplay.nas @@ -593,7 +593,7 @@ canvas.NavDisplay.update = func() # FIXME: This stuff is still too aircraft spec me.symbols.dmeR.setColor(0,0.6,0.85); if((var navident=getprop("/instrumentation/adf[1]/ident")) != "") me.symbols.vorRId.setText(navident); - else me.symbols.vorRId.setText(sprintf("%3d",getprop("/instrumentation/adf[1]/frequencies/selected-khz"))); + else me.symbols.vorRId.setText(sprintf("%3d",pts.Instrumentation.Adf.Frequencies.selectedKhz[1].getValue())); me.symbols.vorRId.setColor(0,0.6,0.85); me.symbols.dmeRDist.setText(""); me.symbols.dmeRDist.setColor(0,0.6,0.85); diff --git a/Models/Instruments/ND/canvas/style.nas b/Models/Instruments/ND/canvas/style.nas index f34f8247..0d37513b 100644 --- a/Models/Instruments/ND/canvas/style.nas +++ b/Models/Instruments/ND/canvas/style.nas @@ -1387,9 +1387,9 @@ canvas.NDStyles["Airbus"] = { is_true: func(nd) { nd.symbols.vorCrsPtr.show(); if (is_ils) { - nd.symbols.vorCrsPtr.setRotation((getprop("/instrumentation/nav[0]/radials/selected-deg")-nd.aircraft_source.get_hdg_mag())*D2R); + nd.symbols.vorCrsPtr.setRotation((pts.Instrumentation.Nav.Radials.selectedDeg[0].getValue()-nd.aircraft_source.get_hdg_mag())*D2R); } else { - nd.symbols.vorCrsPtr.setRotation((getprop("/instrumentation/nav[2]/radials/selected-deg")-nd.aircraft_source.get_hdg_mag())*D2R); + nd.symbols.vorCrsPtr.setRotation((pts.Instrumentation.Nav.Radials.selectedDeg[2].getValue()-nd.aircraft_source.get_hdg_mag())*D2R); } }, @@ -1407,9 +1407,10 @@ canvas.NDStyles["Airbus"] = { var type = (is_ils ? "ils" : "vor"); var path = nd.get_nav_path(type, 0); if (is_ils) { - nd.symbols.vorCrsPtr2.setRotation((getprop("/instrumentation/nav[0]/radials/selected-deg")-nd.aircraft_source.get_hdg_mag())*D2R); + nd.symbols.vorCrsPtr2.setRotation((pts.Instrumentation.Nav.Radials.selectedDeg[0].getValue()-nd.aircraft_source.get_hdg_mag())*D2R); } else { - nd.symbols.vorCrsPtr2.setRotation((getprop("/instrumentation/nav[2]/radials/selected-deg")-nd.aircraft_source.get_hdg_mag())*D2R); + # TODO - 3? + nd.symbols.vorCrsPtr2.setRotation((pts.Instrumentation.Nav.Radials.selectedDeg[2].getValue()-nd.aircraft_source.get_hdg_mag())*D2R); } var line = nd.symbols.vorCrsPtr2.getElementById("vorCrsPtr2_line"); if(!is_ils){ @@ -1499,9 +1500,7 @@ canvas.NDStyles["Airbus"] = { }, is_true: func(nd) { nd.symbols.locTrkPointer.show(); - var crs = getprop("/instrumentation/nav/radials/selected-deg"); - var rotation = (crs - nd.aircraft_source.get_hdg_tru())*D2R; - nd.symbols.locTrkPointer.setRotation(rotation); + nd.symbols.locTrkPointer.setRotation( (pts.Instrumentation.Nav.Radials.selectedDeg[0].getValue() - nd.aircraft_source.get_hdg_tru()) * D2R); }, is_false: func(nd) nd.symbols.locTrkPointer.hide(), }, diff --git a/Models/Instruments/PFD/PFD.nas b/Models/Instruments/PFD/PFD.nas index 891c6225..7fb55d11 100644 --- a/Models/Instruments/PFD/PFD.nas +++ b/Models/Instruments/PFD/PFD.nas @@ -522,42 +522,6 @@ var canvas_pfd = { obj["GS_scale"].hide(); } }), - props.UpdateManager.FromHashList(["pfdILS1","pfdILS2","dmeInRange","dmeDistance","pfdILSMcdu"], nil, func(val) { - if ((obj.number == 0 and val.pfdILS1) or (obj.number == 1 and val.pfdILS2)) { - obj.split_ils = split("/", val.pfdILSMcdu); - if (size(obj.split_ils) < 2) { - obj["ils_freq"].setText(obj.split_ils[0]); - obj["ils_freq"].show(); - obj["ils_code"].hide(); - obj["dme_dist"].hide(); - obj["dme_dist_legend"].hide(); - } else { - obj["ils_code"].setText(obj.split_ils[0]); - obj["ils_freq"].setText(obj.split_ils[1]); - obj["ils_code"].show(); - obj["ils_freq"].show(); - - if (val.dmeInRange) { - obj["dme_dist"].show(); - obj["dme_dist_legend"].show(); - - if (val.dmeDistance < 20.0) { - obj["dme_dist"].setText(sprintf("%1.1f", val.dmeDistance)); - } else { - obj["dme_dist"].setText(sprintf("%2.0f", val.dmeDistance)); - } - } else { - obj["dme_dist"].hide(); - obj["dme_dist_legend"].hide(); - } - } - } else { - obj["ils_code"].hide(); - obj["ils_freq"].hide(); - obj["dme_dist"].hide(); - obj["dme_dist_legend"].hide(); - } - }), props.UpdateManager.FromHashList(["hasLocalizer","hasGlideslope","signalQuality","localizerInRange","glideslopeInRange","pfdILS1","pfdILS2"], nil, func(val) { if (((obj.number == 0 and val.pfdILS1) or (obj.number == 1 and val.pfdILS2)) and val.localizerInRange and val.hasLocalizer and val.signalQuality > 0.99) { obj["LOC_pointer"].show(); @@ -747,50 +711,6 @@ var canvas_pfd = { obj["HDG_target"].hide(); } }), - props.UpdateManager.FromHashList(["pfdILSMcdu","headingPFD","pfdILS1","pfdILS2","ilsCrs"], nil, func(val) { - obj.split_ils = split("/", val.pfdILSMcdu); - - if (((obj.number == 0 and val.pfdILS1) or (obj.number == 1 and val.pfdILS2)) and size(obj.split_ils) == 2) { - obj.magnetic_hdg = val.ilsCrs; - obj.magnetic_hdg_dif = geo.normdeg180(obj.magnetic_hdg - val.headingPFD); - if (obj.magnetic_hdg_dif >= -23.62 and obj.magnetic_hdg_dif <= 23.62) { - obj["CRS_pointer"].setTranslation((obj.magnetic_hdg_dif / 10) * 98.5416, 0); - obj["ILS_HDG_R"].hide(); - obj["ILS_HDG_L"].hide(); - obj["CRS_pointer"].show(); - } else if (obj.magnetic_hdg_dif < -23.62 and obj.magnetic_hdg_dif >= -180) { - if (int(obj.magnetic_hdg) < 10) { - obj["ILS_left"].setText(sprintf("00%1.0f", int(obj.magnetic_hdg))); - } else if (int(obj.magnetic_hdg) < 100) { - obj["ILS_left"].setText(sprintf("0%2.0f", int(obj.magnetic_hdg))); - } else { - obj["ILS_left"].setText(sprintf("%3.0f", int(obj.magnetic_hdg))); - } - obj["ILS_HDG_L"].show(); - obj["ILS_HDG_R"].hide(); - obj["CRS_pointer"].hide(); - } else if (obj.magnetic_hdg_dif > 23.62 and obj.magnetic_hdg_dif <= 180) { - if (int(obj.magnetic_hdg) < 10) { - obj["ILS_right"].setText(sprintf("00%1.0f", int(obj.magnetic_hdg))); - } else if (int(obj.magnetic_hdg) < 100) { - obj["ILS_right"].setText(sprintf("0%2.0f", int(obj.magnetic_hdg))); - } else { - obj["ILS_right"].setText(sprintf("%3.0f", int(obj.magnetic_hdg))); - } - obj["ILS_HDG_R"].show(); - obj["ILS_HDG_L"].hide(); - obj["CRS_pointer"].hide(); - } else { - obj["ILS_HDG_R"].hide(); - obj["ILS_HDG_L"].hide(); - obj["CRS_pointer"].hide(); - } - } else { - obj["ILS_HDG_R"].hide(); - obj["ILS_HDG_L"].hide(); - obj["CRS_pointer"].hide(); - } - }), props.UpdateManager.FromHashList(["altimeterHpa","altimeterInhg","altimeterInhgMode"], nil, func(val) { if (val.altimeterInhgMode == 0) { obj["QNH_setting"].setText(sprintf("%4.0f", val.altimeterHpa)); @@ -1746,6 +1666,82 @@ var canvas_pfd = { } } + me.split_ils = split("/", fmgc.FMGCInternal.ILS.mcdu); + if ((me.number == 0 and notification.pfdILS1) or (me.number == 1 and notification.pfdILS2)) { + if (size(me.split_ils) < 2) { + me["ils_freq"].setText(me.split_ils[0]); + me["ils_freq"].show(); + me["ils_code"].hide(); + me["dme_dist"].hide(); + me["dme_dist_legend"].hide(); + } else { + me["ils_code"].setText(me.split_ils[0]); + me["ils_freq"].setText(me.split_ils[1]); + me["ils_code"].show(); + me["ils_freq"].show(); + + if (notification.dmeInRange) { + me["dme_dist"].show(); + me["dme_dist_legend"].show(); + + if (notification.dmeDistance < 20.0) { + me["dme_dist"].setText(sprintf("%1.1f", notification.dmeDistance)); + } else { + me["dme_dist"].setText(sprintf("%2.0f", notification.dmeDistance)); + } + } else { + me["dme_dist"].hide(); + me["dme_dist_legend"].hide(); + } + } + } else { + me["ils_code"].hide(); + me["ils_freq"].hide(); + me["dme_dist"].hide(); + me["dme_dist_legend"].hide(); + } + + if (((me.number == 0 and notification.pfdILS1) or (me.number == 1 and notification.pfdILS2)) and size(me.split_ils) == 2) { + me.magnetic_hdg = notification.ilsCrs; + me.magnetic_hdg_dif = geo.normdeg180(me.magnetic_hdg - notification.headingPFD); + if (me.magnetic_hdg_dif >= -23.62 and me.magnetic_hdg_dif <= 23.62) { + me["CRS_pointer"].setTranslation((me.magnetic_hdg_dif / 10) * 98.5416, 0); + me["ILS_HDG_R"].hide(); + me["ILS_HDG_L"].hide(); + me["CRS_pointer"].show(); + } else if (me.magnetic_hdg_dif < -23.62 and me.magnetic_hdg_dif >= -180) { + if (int(me.magnetic_hdg) < 10) { + me["ILS_left"].setText(sprintf("00%1.0f", int(me.magnetic_hdg))); + } else if (int(me.magnetic_hdg) < 100) { + me["ILS_left"].setText(sprintf("0%2.0f", int(me.magnetic_hdg))); + } else { + me["ILS_left"].setText(sprintf("%3.0f", int(me.magnetic_hdg))); + } + me["ILS_HDG_L"].show(); + me["ILS_HDG_R"].hide(); + me["CRS_pointer"].hide(); + } else if (me.magnetic_hdg_dif > 23.62 and me.magnetic_hdg_dif <= 180) { + if (int(me.magnetic_hdg) < 10) { + me["ILS_right"].setText(sprintf("00%1.0f", int(me.magnetic_hdg))); + } else if (int(me.magnetic_hdg) < 100) { + me["ILS_right"].setText(sprintf("0%2.0f", int(me.magnetic_hdg))); + } else { + me["ILS_right"].setText(sprintf("%3.0f", int(me.magnetic_hdg))); + } + me["ILS_HDG_R"].show(); + me["ILS_HDG_L"].hide(); + me["CRS_pointer"].hide(); + } else { + me["ILS_HDG_R"].hide(); + me["ILS_HDG_L"].hide(); + me["CRS_pointer"].hide(); + } + } else { + me["ILS_HDG_R"].hide(); + me["ILS_HDG_L"].hide(); + me["CRS_pointer"].hide(); + } + foreach(var update_item; me.update_items) { update_item.update(notification); @@ -2005,7 +2001,6 @@ var input = { pfdILS1: "/modes/pfd/ILS1", pfdILS2: "/modes/pfd/ILS2", - pfdILSMcdu: "/FMGC/internal/ils1-mcdu", markerO: "/instrumentation/marker-beacon/outer", markerM: "/instrumentation/marker-beacon/middle", diff --git a/Nasal/FMGC/FMGC.nas b/Nasal/FMGC/FMGC.nas index 36625aa0..f23d9af3 100644 --- a/Nasal/FMGC/FMGC.nas +++ b/Nasal/FMGC/FMGC.nas @@ -32,24 +32,6 @@ var alt = 0; var altitude = 0; var flap = 0; var flaps = 0; -var freqnav0uf = 0; -var freqnav0 = 0; -var namenav0 = "XX"; -var freqnav1uf = 0; -var freqnav1 = 0; -var namenav1 = "XX"; -var freqnav2uf = 0; -var freqnav2 = 0; -var namenav2 = "XX"; -var freqnav3uf = 0; -var freqnav3 = 0; -var namenav3 = "XX"; -var freqadf0uf = 0; -var freqadf0 = 0; -var nameadf0 = "XX"; -var freqadf1uf = 0; -var freqadf1 = 0; -var nameadf1 = "XX"; var ias = 0; var mach = 0; var ktsmach = 0; @@ -66,18 +48,12 @@ var windSpeed = 0; var windsDidChange = 0; var tempOverspeed = nil; -setprop("position/gear-agl-ft", 0); +setprop("/position/gear-agl-ft", 0); setprop("/it-autoflight/settings/accel-agl-ft", 1500); #eventually set to 1500 above runway setprop("/it-autoflight/internal/vert-speed-fpm", 0); setprop("/it-autoflight/output/fma-pwr", 0); setprop("/instrumentation/nav[0]/nav-id", "XXX"); setprop("/instrumentation/nav[1]/nav-id", "XXX"); -setprop("/FMGC/internal/ils1-mcdu", "XXX/999.99"); -setprop("/FMGC/internal/ils2-mcdu", "XXX/999.99"); -setprop("/FMGC/internal/vor1-mcdu", "XXX/999.99"); -setprop("/FMGC/internal/vor2-mcdu", "999.99/XXX"); -setprop("/FMGC/internal/adf1-mcdu", "XXX/999.99"); -setprop("/FMGC/internal/adf2-mcdu", "999.99/XXX"); var FMGCAlignDone = [props.globals.initNode("/FMGC/internal/align1-done", 0, "BOOL"), props.globals.initNode("/FMGC/internal/align2-done", 0, "BOOL"), props.globals.initNode("/FMGC/internal/align3-done", 0, "BOOL")]; var FMGCAlignTime = [props.globals.initNode("/FMGC/internal/align1-time", 0, "DOUBLE"), props.globals.initNode("/FMGC/internal/align2-time", 0, "DOUBLE"), props.globals.initNode("/FMGC/internal/align3-time", 0, "DOUBLE")]; @@ -245,6 +221,32 @@ var FMGCInternal = { mngKtsMach: 0, mngSpd: 0, mngSpdCmd: 0, + + # RADNAV + ADF1: { + freqSet: 0, + mcdu: "XXX/999.99" + }, + ADF2: { + freqSet: 0, + mcdu: "999.99/XXX" + }, + ILS: { + crsSet: 0, + freqCalculated: 0, + freqSet: 0, + mcdu: "XXX/999.99" + }, + VOR1: { + crsSet: 0, + freqSet: 0, + mcdu: "XXX/999.99" + }, + VOR2: { + crsSet: 0, + freqSet: 0, + mcdu: "999.99/XXX" + }, }; var postInit = func() { @@ -523,78 +525,53 @@ var updateFuel = func { ############################ # Flight Phase and Various # ############################ - +var freqnav0 = nil; var nav0 = func { - var freqnav0uf = getprop("/instrumentation/nav[0]/frequencies/selected-mhz"); - var freqnav0 = sprintf("%.2f", freqnav0uf); - var namenav0 = getprop("/instrumentation/nav[0]/nav-id") or ""; + freqnav0 = sprintf("%.2f", pts.Instrumentation.Nav.Frequencies.selectedMhz[0].getValue()); if (freqnav0 >= 108.10 and freqnav0 <= 111.95) { - if (namenav0 != "") { - setprop("/FMGC/internal/ils1-mcdu", namenav0 ~ "/" ~ freqnav0); - } else { - setprop("/FMGC/internal/ils1-mcdu", freqnav0); - } - } -} - -var nav1 = func { - var freqnav1uf = getprop("/instrumentation/nav[1]/frequencies/selected-mhz"); - var freqnav1 = sprintf("%.2f", freqnav1uf); - var namenav1 = getprop("/instrumentation/nav[1]/nav-id") or ""; - if (freqnav1 >= 108.10 and freqnav1 <= 111.95) { - if (namenav1 != "") { - setprop("/FMGC/internal/ils2-mcdu", freqnav1 ~ "/" ~ namenav1); - } else { - setprop("/FMGC/internal/ils2-mcdu", freqnav1); - } + var namenav0 = getprop("/instrumentation/nav[0]/nav-id") or " "; + fmgc.FMGCInternal.ILS.mcdu = namenav0 ~ "/" ~ freqnav0; } } +var freqnav2 = nil; var nav2 = func { - var freqnav2uf = getprop("/instrumentation/nav[2]/frequencies/selected-mhz"); - var freqnav2 = sprintf("%.2f", freqnav2uf); - var namenav2 = getprop("/instrumentation/nav[2]/nav-id") or ""; + freqnav2 = sprintf("%.2f", pts.Instrumentation.Nav.Frequencies.selectedMhz[2].getValue()); if (freqnav2 >= 108.00 and freqnav2 <= 117.95) { - if (namenav2 != "") { - setprop("/FMGC/internal/vor1-mcdu", namenav2 ~ "/" ~ freqnav2); - } else { - setprop("/FMGC/internal/vor1-mcdu", freqnav2); - } + var namenav2 = getprop("/instrumentation/nav[2]/nav-id") or " "; + fmgc.FMGCInternal.VOR1.mcdu = namenav2 ~ "/" ~ freqnav2; } } +var freqnav3 = nil; var nav3 = func { - var freqnav3uf = getprop("/instrumentation/nav[3]/frequencies/selected-mhz"); - var freqnav3 = sprintf("%.2f", freqnav3uf); - var namenav3 = getprop("/instrumentation/nav[3]/nav-id") or ""; + freqnav3 = sprintf("%.2f", pts.Instrumentation.Nav.Frequencies.selectedMhz[3].getValue()); if (freqnav3 >= 108.00 and freqnav3 <= 117.95) { - if (namenav3 != "") { - setprop("/FMGC/internal/vor2-mcdu", freqnav3 ~ "/" ~ namenav3); - } else { - setprop("/FMGC/internal/vor2-mcdu", freqnav3); - } + var namenav3 = getprop("/instrumentation/nav[3]/nav-id") or " "; + fmgc.FMGCInternal.VOR2.mcdu = freqnav3 ~ "/" ~ namenav3; } } +var freqadf0 = nil; var adf0 = func { - var freqadf0 = sprintf("%.1f", pts.Instrumentation.Adf.Frequencies.selectedKhz[0].getValue()); + freqadf0 = sprintf("%.1f", pts.Instrumentation.Adf.Frequencies.selectedKhz[0].getValue()); if (freqadf0 >= 190 and freqadf0 <= 1799) { var nameadf0 = pts.Instrumentation.Adf.ident[0].getValue() or " "; - setprop("/FMGC/internal/adf1-mcdu", nameadf0 ~ "/" ~ freqadf0); + fmgc.FMGCInternal.ADF1.mcdu = nameadf0 ~ "/" ~ freqadf0; } } +var freqadf1 = nil; var adf1 = func { - var freqadf1 = sprintf("%.1f", pts.Instrumentation.Adf.Frequencies.selectedKhz[1].getValue()); + freqadf1 = sprintf("%.1f", pts.Instrumentation.Adf.Frequencies.selectedKhz[1].getValue()); if (freqadf1 >= 190 and freqadf1 <= 1799) { var nameadf1 = pts.Instrumentation.Adf.ident[1].getValue() or " "; - setprop("/FMGC/internal/adf2-mcdu", freqadf1 ~ "/" ~ nameadf1); + fmgc.FMGCInternal.ADF2.mcdu = freqadf1 ~ "/" ~ nameadf1; } } var radios = maketimer(1, func() { nav0(); - nav1(); nav2(); nav3(); adf0(); @@ -952,28 +929,28 @@ var updateAirportRadios = func { setprop("/FMGC/internal/ldg-elev", airport.elevation * M2FT); # eventually should be runway elevation magnetic_hdg = geo.normdeg(destination_rwy.heading - getprop("/environment/magnetic-variation-deg")); runway_ils = destination_rwy.ils_frequency_mhz; - if (runway_ils != nil and !getprop("/FMGC/internal/ils1freq-set") and !getprop("/FMGC/internal/ils1crs-set")) { - setprop("/FMGC/internal/ils1freq-calculated", runway_ils); - setprop("/instrumentation/nav[0]/frequencies/selected-mhz", runway_ils); - setprop("/instrumentation/nav[0]/radials/selected-deg", magnetic_hdg); - } elsif (runway_ils != nil and !getprop("/FMGC/internal/ils1freq-set")) { - setprop("/FMGC/internal/ils1freq-calculated", runway_ils); - setprop("/instrumentation/nav[0]/frequencies/selected-mhz", runway_ils); - } elsif (!getprop("/FMGC/internal/ils1crs-set")) { - setprop("/instrumentation/nav[0]/radials/selected-deg", magnetic_hdg); + if (runway_ils != nil and !fmgc.FMGCInternal.ILS.freqSet and !fmgc.FMGCInternal.ILS.crsSet) { + fmgc.FMGCInternal.ILS.freqCalculated = runway_ils; + pts.Instrumentation.Nav.Frequencies.selectedMhz[0].setValue(runway_ils); + pts.Instrumentation.Nav.Radials.selectedDeg[0].setValue(magnetic_hdg); + } elsif (runway_ils != nil and !fmgc.FMGCInternal.ILS.freqSet) { + fmgc.FMGCInternal.ILS.freqCalculated = runway_ils; + pts.Instrumentation.Nav.Frequencies.selectedMhz[0].setValue(runway_ils); + } elsif (!fmgc.FMGCInternal.ILS.crsSet) { + pts.Instrumentation.Nav.Radials.selectedDeg[0].setValue(magnetic_hdg); } } elsif (airportRadiosPhase <= 1 and departure_rwy != nil) { magnetic_hdg = geo.normdeg(departure_rwy.heading - getprop("/environment/magnetic-variation-deg")); runway_ils = departure_rwy.ils_frequency_mhz; - if (runway_ils != nil and !getprop("/FMGC/internal/ils1freq-set") and !getprop("/FMGC/internal/ils1crs-set")) { - setprop("/FMGC/internal/ils1freq-calculated", runway_ils); - setprop("/instrumentation/nav[0]/frequencies/selected-mhz", runway_ils); - setprop("/instrumentation/nav[0]/radials/selected-deg", magnetic_hdg); - } elsif (runway_ils != nil and !getprop("/FMGC/internal/ils1freq-set")) { - setprop("/FMGC/internal/ils1freq-calculated", runway_ils); - setprop("/instrumentation/nav[0]/frequencies/selected-mhz", runway_ils); - } elsif (!getprop("/FMGC/internal/ils1crs-set")) { - setprop("/instrumentation/nav[0]/radials/selected-deg", magnetic_hdg); + if (runway_ils != nil and !fmgc.FMGCInternal.ILS.freqSet and !fmgc.FMGCInternal.ILS.crsSet) { + fmgc.FMGCInternal.ILS.freqCalculated = runway_ils; + pts.Instrumentation.Nav.Frequencies.selectedMhz[0].setValue(runway_ils); + pts.Instrumentation.Nav.Radials.selectedDeg[0].setValue(magnetic_hdg); + } elsif (runway_ils != nil and !fmgc.FMGCInternal.ILS.freqSet) { + fmgc.FMGCInternal.ILS.freqCalculated = runway_ils; + pts.Instrumentation.Nav.Frequencies.selectedMhz[0].setValue(runway_ils); + } elsif (!fmgc.FMGCInternal.ILS.crsSet) { + pts.Instrumentation.Nav.Radials.selectedDeg[0].setValue(magnetic_hdg); } } @@ -1238,6 +1215,7 @@ setlistener("/FMGC/internal/fuel-calculating", func() { var timer30secLanding = maketimer(1, func() { if (pts.Sim.Time.elapsedSec.getValue() > getprop("/FMGC/internal/landing-time") + 30) { FMGCInternal.phase = 7; + if (FMGCInternal.costIndexSet) { setprop("/FMGC/internal/last-cost-index", FMGCInternal.costIndex); } else { diff --git a/Nasal/Libraries/property-tree-setup.nas b/Nasal/Libraries/property-tree-setup.nas index ba94fe6a..b88890eb 100644 --- a/Nasal/Libraries/property-tree-setup.nas +++ b/Nasal/Libraries/property-tree-setup.nas @@ -211,6 +211,12 @@ var Instrumentation = { }, }, Nav: { + Frequencies: { + selectedMhz: [props.globals.getNode("/instrumentation/nav[0]/frequencies/selected-mhz"), props.globals.getNode("/instrumentation/nav[1]/frequencies/selected-mhz"), props.globals.getNode("/instrumentation/nav[2]/frequencies/selected-mhz"), props.globals.getNode("/instrumentation/nav[3]/frequencies/selected-mhz")], + }, + Radials: { + selectedDeg: [props.globals.getNode("/instrumentation/nav[0]/radials/selected-deg"), props.globals.getNode("/instrumentation/nav[1]/radials/selected-deg"), props.globals.getNode("/instrumentation/nav[2]/radials/selected-deg"), props.globals.getNode("/instrumentation/nav[3]/radials/selected-deg")], + }, gsDeflection: props.globals.getNode("/instrumentation/nav[0]/gs-needle-deflection-norm"), locDeflection: props.globals.getNode("/instrumentation/nav[0]/heading-needle-deflection-norm"), }, diff --git a/Nasal/MCDU/MCDU.nas b/Nasal/MCDU/MCDU.nas index 5f9253a6..8511ce8c 100644 --- a/Nasal/MCDU/MCDU.nas +++ b/Nasal/MCDU/MCDU.nas @@ -45,15 +45,15 @@ var MCDU_reset = func(i) { setprop("/FMGC/print/mcdu/page2/R4req", 0); #RADNAV - setprop("/FMGC/internal/ils1freq-set", 0); - setprop("/FMGC/internal/ils1crs-set", 0); - setprop("/FMGC/internal/ils1freq-calculated", 0); - setprop("/FMGC/internal/vor1freq-set", 0); - setprop("/FMGC/internal/vor1crs-set", 0); - setprop("/FMGC/internal/vor2freq-set", 0); - setprop("/FMGC/internal/vor2crs-set", 0); - setprop("/FMGC/internal/adf1freq-set", 0); - setprop("/FMGC/internal/adf2freq-set", 0); + fmgc.FMGCInternal.ILS.freqSet = 0; + fmgc.FMGCInternal.ILS.freqCalculated = 0; + fmgc.FMGCInternal.ILS.crsSet = 0; + fmgc.FMGCInternal.VOR1.freqSet = 0; + fmgc.FMGCInternal.VOR1.crsSet = 0; + fmgc.FMGCInternal.VOR2.freqSet = 0; + fmgc.FMGCInternal.VOR2.crsSet = 0; + fmgc.FMGCInternal.ADF1.freqSet = 0; + fmgc.FMGCInternal.ADF2.freqSet = 0; # INT-A fmgc.FMGCInternal.altAirport = ""; diff --git a/Nasal/MCDU/RADNAV.nas b/Nasal/MCDU/RADNAV.nas index 0eb72249..f772799c 100644 --- a/Nasal/MCDU/RADNAV.nas +++ b/Nasal/MCDU/RADNAV.nas @@ -1,31 +1,33 @@ # A3XX mCDU by Joshua Davidson (Octal450), Jonathan Redpath, and Matthew Maring (mattmaring) - # Copyright (c) 2020 Josh Davidson (Octal450) +var radNavScratchpad = nil; +var radNavScratchpadSize = nil; + var radnavInput = func(key, i) { - var scratchpad = mcdu_scratchpad.scratchpads[i].scratchpad; - if (!getprop("/systems/radio/rmp[0]/nav") and !getprop("/systems/radio/rmp[1]/nav")) { + radNavScratchpad = mcdu_scratchpad.scratchpads[i].scratchpad; + radNavScratchpadSize = size(radNavScratchpad); + if (!rmp.rmpNav[0].getValue() and !rmp.rmpNav[1].getValue()) { if (key == "L1") { - if (scratchpad == "CLR") { - setprop("/FMGC/internal/vor1freq-set", 0); + if (radNavScratchpad == "CLR") { + fmgc.FMGCInternal.VOR1.freqSet = 0; mcdu_scratchpad.scratchpads[i].empty(); } else { - var tfs = size(scratchpad); - if (tfs == 3 or tfs == 5 or tfs == 6) { - if (scratchpad >= 108.00 and scratchpad <= 111.95) { - if (scratchpad == 108.10 or scratchpad == 108.15 or scratchpad == 108.30 or scratchpad == 108.35 or scratchpad == 108.50 or scratchpad == 108.55 or scratchpad == 108.70 or scratchpad == 108.75 or scratchpad == 108.90 or scratchpad == 108.95 - or scratchpad == 109.10 or scratchpad == 109.15 or scratchpad == 109.30 or scratchpad == 109.35 or scratchpad == 109.50 or scratchpad == 109.55 or scratchpad == 109.70 or scratchpad == 109.75 or scratchpad == 109.90 or scratchpad == 109.95 - or scratchpad == 110.10 or scratchpad == 110.15 or scratchpad == 110.30 or scratchpad == 110.35 or scratchpad == 110.50 or scratchpad == 110.55 or scratchpad == 110.70 or scratchpad == 110.75 or scratchpad == 110.90 or scratchpad == 110.95 - or scratchpad == 111.10 or scratchpad == 111.15 or scratchpad == 111.30 or scratchpad == 111.35 or scratchpad == 111.50 or scratchpad == 111.55 or scratchpad == 111.70 or scratchpad == 111.75 or scratchpad == 111.90 or scratchpad == 111.95) { + if (radNavScratchpadSize == 3 or radNavScratchpadSize == 5 or radNavScratchpadSize == 6) { + if (radNavScratchpad >= 108.00 and radNavScratchpad <= 111.95) { + if (radNavScratchpad == 108.10 or radNavScratchpad == 108.15 or radNavScratchpad == 108.30 or radNavScratchpad == 108.35 or radNavScratchpad == 108.50 or radNavScratchpad == 108.55 or radNavScratchpad == 108.70 or radNavScratchpad == 108.75 or radNavScratchpad == 108.90 or radNavScratchpad == 108.95 + or radNavScratchpad == 109.10 or radNavScratchpad == 109.15 or radNavScratchpad == 109.30 or radNavScratchpad == 109.35 or radNavScratchpad == 109.50 or radNavScratchpad == 109.55 or radNavScratchpad == 109.70 or radNavScratchpad == 109.75 or radNavScratchpad == 109.90 or radNavScratchpad == 109.95 + or radNavScratchpad == 110.10 or radNavScratchpad == 110.15 or radNavScratchpad == 110.30 or radNavScratchpad == 110.35 or radNavScratchpad == 110.50 or radNavScratchpad == 110.55 or radNavScratchpad == 110.70 or radNavScratchpad == 110.75 or radNavScratchpad == 110.90 or radNavScratchpad == 110.95 + or radNavScratchpad == 111.10 or radNavScratchpad == 111.15 or radNavScratchpad == 111.30 or radNavScratchpad == 111.35 or radNavScratchpad == 111.50 or radNavScratchpad == 111.55 or radNavScratchpad == 111.70 or radNavScratchpad == 111.75 or radNavScratchpad == 111.90 or radNavScratchpad == 111.95) { mcdu_message(i, "NOT ALLOWED"); } else { - setprop("instrumentation/nav[2]/frequencies/selected-mhz", scratchpad); - setprop("/FMGC/internal/vor1freq-set", 1); + pts.Instrumentation.Nav.Frequencies.selectedMhz[2].setValue(radNavScratchpad); + fmgc.FMGCInternal.VOR1.freqSet = 1; mcdu_scratchpad.scratchpads[i].empty(); } - } else if (scratchpad >= 112.00 and scratchpad <= 117.95) { - setprop("instrumentation/nav[2]/frequencies/selected-mhz", scratchpad); - setprop("/FMGC/internal/vor1freq-set", 1); + } else if (radNavScratchpad >= 112.00 and radNavScratchpad <= 117.95) { + pts.Instrumentation.Nav.Frequencies.selectedMhz[2].setValue(radNavScratchpad); + fmgc.FMGCInternal.VOR1.freqSet = 1; mcdu_scratchpad.scratchpads[i].empty(); } else { mcdu_message(i, "NOT ALLOWED"); @@ -35,15 +37,14 @@ var radnavInput = func(key, i) { } } } else if (key == "L2") { - if (scratchpad == "CLR") { - setprop("/FMGC/internal/vor1crs-set", 0); + if (radNavScratchpad == "CLR") { + fmgc.FMGCInternal.VOR1.crsSet = 0; mcdu_scratchpad.scratchpads[i].empty(); } else { - var tfs = size(scratchpad); - if (tfs >= 1 and tfs <= 3) { - if (scratchpad >= 0 and scratchpad <= 360) { - setprop("instrumentation/nav[2]/radials/selected-deg", scratchpad); - setprop("/FMGC/internal/vor1crs-set", 1); + if (radNavScratchpadSize >= 1 and radNavScratchpadSize <= 3) { + if (radNavScratchpad >= 0 and radNavScratchpad <= 360) { + pts.Instrumentation.Nav.Radials.selectedDeg[2].setValue(radNavScratchpad); + fmgc.FMGCInternal.VOR1.crsSet = 1; mcdu_scratchpad.scratchpads[i].empty(); } else { mcdu_message(i, "NOT ALLOWED"); @@ -53,21 +54,20 @@ var radnavInput = func(key, i) { } } } else if (key == "L3") { - if (scratchpad == "CLR") { - setprop("/FMGC/internal/ils1freq-set", 0); + if (radNavScratchpad == "CLR") { + fmgc.FMGCInternal.ILS.freqSet = 0; mcdu_scratchpad.scratchpads[i].empty(); } else { - var tfs = size(scratchpad); - if (tfs == 3 or tfs == 5 or tfs == 6) { - if (scratchpad >= 108.00 and scratchpad <= 111.95) { - if (scratchpad == 108.10 or scratchpad == 108.15 or scratchpad == 108.30 or scratchpad == 108.35 or scratchpad == 108.50 or scratchpad == 108.55 or scratchpad == 108.70 or scratchpad == 108.75 or scratchpad == 108.90 or scratchpad == 108.95 - or scratchpad == 109.10 or scratchpad == 109.15 or scratchpad == 109.30 or scratchpad == 109.35 or scratchpad == 109.50 or scratchpad == 109.55 or scratchpad == 109.70 or scratchpad == 109.75 or scratchpad == 109.90 or scratchpad == 109.95 - or scratchpad == 110.10 or scratchpad == 110.15 or scratchpad == 110.30 or scratchpad == 110.35 or scratchpad == 110.50 or scratchpad == 110.55 or scratchpad == 110.70 or scratchpad == 110.75 or scratchpad == 110.90 or scratchpad == 110.95 - or scratchpad == 111.10 or scratchpad == 111.15 or scratchpad == 111.30 or scratchpad == 111.35 or scratchpad == 111.50 or scratchpad == 111.55 or scratchpad == 111.70 or scratchpad == 111.75 or scratchpad == 111.90 or scratchpad == 111.95) { - setprop("instrumentation/nav[0]/frequencies/selected-mhz", scratchpad); - setprop("/FMGC/internal/ils1freq-set", 1); + if (radNavScratchpadSize == 3 or radNavScratchpadSize == 5 or radNavScratchpadSize == 6) { + if (radNavScratchpad >= 108.00 and radNavScratchpad <= 111.95) { + if (radNavScratchpad == 108.10 or radNavScratchpad == 108.15 or radNavScratchpad == 108.30 or radNavScratchpad == 108.35 or radNavScratchpad == 108.50 or radNavScratchpad == 108.55 or radNavScratchpad == 108.70 or radNavScratchpad == 108.75 or radNavScratchpad == 108.90 or radNavScratchpad == 108.95 + or radNavScratchpad == 109.10 or radNavScratchpad == 109.15 or radNavScratchpad == 109.30 or radNavScratchpad == 109.35 or radNavScratchpad == 109.50 or radNavScratchpad == 109.55 or radNavScratchpad == 109.70 or radNavScratchpad == 109.75 or radNavScratchpad == 109.90 or radNavScratchpad == 109.95 + or radNavScratchpad == 110.10 or radNavScratchpad == 110.15 or radNavScratchpad == 110.30 or radNavScratchpad == 110.35 or radNavScratchpad == 110.50 or radNavScratchpad == 110.55 or radNavScratchpad == 110.70 or radNavScratchpad == 110.75 or radNavScratchpad == 110.90 or radNavScratchpad == 110.95 + or radNavScratchpad == 111.10 or radNavScratchpad == 111.15 or radNavScratchpad == 111.30 or radNavScratchpad == 111.35 or radNavScratchpad == 111.50 or radNavScratchpad == 111.55 or radNavScratchpad == 111.70 or radNavScratchpad == 111.75 or radNavScratchpad == 111.90 or radNavScratchpad == 111.95) { + pts.Instrumentation.Nav.Frequencies.selectedMhz[0].setValue(radNavScratchpad); + fmgc.FMGCInternal.ILS.freqSet = 1; mcdu_scratchpad.scratchpads[i].empty(); - if (num(getprop("/FMGC/internal/ils1freq-calculated")) != 0 and num(getprop("/FMGC/internal/ils1freq-calculated")) != num(getprop("instrumentation/nav[0]/frequencies/selected-mhz"))) { + if (num(fmgc.FMGCInternal.ILS.freqCalculated) != 0 and num(fmgc.FMGCInternal.ILS.freqCalculated) != num(pts.Instrumentation.Nav.Frequencies.selectedMhz[0].getValue())) { mcdu_message(i, "RWY/LS MISMATCH"); } } else { @@ -81,15 +81,14 @@ var radnavInput = func(key, i) { } } } else if (key == "L4") { - if (scratchpad == "CLR") { - setprop("/FMGC/internal/ils1crs-set", 0); + if (radNavScratchpad == "CLR") { + fmgc.FMGCInternal.ILS.crsSet = 0; mcdu_scratchpad.scratchpads[i].empty(); } else { - var tfs = size(scratchpad); - if (tfs >= 1 and tfs <= 3) { - if (scratchpad >= 0 and scratchpad <= 360) { - setprop("instrumentation/nav[0]/radials/selected-deg", scratchpad); - setprop("/FMGC/internal/ils1crs-set", 1); + if (radNavScratchpadSize >= 1 and radNavScratchpadSize <= 3) { + if (radNavScratchpad >= 0 and radNavScratchpad <= 360) { + pts.Instrumentation.Nav.Radials.selectedDeg[0].setValue(radNavScratchpad); + fmgc.FMGCInternal.ILS.crsSet = 1; mcdu_scratchpad.scratchpads[i].empty(); } else { mcdu_message(i, "NOT ALLOWED"); @@ -99,25 +98,24 @@ var radnavInput = func(key, i) { } } } else if (key == "L5") { - if (scratchpad == "CLR") { - setprop("/FMGC/internal/adf1freq-set", 0); + if (radNavScratchpad == "CLR") { + fmgc.FMGCInternal.ADF1.freqSet = 0; mcdu_scratchpad.scratchpads[i].empty(); } else { - var tfs = size(scratchpad); - if (tfs >= 3 and tfs <= 6) { - if (scratchpad >= 190 and scratchpad <= 1799) { - if (scratchpad != int(scratchpad)) { - var splitScratchpad = split(".",scratchpad); - if (size(splitScratchpad) != 2 or splitScratchpad[1] != "5") { + if (radNavScratchpadSize >= 3 and radNavScratchpadSize <= 6) { + if (radNavScratchpad >= 190 and radNavScratchpad <= 1799) { + if (radNavScratchpad != int(radNavScratchpad)) { + var splitradNavScratchpad = split(".",radNavScratchpad); + if (size(splitradNavScratchpad) != 2 or splitradNavScratchpad[1] != "5") { mcdu_message(i, "NOT ALLOWED"); } else { - setprop("/instrumentation/adf[0]/frequencies/selected-khz", scratchpad); - setprop("/FMGC/internal/adf1freq-set", 1); + pts.Instrumentation.Adf.Frequencies.selectedKhz[0].setValue(radNavScratchpad); + fmgc.FMGCInternal.ADF1.freqSet = 1; mcdu_scratchpad.scratchpads[i].empty(); } } else { - setprop("/instrumentation/adf[0]/frequencies/selected-khz", scratchpad); - setprop("/FMGC/internal/adf1freq-set", 1); + pts.Instrumentation.Adf.Frequencies.selectedKhz[0].setValue(radNavScratchpad); + fmgc.FMGCInternal.ADF1.freqSet = 1; mcdu_scratchpad.scratchpads[i].empty(); } } else { @@ -128,14 +126,13 @@ var radnavInput = func(key, i) { } } } else if (key == "L6") { - if (getprop("/FMGC/internal/adf1freq-set")) { - if (scratchpad == "CLR" and getprop("/systems/radio/rmp[0]/bfo-active")) { - setprop("/systems/radio/rmp[0]/bfo-active", 0); + if (fmgc.FMGCInternal.ADF1.freqSet) { + if (radNavScratchpad == "CLR" and rmp.BFOActive[0].getValue()) { + rmp.BFOActive[0].setValue(0); mcdu_scratchpad.scratchpads[i].empty(); } else { - var tfs = size(scratchpad); - if (tfs == 0 and !getprop("/systems/radio/rmp[0]/bfo-active")) { - setprop("/systems/radio/rmp[0]/bfo-active", 1); + if (radNavScratchpadSize == 0 and !rmp.BFOActive[0].getValue()) { + rmp.BFOActive[0].setValue(1); } else { mcdu_message(i, "NOT ALLOWED"); } @@ -144,26 +141,25 @@ var radnavInput = func(key, i) { mcdu_message(i, "NOT ALLOWED"); } } else if (key == "R1") { - if (scratchpad == "CLR") { - setprop("/FMGC/internal/vor2freq-set", 0); + if (radNavScratchpad == "CLR") { + fmgc.FMGCInternal.VOR2.freqSet = 0; mcdu_scratchpad.scratchpads[i].empty(); } else { - var tfs = size(scratchpad); - if (tfs == 3 or tfs == 5 or tfs == 6) { - if (scratchpad >= 108.10 and scratchpad <= 111.95) { - if (scratchpad == 108.10 or scratchpad == 108.15 or scratchpad == 108.30 or scratchpad == 108.35 or scratchpad == 108.50 or scratchpad == 108.55 or scratchpad == 108.70 or scratchpad == 108.75 or scratchpad == 108.90 or scratchpad == 108.95 - or scratchpad == 109.10 or scratchpad == 109.15 or scratchpad == 109.30 or scratchpad == 109.35 or scratchpad == 109.50 or scratchpad == 109.55 or scratchpad == 109.70 or scratchpad == 109.75 or scratchpad == 109.90 or scratchpad == 109.95 - or scratchpad == 110.10 or scratchpad == 110.15 or scratchpad == 110.30 or scratchpad == 110.35 or scratchpad == 110.50 or scratchpad == 110.55 or scratchpad == 110.70 or scratchpad == 110.75 or scratchpad == 110.90 or scratchpad == 110.95 - or scratchpad == 111.10 or scratchpad == 111.15 or scratchpad == 111.30 or scratchpad == 111.35 or scratchpad == 111.50 or scratchpad == 111.55 or scratchpad == 111.70 or scratchpad == 111.75 or scratchpad == 111.90 or scratchpad == 111.95) { + if (radNavScratchpadSize == 3 or radNavScratchpadSize == 5 or radNavScratchpadSize == 6) { + if (radNavScratchpad >= 108.10 and radNavScratchpad <= 111.95) { + if (radNavScratchpad == 108.10 or radNavScratchpad == 108.15 or radNavScratchpad == 108.30 or radNavScratchpad == 108.35 or radNavScratchpad == 108.50 or radNavScratchpad == 108.55 or radNavScratchpad == 108.70 or radNavScratchpad == 108.75 or radNavScratchpad == 108.90 or radNavScratchpad == 108.95 + or radNavScratchpad == 109.10 or radNavScratchpad == 109.15 or radNavScratchpad == 109.30 or radNavScratchpad == 109.35 or radNavScratchpad == 109.50 or radNavScratchpad == 109.55 or radNavScratchpad == 109.70 or radNavScratchpad == 109.75 or radNavScratchpad == 109.90 or radNavScratchpad == 109.95 + or radNavScratchpad == 110.10 or radNavScratchpad == 110.15 or radNavScratchpad == 110.30 or radNavScratchpad == 110.35 or radNavScratchpad == 110.50 or radNavScratchpad == 110.55 or radNavScratchpad == 110.70 or radNavScratchpad == 110.75 or radNavScratchpad == 110.90 or radNavScratchpad == 110.95 + or radNavScratchpad == 111.10 or radNavScratchpad == 111.15 or radNavScratchpad == 111.30 or radNavScratchpad == 111.35 or radNavScratchpad == 111.50 or radNavScratchpad == 111.55 or radNavScratchpad == 111.70 or radNavScratchpad == 111.75 or radNavScratchpad == 111.90 or radNavScratchpad == 111.95) { mcdu_message(i, "NOT ALLOWED"); } else { - setprop("instrumentation/nav[3]/frequencies/selected-mhz", scratchpad); - setprop("/FMGC/internal/vor2freq-set", 1); + pts.Instrumentation.Nav.Frequencies.selectedMhz[3].setValue(radNavScratchpad); + fmgc.FMGCInternal.VOR2.freqSet = 1; mcdu_scratchpad.scratchpads[i].empty(); } - } else if (scratchpad >= 112.00 and scratchpad <= 117.95) { - setprop("instrumentation/nav[3]/frequencies/selected-mhz", scratchpad); - setprop("/FMGC/internal/vor2freq-set", 1); + } else if (radNavScratchpad >= 112.00 and radNavScratchpad <= 117.95) { + pts.Instrumentation.Nav.Frequencies.selectedMhz[3].setValue(radNavScratchpad); + fmgc.FMGCInternal.VOR2.freqSet = 1; mcdu_scratchpad.scratchpads[i].empty(); } else { mcdu_message(i, "NOT ALLOWED"); @@ -173,15 +169,14 @@ var radnavInput = func(key, i) { } } } else if (key == "R2") { - if (scratchpad == "CLR") { - setprop("/FMGC/internal/vor2crs-set", 0); + if (radNavScratchpad == "CLR") { + fmgc.FMGCInternal.VOR2.crsSet = 0; mcdu_scratchpad.scratchpads[i].empty(); } else { - var tfs = size(scratchpad); - if (tfs >= 1 and tfs <= 3) { - if (scratchpad >= 0 and scratchpad <= 360) { - setprop("instrumentation/nav[3]/radials/selected-deg", scratchpad); - setprop("/FMGC/internal/vor2crs-set", 1); + if (radNavScratchpadSize >= 1 and radNavScratchpadSize <= 3) { + if (radNavScratchpad >= 0 and radNavScratchpad <= 360) { + pts.Instrumentation.Nav.Radials.selectedDeg[3].setValue(radNavScratchpad); + fmgc.FMGCInternal.VOR2.crsSet = 1; mcdu_scratchpad.scratchpads[i].empty(); } else { mcdu_message(i, "NOT ALLOWED"); @@ -191,25 +186,24 @@ var radnavInput = func(key, i) { } } } else if (key == "R5") { - if (scratchpad == "CLR") { - setprop("/FMGC/internal/adf2freq-set", 0); + if (radNavScratchpad == "CLR") { + fmgc.FMGCInternal.ADF2.freqSet = 0; mcdu_scratchpad.scratchpads[i].empty(); } else { - var tfs = size(scratchpad); - if (tfs >= 3 and tfs <= 6) { - if (scratchpad >= 190 and scratchpad <= 1799) { - if (scratchpad != int(scratchpad)) { - var splitScratchpad = split(".",scratchpad); - if (size(splitScratchpad) != 2 or splitScratchpad[1] != "5") { + if (radNavScratchpadSize >= 3 and radNavScratchpadSize <= 6) { + if (radNavScratchpad >= 190 and radNavScratchpad <= 1799) { + if (radNavScratchpad != int(radNavScratchpad)) { + var splitradNavScratchpad = split(".",radNavScratchpad); + if (size(splitradNavScratchpad) != 2 or splitradNavScratchpad[1] != "5") { mcdu_message(i, "NOT ALLOWED"); } else { - setprop("/instrumentation/adf[1]/frequencies/selected-khz", scratchpad); - setprop("/FMGC/internal/adf2freq-set", 1); + pts.Instrumentation.Adf.Frequencies.selectedKhz[1].setValue(radNavScratchpad); + fmgc.FMGCInternal.ADF2.freqSet = 1; mcdu_scratchpad.scratchpads[i].empty(); } } else { - setprop("/instrumentation/adf[1]/frequencies/selected-khz", scratchpad); - setprop("/FMGC/internal/adf2freq-set", 1); + pts.Instrumentation.Adf.Frequencies.selectedKhz[1].setValue(radNavScratchpad); + fmgc.FMGCInternal.ADF2.freqSet = 1; mcdu_scratchpad.scratchpads[i].empty(); } } else { @@ -220,14 +214,13 @@ var radnavInput = func(key, i) { } } } else if (key == "R6") { - if (getprop("/FMGC/internal/adf2freq-set")) { - if (scratchpad == "CLR" and getprop("/systems/radio/rmp[1]/bfo-active")) { - setprop("/systems/radio/rmp[1]/bfo-active", 0); + if (fmgc.FMGCInternal.ADF2.freqSet) { + if (radNavScratchpad == "CLR" and rmp.BFOActive[1].getValue()) { + rmp.BFOActive[1].setValue(0); mcdu_scratchpad.scratchpads[i].empty(); } else { - var tfs = size(scratchpad); - if (tfs == 0 and !getprop("/systems/radio/rmp[1]/bfo-active")) { - setprop("/systems/radio/rmp[1]/bfo-active", 1); + if (radNavScratchpadSize == 0 and !rmp.BFOActive[1].getValue()) { + rmp.BFOActive[1].setValue(1); } else { mcdu_message(i, "NOT ALLOWED"); } diff --git a/Nasal/Panels/rmp.nas b/Nasal/Panels/rmp.nas index 29545a27..b24eb124 100644 --- a/Nasal/Panels/rmp.nas +++ b/Nasal/Panels/rmp.nas @@ -97,6 +97,7 @@ var sel_crs_rmp1 = props.globals.initNode("/systems/radio/rmp[0]/select-crs", 1, var sel_crs_rmp2 = props.globals.initNode("/systems/radio/rmp[1]/select-crs", 1, "BOOL"); var vhf3_data_mode = props.globals.initNode("/systems/radio/vhf3-data-mode", 1, "BOOL"); +var rmpNav = [props.globals.initNode("/systems/radio/rmp[0]/nav", 0, "BOOL"),props.globals.initNode("/systems/radio/rmp[1]/nav", 0, "BOOL")]; var init = func() { chan_rmp1.setValue("vhf1"); @@ -478,14 +479,14 @@ var change_nav_mode = func(rmp_nr, nav_mode) { if (rmp_nr == 2 and (chan_rmp2.getValue() == "vor" or chan_rmp2.getValue() == "ls" or chan_rmp2.getValue() == "adf")) { chan_rmp2.setValue("vhf2"); } - setprop("/FMGC/internal/ils1freq-set", 1); - setprop("/FMGC/internal/ils1crs-set", 1); - setprop("/FMGC/internal/vor1freq-set", 1); - setprop("/FMGC/internal/vor1crs-set", 1); - setprop("/FMGC/internal/vor2freq-set", 1); - setprop("/FMGC/internal/vor2crs-set", 1); - setprop("/FMGC/internal/adf1freq-set", 1); - setprop("/FMGC/internal/adf2freq-set", 1); + fmgc.FMGCInternal.ILS.freqSet = 1; + fmgc.FMGCInternal.ILS.crsSet = 1; + fmgc.FMGCInternal.VOR1.freqSet = 1; + fmgc.FMGCInternal.VOR1.crsSet = 1; + fmgc.FMGCInternal.VOR2.freqSet = 1; + fmgc.FMGCInternal.VOR2.crsSet = 1; + fmgc.FMGCInternal.ADF1.freqSet = 1; + fmgc.FMGCInternal.ADF2.freqSet = 1; } }