From e94861b94acbaba36b9a55423ec25e52196d19c0 Mon Sep 17 00:00:00 2001 From: Jonathan Redpath Date: Fri, 28 Dec 2018 12:40:12 +0000 Subject: [PATCH] Refactor autopilot off warnings --- A320-main.xml | 9 +------ Models/FlightDeck/a320.flightdeck.xml | 38 +++++++++++++-------------- Nasal/ECAM.nas | 6 ++--- Nasal/buttons.nas | 33 ++++++++++++++++------- Nasal/fadec-common.nas | 5 ++-- Nasal/it-fbw.nas | 6 ----- gui/dialogs/a3xx-autoflight-dlg.xml | 4 +-- 7 files changed, 51 insertions(+), 50 deletions(-) diff --git a/A320-main.xml b/A320-main.xml index a56d66f3..be7548fd 100644 --- a/A320-main.xml +++ b/A320-main.xml @@ -1065,7 +1065,6 @@ nasal nasal - @@ -4081,19 +4080,18 @@ false - - property-toggle - it-autoflight/input/ap2 - nasal nasal - @@ -4121,17 +4119,19 @@ false - - property-toggle - it-autoflight/input/athr - nasal nasal - + diff --git a/Nasal/ECAM.nas b/Nasal/ECAM.nas index 0b0d5138..342b901d 100644 --- a/Nasal/ECAM.nas +++ b/Nasal/ECAM.nas @@ -157,10 +157,10 @@ var ECAM = { if (stateL == 3 and stateR == 3 and getprop("/ECAM/engine-start-time") + 120 < getprop("/sim/time/elapsed-sec") and getprop("/ECAM/to-memo-enable") == 1 and wow == 1) { setprop("/ECAM/left-msg", "TO-MEMO"); - } else if (getprop("/ECAM/ldg-memo-enable") == 1) { + } elsif (getprop("/ECAM/ldg-memo-enable") == 1) { setprop("/ECAM/left-msg", "LDG-MEMO"); - } else if (getprop("/ECAM/show-left-msg") == 1) { - setprop("/ECAM/left-msg", "MSG"); + } elsif (getprop("/ECAM/show-left-msg") == 1) { + setprop("/ECAM/left-msg", "MSG"); # messages should have priority over memos - how? } else { setprop("/ECAM/left-msg", "NONE"); } diff --git a/Nasal/buttons.nas b/Nasal/buttons.nas index 123ba2d4..2c5b5a3d 100644 --- a/Nasal/buttons.nas +++ b/Nasal/buttons.nas @@ -251,27 +251,40 @@ var decreaseManVS = func { } var apOff = func(type, side) { - if ((side == 1 and getprop("/it-autoflight/output/ap1") == 1) or (side == 2 and getprop("/it-autoflight/output/ap2") == 1)) { - setprop("/it-autoflight/output/ap-warning", 0); - return; + if (side == 0) { + setprop("/it-autoflight/input/ap1", 0); + setprop("/it-autoflight/input/ap2", 0); + } elsif (side == 1) { + setprop("/it-autoflight/input/ap1", 0); + } elsif (side == 2) { + setprop("/it-autoflight/input/ap2", 0); } - - if (type == "soft") { + apWarn(type); +} + +var apWarn = func(type) { + if (type == "none") { + return; + } elsif (type == "soft") { setprop("/ECAM/ap-off-time", getprop("/sim/time/elapsed-sec")); setprop("/it-autoflight/output/ap-warning", 1); setprop("/ECAM/warnings/master-warning-light", 1); } else { setprop("/it-autoflight/output/ap-warning", 2); + # master warning handled by warning system in this case libraries.LowerECAM.clrLight(); } } var athrOff = func(type) { - if (getprop("it-autoflight/output/athr") == 1) { - setprop("/it-autoflight/output/athr-warning", 0); - return; - } - if (type == "soft") { + setprop("/it-autoflight/input/athr", 0); + athrWarn(type); +} + +var athrWarn = func(type) { + if (type == "none") { + return; + } elsif (type == "soft") { setprop("/ECAM/athr-off-time", getprop("/sim/time/elapsed-sec")); setprop("/it-autoflight/output/athr-warning", 1); } else { diff --git a/Nasal/fadec-common.nas b/Nasal/fadec-common.nas index 5babe983..e722b93c 100644 --- a/Nasal/fadec-common.nas +++ b/Nasal/fadec-common.nas @@ -194,10 +194,11 @@ var atoff_request = func { state1 = getprop("/systems/thrust/state1"); state2 = getprop("/systems/thrust/state2"); if ((state1 == "IDLE") and (state2 == "IDLE") and (getprop("/systems/thrust/alpha-floor") == 0) and (getprop("/systems/thrust/toga-lk") == 0)) { - if (getprop("/it-autoflight/output/athr") == 1 and getprop("/position/gear-agl-ft") > 50) { + if (getprop("/it-autoflight/input/athr") == 1 and getprop("/position/gear-agl-ft") > 50) { libraries.athrOff("soft"); + } elsif (getprop("/position/gear-agl-ft") < 50) { + libraries.athrOff("none"); } - setprop("/it-autoflight/input/athr", 0); } } diff --git a/Nasal/it-fbw.nas b/Nasal/it-fbw.nas index d964fbf5..61464975 100644 --- a/Nasal/it-fbw.nas +++ b/Nasal/it-fbw.nas @@ -208,12 +208,6 @@ var update_loop = func { if (getprop("/it-fbw/protections/overspeed") != 1) { setprop("/it-fbw/protections/overspeed", 1); } - if (getprop("/it-autoflight/output/ap1") == 1) { - setprop("/it-autoflight/input/ap1", 0); - } - if (getprop("/it-autoflight/output/ap2") == 1) { - setprop("/it-autoflight/input/ap2", 0); - } libraries.apOff("hard", 0); } else { if (getprop("/it-fbw/protections/overspeed") != 0) { diff --git a/gui/dialogs/a3xx-autoflight-dlg.xml b/gui/dialogs/a3xx-autoflight-dlg.xml index 6b9780a3..30fa6bd1 100644 --- a/gui/dialogs/a3xx-autoflight-dlg.xml +++ b/gui/dialogs/a3xx-autoflight-dlg.xml @@ -54,7 +54,7 @@ nasal - +