1
0
Fork 0

Actually record previous flight's wind, add missing degree symbols

This commit is contained in:
Matthew Maring 2020-08-05 19:37:26 -04:00
parent 0f820ece04
commit 366382c9cc
6 changed files with 136 additions and 37 deletions

View file

@ -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
############################

View file

@ -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();
}
};

View file

@ -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;
}
}

View file

@ -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;
}
}

View file

@ -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 {

View file

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