From ee9b1ba0665db710e300215024406b0e5ded8bd7 Mon Sep 17 00:00:00 2001 From: Jonathan Redpath Date: Sat, 29 Dec 2018 13:17:00 +0000 Subject: [PATCH] thrust locked function --- Nasal/ECAM/ECAM-controller.nas | 31 +++++++++++++++++++++++++++++++ Nasal/buttons.nas | 27 +++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) diff --git a/Nasal/ECAM/ECAM-controller.nas b/Nasal/ECAM/ECAM-controller.nas index ae26ec1c..3e2a4c4c 100644 --- a/Nasal/ECAM/ECAM-controller.nas +++ b/Nasal/ECAM/ECAM-controller.nas @@ -187,6 +187,37 @@ var ECAM_controller = { setprop("/ECAM/warnings/overflow", 0); } }, + reset: func() { + foreach (var w; warnings.vector) { + if (w.active == 1) { + w.active = 0; + } + } + + foreach (var l; leftmemos.vector) { + if (l.active == 1) { + l.active = 0; + } + } + + foreach (var sL; specialLines.vector) { + if (sL.active == 1) { + sL.active = 0; + } + } + + foreach (var sF; secondaryFailures.vector) { + if (sF.active == 1) { + sF.active = 0; + } + } + + foreach (var m; memos.vector) { + if (m.active == 1) { + m.active = 0; + } + } + }, }; var ECAMloopTimer = maketimer(0.2, func { diff --git a/Nasal/buttons.nas b/Nasal/buttons.nas index 2c5b5a3d..910d87c7 100644 --- a/Nasal/buttons.nas +++ b/Nasal/buttons.nas @@ -277,7 +277,12 @@ var apWarn = func(type) { } var athrOff = func(type) { + if (type == "hard") { + lockThr(); + } + setprop("/it-autoflight/input/athr", 0); + athrWarn(type); } @@ -293,3 +298,25 @@ var athrWarn = func(type) { } setprop("/ECAM/warnings/master-caution-light", 1); } + +var lockThr = func() { + state1 = getprop("/systems/thrust/state1"); + state2 = getprop("/systems/thrust/state2"); + if ((state1 == "CL" and state2 == "CL" and getprop("/systems/thrust/eng-out") == 0) or (state1 == "MCT" and state2 == "MCT" and getprop("/systems/thrust/eng-out") == 1)) { + setprop("/systems/thrust/thr-locked", 1); + } + + lockTimer.start(); +} + +var checkLockThr = func() { + state1 = getprop("/systems/thrust/state1"); + state2 = getprop("/systems/thrust/state2"); + if ((state1 != "CL" and state2 != "CL" and getprop("/systems/thrust/eng-out") == 0) or (state1 != "MCT" and state2 != "MCT" and getprop("/systems/thrust/eng-out") == 1)) { + setprop("/systems/thrust/thr-locked", 0); + lockTimer.stop(); + } +} + + +var lockTimer = maketimer(0.02, checkLockThr); \ No newline at end of file