1
0
Fork 0

Merge branch 'dev' into fuel-prediction

This commit is contained in:
legoboyvdlp R 2020-05-21 19:22:25 +01:00
commit 8fcb2f83d8
13 changed files with 896 additions and 164 deletions

View file

@ -4000,6 +4000,7 @@
<file>Aircraft/A320-family/Nasal/FMGC/FCU.nas</file>
</fcu>
<fmgc>
<file>Aircraft/A320-family/Nasal/FMGC/flightplan-waypoints.nas</file>
<file>Aircraft/A320-family/Nasal/FMGC/flightplan.nas</file>
<file>Aircraft/A320-family/Nasal/FMGC/FMGC.nas</file>
<file>Aircraft/A320-family/Nasal/FMGC/FMGC-b.nas</file>
@ -4014,6 +4015,7 @@
<file>Aircraft/A320-family/Nasal/MCDU/ARRIVAL.nas</file> <!-- dynamic page - init before MCDU -->
<file>Aircraft/A320-family/Nasal/MCDU/AIRWAYS.nas</file> <!-- dynamic page - init before MCDU -->
<file>Aircraft/A320-family/Nasal/MCDU/CLOSESTAIRPORT.nas</file> <!-- dynamic page - init before MCDU -->
<file>Aircraft/A320-family/Nasal/MCDU/PILOTWAYPOINT.nas</file> <!-- dynamic page - init before MCDU -->
<file>Aircraft/A320-family/Nasal/MCDU/HOLD.nas</file> <!-- dynamic page - init before MCDU -->
<file>Aircraft/A320-family/Nasal/MCDU/F-PLN.nas</file> <!-- dynamic page - init before MCDU -->
<file>Aircraft/A320-family/Nasal/MCDU/MCDU.nas</file>

View file

