From 692b6dca2bae9eeb4ad0dd6e679f9250306bf7ae Mon Sep 17 00:00:00 2001 From: Jonathan Redpath Date: Sun, 20 Mar 2022 17:27:11 +0000 Subject: [PATCH 01/17] PFD: revise some code for efficiency --- Models/Instruments/PFD/PFD.nas | 158 ++++++++++++++++++++------------- 1 file changed, 94 insertions(+), 64 deletions(-) diff --git a/Models/Instruments/PFD/PFD.nas b/Models/Instruments/PFD/PFD.nas index be3efb55..d661662b 100644 --- a/Models/Instruments/PFD/PFD.nas +++ b/Models/Instruments/PFD/PFD.nas @@ -191,19 +191,31 @@ var canvas_pfd = { obj["LOC_scale"].hide(); obj["GS_scale"].hide(); + obj.temporaryNodes = { + showGroundReferenceAGL: 0, + showTailstrikeAGL: 0, + showTailstrikeGroundspeed: 0, + showTailstrikeThrust: 0, + }; + + obj.AICenter = obj["AI_center"].getCenter(); + obj.update_items = [ - props.UpdateManager.FromHashValue("pitchPFD", nil, func(val) { + props.UpdateManager.FromHashValue("pitchPFD", 0.05, func(val) { obj.AI_horizon_trans.setTranslation(0, val * 11.825); }), - props.UpdateManager.FromHashValue("roll", nil, func(val) { - obj.AI_horizon_rot.setRotation(-val * D2R, obj["AI_center"].getCenter()); - obj.AI_horizon_ground_rot.setRotation(-val * D2R, obj["AI_center"].getCenter()); - obj.AI_horizon_sky_rot.setRotation(-val * D2R, obj["AI_center"].getCenter()); + props.UpdateManager.FromHashValue("roll", 0.1, func(val) { + obj.AI_horizon_rot.setRotation(-val * D2R, obj.AICenter); + obj.AI_horizon_ground_rot.setRotation(-val * D2R, obj.AICenter); + obj.AI_horizon_sky_rot.setRotation(-val * D2R, obj.AICenter); + obj.AI_horizon_hdg_rot.setRotation(-val * D2R, obj.AICenter); obj["AI_bank"].setRotation(-val * D2R); obj["AI_agl_g"].setRotation(-val * D2R); - obj.AI_horizon_hdg_rot.setRotation(-val * D2R, obj["AI_center"].getCenter()); }), - props.UpdateManager.FromHashValue("fbwLaw", nil, func(val) { + props.UpdateManager.FromHashValue("roll", nil, func(val) { + obj.AI_horizon_hdg_rot.setRotation(-val * D2R, obj.AICenter); + }), + props.UpdateManager.FromHashValue("fbwLaw", 1, func(val) { if (val == 0) { obj["AI_bank_lim"].show(); obj["AI_pitch_lim"].show(); @@ -216,22 +228,22 @@ var canvas_pfd = { obj["AI_pitch_lim_X"].show(); } }), - props.UpdateManager.FromHashValue("horizonGround", nil, func(val) { + props.UpdateManager.FromHashValue("horizonGround", 0.1, func(val) { obj.AI_horizon_ground_trans.setTranslation(0, val * 11.825); }), - props.UpdateManager.FromHashValue("horizonPitch", nil, func(val) { + props.UpdateManager.FromHashValue("horizonPitch", 0.1, func(val) { obj.AI_horizon_hdg_trans.setTranslation(obj.middleOffset, val * 11.825); }), - props.UpdateManager.FromHashValue("slipSkid", nil, func(val) { + props.UpdateManager.FromHashValue("slipSkid", 0.1, func(val) { obj["AI_slipskid"].setTranslation(math.clamp(val, -15, 15) * 7, 0); }), - props.UpdateManager.FromHashValue("FDRollBar", nil, func(val) { + props.UpdateManager.FromHashValue("FDRollBar", 0.2, func(val) { obj["FD_roll"].setTranslation(val * 2.2, 0); }), - props.UpdateManager.FromHashValue("FDPitchBar", nil, func(val) { + props.UpdateManager.FromHashValue("FDPitchBar", 0.2, func(val) { obj["FD_pitch"].setTranslation(0, val * -3.8); }), - props.UpdateManager.FromHashValue("agl", nil, func(val) { + props.UpdateManager.FromHashValue("agl", 0.5, func(val) { if (val >= 50) { obj["AI_agl"].setText(sprintf("%s", math.round(math.clamp(val, 0, 2500),10))); } else if (val >= 5) { @@ -240,29 +252,38 @@ var canvas_pfd = { obj["AI_agl"].setText(sprintf("%s", math.round(math.clamp(val, 0, 2500)))); } obj["ground_ref"].setTranslation(0, (-val / 100) * -48.66856); - }), - props.UpdateManager.FromHashList(["agl","gear1Wow", "gear2Wow","fmgcPhase"], nil, func(val) { - if (-val.agl >= -565 and -val.agl <= 565) { - if ((val.fmgcPhase == 5 or val.fmgcPhase == 6) and !val.gear1Wow and !val.gear2Wow) { # TODO: add std too - obj["ground"].setTranslation(0, (-val.agl / 100) * -48.66856); - obj["ground"].show(); - } else { - obj["ground"].hide(); - } + obj["ground"].setTranslation(0, (-val / 100) * -48.66856); + + if (abs(val) <= 565) { + obj.temporaryNodes.showGroundReferenceAGL = 1; } else { - obj["ground"].hide(); + obj.temporaryNodes.showGroundReferenceAGL = 0; + } + + if (val <= 400) { + obj.temporaryNodes.showTailstrikeAGL = 1; + } else { + obj.temporaryNodes.showTailstrikeAGL = 0; } }), - props.UpdateManager.FromHashValue("vsNeedle", nil, func(val) { + props.UpdateManager.FromHashValue("vsNeedle", 0.1, func(val) { obj["VS_pointer"].setRotation(val * D2R); }), - props.UpdateManager.FromHashValue("vsDigit", nil, func(val) { + props.UpdateManager.FromHashValue("vsDigit", 0.5, func(val) { obj["VS_box"].setTranslation(0, val); }), - props.UpdateManager.FromHashValue("localizer", nil, func(val) { + props.UpdateManager.FromHashValue("vsPFD", 0.5, func(val) { + if (val < 2) { + obj["VS_box"].hide(); + } else { + obj["VS_digit"].setText(sprintf("%02d", val)); + obj["VS_box"].show(); + } + }), + props.UpdateManager.FromHashValue("localizer", 0.01, func(val) { obj["LOC_pointer"].setTranslation(val * 197, 0); }), - props.UpdateManager.FromHashValue("glideslope", nil, func(val) { + props.UpdateManager.FromHashValue("glideslope", 0.01, func(val) { obj["GS_pointer"].setTranslation(0, val * -197); }), props.UpdateManager.FromHashList(["athr", "thrustLvrClb"], nil, func(val) { @@ -272,24 +293,11 @@ var canvas_pfd = { obj["FMA_lvrclb"].hide(); } }), - props.UpdateManager.FromHashList(["trackPFD","headingPFD"], nil, func(val) { - obj.track_diff = geo.normdeg180(val.trackPFD - val.headingPFD); + props.UpdateManager.FromHashList(["trackPFD","headingPFD"], 0.1, func(val) { + obj.track_diff = geo.normdeg180(val.trackPFD - val.headingPFD); # store this to use in FPV obj["TRK_pointer"].setTranslation(obj.getTrackDiffPixels(obj.track_diff),0); }), - props.UpdateManager.FromHashValue("vsPFD", nil, func(val) { - if (val < 2) { - obj["VS_box"].hide(); - } else { - obj["VS_box"].show(); - } - - if (val < 10) { - obj["VS_digit"].setText(sprintf("%02d", "0" ~ val)); - } else { - obj["VS_digit"].setText(sprintf("%02d", val)); - } - }), - props.UpdateManager.FromHashList(["vsAutopilot","agl"], nil, func(val) { + props.UpdateManager.FromHashList(["vsAutopilot","agl"], 5, func(val) { if (abs(val.vsAutopilot) >= 6000 or (val.vsAutopilot <= -2000 and val.agl <= 2500) or (val.vsAutopilot <= -1200 and val.agl <= 1000)) { obj["VS_digit"].setColor(0.7333,0.3803,0); obj["VS_pointer"].setColor(0.7333,0.3803,0); @@ -300,10 +308,10 @@ var canvas_pfd = { obj["VS_pointer"].setColorFill(0.0509,0.7529,0.2941); } }), - props.UpdateManager.FromHashList(["aileronPFD","elevatorPFD"], nil, func(val) { + props.UpdateManager.FromHashList(["aileronPFD","elevatorPFD"], 0.01, func(val) { obj["AI_stick_pos"].setTranslation(val.aileronPFD * 196.8, val.elevatorPFD * 151.5); }), - props.UpdateManager.FromHashValue("headingScale", nil, func(val) { + props.UpdateManager.FromHashValue("headingScale", 0.025, func(val) { obj.heading = val; obj.heading10 = (obj.heading / 10); obj.headOffset = obj.heading10 - int(obj.heading10); @@ -368,7 +376,7 @@ var canvas_pfd = { } }), props.UpdateManager.FromHashList(["apBox","apMode"], nil, func(val) { - obj["FMA_ap"].setText(sprintf("%s", val.apMode)); + obj["FMA_athr"].setText(val.apMode); if (val.apBox and val.apMode != " ") { obj["FMA_ap_box"].show(); } else { @@ -376,7 +384,7 @@ var canvas_pfd = { } }), props.UpdateManager.FromHashList(["atBox","atMode"], nil, func(val) { - obj["FMA_athr"].setText(sprintf("%s", val.atMode)); + obj["FMA_athr"].setText(val.atMode); if (val.atBox and val.atMode != " ") { obj["FMA_athr_box"].show(); } else { @@ -384,27 +392,26 @@ var canvas_pfd = { } }), props.UpdateManager.FromHashValue("rollMode", nil, func(val) { - obj["FMA_roll"].setText(sprintf("%s", val)); + obj["FMA_roll"].setText(val); }), props.UpdateManager.FromHashValue("rollModeArmed", nil, func(val) { - obj["FMA_rollarm"].setText(sprintf("%s", val)); + obj["FMA_rollarm"].setText(val); }), props.UpdateManager.FromHashList(["pitchMode","pitchModeBox","autopilotVS","autopilotFPA","pitchMode2Armed","pitchModeArmed","pitchMode2ArmedBox","pitchModeArmedBox","rollMode","rollModeBox","rollModeArmed","rollModeArmedBox","ap1","ap2","fd1","fd2"], nil, func(val) { - obj["FMA_combined"].setText(sprintf("%s", val.pitchMode)); + obj["FMA_combined"].setText(val.pitchMode); if (val.pitchMode == "V/S") { - obj["FMA_pitch"].setText(sprintf("%s ", val.pitchMode)); + obj["FMA_pitch"].setText("V/S "); obj["vsFMArate"].setText(sprintf("%+4.0f",val.autopilotVS)); obj["vsFMArate"].show(); } elsif (val.pitchMode == "FPA") { - obj["FMA_pitch"].setText(sprintf("%s ", val.pitchMode)); + obj["FMA_pitch"].setText("FPA "); obj["vsFMArate"].setText(sprintf("%+3.1f°",val.autopilotFPA)); obj["vsFMArate"].show(); } else { - obj["FMA_pitch"].setText(sprintf("%s", val.pitchMode)); + obj["FMA_pitch"].setText(val.pitchMode); obj["vsFMArate"].hide(); } - if (val.pitchMode == "LAND" or val.pitchMode == "FLARE" or val.pitchMode == "ROLL OUT") { obj["FMA_pitch"].hide(); obj["FMA_roll"].hide(); @@ -455,13 +462,13 @@ var canvas_pfd = { } }), props.UpdateManager.FromHashValue("pitchModeArmed", nil, func(val) { - obj["FMA_pitcharm"].setText(sprintf("%s", val)); + obj["FMA_pitcharm"].setText(val); }), props.UpdateManager.FromHashValue("pitchMode2Armed", nil, func(val) { - obj["FMA_pitcharm2"].setText(sprintf("%s", val)); + obj["FMA_pitcharm2"].setText(val); }), props.UpdateManager.FromHashList(["fdBox","fdMode"], nil, func(val) { - obj["FMA_fd"].setText(sprintf("%s", val.fdMode)); + obj["FMA_fd"].setText(val.fdMode); if (val.fdBox and val.fdMode != " ") { obj["FMA_fd_box"].show(); } else { @@ -680,14 +687,21 @@ var canvas_pfd = { obj["FMA_thrust_box"].setColor(0.8078,0.8039,0.8078); } }), - props.UpdateManager.FromHashValue("flexTemp", nil, func(val) { + props.UpdateManager.FromHashValue("flexTemp", 1, func(val) { obj["FMA_flxtemp"].setText(sprintf("%s", "+" ~ val)); }), - props.UpdateManager.FromHashList(["agl","groundspeed","thr1","thr2"], nil, func(val) { - if (val.agl < 400 and val.groundspeed > 50 and val.thr1 < 0.78 and val.thr2 < 0.78) { - obj["tailstrikeInd"].show(); + props.UpdateManager.FromHashValue("groundspeed", 1, func(val) { + if (val > 50) { + obj.temporaryNodes.showTailstrikeGroundspeed = 1; } else { - obj["tailstrikeInd"].hide(); + obj.temporaryNodes.showTailstrikeGroundspeed = 0; + } + }), + props.UpdateManager.FromHashList(["thr1","thr2"], 0.05, func(val) { + if (val.thr1 < 0.78 and val.thr2 < 0.78) { + obj.temporaryNodes.showTailstrikeThrust = 1; + } else { + obj.temporaryNodes.showTailstrikeThrust = 0; } }), props.UpdateManager.FromHashList(["hdgDiff","showHdg","targetHeading"], nil, func(val) { @@ -836,7 +850,7 @@ var canvas_pfd = { me["FPV"].hide(); } else { me.AI_fpv_trans.setTranslation(me.getTrackDiffPixels(math.clamp(me.track_diff, -21, 21)), math.clamp(me.aoa, -20, 20) * 12.5); - me.AI_fpv_rot.setRotation(-notification.roll * D2R, me["AI_center"].getCenter()); + me.AI_fpv_rot.setRotation(-notification.roll * D2R, obj.AICenter); me["FPV"].setRotation(notification.roll * D2R); # It shouldn't be rotated, only the axis should be me["FPV"].show(); } @@ -1238,7 +1252,7 @@ var canvas_pfd = { me["ASI_trend_down"].hide(); } - if (-notification.agl >= -565 and -notification.agl <= 565) { + if (me.temporaryNodes.showGroundReferenceAGL) { me["ground_ref"].show(); } else { me["ground_ref"].hide(); @@ -1764,6 +1778,22 @@ var canvas_pfd = { me["CRS_pointer"].hide(); } + if (me.temporaryNodes.showGroundReferenceAGL) { + if ((notification.fmgcPhase == 5 or notification.fmgcPhase == 6) and !notification.gear1Wow and !notification.gear2Wow) { # TODO: add std too + me["ground"].show(); + } else { + me["ground"].hide(); + } + } else { + me["ground"].hide(); + } + + if (me.temporaryNodes.showTailstrikeAGL and me.temporaryNodes.showTailstrikeGroundspeed and me.temporaryNodes.showTailstrikeThrust) { + me["tailstrikeInd"].show(); + } else { + me["tailstrikeInd"].hide(); + } + foreach(var update_item; me.update_items) { update_item.update(notification); From 31e486567bc721d897ac44900e0d0bfe58ea9f52 Mon Sep 17 00:00:00 2001 From: Jonathan Redpath Date: Mon, 21 Mar 2022 10:32:00 +0000 Subject: [PATCH 02/17] PFD: split the horizon translate animations --- Models/Instruments/PFD/PFD.nas | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Models/Instruments/PFD/PFD.nas b/Models/Instruments/PFD/PFD.nas index d661662b..213d32e2 100644 --- a/Models/Instruments/PFD/PFD.nas +++ b/Models/Instruments/PFD/PFD.nas @@ -232,7 +232,7 @@ var canvas_pfd = { obj.AI_horizon_ground_trans.setTranslation(0, val * 11.825); }), props.UpdateManager.FromHashValue("horizonPitch", 0.1, func(val) { - obj.AI_horizon_hdg_trans.setTranslation(obj.middleOffset, val * 11.825); + obj.AI_horizon_hdg_trans.setTranslation(0, val * 11.825); }), props.UpdateManager.FromHashValue("slipSkid", 0.1, func(val) { obj["AI_slipskid"].setTranslation(math.clamp(val, -15, 15) * 7, 0); @@ -336,6 +336,7 @@ var canvas_pfd = { obj.middleOffset = -obj.headOffset * 98.5416; } + obj.AI_horizon_hdg_trans.setTranslation(obj.middleOffset, 0); obj["HDG_scale"].setTranslation(obj.middleOffset, 0); obj["HDG_scale"].update(); From b2793c858b5b0c4dc8488e832f2fa520872b37d3 Mon Sep 17 00:00:00 2001 From: Jonathan Redpath Date: Mon, 21 Mar 2022 13:50:12 +0000 Subject: [PATCH 03/17] Move FPV and DME distance to updateManager --- Models/Instruments/PFD/PFD.nas | 43 ++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/Models/Instruments/PFD/PFD.nas b/Models/Instruments/PFD/PFD.nas index 213d32e2..17cd3e4b 100644 --- a/Models/Instruments/PFD/PFD.nas +++ b/Models/Instruments/PFD/PFD.nas @@ -211,9 +211,8 @@ var canvas_pfd = { obj.AI_horizon_hdg_rot.setRotation(-val * D2R, obj.AICenter); obj["AI_bank"].setRotation(-val * D2R); obj["AI_agl_g"].setRotation(-val * D2R); - }), - props.UpdateManager.FromHashValue("roll", nil, func(val) { - obj.AI_horizon_hdg_rot.setRotation(-val * D2R, obj.AICenter); + obj.AI_fpv_rot.setRotation(-val * D2R, obj.AICenter); + obj["FPV"].setRotation(val * D2R); # It shouldn't be rotated, only the axis should }), props.UpdateManager.FromHashValue("fbwLaw", 1, func(val) { if (val == 0) { @@ -231,8 +230,8 @@ var canvas_pfd = { props.UpdateManager.FromHashValue("horizonGround", 0.1, func(val) { obj.AI_horizon_ground_trans.setTranslation(0, val * 11.825); }), - props.UpdateManager.FromHashValue("horizonPitch", 0.1, func(val) { - obj.AI_horizon_hdg_trans.setTranslation(0, val * 11.825); + props.UpdateManager.FromHashList(["middleOffset","horizonPitch"], 0.1, func(val) { + obj.AI_horizon_hdg_trans.setTranslation(val.middleOffset, val.horizonPitch * 11.825); }), props.UpdateManager.FromHashValue("slipSkid", 0.1, func(val) { obj["AI_slipskid"].setTranslation(math.clamp(val, -15, 15) * 7, 0); @@ -297,6 +296,9 @@ var canvas_pfd = { obj.track_diff = geo.normdeg180(val.trackPFD - val.headingPFD); # store this to use in FPV obj["TRK_pointer"].setTranslation(obj.getTrackDiffPixels(obj.track_diff),0); }), + props.UpdateManager.FromHashList(["trackPFD","headingPFD","aoaPFD"], 0.01, func(val) { + obj.AI_fpv_trans.setTranslation(obj.getTrackDiffPixels(math.clamp(obj.track_diff, -21, 21)), math.clamp(val.aoaPFD, -20, 20) * 12.5); + }), props.UpdateManager.FromHashList(["vsAutopilot","agl"], 5, func(val) { if (abs(val.vsAutopilot) >= 6000 or (val.vsAutopilot <= -2000 and val.agl <= 2500) or (val.vsAutopilot <= -1200 and val.agl <= 1000)) { obj["VS_digit"].setColor(0.7333,0.3803,0); @@ -336,7 +338,6 @@ var canvas_pfd = { obj.middleOffset = -obj.headOffset * 98.5416; } - obj.AI_horizon_hdg_trans.setTranslation(obj.middleOffset, 0); obj["HDG_scale"].setTranslation(obj.middleOffset, 0); obj["HDG_scale"].update(); @@ -357,7 +358,7 @@ var canvas_pfd = { obj["HDG_seven"].setFontSize(fontSizeHDG(obj.rightText3), 1); obj["HDG_one"].setFontSize(fontSizeHDG(obj.leftText3), 1); }), - props.UpdateManager.FromHashValue("altitudeAutopilot", nil, func(val) { + props.UpdateManager.FromHashValue("altitudeAutopilot", 50, func(val) { obj["ALT_digit_UP_metric"].setText(sprintf("%5.0fM", val * 0.3048)); }), props.UpdateManager.FromHashList(["fac1","fac2"], nil, func(val) { @@ -763,6 +764,13 @@ var canvas_pfd = { obj["ASI_decimal_DN"].setColor(0.0901,0.6039,0.7176); } }), + props.UpdateManager.FromHashValue("dmeDistance", 0.05, func(val) { + if (val < 19.95) { + obj["dme_dist"].setText(sprintf("%1.1f", val)); + } else { + obj["dme_dist"].setText(sprintf("%2.0f", val)); + } + }), ]; obj.update_items_mismatch = [ @@ -809,6 +817,7 @@ var canvas_pfd = { aoa: 0, showMetricAlt: 0, ASItrendIsShown: 0, + onsideADIRSOperating: 0, update: func(notification) { me.updatePower(notification); @@ -827,6 +836,12 @@ var canvas_pfd = { # Errors if (systems.ADIRS.ADIRunits[(me.number == 0 ? 0 : 1)].operating == 1 or (systems.ADIRS.ADIRunits[2].operating == 1 and notification.attSwitch == (me.number == 0 ? -1 : 1))) { + me.onsideADIRSOperating = 1; + } else { + me.onsideADIRSOperating = 0; + } + + if (me.onsideADIRSOperating) { me["AI_group"].show(); me["HDG_group"].show(); me["AI_error"].hide(); @@ -844,15 +859,13 @@ var canvas_pfd = { me["VS_group"].hide(); } + notification.aoaPFD = (me.number == 0 ? me.getAOAForPFD1() : me.getAOAForPFD2()); + notification.middleOffset = me.middleOffset; # FPV if (notification.trkFpa) { - me.aoa = (me.number == 0 ? me.getAOAForPFD1() : me.getAOAForPFD2()); - if (me.aoa == nil or (systems.ADIRS.ADIRunits[(me.number == 0 ? 0 : 1)].operating != 1) or (systems.ADIRS.ADIRunits[2].operating != 1 and notification.attSwitch == (me.number == 0 ? -1 : 1))){ + if (notification.aoaPFD == nil or !me.onsideADIRSOperating){ me["FPV"].hide(); } else { - me.AI_fpv_trans.setTranslation(me.getTrackDiffPixels(math.clamp(me.track_diff, -21, 21)), math.clamp(me.aoa, -20, 20) * 12.5); - me.AI_fpv_rot.setRotation(-notification.roll * D2R, obj.AICenter); - me["FPV"].setRotation(notification.roll * D2R); # It shouldn't be rotated, only the axis should be me["FPV"].show(); } } else { @@ -1720,12 +1733,6 @@ var canvas_pfd = { if (notification.dmeInRange) { me["dme_dist"].show(); me["dme_dist_legend"].show(); - - if (notification.dmeDistance < 20.0) { - me["dme_dist"].setText(sprintf("%1.1f", notification.dmeDistance)); - } else { - me["dme_dist"].setText(sprintf("%2.0f", notification.dmeDistance)); - } } else { me["dme_dist"].hide(); me["dme_dist_legend"].hide(); From 3ec66e31c189bffc77d2f0f37e3264f33b84fe51 Mon Sep 17 00:00:00 2001 From: Jonathan Redpath Date: Thu, 28 Apr 2022 16:14:30 +0100 Subject: [PATCH 04/17] Begin speed and mach rework --- Models/Instruments/PFD/PFD.nas | 614 ++++++++++++--------------------- 1 file changed, 215 insertions(+), 399 deletions(-) diff --git a/Models/Instruments/PFD/PFD.nas b/Models/Instruments/PFD/PFD.nas index 17cd3e4b..5d1cbe42 100644 --- a/Models/Instruments/PFD/PFD.nas +++ b/Models/Instruments/PFD/PFD.nas @@ -46,6 +46,7 @@ var autoland_pitch_land = props.globals.initNode("/instrumentation/pfd/logic/aut var autoland_ap_disc_ft = props.globals.initNode("/instrumentation/pfd/logic/autoland/ap-disc-ft", 0, "INT"); var canvas_pfd = { + ASItrendIsShown: 0, middleOffset: 0, heading: 0, heading10: 0, @@ -67,15 +68,11 @@ var canvas_pfd = { ASItrend: 0, ASItrgt: 0, ASItrgtdiff: 0, - V1trgt: 0, - VRtrgt: 0, V2trgt: 0, Strgt: 0, Ftrgt: 0, flaptrgt: 0, cleantrgt: 0, - SPDv1trgtdiff: 0, - SPDvrtrgtdiff: 0, SPDv2trgtdiff: 0, SPDstrgtdiff: 0, SPDftrgtdiff: 0, @@ -137,6 +134,7 @@ var canvas_pfd = { obj.units = acconfig_weight_kgs.getValue(); # temporary vars + obj.ASItrendIsShown = 0; obj.middleOffset = 0; obj.heading = 0; obj.heading10 = 0; @@ -158,15 +156,11 @@ var canvas_pfd = { obj.ASItrend = 0; obj.ASItrgt = 0; obj.ASItrgtdiff = 0; - obj.V1trgt = 0; - obj.VRtrgt = 0; obj.V2trgt = 0; obj.Strgt = 0; obj.Ftrgt = 0; obj.flaptrgt = 0; obj.cleantrgt = 0; - obj.SPDv1trgtdiff = 0; - obj.SPDvrtrgtdiff = 0; obj.SPDv2trgtdiff = 0; obj.SPDstrgtdiff = 0; obj.SPDftrgtdiff = 0; @@ -201,10 +195,10 @@ var canvas_pfd = { obj.AICenter = obj["AI_center"].getCenter(); obj.update_items = [ - props.UpdateManager.FromHashValue("pitchPFD", 0.05, func(val) { + props.UpdateManager.FromHashValue("pitchPFD", 0.025, func(val) { obj.AI_horizon_trans.setTranslation(0, val * 11.825); }), - props.UpdateManager.FromHashValue("roll", 0.1, func(val) { + props.UpdateManager.FromHashValue("roll", 0.025, func(val) { obj.AI_horizon_rot.setRotation(-val * D2R, obj.AICenter); obj.AI_horizon_ground_rot.setRotation(-val * D2R, obj.AICenter); obj.AI_horizon_sky_rot.setRotation(-val * D2R, obj.AICenter); @@ -236,20 +230,22 @@ var canvas_pfd = { props.UpdateManager.FromHashValue("slipSkid", 0.1, func(val) { obj["AI_slipskid"].setTranslation(math.clamp(val, -15, 15) * 7, 0); }), - props.UpdateManager.FromHashValue("FDRollBar", 0.2, func(val) { + props.UpdateManager.FromHashValue("FDRollBar", 0.1, func(val) { obj["FD_roll"].setTranslation(val * 2.2, 0); }), - props.UpdateManager.FromHashValue("FDPitchBar", 0.2, func(val) { + props.UpdateManager.FromHashValue("FDPitchBar", 0.1, func(val) { obj["FD_pitch"].setTranslation(0, val * -3.8); }), props.UpdateManager.FromHashValue("agl", 0.5, func(val) { + var roundingFactor = 1; if (val >= 50) { - obj["AI_agl"].setText(sprintf("%s", math.round(math.clamp(val, 0, 2500),10))); + roundingFactor = 10; } else if (val >= 5) { - obj["AI_agl"].setText(sprintf("%s", math.round(math.clamp(val, 0, 2500),5))); - } else { - obj["AI_agl"].setText(sprintf("%s", math.round(math.clamp(val, 0, 2500)))); + roundingFactor = 5; } + + obj["AI_agl"].setText(sprintf("%s", math.round(math.clamp(val, 0, 2500), roundingFactor))); + obj["ground_ref"].setTranslation(0, (-val / 100) * -48.66856); obj["ground"].setTranslation(0, (-val / 100) * -48.66856); @@ -285,7 +281,7 @@ var canvas_pfd = { props.UpdateManager.FromHashValue("glideslope", 0.01, func(val) { obj["GS_pointer"].setTranslation(0, val * -197); }), - props.UpdateManager.FromHashList(["athr", "thrustLvrClb"], nil, func(val) { + props.UpdateManager.FromHashList(["athr", "thrustLvrClb"], 1, func(val) { if (val.athr and val.thrustLvrClb) { obj["FMA_lvrclb"].show(); } else { @@ -361,7 +357,7 @@ var canvas_pfd = { props.UpdateManager.FromHashValue("altitudeAutopilot", 50, func(val) { obj["ALT_digit_UP_metric"].setText(sprintf("%5.0fM", val * 0.3048)); }), - props.UpdateManager.FromHashList(["fac1","fac2"], nil, func(val) { + props.UpdateManager.FromHashList(["fac1","fac2"], 1, func(val) { if (obj.number == 0) { # LHS only acc to manual if (!val.fac1 and !val.fac2) { obj["spdLimError"].show(); @@ -370,7 +366,7 @@ var canvas_pfd = { } } }), - props.UpdateManager.FromHashValue("athrArm", nil, func(val) { + props.UpdateManager.FromHashValue("athrArm", 1, func(val) { if (val != 1) { obj["FMA_athr"].setColor(0.8078,0.8039,0.8078); } else { @@ -477,7 +473,7 @@ var canvas_pfd = { obj["FMA_fd_box"].hide(); } }), - props.UpdateManager.FromHashList(["fd1","fd2","ap1","ap2"], nil, func(val) { + props.UpdateManager.FromHashList(["fd1","fd2","ap1","ap2"], 1, func(val) { if (val.fd1 or val.fd2 or val.ap1 or val.ap2) { obj["FMA_pitcharm"].show(); obj["FMA_pitcharm2"].show(); @@ -492,7 +488,7 @@ var canvas_pfd = { obj["FMA_roll"].hide(); } }), - props.UpdateManager.FromHashList(["gear1Wow","gear2Wow","fmgcPhase","engine1State","engine2State"], nil, func(val) { + props.UpdateManager.FromHashList(["gear1Wow","gear2Wow","fmgcPhase","engine1State","engine2State"], 1, func(val) { if ((val.gear1Wow or val.gear2Wow) and val.fmgcPhase != 0 and val.fmgcPhase != 1) { obj["AI_stick"].show(); obj["AI_stick_pos"].show(); @@ -504,7 +500,7 @@ var canvas_pfd = { obj["AI_stick_pos"].hide(); } }), - props.UpdateManager.FromHashList(["markerO","markerM","markerI"], nil, func(val) { + props.UpdateManager.FromHashList(["markerO","markerM","markerI"], 1, func(val) { if (val.markerO) { obj["outerMarker"].show(); obj["middleMarker"].hide(); @@ -523,7 +519,7 @@ var canvas_pfd = { obj["innerMarker"].hide(); } }), - props.UpdateManager.FromHashList(["pfdILS1","pfdILS2"], nil, func(val) { + props.UpdateManager.FromHashList(["pfdILS1","pfdILS2"], 1, func(val) { if ((obj.number == 0 and val.pfdILS1) or (obj.number == 1 and val.pfdILS2)) { obj["LOC_scale"].show(); obj["GS_scale"].show(); @@ -544,8 +540,8 @@ var canvas_pfd = { obj["GS_pointer"].hide(); } }), - props.UpdateManager.FromHashList(["fd1","fd2","rollMode","pitchMode","trkFpa","pitchPFD","roll","gear1Wow"], nil, func(val) { - if (((obj.number == 0 and val.fd1) or (obj.number == 1 and val.fd2)) and val.trkFpa == 0 and val.pitchPFD < 25 and val.pitchPFD > -13 and val.roll < 45 and val.roll > -45) { + props.UpdateManager.FromHashList(["fd1","fd2","rollMode","pitchMode","trkFpa","pitchWithinLimits","rollWithinLimits","gear1Wow"], nil, func(val) { + if (((obj.number == 0 and val.fd1) or (obj.number == 1 and val.fd2)) and val.trkFpa == 0 and val.pitchWithinLimits and val.rollWithinLimits) { if (val.rollMode != " " and !val.gear1Wow) { obj["FD_roll"].show(); } else { @@ -699,26 +695,30 @@ var canvas_pfd = { obj.temporaryNodes.showTailstrikeGroundspeed = 0; } }), - props.UpdateManager.FromHashList(["thr1","thr2"], 0.05, func(val) { + props.UpdateManager.FromHashList(["thr1","thr2"], 0.005, func(val) { if (val.thr1 < 0.78 and val.thr2 < 0.78) { obj.temporaryNodes.showTailstrikeThrust = 1; } else { obj.temporaryNodes.showTailstrikeThrust = 0; } }), - props.UpdateManager.FromHashList(["hdgDiff","showHdg","targetHeading"], nil, func(val) { + props.UpdateManager.FromHashValue("targetHeading", 0.5, func(val) { + obj["HDG_digit_L"].setText(sprintf("%3.0f", val)); + obj["HDG_digit_R"].setText(sprintf("%3.0f", val)); + }), + props.UpdateManager.FromHashValue("hdgDiff", 0.1, func(val) { + obj["HDG_target"].setTranslation((val / 10) * 98.5416, 0); + }), + props.UpdateManager.FromHashList(["hdgDiff","showHdg"], 0.01, func(val) { if (val.showHdg and val.hdgDiff >= -23.62 and val.hdgDiff <= 23.62) { - obj["HDG_target"].setTranslation((val.hdgDiff / 10) * 98.5416, 0); obj["HDG_digit_L"].hide(); obj["HDG_digit_R"].hide(); obj["HDG_target"].show(); } else if (val.showHdg and val.hdgDiff < -23.62 and val.hdgDiff >= -180) { - obj["HDG_digit_L"].setText(sprintf("%3.0f", val.targetHeading)); obj["HDG_digit_L"].show(); obj["HDG_digit_R"].hide(); obj["HDG_target"].hide(); } else if (val.showHdg and val.hdgDiff > 23.62 and val.hdgDiff <= 180) { - obj["HDG_digit_R"].setText(sprintf("%3.0f", val.targetHeading)); obj["HDG_digit_R"].show(); obj["HDG_digit_L"].hide(); obj["HDG_target"].hide(); @@ -728,14 +728,14 @@ var canvas_pfd = { obj["HDG_target"].hide(); } }), - props.UpdateManager.FromHashList(["altimeterHpa","altimeterInhg","altimeterInhgMode"], nil, func(val) { + props.UpdateManager.FromHashList(["altimeterHpa","altimeterInhg","altimeterInhgMode"], 0.005, func(val) { if (val.altimeterInhgMode == 0) { obj["QNH_setting"].setText(sprintf("%4.0f", val.altimeterHpa)); } else { obj["QNH_setting"].setText(sprintf("%2.2f", val.altimeterInhg)); } }), - props.UpdateManager.FromHashList(["altimeterStd","altitudeAutopilot"], nil, func(val) { + props.UpdateManager.FromHashList(["altimeterStd","altitudeAutopilot"], 25, func(val) { if (val.altimeterStd == 1) { if (val.altitudeAutopilot < 10000) { obj["ALT_digit_UP"].setText(sprintf("%s", "FL " ~ val.altitudeAutopilot / 100)); @@ -749,7 +749,7 @@ var canvas_pfd = { obj["ALT_digit_DN"].setText(sprintf("%5.0f", val.altitudeAutopilot)); } }), - props.UpdateManager.FromHashValue("managedSpd", nil, func(val) { + props.UpdateManager.FromHashValue("managedSpd", 1, func(val) { if (val) { obj["ASI_target"].setColor(0.6901,0.3333,0.7450); obj["ASI_digit_UP"].setColor(0.6901,0.3333,0.7450); @@ -764,13 +764,133 @@ var canvas_pfd = { obj["ASI_decimal_DN"].setColor(0.0901,0.6039,0.7176); } }), - props.UpdateManager.FromHashValue("dmeDistance", 0.05, func(val) { + props.UpdateManager.FromHashValue("dmeDistance", 0.025, func(val) { if (val < 19.95) { obj["dme_dist"].setText(sprintf("%1.1f", val)); } else { obj["dme_dist"].setText(sprintf("%2.0f", val)); } }), + props.UpdateManager.FromHashValue("speedError", 1, func(val) { + if (!val) { + obj["ASI_error"].hide(); + obj["ASI_buss"].hide(); + obj["ASI_buss_ref"].hide(); + obj["ASI_buss_ref_blue"].hide(); + obj["ASI_frame"].setColor(1,1,1); + obj["ASI_group"].show(); + obj["VLS_min"].hide(); + obj["ALPHA_PROT"].hide(); + obj["ALPHA_MAX"].hide(); + obj["ALPHA_SW"].hide(); + } else { + obj["ASI_group"].hide(); + obj["ASI_frame"].setColor(1,0,0); + obj["clean_speed"].hide(); + obj["S_target"].hide(); + obj["F_target"].hide(); + obj["flap_max"].hide(); + obj["v1_group"].hide(); + obj["v1_text"].hide(); + obj["vr_speed"].hide(); + obj["ground"].hide(); # Why? + obj["ground_ref"].hide(); + obj["VLS_min"].hide(); + obj["VLS_min"].hide(); + obj["ALPHA_PROT"].hide(); + obj["ALPHA_MAX"].hide(); + obj["ALPHA_SW"].hide(); + } + }), + props.UpdateManager.FromHashList(["speedError","fac1","fac2"], 1, func(val) { + if (!val.speedError and (val.fac1 or val.fac2)) { + obj["ASI_max"].show(); + } else { + obj["ASI_max"].hide(); + } + }), + props.UpdateManager.FromHashList(["speedError","fac1","fac2","ASItrendIsShown"], 1, func(val) { + if (!val.speedError and (val.fac1 or val.fac2)) { + if (val.ASItrendIsShown == 1) { + obj["ASI_trend_up"].show(); + obj["ASI_trend_down"].hide(); + } else if (val.ASItrendIsShown == -1) { + obj["ASI_trend_up"].hide(); + obj["ASI_trend_down"].show(); + } else { + obj["ASI_trend_up"].hide(); + obj["ASI_trend_down"].hide(); + } + } else { + obj["ASI_trend_up"].hide(); + obj["ASI_trend_down"].hide(); + } + }), + props.UpdateManager.FromHashValue("ASI", 0.5, func(val) { + obj["ASI_scale"].setTranslation(0, val * 6.6); + }), + props.UpdateManager.FromHashValue("ASImax", 0.5, func(val) { + obj["ASI_max"].setTranslation(0, val * -6.6); + }), + props.UpdateManager.FromHashValue("ASItrend", 0.1, func(val) { + obj["ASI_trend_up"].setTranslation(0, math.clamp(val, 0, 50) * -6.6); + obj["ASI_trend_down"].setTranslation(0, math.clamp(val, -50, 0) * -6.6); + }), + props.UpdateManager.FromHashValue("V1trgt", 0.5, func(val) { + obj["v1_group"].setTranslation(0, val * -6.6); + obj["v1_text"].setText(sprintf("%3.0f", fmgc.FMGCInternal.v1)); + }), + props.UpdateManager.FromHashList(["speedError","showVr","SPDv1trgtdiff","fmgcPhase","agl"], 0.5, func(val) { + if (!val.speedError and val.showVr) { + if (val.agl < 55 and val.fmgcPhase <= 2 and abs(val.SPDv1trgtdiff) <= 42) { + obj["v1_group"].show(); + obj["v1_text"].hide(); + } else if (notification.agl < 55 and fmgc.FMGCInternal.phase <= 2) { + obj["v1_group"].hide(); + obj["v1_text"].show(); + } else { + obj["v1_group"].hide(); + obj["v1_text"].hide(); + } + } else { + obj["v1_group"].hide(); + obj["v1_text"].hide(); + } + }), + props.UpdateManager.FromHashValue("VRtrgt", 0.5, func(val) { + obj["vr_speed"].setTranslation(0, val * -6.6); + }), + props.UpdateManager.FromHashList(["speedError","showVr","SPDvrtrgtdiff","fmgcPhase","agl"], 0.5, func(val) { + if (!val.speedError and val.showVr) { + if (val.agl < 55 and val.fmgcPhase <= 2 and abs(val.SPDvrtrgtdiff) <= 42) { + obj["vr_speed"].show(); + } else { + obj["vr_speed"].hide(); + } + } else { + obj["vr_speed"].hide(); + } + }), + props.UpdateManager.FromHashList(["machError","ind_mach"], 0.001, func(val) { + if (val.machError) { + obj["ASI_mach"].hide(); + obj["machError"].show(); + } else { + obj["machError"].hide(); + + if (val.ind_mach >= 0.999) { + obj["ASI_mach"].setText(".999"); + } else { + obj["ASI_mach"].setText(sprintf(".%3.0f", val.ind_mach * 1000)); + } + + if (val.ind_mach >= 0.5) { + obj["ASI_mach"].show(); + } else { + obj["ASI_mach"].hide(); + } + } + }), ]; obj.update_items_mismatch = [ @@ -816,7 +936,6 @@ var canvas_pfd = { }, aoa: 0, showMetricAlt: 0, - ASItrendIsShown: 0, onsideADIRSOperating: 0, update: func(notification) { me.updatePower(notification); @@ -861,6 +980,20 @@ var canvas_pfd = { notification.aoaPFD = (me.number == 0 ? me.getAOAForPFD1() : me.getAOAForPFD2()); notification.middleOffset = me.middleOffset; + + # FD Hide / Show + if (notification.pitchPFD < 25 and notification.pitchPFD > -13) { + notification.pitchWithinLimits = 1; + } else { + notification.pitchWithinLimits = 0; + } + + if (abs(notification.roll) < 45) { + notification.rollWithinLimits = 1; + } else { + notification.rollWithinLimits = 0; + } + # FPV if (notification.trkFpa) { if (notification.aoaPFD == nil or !me.onsideADIRSOperating){ @@ -900,379 +1033,80 @@ var canvas_pfd = { me["ilsError"].hide(); } + # Airspeed if (dmc.DMController.DMCs[me.number].outputs[0] != nil) { me.ind_spd = dmc.DMController.DMCs[me.number].outputs[0].getValue(); - me["ASI_error"].hide(); - me["ASI_buss"].hide(); - me["ASI_buss_ref"].hide(); - me["ASI_buss_ref_blue"].hide(); - me["ASI_frame"].setColor(1,1,1); - me["ASI_group"].show(); - me["VLS_min"].hide(); - me["ALPHA_PROT"].hide(); - me["ALPHA_MAX"].hide(); - me["ALPHA_SW"].hide(); + notification.speedError = 0; if (me.ind_spd <= 30) { - me.ASI = 0; + notification.ASI = 0; } else if (me.ind_spd >= 420) { - me.ASI = 390; + notification.ASI = 390; } else { - me.ASI = me.ind_spd - 30; + notification.ASI = me.ind_spd - 30; } if (fmgc.FMGCInternal.maxspeed <= 30) { - me.ASImax = 0 - me.ASI; + notification.ASImax = 0 - me.ASI; } else if (fmgc.FMGCInternal.maxspeed >= 420) { - me.ASImax = 390 - me.ASI; + notification.ASImax = 390 - me.ASI; } else { - me.ASImax = fmgc.FMGCInternal.maxspeed - 30 - me.ASI; - } - - me["ASI_scale"].setTranslation(0, me.ASI * 6.6); - - if (notification.fac1 or notification.fac2) { - me["ASI_max"].setTranslation(0, me.ASImax * -6.6); - me["ASI_max"].show(); - } else { - me["ASI_max"].hide(); - } - - if (!fmgc.FMGCInternal.takeoffState and fmgc.FMGCInternal.phase >= 1 and !notification.gear1Wow and !notification.gear2Wow) { - if (fmgc.FMGCInternal.vls_min <= 30) { - me.VLSmin = 0 - me.ASI; - } else if (fmgc.FMGCInternal.vls_min >= 420) { - me.VLSmin = 390 - me.ASI; - } else { - me.VLSmin = fmgc.FMGCInternal.vls_min - 30 - me.ASI; - } - - if (fmgc.FMGCInternal.alpha_prot <= 30) { - me.ALPHAprot = 0 - me.ASI; - } else if (fmgc.FMGCInternal.alpha_prot >= 420) { - me.ALPHAprot = 390 - me.ASI; - } else { - me.ALPHAprot = fmgc.FMGCInternal.alpha_prot - 30 - me.ASI; - } - - if (fmgc.FMGCInternal.alpha_max <= 30) { - me.ALPHAmax = 0 - me.ASI; - } else if (fmgc.FMGCInternal.alpha_max >= 420) { - me.ALPHAmax = 390 - me.ASI; - } else { - me.ALPHAmax = fmgc.FMGCInternal.alpha_max - 30 - me.ASI; - } - - if (fmgc.FMGCInternal.vsw <= 30) { - me.ALPHAvsw = 0 - me.ASI; - } else if (fmgc.FMGCInternal.vsw >= 420) { - me.ALPHAvsw = 390 - me.ASI; - } else { - me.ALPHAvsw = fmgc.FMGCInternal.vsw - 30 - me.ASI; - } - - if (notification.fac1 or notification.fac2) { - me["VLS_min"].setTranslation(0, me.VLSmin * -6.6); - me["VLS_min"].show(); - if (notification.fbwLaw == 0) { - me["ALPHA_PROT"].setTranslation(0, me.ALPHAprot * -6.6); - me["ALPHA_MAX"].setTranslation(0, me.ALPHAmax * -6.6); - me["ALPHA_PROT"].show(); - me["ALPHA_MAX"].show(); - me["ALPHA_SW"].hide(); - } else { - me["ALPHA_PROT"].hide(); - me["ALPHA_MAX"].hide(); - me["ALPHA_SW"].setTranslation(0, me.ALPHAvsw * -6.6); - me["ALPHA_SW"].show(); - } - } else { - me["VLS_min"].hide(); - me["ALPHA_PROT"].hide(); - me["ALPHA_MAX"].hide(); - me["ALPHA_SW"].hide(); - } - } - - me.tgt_ias = notification.targetIasPFD; - me.tgt_kts = notification.targetKts; - - if (notification.managedSpd) { - if (fmgc.FMGCInternal.decel) { - me.tgt_ias = fmgc.FMGCInternal.vappSpeedSet ? fmgc.FMGCInternal.vapp_appr : fmgc.FMGCInternal.vapp; - me.tgt_kts = fmgc.FMGCInternal.vappSpeedSet ? fmgc.FMGCInternal.vapp_appr : fmgc.FMGCInternal.vapp; - } else if (fmgc.FMGCInternal.phase == 6) { - me.tgt_ias = fmgc.FMGCInternal.clean; - me.tgt_kts = fmgc.FMGCInternal.clean; - } - } - - if (me.tgt_ias <= 30) { - me.ASItrgt = 0 - me.ASI; - } else if (me.tgt_ias >= 420) { - me.ASItrgt = 390 - me.ASI; - } else { - me.ASItrgt = me.tgt_ias - 30 - me.ASI; - } - - me.ASItrgtdiff = me.tgt_ias - me.ind_spd; - - if (me.ASItrgtdiff >= -42 and me.ASItrgtdiff <= 42) { - me["ASI_target"].setTranslation(0, me.ASItrgt * -6.6); - me["ASI_digit_UP"].hide(); - me["ASI_decimal_UP"].hide(); - me["ASI_digit_DN"].hide(); - me["ASI_decimal_DN"].hide(); - me["ASI_target"].show(); - } else if (me.ASItrgtdiff < -42) { - if (notification.ktsMach) { - me["ASI_digit_DN"].setText(sprintf("%3.0f", notification.targetMach * 1000)); - me["ASI_decimal_UP"].hide(); - me["ASI_decimal_DN"].show(); - } else { - me["ASI_digit_DN"].setText(sprintf("%3.0f", me.tgt_kts)); - me["ASI_decimal_UP"].hide(); - me["ASI_decimal_DN"].hide(); - } - me["ASI_digit_DN"].show(); - me["ASI_digit_UP"].hide(); - me["ASI_target"].hide(); - } else if (me.ASItrgtdiff > 42) { - if (notification.ktsMach) { - me["ASI_digit_UP"].setText(sprintf("%3.0f", notification.targetMach * 1000)); - me["ASI_decimal_UP"].show(); - me["ASI_decimal_DN"].hide(); - } else { - me["ASI_digit_UP"].setText(sprintf("%3.0f", me.tgt_kts)); - me["ASI_decimal_UP"].hide(); - me["ASI_decimal_DN"].hide(); - } - me["ASI_digit_UP"].show(); - me["ASI_digit_DN"].hide(); - me["ASI_target"].hide(); + notification.ASImax = fmgc.FMGCInternal.maxspeed - 30 - notification.ASI; } if (fmgc.FMGCInternal.v1set) { if (fmgc.FMGCInternal.v1 <= 30) { - me.V1trgt = 0 - me.ASI; + notification.V1trgt = 0 - notification.ASI; } else if (fmgc.FMGCInternal.v1 >= 420) { - me.V1trgt = 390 - me.ASI; + notification.V1trgt = 390 - notification.ASI; } else { - me.V1trgt = fmgc.FMGCInternal.v1 - 30 - me.ASI; + notification.V1trgt = fmgc.FMGCInternal.v1 - 30 - notification.ASI; } - me.SPDv1trgtdiff = fmgc.FMGCInternal.v1 - me.ind_spd; - - if (notification.agl < 55 and fmgc.FMGCInternal.phase <= 2 and me.SPDv1trgtdiff >= -42 and me.SPDv1trgtdiff <= 42) { - me["v1_group"].show(); - me["v1_text"].hide(); - me["v1_group"].setTranslation(0, me.V1trgt * -6.6); - } else if (notification.agl < 55 and fmgc.FMGCInternal.phase <= 2) { - me["v1_group"].hide(); - me["v1_text"].show(); - me["v1_text"].setText(sprintf("%3.0f", fmgc.FMGCInternal.v1)); - } else { - me["v1_group"].hide(); - me["v1_text"].hide(); - } + notification.SPDv1trgtdiff = fmgc.FMGCInternal.v1 - me.ind_spd; + notification.showV1 = 1; } else { - me["v1_group"].hide(); - me["v1_text"].hide(); + notification.V1trgt = 0; + notification.SPDv1trgtdiff = 0; + notification.showV1 = 0; } if (fmgc.FMGCInternal.vrset) { if (fmgc.FMGCInternal.vr <= 30) { - me.VRtrgt = 0 - me.ASI; + notification.VRtrgt = 0 - notification.ASI; } else if (fmgc.FMGCInternal.vr >= 420) { - me.VRtrgt = 390 - me.ASI; + notification.VRtrgt = 390 - notification.ASI; } else { - me.VRtrgt = fmgc.FMGCInternal.vr - 30 - me.ASI; + notification.VRtrgt = fmgc.FMGCInternal.vr - 30 - notification.ASI; } - me.SPDvrtrgtdiff = fmgc.FMGCInternal.vr - me.ind_spd; - - if (notification.agl < 55 and fmgc.FMGCInternal.phase <= 2 and me.SPDvrtrgtdiff >= -42 and me.SPDvrtrgtdiff <= 42) { - me["vr_speed"].show(); - me["vr_speed"].setTranslation(0, me.VRtrgt * -6.6); - } else { - me["vr_speed"].hide(); - } + notification.SPDvrtrgtdiff = fmgc.FMGCInternal.vr - me.ind_spd; + notification.showVr = 1; } else { - me["vr_speed"].hide(); + notification.VRtrgt = 0; + notification.SPDvrtrgtdiff = 0; + notification.showVr = 0; } - if (fmgc.FMGCInternal.v2set) { - if (fmgc.FMGCInternal.v2 <= 30) { - me.V2trgt = 0 - me.ASI; - } else if (fmgc.FMGCInternal.v2 >= 420) { - me.V2trgt = 390 - me.ASI; - } else { - me.V2trgt = fmgc.FMGCInternal.v2 - 30 - me.ASI; - } - - me.SPDv2trgtdiff = fmgc.FMGCInternal.v2 - me.ind_spd; - - if (notification.agl < 55 and fmgc.FMGCInternal.phase <= 2 and me.SPDv2trgtdiff >= -42 and me.SPDv2trgtdiff <= 42) { - me["ASI_target"].show(); - me["ASI_target"].setTranslation(0, me.V2trgt * -6.6); - me["ASI_digit_UP"].setText(sprintf("%3.0f", fmgc.FMGCInternal.v2)); - } else if (notification.agl < 55 and fmgc.FMGCInternal.phase <= 2) { - me["ASI_target"].hide(); - me["ASI_digit_UP"].setText(sprintf("%3.0f", fmgc.FMGCInternal.v2)); - } - } - - if (notification.fac1 or notification.fac2) { - if (notification.flapsInput == '1') { - me["F_target"].hide(); - me["clean_speed"].hide(); - - if (fmgc.FMGCInternal.slat <= 30) { - me.Strgt = 0 - me.ASI; - } else if (fmgc.FMGCInternal.slat >= 420) { - me.Strgt = 390 - me.ASI; - } else { - me.Strgt = fmgc.FMGCInternal.slat - 30 - me.ASI; - } - - me.SPDstrgtdiff = fmgc.FMGCInternal.slat - me.ind_spd; - - if (me.SPDstrgtdiff >= -42 and me.SPDstrgtdiff <= 42 and notification.agl >= 400) { - me["S_target"].show(); - me["S_target"].setTranslation(0, me.Strgt * -6.6); - } else { - me["S_target"].hide(); - } - - me.SPDflaptrgtdiff = 200 - me.ind_spd; - - if (me.SPDflaptrgtdiff >= -42 and me.SPDflaptrgtdiff <= 42) { - me["flap_max"].show(); - me["flap_max"].setTranslation(0, (200 - 30 - me.ASI) * -6.6); - } else { - me["flap_max"].hide(); - } - } else if (notification.flapsInput == '2') { - me["S_target"].hide(); - me["clean_speed"].hide(); - - if (fmgc.FMGCInternal.flap2 <= 30) { - me.Ftrgt = 0 - me.ASI; - } else if (fmgc.FMGCInternal.flap2 >= 420) { - me.Ftrgt = 390 - me.ASI; - } else { - me.Ftrgt = fmgc.FMGCInternal.flap2 - 30 - me.ASI; - } - - me.SPDftrgtdiff = fmgc.FMGCInternal.flap2 - me.ind_spd; - - if (me.SPDftrgtdiff >= -42 and me.SPDftrgtdiff <= 42 and notification.agl >= 400) { - me["F_target"].show(); - me["F_target"].setTranslation(0, me.Ftrgt * -6.6); - } else { - me["F_target"].hide(); - } - - me.SPDflaptrgtdiff = 185 - me.ind_spd; - - if (me.SPDflaptrgtdiff >= -42 and me.SPDflaptrgtdiff <= 42) { - me["flap_max"].show(); - me["flap_max"].setTranslation(0, (185 - 30 - me.ASI) * -6.6); - } else { - me["flap_max"].hide(); - } - } else if (notification.flapsInput == '3') { - me["S_target"].hide(); - me["clean_speed"].hide(); - - if (fmgc.FMGCInternal.flap3 <= 30) { - me.Ftrgt = 0 - me.ASI; - } else if (fmgc.FMGCInternal.flap3 >= 420) { - me.Ftrgt = 390 - me.ASI; - } else { - me.Ftrgt = fmgc.FMGCInternal.flap3 - 30 - me.ASI; - } - - me.SPDftrgtdiff = fmgc.FMGCInternal.flap3 - me.ind_spd; - - if (me.SPDftrgtdiff >= -42 and me.SPDftrgtdiff <= 42 and notification.agl >= 400) { - me["F_target"].show(); - me["F_target"].setTranslation(0, me.Ftrgt * -6.6); - } else { - me["F_target"].hide(); - } - - me.SPDflaptrgtdiff = 177 - me.ind_spd; - - if (me.SPDflaptrgtdiff >= -42 and me.SPDflaptrgtdiff <= 42) { - me["flap_max"].show(); - me["flap_max"].setTranslation(0, (177 - 30 - me.ASI) * -6.6); - } else { - me["flap_max"].hide(); - } - } else if (notification.flapsInput == '4') { - me["S_target"].hide(); - me["F_target"].hide(); - me["clean_speed"].hide(); - me["flap_max"].hide(); - } else { - me["S_target"].hide(); - me["F_target"].hide(); - - me.SPDcleantrgtdiff = fmgc.FMGCInternal.clean - me.ind_spd; - - if (me.SPDcleantrgtdiff >= -42 and me.SPDcleantrgtdiff <= 42) { - me["clean_speed"].show(); - me["clean_speed"].setTranslation(0, (fmgc.FMGCInternal.clean - 30 - me.ASI) * -6.6); - } else { - me["clean_speed"].hide(); - } - - me.SPDflaptrgtdiff = 230 - me.ind_spd; - - if (me.SPDflaptrgtdiff >= -42 and me.SPDflaptrgtdiff <= 42) { - me["flap_max"].show(); - me["flap_max"].setTranslation(0, (230 - 30 - me.ASI) * -6.6); - } else { - me["flap_max"].hide(); - } - } + notification.ASItrend = dmc.DMController.DMCs[me.number].outputs[6].getValue() - notification.ASI; + if (notification.ASItrend >= 2 or (me.ASItrendIsShown != 0 and notification.ASItrend >= 1)) { + me.ASItrendIsShown = 1; + } else if (me.ASItrend <= -2 or (me.ASItrendIsShown != 0 and notification.ASItrend <= -1)) { + me.ASItrendIsShown = -1; } else { - me["S_target"].hide(); - me["F_target"].hide(); - me["clean_speed"].hide(); - me["flap_max"].hide(); + me.ASItrendIsShown = 0; } - - me.ASItrend = dmc.DMController.DMCs[me.number].outputs[6].getValue() - me.ASI; - me["ASI_trend_up"].setTranslation(0, math.clamp(me.ASItrend, 0, 50) * -6.6); - me["ASI_trend_down"].setTranslation(0, math.clamp(me.ASItrend, -50, 0) * -6.6); - - if (notification.fac1 or notification.fac2) { - if (me.ASItrend >= 2 or (me.ASItrendIsShown and me.ASItrend >= 1)) { - me["ASI_trend_up"].show(); - me["ASI_trend_down"].hide(); - me.ASItrendIsShown = 1; - } else if (me.ASItrend <= -2 or (me.ASItrendIsShown and me.ASItrend <= -1)) { - me["ASI_trend_up"].hide(); - me["ASI_trend_down"].show(); - me.ASItrendIsShown = 1; - } else { - me["ASI_trend_up"].hide(); - me["ASI_trend_down"].hide(); - } - } else { - me["ASI_trend_up"].hide(); - me["ASI_trend_down"].hide(); - } - + notification.ASItrendIsShown = me.ASItrendIsShown; + if (me.temporaryNodes.showGroundReferenceAGL) { me["ground_ref"].show(); } else { me["ground_ref"].hide(); } } else { - me["ASI_group"].hide(); + me.ind_spd = dmc.DMController.DMCs[me.number].outputs[0].getValue(); + notification.speedError = 1; + if (!systems.ADIRS.Operating.adr[0].getValue() and !systems.ADIRS.Operating.adr[1].getValue() and !systems.ADIRS.Operating.adr[2].getValue()) { me["ASI_buss"].show(); me["ASI_buss_ref"].show(); @@ -1286,40 +1120,22 @@ var canvas_pfd = { me["ASI_buss_ref_blue"].hide(); me["ASI_error"].show(); } - me["ASI_frame"].setColor(1,0,0); - me["clean_speed"].hide(); - me["S_target"].hide(); - me["F_target"].hide(); - me["flap_max"].hide(); - me["v1_group"].hide(); - me["v1_text"].hide(); - me["vr_speed"].hide(); - me["ground"].hide(); - me["ground_ref"].hide(); - me["VLS_min"].hide(); - me["VLS_min"].hide(); - me["ALPHA_PROT"].hide(); - me["ALPHA_MAX"].hide(); - me["ALPHA_SW"].hide(); + + notification.ASItrendIsShown = 0; + notification.V1trgt = 0; + notification.SPDv1trgtdiff = 0; + notification.showV1 = 0; + notification.VRtrgt = 0; + notification.SPDvrtrgtdiff = 0; + notification.showVr = 0; } + # Mach if (dmc.DMController.DMCs[me.number].outputs[2] != nil) { - me.ind_mach = dmc.DMController.DMCs[me.number].outputs[2].getValue(); - me["machError"].hide(); - - if (me.ind_mach >= 0.999) { - me["ASI_mach"].setText(".999"); - } else { - me["ASI_mach"].setText(sprintf(".%3.0f", me.ind_mach * 1000)); - } - - if (me.ind_mach >= 0.5) { - me["ASI_mach"].show(); - } else { - me["ASI_mach"].hide(); - } + notification.ind_mach = dmc.DMController.DMCs[me.number].outputs[2].getValue(); + notification.machError = 0; } else { - me["machError"].show(); + notification.machError = 1; } # Altitude From da6dfac9ffc2b7874ab5ec73da33e3d78cb08fba Mon Sep 17 00:00:00 2001 From: Jonathan Redpath Date: Thu, 28 Apr 2022 19:08:09 +0100 Subject: [PATCH 05/17] Finish moving airspeed to emesary --- Models/Instruments/PFD/PFD.nas | 363 ++++++++++++++++++++++++++++----- 1 file changed, 314 insertions(+), 49 deletions(-) diff --git a/Models/Instruments/PFD/PFD.nas b/Models/Instruments/PFD/PFD.nas index 5d1cbe42..177d374c 100644 --- a/Models/Instruments/PFD/PFD.nas +++ b/Models/Instruments/PFD/PFD.nas @@ -47,6 +47,7 @@ var autoland_ap_disc_ft = props.globals.initNode("/instrumentation/pfd/logic/aut var canvas_pfd = { ASItrendIsShown: 0, + middleOffset: 0, heading: 0, heading10: 0, @@ -63,26 +64,6 @@ var canvas_pfd = { magnetic_hdg: 0, magnetic_hdg_dif: 0, alt_diff_cur: 0, - ASI: 0, - ASImax: 0, - ASItrend: 0, - ASItrgt: 0, - ASItrgtdiff: 0, - V2trgt: 0, - Strgt: 0, - Ftrgt: 0, - flaptrgt: 0, - cleantrgt: 0, - SPDv2trgtdiff: 0, - SPDstrgtdiff: 0, - SPDftrgtdiff: 0, - SPDflaptrgtdiff: 0, - SPDcleantrgtdiff: 0, - ind_mach: 0, - ind_spd: 0, - tgt_kts: 0, - tgt_ias: 0, - vapp: 0, new: func(svg, name, number) { var obj = {parents: [canvas_pfd] }; obj.canvas = canvas.new({ @@ -151,26 +132,6 @@ var canvas_pfd = { obj.magnetic_hdg = 0; obj.magnetic_hdg_dif = 0; obj.alt_diff_cur = 0; - obj.ASI = 0; - obj.ASImax = 0; - obj.ASItrend = 0; - obj.ASItrgt = 0; - obj.ASItrgtdiff = 0; - obj.V2trgt = 0; - obj.Strgt = 0; - obj.Ftrgt = 0; - obj.flaptrgt = 0; - obj.cleantrgt = 0; - obj.SPDv2trgtdiff = 0; - obj.SPDstrgtdiff = 0; - obj.SPDftrgtdiff = 0; - obj.SPDflaptrgtdiff = 0; - obj.SPDcleantrgtdiff = 0; - obj.ind_mach = 0; - obj.ind_spd = 0; - obj.tgt_kts = 0; - obj.tgt_ias = 0; - obj.vapp = 0; # hide non-updated objects obj["FMA_catmode"].hide(); @@ -845,7 +806,7 @@ var canvas_pfd = { if (val.agl < 55 and val.fmgcPhase <= 2 and abs(val.SPDv1trgtdiff) <= 42) { obj["v1_group"].show(); obj["v1_text"].hide(); - } else if (notification.agl < 55 and fmgc.FMGCInternal.phase <= 2) { + } else if (val.agl < 55 and fmgc.FMGCInternal.phase <= 2) { obj["v1_group"].hide(); obj["v1_text"].show(); } else { @@ -871,6 +832,18 @@ var canvas_pfd = { obj["vr_speed"].hide(); } }), + props.UpdateManager.FromHashList(["speedError","showV2","SPDv2trgtdiff","fmgcPhase","agl","V2trgt"], 0.5, func(val) { + if (!val.speedError and val.showVr) { + if (val.agl < 55 and val.fmgcPhase <= 2 and abs(val.SPDv2trgtdiff) <= 42) { + obj["ASI_target"].show(); + obj["ASI_target"].setTranslation(0, me.V2trgt * -6.6); + obj["ASI_digit_UP"].setText(sprintf("%3.0f", fmgc.FMGCInternal.v2)); + } else if (val.agl < 55 and fmgc.FMGCInternal.phase <= 2) { + obj["ASI_target"].hide(); + obj["ASI_digit_UP"].setText(sprintf("%3.0f", fmgc.FMGCInternal.v2)); + } + } + }), props.UpdateManager.FromHashList(["machError","ind_mach"], 0.001, func(val) { if (val.machError) { obj["ASI_mach"].hide(); @@ -891,6 +864,145 @@ var canvas_pfd = { } } }), + props.UpdateManager.FromHashList(["flapMaxSpeed","ASI"], 0.5, func(val) { + obj["flap_max"].setTranslation(0, (val.flapMaxSpeed - 30 - val.ASI) * -6.6); + }), + props.UpdateManager.FromHashList(["speedError","fac1","fac2","flapMaxSpeed","flapsInput","ind_spd"], 0.5, func(val) { + if (!val.speedError and (val.fac1 or val.fac2)) { + if (abs(val.flapMaxSpeed - val.ind_spd) <= 42 and val.flapsInput != 4) { + obj["flap_max"].show(); + } else { + obj["flap_max"].hide(); + } + } else { + obj["flap_max"].hide(); + } + }), + props.UpdateManager.FromHashValue("Ctrgt", , 0.5, func(val) { + obj["clean_speed"].setTranslation(0, val * -6.6); + }), + props.UpdateManager.FromHashValue("Ftrgt", 0.5, func(val) { + obj["F_target"].setTranslation(0, val * -6.6); + }), + props.UpdateManager.FromHashValue("Strgt", 0.5, func(val) { + obj["S_target"].setTranslation(0, val * -6.6); + }), + props.UpdateManager.FromHashList(["speedError","fac1","fac2","flapsInput","SPDstrgtdiff","SPDftrgtdiff","SPDcleantrgtdiff","agl"], 0.5, func(val) { + if (!val.speedError and (val.fac1 or val.fac2)) { + if (val.flapsInput == 1) { + obj["F_target"].hide(); + obj["clean_speed"].hide(); + + if (abs(val.SPDstrgtdiff) <= 42 and val.agl >= 400) { + obj["S_target"].show(); + } else { + obj["S_target"].hide(); + } + } else if (val.flapsInput == 2 or val.flapsInput == 3) { + obj["S_target"].hide(); + obj["clean_speed"].hide(); + + if (abs(val.SPDftrgtdiff) <= 42 and val.agl >= 400) { + obj["F_target"].show(); + } else { + obj["F_target"].hide(); + } + } else if (val.flapsInput == 4) { + obj["S_target"].hide(); + obj["F_target"].hide(); + obj["clean_speed"].hide(); + } else { + obj["S_target"].hide(); + obj["F_target"].hide(); + + if (abs(val.SPDcleantrgtdiff) <= 42) { + obj["clean_speed"].show(); + } else { + obj["clean_speed"].hide(); + } + + } + } else { + obj["S_target"].hide(); + obj["F_target"].hide(); + obj["clean_speed"].hide(); + } + }), + props.UpdateManager.FromHashValue("bussTranslate", 0.2, func(val) { + obj["ASI_buss"].setTranslation(0, val); + obj["ASI_buss_ref_blue"].setTranslation(0, val); + }), + props.UpdateManager.FromHashList(["speedError","fac1","fac2","fbwLaw","fmgcPhase","gear1Wow","gear2Wow","fmgcTakeoffState"], 1, func(val) { + if (!val.fmgcTakeoffState and val.fmgcPhase >= 1 and !val.gear1Wow and !val.gear2Wow and !val.speedError and (val.fac1 or val.fac2)) { + obj["VLS_min"].show(); + if (val.fbwLaw == 0) { + obj["ALPHA_PROT"].show(); + obj["ALPHA_MAX"].show(); + obj["ALPHA_SW"].hide(); + } else { + obj["ALPHA_PROT"].hide(); + obj["ALPHA_MAX"].hide(); + obj["ALPHA_SW"].show(); + } + } else { + obj["VLS_min"].hide(); + obj["ALPHA_PROT"].hide(); + obj["ALPHA_MAX"].hide(); + obj["ALPHA_SW"].hide(); + } + }), + props.UpdateManager.FromHashValue("ALPHAprot", 0.5, func(val) { + obj["ALPHA_PROT"].setTranslation(0, val * -6.6); + }), + props.UpdateManager.FromHashValue("ALPHAmax", 0.5, func(val) { + obj["ALPHA_MAX"].setTranslation(0, val * -6.6); + }), + props.UpdateManager.FromHashValue("ALPHAvsw", 0.5, func(val) { + obj["ALPHA_SW"].setTranslation(0, val * -6.6); + }), + props.UpdateManager.FromHashValue("VLSmin", 0.5, func(val) { + obj["VLS_min"].setTranslation(0, val * -6.6); + }), + props.UpdateManager.FromHashValue("ASItrgt", 0.5, func(val) { + obj["ASI_target"].setTranslation(0, val * -6.6); + }), + props.UpdateManager.FromHashList(["speedError","ASItrgtdiff","targetMach","tgt_kts","ktsMach"], 0.5, func(val) { + if (!val.speedError) { + if (abs(val.ASItrgtdiff) <= 42) { + obj["ASI_digit_UP"].hide(); + obj["ASI_decimal_UP"].hide(); + obj["ASI_digit_DN"].hide(); + obj["ASI_decimal_DN"].hide(); + obj["ASI_target"].show(); + } else if (val.ASItrgtdiff < -42) { + if (val.ktsMach) { + obj["ASI_digit_DN"].setText(sprintf("%3.0f", val.targetMach * 1000)); + obj["ASI_decimal_UP"].hide(); + obj["ASI_decimal_DN"].show(); + } else { + obj["ASI_digit_DN"].setText(sprintf("%3.0f", val.tgt_kts)); + obj["ASI_decimal_UP"].hide(); + obj["ASI_decimal_DN"].hide(); + } + obj["ASI_digit_DN"].show(); + obj["ASI_digit_UP"].hide(); + obj["ASI_target"].hide(); + } else if (val.ASItrgtdiff > 42) { + if (val.ktsMach) { + obj["ASI_digit_UP"].setText(sprintf("%3.0f", val.targetMach * 1000)); + obj["ASI_decimal_UP"].show(); + obj["ASI_decimal_DN"].hide(); + } else { + obj["ASI_digit_UP"].setText(sprintf("%3.0f", val.tgt_kts)); + obj["ASI_decimal_UP"].hide(); + obj["ASI_decimal_DN"].hide(); + } + obj["ASI_digit_UP"].show(); + obj["ASI_digit_DN"].hide(); + obj["ASI_target"].hide(); + } + } + }), ]; obj.update_items_mismatch = [ @@ -1036,6 +1148,7 @@ var canvas_pfd = { # Airspeed if (dmc.DMController.DMCs[me.number].outputs[0] != nil) { me.ind_spd = dmc.DMController.DMCs[me.number].outputs[0].getValue(); + notification.ind_spd = me.ind_spd; notification.speedError = 0; if (me.ind_spd <= 30) { @@ -1088,10 +1201,144 @@ var canvas_pfd = { notification.showVr = 0; } + if (fmgc.FMGCInternal.v2set) { + if (fmgc.FMGCInternal.v2 <= 30) { + notification.V2trgt = 0 - notification.ASI; + } else if (fmgc.FMGCInternal.v2 >= 420) { + notification.V2trgt = 390 - notification.ASI; + } else { + notification.V2trgt = fmgc.FMGCInternal.v2 - 30 - notification.ASI; + } + + notification.SPDv2trgtdiff = fmgc.FMGCInternal.v2 - me.ind_spd; + notification.showV2 = 1; + } else { + notification.V2trgt = 0; + notification.SPDv2trgtdiff = 0; + notification.showV2 = 0; + } + + if (notification.fac1 or notification.fac2) { + if (notification.flapsInput == 1) { + if (fmgc.FMGCInternal.slat <= 30) { + notification.Strgt = 0 - notification.ASI; + } else if (fmgc.FMGCInternal.slat >= 420) { + notification.Strgt = 390 - notification.ASI; + } else { + notification.Strgt = fmgc.FMGCInternal.slat - 30 - notification.ASI; + } + + notification.SPDstrgtdiff = fmgc.FMGCInternal.slat - me.ind_spd; + notification.flapMaxSpeed = 200; + } else if (notification.flapsInput == 2) { + if (fmgc.FMGCInternal.flap2 <= 30) { + notification.Ftrgt = 0 - notification.ASI; + } else if (fmgc.FMGCInternal.flap2 >= 420) { + notification.Ftrgt = 390 - notification.ASI; + } else { + notification.Ftrgt = fmgc.FMGCInternal.flap2 - 30 - notification.ASI; + } + + me.SPDftrgtdiff = fmgc.FMGCInternal.flap2 - me.ind_spd; + notification.flapMaxSpeed = 185; + } else if (notification.flapsInput == 3) { + if (fmgc.FMGCInternal.flap3 <= 30) { + notification.Ftrgt = 0 - notification.ASI; + } else if (fmgc.FMGCInternal.flap3 >= 420) { + notification.Ftrgt = 390 - notification.ASI; + } else { + notification.Ftrgt = fmgc.FMGCInternal.flap3 - 30 - notification.ASI; + } + + notification.SPDftrgtdiff = fmgc.FMGCInternal.flap3 - me.ind_spd; + notification.flapMaxSpeed = 177; + } else if (notification.flapsInput == 0) { + notification.Ctrgt = fmgc.FMGCInternal.clean - 30 - notification.ASI; + + notification.SPDcleantrgtdiff = fmgc.FMGCInternal.clean - me.ind_spd; + notification.flapMaxSpeed = 230; + } + } else { + notification.SPDcleantrgtdiff = 0; + notification.SPDftrgtdiff = 0; + notification.SPDstrgtdiff = 0; + notification.Strgt = 0; + notification.Ftrgt = 0; + notification.Ctrgt = 0; + notification.flapMaxSpeed = 0; + } + + notification.fmgcTakeoffState = fmgc.FMGCInternal.takeoffState; + + if (!fmgc.FMGCInternal.takeoffState and fmgc.FMGCInternal.phase >= 1 and !notification.gear1Wow and !notification.gear2Wow) { + if (fmgc.FMGCInternal.vls_min <= 30) { + notification.VLSmin = 0 - notification.ASI; + } else if (fmgc.FMGCInternal.vls_min >= 420) { + notification.VLSmin = 390 - notification.ASI; + } else { + notification.VLSmin = fmgc.FMGCInternal.vls_min - 30 - notification.ASI; + } + + if (fmgc.FMGCInternal.alpha_prot <= 30) { + notification.ALPHAprot = 0 - notification.ASI; + } else if (fmgc.FMGCInternal.alpha_prot >= 420) { + notification.ALPHAprot = 390 - notification.ASI; + } else { + notification.ALPHAprot = fmgc.FMGCInternal.alpha_prot - 30 - notification.ASI; + } + + if (fmgc.FMGCInternal.alpha_max <= 30) { + notification.ALPHAmax = 0 - notification.ASI; + } else if (fmgc.FMGCInternal.alpha_max >= 420) { + notification.ALPHAmax = 390 - notification.ASI; + } else { + notification.ALPHAmax = fmgc.FMGCInternal.alpha_max - 30 - notification.ASI; + } + + if (fmgc.FMGCInternal.vsw <= 30) { + notification.ALPHAvsw = 0 - notification.ASI; + } else if (fmgc.FMGCInternal.vsw >= 420) { + notification.ALPHAvsw = 390 - notification.ASI; + } else { + notification.ALPHAvsw = fmgc.FMGCInternal.vsw - 30 - notification.ASI; + } + } else { + notification.ALPHAprot = 0; + notification.ALPHAmax = 0; + notification.ALPHAvsw = 0; + notification.VLSmin = 0; + } + + + me.tgt_ias = notification.targetIasPFD; + me.tgt_kts = notification.targetKts; + + if (notification.managedSpd) { + if (fmgc.FMGCInternal.decel) { + me.tgt_ias = fmgc.FMGCInternal.vappSpeedSet ? fmgc.FMGCInternal.vapp_appr : fmgc.FMGCInternal.vapp; + me.tgt_kts = fmgc.FMGCInternal.vappSpeedSet ? fmgc.FMGCInternal.vapp_appr : fmgc.FMGCInternal.vapp; + } else if (fmgc.FMGCInternal.phase == 6) { + me.tgt_ias = fmgc.FMGCInternal.clean; + me.tgt_kts = fmgc.FMGCInternal.clean; + } + } + + notification.tgt_kts = me.tgt_kts; + + if (me.tgt_ias <= 30) { + notification.ASItrgt = 0 - notification.ASI; + } else if (me.tgt_ias >= 420) { + notification.ASItrgt = 390 - notification.ASI; + } else { + notification.ASItrgt = me.tgt_ias - 30 - notification.ASI; + } + + notification.ASItrgtdiff = me.tgt_ias - notification.ind_spd; + notification.ASItrend = dmc.DMController.DMCs[me.number].outputs[6].getValue() - notification.ASI; if (notification.ASItrend >= 2 or (me.ASItrendIsShown != 0 and notification.ASItrend >= 1)) { me.ASItrendIsShown = 1; - } else if (me.ASItrend <= -2 or (me.ASItrendIsShown != 0 and notification.ASItrend <= -1)) { + } else if (notification.ASItrend <= -2 or (me.ASItrendIsShown != 0 and notification.ASItrend <= -1)) { me.ASItrendIsShown = -1; } else { me.ASItrendIsShown = 0; @@ -1104,15 +1351,13 @@ var canvas_pfd = { me["ground_ref"].hide(); } } else { - me.ind_spd = dmc.DMController.DMCs[me.number].outputs[0].getValue(); + notification.ind_spd = 0; notification.speedError = 1; if (!systems.ADIRS.Operating.adr[0].getValue() and !systems.ADIRS.Operating.adr[1].getValue() and !systems.ADIRS.Operating.adr[2].getValue()) { me["ASI_buss"].show(); me["ASI_buss_ref"].show(); me["ASI_buss_ref_blue"].show(); - me["ASI_buss"].setTranslation(0, notification.bussTranslate); - me["ASI_buss_ref_blue"].setTranslation(0, notification.bussTranslate); me["ASI_error"].hide(); } else { me["ASI_buss"].hide(); @@ -1121,13 +1366,33 @@ var canvas_pfd = { me["ASI_error"].show(); } + notification.ASI = 0; + notification.ASImax = 0; + notification.ASItrgt = 0; + notification.ASItrgtdiff = 0; + notification.ASItrend = 0; + notification.ALPHAprot = 0; + notification.ALPHAmax = 0; + notification.ALPHAvsw = 0; notification.ASItrendIsShown = 0; - notification.V1trgt = 0; - notification.SPDv1trgtdiff = 0; + notification.Ctrgt = 0; + notification.flapMaxSpeed = 0; + notification.Ftrgt = 0; + notification.Strgt = 0; notification.showV1 = 0; - notification.VRtrgt = 0; - notification.SPDvrtrgtdiff = 0; notification.showVr = 0; + notification.showV2 = 0; + notification.SPDcleantrgtdiff = 0; + notification.SPDftrgtdiff = 0; + notification.SPDstrgtdiff = 0; + notification.SPDv1trgtdiff = 0; + notification.SPDvrtrgtdiff = 0; + notification.SPDv2trgtdiff = 0; + notification.tgt_kts = 0; + notification.V1trgt = 0; + notification.VRtrgt = 0; + notification.V2trgt = 0; + notification.VLSmin = 0; } # Mach From b00e9f228a225585b1e6bac8a4bcd0387aa0be37 Mon Sep 17 00:00:00 2001 From: Jonathan Redpath Date: Thu, 28 Apr 2022 19:13:25 +0100 Subject: [PATCH 06/17] Bugfix --- Models/Instruments/PFD/PFD.nas | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Models/Instruments/PFD/PFD.nas b/Models/Instruments/PFD/PFD.nas index 177d374c..15d7d1f2 100644 --- a/Models/Instruments/PFD/PFD.nas +++ b/Models/Instruments/PFD/PFD.nas @@ -1239,7 +1239,7 @@ var canvas_pfd = { notification.Ftrgt = fmgc.FMGCInternal.flap2 - 30 - notification.ASI; } - me.SPDftrgtdiff = fmgc.FMGCInternal.flap2 - me.ind_spd; + notification.SPDftrgtdiff = fmgc.FMGCInternal.flap2 - me.ind_spd; notification.flapMaxSpeed = 185; } else if (notification.flapsInput == 3) { if (fmgc.FMGCInternal.flap3 <= 30) { From 6bac9e6d8fa9ad28439f387b1b2bca152905221c Mon Sep 17 00:00:00 2001 From: Jonathan Redpath Date: Thu, 28 Apr 2022 19:14:23 +0100 Subject: [PATCH 07/17] Bugfix 2 --- Models/Instruments/PFD/PFD.nas | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Models/Instruments/PFD/PFD.nas b/Models/Instruments/PFD/PFD.nas index 15d7d1f2..979731cc 100644 --- a/Models/Instruments/PFD/PFD.nas +++ b/Models/Instruments/PFD/PFD.nas @@ -836,7 +836,7 @@ var canvas_pfd = { if (!val.speedError and val.showVr) { if (val.agl < 55 and val.fmgcPhase <= 2 and abs(val.SPDv2trgtdiff) <= 42) { obj["ASI_target"].show(); - obj["ASI_target"].setTranslation(0, me.V2trgt * -6.6); + obj["ASI_target"].setTranslation(0, val.V2trgt * -6.6); obj["ASI_digit_UP"].setText(sprintf("%3.0f", fmgc.FMGCInternal.v2)); } else if (val.agl < 55 and fmgc.FMGCInternal.phase <= 2) { obj["ASI_target"].hide(); From c2bc2c8e557c5d3736c20379f0fc0b86b6ad27dc Mon Sep 17 00:00:00 2001 From: Jonathan Redpath Date: Fri, 29 Apr 2022 16:46:04 +0100 Subject: [PATCH 08/17] Move rest of PFD to emesary --- Models/Instruments/PFD/PFD.nas | 537 ++++++++++++++++++--------------- 1 file changed, 296 insertions(+), 241 deletions(-) diff --git a/Models/Instruments/PFD/PFD.nas b/Models/Instruments/PFD/PFD.nas index 979731cc..fda9ba75 100644 --- a/Models/Instruments/PFD/PFD.nas +++ b/Models/Instruments/PFD/PFD.nas @@ -1003,6 +1003,285 @@ var canvas_pfd = { } } }), + props.UpdateManager.FromHashList(["showPFDILS","magnetic_hdg_dif"], 0.01, func(val) { + if (val.showPFDILS) { + if (abs(val.magnetic_hdg_dif) <= 23.62) { + obj["CRS_pointer"].setTranslation((val.magnetic_hdg_dif / 10) * 98.5416, 0); + + obj["ILS_HDG_L"].hide(); + obj["ILS_HDG_R"].hide(); + obj["CRS_pointer"].show(); + } else if (val.magnetic_hdg_dif < -23.62 and val.magnetic_hdg_dif >= -180) { + obj["ILS_HDG_L"].show(); + obj["ILS_HDG_R"].hide(); + obj["CRS_pointer"].hide(); + } else if (val.magnetic_hdg_dif > 23.62 and val.magnetic_hdg_dif <= 180) { + obj["ILS_HDG_L"].hide(); + obj["ILS_HDG_R"].show(); + obj["CRS_pointer"].hide(); + } else { + obj["ILS_HDG_L"].hide(); + obj["ILS_HDG_R"].hide(); + obj["CRS_pointer"].hide(); + } + } else { + obj["ILS_HDG_L"].hide(); + obj["ILS_HDG_R"].hide(); + obj["CRS_pointer"].hide(); + } + }), + props.UpdateManager.FromHashValue("ilsCrs", 0.5, func(val) { + if (int(val) < 10) { + obj["ILS_left"].setText(sprintf("00%1.0f", int(val))); + obj["ILS_right"].setText(sprintf("00%1.0f", int(val))); + } else if (int(val) < 100) { + obj["ILS_left"].setText(sprintf("0%2.0f", int(val))); + obj["ILS_right"].setText(sprintf("0%2.0f", int(val))); + } else { + obj["ILS_left"].setText(sprintf("%3.0f", int(val))); + obj["ILS_right"].setText(sprintf("%3.0f", int(val))); + } + }), + props.UpdateManager.FromHashValue("altimeterStd", 1, func(val) { + if (val) { + obj["QNH"].hide(); + obj["QNH_setting"].hide(); + } else { + obj["QNH_std"].hide(); + obj["QNH_box"].hide(); + } + }), + props.UpdateManager.FromHashList(["showDecisionHeight","agl","decision","radio","baro","radioNo"], 0.5, func(val) { + if (val.showDecisionHeight) { + if (val.agl <= 2500) { + obj["AI_agl"].show(); + if (val.agl <= val.decision) { + obj["AI_agl"].setColor(0.7333,0.3803,0); + obj["AI_agl"].setFontSize(55); + } else { + if (val.agl <= 400) { + obj["AI_agl"].setFontSize(55); + } else { + obj["AI_agl"].setFontSize(45); + } + obj["AI_agl"].setColor(0.0509,0.7529,0.2941); + } + } else { + obj["AI_agl"].hide(); + } + } else { + obj["FMA_dh"].hide(); + obj["FMA_dhn"].hide(); + obj["FMA_nodh"].hide(); + + if (val.agl <= 2500) { + obj["AI_agl"].show(); + + # Minimums + if (int(val.radio) != 99999) { + obj["FMA_dh"].setText("RADIO"); + obj["FMA_dh"].show(); + obj["FMA_dhn"].setText(sprintf("%.0f", val.radio)); + obj["FMA_dhn"].show(); + obj["FMA_nodh"].hide(); + hundredAbove.setValue(val.radio + 100); + minimum.setValue(val.radio); + + if (val.agl <= val.radio + 100) { + obj["AI_agl"].setColor(0.7333,0.3803,0); + obj["AI_agl"].setFontSize(55); + } else { + if (val.agl <= 400) { + obj["AI_agl"].setFontSize(55); + } else { + obj["AI_agl"].setFontSize(45); + } + obj["AI_agl"].setColor(0.0509,0.7529,0.2941); + } + } else if (int(val.baro) != 99999) { + obj["FMA_dh"].setText("BARO"); + obj["FMA_dh"].show(); + obj["FMA_dhn"].setText(sprintf("%.0f", val.baro)); + obj["FMA_dhn"].show(); + obj["FMA_nodh"].hide(); + hundredAbove.setValue(val.baro + 100); + minimum.setValue(val.baro); + + if (val.agl <= val.baro + 100) { + obj["AI_agl"].setColor(0.7333,0.3803,0); + obj["AI_agl"].setFontSize(55); + } else { + if (val.agl <= 400) { + obj["AI_agl"].setFontSize(55); + } else { + obj["AI_agl"].setFontSize(45); + } + obj["AI_agl"].setColor(0.0509,0.7529,0.2941); + } + } else if (val.radioNo) { + obj["FMA_dh"].setText("BARO"); + obj["FMA_dh"].show(); + obj["FMA_dhn"].setText("100"); + obj["FMA_dhn"].show(); + obj["FMA_nodh"].hide(); + hundredAbove.setValue(100); + minimum.setValue(0); + + if (val.agl <= 400) { + obj["AI_agl"].setFontSize(55); + } else { + obj["AI_agl"].setFontSize(45); + } + + if (val.agl <= 100) { + obj["AI_agl"].setColor(0.7333,0.3803,0); + } else { + obj["AI_agl"].setColor(0.0509,0.7529,0.2941); + } + } else { + obj["FMA_dh"].hide(); + obj["FMA_dhn"].hide(); + obj["FMA_nodh"].show(); + hundredAbove.setValue(400); + minimum.setValue(300); + + if (val.agl <= 400) { + obj["AI_agl"].setColor(0.7333,0.3803,0); + obj["AI_agl"].setFontSize(55); + } else { + obj["AI_agl"].setColor(0.0509,0.7529,0.2941); + obj["AI_agl"].setFontSize(45); + } + } + } else { + obj["AI_agl"].hide(); + obj["FMA_nodh"].hide(); + + # Minimums + if (int(val.radio) != 99999) { + obj["FMA_dh"].setText("RADIO"); + obj["FMA_dh"].show(); + obj["FMA_dhn"].setText(sprintf("%.0f", val.radio)); + obj["FMA_dhn"].show(); + obj["FMA_nodh"].hide(); + } else if (int(val.baro) != 99999) { + obj["FMA_dh"].setText("BARO"); + obj["FMA_dh"].show(); + obj["FMA_dhn"].setText(sprintf("%.0f", val.baro)); + obj["FMA_dhn"].show(); + obj["FMA_nodh"].hide(); + } else if (fmgc.FMGCInternal.radioNo) { + obj["FMA_dh"].setText("BARO"); + obj["FMA_dh"].show(); + obj["FMA_dhn"].setText("100"); + obj["FMA_dhn"].show(); + obj["FMA_nodh"].hide(); + } else { + obj["FMA_dh"].hide(); + obj["FMA_dhn"].hide(); + obj["FMA_nodh"].show(); + } + } + } + }), + props.UpdateManager.FromHashValue("altError", 1, func(val) { + if (val) { + obj["ALT_error"].show(); + obj["ALT_frame"].setColor(1,0,0); + obj["ALT_group"].hide(); + obj["ALT_tens"].hide(); + obj["ALT_neg"].hide(); + obj["ALT_group2"].hide(); + obj["ALT_scale"].hide(); + obj["ALT_box_flash"].hide(); + obj["ALT_box_amber"].hide(); + obj["ALT_box"].hide(); + obj["Metric_box"].hide(); + obj["Metric_letter"].hide(); + obj["Metric_cur_alt"].hide(); + obj["ALT_digit_UP_metric"].hide(); + } else { + obj["ALT_error"].hide(); + obj["ALT_frame"].setColor(1,1,1); + obj["ALT_group"].show(); + obj["ALT_tens"].show(); + obj["ALT_box"].show(); + obj["ALT_group2"].show(); + obj["ALT_scale"].show(); + } + }), + props.UpdateManager.FromHashList(["altError","showMetric"], 1, func(val) { + if (!val.altError and val.showMetric) { + obj["ALT_digit_UP_metric"].show(); + obj["Metric_box"].show(); + obj["Metric_letter"].show(); + obj["Metric_cur_alt"].show(); + } else { + obj["ALT_digit_UP_metric"].hide(); + obj["Metric_box"].hide(); + obj["Metric_letter"].hide(); + obj["Metric_cur_alt"].hide(); + } + }), + props.UpdateManager.FromHashValue("altitude", 0.5, func(val) { + obj["Metric_cur_alt"].setText(sprintf("%5.0f", val * 0.3048)); + + obj.middleAltText = roundaboutAlt(val / 100); + + obj["ALT_five"].setText(sprintf("%03d", abs(obj.middleAltText + 10))); + obj["ALT_four"].setText(sprintf("%03d", abs(obj.middleAltText + 5))); + obj["ALT_three"].setText(sprintf("%03d", abs(obj.middleAltText))); + obj["ALT_two"].setText(sprintf("%03d", abs(obj.middleAltText - 5))); + obj["ALT_one"].setText(sprintf("%03d", abs(obj.middleAltText - 10))); + + if (val < 0) { + obj["ALT_neg"].show(); + } else { + obj["ALT_neg"].hide(); + } + }), + props.UpdateManager.FromHashValue("altitude", 0.1, func(val) { + obj.altOffset = val / 500 - int(val / 500); + obj.middleAltOffset = nil; + + if (obj.altOffset > 0.5) { + obj.middleAltOffset = -(obj.altOffset - 1) * 243.3424; + } else { + obj.middleAltOffset = -obj.altOffset * 243.3424; + } + + obj["ALT_scale"].setTranslation(0, -obj.middleAltOffset); + obj["ALT_scale"].update(); + obj["ALT_tens"].setTranslation(0, num(right(sprintf("%02d", val), 2)) * 1.392); + }), + props.UpdateManager.FromHashValue("altitudeDigits", 1, func(val) { + obj["ALT_digits"].setText(sprintf("%d", val)); + }), + props.UpdateManager.FromHashValue("altitudeDifference", 0.1, func(val) { + obj["ALT_target"].setTranslation(0, (val / 100) * -48.66856); + }), + props.UpdateManager.FromHashValue("altitudeAutopilot", 25, func(val) { + obj["ALT_target_digit"].setText(sprintf("%03d", math.round(val / 100))); + }), + props.UpdateManager.FromHashList(["altError","altitudeDifference"], 1, func(val) { + if (!val.altError and abs(val.altitudeDifference) <= 565) { + obj["ALT_digit_UP"].hide(); + obj["ALT_digit_DN"].hide(); + obj["ALT_target"].show(); + } else { + if (val.altitudeDifference < -565 and !val.altError) { + obj["ALT_digit_DN"].show(); + obj["ALT_digit_UP"].hide(); + } else if (val.altitudeDifference > 565 and !val.altError) { + obj["ALT_digit_UP"].show(); + obj["ALT_digit_DN"].hide(); + } else { + obj["ALT_digit_UP"].hide(); + obj["ALT_digit_DN"].hide(); + } + obj["ALT_target"].hide(); + } + }), ]; obj.update_items_mismatch = [ @@ -1404,72 +1683,13 @@ var canvas_pfd = { } # Altitude - if (dmc.DMController.DMCs[me.number].outputs[1] != nil) { - me["ALT_error"].hide(); - me["ALT_frame"].setColor(1,1,1); - me["ALT_group"].show(); - me["ALT_tens"].show(); - me["ALT_box"].show(); - me["ALT_group2"].show(); - me["ALT_scale"].show(); - - me.altitude = dmc.DMController.DMCs[me.number].outputs[1].getValue(); + notification.showMetric = me.showMetricAlt; - if (me.showMetricAlt) { - me["ALT_digit_UP_metric"].show(); - me["Metric_box"].show(); - me["Metric_letter"].show(); - me["Metric_cur_alt"].show(); - me["Metric_cur_alt"].setText(sprintf("%5.0f", me.altitude * 0.3048)); - } else { - me["ALT_digit_UP_metric"].hide(); - me["Metric_box"].hide(); - me["Metric_letter"].hide(); - me["Metric_cur_alt"].hide(); - } - - me.altOffset = me.altitude / 500 - int(me.altitude / 500); - me.middleAltText = roundaboutAlt(me.altitude / 100); - me.middleAltOffset = nil; - if (me.altOffset > 0.5) { - me.middleAltOffset = -(me.altOffset - 1) * 243.3424; - } else { - me.middleAltOffset = -me.altOffset * 243.3424; - } - me["ALT_scale"].setTranslation(0, -me.middleAltOffset); - me["ALT_scale"].update(); - me["ALT_five"].setText(sprintf("%03d", abs(me.middleAltText+10))); - me["ALT_four"].setText(sprintf("%03d", abs(me.middleAltText+5))); - me["ALT_three"].setText(sprintf("%03d", abs(me.middleAltText))); - me["ALT_two"].setText(sprintf("%03d", abs(me.middleAltText-5))); - me["ALT_one"].setText(sprintf("%03d", abs(me.middleAltText-10))); - - if (me.altitude < 0) { - me["ALT_neg"].show(); - } else { - me["ALT_neg"].hide(); - } - - me["ALT_digits"].setText(sprintf("%d", dmc.DMController.DMCs[me.number].outputs[3].getValue())); - me["ALT_tens"].setTranslation(0, num(right(sprintf("%02d", me.altitude), 2)) * 1.392); - - me.alt_diff_cur = dmc.DMController.DMCs[me.number].outputs[7].getValue(); - if (me.alt_diff_cur >= -565 and me.alt_diff_cur <= 565) { - me["ALT_target"].setTranslation(0, (me.alt_diff_cur / 100) * -48.66856); - me["ALT_target_digit"].setText(sprintf("%03d", math.round(notification.altitudeAutopilot / 100))); - me["ALT_digit_UP"].hide(); - me["ALT_digit_DN"].hide(); - me["ALT_target"].show(); - } else { - me["ALT_target"].hide(); - if (me.alt_diff_cur < -565) { - me["ALT_digit_DN"].show(); - me["ALT_digit_UP"].hide(); - } else if (me.alt_diff_cur > 565) { - me["ALT_digit_UP"].show(); - me["ALT_digit_DN"].hide(); - } - } + if (dmc.DMController.DMCs[me.number].outputs[1] != nil) { + notification.altError = 0; + notification.altitude = dmc.DMController.DMCs[me.number].outputs[1].getValue(); + notification.altitudeDigits = dmc.DMController.DMCs[me.number].outputs[3].getValue(); + notification.altitudeDifference = dmc.DMController.DMCs[me.number].outputs[7].getValue(); if (!ecam.altAlertFlash and !ecam.altAlertSteady) { if (me.number == 0) { @@ -1550,20 +1770,10 @@ var canvas_pfd = { } } } else { - me["ALT_error"].show(); - me["ALT_frame"].setColor(1,0,0); - me["ALT_group"].hide(); - me["ALT_tens"].hide(); - me["ALT_neg"].hide(); - me["ALT_group2"].hide(); - me["ALT_scale"].hide(); - me["ALT_box_flash"].hide(); - me["ALT_box_amber"].hide(); - me["ALT_box"].hide(); - me["Metric_box"].hide(); - me["Metric_letter"].hide(); - me["Metric_cur_alt"].hide(); - me["ALT_digit_UP_metric"].hide(); + notification.altError = 1; + notification.altitude = -9999; + notification.altitudeDigits = -9999; + notification.altitudeDifference = -9999; } if (notification.pitchMode == "LAND" or notification.pitchMode == "FLARE" or notification.pitchMode == "ROLL OUT") { @@ -1598,133 +1808,14 @@ var canvas_pfd = { } } + notification.radioNo = fmgc.FMGCInternal.radioNo; if (fmgc.FMGCInternal.phase < 3 or fmgc.flightPlanController.arrivalDist >= 250) { - me["FMA_dh"].hide(); - me["FMA_dhn"].hide(); - me["FMA_nodh"].hide(); - if (notification.agl <= 2500) { - me["AI_agl"].show(); - if (notification.agl <= notification.decision) { - me["AI_agl"].setColor(0.7333,0.3803,0); - me["AI_agl"].setFontSize(55); - } else { - if (notification.agl <= 400) { - me["AI_agl"].setFontSize(55); - } else { - me["AI_agl"].setFontSize(45); - } - me["AI_agl"].setColor(0.0509,0.7529,0.2941); - } - } else { - me["AI_agl"].hide(); - } + notification.showDecisionHeight = 0; } else { - if (notification.agl <= 2500) { - me["AI_agl"].show(); - if (int(notification.radio) != 99999) { - me["FMA_dh"].setText("RADIO"); - me["FMA_dh"].show(); - me["FMA_dhn"].setText(sprintf("%.0f", notification.radio)); - me["FMA_dhn"].show(); - me["FMA_nodh"].hide(); - hundredAbove.setValue(notification.radio + 100); - minimum.setValue(notification.radio); - if (notification.agl <= notification.radio + 100) { - me["AI_agl"].setColor(0.7333,0.3803,0); - me["AI_agl"].setFontSize(55); - } else { - if (notification.agl <= 400) { - me["AI_agl"].setFontSize(55); - } else { - me["AI_agl"].setFontSize(45); - } - me["AI_agl"].setColor(0.0509,0.7529,0.2941); - } - } else if (int(notification.baro) != 99999) { - me["FMA_dh"].setText("BARO"); - me["FMA_dh"].show(); - me["FMA_dhn"].setText(sprintf("%.0f", notification.baro)); - me["FMA_dhn"].show(); - me["FMA_nodh"].hide(); - hundredAbove.setValue(notification.baro + 100); - minimum.setValue(notification.baro); - if (notification.agl <= notification.baro + 100) { - me["AI_agl"].setColor(0.7333,0.3803,0); - me["AI_agl"].setFontSize(55); - } else { - if (notification.agl <= 400) { - me["AI_agl"].setFontSize(55); - } else { - me["AI_agl"].setFontSize(45); - } - me["AI_agl"].setColor(0.0509,0.7529,0.2941); - } - } else if (fmgc.FMGCInternal.radioNo) { - me["FMA_dh"].setText("BARO"); - me["FMA_dh"].show(); - me["FMA_dhn"].setText("100"); - me["FMA_dhn"].show(); - me["FMA_nodh"].hide(); - hundredAbove.setValue(100); - minimum.setValue(0); - if (notification.agl <= 400) { - me["AI_agl"].setFontSize(55); - } else { - me["AI_agl"].setFontSize(45); - } - - if (notification.agl <= 100) { - me["AI_agl"].setColor(0.7333,0.3803,0); - } else { - me["AI_agl"].setColor(0.0509,0.7529,0.2941); - } - } else { - me["FMA_dh"].hide(); - me["FMA_dhn"].hide(); - me["FMA_nodh"].show(); - hundredAbove.setValue(400); - minimum.setValue(300); - if (notification.agl <= 400) { - me["AI_agl"].setColor(0.7333,0.3803,0); - me["AI_agl"].setFontSize(55); - } else { - me["AI_agl"].setColor(0.0509,0.7529,0.2941); - me["AI_agl"].setFontSize(45); - } - } - } else { - me["AI_agl"].hide(); - me["FMA_nodh"].hide(); - if (int(notification.radio) != 99999) { - me["FMA_dh"].setText("RADIO"); - me["FMA_dh"].show(); - me["FMA_dhn"].setText(sprintf("%.0f", notification.radio)); - me["FMA_dhn"].show(); - me["FMA_nodh"].hide(); - } else if (int(notification.baro) != 99999) { - me["FMA_dh"].setText("BARO"); - me["FMA_dh"].show(); - me["FMA_dhn"].setText(sprintf("%.0f", notification.baro)); - me["FMA_dhn"].show(); - me["FMA_nodh"].hide(); - } else if (fmgc.FMGCInternal.radioNo) { - me["FMA_dh"].setText("BARO"); - me["FMA_dh"].show(); - me["FMA_dhn"].setText("100"); - me["FMA_dhn"].show(); - me["FMA_nodh"].hide(); - } else { - me["FMA_dh"].hide(); - me["FMA_dhn"].hide(); - me["FMA_nodh"].show(); - } - } + notification.showDecisionHeight = 1; } if (notification.altimeterStd == 1) { - me["QNH"].hide(); - me["QNH_setting"].hide(); - if (notification.altitude < fmgc.FMGCInternal.transAlt and fmgc.FMGCInternal.phase == 4) { if (me.number == 0) { if (qnh_going1 == 0) { @@ -1759,9 +1850,6 @@ var canvas_pfd = { me["QNH_box"].show(); } } else { - me["QNH_std"].hide(); - me["QNH_box"].hide(); - if (notification.altitude >= fmgc.FMGCInternal.transAlt and fmgc.FMGCInternal.phase == 2) { if (me.number == 0) { if (qnh_going1 == 0) { @@ -1827,44 +1915,11 @@ var canvas_pfd = { } if (((me.number == 0 and notification.pfdILS1) or (me.number == 1 and notification.pfdILS2)) and size(me.split_ils) == 2) { - me.magnetic_hdg = notification.ilsCrs; - me.magnetic_hdg_dif = geo.normdeg180(me.magnetic_hdg - notification.headingPFD); - if (me.magnetic_hdg_dif >= -23.62 and me.magnetic_hdg_dif <= 23.62) { - me["CRS_pointer"].setTranslation((me.magnetic_hdg_dif / 10) * 98.5416, 0); - me["ILS_HDG_R"].hide(); - me["ILS_HDG_L"].hide(); - me["CRS_pointer"].show(); - } else if (me.magnetic_hdg_dif < -23.62 and me.magnetic_hdg_dif >= -180) { - if (int(me.magnetic_hdg) < 10) { - me["ILS_left"].setText(sprintf("00%1.0f", int(me.magnetic_hdg))); - } else if (int(me.magnetic_hdg) < 100) { - me["ILS_left"].setText(sprintf("0%2.0f", int(me.magnetic_hdg))); - } else { - me["ILS_left"].setText(sprintf("%3.0f", int(me.magnetic_hdg))); - } - me["ILS_HDG_L"].show(); - me["ILS_HDG_R"].hide(); - me["CRS_pointer"].hide(); - } else if (me.magnetic_hdg_dif > 23.62 and me.magnetic_hdg_dif <= 180) { - if (int(me.magnetic_hdg) < 10) { - me["ILS_right"].setText(sprintf("00%1.0f", int(me.magnetic_hdg))); - } else if (int(me.magnetic_hdg) < 100) { - me["ILS_right"].setText(sprintf("0%2.0f", int(me.magnetic_hdg))); - } else { - me["ILS_right"].setText(sprintf("%3.0f", int(me.magnetic_hdg))); - } - me["ILS_HDG_R"].show(); - me["ILS_HDG_L"].hide(); - me["CRS_pointer"].hide(); - } else { - me["ILS_HDG_R"].hide(); - me["ILS_HDG_L"].hide(); - me["CRS_pointer"].hide(); - } + notification.showPFDILS = 1; + notification.magnetic_hdg_dif = geo.normdeg180(me.magnetic_hdg - notification.headingPFD); } else { - me["ILS_HDG_R"].hide(); - me["ILS_HDG_L"].hide(); - me["CRS_pointer"].hide(); + notification.showPFDILS = 0; + notification.magnetic_hdg_dif = 0; } if (me.temporaryNodes.showGroundReferenceAGL) { From ed70a34d9d7ea980566b434d24dc846f65a7c4f7 Mon Sep 17 00:00:00 2001 From: Jonathan Redpath Date: Fri, 29 Apr 2022 20:48:35 +0100 Subject: [PATCH 09/17] Fix decision height --- Models/Instruments/PFD/PFD.nas | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Models/Instruments/PFD/PFD.nas b/Models/Instruments/PFD/PFD.nas index fda9ba75..b0959096 100644 --- a/Models/Instruments/PFD/PFD.nas +++ b/Models/Instruments/PFD/PFD.nas @@ -1052,7 +1052,11 @@ var canvas_pfd = { } }), props.UpdateManager.FromHashList(["showDecisionHeight","agl","decision","radio","baro","radioNo"], 0.5, func(val) { - if (val.showDecisionHeight) { + if (!val.showDecisionHeight) { + obj["FMA_dh"].hide(); + obj["FMA_dhn"].hide(); + obj["FMA_nodh"].hide(); + if (val.agl <= 2500) { obj["AI_agl"].show(); if (val.agl <= val.decision) { @@ -1070,10 +1074,6 @@ var canvas_pfd = { obj["AI_agl"].hide(); } } else { - obj["FMA_dh"].hide(); - obj["FMA_dhn"].hide(); - obj["FMA_nodh"].hide(); - if (val.agl <= 2500) { obj["AI_agl"].show(); From 56abd3a3c373afc4869a93f109a2b22ce27385e8 Mon Sep 17 00:00:00 2001 From: Jonathan Redpath Date: Fri, 29 Apr 2022 20:55:11 +0100 Subject: [PATCH 10/17] Speed up speed scale --- Models/Instruments/IESI/IESI.nas | 34 ++++++++++++++------------------ Models/Instruments/PFD/PFD.nas | 30 +++++++++++++--------------- 2 files changed, 29 insertions(+), 35 deletions(-) diff --git a/Models/Instruments/IESI/IESI.nas b/Models/Instruments/IESI/IESI.nas index 9cc69e0e..7277fe89 100644 --- a/Models/Instruments/IESI/IESI.nas +++ b/Models/Instruments/IESI/IESI.nas @@ -65,9 +65,10 @@ var canvas_IESI = { props.UpdateManager.FromHashValue("airspeed", 0.1, func(val) { obj["ASI_scale"].setTranslation(0, math.clamp(val - 30, 0, 490) * 8.295); }), - props.UpdateManager.FromHashList(["altitude","altitude_ind"], 0.5, func(val) { - val.altitude = math.clamp(val.altitude, -2000, 50000); - if (val.altitude < 0) { + props.UpdateManager.FromHashValue("altitude", 0.5, func(val) { + val = math.clamp(val, -2000, 50000); + + if (val < 0) { obj["negText"].show(); obj._isNegativeAlt = 1; } else { @@ -75,8 +76,8 @@ var canvas_IESI = { obj._isNegativeAlt = 0; } - obj.altOffset = (val.altitude / 500) - int(val.altitude / 500); - obj.middleAltText = roundaboutAlt(val.altitude / 100); + obj.altOffset = (val / 500) - int(val / 500); + obj.middleAltText = roundaboutAlt(val / 100); if (obj.altOffset > 0.5) { obj._middleAltOffset = -(obj.altOffset - 1) * 258.5528; } else { @@ -85,24 +86,19 @@ var canvas_IESI = { obj["ALT_scale"].setTranslation(0, -obj._middleAltOffset); obj["ALT_scale"].update(); - obj["ALT_five"].setText(sprintf("%03d", abs(obj.middleAltText+10))); - obj["ALT_four"].setText(sprintf("%03d", abs(obj.middleAltText+5))); + obj["ALT_five"].setText(sprintf("%03d", abs(obj.middleAltText + 10))); + obj["ALT_four"].setText(sprintf("%03d", abs(obj.middleAltText + 5))); obj["ALT_three"].setText(sprintf("%03d", abs(obj.middleAltText))); - obj["ALT_two"].setText(sprintf("%03d", abs(obj.middleAltText-5))); - obj["ALT_one"].setText(sprintf("%03d", abs(obj.middleAltText-10))); + obj["ALT_two"].setText(sprintf("%03d", abs(obj.middleAltText - 5))); + obj["ALT_one"].setText(sprintf("%03d", abs(obj.middleAltText - 10))); - - if (val.altitude < 0 and val.altitude_ind > 20) { - val.altitude_ind = 20; - } elsif (val.altitude > 0 and val.altitude_ind > 500) { - val.altitude_ind = 500; - } - - obj["ALT_digits"].setText(sprintf("%s", val.altitude_ind)); - obj["ALT_meters"].setText(sprintf("%5.0f", math.round(val.altitude * 0.3048, 10))); - obj.altTens = num(right(sprintf("%02d", val.altitude), 2)); + obj["ALT_meters"].setText(sprintf("%5.0f", math.round(val * 0.3048, 10))); + obj.altTens = num(right(sprintf("%02d", val), 2)); obj["ALT_tens"].setTranslation(0, obj.altTens * 3.16); }), + props.UpdateManager.FromHashValue("altitude_ind", 0.5, func(val) { + obj["ALT_digits"].setText(sprintf("%s", math.clamp(val, -20, 500))); + }), props.UpdateManager.FromHashValue("showMach", 1, func(val) { if (val) { obj["ASI_mach_decimal"].show(); diff --git a/Models/Instruments/PFD/PFD.nas b/Models/Instruments/PFD/PFD.nas index b0959096..e3e34f4c 100644 --- a/Models/Instruments/PFD/PFD.nas +++ b/Models/Instruments/PFD/PFD.nas @@ -249,11 +249,9 @@ var canvas_pfd = { obj["FMA_lvrclb"].hide(); } }), - props.UpdateManager.FromHashList(["trackPFD","headingPFD"], 0.1, func(val) { + props.UpdateManager.FromHashList(["trackPFD","headingPFD","aoaPFD"], 0.01, func(val) { obj.track_diff = geo.normdeg180(val.trackPFD - val.headingPFD); # store this to use in FPV obj["TRK_pointer"].setTranslation(obj.getTrackDiffPixels(obj.track_diff),0); - }), - props.UpdateManager.FromHashList(["trackPFD","headingPFD","aoaPFD"], 0.01, func(val) { obj.AI_fpv_trans.setTranslation(obj.getTrackDiffPixels(math.clamp(obj.track_diff, -21, 21)), math.clamp(val.aoaPFD, -20, 20) * 12.5); }), props.UpdateManager.FromHashList(["vsAutopilot","agl"], 5, func(val) { @@ -787,17 +785,17 @@ var canvas_pfd = { obj["ASI_trend_down"].hide(); } }), - props.UpdateManager.FromHashValue("ASI", 0.5, func(val) { + props.UpdateManager.FromHashValue("ASI", 0.1, func(val) { obj["ASI_scale"].setTranslation(0, val * 6.6); }), - props.UpdateManager.FromHashValue("ASImax", 0.5, func(val) { + props.UpdateManager.FromHashValue("ASImax", 0.1, func(val) { obj["ASI_max"].setTranslation(0, val * -6.6); }), props.UpdateManager.FromHashValue("ASItrend", 0.1, func(val) { obj["ASI_trend_up"].setTranslation(0, math.clamp(val, 0, 50) * -6.6); obj["ASI_trend_down"].setTranslation(0, math.clamp(val, -50, 0) * -6.6); }), - props.UpdateManager.FromHashValue("V1trgt", 0.5, func(val) { + props.UpdateManager.FromHashValue("V1trgt", 0.1, func(val) { obj["v1_group"].setTranslation(0, val * -6.6); obj["v1_text"].setText(sprintf("%3.0f", fmgc.FMGCInternal.v1)); }), @@ -818,7 +816,7 @@ var canvas_pfd = { obj["v1_text"].hide(); } }), - props.UpdateManager.FromHashValue("VRtrgt", 0.5, func(val) { + props.UpdateManager.FromHashValue("VRtrgt", 0.1, func(val) { obj["vr_speed"].setTranslation(0, val * -6.6); }), props.UpdateManager.FromHashList(["speedError","showVr","SPDvrtrgtdiff","fmgcPhase","agl"], 0.5, func(val) { @@ -864,7 +862,7 @@ var canvas_pfd = { } } }), - props.UpdateManager.FromHashList(["flapMaxSpeed","ASI"], 0.5, func(val) { + props.UpdateManager.FromHashList(["flapMaxSpeed","ASI"], 0.1, func(val) { obj["flap_max"].setTranslation(0, (val.flapMaxSpeed - 30 - val.ASI) * -6.6); }), props.UpdateManager.FromHashList(["speedError","fac1","fac2","flapMaxSpeed","flapsInput","ind_spd"], 0.5, func(val) { @@ -878,13 +876,13 @@ var canvas_pfd = { obj["flap_max"].hide(); } }), - props.UpdateManager.FromHashValue("Ctrgt", , 0.5, func(val) { + props.UpdateManager.FromHashValue("Ctrgt", , 0.1, func(val) { obj["clean_speed"].setTranslation(0, val * -6.6); }), - props.UpdateManager.FromHashValue("Ftrgt", 0.5, func(val) { + props.UpdateManager.FromHashValue("Ftrgt", 0.1, func(val) { obj["F_target"].setTranslation(0, val * -6.6); }), - props.UpdateManager.FromHashValue("Strgt", 0.5, func(val) { + props.UpdateManager.FromHashValue("Strgt", 0.1, func(val) { obj["S_target"].setTranslation(0, val * -6.6); }), props.UpdateManager.FromHashList(["speedError","fac1","fac2","flapsInput","SPDstrgtdiff","SPDftrgtdiff","SPDcleantrgtdiff","agl"], 0.5, func(val) { @@ -951,19 +949,19 @@ var canvas_pfd = { obj["ALPHA_SW"].hide(); } }), - props.UpdateManager.FromHashValue("ALPHAprot", 0.5, func(val) { + props.UpdateManager.FromHashValue("ALPHAprot", 0.1, func(val) { obj["ALPHA_PROT"].setTranslation(0, val * -6.6); }), - props.UpdateManager.FromHashValue("ALPHAmax", 0.5, func(val) { + props.UpdateManager.FromHashValue("ALPHAmax", 0.1, func(val) { obj["ALPHA_MAX"].setTranslation(0, val * -6.6); }), - props.UpdateManager.FromHashValue("ALPHAvsw", 0.5, func(val) { + props.UpdateManager.FromHashValue("ALPHAvsw", 0.1, func(val) { obj["ALPHA_SW"].setTranslation(0, val * -6.6); }), - props.UpdateManager.FromHashValue("VLSmin", 0.5, func(val) { + props.UpdateManager.FromHashValue("VLSmin", 0.1, func(val) { obj["VLS_min"].setTranslation(0, val * -6.6); }), - props.UpdateManager.FromHashValue("ASItrgt", 0.5, func(val) { + props.UpdateManager.FromHashValue("ASItrgt", 0.1, func(val) { obj["ASI_target"].setTranslation(0, val * -6.6); }), props.UpdateManager.FromHashList(["speedError","ASItrgtdiff","targetMach","tgt_kts","ktsMach"], 0.5, func(val) { From 2b27c7d483f9106b250db3be9210061ee7c66743 Mon Sep 17 00:00:00 2001 From: Jonathan Redpath Date: Fri, 29 Apr 2022 21:06:45 +0100 Subject: [PATCH 11/17] Synchronize the heading scale with the target scale --- Models/Instruments/PFD/PFD.nas | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Models/Instruments/PFD/PFD.nas b/Models/Instruments/PFD/PFD.nas index e3e34f4c..e495db34 100644 --- a/Models/Instruments/PFD/PFD.nas +++ b/Models/Instruments/PFD/PFD.nas @@ -665,7 +665,7 @@ var canvas_pfd = { obj["HDG_digit_L"].setText(sprintf("%3.0f", val)); obj["HDG_digit_R"].setText(sprintf("%3.0f", val)); }), - props.UpdateManager.FromHashValue("hdgDiff", 0.1, func(val) { + props.UpdateManager.FromHashValue("hdgDiff", 0.025, func(val) { obj["HDG_target"].setTranslation((val / 10) * 98.5416, 0); }), props.UpdateManager.FromHashList(["hdgDiff","showHdg"], 0.01, func(val) { From cf9a657195349c980e8f4a49058fd2cffa5cc0ac Mon Sep 17 00:00:00 2001 From: Jonathan Redpath Date: Sat, 30 Apr 2022 13:14:13 +0100 Subject: [PATCH 12/17] IESI - revise power so that it also uses Emesary --- A320-main.xml | 4 + Models/Instruments/IESI/IESI.nas | 305 ++++++++++++++++++------------- Models/Instruments/PFD/PFD.nas | 22 +-- Nasal/FMGC/FMGC-c.nas | 12 +- Systems/a320-misc.xml | 1 + 5 files changed, 203 insertions(+), 141 deletions(-) diff --git a/A320-main.xml b/A320-main.xml index 4248d265..983e4fd8 100644 --- a/A320-main.xml +++ b/A320-main.xml @@ -1758,7 +1758,11 @@ + false false + + false + diff --git a/Models/Instruments/IESI/IESI.nas b/Models/Instruments/IESI/IESI.nas index 7277fe89..67ca58c6 100644 --- a/Models/Instruments/IESI/IESI.nas +++ b/Models/Instruments/IESI/IESI.nas @@ -4,7 +4,6 @@ # props.nas nodes var iesi_init = props.globals.initNode("/instrumentation/iesi/iesi-init", 0, "BOOL"); -var iesi_reset = props.globals.initNode("/instrumentation/iesi/att-reset", 0, "DOUBLE"); var pinPrograms = { metricAltitude: 1, @@ -29,6 +28,7 @@ var canvas_IESI = { }; canvas.parsesvg(obj.group, svg, {"font-mapper": obj.font_mapper} ); + foreach(var key; obj.getKeys()) { obj[key] = obj.group.getElementById(key); @@ -46,20 +46,28 @@ var canvas_IESI = { obj[key].set("clip-frame", canvas.Element.PARENT); } }; + obj.AI_horizon_trans = obj["AI_horizon"].createTransform(); obj.AI_horizon_rot = obj["AI_horizon"].createTransform(); obj._aiCenter = obj["AI_center"].getCenter(); + obj._cachedInhg = -999; + obj._cachedMetric = pinPrograms.metricAltitude; obj._cachedMode = nil; + obj._cachedShowInhg = pinPrograms.showInHg; obj._canReset = 0; obj._excessMotionInInit = 0; obj._fastInit = 0; obj._IESITime = 0; obj._isNegativeAlt = 0; obj._middleAltOffset = nil; - obj._powerResult = 0; - obj._roll = 0; + obj.iesiInAlign = 0; + + + obj["IESI"].hide(); + obj["IESI_Init"].show(); + obj["ATTflag"].hide(); obj.update_items = [ props.UpdateManager.FromHashValue("airspeed", 0.1, func(val) { @@ -78,6 +86,7 @@ var canvas_IESI = { obj.altOffset = (val / 500) - int(val / 500); obj.middleAltText = roundaboutAlt(val / 100); + if (obj.altOffset > 0.5) { obj._middleAltOffset = -(obj.altOffset - 1) * 258.5528; } else { @@ -86,6 +95,7 @@ var canvas_IESI = { obj["ALT_scale"].setTranslation(0, -obj._middleAltOffset); obj["ALT_scale"].update(); + obj["ALT_five"].setText(sprintf("%03d", abs(obj.middleAltText + 10))); obj["ALT_four"].setText(sprintf("%03d", abs(obj.middleAltText + 5))); obj["ALT_three"].setText(sprintf("%03d", abs(obj.middleAltText))); @@ -93,8 +103,8 @@ var canvas_IESI = { obj["ALT_one"].setText(sprintf("%03d", abs(obj.middleAltText - 10))); obj["ALT_meters"].setText(sprintf("%5.0f", math.round(val * 0.3048, 10))); - obj.altTens = num(right(sprintf("%02d", val), 2)); - obj["ALT_tens"].setTranslation(0, obj.altTens * 3.16); + + obj["ALT_tens"].setTranslation(0, num(right(sprintf("%02d", val), 2)) * 3.16); }), props.UpdateManager.FromHashValue("altitude_ind", 0.5, func(val) { obj["ALT_digits"].setText(sprintf("%s", math.clamp(val, -20, 500))); @@ -111,16 +121,15 @@ var canvas_IESI = { props.UpdateManager.FromHashValue("mach", 0.001, func(val) { obj["ASI_mach"].setText(sprintf("%2.0f", math.clamp(val * 100, 0, 99))); }), - props.UpdateManager.FromHashValue("pitch", 0.025, func(val) { + props.UpdateManager.FromHashValue("iesiPitch", 0.025, func(val) { obj.AI_horizon_trans.setTranslation(0, val * 16.74); }), props.UpdateManager.FromHashValue("roll", 0.025, func(val) { - obj._roll = -val * D2R; - obj.AI_horizon_rot.setRotation(obj._roll, obj._aiCenter); - obj["AI_bank"].setRotation(obj._roll); + obj.AI_horizon_rot.setRotation(-val * D2R, obj._aiCenter); + obj["AI_bank"].setRotation(-val * D2R); }), props.UpdateManager.FromHashValue("skid", 0.1, func(val) { - if (abs(val) >= 84.99) { + if (abs(val) >= 85) { obj["AI_slipskid"].hide(); } else { obj["AI_slipskid"].setTranslation(-val, 0); @@ -128,112 +137,172 @@ var canvas_IESI = { } }), ]; + + obj.update_items_init = [ + props.UpdateManager.FromHashList(["iesiAlignTime","elapsedTime"], 0.5, func(val) { + if (val.iesiAlignTime + 90 >= val.elapsedTime) { + obj.iesiInAlign = 1; + } else { + obj.iesiInAlign = 0; + } + }), + props.UpdateManager.FromHashList(["iesiInAlign","iesiFastInit","irAlignFault"], 1, func(val) { + if (val.iesiInAlign) { + if (!val.iesiFastInit and val.irAlignFault) { + obj._excessMotionInInit = 1; + } + } + }), + props.UpdateManager.FromHashList(["iesiExcessMotion","iesiFastInit","iesiInAlign"], 1, func(val) { + if (val.iesiInAlign) { + if (val.iesiFastInit) { + obj["IESI"].show(); + obj["IESI_Init"].hide(); + obj["AI_bank"].hide(); + obj["AI_bank_center"].hide(); + obj["AI_bank_scale"].hide(); + obj["AI_horizon"].hide(); + obj["AI_sky_bank"].hide(); + obj["ATTflag_text"].setText("ATT 10s"); + obj["ATTflag_text"].setColor(0,0,0); + obj["ATTflag_rect"].setScale(1.5,1); + obj["ATTflag_rect"].setTranslation(-250,0); + obj["ATTflag_rect"].setColorFill(1,1,0); + obj["ATTflag_rect"].setColor(1,1,0); + obj["ATTflag"].show(); + obj["attRst"].hide(); + obj["attRstRect"].hide(); + } else { + obj["IESI"].hide(); + obj["IESI_Init"].show(); + obj["ATTflag"].hide(); + } + } else { + if (!val.iesiExcessMotion) { + obj["IESI_Init"].hide(); + obj["IESI"].show(); + obj["AI_bank"].show(); + obj["AI_bank_center"].show(); + obj["AI_bank_scale"].show(); + obj["AI_index"].show(); + obj["AI_horizon"].show(); + obj["AI_sky_bank"].show(); + obj["ATTflag"].hide(); + } else { + obj["IESI_Init"].hide(); + obj["IESI"].show(); + obj["AI_bank"].hide(); + obj["AI_bank_center"].hide(); + obj["AI_bank_scale"].hide(); + obj["AI_horizon"].hide(); + obj["AI_sky_bank"].hide(); + obj["ATTflag_text"].setText("ATT"); + obj["ATTflag_text"].setColor(1,0,0); + obj["ATTflag_rect"].setScale(1,1); + obj["ATTflag_rect"].setTranslation(0,0); + obj["ATTflag_rect"].setColorFill(0,0,0); + obj["ATTflag_rect"].setColor(0,0,0); + obj["ATTflag"].show(); + obj["attRst"].show(); + obj["attRstRect"].show(); + } + } + }), + ]; + + obj.update_items_power = [ + props.UpdateManager.FromHashList(["iesiPowered","iesiBrt"], 0.005, func(val) { + if (val.iesiPowered and val.iesiBrt > 0.01) { + obj.group.setVisible(1); + } else { + obj.group.setVisible(0); + } + }), + props.UpdateManager.FromHashList(["iesiPowered","acconfig","iesiInit"], 1, func(val) { + if (val.iesiPowered) { + if (val.iesiInit) return; + obj.initIESI(val.acconfig); + } elsif (val.iesiInit) { + obj._canReset = 0; + obj._excessMotionInInit = 0; + obj._fastInit = 0; + iesi_init.setBoolValue(0); + } + }), + ]; return obj; - }, + }, getKeys: func() { return ["IESI","IESI_Init","attRst","attRstRect","att90s","ATTflag","ATTflag_rect","ATTflag_text","ALTwarn","SPDwarn","ASI_scale","ASI_mach","ASI_mach_decimal","AI_center","AI_index","AI_horizon","AI_sky_bank","AI_bank","AI_bank_center","AI_slipskid","ALT_scale","ALT_one","ALT_two","ALT_three","ALT_four","ALT_five","ALT_digits","ALT_tens","ALT_meters","QNH_setting","QNH_std","negText","negText2","AI_bank_scale","metricM","metricBox"]; }, - alignFault: props.globals.getNode("/systems/navigation/align-fault"), update: func(notification) { - me._powerResult = me.updatePower(notification); - if (me._powerResult == 0) { return; } + me.updatePower(notification); - if (math.abs(notification.qnh_inhg - me._cachedInhg) > 0.005 or notification.altimeter_mode != me._cachedMode) { - me._cachedInhg = notification.qnh_inhg; - me._cachedMode = notification.altimeter_mode; + foreach(var update_item; me.update_items_power) + { + update_item.update(notification); + } + + if (!me.group.getVisible()) { return; } + + notification.iesiAlignTime = me._IESITime; + notification.iesiExcessMotion = me._excessMotionInInit; + notification.iesiFastInit = me._fastInit; + notification.iesiInAlign = me.iesiInAlign; + + foreach(var update_item; me.update_items_init) + { + update_item.update(notification); + } + + if (math.abs(notification.qnh_inhg_iesi - me._cachedInhg) > 0.005 or notification.altimeter_mode_iesi != me._cachedMode or pinPrograms.showInHg != me._cachedShowInhg) { + me._cachedInhg = notification.qnh_inhg_iesi; + me._cachedMode = notification.altimeter_mode_iesi; + me._cachedShowInhg = pinPrograms.showInHg; me.updateQNH(notification); } - if (me._IESITime + 90 >= notification.elapsedTime) { - if (!me._fastInit and me.alignFault.getBoolValue()) { - me._excessMotionInInit = 1; - } - - if (me._fastInit) { - me["IESI"].show(); - me["IESI_Init"].hide(); - me["AI_bank"].hide(); - me["AI_bank_center"].hide(); - me["AI_bank_scale"].hide(); - me["AI_horizon"].hide(); - me["AI_sky_bank"].hide(); - me["ATTflag_text"].setText("ATT 10s"); - me["ATTflag_text"].setColor(0,0,0); - me["ATTflag_rect"].setScale(1.5,1); - me["ATTflag_rect"].setTranslation(-250,0); - me["ATTflag_rect"].setColorFill(1,1,0); - me["ATTflag_rect"].setColor(1,1,0); - me["ATTflag"].show(); - me["attRst"].hide(); - me["attRstRect"].hide(); - } else { - me["IESI"].hide(); - me["IESI_Init"].show(); - me["ATTflag"].hide(); - return; - } - } else { - if (pinPrograms.metricAltitude) { - me["ALT_meters"].show(); - me["metricM"].show(); - me["metricBox"].show(); - - if (me._isNegativeAlt) { - me["negText2"].show(); - } else { - me["negText2"].hide(); - } - } else { - me["ALT_meters"].hide(); - me["metricM"].hide(); - me["metricBox"].hide(); - me["negText2"].hide(); - } - - if (!me._excessMotionInInit) { - me["IESI_Init"].hide(); - me["IESI"].show(); - me["AI_bank"].show(); - me["AI_bank_center"].show(); - me["AI_bank_scale"].show(); - me["AI_index"].show(); - me["AI_horizon"].show(); - me["AI_sky_bank"].show(); - me["ATTflag"].hide(); - } else { - me["IESI_Init"].hide(); - me["IESI"].show(); - me["AI_bank"].hide(); - me["AI_bank_center"].hide(); - me["AI_bank_scale"].hide(); - me["AI_horizon"].hide(); - me["AI_sky_bank"].hide(); - me["ATTflag_text"].setText("ATT"); - me["ATTflag_text"].setColor(1,0,0); - me["ATTflag_rect"].setScale(1,1); - me["ATTflag_rect"].setTranslation(0,0); - me["ATTflag_rect"].setColorFill(0,0,0); - me["ATTflag_rect"].setColor(0,0,0); - me["ATTflag"].show(); - me["attRst"].show(); - me["attRstRect"].show(); - } - } + if (me.iesiInAlign and !me._fastInit) return; foreach(var update_item; me.update_items) { update_item.update(notification); } + + if (!me.iesiInAlign and pinPrograms.metricAltitude != me._cachedMetric) { + me._cachedMetric = pinPrograms.metricAltitude; + me.updateMetric(pinPrograms.metricAltitude); + } + + if (pinPrograms.metricAltitude) { + if (me._isNegativeAlt) { + me["negText2"].show(); + } else { + me["negText2"].hide(); + } + } + }, + updateMetric: func(val) { + if (val) { + me["ALT_meters"].show(); + me["metricM"].show(); + me["metricBox"].show(); + } else { + me["ALT_meters"].hide(); + me["metricM"].hide(); + me["metricBox"].hide(); + me["negText2"].hide(); + } }, updateQNH: func(notification) { - if (notification.altimeter_mode) { + if (notification.altimeter_mode_iesi) { me["QNH_setting"].hide(); me["QNH_std"].show(); } else { if (pinPrograms.showInHg) { - me["QNH_setting"].setText(sprintf("%4.0f", notification.qnh_hpa) ~ "/" ~ sprintf("%2.2f", notification.qnh_inhg)); + me["QNH_setting"].setText(sprintf("%4.0f", notification.qnh_hpa_iesi) ~ "/" ~ sprintf("%2.2f", notification.qnh_inhg_iesi)); } else { - me["QNH_setting"].setText(sprintf("%4.0f", notification.qnh_hpa)); + me["QNH_setting"].setText(sprintf("%4.0f", notification.qnh_hpa_iesi)); } me["QNH_std"].hide(); me["QNH_setting"].show(); @@ -248,28 +317,13 @@ var canvas_IESI = { } else if (me._IESITime + 90 < notification.elapsedTime and notification.iesiInit and !me._canReset) { me._canReset = 1; } - - if (notification.iesiPowered) { - if (notification.acconfig != 1 and notification.iesiInit != 1) { - iesi_init.setBoolValue(1); - me._IESITime = notification.elapsedTime - (me._fastInit ? 80 : 0); - } else if (notification.acconfig == 1 and notification.iesiInit != 1) { - iesi_init.setBoolValue(1); - me._IESITime = notification.elapsedTime - 87; - } - } elsif (notification.iesiInit) { - me._canReset = 0; - me._excessMotionInInit = 0; - me._fastInit = 0; - iesi_init.setBoolValue(0); - } - - if (notification.iesiPowered and notification.iesiBrt > 0.01) { - me.group.setVisible(1); - return 1; + }, + initIESI: func(acconfig) { + iesi_init.setBoolValue(1); + if (!acconfig) { + me._IESITime = pts.Sim.Time.elapsedSec.getValue() - (me._fastInit ? 80 : 0); } else { - me.group.setVisible(0); - return 0; + me._IESITime = pts.Sim.Time.elapsedSec.getValue() - 87; } }, }; @@ -302,40 +356,41 @@ var IESIRecipient = var A320IESI = IESIRecipient.new("A320 IESI"); emesary.GlobalTransmitter.Register(A320IESI); +# Emesary Frame Notifiaction Properties var input = { "acconfig": "/systems/acconfig/autoconfig-running", "airspeed": "/instrumentation/airspeed-indicator[0]/indicated-speed-kt", "altitude": "/instrumentation/altimeter[6]/indicated-altitude-ft", "altitude_ind": "/instrumentation/altimeter[6]/indicated-altitude-ft-pfd", - "altimeter_mode": "/instrumentation/altimeter[6]/std", + "altimeter_mode_iesi": "/instrumentation/altimeter[6]/std", "attReset": "/instrumentation/iesi/att-reset", "iesiBrt": "/controls/lighting/DU/iesi", "iesiInit": "/instrumentation/iesi/iesi-init", + "iesiPitch": "/instrumentation/iesi/pitch-deg", "iesiPowered": "/instrumentation/iesi/power/power-on", + "irAlignFault": "/systems/navigation/align-fault", "mach": "/instrumentation/airspeed-indicator/indicated-mach", - "pitch": "/instrumentation/iesi/pitch-deg", - "qnh_hpa": "/instrumentation/altimeter[6]/setting-hpa", - "qnh_inhg": "/instrumentation/altimeter[6]/setting-inhg", + "qnh_hpa_iesi": "/instrumentation/altimeter[6]/setting-hpa", + "qnh_inhg_iesi": "/instrumentation/altimeter[6]/setting-inhg", "roll": "/orientation/roll-deg", - "skid": "/instrumentation/iesi/slip-skid", "showMach": "/instrumentation/iesi/display/show-mach", + "skid": "/instrumentation/iesi/slip-skid", }; foreach (var name; keys(input)) { emesary.GlobalTransmitter.NotifyAll(notifications.FrameNotificationAddProperty.new("A320 IESI", name, input[name])); } +# Helper functions var showIESI = func { var dlg = canvas.Window.new([512, 512], "dialog").set("resize", 1); dlg.setCanvas(A320IESI.MainScreen.canvas); } var roundabout = func(x) { - var y = x - int(x); - return y < 0.5 ? int(x) : 1 + int(x); + return (x - int(x)) < 0.5 ? int(x) : 1 + int(x); }; var roundaboutAlt = func(x) { - var y = x * 0.2 - int(x * 0.2); - return y < 0.5 ? 5 * int(x * 0.2) : 5 + 5 * int(x * 0.2); + return (x * 0.2 - int(x * 0.2)) < 0.5 ? 5 * int(x * 0.2) : 5 + 5 * int(x * 0.2); }; \ No newline at end of file diff --git a/Models/Instruments/PFD/PFD.nas b/Models/Instruments/PFD/PFD.nas index e495db34..053d7b99 100644 --- a/Models/Instruments/PFD/PFD.nas +++ b/Models/Instruments/PFD/PFD.nas @@ -16,7 +16,6 @@ var alt_inhg = props.globals.getNode("/instrumentation/altimeter/setting-inhg", var aoa_1 = props.globals.getNode("/systems/navigation/adr/output/aoa-1", 1); var aoa_2 = props.globals.getNode("/systems/navigation/adr/output/aoa-2", 1); var aoa_3 = props.globals.getNode("/systems/navigation/adr/output/aoa-3", 1); -var elapsedtime = props.globals.getNode("/sim/time/elapsed-sec", 1); var hundredAbove = props.globals.getNode("/instrumentation/pfd/hundred-above", 1); var minimum = props.globals.getNode("/instrumentation/pfd/minimums", 1); @@ -26,6 +25,7 @@ var amberFlash = [0, 0]; var dhFlash = 0; var ilsFlash = [0,0]; var qnhFlash = [0,0]; +var elapsedtime_act = nil; var du1_test = props.globals.initNode("/instrumentation/du/du1-test", 0, "BOOL"); var du1_test_time = props.globals.initNode("/instrumentation/du/du1-test-time", 0.0, "DOUBLE"); var du1_offtime = props.globals.initNode("/instrumentation/du/du1-off-time", 0.0, "DOUBLE"); @@ -876,7 +876,7 @@ var canvas_pfd = { obj["flap_max"].hide(); } }), - props.UpdateManager.FromHashValue("Ctrgt", , 0.1, func(val) { + props.UpdateManager.FromHashValue("Ctrgt", 0.1, func(val) { obj["clean_speed"].setTranslation(0, val * -6.6); }), props.UpdateManager.FromHashValue("Ftrgt", 0.1, func(val) { @@ -1995,7 +1995,7 @@ var canvas_pfd = { me.testTimeNode = du1_test_time; } - var elapsedtime_act = elapsedtime.getValue(); + elapsedtime_act = pts.Sim.Time.elapsedSec.getValue(); if (me.powerNode.getValue() >= 110) { if (!me.on) { if (me.offTimeNode.getValue() + 3 < elapsedtime_act) { @@ -2245,20 +2245,19 @@ setlistener("/systems/electrical/bus/ac-2", func() { }, 0, 0); # Helper Functions - var roundabout = func(x) { - var y = x - int(x); - return y < 0.5 ? int(x) : 1 + int(x); + return (x - int(x)) < 0.5 ? int(x) : 1 + int(x); }; var roundaboutAlt = func(x) { - var y = x * 0.2 - int(x * 0.2); - return y < 0.5 ? 5 * int(x * 0.2) : 5 + 5 * int(x * 0.2); + return (x * 0.2 - int(x * 0.2)) < 0.5 ? 5 * int(x * 0.2) : 5 + 5 * int(x * 0.2); }; +var _fontSizeHDGTempVar = nil; + var fontSizeHDG = func(input) { - var test = input / 3; - if (test == int(test)) { + _fontSizeHDGTempVar = input / 3; + if (_fontSizeHDGTempVar == int(_fontSizeHDGTempVar)) { return 42; } else { return 32; @@ -2274,6 +2273,7 @@ var showPFD2 = func { var dlg = canvas.Window.new([512, 512], "dialog").set("resize", 1); dlg.setCanvas(A320PFD2.MainScreen.canvas); } + # Flash managers var ils_going1 = 0; var ilsTimer1 = maketimer(0.50, func { @@ -2380,4 +2380,4 @@ setlistener("/modes/pfd/fma/pitch-mode", func(pitch) { } else { autoland_pitch_land.setBoolValue(0); } -},0,0); +}, 0, 0); diff --git a/Nasal/FMGC/FMGC-c.nas b/Nasal/FMGC/FMGC-c.nas index b918532f..df839956 100644 --- a/Nasal/FMGC/FMGC-c.nas +++ b/Nasal/FMGC/FMGC-c.nas @@ -554,21 +554,23 @@ var fmaAthr = func { } } +var elapsedTimeBoxes = nil; var showAllBoxes = func { + elapsedTimeBoxes = pts.Sim.Time.elapsedSec.getValue(); if (Modes.PFD.FMA.rollMode.getValue() != " ") { - Modes.PFD.FMA.rollModeTime.setValue(pts.Sim.Time.elapsedSec.getValue()); + Modes.PFD.FMA.rollModeTime.setValue(elapsedTimeBoxes); } if (Modes.PFD.FMA.pitchMode.getValue() != " ") { - Modes.PFD.FMA.pitchModeTime.setValue(pts.Sim.Time.elapsedSec.getValue()); + Modes.PFD.FMA.pitchModeTime.setValue(elapsedTimeBoxes); } if (Modes.PFD.FMA.rollModeArmed.getValue() != " ") { - Modes.PFD.FMA.rollModeArmedTime.setValue(pts.Sim.Time.elapsedSec.getValue()); + Modes.PFD.FMA.rollModeArmedTime.setValue(elapsedTimeBoxes); } if (Modes.PFD.FMA.pitchModeArmed.getValue() != " ") { - Modes.PFD.FMA.pitchModeArmedTime.setValue(pts.Sim.Time.elapsedSec.getValue()); + Modes.PFD.FMA.pitchModeArmedTime.setValue(elapsedTimeBoxes); } if (Modes.PFD.FMA.pitchMode2Armed.getValue() != " ") { - Modes.PFD.FMA.pitchMode2ArmedTime.setValue(pts.Sim.Time.elapsedSec.getValue()); + Modes.PFD.FMA.pitchMode2ArmedTime.setValue(elapsedTimeBoxes); } } diff --git a/Systems/a320-misc.xml b/Systems/a320-misc.xml index fa8d5edd..31696c72 100644 --- a/Systems/a320-misc.xml +++ b/Systems/a320-misc.xml @@ -571,6 +571,7 @@ 4 /controls/lighting/DU/iesi + /instrumentation/iesi/power/power-on From c845cda5af3be8d76bce45bdd6af0137df993fe6 Mon Sep 17 00:00:00 2001 From: Jonathan Redpath Date: Sat, 30 Apr 2022 13:17:25 +0100 Subject: [PATCH 13/17] Fix confusion between IESI and PFD nodes --- Models/Instruments/IESI/IESI.nas | 34 ++++++++++++++++++-------------- Models/Instruments/PFD/PFD.nas | 12 +++++------ 2 files changed, 25 insertions(+), 21 deletions(-) diff --git a/Models/Instruments/IESI/IESI.nas b/Models/Instruments/IESI/IESI.nas index 67ca58c6..51dc6810 100644 --- a/Models/Instruments/IESI/IESI.nas +++ b/Models/Instruments/IESI/IESI.nas @@ -70,12 +70,22 @@ var canvas_IESI = { obj["ATTflag"].hide(); obj.update_items = [ - props.UpdateManager.FromHashValue("airspeed", 0.1, func(val) { + props.UpdateManager.FromHashValue("airspeedIESI", 0.1, func(val) { obj["ASI_scale"].setTranslation(0, math.clamp(val - 30, 0, 490) * 8.295); }), - props.UpdateManager.FromHashValue("altitude", 0.5, func(val) { + props.UpdateManager.FromHashValue("altitudeIESI", 0.5, func(val) { val = math.clamp(val, -2000, 50000); + obj["ALT_meters"].setText(sprintf("%5.0f", math.round(val * 0.3048, 10))); + + obj.middleAltText = roundaboutAlt(val / 100); + + obj["ALT_five"].setText(sprintf("%03d", abs(obj.middleAltText + 10))); + obj["ALT_four"].setText(sprintf("%03d", abs(obj.middleAltText + 5))); + obj["ALT_three"].setText(sprintf("%03d", abs(obj.middleAltText))); + obj["ALT_two"].setText(sprintf("%03d", abs(obj.middleAltText - 5))); + obj["ALT_one"].setText(sprintf("%03d", abs(obj.middleAltText - 10))); + if (val < 0) { obj["negText"].show(); obj._isNegativeAlt = 1; @@ -83,9 +93,11 @@ var canvas_IESI = { obj["negText"].hide(); obj._isNegativeAlt = 0; } + }), + props.UpdateManager.FromHashValue("altitudeIESI", 0.1, func(val) { + val = math.clamp(val, -2000, 50000); obj.altOffset = (val / 500) - int(val / 500); - obj.middleAltText = roundaboutAlt(val / 100); if (obj.altOffset > 0.5) { obj._middleAltOffset = -(obj.altOffset - 1) * 258.5528; @@ -96,17 +108,9 @@ var canvas_IESI = { obj["ALT_scale"].setTranslation(0, -obj._middleAltOffset); obj["ALT_scale"].update(); - obj["ALT_five"].setText(sprintf("%03d", abs(obj.middleAltText + 10))); - obj["ALT_four"].setText(sprintf("%03d", abs(obj.middleAltText + 5))); - obj["ALT_three"].setText(sprintf("%03d", abs(obj.middleAltText))); - obj["ALT_two"].setText(sprintf("%03d", abs(obj.middleAltText - 5))); - obj["ALT_one"].setText(sprintf("%03d", abs(obj.middleAltText - 10))); - - obj["ALT_meters"].setText(sprintf("%5.0f", math.round(val * 0.3048, 10))); - obj["ALT_tens"].setTranslation(0, num(right(sprintf("%02d", val), 2)) * 3.16); }), - props.UpdateManager.FromHashValue("altitude_ind", 0.5, func(val) { + props.UpdateManager.FromHashValue("altitude_indIESI", 0.5, func(val) { obj["ALT_digits"].setText(sprintf("%s", math.clamp(val, -20, 500))); }), props.UpdateManager.FromHashValue("showMach", 1, func(val) { @@ -359,9 +363,9 @@ emesary.GlobalTransmitter.Register(A320IESI); # Emesary Frame Notifiaction Properties var input = { "acconfig": "/systems/acconfig/autoconfig-running", - "airspeed": "/instrumentation/airspeed-indicator[0]/indicated-speed-kt", - "altitude": "/instrumentation/altimeter[6]/indicated-altitude-ft", - "altitude_ind": "/instrumentation/altimeter[6]/indicated-altitude-ft-pfd", + "airspeedIESI": "/instrumentation/airspeed-indicator[0]/indicated-speed-kt", + "altitudeIESI": "/instrumentation/altimeter[6]/indicated-altitude-ft", + "altitude_indIESI": "/instrumentation/altimeter[6]/indicated-altitude-ft-pfd", "altimeter_mode_iesi": "/instrumentation/altimeter[6]/std", "attReset": "/instrumentation/iesi/att-reset", "iesiBrt": "/controls/lighting/DU/iesi", diff --git a/Models/Instruments/PFD/PFD.nas b/Models/Instruments/PFD/PFD.nas index 053d7b99..f9b22f31 100644 --- a/Models/Instruments/PFD/PFD.nas +++ b/Models/Instruments/PFD/PFD.nas @@ -1221,7 +1221,7 @@ var canvas_pfd = { obj["Metric_cur_alt"].hide(); } }), - props.UpdateManager.FromHashValue("altitude", 0.5, func(val) { + props.UpdateManager.FromHashValue("altitudePFD", 0.5, func(val) { obj["Metric_cur_alt"].setText(sprintf("%5.0f", val * 0.3048)); obj.middleAltText = roundaboutAlt(val / 100); @@ -1238,7 +1238,7 @@ var canvas_pfd = { obj["ALT_neg"].hide(); } }), - props.UpdateManager.FromHashValue("altitude", 0.1, func(val) { + props.UpdateManager.FromHashValue("altitudePFD", 0.1, func(val) { obj.altOffset = val / 500 - int(val / 500); obj.middleAltOffset = nil; @@ -1685,7 +1685,7 @@ var canvas_pfd = { if (dmc.DMController.DMCs[me.number].outputs[1] != nil) { notification.altError = 0; - notification.altitude = dmc.DMController.DMCs[me.number].outputs[1].getValue(); + notification.altitudePFD = dmc.DMController.DMCs[me.number].outputs[1].getValue(); notification.altitudeDigits = dmc.DMController.DMCs[me.number].outputs[3].getValue(); notification.altitudeDifference = dmc.DMController.DMCs[me.number].outputs[7].getValue(); @@ -1769,7 +1769,7 @@ var canvas_pfd = { } } else { notification.altError = 1; - notification.altitude = -9999; + notification.altitudePFD = -9999; notification.altitudeDigits = -9999; notification.altitudeDifference = -9999; } @@ -1814,7 +1814,7 @@ var canvas_pfd = { } if (notification.altimeterStd == 1) { - if (notification.altitude < fmgc.FMGCInternal.transAlt and fmgc.FMGCInternal.phase == 4) { + if (notification.altitudePFD < fmgc.FMGCInternal.transAlt and fmgc.FMGCInternal.phase == 4) { if (me.number == 0) { if (qnh_going1 == 0) { qnhTimer1.start(); @@ -1848,7 +1848,7 @@ var canvas_pfd = { me["QNH_box"].show(); } } else { - if (notification.altitude >= fmgc.FMGCInternal.transAlt and fmgc.FMGCInternal.phase == 2) { + if (notification.altitudePFD >= fmgc.FMGCInternal.transAlt and fmgc.FMGCInternal.phase == 2) { if (me.number == 0) { if (qnh_going1 == 0) { qnhTimer1.start(); From a6770fe3e26c24b0453fe2ee9e47591a0577f7b3 Mon Sep 17 00:00:00 2001 From: Jonathan Redpath Date: Sat, 30 Apr 2022 16:52:58 +0100 Subject: [PATCH 14/17] Begin to rewrite lower ECAM power --- .../Instruments/Lower-ECAM/Lower-ECAM-APU.nas | 59 ++++++------ .../Lower-ECAM/Lower-ECAM-base.nas | 3 +- Models/Instruments/Lower-ECAM/Lower-ECAM.nas | 5 + Systems/a320-misc.xml | 94 +++++++++++++++++-- 4 files changed, 118 insertions(+), 43 deletions(-) diff --git a/Models/Instruments/Lower-ECAM/Lower-ECAM-APU.nas b/Models/Instruments/Lower-ECAM/Lower-ECAM-APU.nas index 66c29724..62df0b79 100644 --- a/Models/Instruments/Lower-ECAM/Lower-ECAM-APU.nas +++ b/Models/Instruments/Lower-ECAM/Lower-ECAM-APU.nas @@ -194,6 +194,25 @@ var canvas_lowerECAMPageApu = }), ]; + obj.updateItemsPower = [ + props.UpdateManager.FromHashList(["du3Power","du4Power","du3InTest","du4InTest","ecamDuXfr","pageMatch"], 1, func(val) { + if (val.pageMatch) { + if (val.du4Power) { + obj.group.setVisible(val.du4InTest ? 0 : 1); + obj.test.setVisible(val.du4InTest ? 1 : 0); + } else if (val.ecamDuXfr and val.du3Power) { + obj.group.setVisible(val.du3InTest ? 0 : 1); + obj.test.setVisible(val.du3InTest ? 1 : 0); + } else { + obj.group.setVisible(0); + obj.test.setVisible(0); + } + } else { + obj.group.setVisible(0); + } + }), + ]; + obj.updateItemsBottom = [ props.UpdateManager.FromHashValue("acconfigUnits", nil, func(val) { obj.units = val; @@ -269,7 +288,7 @@ var canvas_lowerECAMPageApu = } }, update: func(notification) { - me.updatePower(); + me.updatePower(notification); if (me.test.getVisible() == 1) { me.updateTest(notification); @@ -312,38 +331,16 @@ var canvas_lowerECAMPageApu = me.updateBottom(notification); }, - updatePower: func() { + updatePower: func(notification) { if (me.name == ecam.SystemDisplayController.displayedPage.name) { - if (du4_lgt.getValue() > 0.01 and systems.ELEC.Bus.ac2.getValue() >= 110) { - if (du4_test_time.getValue() + du4_test_amount.getValue() >= pts.Sim.Time.elapsedSec.getValue()) { - me.group.setVisible(0); - me.test.setVisible(1); - } else { - me.group.setVisible(1); - me.test.setVisible(0); - } - } else { - if (pts.Modes.EcamDuXfr.getBoolValue()) { - if (du3_lgt.getValue() > 0.01 and systems.ELEC.Bus.acEss.getValue() >= 110) { - if (du3_test_time.getValue() + du3_test_amount.getValue() >= pts.Sim.Time.elapsedSec.getValue()) { - me.group.setVisible(0); - me.test.setVisible(1); - } else { - me.group.setVisible(1); - me.test.setVisible(0); - } - } else { - me.group.setVisible(0); - me.test.setVisible(0); - } - } else { - me.group.setVisible(0); - me.test.setVisible(0); - } - } + notification.pageMatch = 1; } else { - me.group.setVisible(0); - # don't hide the test group; just let whichever page is active control it + notification.pageMatch = 0; + } + + foreach(var update_item; me.updateItemsPower) + { + update_item.update(notification); } }, }; diff --git a/Models/Instruments/Lower-ECAM/Lower-ECAM-base.nas b/Models/Instruments/Lower-ECAM/Lower-ECAM-base.nas index 98e9260d..3e23d36b 100644 --- a/Models/Instruments/Lower-ECAM/Lower-ECAM-base.nas +++ b/Models/Instruments/Lower-ECAM/Lower-ECAM-base.nas @@ -73,8 +73,7 @@ var canvas_lowerECAM_base = } }, # Due to weirdness of the parents hash / me reference - # you need to access it using me.Test_white rather than - # me["Test_white"] + # you need to access it using me.Test_white updateTest: func(notification) { if (du4_test_time.getValue() + 1 >= notification.elapsedTime) { me.Test_white.show(); diff --git a/Models/Instruments/Lower-ECAM/Lower-ECAM.nas b/Models/Instruments/Lower-ECAM/Lower-ECAM.nas index 02c0bc3f..e228ca74 100644 --- a/Models/Instruments/Lower-ECAM/Lower-ECAM.nas +++ b/Models/Instruments/Lower-ECAM/Lower-ECAM.nas @@ -61,6 +61,11 @@ var input = { gForceDisplay: "/ECAM/Lower/g-force-display", hour: "/sim/time/utc/hour", minute: "/sim/time/utc/minute", + du3Power: "/instrumentation/displays/du3/power-on", + du4Power: "/instrumentation/displays/du4/power-on", + du3InTest: "/instrumentation/displays/du3/test-active", + du4InTest: "/instrumentation/displays/du4/test-active", + ecamDuXfr: "/modes/ecam-du-xfr", }; foreach (var name; keys(input)) { diff --git a/Systems/a320-misc.xml b/Systems/a320-misc.xml index 31696c72..f3526b79 100644 --- a/Systems/a320-misc.xml +++ b/Systems/a320-misc.xml @@ -29,16 +29,6 @@ - - - - /instrumentation/iesi/att-reset-cmd - 0.5 - 100 - - - - @@ -526,6 +516,12 @@ + + /instrumentation/iesi/att-reset-cmd + 0.5 + 100 + + @@ -579,4 +575,82 @@ + + + + + + /systems/electrical/bus/ac-ess ge 110 + /controls/lighting/DU/du3 ge 0.01 + + + + + /instrumentation/displays/du3/power-command + 5 + 100 + + + + + + /instrumentation/displays/du3/power-transient-timer ne 0 + + + + + + + /instrumentation/du/du3-test-amount + /instrumentation/du/du3-test-time + + + + + + + + /instrumentation/displays/du3/test-sum ge /sim/time/elapsed-sec + + + + + + + /systems/electrical/bus/ac-2 ge 110 + /controls/lighting/DU/du4 ge 0.01 + + + + + /instrumentation/displays/du4/power-command + 5 + 100 + + + + + + /instrumentation/displays/du4/power-transient-timer ne 0 + + + + + + + /instrumentation/du/du4-test-amount + /instrumentation/du/du4-test-time + + + + + + + + /instrumentation/displays/du4/test-sum ge /sim/time/elapsed-sec + + + + + From 12e7258f2353f69a5a572ac94ad59f5658db11d8 Mon Sep 17 00:00:00 2001 From: Jonathan Redpath Date: Tue, 3 May 2022 15:22:49 +0100 Subject: [PATCH 15/17] Correct the ILS course indication --- Models/Instruments/PFD/PFD.nas | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Models/Instruments/PFD/PFD.nas b/Models/Instruments/PFD/PFD.nas index f9b22f31..7e8f7333 100644 --- a/Models/Instruments/PFD/PFD.nas +++ b/Models/Instruments/PFD/PFD.nas @@ -61,7 +61,6 @@ var canvas_pfd = { rightText3: 0, track_diff: 0, split_ils: 0, - magnetic_hdg: 0, magnetic_hdg_dif: 0, alt_diff_cur: 0, new: func(svg, name, number) { @@ -129,7 +128,6 @@ var canvas_pfd = { obj.rightText3 = 0; obj.track_diff = 0; obj.split_ils = 0; - obj.magnetic_hdg = 0; obj.magnetic_hdg_dif = 0; obj.alt_diff_cur = 0; @@ -1914,7 +1912,7 @@ var canvas_pfd = { if (((me.number == 0 and notification.pfdILS1) or (me.number == 1 and notification.pfdILS2)) and size(me.split_ils) == 2) { notification.showPFDILS = 1; - notification.magnetic_hdg_dif = geo.normdeg180(me.magnetic_hdg - notification.headingPFD); + notification.magnetic_hdg_dif = geo.normdeg180(notification.ilsCrs - notification.headingPFD); } else { notification.showPFDILS = 0; notification.magnetic_hdg_dif = 0; From 6aac392eeccf154bc9053a9f8c950ddee3dce499 Mon Sep 17 00:00:00 2001 From: Jonathan Redpath Date: Tue, 3 May 2022 16:19:17 +0100 Subject: [PATCH 16/17] PFD: fix bugs --- Models/Instruments/PFD/PFD.nas | 69 ++++++++++++++++-------------- Models/Instruments/PFD/res/pfd.svg | 23 +++++----- 2 files changed, 49 insertions(+), 43 deletions(-) diff --git a/Models/Instruments/PFD/PFD.nas b/Models/Instruments/PFD/PFD.nas index 7e8f7333..aeb5a6d1 100644 --- a/Models/Instruments/PFD/PFD.nas +++ b/Models/Instruments/PFD/PFD.nas @@ -234,10 +234,10 @@ var canvas_pfd = { obj["VS_box"].show(); } }), - props.UpdateManager.FromHashValue("localizer", 0.01, func(val) { + props.UpdateManager.FromHashValue("localizer", 0.0025, func(val) { obj["LOC_pointer"].setTranslation(val * 197, 0); }), - props.UpdateManager.FromHashValue("glideslope", 0.01, func(val) { + props.UpdateManager.FromHashValue("glideslope", 0.0025, func(val) { obj["GS_pointer"].setTranslation(0, val * -197); }), props.UpdateManager.FromHashList(["athr", "thrustLvrClb"], 1, func(val) { @@ -331,7 +331,7 @@ var canvas_pfd = { } }), props.UpdateManager.FromHashList(["apBox","apMode"], nil, func(val) { - obj["FMA_athr"].setText(val.apMode); + obj["FMA_ap"].setText(val.apMode); if (val.apBox and val.apMode != " ") { obj["FMA_ap_box"].show(); } else { @@ -692,7 +692,7 @@ var canvas_pfd = { obj["QNH_setting"].setText(sprintf("%2.2f", val.altimeterInhg)); } }), - props.UpdateManager.FromHashList(["altimeterStd","altitudeAutopilot"], 25, func(val) { + props.UpdateManager.FromHashList(["altimeterStd","altitudeAutopilot"], 1, func(val) { if (val.altimeterStd == 1) { if (val.altitudeAutopilot < 10000) { obj["ALT_digit_UP"].setText(sprintf("%s", "FL " ~ val.altitudeAutopilot / 100)); @@ -1219,36 +1219,42 @@ var canvas_pfd = { obj["Metric_cur_alt"].hide(); } }), - props.UpdateManager.FromHashValue("altitudePFD", 0.5, func(val) { - obj["Metric_cur_alt"].setText(sprintf("%5.0f", val * 0.3048)); - - obj.middleAltText = roundaboutAlt(val / 100); - - obj["ALT_five"].setText(sprintf("%03d", abs(obj.middleAltText + 10))); - obj["ALT_four"].setText(sprintf("%03d", abs(obj.middleAltText + 5))); - obj["ALT_three"].setText(sprintf("%03d", abs(obj.middleAltText))); - obj["ALT_two"].setText(sprintf("%03d", abs(obj.middleAltText - 5))); - obj["ALT_one"].setText(sprintf("%03d", abs(obj.middleAltText - 10))); - - if (val < 0) { - obj["ALT_neg"].show(); + props.UpdateManager.FromHashList(["altitudePFD","altError"], 0.5, func(val) { + if (!val.altError) { + obj["Metric_cur_alt"].setText(sprintf("%5.0f", val.altitudePFD * 0.3048)); + + obj.middleAltText = roundaboutAlt(val.altitudePFD / 100); + + obj["ALT_five"].setText(sprintf("%03d", abs(obj.middleAltText + 10))); + obj["ALT_four"].setText(sprintf("%03d", abs(obj.middleAltText + 5))); + obj["ALT_three"].setText(sprintf("%03d", abs(obj.middleAltText))); + obj["ALT_two"].setText(sprintf("%03d", abs(obj.middleAltText - 5))); + obj["ALT_one"].setText(sprintf("%03d", abs(obj.middleAltText - 10))); + + if (val.altitudePFD < 0) { + obj["ALT_neg"].show(); + } else { + obj["ALT_neg"].hide(); + } } else { obj["ALT_neg"].hide(); } }), - props.UpdateManager.FromHashValue("altitudePFD", 0.1, func(val) { - obj.altOffset = val / 500 - int(val / 500); - obj.middleAltOffset = nil; - - if (obj.altOffset > 0.5) { - obj.middleAltOffset = -(obj.altOffset - 1) * 243.3424; - } else { - obj.middleAltOffset = -obj.altOffset * 243.3424; + props.UpdateManager.FromHashList(["altitudePFD","altError"], 0.1, func(val) { + if (!val.altError) { + obj.altOffset = val / 500 - int(val.altitudePFD / 500); + obj.middleAltOffset = nil; + + if (obj.altOffset > 0.5) { + obj.middleAltOffset = -(obj.altOffset - 1) * 243.3424; + } else { + obj.middleAltOffset = -obj.altOffset * 243.3424; + } + + obj["ALT_scale"].setTranslation(0, -obj.middleAltOffset); + obj["ALT_scale"].update(); + obj["ALT_tens"].setTranslation(0, num(right(sprintf("%02d", val.altitudePFD), 2)) * 1.392); } - - obj["ALT_scale"].setTranslation(0, -obj.middleAltOffset); - obj["ALT_scale"].update(); - obj["ALT_tens"].setTranslation(0, num(right(sprintf("%02d", val), 2)) * 1.392); }), props.UpdateManager.FromHashValue("altitudeDigits", 1, func(val) { obj["ALT_digits"].setText(sprintf("%d", val)); @@ -1695,6 +1701,7 @@ var canvas_pfd = { alt_going2 = 0; amber_going2 = 0; } + me["ALT_box"].show(); me["ALT_box_flash"].hide(); me["ALT_box_amber"].hide(); } else { @@ -2073,14 +2080,14 @@ var canvas_pfd = { getAOAForPFD1: func() { if (air_data_switch.getValue() != -1 and adr_1_switch.getValue() and !adr_1_fault.getValue()) return aoa_1.getValue(); if (air_data_switch.getValue() == -1 and adr_3_switch.getValue() and !adr_3_fault.getValue()) return aoa_3.getValue(); - return nil; + return 0; }, # Get Angle of Attack from ADR2 or, depending on Switching panel, ADR3 getAOAForPFD2: func() { if (air_data_switch.getValue() != 1 and adr_2_switch.getValue() and !adr_2_fault.getValue()) return aoa_2.getValue(); if (air_data_switch.getValue() == 1 and adr_3_switch.getValue() and !adr_3_fault.getValue()) return aoa_3.getValue(); - return nil; + return 0; }, # Convert difference between magnetic heading and track measured in degrees to pixel for display on PFDs diff --git a/Models/Instruments/PFD/res/pfd.svg b/Models/Instruments/PFD/res/pfd.svg index 94fe82fd..215a66e5 100644 --- a/Models/Instruments/PFD/res/pfd.svg +++ b/Models/Instruments/PFD/res/pfd.svg @@ -22,7 +22,6 @@ image/svg+xml - @@ -37,13 +36,13 @@ units="pt" inkscape:snap-global="false" showguides="true" - inkscape:current-layer="ALT_group" + inkscape:current-layer="svg2" inkscape:window-maximized="1" inkscape:window-y="-11" inkscape:window-x="-11" - inkscape:cy="673.69595" - inkscape:cx="1065.6983" - inkscape:zoom="5.6568545" + inkscape:cy="228.04193" + inkscape:cx="941.86619" + inkscape:zoom="2.8284273" showgrid="false" id="namedview371" inkscape:window-height="974" @@ -2397,15 +2396,15 @@ inkscape:connector-curvature="0" id="path1283" d="m 856.4002,481.90842 2.2e-4,-15.92813 h 52.07464 v 93.34657 h -52.07457 v -15.26583" - style="fill:#000000;fill-opacity:1;stroke:#ffff00;stroke-width:3.19994998;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:fill markers stroke" /> + style="fill:#000000;fill-opacity:1;stroke:#ffff00;stroke-width:3.19995;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:fill markers stroke" /> + style="fill:none;fill-opacity:1;stroke:#ffff00;stroke-width:3.19995;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:fill markers stroke" /> RADIO 0250 Date: Tue, 3 May 2022 16:20:46 +0100 Subject: [PATCH 17/17] Fix other bug --- Models/Instruments/PFD/PFD.nas | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Models/Instruments/PFD/PFD.nas b/Models/Instruments/PFD/PFD.nas index aeb5a6d1..82bdba9f 100644 --- a/Models/Instruments/PFD/PFD.nas +++ b/Models/Instruments/PFD/PFD.nas @@ -1242,7 +1242,7 @@ var canvas_pfd = { }), props.UpdateManager.FromHashList(["altitudePFD","altError"], 0.1, func(val) { if (!val.altError) { - obj.altOffset = val / 500 - int(val.altitudePFD / 500); + obj.altOffset = val.altitudePFD / 500 - int(val.altitudePFD / 500); obj.middleAltOffset = nil; if (obj.altOffset > 0.5) {