FMGC: Move F-PLN Code changes to make it work better
This commit is contained in:
parent
ea699ab0cd
commit
862ed64a28
2 changed files with 246 additions and 152 deletions
|
@ -40,6 +40,12 @@ setprop("/MCDUC/colors/yel/r", 0.9333);
|
|||
setprop("/MCDUC/colors/yel/g", 0.9333);
|
||||
setprop("/MCDUC/colors/yel/b", 0.0000);
|
||||
|
||||
var WHITE = [1.0000,1.0000,1.0000];
|
||||
var GREEN = [0.0509,0.7529,0.2941];
|
||||
var BLUE = [0.0901,0.6039,0.7176];
|
||||
var AMBER = [0.7333,0.3803,0.0000];
|
||||
var YELLOW = [0.9333,0.9333,0.0000];
|
||||
|
||||
# Fetch nodes:
|
||||
var ac1 = props.globals.getNode("/systems/electrical/bus/ac1", 1);
|
||||
var ac2 = props.globals.getNode("/systems/electrical/bus/ac2", 1);
|
||||
|
@ -117,17 +123,10 @@ var fplnL3s = [props.globals.getNode("/MCDU[0]/F-PLN/left-3s", 1), props.globals
|
|||
var fplnL4s = [props.globals.getNode("/MCDU[0]/F-PLN/left-4s", 1), props.globals.getNode("/MCDU[1]/F-PLN/left-4s", 1)];
|
||||
var fplnL5s = [props.globals.getNode("/MCDU[0]/F-PLN/left-5s", 1), props.globals.getNode("/MCDU[1]/F-PLN/left-5s", 1)];
|
||||
var fplnL6s = [props.globals.getNode("/MCDU[0]/F-PLN/left-6s", 1), props.globals.getNode("/MCDU[1]/F-PLN/left-6s", 1)];
|
||||
var fpln1c = [props.globals.getNode("/MCDU[0]/F-PLN/line-1c", 1), props.globals.getNode("/MCDU[1]/F-PLN/line-1c", 1)];
|
||||
var fpln2c = [props.globals.getNode("/MCDU[0]/F-PLN/line-2c", 1), props.globals.getNode("/MCDU[1]/F-PLN/line-2c", 1)];
|
||||
var fpln3c = [props.globals.getNode("/MCDU[0]/F-PLN/line-3c", 1), props.globals.getNode("/MCDU[1]/F-PLN/line-3c", 1)];
|
||||
var fpln4c = [props.globals.getNode("/MCDU[0]/F-PLN/line-4c", 1), props.globals.getNode("/MCDU[1]/F-PLN/line-4c", 1)];
|
||||
var fpln5c = [props.globals.getNode("/MCDU[0]/F-PLN/line-5c", 1), props.globals.getNode("/MCDU[1]/F-PLN/line-5c", 1)];
|
||||
var fpln6c = [props.globals.getNode("/MCDU[0]/F-PLN/line-6c", 1), props.globals.getNode("/MCDU[1]/F-PLN/line-6c", 1)];
|
||||
var showFromInd = [props.globals.getNode("MCDU[0]/F-PLN/show-from", 1), props.globals.getNode("MCDU[1]/F-PLN/show-from", 1)];
|
||||
|
||||
# Create Nodes:
|
||||
var pageSwitch = [props.globals.initNode("/MCDU[0]/internal/switch", 0, "BOOL"), props.globals.initNode("/MCDU[1]/internal/switch", 0, "BOOL")];
|
||||
var fplnCSwitch = [props.globals.initNode("/MCDU[0]/internal/fpln-c-switch", 0, "BOOL"), props.globals.initNode("/MCDU[1]/internal/fpln-c-switch", 0, "BOOL")];
|
||||
|
||||
var canvas_MCDU_base = {
|
||||
init: func(canvas_group, file) {
|
||||
|
@ -223,6 +222,7 @@ var canvas_MCDU_base = {
|
|||
if (fplnLineSize >= 1) {
|
||||
fplnl1 = mcdu.MCDULines[i].output[0].getText(i);
|
||||
if (fplnl1 != "") {
|
||||
me["FPLN_L1"].setColor(mcdu.MCDULines[i].output[0].getColor(i));
|
||||
me["FPLN_L1"].setText(fplnl1);
|
||||
me["FPLN_L1"].show();
|
||||
} else {
|
||||
|
@ -235,6 +235,7 @@ var canvas_MCDU_base = {
|
|||
if (fplnLineSize >= 2) {
|
||||
fplnl2 = mcdu.MCDULines[i].output[1].getText(i);
|
||||
if (fplnl2 != "") {
|
||||
me["FPLN_L2"].setColor(mcdu.MCDULines[i].output[1].getColor(i));
|
||||
me["FPLN_L2"].setText(fplnl2);
|
||||
me["FPLN_L2"].show();
|
||||
} else {
|
||||
|
@ -247,6 +248,7 @@ var canvas_MCDU_base = {
|
|||
if (fplnLineSize >= 3) {
|
||||
fplnl3 = mcdu.MCDULines[i].output[2].getText(i);
|
||||
if (fplnl3 != "") {
|
||||
me["FPLN_L3"].setColor(mcdu.MCDULines[i].output[2].getColor(i));
|
||||
me["FPLN_L3"].setText(fplnl3);
|
||||
me["FPLN_L3"].show();
|
||||
} else {
|
||||
|
@ -259,6 +261,7 @@ var canvas_MCDU_base = {
|
|||
if (fplnLineSize >= 4) {
|
||||
fplnl4 = mcdu.MCDULines[i].output[3].getText(i);
|
||||
if (fplnl4 != "") {
|
||||
me["FPLN_L4"].setColor(mcdu.MCDULines[i].output[3].getColor(i));
|
||||
me["FPLN_L4"].setText(fplnl4);
|
||||
me["FPLN_L4"].show();
|
||||
} else {
|
||||
|
@ -271,6 +274,7 @@ var canvas_MCDU_base = {
|
|||
if (fplnLineSize >= 5) {
|
||||
fplnl5 = mcdu.MCDULines[i].output[4].getText(i);
|
||||
if (fplnl5 != "") {
|
||||
me["FPLN_L5"].setColor(mcdu.MCDULines[i].output[4].getColor(i));
|
||||
me["FPLN_L5"].setText(fplnl5);
|
||||
me["FPLN_L5"].show();
|
||||
} else {
|
||||
|
@ -283,6 +287,7 @@ var canvas_MCDU_base = {
|
|||
if (fplnLineSize >= 6) {
|
||||
fplnl6 = mcdu.MCDULines[i].output[5].getText(i);
|
||||
if (fplnl6 != "") {
|
||||
me["FPLN_L6"].setColor(mcdu.MCDULines[i].output[5].getColor(i));
|
||||
me["FPLN_L6"].setText(fplnl6);
|
||||
me["FPLN_L6"].show();
|
||||
} else {
|
||||
|
@ -353,11 +358,6 @@ var canvas_MCDU_base = {
|
|||
me["FPLN_TMPY_group"].hide();
|
||||
me["FPLN_6_group"].show();
|
||||
}
|
||||
|
||||
if (fplnCSwitch[i].getBoolValue() != 1) {
|
||||
me.FPLNcolor(fpln1c[i].getValue(), fpln2c[i].getValue(), fpln3c[i].getValue(), fpln4c[i].getValue(), fpln5c[i].getValue(), fpln6c[i].getValue());
|
||||
fplnCSwitch[i].setBoolValue(1);
|
||||
}
|
||||
} else if (page == "MCDU") {
|
||||
if (!pageSwitch[i].getBoolValue()) {
|
||||
me["Simple"].show();
|
||||
|
@ -1776,14 +1776,6 @@ var canvas_MCDU_base = {
|
|||
me["Simple_C6S"].setColor(getprop("/MCDUC/colors/" ~ f ~ "/r"), getprop("/MCDUC/colors/" ~ f ~ "/g"), getprop("/MCDUC/colors/" ~ f ~ "/b"));
|
||||
}
|
||||
},
|
||||
FPLNcolor: func(a, b, c, d, e, f) {
|
||||
me["FPLN_L1"].setColor(getprop("/MCDUC/colors/" ~ a ~ "/r"), getprop("/MCDUC/colors/" ~ a ~ "/g"), getprop("/MCDUC/colors/" ~ a ~ "/b"));
|
||||
me["FPLN_L2"].setColor(getprop("/MCDUC/colors/" ~ b ~ "/r"), getprop("/MCDUC/colors/" ~ b ~ "/g"), getprop("/MCDUC/colors/" ~ b ~ "/b"));
|
||||
me["FPLN_L3"].setColor(getprop("/MCDUC/colors/" ~ c ~ "/r"), getprop("/MCDUC/colors/" ~ c ~ "/g"), getprop("/MCDUC/colors/" ~ c ~ "/b"));
|
||||
me["FPLN_L4"].setColor(getprop("/MCDUC/colors/" ~ d ~ "/r"), getprop("/MCDUC/colors/" ~ d ~ "/g"), getprop("/MCDUC/colors/" ~ d ~ "/b"));
|
||||
me["FPLN_L5"].setColor(getprop("/MCDUC/colors/" ~ e ~ "/r"), getprop("/MCDUC/colors/" ~ e ~ "/g"), getprop("/MCDUC/colors/" ~ e ~ "/b"));
|
||||
me["FPLN_L6"].setColor(getprop("/MCDUC/colors/" ~ f ~ "/r"), getprop("/MCDUC/colors/" ~ f ~ "/g"), getprop("/MCDUC/colors/" ~ f ~ "/b"));
|
||||
},
|
||||
# 0 = ignore
|
||||
fontLeft: func (a, b, c, d, e, f) {
|
||||
if (a != 0) {
|
||||
|
@ -1989,82 +1981,8 @@ var showMCDU2 = func {
|
|||
|
||||
setlistener("/MCDU[0]/page", func {
|
||||
pageSwitch[0].setBoolValue(0);
|
||||
fplnCSwitch[0].setBoolValue(0);
|
||||
}, 0, 0);
|
||||
|
||||
setlistener("/MCDU[1]/page", func {
|
||||
pageSwitch[1].setBoolValue(0);
|
||||
fplnCSwitch[1].setBoolValue(0);
|
||||
}, 0, 0);
|
||||
|
||||
setlistener("/MCDU[0]/F-PLN/line-1c", func {
|
||||
if (pageProp[0].getValue() == "F-PLNA" or pageProp[0].getValue() == "F-PLNB") {
|
||||
fplnCSwitch[0].setBoolValue(0);
|
||||
}
|
||||
}, 0, 0);
|
||||
|
||||
setlistener("/MCDU[0]/F-PLN/line-2c", func {
|
||||
if (pageProp[0].getValue() == "F-PLNA" or pageProp[0].getValue() == "F-PLNB") {
|
||||
fplnCSwitch[0].setBoolValue(0);
|
||||
}
|
||||
}, 0, 0);
|
||||
|
||||
setlistener("/MCDU[0]/F-PLN/line-3c", func {
|
||||
if (pageProp[0].getValue() == "F-PLNA" or pageProp[0].getValue() == "F-PLNB") {
|
||||
fplnCSwitch[0].setBoolValue(0);
|
||||
}
|
||||
}, 0, 0);
|
||||
|
||||
setlistener("/MCDU[0]/F-PLN/line-4c", func {
|
||||
if (pageProp[0].getValue() == "F-PLNA" or pageProp[0].getValue() == "F-PLNB") {
|
||||
fplnCSwitch[0].setBoolValue(0);
|
||||
}
|
||||
}, 0, 0);
|
||||
|
||||
setlistener("/MCDU[0]/F-PLN/line-5c", func {
|
||||
if (pageProp[0].getValue() == "F-PLNA" or pageProp[0].getValue() == "F-PLNB") {
|
||||
fplnCSwitch[0].setBoolValue(0);
|
||||
}
|
||||
}, 0, 0);
|
||||
|
||||
setlistener("/MCDU[0]/F-PLN/line-6c", func {
|
||||
if (pageProp[0].getValue() == "F-PLNA" or pageProp[0].getValue() == "F-PLNB") {
|
||||
fplnCSwitch[0].setBoolValue(0);
|
||||
}
|
||||
}, 0, 0);
|
||||
|
||||
setlistener("/MCDU[1]/F-PLN/line-1c", func {
|
||||
if (pageProp[1].getValue() == "F-PLNA" or pageProp[1].getValue() == "F-PLNB") {
|
||||
fplnCSwitch[1].setBoolValue(0);
|
||||
}
|
||||
}, 0, 0);
|
||||
|
||||
setlistener("/MCDU[1]/F-PLN/line-2c", func {
|
||||
if (pageProp[1].getValue() == "F-PLNA" or pageProp[1].getValue() == "F-PLNB") {
|
||||
fplnCSwitch[1].setBoolValue(0);
|
||||
}
|
||||
}, 0, 0);
|
||||
|
||||
setlistener("/MCDU[1]/F-PLN/line-3c", func {
|
||||
if (pageProp[1].getValue() == "F-PLNA" or pageProp[1].getValue() == "F-PLNB") {
|
||||
fplnCSwitch[1].setBoolValue(0);
|
||||
}
|
||||
}, 0, 0);
|
||||
|
||||
setlistener("/MCDU[1]/F-PLN/line-4c", func {
|
||||
if (pageProp[1].getValue() == "F-PLNA" or pageProp[1].getValue() == "F-PLNB") {
|
||||
fplnCSwitch[1].setBoolValue(0);
|
||||
}
|
||||
}, 0, 0);
|
||||
|
||||
setlistener("/MCDU[1]/F-PLN/line-5c", func {
|
||||
if (pageProp[1].getValue() == "F-PLNA" or pageProp[1].getValue() == "F-PLNB") {
|
||||
fplnCSwitch[1].setBoolValue(0);
|
||||
}
|
||||
}, 0, 0);
|
||||
|
||||
setlistener("/MCDU[1]/F-PLN/line-6c", func {
|
||||
if (pageProp[1].getValue() == "F-PLNA" or pageProp[1].getValue() == "F-PLNB") {
|
||||
fplnCSwitch[1].setBoolValue(0);
|
||||
}
|
||||
}, 0, 0);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# Airbus A3XX FMGC MCDU Bridge
|
||||
|
||||
# Copyright (c) 2019 Joshua Davidson (it0uchpods)
|
||||
# Copyright (c) 2019 Joshua Davidson (it0uchpods) and Nikolai V. Chr. (Necolatis)
|
||||
|
||||
# Lowercase "g" is a degree symbol in the MCDU font.
|
||||
# wht = white, grn = green, blu = blue, amb = amber, yel = yellow
|
||||
|
@ -16,22 +16,14 @@ var left3s = [props.globals.initNode("MCDU[0]/F-PLN/left-3s", "", "STRING"), pro
|
|||
var left4s = [props.globals.initNode("MCDU[0]/F-PLN/left-4s", "", "STRING"), props.globals.initNode("MCDU[1]/F-PLN/left-4s", "", "STRING")];
|
||||
var left5s = [props.globals.initNode("MCDU[0]/F-PLN/left-5s", "", "STRING"), props.globals.initNode("MCDU[1]/F-PLN/left-5s", "", "STRING")];
|
||||
var left6s = [props.globals.initNode("MCDU[0]/F-PLN/left-6s", "", "STRING"), props.globals.initNode("MCDU[1]/F-PLN/left-6s", "", "STRING")];
|
||||
var line1c = [props.globals.initNode("MCDU[0]/F-PLN/line-1c", "wht", "STRING"), props.globals.initNode("MCDU[1]/F-PLN/line-1c", "wht", "STRING")];
|
||||
var line2c = [props.globals.initNode("MCDU[0]/F-PLN/line-2c", "wht", "STRING"), props.globals.initNode("MCDU[1]/F-PLN/line-2c", "wht", "STRING")];
|
||||
var line3c = [props.globals.initNode("MCDU[0]/F-PLN/line-3c", "wht", "STRING"), props.globals.initNode("MCDU[1]/F-PLN/line-3c", "wht", "STRING")];
|
||||
var line4c = [props.globals.initNode("MCDU[0]/F-PLN/line-4c", "wht", "STRING"), props.globals.initNode("MCDU[1]/F-PLN/line-4c", "wht", "STRING")];
|
||||
var line5c = [props.globals.initNode("MCDU[0]/F-PLN/line-5c", "wht", "STRING"), props.globals.initNode("MCDU[1]/F-PLN/line-5c", "wht", "STRING")];
|
||||
var line6c = [props.globals.initNode("MCDU[0]/F-PLN/line-6c", "wht", "STRING"), props.globals.initNode("MCDU[1]/F-PLN/line-6c", "wht", "STRING")];
|
||||
var showFromInd = [props.globals.initNode("MCDU[0]/F-PLN/show-from", 0, "BOOL"), props.globals.initNode("MCDU[1]/F-PLN/show-from", 0, "BOOL")];
|
||||
|
||||
var TMPY = 5;
|
||||
var MAIN = 6;
|
||||
var num = 0;
|
||||
var page = "";
|
||||
var debug = 0; # Set to 1 to check inner functionality
|
||||
var active_out = [nil, nil, props.globals.getNode("/FMGC/flightplan[2]/active")];
|
||||
var num_out = [props.globals.getNode("/FMGC/flightplan[0]/num"), props.globals.getNode("/FMGC/flightplan[1]/num"), props.globals.getNode("/FMGC/flightplan[2]/num")];
|
||||
var TMPYActive = [props.globals.getNode("/FMGC/internal/tmpy-active[0]"), props.globals.getNode("/FMGC/internal/tmpy-active[1]")];
|
||||
var pageProp = [props.globals.getNode("/MCDU[0]/page", 1), props.globals.getNode("/MCDU[1]/page", 1)];
|
||||
|
||||
# Create text items
|
||||
var StaticText = {
|
||||
|
@ -40,7 +32,7 @@ var StaticText = {
|
|||
in.type = type;
|
||||
return in;
|
||||
},
|
||||
getText: func() {
|
||||
getText: func(i) {
|
||||
if (me.type == "discontinuity") {
|
||||
return "---F-PLN DISCONTINUITY--";
|
||||
} else if (me.type == "fplnEnd") {
|
||||
|
@ -51,8 +43,8 @@ var StaticText = {
|
|||
return "------NO ALTN F-PLN-----";
|
||||
}
|
||||
},
|
||||
getColor: func() {
|
||||
return "wht";
|
||||
getColor: func(i) {
|
||||
return canvas_mcdu.WHITE;
|
||||
},
|
||||
type: nil,
|
||||
pushButtonLeft: func() {
|
||||
|
@ -64,30 +56,28 @@ var StaticText = {
|
|||
};
|
||||
|
||||
var MCDUText = {
|
||||
new: func(wp) {
|
||||
new: func(wp, dest) {
|
||||
var in = {parents:[MCDUText]};
|
||||
in.wp = wp;
|
||||
in.dest = dest;
|
||||
return in;
|
||||
},
|
||||
getText: func(i) {
|
||||
if (TMPYActive[i].getBoolValue()) {
|
||||
left1[i].setValue(fmgc.wpID[i][me.wp].getValue());
|
||||
} else {
|
||||
left1[i].setValue(fmgc.wpID[2][me.wp].getValue());
|
||||
}
|
||||
return me.wp.wp_name;
|
||||
},
|
||||
getColor: func(i) {
|
||||
|
||||
if (TMPYActive[i].getBoolValue()) {
|
||||
if (me.wp == fmgc.arrivalAirportI[i]) {
|
||||
return "wht";
|
||||
if (me.dest) {
|
||||
return canvas_mcdu.WHITE;
|
||||
} else {
|
||||
return "yel";
|
||||
return canvas_mcdu.YELLOW;
|
||||
}
|
||||
} else {
|
||||
if (me.wp == fmgc.arrivalAirportI[2]) {
|
||||
return "wht";
|
||||
if (me.dest) {
|
||||
return canvas_mcdu.WHITE;
|
||||
} else {
|
||||
return "grn";
|
||||
return canvas_mcdu.GREEN;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -104,7 +94,7 @@ var FPLNLineComputer = {
|
|||
new: func(mcdu) {
|
||||
var in = {parents:[FPLNLineComputer]};
|
||||
in.mcdu = mcdu;
|
||||
printf("%d: Line computer created.",in.mcdu);
|
||||
if (debug == 1) printf("%d: Line computer created.", in.mcdu);
|
||||
return in;
|
||||
},
|
||||
index: 0,
|
||||
|
@ -112,38 +102,45 @@ var FPLNLineComputer = {
|
|||
destination: nil,
|
||||
destIndex: nil,
|
||||
planEnd: nil,
|
||||
planNoAlt: nil,
|
||||
lines: nil,
|
||||
output: [],
|
||||
mcdu: nil,
|
||||
enableScroll: 0,
|
||||
updatePlan: func(fpln) {
|
||||
printf("oops, this method is not ready yet");
|
||||
if (debug == 1) printf("oops, this method is not ready yet");
|
||||
# Here you make the line instances and put them into me.planList
|
||||
me.checkIndex();
|
||||
me.updateScroll();
|
||||
},
|
||||
replacePlan: func(fpln, lines, destIndex) {
|
||||
# Here you set another plan, do this when changing plan on display or when destination changes
|
||||
printf("%d: replacePlan called", me.mcdu);
|
||||
if (debug == 1) printf("%d: replacePlan called for %d lines and destIndex %d", me.mcdu, lines, destIndex);
|
||||
me.planList = [];
|
||||
for (var j = 0; j < fpln.getPlanSize(); j += 1) {
|
||||
append(me.planList, MCDUText.new(fpln.getWP(j)));
|
||||
me.dest = 0;
|
||||
if (j == destIndex) {
|
||||
me.dest = 1;
|
||||
}
|
||||
append(me.planList, MCDUText.new(fpln.getWP(j), me.dest));
|
||||
}
|
||||
me.destination = MCDUText.new(fpln.getWP(destIndex));
|
||||
me.destination = MCDUText.new(fpln.getWP(destIndex), 1);
|
||||
if (debug == 1) printf("%d: dest is: %s", me.mcdu, fpln.getWP(destIndex).wp_name);
|
||||
me.planEnd = StaticText.new("fplnEnd");
|
||||
me.planNoAlt = StaticText.new("noAltnFpln");
|
||||
me.destIndex = destIndex;
|
||||
me.initScroll(lines);
|
||||
},
|
||||
initScroll: func(lines) {
|
||||
me.lines = lines;
|
||||
me.index = 0;
|
||||
me.maxItems = size(me.planList) + 2; # + 2 is for end of plan line and no alternate flightplan
|
||||
me.maxItems = size(me.planList) + 2; # + 2 is for end of plan line and altn end of plan.
|
||||
me.enableScroll = lines < me.maxItems;
|
||||
printf("%d: scroll is %d. Number of WP is %d", me.mcdu, me.enableScroll, size(me.planList));
|
||||
if (debug == 1) printf("%d: scroll is %d. Size of plan is %d", me.mcdu, me.enableScroll, size(me.planList));
|
||||
me.updateScroll();
|
||||
},
|
||||
checkIndex: func() {
|
||||
printf("oops, this method is not ready yet");
|
||||
if (debug == 1) printf("oops, this method is not ready yet");
|
||||
if (me.lines == MAIN) {
|
||||
me.extra = 2;
|
||||
} else {
|
||||
|
@ -155,70 +152,249 @@ var FPLNLineComputer = {
|
|||
me.index = size(planList) + me.extra + size(planList) - me.lines - 1;
|
||||
}
|
||||
},
|
||||
scrollDown: func() {
|
||||
printf("%d: scroll down", me.mcdu);
|
||||
scrollDown: func() { # Scroll Up in Thales Manual
|
||||
if (debug == 1) printf("%d: scroll down", me.mcdu);
|
||||
me.extra = 1;
|
||||
if (!me.enableScroll) {
|
||||
me.index = 0;
|
||||
} else {
|
||||
me.index += 1;
|
||||
if (me.index > size(planList)) {
|
||||
if (me.index > size(me.planList) + 1) {
|
||||
me.index = 0;
|
||||
}
|
||||
}
|
||||
me.updateScroll();
|
||||
},
|
||||
scrollUp: func() {
|
||||
printf("%d: scroll up", me.mcdu);
|
||||
scrollUp: func() { # Scroll Down in Thales Manual
|
||||
if (debug == 1) printf("%d: scroll up", me.mcdu);
|
||||
me.extra = 1;
|
||||
if (!me.enableScroll) {
|
||||
me.index = 0;
|
||||
} else {
|
||||
me.index -= 1;
|
||||
if (me.index < 0) {
|
||||
me.index = size(planList);
|
||||
me.index = size(me.planList) + 1;
|
||||
}
|
||||
}
|
||||
me.updateScroll();
|
||||
},
|
||||
updateScroll: func() {
|
||||
me.output = [];
|
||||
if (me.index <= size(me.planList)) {
|
||||
if (me.index <= size(me.planList)+1) {
|
||||
var i = 0;
|
||||
printf("%d: updating display from index %d", me.mcdu, me.index);
|
||||
for (i = me.index; i < math.min(size(me.planList), i + 5); i += 1) {
|
||||
me.realIndex = me.index-1;
|
||||
if (debug == 1) printf("%d: updating display from index %d", me.mcdu, me.realIndex);
|
||||
for (i = me.index; i < math.min(size(me.planList), me.index + 5); i += 1) {
|
||||
append(me.output, me.planList[i]);
|
||||
me.realIndex = i;
|
||||
}
|
||||
printf("%d: populated until wp index %d", me.mcdu,i);
|
||||
if (i < me.destIndex and me.lines == MAIN) {
|
||||
if (debug == 1) printf("%d: populated until wp index %d", me.mcdu,me.realIndex);
|
||||
if (me.realIndex < me.destIndex and me.lines == MAIN) {
|
||||
# Destination has not been shown yet, now its time (if we show 6 lines)
|
||||
append(me.output, me.destination);
|
||||
printf("%d: added dest at bottom for total of %d lines", me.mcdu, size(me.output));
|
||||
if (debug == 1) printf("%d: added dest at bottom for total of %d lines", me.mcdu, size(me.output));
|
||||
return;
|
||||
} else if (size(me.output) < me.lines and (i == size(me.planList) - 1 or (me.enableScroll and i == size(me.planList)))) {
|
||||
# Show the end of plan
|
||||
append(me.output, me.planEnd);
|
||||
printf("%d: added end", me.mcdu);
|
||||
if (me.enableScroll and size(me.output) < me.lines) {
|
||||
# We start wrapping
|
||||
for (var j = 0; size(me.output) < me.lines; j += 1) {
|
||||
append(me.output, me.planList[j]);
|
||||
} else if (size(me.output) < me.lines) {
|
||||
for (i = me.realIndex+1; size(me.output) < me.lines and i < size(me.planList); i += 1) {
|
||||
append(me.output, me.planList[i]);
|
||||
me.realIndex = i;
|
||||
}
|
||||
if (debug == 1) printf("%d: populated after until wp index %d", me.mcdu,me.realIndex);
|
||||
if (size(me.output) < me.lines) {
|
||||
if (me.realIndex == size(me.planList)-1) {
|
||||
# Show the end of plan
|
||||
append(me.output, me.planEnd);
|
||||
me.realIndex += 1;
|
||||
if (debug == 1) printf("%d: added end, wp index=%d", me.mcdu, me.realIndex);
|
||||
}
|
||||
if (size(me.output) < me.lines and (me.realIndex == size(me.planList))) {
|
||||
append(me.output, me.planNoAlt);
|
||||
me.realIndex += 1;
|
||||
if (debug == 1) printf("%d: added no-alt, wp index=%d", me.mcdu,me.realIndex);
|
||||
if (me.enableScroll and size(me.output) < me.lines) {
|
||||
# We start wrapping
|
||||
for (var j = 0; size(me.output) < me.lines; j += 1) {
|
||||
append(me.output, me.planList[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
printf("%d: %d lines", me.mcdu, size(me.output));
|
||||
if (debug == 1) printf("%d: %d lines", me.mcdu, size(me.output));
|
||||
},
|
||||
};
|
||||
|
||||
var MCDULines = [FPLNLineComputer.new(0), FPLNLineComputer.new(1)];
|
||||
|
||||
# For testing purposes only -- do not touch!
|
||||
var test = func {
|
||||
var fp = createFlightplan(getprop("sim/aircraft-dir")~"/plan.gpx");
|
||||
var desti = int(fp.getPlanSize()*0.5);
|
||||
MCDULines[0].replacePlan(fp,6,desti);
|
||||
print("Display:");
|
||||
foreach(line;MCDULines[0].output) {
|
||||
printf("line: %s",line.getText(0));
|
||||
}
|
||||
print("down");MCDULines[0].scrollDown();
|
||||
foreach(line;MCDULines[0].output) {
|
||||
printf("line: %s",line.getText(0));
|
||||
}
|
||||
print("down");MCDULines[0].scrollDown();
|
||||
foreach(line;MCDULines[0].output) {
|
||||
printf("line: %s",line.getText(0));
|
||||
}
|
||||
print("down");MCDULines[0].scrollDown();
|
||||
foreach(line;MCDULines[0].output) {
|
||||
printf("line: %s",line.getText(0));
|
||||
}
|
||||
print("down");MCDULines[0].scrollDown();
|
||||
foreach(line;MCDULines[0].output) {
|
||||
printf("line: %s",line.getText(0));
|
||||
}
|
||||
print("down");MCDULines[0].scrollDown();
|
||||
foreach(line;MCDULines[0].output) {
|
||||
printf("line: %s",line.getText(0));
|
||||
}
|
||||
print("down");MCDULines[0].scrollDown();
|
||||
foreach(line;MCDULines[0].output) {
|
||||
printf("line: %s",line.getText(0));
|
||||
}
|
||||
print("down");MCDULines[0].scrollDown();
|
||||
foreach(line;MCDULines[0].output) {
|
||||
printf("line: %s",line.getText(0));
|
||||
}
|
||||
print("down");MCDULines[0].scrollDown();
|
||||
foreach(line;MCDULines[0].output) {
|
||||
printf("line: %s",line.getText(0));
|
||||
}
|
||||
print("down");MCDULines[0].scrollDown();
|
||||
foreach(line;MCDULines[0].output) {
|
||||
printf("line: %s",line.getText(0));
|
||||
}
|
||||
print("down");MCDULines[0].scrollDown();
|
||||
foreach(line;MCDULines[0].output) {
|
||||
printf("line: %s",line.getText(0));
|
||||
}
|
||||
print("down");MCDULines[0].scrollDown();
|
||||
foreach(line;MCDULines[0].output) {
|
||||
printf("line: %s",line.getText(0));
|
||||
}
|
||||
print("down");MCDULines[0].scrollDown();
|
||||
foreach(line;MCDULines[0].output) {
|
||||
printf("line: %s",line.getText(0));
|
||||
}
|
||||
print("down");MCDULines[0].scrollDown();
|
||||
foreach(line;MCDULines[0].output) {
|
||||
printf("line: %s",line.getText(0));
|
||||
}
|
||||
print("down");MCDULines[0].scrollDown();
|
||||
foreach(line;MCDULines[0].output) {
|
||||
printf("line: %s",line.getText(0));
|
||||
}
|
||||
print("down");MCDULines[0].scrollDown();
|
||||
foreach(line;MCDULines[0].output) {
|
||||
printf("line: %s",line.getText(0));
|
||||
}
|
||||
print("down");MCDULines[0].scrollDown();
|
||||
foreach(line;MCDULines[0].output) {
|
||||
printf("line: %s",line.getText(0));
|
||||
}
|
||||
print("down");MCDULines[0].scrollDown();
|
||||
foreach(line;MCDULines[0].output) {
|
||||
printf("line: %s",line.getText(0));
|
||||
}
|
||||
print("down");MCDULines[0].scrollDown();
|
||||
foreach(line;MCDULines[0].output) {
|
||||
printf("line: %s",line.getText(0));
|
||||
}
|
||||
print("down");MCDULines[0].scrollDown();
|
||||
foreach(line;MCDULines[0].output) {
|
||||
printf("line: %s",line.getText(0));
|
||||
}
|
||||
print("down");MCDULines[0].scrollDown();
|
||||
foreach(line;MCDULines[0].output) {
|
||||
printf("line: %s",line.getText(0));
|
||||
}
|
||||
print("down");MCDULines[0].scrollDown();
|
||||
foreach(line;MCDULines[0].output) {
|
||||
printf("line: %s",line.getText(0));
|
||||
}
|
||||
print("down");MCDULines[0].scrollDown();
|
||||
foreach(line;MCDULines[0].output) {
|
||||
printf("line: %s",line.getText(0));
|
||||
}
|
||||
print("down");MCDULines[0].scrollDown();
|
||||
foreach(line;MCDULines[0].output) {
|
||||
printf("line: %s",line.getText(0));
|
||||
}
|
||||
print("down");MCDULines[0].scrollDown();
|
||||
foreach(line;MCDULines[0].output) {
|
||||
printf("line: %s",line.getText(0));
|
||||
}
|
||||
print("down");MCDULines[0].scrollDown();
|
||||
foreach(line;MCDULines[0].output) {
|
||||
printf("line: %s",line.getText(0));
|
||||
}
|
||||
print("up");MCDULines[0].scrollUp();
|
||||
foreach(line;MCDULines[0].output) {
|
||||
printf("line: %s",line.getText(0));
|
||||
}
|
||||
print("up");MCDULines[0].scrollUp();
|
||||
foreach(line;MCDULines[0].output) {
|
||||
printf("line: %s",line.getText(0));
|
||||
}
|
||||
print("up");MCDULines[0].scrollUp();
|
||||
foreach(line;MCDULines[0].output) {
|
||||
printf("line: %s",line.getText(0));
|
||||
}
|
||||
print("up");MCDULines[0].scrollUp();
|
||||
foreach(line;MCDULines[0].output) {
|
||||
printf("line: %s",line.getText(0));
|
||||
}
|
||||
print("up");MCDULines[0].scrollUp();
|
||||
foreach(line;MCDULines[0].output) {
|
||||
printf("line: %s",line.getText(0));
|
||||
}
|
||||
print("up");MCDULines[0].scrollUp();
|
||||
foreach(line;MCDULines[0].output) {
|
||||
printf("line: %s",line.getText(0));
|
||||
}
|
||||
print("up");MCDULines[0].scrollUp();
|
||||
foreach(line;MCDULines[0].output) {
|
||||
printf("line: %s",line.getText(0));
|
||||
}
|
||||
print("up");MCDULines[0].scrollUp();
|
||||
foreach(line;MCDULines[0].output) {
|
||||
printf("line: %s",line.getText(0));
|
||||
}
|
||||
print("up");MCDULines[0].scrollUp();
|
||||
foreach(line;MCDULines[0].output) {
|
||||
printf("line: %s",line.getText(0));
|
||||
}
|
||||
print("up");MCDULines[0].scrollUp();
|
||||
foreach(line;MCDULines[0].output) {
|
||||
printf("line: %s",line.getText(0));
|
||||
}
|
||||
print("up");MCDULines[0].scrollUp();
|
||||
foreach(line;MCDULines[0].output) {
|
||||
printf("line: %s",line.getText(0));
|
||||
}
|
||||
print("up");MCDULines[0].scrollUp();
|
||||
foreach(line;MCDULines[0].output) {
|
||||
printf("line: %s",line.getText(0));
|
||||
}
|
||||
}
|
||||
|
||||
#test();
|
||||
|
||||
var slewFPLN = func(d, i) { # Scrolling function. d is -1 or 1 for direction, and i is instance.
|
||||
if (d == 1) {
|
||||
MCDULines[i].scrollUp();
|
||||
} else if (d == 0) {
|
||||
MCDULines[i].scrollDown();
|
||||
MCDULines[i].scrollDown(); # Scroll Up in Thales Manual
|
||||
print("scrollDown()");
|
||||
} else if (d == -1) {
|
||||
MCDULines[i].scrollUp(); # Scroll Down in Thales Manual
|
||||
print("scrollUp()");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Reference in a new issue