1
0
Fork 0

A/C STATUS page works; deleting works; it won't yet add at the first index (it _does_ add the waypoint to db but doesn't add to the flightplan :(

This commit is contained in:
legoboyvdlp R 2020-05-17 17:53:43 +01:00
parent 7b6f861960
commit eb37ea57fc
5 changed files with 103 additions and 46 deletions

View file

@ -727,7 +727,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();
@ -742,8 +753,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.fontLeft(default, default, default, default, symbol, default);
@ -752,31 +763,59 @@ 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 ");
me["Simple_R5"].setText("DELETE ALL ");
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 (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();

View file

@ -1,6 +1,12 @@
# A3XX FMGC Waypoint database
# Copyright (c) 2020 Josh Davidson (Octal450) and Jonathan Redpath (legoboyvdlp)
var nilTree = {
"latitude": 0,
"longitude": 0,
"ident": "",
};
var WaypointDatabase = {
waypointsVec: [],
# addWP - adds pilot waypoint to waypoints vector
@ -36,7 +42,14 @@ var WaypointDatabase = {
},
# delete - empties waypoints vector
delete: func() {
me.waypointsVec = [];
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;
}
}
}
},
# deleteAtIndex - delete at specific index. Set to nil, so it still exists in vector
deleteAtIndex: func(index) {
@ -84,9 +97,7 @@ var WaypointDatabase = {
},
# write - write to file, as a delimited string
write: func() {
var path = getprop("/sim/fg-home") ~ "/Export/savedWaypoints.txt";
var file = io.open(path, "wb"); # open in write mode
var path = getprop("/sim/fg-home") ~ "/Export/savedWaypoints.xml";
var tree = {
"waypoints": {
@ -99,12 +110,13 @@ var WaypointDatabase = {
if (me.waypointsVec[i] != nil) {
node.getChild("waypoints").addChild(me.waypointsVec[i].tree);
debug.dump(me.waypointsVec[i].tree);
} else {
node.getChild("waypoints").addChild(nilTree);
}
}
debug.dump(node);
io.writexml(file, node); # write the data
io.close(file); # close (and flush) the file stream
io.writexml(path, node); # write the data
},
};

View file

@ -404,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;
}
@ -437,30 +437,6 @@ var flightPlanController = {
}
},
insertLatLonFix: func(text, index, plan) {
if (index == 0) {
return 1;
}
var lat = split("/", text)[0];
var lon = split("/", text)[1];
var latDecimal = mcdu.stringToDegrees(lat, "lat");
var lonDecimal = mcdu.stringToDegrees(lon, "lon");
if (latDecimal > 90 or latDecimal < -90 or lonDecimal > 180 or lonDecimal < -180) {
return 1;
}
var waypoint = pilotWaypoint.new({lat: latDecimal, lon: lonDecimal}, "LL");
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;
},
insertNavaid: func(text, index, plan, override = 0, overrideIndex = -1) {
if (index == 0) {
return 1;
@ -510,6 +486,32 @@ var flightPlanController = {
}
},
insertLatLonFix: func(text, index, plan) {
if (index == 0) {
return 1;
}
var lat = split("/", text)[0];
var lon = split("/", text)[1];
var latDecimal = mcdu.stringToDegrees(lat, "lat");
var lonDecimal = mcdu.stringToDegrees(lon, "lon");
if (latDecimal > 90 or latDecimal < -90 or lonDecimal > 180 or lonDecimal < -180) {
return 1;
}
var waypoint = pilotWaypoint.new({lat: latDecimal, lon: lonDecimal}, "LL");
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;
},
# getWPforPBD - parse scratchpad text to find waypoint ghost for PBD
# args: text, index, plan
# text: scratchpad text

View file

@ -538,6 +538,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") {

View file

@ -5,5 +5,7 @@
var statusInput = func(key, i) {
if (key == "L3") {
fmgc.switchDatabase();
} elsif (key == "R5") {
fmgc.WaypointDatabase.delete();
}
}