1
0
Fork 0

Merge branch 'dev' into pneumatics

This commit is contained in:
legoboyvdlp R 2020-05-15 12:03:07 +01:00
commit 8e47693170
4 changed files with 173 additions and 63 deletions

View file

@ -228,8 +228,8 @@ var fuel_flow1 = props.globals.getNode("/engines/engine[0]/fuel-flow_actual", 1)
var fuel_flow2 = props.globals.getNode("/engines/engine[1]/fuel-flow_actual", 1);
var fuel_left_outer_temp = props.globals.getNode("/consumables/fuel/tank[0]/temperature_degC", 1);
var fuel_left_inner_temp = props.globals.getNode("/consumables/fuel/tank[1]/temperature_degC", 1);
var fuel_right_outer_temp = props.globals.getNode("/consumables/fuel/tank[3]/temperature_degC", 1);
var fuel_right_inner_temp = props.globals.getNode("/consumables/fuel/tank[4]/temperature_degC", 1);
var fuel_right_outer_temp = props.globals.getNode("/consumables/fuel/tank[4]/temperature_degC", 1);
var fuel_right_inner_temp = props.globals.getNode("/consumables/fuel/tank[3]/temperature_degC", 1);
var cutoff_switch1 = props.globals.getNode("/controls/engines/engine[0]/cutoff-switch", 1);
var cutoff_switch2 = props.globals.getNode("/controls/engines/engine[1]/cutoff-switch", 1);
var fuel_xfeed = props.globals.getNode("/controls/fuel/x-feed", 1);

View file

