FMGC: Many improvements and updates to F-PLN

This commit is contained in:
Joshua Davidson 2019-02-19 21:52:02 -07:00
parent f84f9f3516
commit 238663b9db
2 changed files with 53 additions and 48 deletions

View file

@ -147,27 +147,27 @@ var FPLNLineComputer = {
},
replacePlan: func(fplnID, lines, firstLineIndex) {
# Here you set another plan, do this when changing plan on display or when destination changes
if (debug == 1) printf("%d: replacePlan called for %d lines and me.destIndex %d", me.mcdu, lines, destIndex);
if (debug == 1) printf("%d: replacePlan called for %d lines and firstLine %d", me.mcdu, lines, firstLineIndex);
var fpln = nil;
me.planList = [];
if (!fmgc.active_out[2].getBoolValue()) {
fpln = createFlightplan();
me.destIndex = -1;
me.destination = nil;
} else {
fpln = fmgc.fp[fplnID]; # Get the Nasal Flightplan
me.destIndex = fmgc.arrivalAirportI[fplnID];
me.destination = FPLNText.new(fpln.getWP(me.destIndex), 1, fplnID, me.destIndex);
}
me.planList = [];
for (var j = 0; j < fpln.getPlanSize(); j += 1) {
me.dest = 0;
if (j == me.destIndex) {
me.dest = 1;
for (var j = 0; j < fpln.getPlanSize(); j += 1) {
me.dest = 0;
if (j == me.destIndex) {
me.dest = 1;
}
append(me.planList, FPLNText.new(fpln.getWP(j), me.dest, fplnID, j));
}
append(me.planList, FPLNText.new(fpln.getWP(j), me.dest, fplnID, j));
}
if (debug == 1) printf("%d: dest is: %s", me.mcdu, fpln.getWP(me.destIndex).wp_name);
if (debug == 1) printf("%d: dest is: %s", me.mcdu, fpln.getWP(me.destIndex).wp_name);
}
me.index = firstLineIndex;
me.lines = lines;
me.initScroll();
@ -175,20 +175,17 @@ var FPLNLineComputer = {
initScroll: func() {
me.maxItems = size(me.planList) + 2; # + 2 is for end of plan line and altn end of plan.
me.enableScroll = me.lines < me.maxItems;
me.checkIndex();
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 (me.lines == MAIN) {
me.extra = 2;
} else {
me.extra = 1
}
if (size(planList) < MAIN) {
if (!me.enableScroll) {
me.index = 0;
} else if (me.index > size(planList) + me.extra + size(planList) - me.lines - 1) {
me.index = size(planList) + me.extra + size(planList) - me.lines - 1;
if (debug == 1) printf("%d: index forced to 0",me.mcdu);
} elsif (me.index > size(me.planList) + 2 - me.lines) {
me.index = size(me.planList) + 2 - me.lines;
if (debug == 1) printf("%d: index forced to %d",me.mcdu,me.index);
}
},
scrollDown: func() { # Scroll Up in Thales Manual
@ -267,6 +264,31 @@ var FPLNLineComputer = {
var FPLNLines = [FPLNLineComputer.new(0), FPLNLineComputer.new(1)];
clearFPLNComputer(); # Just in case, we have it in the clear state.
var slewFPLN = func(d, i) { # Scrolling function. d is -1 or 1 for direction, and i is instance.
if (d == 1) {
FPLNLines[i].scrollDown(); # Scroll Up in Thales Manual
} else if (d == -1) {
FPLNLines[i].scrollUp(); # Scroll Down in Thales Manual
}
}
# Button and Inputs
var FPLNButton = func(s, key, i) {
if (s == "L") {
} else if (s == "R") {
}
}
var notInDataBase = func(i) {
if (getprop("/MCDU[" ~ i ~ "]/scratchpad") != "NOT IN DATABASE") {
setprop("/MCDU[" ~ i ~ "]/last-scratchpad", getprop("/MCDU[" ~ i ~ "]/scratchpad"));
}
setprop("/MCDU[" ~ i ~ "]/scratchpad-msg", 1);
setprop("/MCDU[" ~ i ~ "]/scratchpad", "NOT IN DATABASE");
}
# For testing purposes only -- do not touch!
var test = func {
var fp = createFlightplan(getprop("sim/aircraft-dir")~"/plan.gpx");
@ -427,28 +449,3 @@ var test = func {
}
#test();
var slewFPLN = func(d, i) { # Scrolling function. d is -1 or 1 for direction, and i is instance.
if (d == 1) {
FPLNLines[i].scrollDown(); # Scroll Up in Thales Manual
} else if (d == -1) {
FPLNLines[i].scrollUp(); # Scroll Down in Thales Manual
}
}
# Button and Inputs
var FPLNButton = func(s, key, i) {
if (s == "L") {
} else if (s == "R") {
}
}
var notInDataBase = func(i) {
if (getprop("/MCDU[" ~ i ~ "]/scratchpad") != "NOT IN DATABASE") {
setprop("/MCDU[" ~ i ~ "]/last-scratchpad", getprop("/MCDU[" ~ i ~ "]/scratchpad"));
}
setprop("/MCDU[" ~ i ~ "]/scratchpad-msg", 1);
setprop("/MCDU[" ~ i ~ "]/scratchpad", "NOT IN DATABASE");
}

View file

@ -78,18 +78,18 @@ var flightplan = {
},
initTempFP: func(f, n) { # f is temp, n is active
fp[f] = fp[n].clone();
me.checkWPOutputs(f);
TMPYActive[f].setBoolValue(1);
me.checkWPOutputs(f);
},
executeTempFP: func(f, n) { # f is temp, n is active
fp[n] = fp[f].clone();
me.checkWPOutputs(n);
TMPYActive[f].setBoolValue(0);
if (f == 0) {
me.reset0();
} else if (f == 1) {
me.reset1();
}
me.checkWPOutputs(n);
},
updateARPT: func(dep, arr, n) {
if (n == 2) { # Which flightplan?
@ -173,6 +173,14 @@ var flightplan = {
append(wpCoursePrev[n], props.globals.initNode("/FMGC/flightplan[" ~ n ~ "]/wp[" ~ counter ~ "]/course-from-prev", 0, "DOUBLE"));
append(wpDistancePrev[n], props.globals.initNode("/FMGC/flightplan[" ~ n ~ "]/wp[" ~ counter ~ "]/distance-from-prev", 0, "DOUBLE"));
}
me.outputProps(); # Make sure everything is updated before we update the MCDUs.
for (var i = 0; i < 2; i += 1) { # Update the 2 MCDUs
if (n == 0 or n == 1) {
mcdu.FPLNLines[i].replacePlan(n, mcdu.TMPY, mcdu.FPLNLines[i].index);
} else {
mcdu.FPLNLines[i].replacePlan(n, mcdu.MAIN, mcdu.FPLNLines[i].index);
}
}
canvas_nd.A3XXRouteDriver.triggerSignal("fp-added"); # Update the NDs
},
outputProps: func() {