1
0
Fork 0

Prevent f-pln crash on init, basic HOLD pattern page

This commit is contained in:
Jonathan Redpath 2022-01-26 12:10:27 +00:00
parent 4383b3bd8e
commit f04154206b
2 changed files with 84 additions and 32 deletions

View file

@ -819,7 +819,9 @@ var flightPlanController = {
if (me.currentToWptIndex.getValue() < 1) { if (me.currentToWptIndex.getValue() < 1) {
var errs = []; var errs = [];
call(func { call(func {
me.currentToWptIndex.setValue(1); if (me.flightplans[2].getWP(1).id != "DISCONTINUITY") {
me.currentToWptIndex.setValue(1);
}
}, nil, nil, nil, errs); }, nil, nil, nil, errs);
if (size(errs) != 0) { debug.printerror(errs); } if (size(errs) != 0) { debug.printerror(errs); }
} }

View file

@ -39,38 +39,50 @@ var holdPage = {
_setupPageWithData: func() { _setupPageWithData: func() {
me.title = ["HOLD", " AT ", me.waypoint.wp_name]; me.title = ["HOLD", " AT ", me.waypoint.wp_name];
me.titleColour = "wht"; me.titleColour = "wht";
me.arrowsMatrix = [[0, 0, 0, 0, 0, 1], [1, 1, 0, 0, 0, 0]]; me.arrowsMatrix = [[0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0]];
me.arrowsColour = [["ack", "ack", "ack", "ack", "ack", "wht"], ["blu", "blu", "ack", "ack", "ack", "ack"]]; me.arrowsColour = [["ack", "ack", "ack", "ack", "ack", "wht"], ["blu", "blu", "ack", "ack", "ack", "ack"]];
if (me.waypoint.fly_type == "Hold") { if (me.waypoint.fly_type == "Hold") {
me.makeTmpy(); me.R1 = ["COMPUTED ", nil, "wht"];
me.L1 = [sprintf("%03.0f°", me.waypoint.hold_inbound_radial), "INB CRS", "blu"]; me.R2 = ["DATABASE ", nil, "blu"];
me.arrowsColour[1][0] = "wht";
if (me.waypoint.hold_is_left_handed) { me.arrowsColour[1][1] = "blu";
me.L2 = ["L", " TURN", "blu"]; me.arrowsMatrix[1][0] = 1;
} else {
me.L2 = ["R", " TURN", "blu"];
}
if (me.waypoint.hold_is_distance) {
me.L3 = [" -.-/" ~ me.waypoint.hold_time_or_distance, "TIME/DIST", "blu"];
} else {
me.L3 = [sprintf("%3.1f", (me.waypoint.hold_time_or_distance / 60)) ~ "/----", "TIME/DIST", "blu"];
}
me.R1 = ["COMPUTED ", nil, "blu"];
me.R2 = ["DATABASE ", nil, "yel"];
me.arrowsMatrix[1][1] = 0; me.arrowsMatrix[1][1] = 0;
} else { } else {
me.L1 = ["100°", "INB CRS", "blu"]; # waypoint is a leg, figure out how to handle it
me.L2 = ["R", " TURN", "blu"]; return;
me.waypoint.hold_count = 999;
me.waypoint.hold_is_left_handed = 0;
me.waypoint.hold_is_distance = 0;
me.waypoint.hold_inbound_radial = me.waypoint.leg_bearing;
if (pts.Instrumentation.Altimeter.indicatedFt.getValue() >= 14000) { if (pts.Instrumentation.Altimeter.indicatedFt.getValue() >= 14000) {
me.L3 = ["1.5/----", "TIME/DIST", "blu"]; me.waypoint.hold_time_or_distance = 90;
} else { } else {
me.L3 = ["1.0/----", "TIME/DIST", "blu"]; me.waypoint.hold_time_or_distance = 60;
} }
me.R1 = ["COMPUTED ", nil, "blu"];
me.R2 = ["DATABASE ", nil, "blu"]; me.R1 = ["COMPUTED ", nil, "yel"];
me.R2 = ["DATABASE ", nil, "wht"];
me.arrowsColour[1][0] = "yel";
me.arrowsColour[1][1] = "wht";
me.arrowsMatrix[1][0] = 0;
me.arrowsMatrix[1][1] = 1;
} }
me.L6 = [" RETURN", nil, "wht"];
me.L1 = [sprintf("%03.0f°", me.waypoint.hold_inbound_radial), "INB CRS", "yel"];
if (me.waypoint.hold_is_left_handed) {
me.L2 = ["L", " TURN", "blu"];
} else {
me.L2 = ["R", " TURN", "blu"];
}
if (me.waypoint.hold_is_distance) {
me.L3 = [" -.-/" ~ me.waypoint.hold_time_or_distance, "TIME/DIST", "blu"];
} else {
me.L3 = [sprintf("%3.1f", (me.waypoint.hold_time_or_distance / 60)) ~ "/----", "TIME/DIST", "blu"];
}
me.C4 = ["LAST EXIT", nil, "wht"]; me.C4 = ["LAST EXIT", nil, "wht"];
me.C5 = ["---- ---.-", "UTC FUEL", "wht"]; me.C5 = ["---- ---.-", "UTC FUEL", "wht"];
canvas_mcdu.pageSwitch[me.computer].setBoolValue(0); canvas_mcdu.pageSwitch[me.computer].setBoolValue(0);
@ -82,23 +94,61 @@ var holdPage = {
}, },
updateTmpy: func() { updateTmpy: func() {
if (fmgc.flightPlanController.temporaryFlag[me.computer]) { if (fmgc.flightPlanController.temporaryFlag[me.computer]) {
me.L1[2] = "yel";
me.L2[2] = "yel";
me.L3[2] = "yel";
me.L6 = [" F-PLN", " TMPY", "yel"]; me.L6 = [" F-PLN", " TMPY", "yel"];
me.R6 = ["INSERT ", " TMPY", "yel"]; me.R6 = ["INSERT ", " TMPY", "yel"];
me.arrowsColour[0][5] = "yel"; me.arrowsColour[0][5] = "yel";
me.titleColour = "yel"; me.titleColour = "yel";
canvas_mcdu.pageSwitch[me.computer].setBoolValue(0); canvas_mcdu.pageSwitch[me.computer].setBoolValue(0);
} else { } else {
me.L1[2] = "blu";
me.L2[2] = "blu";
me.L3[2] = "blu";
me.L6 = [" RETURN", nil, "wht"]; me.L6 = [" RETURN", nil, "wht"];
me.R6 = [nil, nil, "ack"]; me.R6 = [nil, nil, "ack"];
me.arrowsColour[0][5] = "wht"; me.arrowsColour[0][5] = "wht";
me.titleColour = "wht"; me.titleColour = "wht";
canvas_mcdu.pageSwitch[me.computer].setBoolValue(0); canvas_mcdu.pageSwitch[me.computer].setBoolValue(0);
} }
} },
pushbuttonLeft: func(index) {
me.scratchpad = mcdu_scratchpad.scratchpads[me.computer].scratchpad;
if (index == 1) {
if (size(me.scratchpad) <= 3 and num(me.scratchpad) != nil) {
me.waypoint.hold_inbound_radial = me.scratchpad;
} else {
mcdu_message(me.computer, "NOT ALLOWED");
}
} else if (index == 2) {
if (me.scratchpad == "L") {
me.waypoint.hold_is_left_handed = 1;
} elsif (me.scratchpad == "R") {
me.waypoint.hold_is_left_handed = 0;
} else {
mcdu_message(me.computer, "NOT ALLOWED");
}
} elsif (index == 3) {
if (num(me.scratchpad) != nil) {
me.waypoint.hold_time_or_distance = me.scratchpad;
} else {
mcdu_message(me.computer, "NOT ALLOWED");
}
} elsif (index == 6) {
if (fmgc.flightPlanController.temporaryFlag[me.computer]) {
setprop("/MCDU[" ~ me.computer ~ "]/page", "F-PLNA");
} else {
setprop("/MCDU[" ~ me.computer ~ "]/page", "LATREV");
}
}
},
pushbuttonRight: func(index) {
me.scratchpad = mcdu_scratchpad.scratchpads[me.computer].scratchpad;
if (size(me.scratchpad) != 0) {
mcdu_message(me.computer, "NOT ALLOWED");
} else {
if (index == 6) {
if (fmgc.flightPlanController.temporaryFlag[me.computer]) {
setprop("/MCDU[" ~ me.computer ~ "]/page", "F-PLNA");
} else {
mcdu_message(me.computer, "NOT ALLOWED");
}
}
}
},
}; };