2020-06-10 02:42:30 +00:00
|
|
|
# A3XX FMGC Wind Driver
|
|
|
|
# Copyright (c) 2020 Matthew Maring (mattmaring)
|
|
|
|
|
|
|
|
var wind = {
|
|
|
|
new: func() {
|
2020-06-13 14:51:03 +00:00
|
|
|
var w = {parents: [wind]};
|
2020-07-30 01:33:00 +00:00
|
|
|
w.heading = -1;
|
|
|
|
w.magnitude = -1;
|
2020-06-13 14:51:03 +00:00
|
|
|
w.altitude = "";
|
2020-07-30 01:25:56 +00:00
|
|
|
w.set = 0;
|
2020-06-13 14:51:03 +00:00
|
|
|
return w;
|
2020-06-10 21:44:04 +00:00
|
|
|
},
|
|
|
|
|
2020-07-30 01:25:56 +00:00
|
|
|
newcopy: func(heading, magnitude, altitude, set) {
|
2020-06-13 14:51:03 +00:00
|
|
|
var w = {parents: [wind]};
|
2020-06-13 14:58:09 +00:00
|
|
|
w.heading = heading;
|
|
|
|
w.magnitude = magnitude;
|
|
|
|
w.altitude = altitude;
|
2020-07-30 01:25:56 +00:00
|
|
|
w.set = set;
|
2020-06-13 14:51:03 +00:00
|
|
|
return w;
|
2020-06-10 02:42:30 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-06-11 17:55:52 +00:00
|
|
|
var alt_wind = {
|
|
|
|
new: func() {
|
2020-06-13 14:51:03 +00:00
|
|
|
var aw = {parents: [alt_wind]};
|
2020-07-30 01:33:00 +00:00
|
|
|
aw.heading = -1;
|
|
|
|
aw.magnitude = -1;
|
2020-07-30 01:25:56 +00:00
|
|
|
aw.set = 0;
|
2020-06-13 14:51:03 +00:00
|
|
|
return aw;
|
2020-06-11 17:55:52 +00:00
|
|
|
},
|
|
|
|
|
2020-07-30 01:25:56 +00:00
|
|
|
newcopy: func(heading, magnitude, set) {
|
2020-06-13 14:51:03 +00:00
|
|
|
var aw = {parents: [alt_wind]};
|
2020-07-30 01:25:56 +00:00
|
|
|
aw.heading = heading;
|
2020-06-13 14:58:09 +00:00
|
|
|
aw.magnitude = magnitude;
|
2020-07-30 01:25:56 +00:00
|
|
|
aw.set = set;
|
2020-06-13 14:51:03 +00:00
|
|
|
return aw;
|
2020-06-11 17:55:52 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
var sat_temp = {
|
|
|
|
new: func() {
|
2020-06-13 14:51:03 +00:00
|
|
|
var st = {parents: [sat_temp]};
|
2020-07-30 01:33:00 +00:00
|
|
|
st.temp = -999;
|
2020-06-13 14:51:03 +00:00
|
|
|
st.altitude = "";
|
2020-07-30 01:25:56 +00:00
|
|
|
st.set = 0;
|
2020-06-13 14:51:03 +00:00
|
|
|
return st;
|
2020-06-11 17:55:52 +00:00
|
|
|
},
|
|
|
|
|
2020-07-30 01:25:56 +00:00
|
|
|
newcopy: func(temp, altitude, set) {
|
2020-06-13 14:51:03 +00:00
|
|
|
var st = {parents: [sat_temp]};
|
2020-06-13 14:58:09 +00:00
|
|
|
st.temp = temp;
|
|
|
|
st.altitude = altitude;
|
2020-07-30 01:25:56 +00:00
|
|
|
st.set = set;
|
2020-06-13 14:51:03 +00:00
|
|
|
return st;
|
2020-06-11 17:55:52 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-06-10 02:42:30 +00:00
|
|
|
var waypoint_winds = {
|
|
|
|
new: func(id, type, includeWind) {
|
2020-06-13 14:51:03 +00:00
|
|
|
var ww = {parents: [waypoint_winds]};
|
2020-06-13 14:58:09 +00:00
|
|
|
ww.id = id;
|
|
|
|
ww.type = type; #departure, waypoint, arrival
|
|
|
|
ww.includeWind = includeWind;
|
2020-06-13 14:51:03 +00:00
|
|
|
ww.wind1 = wind.new();
|
|
|
|
ww.wind2 = wind.new();
|
|
|
|
ww.wind3 = wind.new();
|
|
|
|
ww.wind4 = wind.new();
|
|
|
|
ww.wind5 = wind.new();
|
|
|
|
ww.sat1 = sat_temp.new();
|
|
|
|
ww.alt1 = alt_wind.new();
|
|
|
|
return ww;
|
2020-06-10 21:44:04 +00:00
|
|
|
},
|
|
|
|
|
2020-06-11 17:55:52 +00:00
|
|
|
newcopy: func(id, type, includeWind, wind1, wind2, wind3, wind4, wind5, sat1, alt1) {
|
2020-06-13 14:51:03 +00:00
|
|
|
var ww = {parents: [waypoint_winds]};
|
2020-06-13 14:58:09 +00:00
|
|
|
ww.id = id;
|
|
|
|
ww.type = type; #departure, waypoint, arrival
|
|
|
|
ww.includeWind = includeWind;
|
|
|
|
ww.wind1 = wind1;
|
|
|
|
ww.wind2 = wind2;
|
|
|
|
ww.wind3 = wind3;
|
|
|
|
ww.wind4 = wind4;
|
|
|
|
ww.wind5 = wind5;
|
|
|
|
ww.sat1 = sat1;
|
|
|
|
ww.alt1 = alt1;
|
2020-06-13 14:51:03 +00:00
|
|
|
return ww;
|
2020-06-10 02:42:30 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
var windController = {
|
2020-06-10 21:44:04 +00:00
|
|
|
clb_winds: [0, 0, 0],
|
|
|
|
crz_winds: [0, 0, 0],
|
|
|
|
des_winds: [0, 0, 0],
|
2020-08-05 09:36:25 +00:00
|
|
|
hist_winds: 0,
|
2020-08-08 12:55:49 +00:00
|
|
|
fl50_wind: [-1, -1, ""],
|
2020-08-05 23:37:26 +00:00
|
|
|
fl150_wind: [-1, -1, ""],
|
|
|
|
fl250_wind: [-1, -1, ""],
|
|
|
|
flcrz_wind: [-1, -1, ""],
|
2020-06-10 21:44:04 +00:00
|
|
|
winds: [[], [], []], #waypoint winds used if route includes navaids
|
2020-06-10 02:42:30 +00:00
|
|
|
nav_indicies: [[], [], []],
|
|
|
|
windSizes: [0, 0, 0],
|
2020-06-13 01:28:14 +00:00
|
|
|
accessPage: ["", ""],
|
2020-06-10 02:42:30 +00:00
|
|
|
#temporaryFlag: [0, 0],
|
|
|
|
|
|
|
|
init: func() {
|
|
|
|
me.resetWind(2);
|
2020-06-10 21:44:04 +00:00
|
|
|
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);
|
2020-08-05 09:36:25 +00:00
|
|
|
me.hist_winds = waypoint_winds.new("history", "waypoint", 1);
|
|
|
|
me.read();
|
2020-06-10 02:42:30 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
reset: func() {
|
|
|
|
#me.temporaryFlag[0] = 0;
|
|
|
|
#me.temporaryFlag[1] = 0;
|
|
|
|
me.resetWind(0);
|
|
|
|
me.resetWind(1);
|
|
|
|
me.resetWind(2);
|
|
|
|
},
|
|
|
|
|
|
|
|
resetWind: func(n) {
|
2020-06-10 21:44:04 +00:00
|
|
|
me.clb_winds[n] = 0;
|
|
|
|
me.crz_winds[n] = 0;
|
|
|
|
me.des_winds[n] = 0;
|
2020-06-10 02:42:30 +00:00
|
|
|
me.winds[n] = [];
|
|
|
|
me.nav_indicies[n] = [];
|
|
|
|
me.windSizes[n] = 0;
|
|
|
|
},
|
|
|
|
|
2020-07-30 02:21:30 +00:00
|
|
|
resetDesWinds: func() {
|
|
|
|
me.des_winds[0] = 0;
|
|
|
|
me.des_winds[1] = 0;
|
|
|
|
me.des_winds[2] = waypoint_winds.new("descent", "waypoint", 1);
|
|
|
|
},
|
|
|
|
|
2020-06-10 21:44:04 +00:00
|
|
|
copyClbWind: func(n) {
|
|
|
|
var id = me.clb_winds[n].id;
|
|
|
|
var type = me.clb_winds[n].type;
|
|
|
|
var includeWind = me.clb_winds[n].includeWind;
|
2020-07-30 01:25:56 +00:00
|
|
|
var wind1 = wind.newcopy(me.clb_winds[n].wind1.heading, me.clb_winds[n].wind1.magnitude, me.clb_winds[n].wind1.altitude, me.clb_winds[n].wind1.set);
|
|
|
|
var wind2 = wind.newcopy(me.clb_winds[n].wind2.heading, me.clb_winds[n].wind2.magnitude, me.clb_winds[n].wind2.altitude, me.clb_winds[n].wind2.set);
|
|
|
|
var wind3 = wind.newcopy(me.clb_winds[n].wind3.heading, me.clb_winds[n].wind3.magnitude, me.clb_winds[n].wind3.altitude, me.clb_winds[n].wind3.set);
|
|
|
|
var wind4 = wind.newcopy(me.clb_winds[n].wind4.heading, me.clb_winds[n].wind4.magnitude, me.clb_winds[n].wind4.altitude, me.clb_winds[n].wind4.set);
|
|
|
|
var wind5 = wind.newcopy(me.clb_winds[n].wind5.heading, me.clb_winds[n].wind5.magnitude, me.clb_winds[n].wind5.altitude, me.clb_winds[n].wind5.set);
|
|
|
|
var sat1 = sat_temp.newcopy(me.clb_winds[n].sat1.temp, me.clb_winds[n].sat1.altitude, me.clb_winds[n].sat1.set);
|
|
|
|
var alt1 = alt_wind.newcopy(me.clb_winds[n].alt1.heading, me.clb_winds[n].alt1.magnitude, me.clb_winds[n].alt1.set);
|
2020-06-11 17:55:52 +00:00
|
|
|
return waypoint_winds.newcopy(id, type, includeWind, wind1, wind2, wind3, wind4, wind5, sat1, alt1);
|
2020-06-10 21:44:04 +00:00
|
|
|
},
|
|
|
|
|
2020-06-10 22:26:55 +00:00
|
|
|
copyCrzWind: func(n) {
|
|
|
|
var id = me.crz_winds[n].id;
|
|
|
|
var type = me.crz_winds[n].type;
|
|
|
|
var includeWind = me.crz_winds[n].includeWind;
|
2020-07-30 01:25:56 +00:00
|
|
|
var wind1 = wind.newcopy(me.crz_winds[n].wind1.heading, me.crz_winds[n].wind1.magnitude, me.crz_winds[n].wind1.altitude, me.crz_winds[n].wind1.set);
|
|
|
|
var wind2 = wind.newcopy(me.crz_winds[n].wind2.heading, me.crz_winds[n].wind2.magnitude, me.crz_winds[n].wind2.altitude, me.crz_winds[n].wind2.set);
|
|
|
|
var wind3 = wind.newcopy(me.crz_winds[n].wind3.heading, me.crz_winds[n].wind3.magnitude, me.crz_winds[n].wind3.altitude, me.crz_winds[n].wind3.set);
|
|
|
|
var wind4 = wind.newcopy(me.crz_winds[n].wind4.heading, me.crz_winds[n].wind4.magnitude, me.crz_winds[n].wind4.altitude, me.crz_winds[n].wind4.set);
|
|
|
|
var wind5 = wind.newcopy(me.crz_winds[n].wind5.heading, me.crz_winds[n].wind5.magnitude, me.crz_winds[n].wind5.altitude, me.crz_winds[n].wind5.set);
|
|
|
|
var sat1 = sat_temp.newcopy(me.crz_winds[n].sat1.temp, me.crz_winds[n].sat1.altitude, me.crz_winds[n].sat1.set);
|
|
|
|
var alt1 = alt_wind.newcopy(me.crz_winds[n].alt1.heading, me.crz_winds[n].alt1.magnitude, me.crz_winds[n].alt1.set);
|
2020-06-11 17:55:52 +00:00
|
|
|
return waypoint_winds.newcopy(id, type, includeWind, wind1, wind2, wind3, wind4, wind5, sat1, alt1);
|
2020-06-10 22:26:55 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
copyDesWind: func(n) {
|
|
|
|
var id = me.des_winds[n].id;
|
|
|
|
var type = me.des_winds[n].type;
|
|
|
|
var includeWind = me.des_winds[n].includeWind;
|
2020-07-30 01:25:56 +00:00
|
|
|
var wind1 = wind.newcopy(me.des_winds[n].wind1.heading, me.des_winds[n].wind1.magnitude, me.des_winds[n].wind1.altitude, me.des_winds[n].wind1.set);
|
|
|
|
var wind2 = wind.newcopy(me.des_winds[n].wind2.heading, me.des_winds[n].wind2.magnitude, me.des_winds[n].wind2.altitude, me.des_winds[n].wind2.set);
|
|
|
|
var wind3 = wind.newcopy(me.des_winds[n].wind3.heading, me.des_winds[n].wind3.magnitude, me.des_winds[n].wind3.altitude, me.des_winds[n].wind3.set);
|
|
|
|
var wind4 = wind.newcopy(me.des_winds[n].wind4.heading, me.des_winds[n].wind4.magnitude, me.des_winds[n].wind4.altitude, me.des_winds[n].wind4.set);
|
|
|
|
var wind5 = wind.newcopy(me.des_winds[n].wind5.heading, me.des_winds[n].wind5.magnitude, me.des_winds[n].wind5.altitude, me.des_winds[n].wind5.set);
|
|
|
|
var sat1 = sat_temp.newcopy(me.des_winds[n].sat1.temp, me.des_winds[n].sat1.altitude, me.des_winds[n].sat1.set);
|
|
|
|
var alt1 = alt_wind.newcopy(me.des_winds[n].alt1.heading, me.des_winds[n].alt1.magnitude, me.des_winds[n].alt1.set);
|
2020-06-11 17:55:52 +00:00
|
|
|
return waypoint_winds.newcopy(id, type, includeWind, wind1, wind2, wind3, wind4, wind5, sat1, alt1);
|
2020-06-10 22:26:55 +00:00
|
|
|
},
|
|
|
|
|
2020-06-11 16:57:35 +00:00
|
|
|
copyWinds: func(n) {
|
|
|
|
var tempWind = [];
|
|
|
|
for (i = 0; i < size(me.winds[n]); i += 1) {
|
|
|
|
var id = me.winds[n][i].id;
|
|
|
|
var type = me.winds[n][i].type;
|
|
|
|
var includeWind = me.winds[n][i].includeWind;
|
2020-07-30 01:25:56 +00:00
|
|
|
var wind1 = wind.newcopy(me.winds[n][i].wind1.heading, me.winds[n][i].wind1.magnitude, me.winds[n][i].wind1.altitude, me.winds[n][i].wind1.set);
|
|
|
|
var wind2 = wind.newcopy(me.winds[n][i].wind2.heading, me.winds[n][i].wind2.magnitude, me.winds[n][i].wind2.altitude, me.winds[n][i].wind2.set);
|
|
|
|
var wind3 = wind.newcopy(me.winds[n][i].wind3.heading, me.winds[n][i].wind3.magnitude, me.winds[n][i].wind3.altitude, me.winds[n][i].wind3.set);
|
|
|
|
var wind4 = wind.newcopy(me.winds[n][i].wind4.heading, me.winds[n][i].wind4.magnitude, me.winds[n][i].wind4.altitude, me.winds[n][i].wind4.set);
|
|
|
|
var wind5 = wind.newcopy(me.winds[n][i].wind5.heading, me.winds[n][i].wind5.magnitude, me.winds[n][i].wind5.altitude, me.winds[n][i].wind5.set);
|
|
|
|
var sat1 = sat_temp.newcopy(me.winds[n][i].sat1.temp, me.winds[n][i].sat1.altitude, me.winds[n][i].sat1.set);
|
|
|
|
var alt1 = alt_wind.newcopy(me.winds[n][i].alt1.heading, me.winds[n][i].alt1.magnitude, me.winds[n][i].alt1.set);
|
2020-06-11 17:55:52 +00:00
|
|
|
append(tempWind, waypoint_winds.newcopy(id, type, includeWind, wind1, wind2, wind3, wind4, wind5, sat1, alt1));
|
2020-06-11 16:57:35 +00:00
|
|
|
}
|
|
|
|
return tempWind;
|
|
|
|
},
|
|
|
|
|
2020-06-10 02:42:30 +00:00
|
|
|
createTemporaryWinds: func(n) {
|
|
|
|
me.resetWind(n);
|
2020-06-10 21:44:04 +00:00
|
|
|
me.clb_winds[n] = me.copyClbWind(2);
|
2020-06-10 22:26:55 +00:00
|
|
|
me.crz_winds[n] = me.copyCrzWind(2);
|
|
|
|
me.des_winds[n] = me.copyDesWind(2);
|
2020-06-11 16:57:35 +00:00
|
|
|
me.winds[n] = me.copyWinds(2);
|
2020-06-10 02:42:30 +00:00
|
|
|
me.nav_indicies[n] = me.nav_indicies[2];
|
|
|
|
me.windSizes[n] = me.windSizes[2];
|
2020-07-30 18:48:11 +00:00
|
|
|
#me.waypointsChanged();
|
2020-06-10 02:42:30 +00:00
|
|
|
#me.temporaryFlag[n] = 1;
|
|
|
|
},
|
|
|
|
|
|
|
|
destroyTemporaryWinds: func(n, a) { # a = 1 activate, a = 0 erase
|
2020-06-10 23:22:08 +00:00
|
|
|
#print("destroying temporary ", n);
|
2020-06-10 02:42:30 +00:00
|
|
|
if (a == 1) {
|
|
|
|
me.resetWind(2);
|
2020-06-10 21:44:04 +00:00
|
|
|
me.clb_winds[2] = me.copyClbWind(n);
|
2020-06-10 22:26:55 +00:00
|
|
|
me.crz_winds[2] = me.copyCrzWind(n);
|
|
|
|
me.des_winds[2] = me.copyDesWind(n);
|
2020-06-11 16:57:35 +00:00
|
|
|
me.winds[2] = me.copyWinds(n);
|
2020-06-10 02:42:30 +00:00
|
|
|
me.nav_indicies[2] = me.nav_indicies[n];
|
|
|
|
me.windSizes[2] = me.windSizes[n];
|
|
|
|
}
|
|
|
|
if (n == 3) { return; }
|
|
|
|
me.resetWind(n);
|
2020-07-30 18:48:11 +00:00
|
|
|
me.waypointsChanged();
|
2020-06-10 02:42:30 +00:00
|
|
|
#me.temporaryFlag[n] = 0;
|
|
|
|
},
|
2020-08-05 09:36:25 +00:00
|
|
|
# read - read from hist wind file, create one if it doesn't exist
|
|
|
|
read: func() {
|
2021-06-09 16:25:17 +00:00
|
|
|
var path = pts.Sim.fgHome.getValue() ~ "/Export/A320SavedWinds.txt";
|
2020-08-05 09:36:25 +00:00
|
|
|
# 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
|
|
|
|
write: func() {
|
|
|
|
if (me.des_winds[2] != 0) {
|
2021-06-09 16:25:17 +00:00
|
|
|
var path = pts.Sim.fgHome.getValue() ~ "/Export/A320SavedWinds.txt";
|
2020-08-05 09:36:25 +00:00
|
|
|
var file = io.open(path, "wb");
|
2020-08-05 23:37:26 +00:00
|
|
|
var winds_added = 0;
|
|
|
|
|
2020-08-08 12:55:49 +00:00
|
|
|
if (me.fl50_wind[2] != "") {
|
|
|
|
io.write(file, me.fl50_wind[0] ~ "," ~ me.fl50_wind[1] ~ "," ~ me.fl50_wind[2] ~ "\n");
|
2020-08-05 23:37:26 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2020-08-05 09:36:25 +00:00
|
|
|
io.close(file);
|
|
|
|
} else {
|
|
|
|
print("no wind data");
|
|
|
|
}
|
|
|
|
},
|
2020-06-10 02:42:30 +00:00
|
|
|
|
|
|
|
insertWind: func(plan, index, value, id) {
|
|
|
|
if (me.windSizes[plan] == index) {
|
|
|
|
if (value == 3) {
|
|
|
|
append(me.winds[plan], waypoint_winds.new(id, "arrival", 0));
|
|
|
|
} else if (value == 2) {
|
|
|
|
append(me.winds[plan], waypoint_winds.new(id, "departure", 0));
|
|
|
|
} else if (value == 1) {
|
|
|
|
append(me.winds[plan], waypoint_winds.new(id, "waypoint", 1));
|
|
|
|
} else {
|
|
|
|
append(me.winds[plan], waypoint_winds.new(id, "waypoint", 0));
|
|
|
|
}
|
|
|
|
me.windSizes[plan] += 1;
|
|
|
|
} else if (me.windSizes[plan] > index and index >= 0) {
|
|
|
|
append(me.winds[plan], waypoint_winds.new(id, "waypoint", 0));
|
|
|
|
me.windSizes[plan] += 1;
|
|
|
|
for (i = me.windSizes[plan] - 1; i > index; i -= 1) {
|
|
|
|
me.winds[plan][i] = me.winds[plan][i - 1];
|
|
|
|
}
|
|
|
|
if (value == 3) {
|
|
|
|
me.winds[plan][index] = waypoint_winds.new(id, "arrival", 0);
|
|
|
|
} else if (value == 2) {
|
|
|
|
me.winds[plan][index] = waypoint_winds.new(id, "departure", 0);
|
|
|
|
} else if (value == 1) {
|
|
|
|
me.winds[plan][index] = waypoint_winds.new(id, "waypoint", 1);
|
|
|
|
} else {
|
|
|
|
me.winds[plan][index] = waypoint_winds.new(id, "waypoint", 0);
|
|
|
|
}
|
|
|
|
} else {
|
2020-06-10 23:22:08 +00:00
|
|
|
#print("insert invalid id: ", id, ", plan: ", plan, ", index: ", index, ", size: ", me.windSizes[plan]);
|
|
|
|
#debug.dump(me.winds);
|
|
|
|
#debug.dump(me.windSizes);
|
2020-06-10 02:42:30 +00:00
|
|
|
return;
|
|
|
|
}
|
2020-06-10 23:22:08 +00:00
|
|
|
#print("insert plan: ", plan, ", index: ", index);
|
|
|
|
#debug.dump(me.winds);
|
|
|
|
#debug.dump(me.windSizes);
|
2020-07-30 18:48:11 +00:00
|
|
|
me.waypointsChanged();
|
2020-06-10 02:42:30 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
deleteWind: func(plan, index) {
|
|
|
|
if (me.windSizes[plan] == index) {
|
|
|
|
pop(me.winds[plan]);
|
|
|
|
me.windSizes[plan] -= 1;
|
|
|
|
} else if (me.windSizes[plan] > index and index >= 0) {
|
|
|
|
for (i = index; i < me.windSizes[plan] - 1; i += 1) {
|
|
|
|
me.winds[plan][i] = me.winds[plan][i + 1];
|
|
|
|
}
|
|
|
|
pop(me.winds[plan]);
|
|
|
|
me.windSizes[plan] -= 1;
|
|
|
|
} else {
|
2020-06-10 23:22:08 +00:00
|
|
|
#print("delete invalid plan: ", plan, ", index: ", index, ", size: ", me.windSizes[plan]);
|
|
|
|
#debug.dump(me.winds);
|
|
|
|
#debug.dump(me.windSizes);
|
2020-06-10 02:42:30 +00:00
|
|
|
return;
|
|
|
|
}
|
2020-06-10 23:22:08 +00:00
|
|
|
#print("delete plan: ", plan, ", index: ", index);
|
|
|
|
#debug.dump(me.winds);
|
|
|
|
#debug.dump(me.windSizes);
|
2020-07-30 18:48:11 +00:00
|
|
|
me.waypointsChanged();
|
|
|
|
},
|
|
|
|
|
|
|
|
waypointsChanged: func() {
|
|
|
|
if (canvas_mcdu.myCRZWIND[1] != nil) {
|
|
|
|
if (!fmgc.flightPlanController.temporaryFlag[1]) {
|
|
|
|
if (fmgc.FMGCInternal.toFromSet and size(fmgc.windController.nav_indicies[2]) > 0) {
|
|
|
|
canvas_mcdu.myCRZWIND[1].waypoint = fmgc.flightPlanController.flightplans[2].getWP(me.nav_indicies[2][0]);
|
|
|
|
canvas_mcdu.myCRZWIND[1].singleCRZ = 0;
|
|
|
|
canvas_mcdu.myCRZWIND[1].cur_location = 0;
|
|
|
|
} else {
|
|
|
|
canvas_mcdu.myCRZWIND[1].waypoint = nil;
|
|
|
|
canvas_mcdu.myCRZWIND[1].singleCRZ = 1;
|
|
|
|
canvas_mcdu.myCRZWIND[1].cur_location = 0;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (fmgc.FMGCInternal.toFromSet and size(fmgc.windController.nav_indicies[1]) > 0) {
|
|
|
|
canvas_mcdu.myCRZWIND[1].waypoint = fmgc.flightPlanController.flightplans[1].getWP(me.nav_indicies[1][0]);
|
|
|
|
canvas_mcdu.myCRZWIND[1].singleCRZ = 0;
|
|
|
|
canvas_mcdu.myCRZWIND[1].cur_location = 0;
|
|
|
|
} else {
|
|
|
|
canvas_mcdu.myCRZWIND[1].waypoint = nil;
|
|
|
|
canvas_mcdu.myCRZWIND[1].singleCRZ = 1;
|
|
|
|
canvas_mcdu.myCRZWIND[1].cur_location = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
canvas_mcdu.myCRZWIND[1].reload();
|
|
|
|
}
|
|
|
|
if (canvas_mcdu.myCRZWIND[0] != nil) {
|
|
|
|
if (!fmgc.flightPlanController.temporaryFlag[0]) {
|
|
|
|
if (fmgc.FMGCInternal.toFromSet and size(fmgc.windController.nav_indicies[2]) > 0) {
|
|
|
|
canvas_mcdu.myCRZWIND[0].waypoint = fmgc.flightPlanController.flightplans[2].getWP(me.nav_indicies[2][0]);
|
|
|
|
canvas_mcdu.myCRZWIND[0].singleCRZ = 0;
|
|
|
|
canvas_mcdu.myCRZWIND[0].cur_location = 0;
|
|
|
|
} else {
|
|
|
|
canvas_mcdu.myCRZWIND[0].waypoint = nil;
|
|
|
|
canvas_mcdu.myCRZWIND[0].singleCRZ = 1;
|
|
|
|
canvas_mcdu.myCRZWIND[0].cur_location = 0;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (fmgc.FMGCInternal.toFromSet and size(fmgc.windController.nav_indicies[0]) > 0) {
|
|
|
|
canvas_mcdu.myCRZWIND[0].waypoint = fmgc.flightPlanController.flightplans[0].getWP(me.nav_indicies[0][0]);
|
|
|
|
canvas_mcdu.myCRZWIND[0].singleCRZ = 0;
|
|
|
|
canvas_mcdu.myCRZWIND[0].cur_location = 0;
|
|
|
|
} else {
|
|
|
|
canvas_mcdu.myCRZWIND[0].waypoint = nil;
|
|
|
|
canvas_mcdu.myCRZWIND[0].singleCRZ = 1;
|
|
|
|
canvas_mcdu.myCRZWIND[0].cur_location = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
canvas_mcdu.myCRZWIND[0].reload();
|
|
|
|
}
|
2020-06-10 02:42:30 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
updatePlans: func() {
|
|
|
|
var winds_copy = me.winds;
|
|
|
|
var windSizes_copy = me.windSizes;
|
|
|
|
me.winds = [[], [], []];
|
|
|
|
me.nav_indicies = [[], [], []];
|
|
|
|
me.windSizes = [0, 0, 0];
|
2020-06-10 21:44:04 +00:00
|
|
|
|
2020-06-10 02:42:30 +00:00
|
|
|
# loop through waypoints
|
|
|
|
for (plan = 0; plan <= 2; plan += 1) {
|
|
|
|
for (i = 0; i < fmgc.flightPlanController.flightplans[plan].getPlanSize(); i += 1) {
|
|
|
|
var waypoint = fmgc.flightPlanController.flightplans[plan].getWP(i);
|
2020-06-10 23:22:08 +00:00
|
|
|
#print(waypoint.wp_role, "| : |", waypoint.wp_type);
|
2020-06-10 02:42:30 +00:00
|
|
|
if (waypoint.wp_role == "sid") {
|
|
|
|
append(me.winds[plan], waypoint_winds.new(waypoint.id, "departure", 0));
|
|
|
|
me.windSizes[plan] += 1;
|
2020-06-13 02:12:28 +00:00
|
|
|
} else if (waypoint.wp_role == "star" or waypoint.wp_role == "approach" or waypoint.wp_role == "missed") {
|
2020-06-10 02:42:30 +00:00
|
|
|
append(me.winds[plan], waypoint_winds.new(waypoint.id, "arrival", 0));
|
|
|
|
me.windSizes[plan] += 1;
|
|
|
|
} else if (waypoint.wp_role == nil and waypoint.wp_type == "navaid") {
|
|
|
|
var found = 0;
|
|
|
|
for (index = 0; index < windSizes_copy[plan]; index += 1) {
|
2020-06-10 23:22:08 +00:00
|
|
|
#print(waypoint.id, " : ", winds_copy[plan][index].id);
|
2020-06-10 02:42:30 +00:00
|
|
|
if (waypoint.id == winds_copy[plan][index].id) {
|
2020-06-10 21:44:04 +00:00
|
|
|
append(me.winds[plan], winds_copy[plan][index]);
|
2020-06-10 02:42:30 +00:00
|
|
|
append(me.nav_indicies[plan], i);
|
|
|
|
me.windSizes[plan] += 1;
|
|
|
|
found = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (found != 1) {
|
|
|
|
append(me.winds[plan], waypoint_winds.new(waypoint.id, "waypoint", 0));
|
|
|
|
me.windSizes[plan] += 1;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
append(me.winds[plan], waypoint_winds.new(waypoint.id, "waypoint", 0));
|
|
|
|
me.windSizes[plan] += 1;
|
|
|
|
}
|
2020-06-10 23:22:08 +00:00
|
|
|
#print("insert plan: ", plan, ", index: ", i);
|
|
|
|
#debug.dump(me.winds);
|
|
|
|
#debug.dump(me.nav_indicies);
|
|
|
|
#debug.dump(me.windSizes);
|
2020-06-10 02:42:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-10 21:44:04 +00:00
|
|
|
if (canvas_mcdu.myCLBWIND[1] != nil) {
|
2020-06-11 16:57:35 +00:00
|
|
|
canvas_mcdu.myCLBWIND[1].reload();
|
2020-06-10 21:44:04 +00:00
|
|
|
}
|
|
|
|
if (canvas_mcdu.myCLBWIND[0] != nil) {
|
2020-06-11 16:57:35 +00:00
|
|
|
canvas_mcdu.myCLBWIND[0].reload();
|
2020-06-10 21:44:04 +00:00
|
|
|
}
|
2020-06-10 22:26:55 +00:00
|
|
|
if (canvas_mcdu.myCRZWIND[1] != nil) {
|
2020-06-11 16:57:35 +00:00
|
|
|
canvas_mcdu.myCRZWIND[1].reload();
|
2020-06-10 22:26:55 +00:00
|
|
|
}
|
|
|
|
if (canvas_mcdu.myCRZWIND[0] != nil) {
|
2020-06-11 16:57:35 +00:00
|
|
|
canvas_mcdu.myCRZWIND[0].reload();
|
2020-06-10 22:26:55 +00:00
|
|
|
}
|
|
|
|
if (canvas_mcdu.myDESWIND[1] != nil) {
|
2020-06-11 16:57:35 +00:00
|
|
|
canvas_mcdu.myDESWIND[1].reload();
|
2020-06-10 22:26:55 +00:00
|
|
|
}
|
|
|
|
if (canvas_mcdu.myDESWIND[0] != nil) {
|
2020-06-11 16:57:35 +00:00
|
|
|
canvas_mcdu.myDESWIND[0].reload();
|
2020-06-10 22:26:55 +00:00
|
|
|
}
|
2020-06-12 16:53:12 +00:00
|
|
|
if (canvas_mcdu.myHISTWIND[1] != nil) {
|
|
|
|
canvas_mcdu.myHISTWIND[1].reload();
|
|
|
|
}
|
|
|
|
if (canvas_mcdu.myHISTWIND[0] != nil) {
|
|
|
|
canvas_mcdu.myHISTWIND[0].reload();
|
|
|
|
}
|
2020-06-10 02:42:30 +00:00
|
|
|
}
|
|
|
|
};
|