From d6b2b82c92a1cf355c4c2807e576faf1a71fdf1c Mon Sep 17 00:00:00 2001 From: Matthew Maring <56924612+hayden2000@users.noreply.github.com> Date: Wed, 29 Jul 2020 19:24:03 -0400 Subject: [PATCH] Push GRND wind to PERFAPPR --- Models/Instruments/MCDU/MCDU.nas | 22 +++++++++++++--------- Nasal/FMGC/FMGC.nas | 25 ++++++++++++++++--------- Nasal/MCDU/MCDU.nas | 8 ++++---- Nasal/MCDU/PERFAPPR.nas | 12 ++++++++---- Nasal/MCDU/WINDCLB.nas | 5 ++++- Nasal/MCDU/WINDCRZ.nas | 5 ++++- Nasal/MCDU/WINDDES.nas | 26 ++++++++++++++++++++------ 7 files changed, 69 insertions(+), 34 deletions(-) diff --git a/Models/Instruments/MCDU/MCDU.nas b/Models/Instruments/MCDU/MCDU.nas index 41f49561..6f1e490f 100644 --- a/Models/Instruments/MCDU/MCDU.nas +++ b/Models/Instruments/MCDU/MCDU.nas @@ -180,10 +180,6 @@ var activate_twice = props.globals.getNode("/FMGC/internal/activate-twice", 1); # APPR PERF var dest_qnh = props.globals.getNode("/FMGC/internal/dest-qnh", 1); var dest_temp = props.globals.getNode("/FMGC/internal/dest-temp", 1); -var dest_mag = props.globals.getNode("/FMGC/internal/dest-mag", 1); -var dest_wind = props.globals.getNode("/FMGC/internal/dest-wind", 1); -# var grnd_mag = props.globals.getNode("/FMGC/internal/dest-mag-grnd", 1); -# var grnd_wind = props.globals.getNode("/FMGC/internal/dest-wind-grnd", 1); var vapp_speed_set = props.globals.getNode("/FMGC/internal/vapp-speed-set", 1); var final = props.globals.getNode("/FMGC/internal/final", 1); var radio = props.globals.getNode("/FMGC/internal/radio", 1); @@ -3632,12 +3628,20 @@ var canvas_MCDU_base = { } me["Simple_L3S"].setText("MAG WIND"); - if (dest_mag.getValue() != -1 and dest_wind.getValue() != -1) { - me["Simple_L3"].setText(sprintf("%03.0fg", dest_mag.getValue()) ~ sprintf("/%.0f", dest_wind.getValue())); - # } else if (grnd_mag.getValue() != -1 and grnd_wind.getValue() != -1) { -# me["Simple_L3"].setText(sprintf("%03.0fg", grnd_mag.getValue()) ~ sprintf("/%.0f", grnd_wind.getValue())); + if (fmgc.FMGCInternal.destMagSet and fmgc.FMGCInternal.destWindSet) { + me["Simple_L3"].setText(sprintf("%03.0fg", fmgc.FMGCInternal.destMag) ~ sprintf("/%.0f", fmgc.FMGCInternal.destWind)); + me["Simple_L3"].setFontSize(normal); } else { - me["Simple_L3"].setText("---g/---");; + me["Simple_L3"].setFontSize(small); + if (myDESWIND[i] != nil and myDESWIND[i].returnGRND() != nil) { + var result = myDESWIND[i].returnGRND(); + me["Simple_L3"].setText(sprintf("%03.0fg", result[0]) ~ sprintf("/%.0f", result[1])); + } else if (myDESWIND[math.abs(i-1)] != nil and myDESWIND[math.abs(i-1)].returnGRND() != nil) { + var result = myDESWIND[math.abs(i-1)].returnGRND(); + me["Simple_L3"].setText(sprintf("%03.0fg", result[0]) ~ sprintf("/%.0f", result[1])); + } else { + me["Simple_L3"].setText("---g/---"); + } } me["Simple_L4S"].setText("TRANS FL"); diff --git a/Nasal/FMGC/FMGC.nas b/Nasal/FMGC/FMGC.nas index 08a0a4b4..d9012e2e 100644 --- a/Nasal/FMGC/FMGC.nas +++ b/Nasal/FMGC/FMGC.nas @@ -142,14 +142,22 @@ var FMGCInternal = { vmo_mmo: 0, # PERF + transAlt: 18000, + transAltSet: 0, + + # PERF TO v1: 0, v1set: 0, vr: 0, vrset: 0, v2: 0, v2set: 0, - transAlt: 18000, - transAltSet: 0, + + # PERF APPR + destMag: 0, + destMagSet: 0, + destWind: 0, + destWindSet: 0, # INIT A altAirport: "", @@ -609,7 +617,6 @@ var masterFMGC = maketimer(0.2, func { tow = getprop("/FMGC/internal/tow") or 0; lw = getprop("/FMGC/internal/lw") or 0; altitude = getprop("/instrumentation/altimeter/indicated-altitude-ft"); - dest_wind = getprop("/FMGC/internal/dest-wind") or 0; # current speeds clean = 2 * weight_lbs * 0.45359237 + 85; @@ -636,12 +643,12 @@ var masterFMGC = maketimer(0.2, func { } setprop("/FMGC/internal/computed-speeds/vls", vls); if (!getprop("/FMGC/internal/vapp-speed-set")) { - if (dest_wind < 5) { + if (fmgc.FMGCInternal.destWind < 5) { vapp = vls + 5; - } else if (dest_wind > 15) { + } else if (fmgc.FMGCInternal.destWind > 15) { vapp = vls + 15; } else { - vapp = vls + dest_wind; + vapp = vls + fmgc.FMGCInternal.destWind; } setprop("/FMGC/internal/computed-speeds/vapp", vapp); } @@ -704,12 +711,12 @@ var masterFMGC = maketimer(0.2, func { } setprop("/FMGC/internal/computed-speeds/vls_appr", vls_appr); if (!getprop("/FMGC/internal/vapp-speed-set")) { - if (dest_wind < 5) { + if (fmgc.FMGCInternal.destWind < 5) { vapp_appr = vls_appr + 5; - } else if (dest_wind > 15) { + } else if (fmgc.FMGCInternal.destWind > 15) { vapp_appr = vls_appr + 15; } else { - vapp_appr = vls_appr + dest_wind; + vapp_appr = vls_appr + fmgc.FMGCInternal.destWind; } setprop("/FMGC/internal/computed-speeds/vapp_appr", vapp_appr); } diff --git a/Nasal/MCDU/MCDU.nas b/Nasal/MCDU/MCDU.nas index 40742e3e..d096e6ca 100644 --- a/Nasal/MCDU/MCDU.nas +++ b/Nasal/MCDU/MCDU.nas @@ -172,10 +172,10 @@ var MCDU_reset = func(i) { # APPR PERF setprop("/FMGC/internal/dest-qnh", -1); setprop("/FMGC/internal/dest-temp", -999); - setprop("/FMGC/internal/dest-mag", -1); - setprop("/FMGC/internal/dest-wind", -1); - # setprop("/FMGC/internal/dest-mag-grnd", -1); - # setprop("/FMGC/internal/dest-wind-grnd", -1); + fmgc.FMGCInternal.destMag = 0; + fmgc.FMGCInternal.destMagSet = 0; + fmgc.FMGCInternal.destWind = 0; + fmgc.FMGCInternal.destWindSet = 0; setprop("/FMGC/internal/vapp-speed-set", 0); setprop("/FMGC/internal/final", ""); setprop("/FMGC/internal/baro", 99999); diff --git a/Nasal/MCDU/PERFAPPR.nas b/Nasal/MCDU/PERFAPPR.nas index a59aff03..a1e88d17 100644 --- a/Nasal/MCDU/PERFAPPR.nas +++ b/Nasal/MCDU/PERFAPPR.nas @@ -30,8 +30,10 @@ var perfAPPRInput = func(key, i) { } else if (key == "L3") { var tfs = size(scratchpad); if (scratchpad == "CLR") { - setprop("/FMGC/internal/dest-mag", -1); - setprop("/FMGC/internal/dest-wind", -1); + fmgc.FMGCInternal.destMag = 0; + fmgc.FMGCInternal.destMagSet = 0; + fmgc.FMGCInternal.destWind = 0; + fmgc.FMGCInternal.destWindSet = 0; mcdu_scratchpad.scratchpads[i].empty(); } else if (tfs >= 3 and tfs <= 7 and find("/", scratchpad) != -1) { var weather = split("/", scratchpad); @@ -39,8 +41,10 @@ var perfAPPRInput = func(key, i) { var winds = size(weather[1]); if (mags >= 1 and mags <= 3 and winds >= 1 and winds <= 3) { if (num(weather[0]) != nil and num(weather[1]) != nil and int(weather[0]) >= 0 and int(weather[0]) <= 360 and int(weather[1]) >= 0 and int(weather[1]) <= 200) { - setprop("/FMGC/internal/dest-mag", weather[0]); - setprop("/FMGC/internal/dest-wind", weather[1]); + fmgc.FMGCInternal.destMag = weather[0]; + fmgc.FMGCInternal.destMagSet = 1; + fmgc.FMGCInternal.destWind = weather[1]; + fmgc.FMGCInternal.destWindSet = 1; mcdu_scratchpad.scratchpads[i].empty(); fmgc.updateARPT(); } else { diff --git a/Nasal/MCDU/WINDCLB.nas b/Nasal/MCDU/WINDCLB.nas index e7619834..f5796397 100644 --- a/Nasal/MCDU/WINDCLB.nas +++ b/Nasal/MCDU/WINDCLB.nas @@ -193,7 +193,10 @@ var windCLBPage = { } else if (me.items >= index) { if (size(mcdu_scratchpad.scratchpads[me.computer].scratchpad) >= 5 and size(mcdu_scratchpad.scratchpads[me.computer].scratchpad) <= 13) { var winds = split("/", mcdu_scratchpad.scratchpads[me.computer].scratchpad); - if (size(winds[0]) >= 1 and size(winds[0]) <= 3 and num(winds[0]) != nil and winds[0] >= 0 and winds[0] <= 360 and + if (size(winds) < 3) { + mcdu_message(me.computer, "NOT ALLOWED"); + # not implemented yet + } else if (size(winds[0]) >= 1 and size(winds[0]) <= 3 and num(winds[0]) != nil and winds[0] >= 0 and winds[0] <= 360 and size(winds[1]) >= 1 and size(winds[1]) <= 3 and num(winds[1]) != nil and winds[1] >= 0 and winds[1] <= 200 and size(winds[2]) >= 4 and size(winds[2]) <= 5 and ((num(winds[2]) != nil and winds[2] >= 1000 and winds[2] <= 39000) or (num(split("FL", winds[2])[1]) != nil and split("FL", winds[2])[1] >= 10 and split("FL", winds[2])[1] <= 390))) { diff --git a/Nasal/MCDU/WINDCRZ.nas b/Nasal/MCDU/WINDCRZ.nas index f69d45cd..bbf99eb6 100644 --- a/Nasal/MCDU/WINDCRZ.nas +++ b/Nasal/MCDU/WINDCRZ.nas @@ -327,7 +327,10 @@ var windCRZPage = { } else if (me.items >= index) { if (size(mcdu_scratchpad.scratchpads[me.computer].scratchpad) >= 5 and size(mcdu_scratchpad.scratchpads[me.computer].scratchpad) <= 13) { var winds = split("/", mcdu_scratchpad.scratchpads[me.computer].scratchpad); - if (size(winds[0]) >= 1 and size(winds[0]) <= 3 and num(winds[0]) != nil and winds[0] >= 0 and winds[0] <= 360 and + if (size(winds) < 3) { + mcdu_message(me.computer, "NOT ALLOWED"); + # not implemented yet + } else if (size(winds[0]) >= 1 and size(winds[0]) <= 3 and num(winds[0]) != nil and winds[0] >= 0 and winds[0] <= 360 and size(winds[1]) >= 1 and size(winds[1]) <= 3 and num(winds[1]) != nil and winds[1] >= 0 and winds[1] <= 200 and size(winds[2]) >= 4 and size(winds[2]) <= 5 and ((num(winds[2]) != nil and winds[2] >= 1000 and winds[2] <= 39000) or (num(split("FL", winds[2])[1]) != nil and split("FL", winds[2])[1] >= 10 and split("FL", winds[2])[1] <= 390))) { diff --git a/Nasal/MCDU/WINDDES.nas b/Nasal/MCDU/WINDDES.nas index b2f14947..c6aa1292 100644 --- a/Nasal/MCDU/WINDDES.nas +++ b/Nasal/MCDU/WINDDES.nas @@ -191,6 +191,22 @@ var windDESPage = { me._setupPageWithData(); me.updateTmpy(); }, + returnGRND: func() { + var wind = fmgc.windController.des_winds[2]; + if (wind.wind5.altitude == "GRND") { + return [wind.wind5.heading, wind.wind5.magnitude]; + } else if (wind.wind4.altitude == "GRND") { + return [wind.wind4.heading, wind.wind4.magnitude]; + } else if (wind.wind3.altitude == "GRND") { + return [wind.wind3.heading, wind.wind3.magnitude]; + } else if (wind.wind2.altitude == "GRND") { + return [wind.wind2.heading, wind.wind2.magnitude]; + } else if (wind.wind1.altitude == "GRND") { + return [wind.wind1.heading, wind.wind1.magnitude]; + } else { + return nil; + } + }, pushButtonLeft: func(index) { if (index == 6 and fmgc.flightPlanController.temporaryFlag[me.computer]) { if (canvas_mcdu.myFpln[me.computer] != nil) { @@ -209,7 +225,10 @@ var windDESPage = { } else if (me.items >= index) { if (size(mcdu_scratchpad.scratchpads[me.computer].scratchpad) >= 5 and size(mcdu_scratchpad.scratchpads[me.computer].scratchpad) <= 13) { var winds = split("/", mcdu_scratchpad.scratchpads[me.computer].scratchpad); - if (size(winds[0]) >= 0 and size(winds[0]) <= 3 and num(winds[0]) != nil and winds[0] >= 0 and winds[0] <= 360 and + if (size(winds) < 3) { + mcdu_message(me.computer, "NOT ALLOWED"); + # not implemented yet + } else if (size(winds[0]) >= 0 and size(winds[0]) <= 3 and num(winds[0]) != nil and winds[0] >= 0 and winds[0] <= 360 and size(winds[1]) >= 0 and size(winds[1]) <= 3 and num(winds[1]) != nil and winds[1] >= 0 and winds[1] <= 200 and size(winds[2]) >= 4 and size(winds[2]) <= 5 and (winds[2] == "GRND" or (num(winds[2]) != nil and winds[2] >= 1000 and winds[2] <= 39000) or (num(split("FL", winds[2])[1]) != nil and split("FL", winds[2])[1] >= 10 and split("FL", winds[2])[1] <= 390))) { @@ -218,11 +237,6 @@ var windDESPage = { if (fmgc.flightPlanController.temporaryFlag[me.computer]) { computer_temp = me.computer; } - # if (winds[2] == "GRND") { -# setprop("/FMGC/internal/dest-mag-grnd", winds[0]); -# setprop("/FMGC/internal/dest-wind-grnd", winds[1]); -# } - #print(computer_temp); if (index == 5) { fmgc.windController.des_winds[computer_temp].wind5.heading = winds[0]; fmgc.windController.des_winds[computer_temp].wind5.magnitude = winds[1];