diff --git a/Nasal/FMGC/FCU.nas b/Nasal/FMGC/FCU.nas
index 0e03b355..000bce55 100644
--- a/Nasal/FMGC/FCU.nas
+++ b/Nasal/FMGC/FCU.nas
@@ -512,7 +512,7 @@ var apOff = func(type, side) {
var athrOff = func(type) {
if (athrInput.getValue() == 1) {
if (type == "hard") {
- fadec.lockThr();
+ systems.lockThr();
}
athrInput.setValue(0);
ecam.doAthrWarn(type);
diff --git a/Nasal/Systems/fadec-common.nas b/Nasal/Systems/fadec-common.nas
index 4a5f83d5..cded9429 100644
--- a/Nasal/Systems/fadec-common.nas
+++ b/Nasal/Systems/fadec-common.nas
@@ -30,7 +30,6 @@ var FADEC = {
Lock: {
thrLockAlert: props.globals.getNode("/fdm/jsbsim/fadec/thr-locked-alert"),
thrLockCmd: props.globals.getNode("/fdm/jsbsim/fadec/thr-locked"),
- thrLockCmdN1: [props.globals.getNode("/fdm/jsbsim/fadec/thr-lock-cmd[0]"), props.globals.getNode("/fdm/jsbsim/fadec/thr-lock-cmd[1]")],
thrLockFlash: props.globals.getNode("/fdm/jsbsim/fadec/thr-locked-flash"),
thrLockTime: props.globals.getNode("/fdm/jsbsim/fadec/thr-locked-time"),
},
@@ -187,3 +186,96 @@ setlistener("/fdm/jsbsim/fadec/control-2/detent", func() {
setlistener("/fdm/jsbsim/fadec/limit/active-mode-int", func() {
FADEC.updateTxt();
}, 0, 0);
+
+var lockThr = func() {
+ state1 = systems.FADEC.detentText[0].getValue();
+ state2 = systems.FADEC.detentText[1].getValue();
+ if ((state1 == "CL" and state2 == "CL" and !systems.FADEC.engOut.getValue()) or (state1 == "MCT" and state2 == "MCT" and systems.FADEC.engOut.getValue())) {
+ FADEC.Lock.thrLockTime.setValue(pts.Sim.Time.elapsedSec.getValue());
+ FADEC.Lock.thrLockCmd.setValue(1);
+ lockTimer.start();
+ }
+}
+
+var checkLockThr = func() {
+ if (FADEC.Lock.thrLockTime.getValue() + 5 > pts.Sim.Time.elapsedSec.getValue()) { return; }
+
+ if (fmgc.Output.athr.getBoolValue()) {
+ lockTimer.stop();
+ FADEC.Lock.thrLockCmd.setValue(0);
+ FADEC.Lock.thrLockAlert.setValue(0);
+ FADEC.Lock.thrLockTime.setValue(0);
+ FADEC.Lock.thrLockFlash.setValue(0);
+ return;
+ }
+
+ if (!FADEC.Lock.thrLockCmd.getValue()) {
+ lockTimer.stop();
+ FADEC.Lock.thrLockCmd.setValue(0);
+ FADEC.Lock.thrLockAlert.setValue(0);
+ FADEC.Lock.thrLockTime.setValue(0);
+ FADEC.Lock.thrLockFlash.setValue(0);
+ return;
+ }
+
+ state1 = systems.FADEC.detentText[0].getValue();
+ state2 = systems.FADEC.detentText[1].getValue();
+
+ if ((state1 != "CL" and state2 != "CL" and !systems.FADEC.engOut.getValue()) or (state1 != "MCT" and state2 != "MCT" and systems.FADEC.engOut.getValue())) {
+ lockTimer.stop();
+ FADEC.Lock.thrLockCmd.setValue(0);
+ FADEC.Lock.thrLockAlert.setValue(0);
+ FADEC.Lock.thrLockTime.setValue(0);
+ FADEC.Lock.thrLockFlash.setValue(0);
+ } elsif ((state1 == "CL" and state2 == "CL" and !systems.FADEC.engOut.getValue()) or (state1 == "MCT" and state2 == "MCT" and systems.FADEC.engOut.getValue())) {
+ FADEC.Lock.thrLockAlert.setValue(1);
+ FADEC.Lock.thrLockTime.setValue(pts.Sim.Time.elapsedSec.getValue());
+ FADEC.Lock.thrLockFlash.setValue(1);
+ lockTimer.stop();
+ lockTimer2.start();
+ }
+}
+
+var checkLockThr2 = func() {
+ if (fmgc.Output.athr.getBoolValue()) {
+ lockTimer2.stop();
+ FADEC.Lock.thrLockCmd.setValue(0);
+ FADEC.Lock.thrLockAlert.setValue(0);
+ FADEC.Lock.thrLockTime.setValue(0);
+ FADEC.Lock.thrLockFlash.setValue(0);
+ return;
+ }
+
+ if (!FADEC.Lock.thrLockCmd.getValue()) {
+ lockTimer2.stop();
+ FADEC.Lock.thrLockCmd.setValue(0);
+ FADEC.Lock.thrLockAlert.setValue(0);
+ FADEC.Lock.thrLockTime.setValue(0);
+ FADEC.Lock.thrLockFlash.setValue(0);
+ return;
+ }
+
+ if (FADEC.Lock.thrLockTime.getValue() + 5 < pts.Sim.Time.elapsedSec.getValue()) {
+ FADEC.Lock.thrLockFlash.setValue(0);
+ settimer(func() {
+ FADEC.Lock.thrLockFlash.setValue(1);
+ FADEC.Lock.thrLockTime.setValue(pts.Sim.Time.elapsedSec.getValue());
+ ecam.athr_lock.noRepeat = 0;
+ ecam.athr_lock.noRepeat2 = 0;
+ }, 0.2);
+ }
+
+ state1 = systems.FADEC.detentText[0].getValue();
+ state2 = systems.FADEC.detentText[1].getValue();
+
+ if ((state1 != "CL" and state2 != "CL" and !systems.FADEC.engOut.getValue()) or (state1 != "MCT" and state2 != "MCT" and systems.FADEC.engOut.getValue())) {
+ lockTimer2.stop();
+ FADEC.Lock.thrLockCmd.setValue(0);
+ FADEC.Lock.thrLockAlert.setValue(0);
+ FADEC.Lock.thrLockFlash.setValue(0);
+ FADEC.Lock.thrLockTime.setValue(0);
+ }
+}
+
+var lockTimer = maketimer(0.1, checkLockThr);
+var lockTimer2 = maketimer(0.1, checkLockThr2);
diff --git a/Systems/a320-cfm56-5b4-engine-fadec.xml b/Systems/a320-cfm56-5b4-engine-fadec.xml
index b23585b2..15fbd616 100644
--- a/Systems/a320-cfm56-5b4-engine-fadec.xml
+++ b/Systems/a320-cfm56-5b4-engine-fadec.xml
@@ -1152,6 +1152,9 @@
fadec/reverse-1/position-norm ne 0
+
+ fadec/thr-locked eq 1
+
fadec/athr/active eq 1
@@ -1180,6 +1183,9 @@
fadec/reverse-2/position-norm ne 0
+
+ fadec/thr-locked eq 1
+
fadec/athr/active eq 1