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] 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"];