Implement history winds
This commit is contained in:
parent
e45baeeb0d
commit
536f61d197
3 changed files with 208 additions and 52 deletions
|
@ -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();
|
||||
}
|
||||
};
|
||||
|
|
|
@ -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") {
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
}
|
||||
};
|
Loading…
Reference in a new issue