From ba51c852f595f1a5ec6716c8a042d673869bbd0f Mon Sep 17 00:00:00 2001 From: legoboyvdlp R Date: Wed, 1 Jan 2020 21:49:44 +0000 Subject: [PATCH] Add timer to elec to wait a short time before tripping autopilot if there is a failure, to account for transient failures --- Nasal/ECAM/ECAM-controller.nas | 1 + Nasal/Systems/electrical.nas | 34 ++++++++++++++++++++++++---------- 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/Nasal/ECAM/ECAM-controller.nas b/Nasal/ECAM/ECAM-controller.nas index 0cb83edb..04e42e0b 100644 --- a/Nasal/ECAM/ECAM-controller.nas +++ b/Nasal/ECAM/ECAM-controller.nas @@ -349,6 +349,7 @@ var ECAM_controller = { warning.active = 0; warning.noRepeat = 0; warning.noRepeat2 = 0; + # don't set .wasActive to 0, warnlight / sound funcs do that }, }; diff --git a/Nasal/Systems/electrical.nas b/Nasal/Systems/electrical.nas index d83fe6ed..fd175ebb 100644 --- a/Nasal/Systems/electrical.nas +++ b/Nasal/Systems/electrical.nas @@ -13,6 +13,8 @@ var dc2 = 0; # Main class var ELEC = { + _timer1On: 0, + _timer2On: 0, Bus: { acEss: props.globals.getNode("/systems/electrical/bus/ac-ess"), acEssShed: props.globals.getNode("/systems/electrical/bus/ac-ess-shed"), @@ -227,20 +229,32 @@ var ELEC = { # Autopilot Disconnection routines if (me.Bus.dcEssShed.getValue() < 25) { - if (getprop("/it-autoflight/output/ap1") == 1) { - fcu.apOff("hard", 1); - if (fcu.FCUController.activeFMGC.getValue() == 1) { - fcu.athrOff("hard"); - } + if (getprop("/it-autoflight/output/ap1") == 1 and !me._timer1On) { + me._timer1On = 1; + settimer(func() { + if (me.Bus.dcEssShed.getValue() < 25) { + fcu.apOff("hard", 1); + if (fcu.FCUController.activeFMGC.getValue() == 1) { + fcu.athrOff("hard"); + } + } + me._timer1On = 0; + }, 0.1); } } if (me.Bus.dc2.getValue() < 25) { - if (getprop("/it-autoflight/output/ap2") == 1) { - fcu.apOff("hard", 2); - if (fcu.FCUController.activeFMGC.getValue() == 2) { - fcu.athrOff("hard"); - } + if (getprop("/it-autoflight/output/ap2") == 1 and !me._timer2On) { + me._timer2On = 1; + settimer(func() { + if (me.Bus.dc2.getValue() < 25) { + fcu.apOff("hard", 2); + if (fcu.FCUController.activeFMGC.getValue() == 2) { + fcu.athrOff("hard"); + } + } + me._timer2On = 0; + }, 0.1); } } },