From 859bc8febca13b823c3b6f2e5948530f9a6f863a Mon Sep 17 00:00:00 2001 From: legoboyvdlp R Date: Sat, 16 Mar 2019 10:43:52 +0000 Subject: [PATCH] Thrust Lock logic improve --- Models/FlightDeck/a320.flightdeck.xml | 6 ++-- Nasal/ECAM/ECAM-controller.nas | 34 +++++++++++--------- Nasal/ECAM/ECAM-logic.nas | 9 +++++- Nasal/FMGC-b.nas | 2 ++ Nasal/buttons.nas | 45 ++++++++++++++++++++++----- Nasal/fadec-common.nas | 2 ++ 6 files changed, 72 insertions(+), 26 deletions(-) diff --git a/Models/FlightDeck/a320.flightdeck.xml b/Models/FlightDeck/a320.flightdeck.xml index f0a557ce..d3995d15 100644 --- a/Models/FlightDeck/a320.flightdeck.xml +++ b/Models/FlightDeck/a320.flightdeck.xml @@ -5030,9 +5030,9 @@ setprop("/it-autoflight/output/athr-warning", 0); } - if (getprop("/sim/sound/warnings/chime") == 1) { - setprop("/sim/sound/warnings/chime", 0); - } + # if (getprop("/sim/sound/warnings/chime") == 1) { + # setprop("/sim/sound/warnings/chime", 0); + #} diff --git a/Nasal/ECAM/ECAM-controller.nas b/Nasal/ECAM/ECAM-controller.nas index c1b0dcb2..5e3dcc22 100644 --- a/Nasal/ECAM/ECAM-controller.nas +++ b/Nasal/ECAM/ECAM-controller.nas @@ -25,6 +25,8 @@ var lineIndex = 0; var rightLineIndex = 0; var statusIndex = 0; +var flash = 0; + var warning = { new: func(msg,colour = "g",aural = 9,light = 9,hasSubmsg = 0,lastSubmsg = 0) { var t = {parents:[warning]}; @@ -60,19 +62,15 @@ var warning = { } }, warnlight: func() { - if (me.light >= 1) {return;} - if (me.active == 1 and me.noRepeat == 0) { # only toggle light once per message, allows canceling - lights[me.light].setBoolValue(1); - me.noRepeat = 1; - } + if (me.light >= 1 or me.noRepeat == 1 or me.active == 0) {return;} + lights[me.light].setBoolValue(1); + me.noRepeat = 1; }, sound: func() { - if (me.aural > 1) {return;} - if (me.active == 1) { - if (!aural[me.aural].getBoolValue()) { - aural[me.aural].setBoolValue(1); - } - } + if (me.aural > 1 or me.active == 0) {return;} + #if (!aural[me.aural].getBoolValue()) { + aural[me.aural].setBoolValue(1); + #} }, }; @@ -161,11 +159,19 @@ var ECAM_controller = { foreach (var w; warnings.vector) { w.write(); - w.warnlight(); - w.sound(); } - if (lines[0].getValue() == "") { # disable left memos if a warning exists. Warnings are processed first, so this stops leftmemos if line1 is not empty + foreach (var w2; warnings.vector) { + if (w2.active == 1) { + if (w2.noRepeat == 0) { + w2.warnlight(); + } + w2.sound(); + break + } + } + + if (lines[0].getValue() == "" and flash == 0) { # disable left memos if a warning exists. Warnings are processed first, so this stops leftmemos if line1 is not empty foreach (var l; leftmemos.vector) { l.write(); } diff --git a/Nasal/ECAM/ECAM-logic.nas b/Nasal/ECAM/ECAM-logic.nas index fdff396f..38358604 100644 --- a/Nasal/ECAM/ECAM-logic.nas +++ b/Nasal/ECAM/ECAM-logic.nas @@ -19,6 +19,7 @@ var wowNode = props.globals.getNode("/fdm/jsbsim/position/wow", 1); # local variables var phaseVar = nil; var dualFailFACActive = 1; +var flash = 0; var messages_priority_3 = func { phaseVar = phaseNode.getValue(); @@ -226,7 +227,7 @@ var messages_priority_3 = func { ap_offw.noRepeat = 0; } - if ((athr_lock.clearFlag == 0) and phaseVar >= 5 and phaseVar <= 7 and getprop("/systems/thrust/thr-locked") == 1) { + if ((athr_lock.clearFlag == 0) and phaseVar >= 5 and phaseVar <= 7 and getprop("/systems/thrust/thr-locked-alert") == 1) { athr_lock.active = 1; athr_lock_1.active = 1; } else { @@ -236,6 +237,12 @@ var messages_priority_3 = func { athr_lock_1.noRepeat = 0; } + if (getprop("/systems/thrust/thr-locked") == 1) { + flash = 1; + } else { + flash = 0; + } + if ((athr_offw.clearFlag == 0) and athrWarn.getValue() == 2 and phaseVar != 4 and phaseVar != 8 and phaseVar != 10) { athr_offw.active = 1; athr_offw_1.active = 1; diff --git a/Nasal/FMGC-b.nas b/Nasal/FMGC-b.nas index e3168011..05d33624 100644 --- a/Nasal/FMGC-b.nas +++ b/Nasal/FMGC-b.nas @@ -180,6 +180,7 @@ var Custom = { athrOff: props.globals.initNode("/it-autoflight/sound/athrsound", 0, "BOOL"), enableAthrOff: 0, }, + ThrLock: props.globals.getNode("/systems/thrust/thr-locked", 1) }; var ITAF = { @@ -492,6 +493,7 @@ var ITAF = { if (s == 1) { if (Misc.acEss.getValue() >= 110) { Output.athr.setBoolValue(1); + Custom.ThrLock.setValue(0); Custom.Sound.enableAthrOff = 1; Custom.Sound.athrOff.setBoolValue(0); } diff --git a/Nasal/buttons.nas b/Nasal/buttons.nas index 89119ef0..fe962e71 100644 --- a/Nasal/buttons.nas +++ b/Nasal/buttons.nas @@ -635,23 +635,52 @@ var athrWarn = func(type) { } 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); - } - + setprop("/systems/thrust/thr-lock-time", getprop("/sim/time/elapsed-sec")); + setprop("/systems/thrust/thr-locked", 1); lockTimer.start(); } var checkLockThr = func() { + if (getprop("/systems/thrust/thr-lock-time") + 5 > getprop("/sim/time/elapsed-sec")) { return; } + + if (getprop("/systems/thrust/thr-locked") == 0) { + setprop("/systems/thrust/thr-locked-alert", 0); + setprop("/systems/thrust/thr-lock-time", 0); + lockTimer.stop(); + } + + 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-alert", 1); + setprop("/systems/thrust/thr-lock-time", getprop("/sim/time/elapsed-sec")); + lockTimer.stop(); + lockTimer2.start(); + } +} + +var checkLockThr2 = func() { + if (getprop("/systems/thrust/thr-lock-time") + 5 < getprop("/sim/time/elapsed-sec")) { + setprop("/systems/thrust/thr-locked-alert", 0); + settimer(func() { + setprop("/systems/thrust/thr-locked-alert", 1); + setprop("/systems/thrust/thr-lock-time", getprop("/sim/time/elapsed-sec")); + print(ecam.athr_lock.noRepeat); + ecam.athr_lock.noRepeat = 0; + print(ecam.athr_lock.noRepeat); + }, 0.2); + } + 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(); + setprop("/systems/thrust/thr-locked-alert", 0); + lockTimer2.stop(); } } -var lockTimer = maketimer(0.02, checkLockThr); \ No newline at end of file +var lockTimer = maketimer(0.02, checkLockThr); +var lockTimer2 = maketimer(0.02, checkLockThr2); \ No newline at end of file diff --git a/Nasal/fadec-common.nas b/Nasal/fadec-common.nas index 9cb08221..01562c73 100644 --- a/Nasal/fadec-common.nas +++ b/Nasal/fadec-common.nas @@ -52,6 +52,8 @@ setprop("/systems/thrust/lim-flex", 0); setprop("/engines/flex-derate", 0); setprop("/systems/thrust/eng-out", 0); setprop("/systems/thrust/thr-locked", 0); +setprop("/systems/thrust/thr-locked-alert", 0); +setprop("/systems/thrust/thr-lock-time", 0); setprop("/systems/thrust/thr-lock-cmd[0]", 0); setprop("/systems/thrust/thr-lock-cmd[1]", 0);