@ -125,6 +125,8 @@ var flightPlanController = {
me.addDiscontinuity(1, plan);
# reset mcdu if it exists
if (canvas_mcdu.myFpln[0] != nil) { canvas_mcdu.myFpln[0].scroll = 0; }
if (canvas_mcdu.myFpln[1] != nil) { canvas_mcdu.myFpln[1].scroll = 0; }
if (canvas_mcdu.myArrival[0] != nil) { canvas_mcdu.myArrival[0].reset(); }
if (canvas_mcdu.myArrival[1] != nil) { canvas_mcdu.myArrival[1].reset(); }
if (canvas_mcdu.myDeparture[0] != nil) { canvas_mcdu.myDeparture[0].reset(); }
@ -227,11 +229,11 @@ var flightPlanController = {
# 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 = "") {
var coordinates = greatCircleMove(wpt.lat, wpt.lon, bearing, dist);
var coordinates = greatCircleMove(wpt.lat, wpt.lon, num(bearing), num(dist));
if (typeStr != "") {
return createWP(coordinates, name);
} else {
return createWP(coordinates, name, typeStr);
} else {
return createWP(coordinates, name);
}
},
@ -330,6 +332,23 @@ var flightPlanController = {
}
},
# createDuplicateNames - helper to spawn DUPLICATENAMES page
# args: ghostContainer, index, flag, plan
# ghostContainer: vector of fgPositioned ghosts
# index: index
# flag: is it a navaids DUPLICATENAMES page or not?
# plan: plan
# flagPBD: do we return back to PBD handler or to default waypoint handler?
createDuplicateNames: func(ghostContainer, index, flag, plan, flagPBD = 0, bearing = -999, distance = -99) {
if (canvas_mcdu.myDuplicate[plan] != nil) {
canvas_mcdu.myDuplicate[plan].del();
}
canvas_mcdu.myDuplicate[plan] = nil;
canvas_mcdu.myDuplicate[plan] = mcdu.duplicateNamesPage.new(ghostContainer, index, flag, plan, flagPBD, bearing, distance);
setprop("MCDU[" ~ plan ~ "]/page", "DUPLICATENAMES");
},
insertAirport: func(text, index, plan, override = 0, overrideIndex = -1) {
if (index == 0) {
return 1;
@ -371,12 +390,7 @@ var flightPlanController = {
}
}
} elsif (size(airport) >= 1) {
if (canvas_mcdu.myDuplicate[plan] != nil) {
canvas_mcdu.myDuplicate[plan].del();
}
canvas_mcdu.myDuplicate[plan] = nil;
canvas_mcdu.myDuplicate[plan] = mcdu.duplicateNamesPage.new(airport, index, 0, plan);
setprop("MCDU[" ~ plan ~ "]/page", "DUPLICATENAMES");
me.createDuplicateNames(airport, index, 0, plan);
return 2;
}
},
@ -422,12 +436,7 @@ var flightPlanController = {
}
}
} elsif (size(fix) >= 1) {
if (canvas_mcdu.myDuplicate[plan] != nil) {
canvas_mcdu.myDuplicate[plan].del();
}
canvas_mcdu.myDuplicate[plan] = nil;
canvas_mcdu.myDuplicate[plan] = mcdu.duplicateNamesPage.new(fix, index, 0, plan);
setprop("MCDU[" ~ plan ~ "]/page", "DUPLICATENAMES");
me.createDuplicateNames(fix, index, 0, plan);
return 2;
}
},
@ -503,16 +512,92 @@ var flightPlanController = {
}
}
} elsif (size(navaid) >= 1) {
if (canvas_mcdu.myDuplicate[plan] != nil) {
canvas_mcdu.myDuplicate[plan].del();
}
canvas_mcdu.myDuplicate[plan] = nil;
canvas_mcdu.myDuplicate[plan] = mcdu.duplicateNamesPage.new(navaid, index, 1, plan);
setprop("MCDU[" ~ plan ~ "]/page", "DUPLICATENAMES");
me.createDuplicateNames(navaid, index, 1, plan);
return 2;
}
},
# getWPforPBD - parse scratchpad text to find waypoint ghost for PBD
# args: text, index, plan
# text: scratchpad text
# index: index at which waypoint will be inserted
# plan: plan to which waypoint will be inserted
# return:
# 0: not in database
# 1: notAllowed
# 2: o.k.
getWPforPBD: func(text, index, plan, override = 0, overrideIndex = -1) {
if (index == 0) {
return 1;
}
var textSplit = split("/", text);
if (size(split(".", textSplit[2])) != 1 or size(textSplit[1]) < 2 or size(textSplit[1]) > 3) {
return 1;
}
var wpGhost = nil;
var wpGhostContainer = nil;
var type = nil;
if (size(textSplit[0]) == 5) {
wpGhostContainer = findFixesByID(textSplit[0]);
if (size(wpGhostContainer) == 0) {
return 0;
}
type = "fix";
} elsif (size(textSplit[0]) == 4) {
wpGhostContainer = findAirportsByICAO(textSplit[0]);
if (size(wpGhostContainer) == 0) {
return 0;
}
type = "airport";
} elsif (size(textSplit[0]) == 3 or size(textSplit[0]) == 2) {
wpGhostContainer = findNavaidsByID(textSplit[0]);
if (size(wpGhostContainer) == 0) {
return 0;
}
type = "navaid";
} else {
return 1;
}
if (size(wpGhostContainer) == 0 or override) {
if (!override) {
wpGhost = wpGhostContainer[0];
} else {
wpGhost = wpGhostContainer[overrideIndex];
}
} else {
if (type == "navaid") {
me.createDuplicateNames(wpGhostContainer, index, 1, plan, 1, num(textSplit[1]), num(textSplit[2]));
} else {
me.createDuplicateNames(wpGhostContainer, index, 0, plan, 1, num(textSplit[1]), num(textSplit[2]));
}
return 2;
}
var localMagvar = magvar(wpGhost.lat, wpGhost.lon);
me.insertPlaceBearingDistance(wpGhost, textSplit[1] + localMagvar, textSplit[2], index, plan);
return 2;
},
# insertPlaceBearingDistance - insert PBD waypoint at specified index,
# at some specified bearing, distance from a specified location
# args: wp, index, plan
# wpt: waypoint ghost
# index: index to insert at in plan
# plan: plan to insert to
insertPlaceBearingDistance: func(wp, bearing, distance, index, plan) {
me.flightplans[plan].insertWP(me.childWPBearingDistance(wp, bearing, distance, "PBD" ~ index), index);
me.addDiscontinuity(index + 1, plan);
me.flightPlanChanged(plan);
},
scratchpad: func(text, index, plan) { # return 0 not in database, 1 not allowed, 2 success, 3 = not allowed due to dir to
if (mcdu.dirToFlag) {
return 3;
@ -529,7 +614,9 @@ var flightPlanController = {
var thePlan = plan;
}
if (text == "CLR") {
if (size(split("/", text)) == 3) {
return me.getWPforPBD(text, index, thePlan);
} elsif (text == "CLR") {
return me.deleteWP(index, thePlan, 0);
} elsif (size(text) > 12) {
return me.insertLatLonFix(text, index, thePlan);

View file

@ -28,15 +28,18 @@ var duplicateNamesPage = {
enableScroll: 0,
scroll: 0,
distances: nil,
new: func(vector, index, type, computer) {
var fp = {parents:[duplicateNamesPage]};
fp.vector = vector;
fp.index = index;
fp.type = type; # 0 = other, 1 = navaid
fp.computer = computer;
fp._setupPageWithData();
fp.distances = [];
return fp;
new: func(vector, index, type, computer, flagPBD = 0, pbdBrg = -999, pbdDist = -99) {
var dn = {parents:[duplicateNamesPage]};
dn.vector = vector;
dn.index = index;
dn.type = type; # 0 = other, 1 = navaid
dn.flagPBD = flagPBD;
dn.bearing = pbdBrg;
dn.distance = pbdDist;
dn.computer = computer;
dn._setupPageWithData();
dn.distances = [];
return dn;
},
del: func() {
return nil;
@ -131,6 +134,7 @@ var duplicateNamesPage = {
},
pushButtonLeft: func(indexSelect) {
if (!dirToFlag) {
if (!me.flagPBD) {
if (size(me.vector[0].id) == 5) {
fmgc.flightPlanController.insertFix(me.vector[0].id, me.index, me.computer, 1, indexSelect - 1);
setprop("MCDU[" ~ me.computer ~ "]/page", "F-PLNA");
@ -141,6 +145,10 @@ var duplicateNamesPage = {
fmgc.flightPlanController.insertNavaid(me.vector[0].id, me.index, me.computer, 1, indexSelect - 1);
setprop("MCDU[" ~ me.computer ~ "]/page", "F-PLNA");
}
} else {
fmgc.flightPlanController.getWPforPBD(me.vector[0].id ~ "/" ~ me.bearing ~ "/" ~ me.distance, me.index, me.computer, 1, indexSelect - 1);
setprop("MCDU[" ~ me.computer ~ "]/page", "F-PLNA");
}
} else {
canvas_mcdu.myDirTo[me.computer].fieldL1(me.vector[0].id, 1, indexSelect - 1);
setprop("MCDU[" ~ me.computer ~ "]/page", "DIRTO");

View file

@ -41,9 +41,9 @@ var fplnItem = {
}
if (me.index == fmgc.flightPlanController.currentToWptIndex.getValue()) {
me.assembledStr[1] = "BRG" ~ me.getBrg();
} elsif (me.index == (fmgc.flightPlanController.currentToWptIndex.getValue() + 1)) {
me.assembledStr[1] = "TRK" ~ me.getTrack();
me.assembledStr[1] = "BRG" ~ me.getBrg() ~ " ";
} elsif (me.index == (fmgc.flightPlanController.currentToWptIndex.getValue() + 1) or me.index == (fmgc.flightPlanController.arrivalIndex[me.plan] + 1)) {
me.assembledStr[1] = "TRK" ~ me.getTrack() ~ " ";
} else {
me.assembledStr[1] = nil;
}
@ -71,25 +71,32 @@ var fplnItem = {
}
},
getBrg: func() {
me.brg = fmgc.wpCourse[me.plan][me.index].getValue() - pts.Environment.magVar.getValue();
me.brg = fmgc.wpCourse[me.plan][me.index].getValue() - magvar();
if (me.brg < 0) { me.brg += 360; }
if (me.brg > 360) { me.brg -= 360; }
return sprintf("%03.0f", math.round(me.brg));
},
getTrack: func() {
me.trk = fmgc.wpCoursePrev[me.plan][me.index].getValue() - pts.Environment.magVar.getValue();
var wp = fmgc.flightPlanController.flightplans[me.plan].getWP(me.index);
me.trk = fmgc.wpCoursePrev[me.plan][me.index].getValue() - magvar(wp.lat, wp.lon);
if (me.trk < 0) { me.trk += 360; }
if (me.trk > 360) { me.trk -= 360; }
return sprintf("%03.0f", math.round(me.trk));
},
getSpd: func() {
if (me.index == 0 and getprop("FMGC/internal/v1-set")) {
return sprintf("%3.0f", math.round(getprop("FMGC/internal/v1")));
} else {
return "---";
}
},
getAlt: func() {
if (me.index == (fmgc.flightPlanController.currentToWptIndex.getValue() - 1) and fmgc.flightPlanController.fromWptAlt != nil) {
if (me.index == 0 and left(me.wp.wp_name, 4) == getprop("/FMGC/internal/dep-arpt") and fmgc.flightPlanController.flightplans[me.plan].departure != nil) {
return sprintf("%6.0f", math.round(fmgc.flightPlanController.flightplans[me.plan].departure.elevation * M2FT));
} elsif (me.index == (fmgc.flightPlanController.currentToWptIndex.getValue() - 1) and fmgc.flightPlanController.fromWptAlt != nil) {
return " " ~ fmgc.flightPlanController.fromWptAlt;
} else {
return "-----";
return "------";
}
},
getDist: func() {
@ -260,12 +267,15 @@ var fplnPage = { # this one is only created once, and then updated - remember th
createPlanList: func() {
me.planList = [];
if (me.temporaryFlagFpln) {
for (var i = 0; i < me.plan.getPlanSize(); i += 1) {
append(me.planList, fplnItem.new(me.plan.getWP(i), i, me.planIndex, me.computer, "yel"));
}
colour = "yel";
} else {
colour = "grn";
}
for (var i = 0; i < me.plan.getPlanSize(); i += 1) {
append(me.planList, fplnItem.new(me.plan.getWP(i), i, me.planIndex, me.computer));
if (!me.temporaryFlagFpln and i > fmgc.flightPlanController.arrivalIndex[me.planIndex] and getprop("/FMGC/status/phase") != 6) {
append(me.planList, fplnItem.new(me.plan.getWP(i), i, me.planIndex, me.computer, "blu"));
} else {
append(me.planList, fplnItem.new(me.plan.getWP(i), i, me.planIndex, me.computer, colour));
}
}
append(me.planList, staticText.new(me.computer, me.getText("fplnEnd")));
@ -327,16 +337,21 @@ var fplnPage = { # this one is only created once, and then updated - remember th
},
destInfo: func() {
if (me.plan.getWP(fmgc.flightPlanController.arrivalIndex[me.planIndex]) != nil) {
me.L6 = [left(me.plan.getWP(fmgc.flightPlanController.arrivalIndex[me.planIndex]).wp_name, 4), " DEST", "wht"];
var destName = split("-", me.plan.getWP(fmgc.flightPlanController.arrivalIndex[me.planIndex]).wp_name);
if (size(destName) == 2) {
me.L6 = [destName[0] ~ destName[1], " DEST", "wht"];
} else {
me.L6 = [destName[0], " DEST", "wht"];
}
} else {
me.L6 = ["----", " DEST", "wht"];
}
me.C6 = ["---- ", "TIME ", "wht"];
if (fmgc.flightPlanController.arrivalDist != nil) {
me.C6 = ["---- " ~ int(fmgc.flightPlanController.arrivalDist), "TIME DIST", "wht"];
me.R6 = [sprintf("%4.0f", int(fmgc.flightPlanController.arrivalDist)) ~ " --.-", "DIST EFOB", "wht"];
} else {
me.C6 = ["---- ----", "TIME DIST", "wht"];
me.R6 = ["---- --.-", "DIST EFOB", "wht"];
}
me.R6 = ["--.-", "EFOB", "wht"];
},
update: func() {
#me.basePage();