From 6f308038423f5eb8243ee24eb3b0c7635065fdb8 Mon Sep 17 00:00:00 2001 From: Joshua Davidson Date: Thu, 6 Jul 2017 11:37:43 -0400 Subject: [PATCH] A3XX: Make ADF Radios working MCDU, fix MCDU bug --- Models/Instruments/MCDU1/RADNAV/RADNAV.xml | 80 ++++++++ Models/Instruments/MCDU2/RADNAV/RADNAV.xml | 80 ++++++++ Nasal/FMGC.nas | 32 ++- Nasal/MCDU1/MCDU.nas | 7 + Nasal/MCDU1/RADNAV.nas | 54 ++++++ Nasal/MCDU2/MCDU.nas | 7 + Nasal/MCDU2/RADNAV.nas | 216 +++++++++++++-------- 7 files changed, 393 insertions(+), 83 deletions(-) diff --git a/Models/Instruments/MCDU1/RADNAV/RADNAV.xml b/Models/Instruments/MCDU1/RADNAV/RADNAV.xml index 3a6a0c2c..ca6128c8 100644 --- a/Models/Instruments/MCDU1/RADNAV/RADNAV.xml +++ b/Models/Instruments/MCDU1/RADNAV/RADNAV.xml @@ -714,6 +714,45 @@ 64 + + adf1freq3 + + -0.001 + -0.042 + 0.0285 + + left-center + yz-plane + text-value + %s + false + BoeingCDU-Large.ttf + /FMGC/internal/adf1-mcdu + true + false + false + 0.0050 + + 64 + 64 + + + + + select + adf1freq2 + + /FMGC/internal/adf1freq-set + + + + + select + adf1freq3 + + /FMGC/internal/adf1freq-set + + adf2freq @@ -761,6 +800,45 @@ 64 + + adf2freq3 + + -0.001 + 0.041 + 0.0285 + + right-center + yz-plane + text-value + %s + false + BoeingCDU-Large.ttf + /FMGC/internal/adf2-mcdu + true + false + false + 0.0050 + + 64 + 64 + + + + + select + adf2freq2 + + /FMGC/internal/adf2freq-set + + + + + select + adf2freq3 + + /FMGC/internal/adf2freq-set + + @@ -818,7 +896,9 @@ ilscrs13 mlscrs2 adf1freq2 + adf1freq3 adf2freq2 + adf2freq3 0 0.5 diff --git a/Models/Instruments/MCDU2/RADNAV/RADNAV.xml b/Models/Instruments/MCDU2/RADNAV/RADNAV.xml index 3a6a0c2c..ca6128c8 100644 --- a/Models/Instruments/MCDU2/RADNAV/RADNAV.xml +++ b/Models/Instruments/MCDU2/RADNAV/RADNAV.xml @@ -714,6 +714,45 @@ 64 + + adf1freq3 + + -0.001 + -0.042 + 0.0285 + + left-center + yz-plane + text-value + %s + false + BoeingCDU-Large.ttf + /FMGC/internal/adf1-mcdu + true + false + false + 0.0050 + + 64 + 64 + + + + + select + adf1freq2 + + /FMGC/internal/adf1freq-set + + + + + select + adf1freq3 + + /FMGC/internal/adf1freq-set + + adf2freq @@ -761,6 +800,45 @@ 64 + + adf2freq3 + + -0.001 + 0.041 + 0.0285 + + right-center + yz-plane + text-value + %s + false + BoeingCDU-Large.ttf + /FMGC/internal/adf2-mcdu + true + false + false + 0.0050 + + 64 + 64 + + + + + select + adf2freq2 + + /FMGC/internal/adf2freq-set + + + + + select + adf2freq3 + + /FMGC/internal/adf2freq-set + + @@ -818,7 +896,9 @@ ilscrs13 mlscrs2 adf1freq2 + adf1freq3 adf2freq2 + adf2freq3 0 0.5 diff --git a/Nasal/FMGC.nas b/Nasal/FMGC.nas index 4edda14a..adc8c6b8 100644 --- a/Nasal/FMGC.nas +++ b/Nasal/FMGC.nas @@ -233,6 +233,8 @@ var various2 = maketimer(0.5, func { nav1(); nav2(); nav3(); + adf0(); + adf1(); var latmode = getprop("/it-autoflight/output/lat"); if (latmode == 0) { setprop("/it-autoflight/custom/show-hdg", 1); @@ -258,7 +260,7 @@ var nav1 = func { var namenav1 = getprop("/instrumentation/nav[1]/nav-id"); if (freqnav1 >= 108.10 and freqnav1 <= 111.95) { if (namenav1 != "") { - setprop("/FMGC/internal/ils2-mcdu", namenav1 ~ "/" ~ freqnav1); + setprop("/FMGC/internal/ils2-mcdu", freqnav1 ~ "/" ~ namenav1); } else { setprop("/FMGC/internal/ils2-mcdu", freqnav1); } @@ -284,13 +286,39 @@ var nav3 = func { var namenav3 = getprop("/instrumentation/nav[3]/nav-id"); if (freqnav3 >= 108.00 and freqnav3 <= 117.95) { if (namenav3 != "") { - setprop("/FMGC/internal/vor2-mcdu", namenav3 ~ "/" ~ freqnav3); + setprop("/FMGC/internal/vor2-mcdu", freqnav3 ~ "/" ~ namenav3); } else { setprop("/FMGC/internal/vor2-mcdu", freqnav3); } } } +var adf0 = func { + var freqadf0uf = getprop("/instrumentation/adf[0]/frequencies/selected-khz"); + var freqadf0 = sprintf("%.2f", freqadf0uf); + var nameadf0 = getprop("/instrumentation/adf[0]/ident"); + if (freqadf0 >= 190 and freqadf0 <= 1750) { + if (nameadf0 != "") { + setprop("/FMGC/internal/adf1-mcdu", nameadf0 ~ "/" ~ freqadf0); + } else { + setprop("/FMGC/internal/adf1-mcdu", freqadf0); + } + } +} + +var adf1 = func { + var freqadf1uf = getprop("/instrumentation/adf[1]/frequencies/selected-khz"); + var freqadf1 = sprintf("%.2f", freqadf1uf); + var nameadf1 = getprop("/instrumentation/adf[1]/ident"); + if (freqadf1 >= 190 and freqadf1 <= 1750) { + if (nameadf1 != "") { + setprop("/FMGC/internal/adf2-mcdu", freqadf1 ~ "/" ~ nameadf1); + } else { + setprop("/FMGC/internal/adf2-mcdu", freqadf1); + } + } +} + ################# # Managed Speed # ################# diff --git a/Nasal/MCDU1/MCDU.nas b/Nasal/MCDU1/MCDU.nas index a433fc5c..f7fd6c9d 100644 --- a/Nasal/MCDU1/MCDU.nas +++ b/Nasal/MCDU1/MCDU.nas @@ -48,12 +48,15 @@ var MCDU_reset = func { 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); } var lskbutton = func(btn) { if (btn == "1") { if (getprop("/MCDU[0]/page") == "MCDU") { setprop("/MCDU[0]/page", getprop("/MCDU[0]/last-fmgc-page")); + setprop("/MCDU[0]/scratchpad-msg", "0"); setprop("/MCDU[0]/scratchpad", ""); } else if (getprop("/MCDU[0]/page") == "TO") { perfTOInput("L1"); @@ -125,6 +128,8 @@ var lskbutton = func(btn) { perfCRZInput("L5"); } else if (getprop("/MCDU[0]/page") == "DES") { perfDESInput("L5"); + } else if (getprop("/MCDU[0]/page") == "RADNAV") { + radnavInput("L5"); } else { if (getprop("/MCDU[0]/scratchpad") != "NOT ALLOWED") { setprop("/MCDU[0]/last-scratchpad", getprop("/MCDU[0]/scratchpad")); @@ -207,6 +212,8 @@ var rskbutton = func(btn) { } else if (btn == "5") { if (getprop("/MCDU[0]/page") == "TO") { perfTOInput("R5"); + } else if (getprop("/MCDU[0]/page") == "RADNAV") { + radnavInput("R5"); } else { if (getprop("/MCDU[0]/scratchpad") != "NOT ALLOWED") { setprop("/MCDU[0]/last-scratchpad", getprop("/MCDU[0]/scratchpad")); diff --git a/Nasal/MCDU1/RADNAV.nas b/Nasal/MCDU1/RADNAV.nas index 3a83f80e..f54970a2 100644 --- a/Nasal/MCDU1/RADNAV.nas +++ b/Nasal/MCDU1/RADNAV.nas @@ -138,6 +138,33 @@ var radnavInput = func(key) { setprop("/MCDU[0]/scratchpad", "NOT ALLOWED"); } } + } else if (key == "L5") { + if (scratchpad == "CLR") { + setprop("/FMGC/internal/adf1freq-set", 0); + setprop("/MCDU[0]/scratchpad-msg", "0"); + setprop("/MCDU[0]/scratchpad", ""); + } else { + var tfs = size(scratchpad); + if (tfs == 3 or tfs == 4) { + if (scratchpad >= 190 and scratchpad <= 1750) { + setprop("/instrumentation/adf[0]/frequencies/selected-khz", scratchpad); + setprop("/FMGC/internal/adf1freq-set", 1); + setprop("/MCDU[0]/scratchpad", ""); + } else { + if (getprop("/MCDU[0]/scratchpad") != "NOT ALLOWED") { + setprop("/MCDU[0]/last-scratchpad", getprop("/MCDU[0]/scratchpad")); + } + setprop("/MCDU[0]/scratchpad-msg", "1"); + setprop("/MCDU[0]/scratchpad", "NOT ALLOWED"); + } + } else { + if (getprop("/MCDU[0]/scratchpad") != "NOT ALLOWED") { + setprop("/MCDU[0]/last-scratchpad", getprop("/MCDU[0]/scratchpad")); + } + setprop("/MCDU[0]/scratchpad-msg", "1"); + setprop("/MCDU[0]/scratchpad", "NOT ALLOWED"); + } + } } else if (key == "R1") { if (scratchpad == "CLR") { setprop("/FMGC/internal/vor2freq-set", 0); @@ -207,5 +234,32 @@ var radnavInput = func(key) { setprop("/MCDU[0]/scratchpad", "NOT ALLOWED"); } } + } else if (key == "R5") { + if (scratchpad == "CLR") { + setprop("/FMGC/internal/adf2freq-set", 0); + setprop("/MCDU[0]/scratchpad-msg", "0"); + setprop("/MCDU[0]/scratchpad", ""); + } else { + var tfs = size(scratchpad); + if (tfs == 3 or tfs == 4) { + if (scratchpad >= 190 and scratchpad <= 1750) { + setprop("/instrumentation/adf[1]/frequencies/selected-khz", scratchpad); + setprop("/FMGC/internal/adf2freq-set", 1); + setprop("/MCDU[0]/scratchpad", ""); + } else { + if (getprop("/MCDU[0]/scratchpad") != "NOT ALLOWED") { + setprop("/MCDU[0]/last-scratchpad", getprop("/MCDU[0]/scratchpad")); + } + setprop("/MCDU[0]/scratchpad-msg", "1"); + setprop("/MCDU[0]/scratchpad", "NOT ALLOWED"); + } + } else { + if (getprop("/MCDU[0]/scratchpad") != "NOT ALLOWED") { + setprop("/MCDU[0]/last-scratchpad", getprop("/MCDU[0]/scratchpad")); + } + setprop("/MCDU[0]/scratchpad-msg", "1"); + setprop("/MCDU[0]/scratchpad", "NOT ALLOWED"); + } + } } } diff --git a/Nasal/MCDU2/MCDU.nas b/Nasal/MCDU2/MCDU.nas index e245675e..3b787ecc 100644 --- a/Nasal/MCDU2/MCDU.nas +++ b/Nasal/MCDU2/MCDU.nas @@ -48,12 +48,15 @@ var MCDU_reset = func { 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); } var lskbutton = func(btn) { if (btn == "1") { if (getprop("/MCDU[1]/page") == "MCDU") { setprop("/MCDU[1]/page", getprop("/MCDU[1]/last-fmgc-page")); + setprop("/MCDU[1]/scratchpad-msg", "0"); setprop("/MCDU[1]/scratchpad", ""); } else if (getprop("/MCDU[1]/page") == "TO") { perfTOInput("L1"); @@ -125,6 +128,8 @@ var lskbutton = func(btn) { perfCRZInput("L5"); } else if (getprop("/MCDU[1]/page") == "DES") { perfDESInput("L5"); + } else if (getprop("/MCDU[1]/page") == "RADNAV") { + radnavInput("L5"); } else { if (getprop("/MCDU[1]/scratchpad") != "NOT ALLOWED") { setprop("/MCDU[1]/last-scratchpad", getprop("/MCDU[1]/scratchpad")); @@ -207,6 +212,8 @@ var rskbutton = func(btn) { } else if (btn == "5") { if (getprop("/MCDU[1]/page") == "TO") { perfTOInput("R5"); + } else if (getprop("/MCDU[1]/page") == "RADNAV") { + radnavInput("R5"); } else { if (getprop("/MCDU[1]/scratchpad") != "NOT ALLOWED") { setprop("/MCDU[1]/last-scratchpad", getprop("/MCDU[1]/scratchpad")); diff --git a/Nasal/MCDU2/RADNAV.nas b/Nasal/MCDU2/RADNAV.nas index 569fbc14..f54970a2 100644 --- a/Nasal/MCDU2/RADNAV.nas +++ b/Nasal/MCDU2/RADNAV.nas @@ -3,12 +3,12 @@ ################################################################## var radnavInput = func(key) { - var scratchpad = getprop("/MCDU[1]/scratchpad"); + var scratchpad = getprop("/MCDU[0]/scratchpad"); if (key == "L1") { if (scratchpad == "CLR") { setprop("/FMGC/internal/vor1freq-set", 0); - setprop("/MCDU[1]/scratchpad-msg", "0"); - setprop("/MCDU[1]/scratchpad", ""); + setprop("/MCDU[0]/scratchpad-msg", "0"); + setprop("/MCDU[0]/scratchpad", ""); } else { var tfs = size(scratchpad); if (tfs == 3 or tfs == 5 or tfs == 6) { @@ -17,67 +17,67 @@ var radnavInput = func(key) { 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 (getprop("/MCDU[1]/scratchpad") != "NOT ALLOWED") { - setprop("/MCDU[1]/last-scratchpad", getprop("/MCDU[1]/scratchpad")); + if (getprop("/MCDU[0]/scratchpad") != "NOT ALLOWED") { + setprop("/MCDU[0]/last-scratchpad", getprop("/MCDU[0]/scratchpad")); } - setprop("/MCDU[1]/scratchpad-msg", "1"); - setprop("/MCDU[1]/scratchpad", "NOT ALLOWED"); + setprop("/MCDU[0]/scratchpad-msg", "1"); + setprop("/MCDU[0]/scratchpad", "NOT ALLOWED"); } else { setprop("/instrumentation/nav[2]/frequencies/selected-mhz", scratchpad); setprop("/FMGC/internal/vor1freq-set", 1); - setprop("/MCDU[1]/scratchpad", ""); + setprop("/MCDU[0]/scratchpad", ""); } } else if (scratchpad >= 112.00 and scratchpad <= 117.95) { setprop("/instrumentation/nav[2]/frequencies/selected-mhz", scratchpad); setprop("/FMGC/internal/vor1freq-set", 1); - setprop("/MCDU[1]/scratchpad", ""); + setprop("/MCDU[0]/scratchpad", ""); } else { - if (getprop("/MCDU[1]/scratchpad") != "NOT ALLOWED") { - setprop("/MCDU[1]/last-scratchpad", getprop("/MCDU[1]/scratchpad")); + if (getprop("/MCDU[0]/scratchpad") != "NOT ALLOWED") { + setprop("/MCDU[0]/last-scratchpad", getprop("/MCDU[0]/scratchpad")); } - setprop("/MCDU[1]/scratchpad-msg", "1"); - setprop("/MCDU[1]/scratchpad", "NOT ALLOWED"); + setprop("/MCDU[0]/scratchpad-msg", "1"); + setprop("/MCDU[0]/scratchpad", "NOT ALLOWED"); } } else { - if (getprop("/MCDU[1]/scratchpad") != "NOT ALLOWED") { - setprop("/MCDU[1]/last-scratchpad", getprop("/MCDU[1]/scratchpad")); + if (getprop("/MCDU[0]/scratchpad") != "NOT ALLOWED") { + setprop("/MCDU[0]/last-scratchpad", getprop("/MCDU[0]/scratchpad")); } - setprop("/MCDU[1]/scratchpad-msg", "1"); - setprop("/MCDU[1]/scratchpad", "NOT ALLOWED"); + setprop("/MCDU[0]/scratchpad-msg", "1"); + setprop("/MCDU[0]/scratchpad", "NOT ALLOWED"); } } } else if (key == "L2") { if (scratchpad == "CLR") { setprop("/FMGC/internal/vor1crs-set", 0); - setprop("/MCDU[1]/scratchpad-msg", "0"); - setprop("/MCDU[1]/scratchpad", ""); + setprop("/MCDU[0]/scratchpad-msg", "0"); + setprop("/MCDU[0]/scratchpad", ""); } 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); - setprop("/MCDU[1]/scratchpad", ""); + setprop("/MCDU[0]/scratchpad", ""); } else { - if (getprop("/MCDU[1]/scratchpad") != "NOT ALLOWED") { - setprop("/MCDU[1]/last-scratchpad", getprop("/MCDU[1]/scratchpad")); + if (getprop("/MCDU[0]/scratchpad") != "NOT ALLOWED") { + setprop("/MCDU[0]/last-scratchpad", getprop("/MCDU[0]/scratchpad")); } - setprop("/MCDU[1]/scratchpad-msg", "1"); - setprop("/MCDU[1]/scratchpad", "NOT ALLOWED"); + setprop("/MCDU[0]/scratchpad-msg", "1"); + setprop("/MCDU[0]/scratchpad", "NOT ALLOWED"); } } else { - if (getprop("/MCDU[1]/scratchpad") != "NOT ALLOWED") { - setprop("/MCDU[1]/last-scratchpad", getprop("/MCDU[1]/scratchpad")); + if (getprop("/MCDU[0]/scratchpad") != "NOT ALLOWED") { + setprop("/MCDU[0]/last-scratchpad", getprop("/MCDU[0]/scratchpad")); } - setprop("/MCDU[1]/scratchpad-msg", "1"); - setprop("/MCDU[1]/scratchpad", "NOT ALLOWED"); + setprop("/MCDU[0]/scratchpad-msg", "1"); + setprop("/MCDU[0]/scratchpad", "NOT ALLOWED"); } } } else if (key == "L3") { if (scratchpad == "CLR") { setprop("/FMGC/internal/ils1freq-set", 0); - setprop("/MCDU[1]/scratchpad-msg", "0"); - setprop("/MCDU[1]/scratchpad", ""); + setprop("/MCDU[0]/scratchpad-msg", "0"); + setprop("/MCDU[0]/scratchpad", ""); } else { var tfs = size(scratchpad); if (tfs == 3 or tfs == 5 or tfs == 6) { @@ -88,61 +88,88 @@ var radnavInput = func(key) { 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); - setprop("/MCDU[1]/scratchpad", ""); + setprop("/MCDU[0]/scratchpad", ""); } else { - if (getprop("/MCDU[1]/scratchpad") != "NOT ALLOWED") { - setprop("/MCDU[1]/last-scratchpad", getprop("/MCDU[1]/scratchpad")); + if (getprop("/MCDU[0]/scratchpad") != "NOT ALLOWED") { + setprop("/MCDU[0]/last-scratchpad", getprop("/MCDU[0]/scratchpad")); } - setprop("/MCDU[1]/scratchpad-msg", "1"); - setprop("/MCDU[1]/scratchpad", "NOT ALLOWED"); + setprop("/MCDU[0]/scratchpad-msg", "1"); + setprop("/MCDU[0]/scratchpad", "NOT ALLOWED"); } } else { - if (getprop("/MCDU[1]/scratchpad") != "NOT ALLOWED") { - setprop("/MCDU[1]/last-scratchpad", getprop("/MCDU[1]/scratchpad")); + if (getprop("/MCDU[0]/scratchpad") != "NOT ALLOWED") { + setprop("/MCDU[0]/last-scratchpad", getprop("/MCDU[0]/scratchpad")); } - setprop("/MCDU[1]/scratchpad-msg", "1"); - setprop("/MCDU[1]/scratchpad", "NOT ALLOWED"); + setprop("/MCDU[0]/scratchpad-msg", "1"); + setprop("/MCDU[0]/scratchpad", "NOT ALLOWED"); } } else { - if (getprop("/MCDU[1]/scratchpad") != "NOT ALLOWED") { - setprop("/MCDU[1]/last-scratchpad", getprop("/MCDU[1]/scratchpad")); + if (getprop("/MCDU[0]/scratchpad") != "NOT ALLOWED") { + setprop("/MCDU[0]/last-scratchpad", getprop("/MCDU[0]/scratchpad")); } - setprop("/MCDU[1]/scratchpad-msg", "1"); - setprop("/MCDU[1]/scratchpad", "NOT ALLOWED"); + setprop("/MCDU[0]/scratchpad-msg", "1"); + setprop("/MCDU[0]/scratchpad", "NOT ALLOWED"); } } } else if (key == "L4") { if (scratchpad == "CLR") { setprop("/FMGC/internal/ils1crs-set", 0); - setprop("/MCDU[1]/scratchpad-msg", "0"); - setprop("/MCDU[1]/scratchpad", ""); + setprop("/MCDU[0]/scratchpad-msg", "0"); + setprop("/MCDU[0]/scratchpad", ""); } 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); - setprop("/MCDU[1]/scratchpad", ""); + setprop("/MCDU[0]/scratchpad", ""); } else { - if (getprop("/MCDU[1]/scratchpad") != "NOT ALLOWED") { - setprop("/MCDU[1]/last-scratchpad", getprop("/MCDU[1]/scratchpad")); + if (getprop("/MCDU[0]/scratchpad") != "NOT ALLOWED") { + setprop("/MCDU[0]/last-scratchpad", getprop("/MCDU[0]/scratchpad")); } - setprop("/MCDU[1]/scratchpad-msg", "1"); - setprop("/MCDU[1]/scratchpad", "NOT ALLOWED"); + setprop("/MCDU[0]/scratchpad-msg", "1"); + setprop("/MCDU[0]/scratchpad", "NOT ALLOWED"); } } else { - if (getprop("/MCDU[1]/scratchpad") != "NOT ALLOWED") { - setprop("/MCDU[1]/last-scratchpad", getprop("/MCDU[1]/scratchpad")); + if (getprop("/MCDU[0]/scratchpad") != "NOT ALLOWED") { + setprop("/MCDU[0]/last-scratchpad", getprop("/MCDU[0]/scratchpad")); } - setprop("/MCDU[1]/scratchpad-msg", "1"); - setprop("/MCDU[1]/scratchpad", "NOT ALLOWED"); + setprop("/MCDU[0]/scratchpad-msg", "1"); + setprop("/MCDU[0]/scratchpad", "NOT ALLOWED"); + } + } + } else if (key == "L5") { + if (scratchpad == "CLR") { + setprop("/FMGC/internal/adf1freq-set", 0); + setprop("/MCDU[0]/scratchpad-msg", "0"); + setprop("/MCDU[0]/scratchpad", ""); + } else { + var tfs = size(scratchpad); + if (tfs == 3 or tfs == 4) { + if (scratchpad >= 190 and scratchpad <= 1750) { + setprop("/instrumentation/adf[0]/frequencies/selected-khz", scratchpad); + setprop("/FMGC/internal/adf1freq-set", 1); + setprop("/MCDU[0]/scratchpad", ""); + } else { + if (getprop("/MCDU[0]/scratchpad") != "NOT ALLOWED") { + setprop("/MCDU[0]/last-scratchpad", getprop("/MCDU[0]/scratchpad")); + } + setprop("/MCDU[0]/scratchpad-msg", "1"); + setprop("/MCDU[0]/scratchpad", "NOT ALLOWED"); + } + } else { + if (getprop("/MCDU[0]/scratchpad") != "NOT ALLOWED") { + setprop("/MCDU[0]/last-scratchpad", getprop("/MCDU[0]/scratchpad")); + } + setprop("/MCDU[0]/scratchpad-msg", "1"); + setprop("/MCDU[0]/scratchpad", "NOT ALLOWED"); } } } else if (key == "R1") { if (scratchpad == "CLR") { setprop("/FMGC/internal/vor2freq-set", 0); - setprop("/MCDU[1]/scratchpad-msg", "0"); - setprop("/MCDU[1]/scratchpad", ""); + setprop("/MCDU[0]/scratchpad-msg", "0"); + setprop("/MCDU[0]/scratchpad", ""); } else { var tfs = size(scratchpad); if (tfs == 3 or tfs == 5 or tfs == 6) { @@ -151,60 +178,87 @@ var radnavInput = func(key) { 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 (getprop("/MCDU[1]/scratchpad") != "NOT ALLOWED") { - setprop("/MCDU[1]/last-scratchpad", getprop("/MCDU[1]/scratchpad")); + if (getprop("/MCDU[0]/scratchpad") != "NOT ALLOWED") { + setprop("/MCDU[0]/last-scratchpad", getprop("/MCDU[0]/scratchpad")); } - setprop("/MCDU[1]/scratchpad-msg", "1"); - setprop("/MCDU[1]/scratchpad", "NOT ALLOWED"); + setprop("/MCDU[0]/scratchpad-msg", "1"); + setprop("/MCDU[0]/scratchpad", "NOT ALLOWED"); } else { setprop("/instrumentation/nav[3]/frequencies/selected-mhz", scratchpad); setprop("/FMGC/internal/vor2freq-set", 1); - setprop("/MCDU[1]/scratchpad", ""); + setprop("/MCDU[0]/scratchpad", ""); } } else if (scratchpad >= 112.00 and scratchpad <= 117.95) { setprop("/instrumentation/nav[3]/frequencies/selected-mhz", scratchpad); setprop("/FMGC/internal/vor2freq-set", 1); - setprop("/MCDU[1]/scratchpad", ""); + setprop("/MCDU[0]/scratchpad", ""); } else { - if (getprop("/MCDU[1]/scratchpad") != "NOT ALLOWED") { - setprop("/MCDU[1]/last-scratchpad", getprop("/MCDU[1]/scratchpad")); + if (getprop("/MCDU[0]/scratchpad") != "NOT ALLOWED") { + setprop("/MCDU[0]/last-scratchpad", getprop("/MCDU[0]/scratchpad")); } - setprop("/MCDU[1]/scratchpad-msg", "1"); - setprop("/MCDU[1]/scratchpad", "NOT ALLOWED"); + setprop("/MCDU[0]/scratchpad-msg", "1"); + setprop("/MCDU[0]/scratchpad", "NOT ALLOWED"); } } else { - if (getprop("/MCDU[1]/scratchpad") != "NOT ALLOWED") { - setprop("/MCDU[1]/last-scratchpad", getprop("/MCDU[1]/scratchpad")); + if (getprop("/MCDU[0]/scratchpad") != "NOT ALLOWED") { + setprop("/MCDU[0]/last-scratchpad", getprop("/MCDU[0]/scratchpad")); } - setprop("/MCDU[1]/scratchpad-msg", "1"); - setprop("/MCDU[1]/scratchpad", "NOT ALLOWED"); + setprop("/MCDU[0]/scratchpad-msg", "1"); + setprop("/MCDU[0]/scratchpad", "NOT ALLOWED"); } } } else if (key == "R2") { if (scratchpad == "CLR") { setprop("/FMGC/internal/vor2crs-set", 0); - setprop("/MCDU[1]/scratchpad-msg", "0"); - setprop("/MCDU[1]/scratchpad", ""); + setprop("/MCDU[0]/scratchpad-msg", "0"); + setprop("/MCDU[0]/scratchpad", ""); } else { var tfs = size(scratchpad); if (tfs >= 1 and tfs <= 3) { if (scratchpad >= 0 and scratchpad <= 360) { setprop("/instrumentation/nav[1]/radials/selected-deg", scratchpad); setprop("/FMGC/internal/vor2crs-set", 1); - setprop("/MCDU[1]/scratchpad", ""); + setprop("/MCDU[0]/scratchpad", ""); } else { - if (getprop("/MCDU[1]/scratchpad") != "NOT ALLOWED") { - setprop("/MCDU[1]/last-scratchpad", getprop("/MCDU[1]/scratchpad")); + if (getprop("/MCDU[0]/scratchpad") != "NOT ALLOWED") { + setprop("/MCDU[0]/last-scratchpad", getprop("/MCDU[0]/scratchpad")); } - setprop("/MCDU[1]/scratchpad-msg", "1"); - setprop("/MCDU[1]/scratchpad", "NOT ALLOWED"); + setprop("/MCDU[0]/scratchpad-msg", "1"); + setprop("/MCDU[0]/scratchpad", "NOT ALLOWED"); } } else { - if (getprop("/MCDU[1]/scratchpad") != "NOT ALLOWED") { - setprop("/MCDU[1]/last-scratchpad", getprop("/MCDU[1]/scratchpad")); + if (getprop("/MCDU[0]/scratchpad") != "NOT ALLOWED") { + setprop("/MCDU[0]/last-scratchpad", getprop("/MCDU[0]/scratchpad")); } - setprop("/MCDU[1]/scratchpad-msg", "1"); - setprop("/MCDU[1]/scratchpad", "NOT ALLOWED"); + setprop("/MCDU[0]/scratchpad-msg", "1"); + setprop("/MCDU[0]/scratchpad", "NOT ALLOWED"); + } + } + } else if (key == "R5") { + if (scratchpad == "CLR") { + setprop("/FMGC/internal/adf2freq-set", 0); + setprop("/MCDU[0]/scratchpad-msg", "0"); + setprop("/MCDU[0]/scratchpad", ""); + } else { + var tfs = size(scratchpad); + if (tfs == 3 or tfs == 4) { + if (scratchpad >= 190 and scratchpad <= 1750) { + setprop("/instrumentation/adf[1]/frequencies/selected-khz", scratchpad); + setprop("/FMGC/internal/adf2freq-set", 1); + setprop("/MCDU[0]/scratchpad", ""); + } else { + if (getprop("/MCDU[0]/scratchpad") != "NOT ALLOWED") { + setprop("/MCDU[0]/last-scratchpad", getprop("/MCDU[0]/scratchpad")); + } + setprop("/MCDU[0]/scratchpad-msg", "1"); + setprop("/MCDU[0]/scratchpad", "NOT ALLOWED"); + } + } else { + if (getprop("/MCDU[0]/scratchpad") != "NOT ALLOWED") { + setprop("/MCDU[0]/last-scratchpad", getprop("/MCDU[0]/scratchpad")); + } + setprop("/MCDU[0]/scratchpad-msg", "1"); + setprop("/MCDU[0]/scratchpad", "NOT ALLOWED"); } } }