2019-12-29 21:37:52 +00:00
|
|
|
var latRev = {
|
|
|
|
title: [nil, nil, nil],
|
|
|
|
subtitle: [nil, nil],
|
|
|
|
fontMatrix: [[0, 0, 0, 0, 0, 0],[0, 0, 0, 0, 0, 0]],
|
|
|
|
arrowsMatrix: [[0, 0, 0, 0, 0, 0],[0, 0, 0, 0, 0, 0]],
|
2019-12-30 21:24:00 +00:00
|
|
|
arrowsColour: [["ack", "ack", "ack", "ack", "ack", "ack"],["ack", "ack", "ack", "ack", "ack", "ack"]],
|
2019-12-29 21:37:52 +00:00
|
|
|
L1: [nil, nil, "ack"], # content, title, colour
|
|
|
|
L2: [nil, nil, "ack"],
|
|
|
|
L3: [nil, nil, "ack"],
|
|
|
|
L4: [nil, nil, "ack"],
|
|
|
|
L5: [nil, nil, "ack"],
|
|
|
|
L6: [nil, nil, "ack"],
|
|
|
|
R1: [nil, nil, "ack"],
|
|
|
|
R2: [nil, nil, "ack"],
|
|
|
|
R3: [nil, nil, "ack"],
|
|
|
|
R4: [nil, nil, "ack"],
|
|
|
|
R5: [nil, nil, "ack"],
|
|
|
|
R6: [nil, nil, "ack"],
|
|
|
|
depAirport: nil,
|
|
|
|
arrAirport: nil,
|
2019-12-31 17:48:23 +00:00
|
|
|
index: nil,
|
|
|
|
computer: nil,
|
|
|
|
new: func(type, id, index, computer) {
|
2019-12-29 21:37:52 +00:00
|
|
|
var lr = {parents:[latRev]};
|
2019-12-31 17:48:23 +00:00
|
|
|
lr.type = type; # 0 = origin 1 = destination 2 = ppos (from waypoint) 3 = generic wpt, 4 = discon
|
2019-12-29 21:37:52 +00:00
|
|
|
lr.id = id;
|
2019-12-31 17:48:23 +00:00
|
|
|
lr.index = index;
|
|
|
|
lr.computer = computer;
|
2019-12-29 21:37:52 +00:00
|
|
|
lr._setupPageWithData();
|
2019-12-31 17:48:23 +00:00
|
|
|
lr._checkTmpy();
|
2019-12-29 21:37:52 +00:00
|
|
|
return lr;
|
|
|
|
},
|
|
|
|
del: func() {
|
|
|
|
return nil;
|
|
|
|
},
|
2019-12-31 17:48:23 +00:00
|
|
|
_checkTmpy: func() {
|
2020-01-05 20:21:28 +00:00
|
|
|
if (fmgc.flightPlanController.temporaryFlag[me.computer]) {
|
2019-12-31 17:48:23 +00:00
|
|
|
me.L6 = [" F-PLN", " TMPY", "yel"];
|
|
|
|
me.arrowsColour[0][5] = "yel";
|
|
|
|
me.R2[2] = "yel";
|
|
|
|
me.R3[2] = "yel";
|
|
|
|
me.R4[2] = "yel";
|
|
|
|
canvas_mcdu.pageSwitch[me.computer].setBoolValue(0);
|
|
|
|
}
|
|
|
|
},
|
2019-12-29 21:37:52 +00:00
|
|
|
_setupPageWithData: func() {
|
|
|
|
if (me.type == 2) {
|
|
|
|
me.title = ["LAT REV", " FROM ", "PPOS"];
|
|
|
|
me.L2 = [" OFFSET", nil, "wht"];
|
|
|
|
me.L3 = [" HOLD", nil, "wht"];
|
|
|
|
me.L6 = [" RETURN", nil, "wht"];
|
|
|
|
me.R1 = ["FIX INFO ", nil, "wht"];
|
2019-12-30 21:24:00 +00:00
|
|
|
me.R2 = ["[ ]°/[ ]°/[ ]", "LL XING/INCR/NO", "blu"];
|
2019-12-29 21:37:52 +00:00
|
|
|
me.arrowsMatrix = [[0, 1, 1, 0, 0, 1], [1, 0, 0, 0, 0, 0]];
|
2019-12-30 21:24:00 +00:00
|
|
|
me.arrowsColour = [["ack", "wht", "wht", "ack", "ack", "wht"], ["wht", "ack", "ack", "ack", "ack", "ack"]];
|
2019-12-29 21:37:52 +00:00
|
|
|
me.fontMatrix = [[0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0]];
|
2019-12-31 17:48:23 +00:00
|
|
|
} elsif (me.type == 4) {
|
|
|
|
me.title = ["LAT REV", " FROM ", "DISCON"];
|
|
|
|
me.R3 = ["[ ]", "NEXT WPT ", "blu"];
|
|
|
|
me.R4 = ["[ ]", "NEW DEST", "blu"];
|
|
|
|
me.L6 = [" RETURN", nil, "wht"];
|
|
|
|
me.arrowsMatrix = [[0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0]];
|
|
|
|
me.arrowsColour = [["ack", "ack", "ack", "ack", "ack", "wht"], ["ack", "ack", "ack", "ack", "ack", "ack"]];
|
|
|
|
me.fontMatrix = [[0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 0, 0]];
|
2019-12-29 21:37:52 +00:00
|
|
|
} else {
|
|
|
|
me.title = ["LAT REV", " FROM ", me.id];
|
|
|
|
|
2019-12-30 21:24:00 +00:00
|
|
|
if (me.type == 0) {
|
|
|
|
if (size(me.id) > 4) {
|
|
|
|
me.depAirport = findAirportsByICAO(left(me.id, 4));
|
|
|
|
} else {
|
|
|
|
me.depAirport = findAirportsByICAO(me.id);
|
|
|
|
}
|
2019-12-29 21:37:52 +00:00
|
|
|
me.subtitle = [dmsToString(sprintf(me.depAirport[0].lat), "lat"), dmsToString(sprintf(me.depAirport[0].lon), "lon")];
|
|
|
|
me.L1 = [" DEPARTURE", nil, "wht"];
|
|
|
|
me.L2 = [" OFFSET", nil, "wht"];
|
|
|
|
me.L6 = [" RETURN", nil, "wht"];
|
|
|
|
me.R1 = ["FIX INFO ", nil, "wht"];
|
2019-12-30 21:24:00 +00:00
|
|
|
me.R2 = ["[ ]°/[ ]°/[ ]", "LL XING/INCR/NO", "blu"];
|
2019-12-31 17:48:23 +00:00
|
|
|
me.R3 = ["[ ]", "NEXT WPT ", "blu"];
|
2019-12-30 21:24:00 +00:00
|
|
|
me.R4 = ["[ ]", "NEW DEST", "blu"];
|
2019-12-29 21:37:52 +00:00
|
|
|
me.arrowsMatrix = [[1, 1, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0]];
|
2019-12-30 21:24:00 +00:00
|
|
|
me.arrowsColour = [["wht", "wht", "ack", "ack", "ack", "wht"], ["wht", "ack", "ack", "ack", "ack", "ack"]];
|
2019-12-29 21:37:52 +00:00
|
|
|
me.fontMatrix = [[0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 0, 0]];
|
|
|
|
} elsif (me.type == 1) {
|
2019-12-30 21:24:00 +00:00
|
|
|
if (size(me.id) > 4) {
|
|
|
|
me.arrAirport = findAirportsByICAO(left(me.id, 4));
|
|
|
|
} else {
|
|
|
|
me.arrAirport = findAirportsByICAO(me.id);
|
|
|
|
}
|
2019-12-29 21:37:52 +00:00
|
|
|
me.subtitle = [dmsToString(sprintf(me.arrAirport[0].lat), "lat"), dmsToString(sprintf(me.arrAirport[0].lon), "lon")];
|
|
|
|
me.L3 = [" ALTN", nil, "wht"];
|
2019-12-30 21:24:00 +00:00
|
|
|
me.L4 = [" ALTN", " ENABLE", "blu"];
|
2019-12-29 21:37:52 +00:00
|
|
|
me.L6 = [" RETURN", nil, "wht"];
|
|
|
|
me.R1 = ["ARRIVAL ", nil, "wht"];
|
2019-12-31 17:48:23 +00:00
|
|
|
me.R3 = ["[ ]", "NEXT WPT ", "blu"];
|
2019-12-29 21:37:52 +00:00
|
|
|
me.arrowsMatrix = [[0, 0, 1, 1, 0, 1], [1, 0, 0, 0, 0, 0]];
|
2019-12-30 21:24:00 +00:00
|
|
|
me.arrowsColour = [["ack", "ack", "wht", "blu", "ack", "wht"], ["wht", "ack", "ack", "ack", "ack", "ack"]];
|
2019-12-29 21:37:52 +00:00
|
|
|
me.fontMatrix = [[0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0]];
|
|
|
|
} elsif (me.type == 3) {
|
|
|
|
if (size(me.id) == 2 or size(me.id) == 3) {
|
|
|
|
me.wpt = findNavaidsByID(me.id);
|
|
|
|
} elsif (size(me.id) == 4) {
|
|
|
|
me.wpt = findAirportsByICAO(me.id);
|
|
|
|
} elsif (size(me.id) == 5) {
|
|
|
|
me.wpt = findFixesByID(me.id);
|
|
|
|
}
|
|
|
|
me.subtitle = [dmsToString(sprintf(me.wpt[0].lat), "lat"), dmsToString(sprintf(me.wpt[0].lon), "lon")];
|
|
|
|
me.L3 = [" HOLD", nil, "wht"];
|
2019-12-30 21:24:00 +00:00
|
|
|
me.L4 = [" ALTN", " ENABLE", "blu"];
|
2019-12-29 21:37:52 +00:00
|
|
|
me.L6 = [" RETURN", nil, "wht"];
|
|
|
|
me.R1 = ["FIX INFO ", nil, "wht"];
|
2019-12-31 17:48:23 +00:00
|
|
|
me.R3 = ["[ ]", "NEXT WPT ", "blu"];
|
2019-12-30 21:24:00 +00:00
|
|
|
me.R4 = ["[ ]", "NEW DEST", "blu"];
|
2019-12-29 21:37:52 +00:00
|
|
|
me.R5 = ["AIRWAYS ", nil, "wht"];
|
|
|
|
me.arrowsMatrix = [[0, 0, 1, 1, 0, 1], [1, 0, 0, 0, 1, 0]];
|
2019-12-30 21:24:00 +00:00
|
|
|
me.arrowsColour = [["ack", "ack", "wht", "blu", "ack", "wht"], ["wht", "ack", "ack", "ack", "wht", "ack"]];
|
2019-12-29 21:37:52 +00:00
|
|
|
me.fontMatrix = [[0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 0, 0]];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2019-12-31 17:48:23 +00:00
|
|
|
makeTmpy: func() {
|
2020-01-05 20:21:28 +00:00
|
|
|
if (!fmgc.flightPlanController.temporaryFlag[me.computer]) {
|
|
|
|
fmgc.flightPlanController.createTemporaryFlightPlan(me.computer);
|
2019-12-31 17:48:23 +00:00
|
|
|
me._checkTmpy();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
nextWpt: func() {
|
|
|
|
me.makeTmpy();
|
|
|
|
me.R3 = [getprop("/MCDU[" ~ me.computer ~ "]/scratchpad"), "NEXT WPT ", "yel"];
|
|
|
|
me.fontMatrix[1][2] = 0;
|
|
|
|
|
|
|
|
# check if it is part of the active f-pln, if so delete intermediate wpts, if not create discontinuiity after it with original wpts
|
|
|
|
if (size(me.R3[0]) == 5) {
|
|
|
|
var fix = findFixesByID(me.R3[0]);
|
2020-01-05 20:21:28 +00:00
|
|
|
if (size(fix) >= 1) {
|
|
|
|
var indexWp = fmgc.flightPlanController.flightplans[me.computer].indexOfWP(fix[0]);
|
2019-12-31 17:48:23 +00:00
|
|
|
if (indexWp == -1) {
|
2020-01-05 20:21:28 +00:00
|
|
|
var _insert = fmgc.flightPlanController.insertFix(me.R3[0], me.index + 1, me.computer);
|
|
|
|
fmgc.flightPlanController.flightplans[me.computer].insertWP(createDiscontinuity(), me.index + 2);
|
|
|
|
fmgc.flightPlanController.flightPlanChanged(me.computer);
|
2019-12-31 17:48:23 +00:00
|
|
|
} else {
|
2020-01-05 20:21:28 +00:00
|
|
|
var numTimesDelete = indexWp - me.index;
|
|
|
|
while (numTimesDelete > 1) {
|
|
|
|
fmgc.flightPlanController.deleteWP(me.index + 1, me.computer.mcdu, 0);
|
|
|
|
numTimesDelete -= 1;
|
2019-12-31 17:48:23 +00:00
|
|
|
}
|
2020-01-05 20:21:28 +00:00
|
|
|
var _insert = 0;
|
2019-12-31 17:48:23 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
var _insert = 1;
|
|
|
|
}
|
|
|
|
} elsif (size(me.R3[0]) == 4) {
|
|
|
|
var airport = findAirportsByICAO(me.R3[0]);
|
2020-01-05 20:21:28 +00:00
|
|
|
if (size(airport) >= 1) {
|
|
|
|
var indexWp = fmgc.flightPlanController.flightplans[me.computer].indexOfWP(fix[0]);
|
2019-12-31 17:48:23 +00:00
|
|
|
if (indexWp == -1) {
|
2020-01-05 20:21:28 +00:00
|
|
|
var _insert = fmgc.flightPlanController.insertArpt(me.R3[0], me.index + 1, me.computer);
|
|
|
|
fmgc.flightPlanController.flightplans[me.computer].insertWP(createDiscontinuity(), me.index + 2);
|
|
|
|
fmgc.flightPlanController.flightPlanChanged(me.computer);
|
2019-12-31 17:48:23 +00:00
|
|
|
} else {
|
2020-01-05 20:21:28 +00:00
|
|
|
var numTimesDelete = indexWp - me.index;
|
|
|
|
while (numTimesDelete > 1) {
|
|
|
|
fmgc.flightPlanController.deleteWP(me.index + 1, me.computer.mcdu, 0);
|
|
|
|
numTimesDelete -= 1;
|
2019-12-31 17:48:23 +00:00
|
|
|
}
|
2020-01-05 20:21:28 +00:00
|
|
|
var _insert = 0;
|
2019-12-31 17:48:23 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
var _insert = 1;
|
|
|
|
}
|
|
|
|
} elsif (size(me.R3[0]) == 3 or size(me.R3[0]) == 2) {
|
|
|
|
var navaid = findNavaidsByID(me.R3[0]);
|
2020-01-05 20:21:28 +00:00
|
|
|
if (size(navaid) >= 1) {
|
|
|
|
var indexWp = fmgc.flightPlanController.flightplans[me.computer].indexOfWP(navaid[0]);
|
2019-12-31 17:48:23 +00:00
|
|
|
if (indexWp == -1) {
|
2020-01-05 20:21:28 +00:00
|
|
|
var _insert = fmgc.flightPlanController.insertNavaid(me.R3[0], me.index + 1, me.computer);
|
|
|
|
fmgc.flightPlanController.flightplans[me.computer].insertWP(createDiscontinuity(), me.index + 2);
|
|
|
|
fmgc.flightPlanController.flightPlanChanged(me.computer);
|
2019-12-31 17:48:23 +00:00
|
|
|
} else {
|
2020-01-05 20:21:28 +00:00
|
|
|
var numTimesDelete = indexWp - me.index;
|
|
|
|
while (numTimesDelete > 1) {
|
|
|
|
fmgc.flightPlanController.deleteWP(me.index + 1, me.computer.mcdu, 0);
|
|
|
|
numTimesDelete -= 1;
|
2019-12-31 17:48:23 +00:00
|
|
|
}
|
2020-01-05 20:21:28 +00:00
|
|
|
var _insert = 0;
|
2019-12-31 17:48:23 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
var _insert = 1;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
formatError(me.computer);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_insert == 1) {
|
|
|
|
notInDataBase(me.computer);
|
|
|
|
} elsif (_insert == 2) {
|
|
|
|
notAllowed(me.computer);
|
|
|
|
} else {
|
|
|
|
setprop("/MCDU[" ~ me.computer ~ "]/scratchpad", "");
|
2020-01-05 20:21:28 +00:00
|
|
|
fmgc.flightPlanController.flightPlanChanged(me.computer);
|
2019-12-31 17:48:23 +00:00
|
|
|
setprop("/MCDU[" ~ me.computer ~ "]/page", "F-PLNA");
|
|
|
|
}
|
|
|
|
},
|
2019-12-29 21:37:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
var dmsToString = func(dms, type) {
|
2019-12-30 21:24:00 +00:00
|
|
|
var degrees = int(dms);
|
|
|
|
var minutes = sprintf("%.1f",abs((dms - degrees) * 60));
|
2019-12-29 21:37:52 +00:00
|
|
|
if (type == "lat") {
|
|
|
|
var sign = degrees >= 0 ? "N" : "S";
|
|
|
|
} else {
|
|
|
|
var sign = degrees >= 0 ? "E" : "W";
|
|
|
|
}
|
2019-12-30 21:24:00 +00:00
|
|
|
return abs(degrees) ~ "g" ~ minutes ~ " " ~ sign;
|
2019-12-29 21:37:52 +00:00
|
|
|
}
|