From 5222aeb63309c29b5f508e10533d46ec33ff1752 Mon Sep 17 00:00:00 2001 From: Matthew Maring <56924612+hayden2000@users.noreply.github.com> Date: Fri, 17 Apr 2020 18:12:55 -0400 Subject: [PATCH] Implement generic mcdu message, add ils mismatch (need to fix offset freq error, i.e. KSFO 28R) --- Models/Instruments/MCDU/MCDU.nas | 19 +++++++++++++++++++ Nasal/FMGC/FMGC.nas | 20 ++------------------ Nasal/MCDU/MCDU.nas | 19 +++++++++++++++++++ Nasal/MCDU/RADNAV.nas | 3 +++ 4 files changed, 43 insertions(+), 18 deletions(-) diff --git a/Models/Instruments/MCDU/MCDU.nas b/Models/Instruments/MCDU/MCDU.nas index e0311f71..b6c2fde6 100644 --- a/Models/Instruments/MCDU/MCDU.nas +++ b/Models/Instruments/MCDU/MCDU.nas @@ -295,6 +295,24 @@ var canvas_MCDU_base = { }, updateCommon: func(i) { page = pageProp[i].getValue(); + if (getprop("MCDU[" ~ i ~ "]/scratchpad-msg") == 1) { + color_selected = getprop("MCDU[" ~ i ~ "]/scratchpad-color"); + if (color_selected == "grn") { + me["Scratchpad"].setColor(GREEN); + } else if (color_selected == "blu") { + me["Scratchpad"].setColor(BLUE); + } else if (color_selected == "amb") { + me["Scratchpad"].setColor(AMBER); + } else if (color_selected == "yel") { + me["Scratchpad"].setColor(YELLOW); + } else if (color_selected == "mag") { + me["Scratchpad"].setColor(MAGENTA); + } else { + me["Scratchpad"].setColor(WHITE); + } + } else { + me["Scratchpad"].setColor(WHITE); + } if (page == "F-PLNA" or page == "F-PLNB") { if (!pageSwitch[i].getBoolValue()) { me["Simple"].show(); @@ -304,6 +322,7 @@ var canvas_MCDU_base = { me["INITA"].hide(); me["IRSINIT"].hide(); me["INITB"].hide(); + me["FUELPRED"].hide(); me["PERFTO"].hide(); me["PERFAPPR"].hide(); me["PERFGA"].hide(); diff --git a/Nasal/FMGC/FMGC.nas b/Nasal/FMGC/FMGC.nas index 55fbab67..7ab79986 100644 --- a/Nasal/FMGC/FMGC.nas +++ b/Nasal/FMGC/FMGC.nas @@ -480,6 +480,7 @@ var masterFMGC = maketimer(0.2, func { #print(r.heading); #print(r.stopway); #print(r.threshold); + setprop("FMGC/internal/ils1freq-calculated", r.ils_frequency_mhz); magnetic_hdg = geo.normdeg(r.heading - getprop("environment/magnetic-variation-deg")); if (r.ils_frequency_mhz != nil and !getprop("FMGC/internal/ils1freq-set") and !getprop("FMGC/internal/ils1crs-set")) { setprop("instrumentation/nav[0]/frequencies/selected-mhz", r.ils_frequency_mhz); @@ -489,21 +490,13 @@ var masterFMGC = maketimer(0.2, func { } else if (!getprop("FMGC/internal/ils1crs-set")) { setprop("instrumentation/nav[0]/radials/selected-deg", magnetic_hdg); } - # if (getprop("FMGC/internal/ils1freq-set") and r.ils_frequency_mhz != getprop("instrumentation/nav[0]/frequencies/selected-mhz")) { -# if (getprop("MCDU[0]/page") == "RADNAV") { -# setprop("MCDU[0]/scratchpad-msg", 1); -# setprop("MCDU[0]/scratchpad", "RWY/LS MISMATCH"); -# } else if (getprop("MCDU[1]/page") == "RADNAV") { -# setprop("MCDU[1]/scratchpad-msg", 1); -# setprop("MCDU[1]/scratchpad", "RWY/LS MISMATCH"); -# } -# } } } else if (fmgc.flightPlanController.flightplans[2].departure_runway != nil and phase <= 1) { var runways = airportinfo(airportinfo(getprop("FMGC/internal/dep-arpt")).id).runways; var rwy = fmgc.flightPlanController.flightplans[2].departure_runway.id; if (runways[rwy] != nil) { var r = runways[rwy]; + setprop("FMGC/internal/ils1freq-calculated", r.ils_frequency_mhz); magnetic_hdg = geo.normdeg(r.heading - getprop("environment/magnetic-variation-deg")); if (r.ils_frequency_mhz != nil and !getprop("FMGC/internal/ils1freq-set") and !getprop("FMGC/internal/ils1crs-set")) { setprop("instrumentation/nav[0]/frequencies/selected-mhz", r.ils_frequency_mhz); @@ -513,15 +506,6 @@ var masterFMGC = maketimer(0.2, func { } else if (!getprop("FMGC/internal/ils1crs-set")) { setprop("instrumentation/nav[0]/radials/selected-deg", magnetic_hdg); } - # if (getprop("FMGC/internal/ils1freq-set") and r.ils_frequency_mhz != getprop("instrumentation/nav[0]/frequencies/selected-mhz")) { -# if (getprop("MCDU[0]/page") == "RADNAV") { -# setprop("MCDU[0]/scratchpad-msg", 1); -# setprop("MCDU[0]/scratchpad", "RWY/LS MISMATCH"); -# } else if (getprop("MCDU[1]/page") == "RADNAV") { -# setprop("MCDU[1]/scratchpad-msg", 1); -# setprop("MCDU[1]/scratchpad", "RWY/LS MISMATCH"); -# } -# } } } }); diff --git a/Nasal/MCDU/MCDU.nas b/Nasal/MCDU/MCDU.nas index 6926498b..6ca98b04 100644 --- a/Nasal/MCDU/MCDU.nas +++ b/Nasal/MCDU/MCDU.nas @@ -15,6 +15,7 @@ var MCDU_reset = func(i) { setprop("MCDU[" ~ i ~ "]/last-fmgc-page", "STATUS"); setprop("MCDU[" ~ i ~ "]/page", "MCDU"); setprop("MCDU[" ~ i ~ "]/scratchpad", "SELECT DESIRED SYSTEM"); + setprop("MCDU[" ~ i ~ "]/scratchpad-color", "wht"); setprop("MCDU[" ~ i ~ "]/scratchpad-msg", 0); setprop("FMGC/keyboard-left", 0); @@ -43,6 +44,7 @@ var MCDU_reset = func(i) { #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); @@ -667,6 +669,7 @@ var arrowbutton = func(btn, i) { } var pagebutton = func(btn, i) { + setprop("MCDU[" ~ i ~ "]/scratchpad-color", "wht"); if (getprop("MCDU[" ~ i ~ "]/page") != "MCDU") { if (btn == "radnav") { setprop("MCDU[" ~ i ~ "]/page", "RADNAV"); @@ -877,6 +880,7 @@ var button = func(btn, i) { } } else { if (btn == "CLR") { + setprop("MCDU[" ~ i ~ "]/scratchpad-color", "wht"); var scratchpad = getprop("MCDU[" ~ i ~ "]/scratchpad"); if (size(scratchpad) == 0) { setprop("MCDU[" ~ i ~ "]/scratchpad-msg", 1); @@ -890,7 +894,21 @@ var button = func(btn, i) { } } +var genericMessage = func(i, text, color) { + if (getprop("MCDU[" ~ i ~ "]/scratchpad") != text) { + if (getprop("MCDU[" ~ i ~ "]/scratchpad-msg") == 1) { + setprop("MCDU[" ~ i ~ "]/last-scratchpad", ""); + } else { + setprop("MCDU[" ~ i ~ "]/last-scratchpad", getprop("MCDU[" ~ i ~ "]/scratchpad")); + } + } + setprop("MCDU[" ~ i ~ "]/scratchpad-color", color); + setprop("MCDU[" ~ i ~ "]/scratchpad-msg", 1); + setprop("MCDU[" ~ i ~ "]/scratchpad", text); +} + var notAllowed = func(i) { + setprop("MCDU[" ~ i ~ "]/scratchpad-color", "wht"); if (getprop("MCDU[" ~ i ~ "]/scratchpad") != "NOT ALLOWED") { if (getprop("MCDU[" ~ i ~ "]/scratchpad-msg") == 1) { setprop("MCDU[" ~ i ~ "]/last-scratchpad", ""); @@ -903,6 +921,7 @@ var notAllowed = func(i) { } var formatError = func(i) { + setprop("MCDU[" ~ i ~ "]/scratchpad-color", "wht"); if (getprop("MCDU[" ~ i ~ "]/scratchpad") != "FORMAT ERROR") { if (getprop("MCDU[" ~ i ~ "]/scratchpad-msg") == 1) { setprop("MCDU[" ~ i ~ "]/last-scratchpad", ""); diff --git a/Nasal/MCDU/RADNAV.nas b/Nasal/MCDU/RADNAV.nas index 477e97a5..ace8f23f 100644 --- a/Nasal/MCDU/RADNAV.nas +++ b/Nasal/MCDU/RADNAV.nas @@ -69,6 +69,9 @@ var radnavInput = func(key, i) { setprop("instrumentation/nav[0]/frequencies/selected-mhz", scratchpad); setprop("FMGC/internal/ils1freq-set", 1); setprop("MCDU[" ~ i ~ "]/scratchpad", ""); + if (num(getprop("FMGC/internal/ils1freq-calculated")) != 0 and num(getprop("FMGC/internal/ils1freq-calculated")) != num(getprop("instrumentation/nav[0]/frequencies/selected-mhz"))) { + genericMessage(i, "RWY/LS MISMATCH", "amb"); + } } else { notAllowed(i); }