From 270e173a777ae9d7521742090de0942c4ae7b398 Mon Sep 17 00:00:00 2001 From: Jonathan Redpath Date: Mon, 19 Nov 2018 15:13:52 +0000 Subject: [PATCH] AP off / athr off --- A320-main.xml | 9 ++++++++ Nasal/ECAM-logic.nas | 11 +++++++++ Nasal/ECAM.nas | 45 ++++++++++++++++++++++++++++++++++++ Nasal/FMGC-b.nas | 6 +++++ Nasal/libraries.nas | 2 +- Sounds/A320-common-sound.xml | 17 ++++++++++++++ 6 files changed, 89 insertions(+), 1 deletion(-) diff --git a/A320-main.xml b/A320-main.xml index f4cf0be8..cb73e3d6 100644 --- a/A320-main.xml +++ b/A320-main.xml @@ -1071,6 +1071,9 @@ if (getprop("/it-autoflight/output/athr") == 1) { setprop("/it-autoflight/input/athr", 0); } + if (libraries.athr_active == 1) { + libraries.athr_active = 0; + } @@ -1317,6 +1320,12 @@ if (getprop("/it-autoflight/output/ap2") == 1) { setprop("/it-autoflight/input/ap2", 0); } + if (libraries.ap1_active == 1) { + libraries.ap1_active = 0; + } + if (libraries.ap2_active == 1) { + libraries.ap2_active = 0; + } diff --git a/Nasal/ECAM-logic.nas b/Nasal/ECAM-logic.nas index 20adbb55..d22f19fa 100644 --- a/Nasal/ECAM-logic.nas +++ b/Nasal/ECAM-logic.nas @@ -132,6 +132,17 @@ var messages_right_memo = func { land_asap_a.active = 0; } + if (libraries.ap1_active == 1 or libraries.ap2_active == 1) { + ap_off.active = 1; + } else { + ap_off.active = 0; + } + + if (libraries.athr_active == 1) { + athr_off.active = 1; + } else { + athr_off.active = 0; + } if ((getprop("/ECAM/warning-phase") >= 2 and getprop("/ECAM/warning-phase") <= 7) and getprop("controls/flight/speedbrake") != 0) { spd_brk.active = 1; } else { diff --git a/Nasal/ECAM.nas b/Nasal/ECAM.nas index fb11991c..93661ef8 100644 --- a/Nasal/ECAM.nas +++ b/Nasal/ECAM.nas @@ -41,6 +41,9 @@ var ENGCounting = 0; var flapLever = 0; var CRZTime = 0; var CRZCondition = 0; +var ap1_active = 0; +var ap2_active = 0; +var athr_active = 0; setprop("/ECAM/left-msg", "NONE"); setprop("/position/gear-agl-ft", 0); # w = White, b = Blue, g = Green, a = Amber, r = Red @@ -73,6 +76,12 @@ var ECAM = { setprop("/ECAM/Lower/light/wheel", 0); setprop("/ECAM/warning-phase", 1); setprop("/ECAM/warning-phase-10-time", 0); + setprop("/ECAM/ap1-off-time", 0); + setprop("/ECAM/ap2-off-time", 0); + setprop("/ECAM/athr-off-time", 0); + var ap1_off_time = getprop("/ECAM/ap1-off-time"); + var ap2_off_time = getprop("/ECAM/ap2-off-time"); + var athr_off_time = getprop("/ECAM/athr-off-time"); LowerECAM.reset(); }, MSGclr: func() { @@ -185,6 +194,19 @@ var ECAM = { } } + # AP / ATHR warnings + if (ap1_active == 1 and (getprop("/ECAM/ap1-off-time") + 9 < getprop("/sim/time/elapsed-sec"))) { + ap1_active = 0; + } + + if (ap2_active == 1 and (getprop("/ECAM/ap2-off-time") + 9 < getprop("/sim/time/elapsed-sec"))) { + ap2_active = 0; + } + + if (athr_active == 1 and (getprop("/ECAM/athr-off-time") + 9 < getprop("/sim/time/elapsed-sec"))) { + athr_active = 0; + } + # Warning Phases if (getprop("/systems/electrical/bus/ac1") < 110 and getprop("/systems/electrical/bus/ac2") < 110 and getprop("/systems/electrical/bus/ac-ess") < 110) { # Reset warning phases if (getprop("/ECAM/warning-phase") != 1) { @@ -411,3 +433,26 @@ var LowerECAM = { setprop("/ECAM/Lower/light/wheel", 0); }, }; + +# Logic for autopilot disconnect warning + +setlistener("/it-autoflight/input/ap1", func { + if (getprop("/it-autoflight/input/ap1") == 0) { + ap1_active = 1; + setprop("/ECAM/ap1-off-time", getprop("/sim/time/elapsed-sec")); + } +}, 0, 0); + +setlistener("/it-autoflight/input/ap2", func { + if (getprop("/it-autoflight/input/ap2") == 0) { + ap2_active = 1; + setprop("/ECAM/ap2-off-time", getprop("/sim/time/elapsed-sec")); + } +}, 0, 0); + +setlistener("/it-autoflight/input/athr", func { + if (getprop("/it-autoflight/input/athr") == 0) { + athr_active = 1; + setprop("/ECAM/athr-off-time", getprop("/sim/time/elapsed-sec")); + } +}, 0, 0); \ No newline at end of file diff --git a/Nasal/FMGC-b.nas b/Nasal/FMGC-b.nas index 5b0fb82d..467d698d 100644 --- a/Nasal/FMGC-b.nas +++ b/Nasal/FMGC-b.nas @@ -170,9 +170,15 @@ setlistener("/it-autoflight/input/athr", func { var atmas = getprop("/it-autoflight/input/athr"); if (atmas == 0) { setprop("/it-autoflight/output/athr", 0); + if (getprop("/it-autoflight/sound/enableathrsound") == 1 and getprop("/it-autoflight/output/athr") == 0) { + setprop("/it-autoflight/sound/athrsound", 1); + setprop("/it-autoflight/sound/enableathrsound", 0); + } } else if (atmas == 1) { thrustmode(); setprop("/it-autoflight/output/athr", 1); + setprop("/it-autoflight/sound/athrsound", 0); + setprop("/it-autoflight/sound/enableathrsound", 1); } }); diff --git a/Nasal/libraries.nas b/Nasal/libraries.nas index 8c37f317..0025085f 100644 --- a/Nasal/libraries.nas +++ b/Nasal/libraries.nas @@ -553,7 +553,7 @@ var lightsLoop = maketimer(0.2, func { if (getprop("/controls/lighting/no-smoking-sign") == 0) { setprop("/controls/lighting/no-smoking-sign", 1); } - } elsif (getprop("controls/switches/no-smoking-sign") == 0.5 and getprop("gear/gear[0]/position-norm") != 0) { + } elsif (getprop("controls/switches/no-smoking-sign") == 0.5 and getprop("gear/gear[0]/position-norm") != 0) { # todo: should be when uplocks not engaged if (getprop("/controls/lighting/no-smoking-sign") == 0) { setprop("/controls/lighting/no-smoking-sign", 1); } diff --git a/Sounds/A320-common-sound.xml b/Sounds/A320-common-sound.xml index 2ed50157..6ddaed1c 100644 --- a/Sounds/A320-common-sound.xml +++ b/Sounds/A320-common-sound.xml @@ -840,6 +840,23 @@ + + athroff + /Aircraft/IDG-A32X/Sounds/Cockpit/chime.wav + + + + /it-autoflight/output/athr + 0 + + /it-autoflight/sound/athrsound + + + + 40.0 + + + gear0 in-transit