From f414119f18185e46f35e6eaff0ce0e11e1561c60 Mon Sep 17 00:00:00 2001 From: vezza Date: Wed, 13 May 2020 22:48:04 +0200 Subject: [PATCH 1/4] BugFix - Fuel temp is odd #128 --- Models/Instruments/Lower-ECAM/Lower-ECAM.nas | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Models/Instruments/Lower-ECAM/Lower-ECAM.nas b/Models/Instruments/Lower-ECAM/Lower-ECAM.nas index 3d9c70ea..58b63651 100644 --- a/Models/Instruments/Lower-ECAM/Lower-ECAM.nas +++ b/Models/Instruments/Lower-ECAM/Lower-ECAM.nas @@ -233,8 +233,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); From 85a34eeb54d54e3a1195bb6e52063c36b96a90fc Mon Sep 17 00:00:00 2001 From: legoboyvdlp R Date: Thu, 14 May 2020 20:02:18 +0100 Subject: [PATCH 2/4] Add Place / Bearing / Distance - uses magnetic heading for now --- Nasal/FMGC/flightplan.nas | 131 +++++++++++++++++++++++++++++++------- Nasal/MCDU/DUPLICATE.nas | 42 +++++++----- Nasal/MCDU/F-PLN.nas | 5 +- 3 files changed, 137 insertions(+), 41 deletions(-) diff --git a/Nasal/FMGC/flightplan.nas b/Nasal/FMGC/flightplan.nas index 009a5ea0..9b3f08e5 100644 --- a/Nasal/FMGC/flightplan.nas +++ b/Nasal/FMGC/flightplan.nas @@ -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); diff --git a/Nasal/MCDU/DUPLICATE.nas b/Nasal/MCDU/DUPLICATE.nas index d782724f..ace8d133 100644 --- a/Nasal/MCDU/DUPLICATE.nas +++ b/Nasal/MCDU/DUPLICATE.nas @@ -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,14 +134,19 @@ var duplicateNamesPage = { }, pushButtonLeft: func(indexSelect) { if (!dirToFlag) { - 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"); - } elsif (size(me.vector[0].id) == 4) { - fmgc.flightPlanController.insertAirport(me.vector[0].id, me.index, me.computer, 1, indexSelect - 1); - setprop("MCDU[" ~ me.computer ~ "]/page", "F-PLNA"); - } elsif (size(me.vector[0].id) == 3 or size(me.vector[0].id)== 2) { - fmgc.flightPlanController.insertNavaid(me.vector[0].id, me.index, me.computer, 1, indexSelect - 1); + 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"); + } elsif (size(me.vector[0].id) == 4) { + fmgc.flightPlanController.insertAirport(me.vector[0].id, me.index, me.computer, 1, indexSelect - 1); + setprop("MCDU[" ~ me.computer ~ "]/page", "F-PLNA"); + } elsif (size(me.vector[0].id) == 3 or size(me.vector[0].id)== 2) { + 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 { diff --git a/Nasal/MCDU/F-PLN.nas b/Nasal/MCDU/F-PLN.nas index 7cc342f6..ff3b1921 100644 --- a/Nasal/MCDU/F-PLN.nas +++ b/Nasal/MCDU/F-PLN.nas @@ -71,13 +71,14 @@ 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)); From 60a18632f48d7ad0bb25cb1ef000b69bde1e50b7 Mon Sep 17 00:00:00 2001 From: legoboyvdlp R Date: Fri, 15 May 2020 00:51:52 +0100 Subject: [PATCH 3/4] FPLN: Missed approach shown in blue (green in go-around); L6 now shows runway code. R1 shows departure elevation and V1 speed. General formatting and spacing improved. Track now displayed on the first missed approach waypoint --- Nasal/MCDU/F-PLN.nas | 60 ++++++++++++++++++++++++++++---------------- 1 file changed, 39 insertions(+), 21 deletions(-) diff --git a/Nasal/MCDU/F-PLN.nas b/Nasal/MCDU/F-PLN.nas index ff3b1921..cc561cf9 100644 --- a/Nasal/MCDU/F-PLN.nas +++ b/Nasal/MCDU/F-PLN.nas @@ -35,15 +35,15 @@ var fplnItem = { if (me.wp != nil) { if (me.wp.wp_name != "DISCONTINUITY") { if (me.index == fmgc.flightPlanController.currentToWptIndex.getValue() - 1 and fmgc.flightPlanController.fromWptTime != nil) { - me.assembledStr[0] = fmgc.flightPlanController.fromWptTime ~ " "; + me.assembledStr[0] = fmgc.flightPlanController.fromWptTime ~ " "; } else { - me.assembledStr[0] = "---- "; + me.assembledStr[0] = "---- "; } 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; } @@ -62,7 +62,11 @@ var fplnItem = { me.spd = me.getSpd(); me.alt = me.getAlt(); me.dist = me.getDist(); - return [me.spd ~ "/" ~ me.alt, " " ~ me.dist ~ "NM ", me.colour]; + if (canvas_mcdu.myFpln[me.computer].scroll - me.index == 0) { + return [me.spd ~ "/" ~ me.alt, " " ~ me.dist ~ "NM ", me.colour]; + } else { + return [me.spd ~ "/" ~ me.alt, " " ~ me.dist ~ " ", me.colour]; + } } else { return [nil, nil, "ack"]; } @@ -84,13 +88,19 @@ var fplnItem = { return sprintf("%03.0f", math.round(me.trk)); }, getSpd: func() { - return "---"; + 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) { - return " " ~ fmgc.flightPlanController.fromWptAlt; + 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() { @@ -261,12 +271,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 { - for (var i = 0; i < me.plan.getPlanSize(); i += 1) { - append(me.planList, fplnItem.new(me.plan.getWP(i), i, me.planIndex, me.computer)); + colour = "grn"; + } + for (var i = 0; i < me.plan.getPlanSize(); i += 1) { + 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"))); @@ -281,9 +294,9 @@ var fplnPage = { # this one is only created once, and then updated - remember th if (size(me.outputList) >= 1) { me.L1 = me.outputList[0].updateLeftText(); me.C1 = me.outputList[0].updateCenterText(); - me.C1[1] = "TIME "; + me.C1[1] = "TIME "; me.R1 = me.outputList[0].updateRightText(); - me.R1[1] = "SPD/ALT "; + me.R1[1] = "SPD/ALT "; } else { me.L1 = [nil, nil, "ack"]; me.C1 = [nil, nil, "ack"]; @@ -328,16 +341,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, " 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(); From 8e021f29b239b5e47476ad88b0bdf2070253d74d Mon Sep 17 00:00:00 2001 From: legoboyvdlp R Date: Fri, 15 May 2020 12:02:29 +0100 Subject: [PATCH 4/4] Sorry - I forgot to add my last bugfixes last night! --- Nasal/MCDU/F-PLN.nas | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/Nasal/MCDU/F-PLN.nas b/Nasal/MCDU/F-PLN.nas index cc561cf9..a4a69201 100644 --- a/Nasal/MCDU/F-PLN.nas +++ b/Nasal/MCDU/F-PLN.nas @@ -62,11 +62,7 @@ var fplnItem = { me.spd = me.getSpd(); me.alt = me.getAlt(); me.dist = me.getDist(); - if (canvas_mcdu.myFpln[me.computer].scroll - me.index == 0) { - return [me.spd ~ "/" ~ me.alt, " " ~ me.dist ~ "NM ", me.colour]; - } else { - return [me.spd ~ "/" ~ me.alt, " " ~ me.dist ~ " ", me.colour]; - } + return [me.spd ~ "/" ~ me.alt, " " ~ me.dist ~ "NM ", me.colour]; } else { return [nil, nil, "ack"]; } @@ -345,7 +341,7 @@ var fplnPage = { # this one is only created once, and then updated - remember th if (size(destName) == 2) { me.L6 = [destName[0] ~ destName[1], " DEST", "wht"]; } else { - me.L6 = [destName, " DEST", "wht"]; + me.L6 = [destName[0], " DEST", "wht"]; } } else { me.L6 = ["----", " DEST", "wht"];