From 536f61d197648e970ba146345b5a0d70b45f5ccd Mon Sep 17 00:00:00 2001 From: Matthew Maring <56924612+hayden2000@users.noreply.github.com> Date: Wed, 5 Aug 2020 05:36:25 -0400 Subject: [PATCH 1/4] Implement history winds --- Nasal/FMGC/winds.nas | 61 ++++++++++++++ Nasal/MCDU/MCDU.nas | 24 ++++-- Nasal/MCDU/WINDHIST.nas | 175 ++++++++++++++++++++++++++++++---------- 3 files changed, 208 insertions(+), 52 deletions(-) diff --git a/Nasal/FMGC/winds.nas b/Nasal/FMGC/winds.nas index b2c477a1..3819c494 100644 --- a/Nasal/FMGC/winds.nas +++ b/Nasal/FMGC/winds.nas @@ -93,6 +93,7 @@ var windController = { clb_winds: [0, 0, 0], crz_winds: [0, 0, 0], des_winds: [0, 0, 0], + hist_winds: 0, winds: [[], [], []], #waypoint winds used if route includes navaids nav_indicies: [[], [], []], windSizes: [0, 0, 0], @@ -104,6 +105,8 @@ var windController = { me.clb_winds[2] = waypoint_winds.new("climb", "waypoint", 1); me.crz_winds[2] = waypoint_winds.new("cruize", "waypoint", 1); me.des_winds[2] = waypoint_winds.new("descent", "waypoint", 1); + me.hist_winds = waypoint_winds.new("history", "waypoint", 1); + me.read(); }, reset: func() { @@ -217,6 +220,62 @@ var windController = { me.waypointsChanged(); #me.temporaryFlag[n] = 0; }, + # read - read from hist wind file, create one if it doesn't exist + read: func() { + var path = getprop("/sim/fg-home") ~ "/Export/A320SavedWinds.txt"; + # create file if it doesn't exist + if (io.stat(path) == nil) { + me.write(); + } + var file = io.open(path); + if (file != nil) { + var line = io.readln(file); + var temp_line = split(",", line); + me.hist_winds.wind1.heading = temp_line[0]; + me.hist_winds.wind1.magnitude = temp_line[1]; + me.hist_winds.wind1.altitude = temp_line[2]; + + line = io.readln(file); + temp_line = split(",", line); + me.hist_winds.wind2.heading = temp_line[0]; + me.hist_winds.wind2.magnitude = temp_line[1]; + me.hist_winds.wind2.altitude = temp_line[2]; + + line = io.readln(file); + temp_line = split(",", line); + me.hist_winds.wind3.heading = temp_line[0]; + me.hist_winds.wind3.magnitude = temp_line[1]; + me.hist_winds.wind3.altitude = temp_line[2]; + + line = io.readln(file); + temp_line = split(",", line); + me.hist_winds.wind4.heading = temp_line[0]; + me.hist_winds.wind4.magnitude = temp_line[1]; + me.hist_winds.wind4.altitude = temp_line[2]; + + line = io.readln(file); + temp_line = split(",", line); + me.hist_winds.wind5.heading = temp_line[0]; + me.hist_winds.wind5.magnitude = temp_line[1]; + me.hist_winds.wind5.altitude = temp_line[2]; + } + }, + # write - write to hist wind file, called whenever winds changed + # note - using previous descent winds, in future actually record the values + write: func() { + if (me.des_winds[2] != 0) { + var path = getprop("/sim/fg-home") ~ "/Export/A320SavedWinds.txt"; + var file = io.open(path, "wb"); + io.write(file, me.des_winds[2].wind1.heading ~ "," ~ me.des_winds[2].wind1.magnitude ~ "," ~ me.des_winds[2].wind1.altitude ~ "\n"); + io.write(file, me.des_winds[2].wind2.heading ~ "," ~ me.des_winds[2].wind2.magnitude ~ "," ~ me.des_winds[2].wind2.altitude ~ "\n"); + io.write(file, me.des_winds[2].wind3.heading ~ "," ~ me.des_winds[2].wind3.magnitude ~ "," ~ me.des_winds[2].wind3.altitude ~ "\n"); + io.write(file, me.des_winds[2].wind4.heading ~ "," ~ me.des_winds[2].wind4.magnitude ~ "," ~ me.des_winds[2].wind4.altitude ~ "\n"); + io.write(file, me.des_winds[2].wind5.heading ~ "," ~ me.des_winds[2].wind5.magnitude ~ "," ~ me.des_winds[2].wind5.altitude ~ "\n"); + io.close(file); + } else { + print("no wind data"); + } + }, insertWind: func(plan, index, value, id) { if (me.windSizes[plan] == index) { @@ -398,5 +457,7 @@ var windController = { if (canvas_mcdu.myHISTWIND[0] != nil) { canvas_mcdu.myHISTWIND[0].reload(); } + + me.write(); } }; diff --git a/Nasal/MCDU/MCDU.nas b/Nasal/MCDU/MCDU.nas index 699ba6bd..6a996cd1 100644 --- a/Nasal/MCDU/MCDU.nas +++ b/Nasal/MCDU/MCDU.nas @@ -525,8 +525,6 @@ var lskbutton = func(btn, i) { canvas_mcdu.myCRZWIND[i].pushButtonLeft(6); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "WINDDES") { canvas_mcdu.myDESWIND[i].pushButtonLeft(6); - #} else if (getprop("/MCDU[" ~ i ~ "]/page") == "WINDHIST") { - # canvas_mcdu.myHISTWIND[i].pushButtonRight(6); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "WINDHIST") { if (canvas_mcdu.myCLBWIND[i] == nil) { canvas_mcdu.myCLBWIND[i] = windCLBPage.new(i); @@ -592,12 +590,16 @@ var rskbutton = func(btn, i) { } else if (getprop("/MCDU[" ~ i ~ "]/page") == "INITB") { initInputB("R1",i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "WINDCLB") { - if (canvas_mcdu.myHISTWIND[i] == nil) { - canvas_mcdu.myHISTWIND[i] = windHISTPage.new(i); + if (fmgc.FMGCInternal.phase == 0) { + if (canvas_mcdu.myHISTWIND[i] == nil) { + canvas_mcdu.myHISTWIND[i] = windHISTPage.new(i); + } else { + canvas_mcdu.myHISTWIND[i].reload(); + } + setprop("MCDU[" ~ i ~ "]/page", "WINDHIST"); } else { - canvas_mcdu.myHISTWIND[i].reload(); + mcdu_message(i, "NOT ALLOWED"); } - setprop("MCDU[" ~ i ~ "]/page", "WINDHIST"); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "WINDDES") { canvas_mcdu.myDESWIND[i].pushButtonRight(1); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "RADNAV") { @@ -889,8 +891,14 @@ var rskbutton = func(btn, i) { canvas_mcdu.myCRZWIND[i].pushButtonRight(6); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "WINDDES") { canvas_mcdu.myDESWIND[i].pushButtonRight(6); - #} else if (getprop("/MCDU[" ~ i ~ "]/page") == "WINDHIST") { - # canvas_mcdu.myHISTWIND[i].pushButtonRight(6); + } else if (getprop("/MCDU[" ~ i ~ "]/page") == "WINDHIST") { + canvas_mcdu.myHISTWIND[i].pushButtonRight(6); + if (canvas_mcdu.myCLBWIND[i] == nil) { + canvas_mcdu.myCLBWIND[i] = windCLBPage.new(i); + } else { + canvas_mcdu.myCLBWIND[i].reload(); + } + setprop("MCDU[" ~ i ~ "]/page", "WINDCLB"); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "PERFTO") { perfTOInput("R6",i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "PERFCLB") { diff --git a/Nasal/MCDU/WINDHIST.nas b/Nasal/MCDU/WINDHIST.nas index 94bd5b08..d24a7d78 100644 --- a/Nasal/MCDU/WINDHIST.nas +++ b/Nasal/MCDU/WINDHIST.nas @@ -33,7 +33,7 @@ var windHISTPage = { var whp = {parents:[windHISTPage]}; whp.computer = computer; whp._setupPageWithData(); - whp.updateTmpy(); + #whp.updateTmpy(); return whp; }, del: func() { @@ -42,17 +42,63 @@ var windHISTPage = { _setupPageWithData: func() { me.title = "HISTORY WIND"; me.titleColour = "wht"; - me.L1 = ["----/---", "", "blu"]; - me.L2 = ["----/---", "", "blu"]; - me.L3 = ["----/---", "", "blu"]; - me.L4 = ["----/---", "", "blu"]; - me.L5 = ["----/---", "", "blu"]; + + if (fmgc.windController.hist_winds.wind1.altitude != "") { + me.L1 = [sprintf("%03d/", fmgc.windController.hist_winds.wind1.heading) ~ sprintf("%03d", fmgc.windController.hist_winds.wind1.magnitude), "", "grn"]; + me.C1 = [fmgc.windController.hist_winds.wind1.altitude, "", "grn"]; + fmgc.windController.hist_winds.wind1.set = 1; + } else { + me.L1 = ["", "", "grn"]; + me.C1 = ["", "", "grn"]; + #me.L1 = ["----/---", "", "grn"]; + #me.C1 = ["FL050", "", "grn"]; + } + + if (fmgc.windController.hist_winds.wind2.altitude != "") { + me.L2 = [sprintf("%03d/", fmgc.windController.hist_winds.wind2.heading) ~ sprintf("%03d", fmgc.windController.hist_winds.wind2.magnitude), "", "grn"]; + me.C2 = [fmgc.windController.hist_winds.wind2.altitude, "", "grn"]; + fmgc.windController.hist_winds.wind2.set = 1; + } else { + me.L2 = ["", "", "grn"]; + me.C2 = ["", "", "grn"]; + #me.L2 = ["----/---", "", "grn"]; + #me.C2 = ["FL150", "", "grn"]; + } + + if (fmgc.windController.hist_winds.wind3.altitude != "") { + me.L3 = [sprintf("%03d/", fmgc.windController.hist_winds.wind3.heading) ~ sprintf("%03d", fmgc.windController.hist_winds.wind3.magnitude), "", "grn"]; + me.C3 = [fmgc.windController.hist_winds.wind3.altitude, "", "grn"]; + fmgc.windController.hist_winds.wind3.set = 1; + } else { + me.L3 = ["", "", "grn"]; + me.C3 = ["", "", "grn"]; + #me.L3 = ["----/---", "", "grn"]; + #me.C3 = ["FL250", "", "grn"]; + } + + if (fmgc.windController.hist_winds.wind4.altitude != "") { + me.L4 = [sprintf("%03d/", fmgc.windController.hist_winds.wind4.heading) ~ sprintf("%03d", fmgc.windController.hist_winds.wind4.magnitude), "", "grn"]; + me.C4 = [fmgc.windController.hist_winds.wind4.altitude, "", "grn"]; + fmgc.windController.hist_winds.wind4.set = 1; + } else { + me.L4 = ["", "", "grn"]; + me.C4 = ["", "", "grn"]; + #me.L4 = ["----/---", "", "grn"]; + #me.C4 = [" FL--- CRZ FL", "", "grn"]; + } + + if (fmgc.windController.hist_winds.wind5.altitude != "") { + me.L5 = [sprintf("%03d/", fmgc.windController.hist_winds.wind5.heading) ~ sprintf("%03d", fmgc.windController.hist_winds.wind5.magnitude), "", "grn"]; + me.C5 = [fmgc.windController.hist_winds.wind5.altitude, "", "grn"]; + fmgc.windController.hist_winds.wind5.set = 1; + } else { + me.L5 = ["", "", "grn"]; + me.C5 = ["", "", "grn"]; + #me.L5 = ["----/---", "", "grn"]; + #me.C5 = ["FL370", "", "grn"]; + } + me.L6 = [" CLIMB WIND", "", "wht"]; - me.C1 = ["FL050", "", "blu"]; - me.C2 = ["FL150", "", "blu"]; - me.C3 = ["FL250", "", "blu"]; - me.C4 = [" FL--- CRZ FL", "", "blu"]; - me.C5 = ["FL370", "", "blu"]; me.R6 = ["SELECT ", "", "amb"]; me.arrowsMatrix = [[0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0]]; @@ -60,40 +106,81 @@ var windHISTPage = { me.fontMatrix = [[1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0]]; canvas_mcdu.pageSwitch[me.computer].setBoolValue(0); }, - makeTmpy: func() { - if (!fmgc.flightPlanController.temporaryFlag[me.computer]) { - fmgc.flightPlanController.createTemporaryFlightPlan(me.computer); - } - }, - updateTmpy: func() { - if (fmgc.flightPlanController.temporaryFlag[me.computer]) { - me.L1[2] = "yel"; - me.L2[2] = "yel"; - me.L3[2] = "yel"; - me.L4[2] = "yel"; - me.L5[2] = "yel"; - me.C1[2] = "yel"; - me.C2[2] = "yel"; - me.C3[2] = "yel"; - me.C4[2] = "yel"; - me.C5[2] = "yel"; - canvas_mcdu.pageSwitch[me.computer].setBoolValue(0); - } else { - me.L1[2] = "blu"; - me.L2[2] = "blu"; - me.L3[2] = "blu"; - me.L4[2] = "blu"; - me.L5[2] = "blu"; - me.C1[2] = "blu"; - me.C2[2] = "blu"; - me.C3[2] = "blu"; - me.C4[2] = "blu"; - me.C5[2] = "blu"; - canvas_mcdu.pageSwitch[me.computer].setBoolValue(0); - } - }, + # makeTmpy: func() { +# if (!fmgc.flightPlanController.temporaryFlag[me.computer]) { +# fmgc.flightPlanController.createTemporaryFlightPlan(me.computer); +# } +# }, + # updateTmpy: func() { +# if (fmgc.flightPlanController.temporaryFlag[me.computer]) { +# me.L1[2] = "yel"; +# me.L2[2] = "yel"; +# me.L3[2] = "yel"; +# me.L4[2] = "yel"; +# me.L5[2] = "yel"; +# me.C1[2] = "yel"; +# me.C2[2] = "yel"; +# me.C3[2] = "yel"; +# me.C4[2] = "yel"; +# me.C5[2] = "yel"; +# canvas_mcdu.pageSwitch[me.computer].setBoolValue(0); +# } else { +# me.L1[2] = "blu"; +# me.L2[2] = "blu"; +# me.L3[2] = "blu"; +# me.L4[2] = "blu"; +# me.L5[2] = "blu"; +# me.C1[2] = "blu"; +# me.C2[2] = "blu"; +# me.C3[2] = "blu"; +# me.C4[2] = "blu"; +# me.C5[2] = "blu"; +# canvas_mcdu.pageSwitch[me.computer].setBoolValue(0); +# } +# }, reload: func() { me._setupPageWithData(); - me.updateTmpy(); + #me.updateTmpy(); + }, + pushButtonRight: func(index) { + if (index == 6) { + var hist_winds = fmgc.windController.hist_winds; + if (hist_winds.wind1.set or hist_winds.wind2.set or hist_winds.wind2.set or hist_winds.wind2.set or hist_winds.wind2.set) { + if (hist_winds.wind1.set) { + fmgc.windController.clb_winds[2].wind1.heading = hist_winds.wind1.heading; + fmgc.windController.clb_winds[2].wind1.magnitude = hist_winds.wind1.magnitude; + fmgc.windController.clb_winds[2].wind1.altitude = hist_winds.wind1.altitude; + fmgc.windController.clb_winds[2].wind1.set = 1; + } + if (hist_winds.wind2.set) { + fmgc.windController.clb_winds[2].wind2.heading = hist_winds.wind2.heading; + fmgc.windController.clb_winds[2].wind2.magnitude = hist_winds.wind2.magnitude; + fmgc.windController.clb_winds[2].wind2.altitude = hist_winds.wind2.altitude; + fmgc.windController.clb_winds[2].wind2.set = 1; + } + if (hist_winds.wind3.set) { + fmgc.windController.clb_winds[2].wind3.heading = hist_winds.wind3.heading; + fmgc.windController.clb_winds[2].wind3.magnitude = hist_winds.wind3.magnitude; + fmgc.windController.clb_winds[2].wind3.altitude = hist_winds.wind3.altitude; + fmgc.windController.clb_winds[2].wind3.set = 1; + } + if (hist_winds.wind4.set) { + fmgc.windController.clb_winds[2].wind4.heading = hist_winds.wind4.heading; + fmgc.windController.clb_winds[2].wind4.magnitude = hist_winds.wind4.magnitude; + fmgc.windController.clb_winds[2].wind4.altitude = hist_winds.wind4.altitude; + fmgc.windController.clb_winds[2].wind4.set = 1; + } + if (hist_winds.wind5.set) { + fmgc.windController.clb_winds[2].wind5.heading = hist_winds.wind5.heading; + fmgc.windController.clb_winds[2].wind5.magnitude = hist_winds.wind5.magnitude; + fmgc.windController.clb_winds[2].wind5.altitude = hist_winds.wind5.altitude; + fmgc.windController.clb_winds[2].wind5.set = 1; + } + } else { + mcdu_message(me.computer, "NO WINDS"); + } + } else { + mcdu_message(me.computer, "NOT ALLOWED"); + } } }; \ No newline at end of file From 0f820ece04d9aa30592c72864ccb2263599dc01e Mon Sep 17 00:00:00 2001 From: Matthew Maring <56924612+hayden2000@users.noreply.github.com> Date: Wed, 5 Aug 2020 05:47:16 -0400 Subject: [PATCH 2/4] Bug fix if no winds stored --- Nasal/MCDU/MCDU.nas | 6 ------ Nasal/MCDU/WINDHIST.nas | 6 ++++++ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Nasal/MCDU/MCDU.nas b/Nasal/MCDU/MCDU.nas index 6a996cd1..c9158e19 100644 --- a/Nasal/MCDU/MCDU.nas +++ b/Nasal/MCDU/MCDU.nas @@ -893,12 +893,6 @@ var rskbutton = func(btn, i) { canvas_mcdu.myDESWIND[i].pushButtonRight(6); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "WINDHIST") { canvas_mcdu.myHISTWIND[i].pushButtonRight(6); - if (canvas_mcdu.myCLBWIND[i] == nil) { - canvas_mcdu.myCLBWIND[i] = windCLBPage.new(i); - } else { - canvas_mcdu.myCLBWIND[i].reload(); - } - setprop("MCDU[" ~ i ~ "]/page", "WINDCLB"); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "PERFTO") { perfTOInput("R6",i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "PERFCLB") { diff --git a/Nasal/MCDU/WINDHIST.nas b/Nasal/MCDU/WINDHIST.nas index d24a7d78..855096b0 100644 --- a/Nasal/MCDU/WINDHIST.nas +++ b/Nasal/MCDU/WINDHIST.nas @@ -176,6 +176,12 @@ var windHISTPage = { fmgc.windController.clb_winds[2].wind5.altitude = hist_winds.wind5.altitude; fmgc.windController.clb_winds[2].wind5.set = 1; } + if (canvas_mcdu.myCLBWIND[me.computer] == nil) { + canvas_mcdu.myCLBWIND[me.computer] = windCLBPage.new(me.computer); + } else { + canvas_mcdu.myCLBWIND[me.computer].reload(); + } + setprop("MCDU[" ~ me.computer ~ "]/page", "WINDCLB"); } else { mcdu_message(me.computer, "NO WINDS"); } From 366382c9ccbf6bacf9f18680aedf1d3f5e536e2d Mon Sep 17 00:00:00 2001 From: Matthew Maring <56924612+hayden2000@users.noreply.github.com> Date: Wed, 5 Aug 2020 19:37:26 -0400 Subject: [PATCH 3/4] Actually record previous flight's wind, add missing degree symbols --- Nasal/FMGC/FMGC.nas | 42 ++++++++++++++++++++++++++++++++ Nasal/FMGC/winds.nas | 39 +++++++++++++++++++++++------ Nasal/MCDU/WINDCLB.nas | 10 ++++---- Nasal/MCDU/WINDCRZ.nas | 16 ++++++------ Nasal/MCDU/WINDDES.nas | 12 ++++----- Nasal/MCDU/WINDHIST.nas | 54 +++++++++++++++++++++++++++++++++-------- 6 files changed, 136 insertions(+), 37 deletions(-) diff --git a/Nasal/FMGC/FMGC.nas b/Nasal/FMGC/FMGC.nas index abcf26d2..24a02626 100644 --- a/Nasal/FMGC/FMGC.nas +++ b/Nasal/FMGC/FMGC.nas @@ -710,6 +710,48 @@ var masterFMGC = maketimer(0.2, func { ############################ updateFuel(); + ############################ + # wind + ############################ + if (FMGCInternal.phase == 3 or FMGCInternal.phase == 4 or FMGCInternal.phase == 6) { + var windsDidChange = 0; + if (FMGCInternal.crzFt > 5000 and alt > 4980 and alt < 5020) { + if (sprintf("%03d", getprop("/environment/wind-from-heading-deg/")) != fmgc.windController.fl050_wind[0] or sprintf("%03d", getprop("/environment/wind-speed-kt/")) != fmgc.windController.fl050_wind[1]) { + fmgc.windController.fl050_wind[0] = sprintf("%03d", getprop("/environment/wind-from-heading-deg/")); + fmgc.windController.fl050_wind[1] = sprintf("%03d", getprop("/environment/wind-speed-kt/")); + fmgc.windController.fl050_wind[2] = "FL050"; + windsDidChange = 1; + } + } + if (FMGCInternal.crzFt > 15000 and alt > 14980 and alt < 15020) { + if (sprintf("%03d", getprop("/environment/wind-from-heading-deg/")) != fmgc.windController.fl150_wind[0] or sprintf("%03d", getprop("/environment/wind-speed-kt/")) != fmgc.windController.fl150_wind[1]) { + fmgc.windController.fl150_wind[0] = sprintf("%03d", getprop("/environment/wind-from-heading-deg/")); + fmgc.windController.fl150_wind[1] = sprintf("%03d", getprop("/environment/wind-speed-kt/")); + fmgc.windController.fl150_wind[2] = "FL150"; + windsDidChange = 1; + } + } + if (FMGCInternal.crzFt > 25000 and alt > 24980 and alt < 25020) { + if (sprintf("%03d", getprop("/environment/wind-from-heading-deg/")) != fmgc.windController.fl250_wind[0] or sprintf("%03d", getprop("/environment/wind-speed-kt/")) != fmgc.windController.fl250_wind[1]) { + fmgc.windController.fl250_wind[0] = sprintf("%03d", getprop("/environment/wind-from-heading-deg/")); + fmgc.windController.fl250_wind[1] = sprintf("%03d", getprop("/environment/wind-speed-kt/")); + fmgc.windController.fl250_wind[2] = "FL250"; + windsDidChange = 1; + } + } + if (FMGCInternal.crzSet and alt > FMGCInternal.crzFt - 20 and alt < FMGCInternal.crzFt + 20) { + if (sprintf("%03d", getprop("/environment/wind-from-heading-deg/")) != fmgc.windController.flcrz_wind[0] or sprintf("%03d", getprop("/environment/wind-speed-kt/")) != fmgc.windController.flcrz_wind[1]) { + fmgc.windController.flcrz_wind[0] = sprintf("%03d", getprop("/environment/wind-from-heading-deg/")); + fmgc.windController.flcrz_wind[1] = sprintf("%03d", getprop("/environment/wind-speed-kt/")); + fmgc.windController.flcrz_wind[2] = "FL" ~ FMGCInternal.crzFl; + windsDidChange = 1; + } + } + if (windsDidChange) { + fmgc.windController.write(); + } + } + ############################ # calculate speeds ############################ diff --git a/Nasal/FMGC/winds.nas b/Nasal/FMGC/winds.nas index 3819c494..b2c78036 100644 --- a/Nasal/FMGC/winds.nas +++ b/Nasal/FMGC/winds.nas @@ -94,6 +94,10 @@ var windController = { crz_winds: [0, 0, 0], des_winds: [0, 0, 0], hist_winds: 0, + fl050_wind: [-1, -1, ""], + fl150_wind: [-1, -1, ""], + fl250_wind: [-1, -1, ""], + flcrz_wind: [-1, -1, ""], winds: [[], [], []], #waypoint winds used if route includes navaids nav_indicies: [[], [], []], windSizes: [0, 0, 0], @@ -261,16 +265,37 @@ var windController = { } }, # write - write to hist wind file, called whenever winds changed - # note - using previous descent winds, in future actually record the values write: func() { if (me.des_winds[2] != 0) { var path = getprop("/sim/fg-home") ~ "/Export/A320SavedWinds.txt"; var file = io.open(path, "wb"); - io.write(file, me.des_winds[2].wind1.heading ~ "," ~ me.des_winds[2].wind1.magnitude ~ "," ~ me.des_winds[2].wind1.altitude ~ "\n"); - io.write(file, me.des_winds[2].wind2.heading ~ "," ~ me.des_winds[2].wind2.magnitude ~ "," ~ me.des_winds[2].wind2.altitude ~ "\n"); - io.write(file, me.des_winds[2].wind3.heading ~ "," ~ me.des_winds[2].wind3.magnitude ~ "," ~ me.des_winds[2].wind3.altitude ~ "\n"); - io.write(file, me.des_winds[2].wind4.heading ~ "," ~ me.des_winds[2].wind4.magnitude ~ "," ~ me.des_winds[2].wind4.altitude ~ "\n"); - io.write(file, me.des_winds[2].wind5.heading ~ "," ~ me.des_winds[2].wind5.magnitude ~ "," ~ me.des_winds[2].wind5.altitude ~ "\n"); + var winds_added = 0; + + if (me.fl050_wind[2] != "") { + io.write(file, me.fl050_wind[0] ~ "," ~ me.fl050_wind[1] ~ "," ~ me.fl050_wind[2] ~ "\n"); + winds_added += 1; + } + + if (me.fl150_wind[2] != "") { + io.write(file, me.fl150_wind[0] ~ "," ~ me.fl150_wind[1] ~ "," ~ me.fl150_wind[2] ~ "\n"); + winds_added += 1; + } + + if (me.fl250_wind[2] != "") { + io.write(file, me.fl250_wind[0] ~ "," ~ me.fl250_wind[1] ~ "," ~ me.fl250_wind[2] ~ "\n"); + winds_added += 1; + } + + if (me.flcrz_wind[2] != "") { + io.write(file, me.flcrz_wind[0] ~ "," ~ me.flcrz_wind[1] ~ "," ~ me.flcrz_wind[2] ~ "\n"); + winds_added += 1; + } + + while (winds_added < 5) { + io.write(file, "-1,-1,\n"); + winds_added += 1; + } + io.close(file); } else { print("no wind data"); @@ -457,7 +482,5 @@ var windController = { if (canvas_mcdu.myHISTWIND[0] != nil) { canvas_mcdu.myHISTWIND[0].reload(); } - - me.write(); } }; diff --git a/Nasal/MCDU/WINDCLB.nas b/Nasal/MCDU/WINDCLB.nas index 00e6d044..a3b574dc 100644 --- a/Nasal/MCDU/WINDCLB.nas +++ b/Nasal/MCDU/WINDCLB.nas @@ -71,7 +71,7 @@ var windCLBPage = { me.L5 = [sprintf("%03.0f", windStore.heading) ~ "°/" ~ sprintf("%03.0f", windStore.magnitude) ~ "/" ~ windStore.altitude, nil, "blu"]; me.fontMatrix[0][4] = 1; } else { - me.L5 = ["[ ]/[ ]/[ ]", nil, "blu"]; + me.L5 = ["[ ]°/[ ]/[ ]", nil, "blu"]; me.fontMatrix[0][4] = 1; } } else { @@ -84,7 +84,7 @@ var windCLBPage = { me.L4 = [sprintf("%03.0f", windStore.heading) ~ "°/" ~ sprintf("%03.0f", windStore.magnitude) ~ "/" ~ windStore.altitude, nil, "blu"]; me.fontMatrix[0][3] = 1; } else { - me.L4 = ["[ ]/[ ]/[ ]", nil, "blu"]; + me.L4 = ["[ ]°/[ ]/[ ]", nil, "blu"]; me.fontMatrix[0][3] = 1; } } else { @@ -97,7 +97,7 @@ var windCLBPage = { me.L3 = [sprintf("%03.0f", windStore.heading) ~ "°/" ~ sprintf("%03.0f", windStore.magnitude) ~ "/" ~ windStore.altitude, nil, "blu"]; me.fontMatrix[0][2] = 1; } else { - me.L3 = ["[ ]/[ ]/[ ]", nil, "blu"]; + me.L3 = ["[ ]°/[ ]/[ ]", nil, "blu"]; me.fontMatrix[0][2] = 1; } } else { @@ -110,7 +110,7 @@ var windCLBPage = { me.L2 = [sprintf("%03.0f", windStore.heading) ~ "°/" ~ sprintf("%03.0f", windStore.magnitude) ~ "/" ~ windStore.altitude, nil, "blu"]; me.fontMatrix[0][1] = 1; } else { - me.L2 = ["[ ]/[ ]/[ ]", nil, "blu"]; + me.L2 = ["[ ]°/[ ]/[ ]", nil, "blu"]; me.fontMatrix[0][1] = 1; } } else { @@ -123,7 +123,7 @@ var windCLBPage = { me.L1 = [sprintf("%03.0f", windStore.heading) ~ "°/" ~ sprintf("%03.0f", windStore.magnitude) ~ "/" ~ windStore.altitude, "TRU WIND/ALT", "blu"]; me.fontMatrix[0][0] = 1; } else { - me.L1 = ["[ ]/[ ]/[ ]", "TRU WIND/ALT", "blu"]; + me.L1 = ["[ ]°/[ ]/[ ]", "TRU WIND/ALT", "blu"]; me.fontMatrix[0][0] = 1; } } diff --git a/Nasal/MCDU/WINDCRZ.nas b/Nasal/MCDU/WINDCRZ.nas index ea422864..00de8535 100644 --- a/Nasal/MCDU/WINDCRZ.nas +++ b/Nasal/MCDU/WINDCRZ.nas @@ -98,7 +98,7 @@ var windCRZPage = { me.L4 = [sprintf("%03.0f", windStore.heading) ~ "°/" ~ sprintf("%03.0f", windStore.magnitude) ~ "/" ~ windStore.altitude, nil, "blu"]; me.fontMatrix[0][3] = 1; } else { - me.L4 = ["[ ]/[ ]/[ ]", nil, "blu"]; + me.L4 = ["[ ]°/[ ]/[ ]", nil, "blu"]; me.fontMatrix[0][3] = 1; } } else { @@ -111,7 +111,7 @@ var windCRZPage = { me.L3 = [sprintf("%03.0f", windStore.heading) ~ "°/" ~ sprintf("%03.0f", windStore.magnitude) ~ "/" ~ windStore.altitude, nil, "blu"]; me.fontMatrix[0][2] = 1; } else { - me.L3 = ["[ ]/[ ]/[ ]", nil, "blu"]; + me.L3 = ["[ ]°/[ ]/[ ]", nil, "blu"]; me.fontMatrix[0][2] = 1; } } else { @@ -124,7 +124,7 @@ var windCRZPage = { me.L2 = [sprintf("%03.0f", windStore.heading) ~ "°/" ~ sprintf("%03.0f", windStore.magnitude) ~ "/" ~ windStore.altitude, nil, "blu"]; me.fontMatrix[0][1] = 1; } else { - me.L2 = ["[ ]/[ ]/[ ]", nil, "blu"]; + me.L2 = ["[ ]°/[ ]/[ ]", nil, "blu"]; me.fontMatrix[0][1] = 1; } } else { @@ -137,7 +137,7 @@ var windCRZPage = { me.L1 = [sprintf("%03.0f", windStore.heading) ~ "°/" ~ sprintf("%03.0f", windStore.magnitude) ~ "/" ~ windStore.altitude, "TRU WIND/ALT", "blu"]; me.fontMatrix[0][0] = 1; } else { - me.L1 = ["[ ]/[ ]/[ ]", "TRU WIND/ALT", "blu"]; + me.L1 = ["[ ]°/[ ]/[ ]", "TRU WIND/ALT", "blu"]; me.fontMatrix[0][0] = 1; } } @@ -157,7 +157,7 @@ var windCRZPage = { me.L4 = [sprintf("%03.0f", windStore.heading) ~ "°/" ~sprintf("%03.0f", windStore.magnitude) ~ "/" ~ windStore.altitude, nil, "blu"]; me.fontMatrix[0][3] = 1; } else { - me.L4 = ["[ ]/[ ]/[ ]", nil, "blu"]; + me.L4 = ["[ ]°/[ ]/[ ]", nil, "blu"]; me.fontMatrix[0][3] = 1; } } else { @@ -170,7 +170,7 @@ var windCRZPage = { me.L3 = [sprintf("%03.0f", windStore.heading) ~ "°/" ~ sprintf("%03.0f", windStore.magnitude) ~ "/" ~ windStore.altitude, nil, "blu"]; me.fontMatrix[0][2] = 1; } else { - me.L3 = ["[ ]/[ ]/[ ]", nil, "blu"]; + me.L3 = ["[ ]°/[ ]/[ ]", nil, "blu"]; me.fontMatrix[0][2] = 1; } } else { @@ -183,7 +183,7 @@ var windCRZPage = { me.L2 = [sprintf("%03.0f", windStore.heading) ~ "°/" ~ sprintf("%03.0f", windStore.magnitude) ~ "/" ~ windStore.altitude, nil, "blu"]; me.fontMatrix[0][1] = 1; } else { - me.L2 = ["[ ]/[ ]/[ ]", nil, "blu"]; + me.L2 = ["[ ]°/[ ]/[ ]", nil, "blu"]; me.fontMatrix[0][1] = 1; } } else { @@ -196,7 +196,7 @@ var windCRZPage = { me.L1 = [sprintf("%03.0f", windStore.heading) ~ "°/" ~ sprintf("%03.0f", windStore.magnitude) ~ "/" ~ windStore.altitude, "TRU WIND/ALT", "blu"]; me.fontMatrix[0][0] = 1; } else { - me.L1 = ["[ ]/[ ]/[ ]", "TRU WIND/ALT", "blu"]; + me.L1 = ["[ ]°/[ ]/[ ]", "TRU WIND/ALT", "blu"]; me.fontMatrix[0][0] = 1; } } diff --git a/Nasal/MCDU/WINDDES.nas b/Nasal/MCDU/WINDDES.nas index 93333358..3ae5f763 100644 --- a/Nasal/MCDU/WINDDES.nas +++ b/Nasal/MCDU/WINDDES.nas @@ -72,7 +72,7 @@ var windDESPage = { me.L5 = [sprintf("%03.0f", windStore.heading) ~ "°/" ~ sprintf("%03.0f", windStore.magnitude) ~ "/" ~ windStore.altitude, nil, "blu"]; me.fontMatrix[0][4] = 1; } else { - me.L5 = ["[ ]/[ ]/[ ]", nil, "blu"]; + me.L5 = ["[ ]/°[ ]/[ ]", nil, "blu"]; me.fontMatrix[0][4] = 1; } } else { @@ -85,7 +85,7 @@ var windDESPage = { me.L4 = [sprintf("%03.0f", windStore.heading) ~ "°/" ~ sprintf("%03.0f", windStore.magnitude) ~ "/" ~ windStore.altitude, nil, "blu"]; me.fontMatrix[0][3] = 1; } else { - me.L4 = ["[ ]/[ ]/[ ]", nil, "blu"]; + me.L4 = ["[ ]°/[ ]/[ ]", nil, "blu"]; me.fontMatrix[0][3] = 1; } } else { @@ -98,7 +98,7 @@ var windDESPage = { me.L3 = [sprintf("%03.0f", windStore.heading) ~ "°/" ~ sprintf("%03.0f", windStore.magnitude) ~ "/" ~ windStore.altitude, nil, "blu"]; me.fontMatrix[0][2] = 1; } else { - me.L3 = ["[ ]/[ ]/[ ]", nil, "blu"]; + me.L3 = ["[ ]°/[ ]/[ ]", nil, "blu"]; me.fontMatrix[0][2] = 1; } } else { @@ -111,7 +111,7 @@ var windDESPage = { me.L2 = [sprintf("%03.0f", windStore.heading) ~ "°/" ~ sprintf("%03.0f", windStore.magnitude) ~ "/" ~ windStore.altitude, nil, "blu"]; me.fontMatrix[0][1] = 1; } else { - me.L2 = ["[ ]/[ ]/[ ]", nil, "blu"]; + me.L2 = ["[ ]°/[ ]/[ ]", nil, "blu"]; me.fontMatrix[0][1] = 1; } } else { @@ -124,7 +124,7 @@ var windDESPage = { me.L1 = [sprintf("%03.0f", windStore.heading) ~ "°/" ~ sprintf("%03.0f", windStore.magnitude) ~ "/" ~ windStore.altitude, "TRU WIND/ALT", "blu"]; me.fontMatrix[0][0] = 1; } else { - me.L1 = ["[ ]/[ ]/[ ]", "TRU WIND/ALT", "blu"]; + me.L1 = ["[ ]°/[ ]/[ ]", "TRU WIND/ALT", "blu"]; me.fontMatrix[0][0] = 1; } } @@ -137,7 +137,7 @@ var windDESPage = { me.R1 = [sprintf("%03.0f", windStore.heading) ~ "°/" ~ sprintf("%03.0f", windStore.magnitude), "ALTN WIND ", "blu"]; me.fontMatrix[1][0] = 1; } else { - me.R1 = ["[ ]/[ ]", "ALTN WIND ", "blu"]; + me.R1 = ["[ ]°/[ ]", "ALTN WIND ", "blu"]; me.fontMatrix[1][0] = 1; } } else { diff --git a/Nasal/MCDU/WINDHIST.nas b/Nasal/MCDU/WINDHIST.nas index 855096b0..86c2c6a4 100644 --- a/Nasal/MCDU/WINDHIST.nas +++ b/Nasal/MCDU/WINDHIST.nas @@ -43,9 +43,27 @@ var windHISTPage = { me.title = "HISTORY WIND"; me.titleColour = "wht"; + var lastIndex = 0; + + if (fmgc.windController.hist_winds.wind5.altitude != "") { + lastIndex = 5; + } else if (fmgc.windController.hist_winds.wind4.altitude != "") { + lastIndex = 4; + } else if (fmgc.windController.hist_winds.wind3.altitude != "") { + lastIndex = 3; + } else if (fmgc.windController.hist_winds.wind2.altitude != "") { + lastIndex = 2; + } else if (fmgc.windController.hist_winds.wind1.altitude != "") { + lastIndex = 1; + } + if (fmgc.windController.hist_winds.wind1.altitude != "") { - me.L1 = [sprintf("%03d/", fmgc.windController.hist_winds.wind1.heading) ~ sprintf("%03d", fmgc.windController.hist_winds.wind1.magnitude), "", "grn"]; - me.C1 = [fmgc.windController.hist_winds.wind1.altitude, "", "grn"]; + me.L1 = [sprintf("%03d°/", fmgc.windController.hist_winds.wind1.heading) ~ sprintf("%03d", fmgc.windController.hist_winds.wind1.magnitude), "", "grn"]; + if (lastIndex == 1) { + me.C1 = [" " ~ fmgc.windController.hist_winds.wind1.altitude ~ " CRZ FL", "", "grn"]; + } else { + me.C1 = [fmgc.windController.hist_winds.wind1.altitude, "", "grn"]; + } fmgc.windController.hist_winds.wind1.set = 1; } else { me.L1 = ["", "", "grn"]; @@ -55,8 +73,12 @@ var windHISTPage = { } if (fmgc.windController.hist_winds.wind2.altitude != "") { - me.L2 = [sprintf("%03d/", fmgc.windController.hist_winds.wind2.heading) ~ sprintf("%03d", fmgc.windController.hist_winds.wind2.magnitude), "", "grn"]; - me.C2 = [fmgc.windController.hist_winds.wind2.altitude, "", "grn"]; + me.L2 = [sprintf("%03d°/", fmgc.windController.hist_winds.wind2.heading) ~ sprintf("%03d", fmgc.windController.hist_winds.wind2.magnitude), "", "grn"]; + if (lastIndex == 2) { + me.C2 = [" " ~ fmgc.windController.hist_winds.wind2.altitude ~ " CRZ FL", "", "grn"]; + } else { + me.C2 = [fmgc.windController.hist_winds.wind2.altitude, "", "grn"]; + } fmgc.windController.hist_winds.wind2.set = 1; } else { me.L2 = ["", "", "grn"]; @@ -66,8 +88,12 @@ var windHISTPage = { } if (fmgc.windController.hist_winds.wind3.altitude != "") { - me.L3 = [sprintf("%03d/", fmgc.windController.hist_winds.wind3.heading) ~ sprintf("%03d", fmgc.windController.hist_winds.wind3.magnitude), "", "grn"]; - me.C3 = [fmgc.windController.hist_winds.wind3.altitude, "", "grn"]; + me.L3 = [sprintf("%03d°/", fmgc.windController.hist_winds.wind3.heading) ~ sprintf("%03d", fmgc.windController.hist_winds.wind3.magnitude), "", "grn"]; + if (lastIndex == 3) { + me.C3 = [" " ~ fmgc.windController.hist_winds.wind3.altitude ~ " CRZ FL", "", "grn"]; + } else { + me.C3 = [fmgc.windController.hist_winds.wind3.altitude, "", "grn"]; + } fmgc.windController.hist_winds.wind3.set = 1; } else { me.L3 = ["", "", "grn"]; @@ -77,8 +103,12 @@ var windHISTPage = { } if (fmgc.windController.hist_winds.wind4.altitude != "") { - me.L4 = [sprintf("%03d/", fmgc.windController.hist_winds.wind4.heading) ~ sprintf("%03d", fmgc.windController.hist_winds.wind4.magnitude), "", "grn"]; - me.C4 = [fmgc.windController.hist_winds.wind4.altitude, "", "grn"]; + me.L4 = [sprintf("%03d°/", fmgc.windController.hist_winds.wind4.heading) ~ sprintf("%03d", fmgc.windController.hist_winds.wind4.magnitude), "", "grn"]; + if (lastIndex == 4) { + me.C4 = [" " ~ fmgc.windController.hist_winds.wind4.altitude ~ " CRZ FL", "", "grn"]; + } else { + me.C4 = [fmgc.windController.hist_winds.wind4.altitude, "", "grn"]; + } fmgc.windController.hist_winds.wind4.set = 1; } else { me.L4 = ["", "", "grn"]; @@ -88,8 +118,12 @@ var windHISTPage = { } if (fmgc.windController.hist_winds.wind5.altitude != "") { - me.L5 = [sprintf("%03d/", fmgc.windController.hist_winds.wind5.heading) ~ sprintf("%03d", fmgc.windController.hist_winds.wind5.magnitude), "", "grn"]; - me.C5 = [fmgc.windController.hist_winds.wind5.altitude, "", "grn"]; + me.L5 = [sprintf("%03d°/", fmgc.windController.hist_winds.wind5.heading) ~ sprintf("%03d", fmgc.windController.hist_winds.wind5.magnitude), "", "grn"]; + if (lastIndex == 5) { + me.C5 = [" " ~ fmgc.windController.hist_winds.wind5.altitude ~ " CRZ FL", "", "grn"]; + } else { + me.C5 = [fmgc.windController.hist_winds.wind5.altitude, "", "grn"]; + } fmgc.windController.hist_winds.wind5.set = 1; } else { me.L5 = ["", "", "grn"]; From cde92dd5afb2e8a93ef2cac553b7d29a58995eb7 Mon Sep 17 00:00:00 2001 From: Matthew Maring <56924612+hayden2000@users.noreply.github.com> Date: Wed, 5 Aug 2020 21:42:43 -0400 Subject: [PATCH 4/4] Fix vapp bug --- Nasal/MCDU/PERFAPPR.nas | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Nasal/MCDU/PERFAPPR.nas b/Nasal/MCDU/PERFAPPR.nas index a1e88d17..5486c0a7 100644 --- a/Nasal/MCDU/PERFAPPR.nas +++ b/Nasal/MCDU/PERFAPPR.nas @@ -81,7 +81,7 @@ var perfAPPRInput = func(key, i) { mcdu_scratchpad.scratchpads[i].empty(); } else if (int(scratchpad) != nil and scratchpad >= 100 and scratchpad <= 350) { setprop("/FMGC/internal/vapp-speed-set", 1); - setprop("/FMGC/internal/computed-speeds/vapp_appr", scratchpad); + fmgc.FMGCInternal.vapp_appr = scratchpad; mcdu_scratchpad.scratchpads[i].empty(); } else { mcdu_message(i, "NOT ALLOWED");