@ -17,6 +17,7 @@ var myHold = [nil, nil];
var myAirways = [nil, nil];
var myDuplicate = [nil, nil];
var myClosestAirport = [nil, nil];
var myPilotWP = [nil, nil];
var default = "BoeingCDU-Large.ttf";
var symbol = "helvetica_medium.txf";
var normal = 70;
@ -740,7 +741,18 @@ var canvas_MCDU_base = {
me["FUELPRED"].hide();
me["PROG"].hide();
me["PERFTO"].hide();
me["arrowsDepArr"].hide();
me["arrowsDepArr"].show();
me["arrow1L"].hide();
me["arrow2L"].hide();
me["arrow3L"].hide();
me["arrow4L"].hide();
me["arrow5L"].hide();
me["arrow1R"].hide();
me["arrow2R"].hide();
me["arrow3R"].hide();
me["arrow4R"].hide();
me["arrow5R"].show();
me["arrow5R"].setColor(getprop("/MCDUC/colors/blu/r"),getprop("/MCDUC/colors/blu/g"),getprop("/MCDUC/colors/blu/b"));
me["PERFAPPR"].hide();
me["PERFGA"].hide();
me["Simple_Title"].show();
@ -755,8 +767,8 @@ var canvas_MCDU_base = {
me["Simple_L0S"].hide();
me.showLeftS(1, 1, 1, -1, 1, 1);
me.showLeftArrow(-1, -1, 1, -1, -1, -1);
me.showRight(-1, 1, -1, -1, -1, 1);
me.showRightS(-1, -1, -1, -1, -1, 1);
me.showRight(-1, 1, -1, 1, 1, 1);
me.showRightS(-1, -1, -1, 1, 1, 1);
me.showRightArrow(-1, -1, -1, -1, -1, 1);
me["Simple_C3B"].hide();
me["Simple_C4B"].hide();
@ -767,31 +779,68 @@ var canvas_MCDU_base = {
me.fontRightS(default, default, default, default, default, default);
me.fontSizeLeft(normal, normal, normal, normal, small, normal);
me.fontSizeRight(normal, normal, normal, normal, normal, normal);
me.fontSizeRight(normal, normal, normal, small, normal, normal);
me.colorLeft("grn", "blu", "blu", "wht", "blu", "grn");
me.colorLeftS("wht", "wht", "wht", "wht", "wht", "wht");
me.colorLeftArrow("wht", "blu", "blu", "wht", "wht", "wht");
me.colorRight("wht", "grn", "wht", "wht", "wht", "wht");
me.colorRightS("wht", "wht", "wht", "wht", "wht", "wht");
me.colorRight("wht", "grn", "wht", "grn", "blu", "wht");
me.colorRightS("wht", "wht", "wht", "wht", "grn", "wht");
me.colorRightArrow("wht", "wht", "wht", "wht", "wht", "wht");
me["Simple_L5"].setText("[ ]");
me["Simple_L6"].setText("+4.0/+0.0");
me["Simple_L1S"].setText(" ENG");
me["Simple_L2S"].setText(" ACTIVE NAV DATA BASE");
me["Simple_L3S"].setText(" SECOND NAV DATA BASE");
me["Simple_L5S"].setText("CHG CODE");
me["Simple_L6S"].setText("IDLE/PERF");
me["Simple_R6"].setText("STATUS/XLOAD ");
me["Simple_R6S"].setText("SOFTWARE ");
me["Simple_R4S"].setText("PILOT STORED ");
me["Simple_R4"].setText("00RTES 00RWYS ");
pageSwitch[i].setBoolValue(1);
}
me["Simple_L1"].setText(sprintf("%s", engType.getValue()));
me["Simple_L2"].setText(sprintf("%s", " " ~ database1.getValue()));
me["Simple_L3"].setText(sprintf("%s", " " ~ database2.getValue()));
me["Simple_L5"].setText("[ ]");
me["Simple_L6"].setText("+4.0/+0.0");
me["Simple_L1S"].setText(" ENG");
me["Simple_L2S"].setText(" ACTIVE NAV DATA BASE");
me["Simple_L3S"].setText(" SECOND NAV DATA BASE");
me["Simple_L5S"].setText("CHG CODE");
me["Simple_L6S"].setText("IDLE/PERF");
me["Simple_R2"].setText(sprintf("%s", databaseCode.getValue() ~ " "));
me["Simple_R6"].setText("STATUS/XLOAD ");
me["Simple_R6S"].setText("SOFTWARE ");
if (fmgc.WaypointDatabase.getCount() >= 1) {
me["Simple_R4"].show();
me["Simple_R5"].show();
me["Simple_R4S"].show();
me["Simple_R5S"].show();
me["arrow5R"].show();
me["Simple_R5S"].setText(sprintf("%02.0f", fmgc.WaypointDatabase.getCount()) ~ "WPTS 00NAVS ");
} else {
me["Simple_R4"].hide();
me["Simple_R5"].hide();
me["Simple_R4S"].hide();
me["Simple_R5S"].hide();
me["arrow5R"].hide();
}
if (fmgc.WaypointDatabase.confirm[i]) {
me["Simple_R5"].setText("CONFIRM DELETE ALL ");
me["Simple_R5"].setColor(getprop("/MCDUC/colors/amb/r"),getprop("/MCDUC/colors/amb/g"),getprop("/MCDUC/colors/amb/b"));
me["arrow5R"].setColor(getprop("/MCDUC/colors/amb/r"),getprop("/MCDUC/colors/amb/g"),getprop("/MCDUC/colors/amb/b"));
} else {
me["Simple_R5"].setText("DELETE ALL ");
me["Simple_R5"].setColor(getprop("/MCDUC/colors/blu/r"),getprop("/MCDUC/colors/blu/g"),getprop("/MCDUC/colors/blu/b"));
me["arrow5R"].setColor(getprop("/MCDUC/colors/blu/r"),getprop("/MCDUC/colors/blu/g"),getprop("/MCDUC/colors/blu/b"));
}
if (getprop("/FMGC/status/phase") == 0 or getprop("/FMGC/status/phase") == 7) {
me["Simple_L5"].show();
me["Simple_L5S"].show();
} else {
me["Simple_L5"].hide();
me["Simple_L5S"].hide();
}
} else if (page == "DATA") {
if (!pageSwitch[i].getBoolValue()) {
me["Simple"].show();
@ -925,6 +974,250 @@ var canvas_MCDU_base = {
me["Simple_R2S"].setText("PILOTS ");
me["Simple_R3S"].setText("PILOTS ");
me["Simple_R4S"].setText("PILOTS ");
} else if (page == "PILOTWP") {
if (!pageSwitch[i].getBoolValue()) {
me["Simple"].show();
me["Simple_Center"].hide();
me["FPLN"].hide();
me["DIRTO_TMPY_group"].hide();
me["INITA"].hide();
me["IRSINIT"].hide();
me["INITB"].hide();
me["FUELPRED"].hide();
me["PROG"].hide();
me["PERFTO"].hide();
me["arrowsDepArr"].hide();
me["Simple_PageNum"].show();
me["Simple_Title"].show();
me["ArrowLeft"].show();
me["ArrowRight"].show();
me["Simple_L0S"].hide();
me.fontLeft(default, default, default, default, default, default);
me.fontLeftS(default, default, default, default, default, default);
me.fontRight(default, default, default, default, default, default);
me.fontRightS(default, default, default, default, default, default);
me.fontSizeLeft(normal, normal, normal, normal, normal, normal);
me.fontSizeRight(normal, normal, normal, normal, normal, normal);
me.colorLeftS("wht", "wht", "wht", "wht", "wht", "wht");
me.colorRightS("wht", "wht", "wht", "wht", "wht", "wht");
if (myPilotWP[i] != nil) {
me["Simple_PageNum"].setText(fmgc.WaypointDatabase.getNoOfIndex(myPilotWP[i].scroll) ~ "/" ~ (fmgc.WaypointDatabase.getCount()));
me["Simple_Title"].setText(sprintf("%s", myPilotWP[i].title ~ " "));
forindex (var matrixArrow; myPilotWP[i].arrowsMatrix) {
if (matrixArrow == 0) {
var sign = "L";
} else {
var sign = "R";
}
forindex (var item; myPilotWP[i].arrowsMatrix[matrixArrow]) {
if (myPilotWP[i].arrowsMatrix[matrixArrow][item] == 1) {
me["Simple_" ~ sign ~ (item + 1) ~ "_Arrow"].show();
} else {
me["Simple_" ~ sign ~ (item + 1) ~ "_Arrow"].hide();
}
}
}
me.colorLeftArrow(myPilotWP[i].arrowsColour[0][0],myPilotWP[i].arrowsColour[0][1],myPilotWP[i].arrowsColour[0][2],myPilotWP[i].arrowsColour[0][3],myPilotWP[i].arrowsColour[0][4],myPilotWP[i].arrowsColour[0][5]);
me.colorRightArrow(myPilotWP[i].arrowsColour[1][0],myPilotWP[i].arrowsColour[1][1],myPilotWP[i].arrowsColour[1][2],myPilotWP[i].arrowsColour[1][3],myPilotWP[i].arrowsColour[1][4],myPilotWP[i].arrowsColour[1][5]);
forindex (var matrixFont; myPilotWP[i].fontMatrix) {
if (matrixFont == 0) {
var sign = "L";
} else {
var sign = "R";
}
forindex (var item; myPilotWP[i].fontMatrix[matrixFont]) {
if (myPilotWP[i].fontMatrix[matrixFont][item] == 1) {
me["Simple_" ~ sign ~ (item + 1)].setFont(symbol);
me["Simple_" ~ sign ~ (item + 1)].setFontSize(small);
} else {
me["Simple_" ~ sign ~ (item + 1)].setFont(default);
me["Simple_" ~ sign ~ (item + 1)].setFontSize(normal);
}
}
}
if (myPilotWP[i].L1[0] == nil) {
me["Simple_L1"].hide();
me["Simple_L1S"].hide();
} else {
me["Simple_L1"].show();
me["Simple_L1"].setText(myPilotWP[i].L1[0]);
if (myPilotWP[i].L1[1] != nil) {
me["Simple_L1S"].show();
me["Simple_L1S"].setText(myPilotWP[i].L1[1]);
} else {
me["Simple_L1S"].hide();
}
}
if (myPilotWP[i].L2[0] == nil) {
me["Simple_L2"].hide();
me["Simple_L2S"].hide();
} else {
me["Simple_L2"].show();
me["Simple_L2"].setText(myPilotWP[i].L2[0]);
if (myPilotWP[i].L2[1] != nil) {
me["Simple_L2S"].show();
me["Simple_L2S"].setText(myPilotWP[i].L2[1]);
} else {
me["Simple_L2S"].hide();
}
}
if (myPilotWP[i].L3[0] == nil) {
me["Simple_L3"].hide();
me["Simple_L3S"].hide();
} else {
me["Simple_L3"].show();
me["Simple_L3"].setText(myPilotWP[i].L3[0]);
if (myPilotWP[i].L3[1] != nil) {
me["Simple_L3S"].show();
me["Simple_L3S"].setText(myPilotWP[i].L3[1]);
} else {
me["Simple_L3S"].hide();
}
}
if (myPilotWP[i].L4[0] == nil) {
me["Simple_L4"].hide();
me["Simple_L4S"].hide();
} else {
me["Simple_L4"].show();
me["Simple_L4"].setText(myPilotWP[i].L4[0]);
if (myPilotWP[i].L4[1] != nil) {
me["Simple_L4S"].show();
me["Simple_L4S"].setText(myPilotWP[i].L4[1]);
} else {
me["Simple_L4S"].hide();
}
}
if (myPilotWP[i].L5[0] == nil) {
me["Simple_L5"].hide();
me["Simple_L5S"].hide();
} else {
me["Simple_L5"].show();
me["Simple_L5"].setText(myPilotWP[i].L5[0]);
if (myPilotWP[i].L5[1] != nil) {
me["Simple_L5S"].show();
me["Simple_L5S"].setText(myPilotWP[i].L5[1]);
} else {
me["Simple_L5S"].hide();
}
}
if (myPilotWP[i].L6[0] == nil) {
me["Simple_L6"].hide();
me["Simple_L6S"].hide();
} else {
me["Simple_L6"].show();
me["Simple_L6"].setText(myPilotWP[i].L6[0]);
if (myPilotWP[i].L6[1] != nil) {
me["Simple_L6S"].show();
me["Simple_L6S"].setText(myPilotWP[i].L6[1]);
} else {
me["Simple_L6S"].hide();
}
}
me.colorLeft(myPilotWP[i].L1[2],myPilotWP[i].L2[2],myPilotWP[i].L3[2],myPilotWP[i].L4[2],myPilotWP[i].L5[2],myPilotWP[i].L6[2]);
if (myPilotWP[i].R1[0] == nil) {
me["Simple_R1"].hide();
me["Simple_R1S"].hide();
} else {
me["Simple_R1"].show();
me["Simple_R1"].setText(myPilotWP[i].R1[0]);
if (myPilotWP[i].R1[1] != nil) {
me["Simple_R1S"].show();
me["Simple_R1S"].setText(myPilotWP[i].R1[1]);
} else {
me["Simple_R1S"].hide();
}
}
if (myPilotWP[i].R2[0] == nil) {
me["Simple_R2"].hide();
me["Simple_R2S"].hide();
} else {
me["Simple_R2"].show();
me["Simple_R2"].setText(myPilotWP[i].R2[0]);
if (myPilotWP[i].R2[1] != nil) {
me["Simple_R2S"].show();
me["Simple_R2S"].setText(myPilotWP[i].R2[1]);
} else {
me["Simple_R2S"].hide();
}
}
if (myPilotWP[i].R3[0] == nil) {
me["Simple_R3"].hide();
me["Simple_R3S"].hide();
} else {
me["Simple_R3"].show();
me["Simple_R3"].setText(myPilotWP[i].R3[0]);
if (myPilotWP[i].R3[1] != nil) {
me["Simple_R3S"].show();
me["Simple_R3S"].setText(myPilotWP[i].R3[1]);
} else {
me["Simple_R3S"].hide();
}
}
if (myPilotWP[i].R4[0] == nil) {
me["Simple_R4"].hide();
me["Simple_R4S"].hide();
} else {
me["Simple_R4"].show();
me["Simple_R4"].setText(myPilotWP[i].R4[0]);
if (myPilotWP[i].R4[1] != nil) {
me["Simple_R4S"].show();
me["Simple_R4S"].setText(myPilotWP[i].R4[1]);
} else {
me["Simple_R4S"].hide();
}
}
if (myPilotWP[i].R5[0] == nil) {
me["Simple_R5"].hide();
me["Simple_R5S"].hide();
} else {
me["Simple_R5"].show();
me["Simple_R5"].setText(myPilotWP[i].R5[0]);
if (myPilotWP[i].R5[1] != nil) {
me["Simple_R5S"].show();
me["Simple_R5S"].setText(myPilotWP[i].R5[1]);
} else {
me["Simple_R5S"].hide();
}
}
if (myPilotWP[i].R6[0] == nil) {
me["Simple_R6"].hide();
me["Simple_R6S"].hide();
} else {
me["Simple_R6"].show();
me["Simple_R6"].setText(myPilotWP[i].R6[0]);
if (myPilotWP[i].R6[1] != nil) {
me["Simple_R6S"].show();
me["Simple_R6S"].setText(myPilotWP[i].R6[1]);
} else {
me["Simple_R6S"].hide();
}
}
me.colorRight(myPilotWP[i].R1[2],myPilotWP[i].R2[2],myPilotWP[i].R3[2],myPilotWP[i].R4[2],myPilotWP[i].R5[2],myPilotWP[i].R6[2]);
}
pageSwitch[i].setBoolValue(1);
}
} else if (page == "POSMON") {
if (!pageSwitch[i].getBoolValue()) {
me["Simple"].show();

View file

@ -119,7 +119,7 @@ setprop("gear/gear[0]/wow-fmgc", 1);
var FMGCinit = func {
setprop("/FMGC/status/to-state", 0);
setprop("/FMGC/status/phase", "0"); # 0 is Preflight 1 is Takeoff 2 is Climb 3 is Cruise 4 is Descent 5 is Decel/Approach 6 is Go Around 7 is Done
setprop("/FMGC/status/phase", 0); # 0 is Preflight 1 is Takeoff 2 is Climb 3 is Cruise 4 is Descent 5 is Decel/Approach 6 is Go Around 7 is Done
setprop("/FMGC/internal/maxspeed", 338);
setprop("/FMGC/internal/mng-spd", 157);
setprop("/FMGC/internal/mng-spd-cmd", 157);
@ -712,7 +712,7 @@ var masterFMGC = maketimer(0.2, func {
});
var reset_FMGC = func {
setprop("/FMGC/status/phase", "0");
setprop("/FMGC/status/phase", 0);
fd1 = getprop("/it-autoflight/input/fd1");
fd2 = getprop("/it-autoflight/input/fd2");
spd = getprop("/it-autoflight/input/spd-kts");

View file

@ -0,0 +1,285 @@
# A3XX FMGC Waypoint database
# Copyright (c) 2020 Josh Davidson (Octal450) and Jonathan Redpath (legoboyvdlp)
var nilTree = {
"latitude": 0,
"longitude": 0,
"ident": "",
};
var WaypointDatabase = {
waypointsVec: [],
confirm: [0, 0],
# addWP - adds pilot waypoint to waypoints vector
# arg: wpObj - passed pilot waypoint object
# return:
# 0 - not allowed
# 2 - accepted
# 4 - database full
addWP: func(wpObj) {
# validate ghost
if (wpObj.wpGhost == nil) {
return 0;
}
# check size of database
if (me.getCount() >= 20) {
return 4;
}
if (wpObj.index >= me.getSize()) {
# add to end, since index doesn't exist
append(me.waypointsVec, wpObj);
me.write();
return 2;
} elsif (me.waypointsVec[wpObj.index] == nil) {
# add at passed index
me.waypointsVec[wpObj.index] = wpObj;
me.write();
return 2;
} else {
# fall back to end
logprint(4, "pilotWaypoint constructor claims index " ~ wpObj.index ~ " is nil, but it isn't!");
append(me.waypointsVec, wpObj);
me.write();
return 2;
}
},
# delete - empties waypoints vector
# callerIdx is the calling mcdu
delete: func(callerIdx) {
var noDel = 0;
for (var i = 0; i < me.getSize(); i = i + 1) {
if (me.waypointsVec[i] != nil) {
if (fmgc.flightPlanController.flightplans[2].indexOfWP(me.waypointsVec[i].wpGhost) == -1) { # docs says only checks active and secondary
me.waypointsVec[i] = nil;
}
}
}
me.write();
if (me.getCount() != 0) {
setprop("/MCDU[" ~ callerIdx ~ "]/scratchpad-msg", 1);
setprop("/MCDU[" ~ callerIdx ~ "]/scratchpad", "PILOT ELEMENT RETAINED");
}
},
# deleteAtIndex - delete at specific index. Set to nil, so it still exists in vector
deleteAtIndex: func(index) {
if (index < 0 or index >= me.getSize() or index >= 20) {
return;
}
me.waypointsVec[index] = nil;
me.write();
},
# getNilIndex - find the first nil
# post 2020.1 use dedicated function vecindex()
getNilIndex: func() {
for (var i = 0; i < me.getSize(); i = i + 1) {
if (me.waypointsVec[i] == nil) {
return i;
}
}
return -1;
},
# getNonNilIndex - find the first non-nil
# post 2020.1 use dedicated function vecindex()
getNonNilIndex: func() {
for (var i = 0; i < me.getSize(); i = i + 1) {
if (me.waypointsVec[i] != nil) {
return i;
}
}
return -1;
},
# getNextFromIndex - find the next non-nil after a passed index
getNextFromIndex: func(index) {
for (var i = (index + 1); i < me.getSize(); i = i + 1) {
if (me.waypointsVec[i] != nil) {
return i;
}
}
for (var i = 0; i <= index; i = i + 1) {
if (me.waypointsVec[i] != nil) {
return i;
}
}
return index;
},
# getPreviousFromIndex - find the next non-nil before a passed index
getPreviousFromIndex: func(index) {
for (var i = (index - 1); i >= 0; i = i - 1) {
if (me.waypointsVec[i] != nil) {
return i;
}
}
for (var i = (me.getSize() - 1); i >= index; i = i - 1) {
if (me.waypointsVec[i] != nil) {
return i;
}
}
return index;
},
# getNoOfIndex - return what number passed item is in list, neglecting "nil"
getNoOfIndex: func(index) {
var count = 0;
for (var i = 0; i <= index; i = i + 1) {
if (me.waypointsVec[i] == nil) {
continue;
}
count += 1;
}
return count;
},
# getCount - return size, neglecting "nil"
getCount: func() {
var count = 0;
for (var i = 0; i < me.getSize(); i = i + 1) {
if (me.waypointsVec[i] == nil) {
continue;
}
count += 1;
}
return count;
},
# getSize - return maximum size of vector
getSize: func() {
return size(me.waypointsVec);
},
# getWP - try to find waypoint whose name matches passed argument
getWP: func(text) {
for (var i = 0; i < me.getSize(); i = i + 1) {
if (me.waypointsVec[i] == nil) {
continue;
}
if (text == me.waypointsVec[i].wpGhost.wp_name) {
return me.waypointsVec[i].wpGhost;
}
}
return nil;
},
# write - write to file, as a hash structure
write: func() {
var path = getprop("/sim/fg-home") ~ "/Export/A320SavedWaypoints.xml";
var tree = {
waypoints: {
},
};
for (var i = 0; i < me.getSize(); i = i + 1) {
if (me.waypointsVec[i] != nil) {
tree.waypoints["waypoint" ~ i] = me.waypointsVec[i].tree;
}
}
io.writexml(path, props.Node.new(tree)); # write the data
},
# read - read from a file, extract using props interface
read: func() {
var path = getprop("/sim/fg-home") ~ "/Export/A320SavedWaypoints.xml";
# create file if it doesn't exist
if (io.stat(path) == nil) {
me.write();
return;
}
var data = io.readxml(path).getChild("waypoints");
var pilotWP = nil;
for (var i = 0; i < 20; i = i + 1) {
pilotWP = nil;
var childNode = data.getChild("waypoint" ~ i);
if (childNode == nil) {
continue;
}
var wpt = createWP({lat: num(childNode.getChild("latitude").getValue()), lon: num(childNode.getChild("longitude").getValue())},childNode.getChild("ident").getValue());
if (left(childNode.getChild("ident").getValue(), 3) == "PBD") {
pilotWP = pilotWaypoint.newAtPosition(wpt, "PBD", right(childNode.getChild("ident").getValue(), 1));
} else {
pilotWP = pilotWaypoint.newAtPosition(wpt, "LL", right(childNode.getChild("ident").getValue(), 1));
}
me.addWPToPos(pilotWP, right(childNode.getChild("ident").getValue(), 1));
}
},
# addWPToPos - helper for reading - inserts at specific index
# will create nil for intermediates
addWPToPos: func(wpObj, position) {
if (me.getSize() >= position) {
me.waypointsVec[position - 1] = wpObj;
} else {
var numToIns = position - me.getSize();
while (numToIns >= 1) {
append(me.waypointsVec, nil);
numToIns -= 1;
}
me.waypointsVec[position - 1] = wpObj;
}
},
};
var pilotWaypoint = {
new: func(positioned, typeStr) {
var pilotWp = { parents:[pilotWaypoint] };
# Figure out what the first index is we can use
var nilIndex = WaypointDatabase.getNilIndex();
var position = nil;
if (nilIndex == -1) {
position = WaypointDatabase.getSize() + 1;
} else {
position = nilIndex + 1
}
pilotWp.setId(typeStr ~ sprintf("%s", position));
pilotWp.index = position - 1;
# set ghost to created waypoint
pilotWp.wpGhost = createWP(positioned, pilotWp.id);
pilotWp.tree = {
"latitude": pilotWp.wpGhost.wp_lat,
"longitude": pilotWp.wpGhost.wp_lon,
"ident": pilotWp.id,
};
return pilotWp;
},
newAtPosition: func(positioned, typeStr, position) {
var pilotWp = { parents:[pilotWaypoint] };
pilotWp.setId(typeStr ~ sprintf("%s", position));
pilotWp.index = position - 1;
# set ghost to created waypoint
pilotWp.wpGhost = positioned;
pilotWp.tree = {
"latitude": pilotWp.wpGhost.wp_lat,
"longitude": pilotWp.wpGhost.wp_lon,
"ident": pilotWp.id,
};
return pilotWp;
},
setId: func(id) {
if (typeof(id) == "scalar") { me.id = id; }
},
getId: func() {
if (me.id != nil) { return id; }
},
};
setlistener("/MCDU[0]/page", func() {
if (getprop("/MCDU[0]/page") != "PILOTWP" and getprop("/MCDU[0]/page") != "STATUS") {
WaypointDatabase.confirm[0] = 0;
}
}, 0, 0);
setlistener("/MCDU[1]/page", func() {
if (getprop("/MCDU[1]/page") != "PILOTWP" and getprop("/MCDU[1]/page") != "STATUS") {
WaypointDatabase.confirm[1] = 0;
}
}, 0, 0);

View file

@ -201,6 +201,13 @@ var flightPlanController = {
# for these two remember to call flightPlanChanged. We are assuming this is called from a function which will all flightPlanChanged itself.
# addDiscontinuity - insert discontinuity at passed index
# args: index, plan
# index: index to add at
# plan: plan to add to
# Check if a discontinuity already exists either immediately before or at that index
# If it does, don't add another one
# Optional flag DEBUG_DISCONT to disable discontinuities totally
addDiscontinuity: func(index, plan) {
if (DEBUG_DISCONT) { return; }
if (index > 0) {
@ -232,13 +239,9 @@ var flightPlanController = {
# name: name of waypoint to be created
# typeStr: optional argument to be passed to createWP, must be one of "sid", "star" "approach" "missed" or "pseudo"
childWPBearingDistance: func(wpt, bearing, dist, name, typeStr = "") {
childWPBearingDistance: func(wpt, bearing, dist) {
var coordinates = greatCircleMove(wpt.lat, wpt.lon, num(bearing), num(dist));
if (typeStr != "") {
return createWP(coordinates, name, typeStr);
} else {
return createWP(coordinates, name);
}
return coordinates;
},
# insertNOSID - create default SID and add to flightplan
@ -254,7 +257,7 @@ var flightPlanController = {
}
# fudge the altitude since we cannot create a hdgtoAlt from nasal. Assume 600 feet per mile - 2.5 miles
me.flightplans[n].insertWP(me.childWPBearingDistance(wptStore, me.flightplans[n].departure_runway.heading, 2.5, "1500", "sid"), 1);
me.flightplans[n].insertWP(createWP(me.childWPBearingDistance(wptStore, me.flightplans[n].departure_runway.heading, 2.5), "1500", "sid"), 1);
}
me.flightPlanChanged(n);
},
@ -274,7 +277,7 @@ var flightPlanController = {
if (hdg > 360) {
hdg = hdg - 360;
}
me.flightplans[n].insertWP(me.childWPBearingDistance(wptStore, hdg, 5, "CF", "star"), me.arrivalIndex[n]);
me.flightplans[n].insertWP(createWP(me.childWPBearingDistance(wptStore, hdg, 5), "CF", "star"), me.arrivalIndex[n]);
}
me.flightPlanChanged(n);
},
@ -293,7 +296,10 @@ var flightPlanController = {
directTo: func(waypointGhost, plan) {
if (me.flightplans[plan].indexOfWP(waypointGhost) == -1) {
me.insertTP(plan, 1);
me.flightplans[plan].insertWP(createWPFrom(waypointGhost), 2);
# use createWP here as createWPFrom doesn't accept waypoints
# createWPFrom worked before... but be sure!
me.flightplans[plan].insertWP(createWP(waypointGhost, waypointGhost.wp_name), 2);
me.addDiscontinuity(3, plan);
} else {
# we want to delete the intermediate waypoints up to but not including the waypoint. Leave index 0, we delete it later.
@ -336,6 +342,18 @@ var flightPlanController = {
}
},
# deleteTillIndex - helper that deletes waypoints up to a passed waypoint already in flightplan
# uses a while loop to delete a certain number of waypoints between passed index and
# index of waypoint alredy in flightplan
deleteTillIndex: func(wpGhost, index, plan) {
var numToDel = me.flightplans[plan].indexOfWP(wpGhost) - index;
while (numToDel > 0) {
me.deleteWP(index, plan, 1);
numToDel -= 1;
}
return 2;
},
# createDuplicateNames - helper to spawn DUPLICATENAMES page
# args: ghostContainer, index, flag, plan
# ghostContainer: vector of fgPositioned ghosts
@ -364,34 +382,21 @@ var flightPlanController = {
}
if (size(airport) == 1 or override) {
if (!override) {
if (me.flightplans[plan].indexOfWP(airport[0]) == -1) {
me.flightplans[plan].insertWP(createWPFrom(airport[0]), index);
me.addDiscontinuity(index + 1, plan);
me.flightPlanChanged(plan);
return 2;
} else {
var numToDel = me.flightplans[plan].indexOfWP(airport[0]) - index;
while (numToDel > 0) {
me.deleteWP(index, plan, 1);
numToDel -= 1;
}
return 2;
}
var indexToInsert = -1;
if (override) {
indexToInsert = overrideIndex;
} else {
if (me.flightplans[plan].indexOfWP(airport[overrideIndex]) == -1) {
me.flightplans[plan].insertWP(createWPFrom(airport[overrideIndex]), index);
me.addDiscontinuity(index + 1, plan);
me.flightPlanChanged(plan);
return 2;
} else {
var numToDel = me.flightplans[plan].indexOfWP(airport[overrideIndex]) - index;
while (numToDel > 0) {
me.deleteWP(index, plan, 1);
numToDel -= 1;
}
return 2;
}
indexToInsert = 0;
}
var indexPresent = me.flightplans[plan].indexOfWP(airport[indexToInsert]);
if (me.flightplans[plan].indexOfWP(airport[indexToInsert]) == -1) {
me.flightplans[plan].insertWP(createWPFrom(airport[indexToInsert]), index);
me.addDiscontinuity(index + 1, plan);
me.flightPlanChanged(plan);
return 2;
} else {
return me.deleteTillIndex(airport[indexToInsert], index, plan);
}
} elsif (size(airport) >= 1) {
me.createDuplicateNames(airport, index, 0, plan);
@ -399,7 +404,7 @@ var flightPlanController = {
}
},
insertFix: func(text, index, plan, override = 0, overrideIndex = -1) { # override - means always choose [0]
insertFix: func(text, index, plan, override = 0, overrideIndex = -1) {
if (index == 0) {
return 1;
}
@ -410,34 +415,21 @@ var flightPlanController = {
}
if (size(fix) == 1 or override) {
if (!override) {
if (me.flightplans[plan].indexOfWP(fix[0]) == -1) {
me.flightplans[plan].insertWP(createWPFrom(fix[0]), index);
me.addDiscontinuity(index + 1, plan);
me.flightPlanChanged(plan);
return 2;
} else {
var numToDel = me.flightplans[plan].indexOfWP(fix[0]) - index;
while (numToDel > 0) {
me.deleteWP(index, plan, 1);
numToDel -= 1;
}
return 2;
}
var indexToInsert = -1;
if (override) {
indexToInsert = overrideIndex;
} else {
if (me.flightplans[plan].indexOfWP(fix[overrideIndex]) == -1) {
me.flightplans[plan].insertWP(createWPFrom(fix[overrideIndex]), index);
me.addDiscontinuity(index + 1, plan);
me.flightPlanChanged(plan);
return 2;
} else {
var numToDel = me.flightplans[plan].indexOfWP(fix[overrideIndex]) - index;
while (numToDel > 0) {
me.deleteWP(index, plan, 1);
numToDel -= 1;
}
return 2;
}
indexToInsert = 0;
}
var indexPresent = me.flightplans[plan].indexOfWP(fix[indexToInsert]);
if (me.flightplans[plan].indexOfWP(fix[indexToInsert]) == -1) {
me.flightplans[plan].insertWP(createWPFrom(fix[indexToInsert]), index);
me.addDiscontinuity(index + 1, plan);
me.flightPlanChanged(plan);
return 2;
} else {
return me.deleteTillIndex(fix[indexToInsert], index, plan);
}
} elsif (size(fix) >= 1) {
me.createDuplicateNames(fix, index, 0, plan);
@ -445,6 +437,55 @@ var flightPlanController = {
}
},
insertNavaid: func(text, index, plan, override = 0, overrideIndex = -1) {
if (index == 0) {
return 1;
}
var navaid = findNavaidsByID(text);
if (size(navaid) == 0) {
return 0;
}
if (size(navaid) == 1 or override) {
var indexToInsert = -1;
if (override) {
indexToInsert = overrideIndex;
} else {
indexToInsert = 0;
}
var indexPresent = me.flightplans[plan].indexOfWP(navaid[indexToInsert]);
if (me.flightplans[plan].indexOfWP(navaid[indexToInsert]) == -1) {
me.flightplans[plan].insertWP(createWPFrom(navaid[indexToInsert]), index);
me.addDiscontinuity(index + 1, plan);
me.flightPlanChanged(plan);
return 2;
} else {
return me.deleteTillIndex(navaid[indexToInsert], index, plan);
}
} elsif (size(navaid) >= 1) {
me.createDuplicateNames(navaid, index, 1, plan);
return 2;
}
},
insertDBWP: func(wpGhost, index, plan) {
if (index == 0 or wpGhost == nil) {
return 1;
}
if (me.flightplans[plan].indexOfWP(wpGhost) == -1) {
# use createWP here as createWPFrom doesn't accept waypoints
me.flightplans[plan].insertWP(createWP(wpGhost, wpGhost.wp_name), index);
me.addDiscontinuity(index + 1, plan);
me.flightPlanChanged(plan);
return 2;
} else {
return me.deleteTillIndex(wpGhost, index, plan);
}
},
insertLatLonFix: func(text, index, plan) {
if (index == 0) {
return 1;
@ -459,66 +500,16 @@ var flightPlanController = {
return 1;
}
var myWpLatLon = createWP(latDecimal, lonDecimal, "LL" ~ index);
if (me.flightplans[plan].indexOfWP(myWpLatLon) == -1) {
me.flightplans[plan].insertWP(myWpLatLon, index);
me.addDiscontinuity(index + 1, plan);
me.flightPlanChanged(plan);
return 2;
} else {
var numToDel = me.flightplans[plan].indexOfWP(myWpLatLon) - index;
while (numToDel > 0) {
me.deleteWP(index, plan, 1);
numToDel -= 1;
}
return 2;
}
},
insertNavaid: func(text, index, plan, override = 0, overrideIndex = -1) {
if (index == 0) {
return 1;
var waypoint = pilotWaypoint.new({lat: latDecimal, lon: lonDecimal}, "LL");
var addDb = WaypointDatabase.addWP(waypoint);
if (addDb != 2) {
return addDb;
}
var navaid = findNavaidsByID(text);
if (size(navaid) == 0) {
return 0;
}
if (size(navaid) == 1 or override) {
if (!override) {
if (me.flightplans[plan].indexOfWP(navaid[0]) == -1) {
me.flightplans[plan].insertWP(createWPFrom(navaid[0]), index);
me.addDiscontinuity(index + 1, plan);
me.flightPlanChanged(plan);
return 2;
} else {
var numToDel = me.flightplans[plan].indexOfWP(navaid[0]) - index;
while (numToDel > 0) {
me.deleteWP(index, plan, 1);
numToDel -= 1;
}
return 2;
}
} else {
if (me.flightplans[plan].indexOfWP(navaid[overrideIndex]) == -1) {
me.flightplans[plan].insertWP(createWPFrom(navaid[overrideIndex]), index);
me.addDiscontinuity(index + 1, plan);
me.flightPlanChanged(plan);
return 2;
} else {
var numToDel = me.flightplans[plan].indexOfWP(navaid[overrideIndex]) - index;
while (numToDel > 0) {
me.deleteWP(index, plan, 1);
numToDel -= 1;
}
return 2;
}
}
} elsif (size(navaid) >= 1) {
me.createDuplicateNames(navaid, index, 1, plan);
return 2;
}
me.flightplans[plan].insertWP(waypoint.wpGhost, index);
me.addDiscontinuity(index + 1, plan);
me.flightPlanChanged(plan);
return 2;
},
# getWPforPBD - parse scratchpad text to find waypoint ghost for PBD
@ -568,7 +559,7 @@ var flightPlanController = {
return 1;
}
if (size(wpGhostContainer) == 0 or override) {
if (size(wpGhostContainer) == 1 or override) {
if (!override) {
wpGhost = wpGhostContainer[0];
} else {
@ -584,8 +575,7 @@ var flightPlanController = {
}
var localMagvar = magvar(wpGhost.lat, wpGhost.lon);
me.insertPlaceBearingDistance(wpGhost, textSplit[1] + localMagvar, textSplit[2], index, plan);
return 2;
return me.insertPlaceBearingDistance(wpGhost, textSplit[1] + localMagvar, textSplit[2], index, plan); # magnetic to true? I don't know. But this works!
},
@ -597,12 +587,19 @@ var flightPlanController = {
# plan: plan to insert to
insertPlaceBearingDistance: func(wp, bearing, distance, index, plan) {
me.flightplans[plan].insertWP(me.childWPBearingDistance(wp, bearing, distance, "PBD" ~ index), index);
var waypoint = pilotWaypoint.new(me.childWPBearingDistance(wp, bearing, distance), "PBD");
var addDb = WaypointDatabase.addWP(waypoint);
if (addDb != 2) {
return addDb;
}
me.flightplans[plan].insertWP(waypoint.wpGhost, index);
me.addDiscontinuity(index + 1, plan);
me.flightPlanChanged(plan);
return 2;
},
scratchpad: func(text, index, plan) { # return 0 not in database, 1 not allowed, 2 success, 3 = not allowed due to dir to
scratchpad: func(text, index, plan) { # return 0 not in database, 1 not allowed, 2 success, 3 = not allowed due to dir to, 4 = database full
if (mcdu.dirToFlag) {
return 3;
}
@ -618,6 +615,12 @@ var flightPlanController = {
var thePlan = plan;
}
# check waypoints database here
var wpFromDB = WaypointDatabase.getWP(text);
if (wpFromDB != nil) {
return me.insertDBWP(wpFromDB, index, thePlan);
}
if (size(split("/", text)) == 3) {
return me.getWPforPBD(text, index, thePlan);
} elsif (text == "CLR") {

View file

@ -227,6 +227,7 @@ var systemsInit = func {
setlistener("/sim/signals/fdm-initialized", func {
systemsInit();
fmgc.flightPlanTimer.start();
fmgc.WaypointDatabase.read();
});
var systemsLoop = maketimer(0.1, func {

View file

@ -87,12 +87,13 @@ var closestAirportPage = {
me.cdVector[1] = courseAndDistance(me.airports[1]);
me.cdVector[2] = courseAndDistance(me.airports[2]);
me.cdVector[3] = courseAndDistance(me.airports[3]);
me.C1 = [math.round(me.cdVector[0][0]) ~ " " ~ math.round(me.cdVector[0][1]), " BRG DIST", "grn"];
me.C2 = [math.round(me.cdVector[1][0]) ~ " " ~ math.round(me.cdVector[1][1]), nil, "grn"];
me.C3 = [math.round(me.cdVector[2][0]) ~ " " ~ math.round(me.cdVector[2][1]), nil, "grn"];
me.C4 = [math.round(me.cdVector[3][0]) ~ " " ~ math.round(me.cdVector[3][1]), nil, "grn"];
var magvarLocal = magvar();
me.C1 = [math.round(me.cdVector[0][0] - magvarLocal) ~ " " ~ math.round(me.cdVector[0][1]), " BRG DIST", "grn"];
me.C2 = [math.round(me.cdVector[1][0] - magvarLocal) ~ " " ~ math.round(me.cdVector[1][1]) , nil, "grn"];
me.C3 = [math.round(me.cdVector[2][0] - magvarLocal) ~ " " ~ math.round(me.cdVector[2][1]), nil, "grn"];
me.C4 = [math.round(me.cdVector[3][0] - magvarLocal) ~ " " ~ math.round(me.cdVector[3][1]), nil, "grn"];
if (me.manAirport != nil) {
me.C5 = [math.round(courseAndDistance(me.manAirport)[0]) ~ " " ~ math.round(courseAndDistance(me.manAirport)[1]), nil, "grn"];
me.C5 = [math.round(courseAndDistance(me.manAirport)[0] - magvarLocal) ~ " " ~ math.round(courseAndDistance(me.manAirport)[1]), nil, "grn"];
}
canvas_mcdu.pageSwitch[me.computer].setBoolValue(0);
},

View file

@ -415,6 +415,8 @@ var fplnPage = { # this one is only created once, and then updated - remember th
notInDataBase(me.computer);
} elsif (returny == 1) {
notAllowed(me.computer);
} elsif (returny == 4) {
databaseFull(me.computer);
} else {
setprop("MCDU[" ~ me.computer ~ "]/scratchpad-msg", "");
setprop("MCDU[" ~ me.computer ~ "]/scratchpad", "");
@ -455,15 +457,25 @@ var fplnPage = { # this one is only created once, and then updated - remember th
};
var notInDataBase = func(i) {
if (getprop("MCDU[" ~ i ~ "]/scratchpad-msg") == 1) {
setprop("MCDU[" ~ i ~ "]/last-scratchpad", "NOT IN DATABASE");
} else {
setprop("MCDU[" ~ i ~ "]/last-scratchpad", getprop("MCDU[" ~ i ~ "]/scratchpad"));
}
if (getprop("MCDU[" ~ i ~ "]/scratchpad-msg") == 1) {
setprop("MCDU[" ~ i ~ "]/last-scratchpad", "NOT IN DATABASE");
} else {
setprop("MCDU[" ~ i ~ "]/last-scratchpad", getprop("MCDU[" ~ i ~ "]/scratchpad"));
}
setprop("MCDU[" ~ i ~ "]/scratchpad-msg", 1);
setprop("MCDU[" ~ i ~ "]/scratchpad", "NOT IN DATABASE");
}
var databaseFull = func(i) {
if (getprop("MCDU[" ~ i ~ "]/scratchpad-msg") == 1) {
setprop("MCDU[" ~ i ~ "]/last-scratchpad", "LIST OF 20 IN USE");
} else {
setprop("MCDU[" ~ i ~ "]/last-scratchpad", getprop("MCDU[" ~ i ~ "]/scratchpad"));
}
setprop("MCDU[" ~ i ~ "]/scratchpad-msg", 1);
setprop("MCDU[" ~ i ~ "]/scratchpad", "LIST OF 20 IN USE");
}
var decimalToShortString = func(dms, type) {
var degrees = split(".", sprintf(dms))[0];
if (type == "lat") {

View file

@ -399,6 +399,7 @@ var lskbutton = func(btn, i) {
canvas_mcdu.myDuplicate[i].pushButtonLeft(5);
} else if (getprop("/MCDU[" ~ i ~ "]/page") == "CLOSESTAIRPORT") {
canvas_mcdu.myClosestAirport[i].manAirportCall(getprop("/MCDU[" ~ i ~ "]/scratchpad"));
setprop("/MCDU[" ~ i ~ "]/scratchpad", "");
} else {
notAllowed(i);
}
@ -473,6 +474,17 @@ var rskbutton = func(btn, i) {
}
} else if (getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNA" or getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNB") {
canvas_mcdu.myFpln[i].pushButtonRight(1);
} else if (getprop("/MCDU[" ~ i ~ "]/page") == "DATA2") {
if (fmgc.WaypointDatabase.getCount() > 0) {
if (canvas_mcdu.myPilotWP[i] != nil) {
canvas_mcdu.myPilotWP[i].del();
}
canvas_mcdu.myPilotWP[i] = nil;
canvas_mcdu.myPilotWP[i] = pilotWaypointPage.new(i);
setprop("/MCDU[" ~ i ~ "]/page", "PILOTWP");
} else {
notAllowed(i); # todo spawn new waypoints page
}
} else {
notAllowed(i);
}
@ -551,6 +563,8 @@ var rskbutton = func(btn, i) {
initInputA("R5",i);
} else if (getprop("/MCDU[" ~ i ~ "]/page") == "INITB") {
initInputB("R5",i);
} else if (getprop("/MCDU[" ~ i ~ "]/page") == "STATUS") {
statusInput("R5",i);
} else if (getprop("/MCDU[" ~ i ~ "]/page") == "PERFTO") {
perfTOInput("R5",i);
} else if (getprop("/MCDU[" ~ i ~ "]/page") == "PERFAPPR") {
@ -619,9 +633,19 @@ var rskbutton = func(btn, i) {
} else if (getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNA" or getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNB") {
canvas_mcdu.myFpln[i].pushButtonRight(6);
} else if (getprop("/MCDU[" ~ i ~ "]/page") == "VERTREV") {
setprop("/MCDU/[" ~ i ~ "]/page", "F-PLNA");
setprop("/MCDU[" ~ i ~ "]/page", "F-PLNA");
} else if (getprop("/MCDU[" ~ i ~ "]/page") == "DIRTO") {
canvas_mcdu.myDirTo[i].fieldR6();
} else if (getprop("/MCDU[" ~ i ~ "]/page") == "PILOTWP") {
if (canvas_mcdu.myPilotWP[i] != nil) {
if (fmgc.WaypointDatabase.confirm[i]) {
fmgc.WaypointDatabase.confirm[i] = 0;
canvas_mcdu.myPilotWP[i].deleteCmd();
} else {
fmgc.WaypointDatabase.confirm[i] = 1;
canvas_mcdu.myPilotWP[i].deleteCmd();
}
}
} else {
notAllowed(i);
}
@ -650,6 +674,8 @@ var arrowbutton = func(btn, i) {
canvas_mcdu.myDeparture[i].scrollLeft();
} else if (getprop("/MCDU[" ~ i ~ "]/page") == "ARRIVAL") {
canvas_mcdu.myArrival[i].scrollLeft();
} else if (getprop("/MCDU[" ~ i ~ "]/page") == "PILOTWP") {
canvas_mcdu.myPilotWP[i].scrollLeft();
}
} else if (btn == "right") {
if (getprop("/MCDU[" ~ i ~ "]/page") == "DATA") {
@ -672,6 +698,8 @@ var arrowbutton = func(btn, i) {
canvas_mcdu.myDeparture[i].scrollRight();
} else if (getprop("/MCDU[" ~ i ~ "]/page") == "ARRIVAL") {
canvas_mcdu.myArrival[i].scrollRight();
} else if (getprop("/MCDU[" ~ i ~ "]/page") == "PILOTWP") {
canvas_mcdu.myPilotWP[i].scrollRight();
}
} else if (btn == "up") {
if (getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNA" or getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNB") {

View file

@ -0,0 +1,97 @@
var pilotWaypointPage = {
title: 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]],
arrowsColour: [["ack", "ack", "ack", "ack", "ack", "ack"],["ack", "ack", "ack", "ack", "ack", "ack"]],
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"],
C1: [nil, nil, "ack"],
C2: [nil, nil, "ack"],
C3: [nil, nil, "ack"],
C4: [nil, nil, "ack"],
C5: [nil, nil, "ack"],
C6: [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"],
new: func(computer) {
var ap = {parents:[pilotWaypointPage]};
ap.scroll = fmgc.WaypointDatabase.getNonNilIndex();
ap.computer = computer;
ap._setupPageWithData();
return ap;
},
del: func() {
return nil;
},
_setupPageWithData: func() {
me.title = "PILOTS WAYPOINT";
me.L1 = [fmgc.WaypointDatabase.waypointsVec[me.scroll].id, " IDENT", "grn"];
var ghost = fmgc.WaypointDatabase.waypointsVec[me.scroll].wpGhost;
me.L2 = [me.translateLatitude(ghost.lat) ~ "/" ~ me.translateLongitude(ghost.lon), " LAT/LON", "grn"];
me.R5 = ["WAYPOINT ", "NEW ", "wht"];
me.arrowsMatrix = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 1]];
me.arrowsColour = [["ack", "ack", "ack", "ack", "ack", "ack"], ["ack", "ack", "ack", "ack", "wht", "blu"]];
if (fmgc.WaypointDatabase.confirm[me.computer]) {
me.R6 = ["CONFIRM DELETE ALL ", nil, "amb"];
me.arrowsColour[1][5] = "amb";
} else {
me.R6 = ["DELETE ALL ", nil, "blu"];
me.arrowsColour[1][5] = "blu";
}
canvas_mcdu.pageSwitch[me.computer].setBoolValue(0);
},
translateLatitude: func(latitude) {
var split = split(".", sprintf("%s", latitude));
var degree = split[0];
if (latitude >= 0) {
var decimal = sprintf("%04.1f", (latitude - num(degree)) * 60);
return sprintf("%02.0f", degree) ~ decimal ~ "N";
} else {
var decimal = sprintf("%04.1f", (latitude - num(degree)) * 60);
return sprintf("%02.0f", degree) ~ decimal ~ "S";
}
},
translateLongitude: func(longitude) {
var split = split(".", sprintf("%s", longitude));
var degree = split[0];
if (longitude >= 0) {
var decimal = sprintf("%04.1f", (longitude - num(degree)) * 60);
return sprintf("%03.0f", degree) ~ decimal ~ "E";
} else {
var decimal = sprintf("%04.1f", (longitude - num(degree)) * 60);
return sprintf("%03.0f", degree) ~ decimal ~ "W";
}
},
scrollLeft: func() {
me.scroll = fmgc.WaypointDatabase.getPreviousFromIndex(me.scroll);
me._setupPageWithData();
canvas_mcdu.pageSwitch[me.computer].setBoolValue(0);
},
scrollRight: func() {
me.scroll = fmgc.WaypointDatabase.getNextFromIndex(me.scroll);
me._setupPageWithData();
canvas_mcdu.pageSwitch[me.computer].setBoolValue(0);
},
deleteCmd: func() {
if (!fmgc.WaypointDatabase.confirm[me.computer]) {
fmgc.WaypointDatabase.delete(me.computer);
me.scroll = fmgc.WaypointDatabase.getNonNilIndex();
}
me._setupPageWithData();
canvas_mcdu.pageSwitch[me.computer].setBoolValue(0);
},
};

View file

@ -5,5 +5,12 @@
var statusInput = func(key, i) {
if (key == "L3") {
fmgc.switchDatabase();
} elsif (key == "R5") {
if (fmgc.WaypointDatabase.confirm[i]) {
fmgc.WaypointDatabase.delete(i);
fmgc.WaypointDatabase.confirm[i] = 0;
} else {
fmgc.WaypointDatabase.confirm[i] = 1;
}
}
}

View file

@ -50,7 +50,7 @@ var vertRev = {
me.L5 = [" WIND DATA", nil, "wht"];
me.L6 = [" RETURN", nil, "wht"];
me.R2 = ["RTA ", nil, "wht"];
me.arrowsMatrix = [[0, 0, 0, 1, 1, 1], [0, 1, 0, 0, 0, 1]];
me.arrowsMatrix = [[0, 0, 0, 1, 1, 1], [0, 1, 0, 0, 0, 0]];
me.arrowsColour = [["ack", "ack", "ack", "wht", "wht", "wht"], ["ack", "wht", "ack", "ack", "wht", "wht"]];
me.fontMatrix = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]];
} if (me.type == 2) {
@ -61,12 +61,17 @@ var vertRev = {
me.L3 = [" [ ]", " SPD CSTR", "blu"];
me.L4 = [" CONSTANT MACH", nil, "wht"];
me.L5 = [" WIND DATA", nil, "wht"];
me.L6 = [" CLB", nil, "wht"];
me.L6 = [" CLB", nil, "amb"];
me.R2 = ["RTA ", nil, "wht"];
me.R3 = ["[ ] ", "ALT CSTR ", "blu"];
me.R6 = ["DES ", nil, "wht"];
me.R6 = ["DES ", nil, "amb"];
# When the system does vertical planning, L6 should be RETURN and R6 not used if the MCDU knows the waypoint is during climb or descent.
# The CLB or DES prompts should only be shown for a vertical revision in the cruise phase.
# For now we fake it and allow the user to press either, which both act like RETURN.
# When CLB/DES are shown, a small "OR" should be shown between them.
# The 'arrows' for CLB/DES should actually be asterisks.
me.arrowsMatrix = [[0, 0, 0, 1, 1, 1], [0, 1, 0, 0, 0, 1]];
me.arrowsColour = [["ack", "ack", "ack", "wht", "wht", "wht"], ["ack", "wht", "ack", "ack", "wht", "wht"]];
me.arrowsColour = [["ack", "ack", "ack", "wht", "wht", "amb"], ["ack", "wht", "ack", "ack", "wht", "amb"]];
me.fontMatrix = [[0, 0, 1, 0, 0, 0], [0, 0, 1, 0, 0, 0]];
} else {
me.title = ["VERT REV", " AT ", me.id];
@ -84,8 +89,7 @@ var vertRev = {
me.L5 = [" WIND DATA", nil, "wht"];
me.L6 = [" RETURN", nil, "wht"];
me.R2 = ["RTA ", nil, "wht"];
me.R6 = ["DES ", nil, "wht"];
me.arrowsMatrix = [[0, 0, 0, 1, 1, 1], [0, 1, 0, 0, 0, 1]];
me.arrowsMatrix = [[0, 0, 0, 1, 1, 1], [0, 1, 0, 0, 0, 0]];
me.arrowsColour = [["ack", "ack", "ack", "wht", "wht", "wht"], ["ack", "wht", "ack", "ack", "wht", "wht"]];
me.fontMatrix = [[0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0]];
} elsif (me.type == 1) {
@ -102,8 +106,7 @@ var vertRev = {
me.L6 = [" RETURN", nil, "wht"];
me.R2 = ["RTA ", nil, "wht"];
me.R3 = ["3000", "G/S INTCP", "grn"];
me.R6 = ["DES ", nil, "wht"];
me.arrowsMatrix = [[0, 0, 0, 1, 1, 1], [0, 1, 0, 0, 0, 1]];
me.arrowsMatrix = [[0, 0, 0, 1, 1, 1], [0, 1, 0, 0, 0, 0]];
me.arrowsColour = [["ack", "ack", "ack", "wht", "wht", "wht"], ["ack", "wht", "ack", "ack", "wht", "wht"]];
me.fontMatrix = [[0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0]];
}

View file

@ -7,7 +7,7 @@
<channel name="Fuel Pumps and Valves">
<!-- Pumps -->
<switch name="/systems/fuel/pumps/apu-operate">
<switch name="/systems/fuel/pumps/apu-operate"> <!-- DC HOT 1 ? -->
<default value="0"/>
<test logic="AND" value="1">
/systems/fuel/pumps/all-eng-pump-off eq 1