From 0d546f53849dcbf6bb2f389224709b74c2f786c4 Mon Sep 17 00:00:00 2001 From: James Turner Date: Thu, 17 Dec 2020 10:26:00 +0000 Subject: [PATCH] KAP140: improve locking to GS/LOC signals Patch from Benedkit Hallinger: This patch introduces a check for valid VOR/LOC as well as GS signals, and only if they are valid they will be catched. See: https://sourceforge.net/p/flightgear/codetickets/2476/ --- Aircraft/Generic/kap140.nas | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/Aircraft/Generic/kap140.nas b/Aircraft/Generic/kap140.nas index 75ac1770e..8bb617cec 100644 --- a/Aircraft/Generic/kap140.nas +++ b/Aircraft/Generic/kap140.nas @@ -94,6 +94,8 @@ var propFlightControls = props.globals.getNode(flightControls, 0); var elevatorControl = propFlightControls.getNode("elevator", 0); var elevatorTrimControl = propFlightControls.getNode("elevator-trim", 0); +var navHeadingValid = "/instrumentation/nav/in-range"; +var navGSValid = "/instrumentation/nav/gs-in-range"; var headingNeedleDeflection = "/instrumentation/nav/heading-needle-deflection"; var gsNeedleDeflection = "/instrumentation/nav/gs-needle-deflection-norm"; var staticPressure = "systems/static/pressure-inhg"; @@ -704,10 +706,11 @@ var navArmFromRol = func lockRollAxis.setBoolValue(1); settingTargetTurnRate.setDoubleValue(0.0); var deviation = getprop(headingNeedleDeflection); + var deviationValid = getprop(navHeadingValid); ## # If the deflection is more than 3 degrees wait 5 seconds and check again. ## - if (abs(deviation) > 3.0) + if (!deviationValid or abs(deviation) > 3.0) { #print("deviation"); settimer(navArmFromRol, 5); @@ -806,10 +809,11 @@ var aprArmFromHdg = func ## lockAprHold.setBoolValue(1); var deviation = getprop(headingNeedleDeflection); + var deviationValid = getprop(navHeadingValid); ## # If the deflection is more than 3 degrees wait 5 seconds and check again. ## - if (abs(deviation) > 3.0) + if (!deviationValid or abs(deviation) > 3.0) { #print("deviation"); settimer(aprArmFromHdg, 5); @@ -862,10 +866,11 @@ var aprArmFromRol = func lockRollAxis.setBoolValue(1); settingTargetTurnRate.setDoubleValue(0.0); var deviation = getprop(headingNeedleDeflection); + var deviationValid = getprop(navHeadingValid); ## # If the deflection is more than 3 degrees wait 5 seconds and check again. ## - if (abs(deviation) > 3.0) + if (!deviationValid or abs(deviation) > 3.0) { #print("deviation"); settimer(aprArmFromRol, 5); @@ -911,10 +916,11 @@ var gsArm = func { annunciatorGsArm.setBoolValue(1); var deviation = getprop(gsNeedleDeflection); + var deviationValid = getprop(navGSValid); ## # If the deflection is more than 50% (manual says '2 to 3 dots') ## - if (abs(deviation) > 0.5) + if (!deviationValid or abs(deviation) > 0.5) { #print("deviation"); settimer(gsArm, 5); @@ -1012,10 +1018,11 @@ var revArmFromHdg = func ## lockRevHold.setBoolValue(1); var deviation = getprop(headingNeedleDeflection); + var deviationValid = getprop(navHeadingValid); ## # If the deflection is more than 3 degrees wait 5 seconds and check again. ## - if (abs(deviation) > 3.0) + if (!deviationValid or abs(deviation) > 3.0) { #print("deviation"); settimer(revArmFromHdg, 5); @@ -1078,10 +1085,11 @@ var revArmFromRol = func lockRollAxis.setBoolValue(1); settingTargetTurnRate.setDoubleValue(0.0); var deviation = getprop(headingNeedleDeflection); + var deviationValid = getprop(navHeadingValid); ## # If the deflection is more than 3 degrees wait 5 seconds and check again. ## - if (abs(deviation) > 3.0) + if (!deviationValid or abs(deviation) > 3.0) { #print("deviation"); settimer(revArmFromRol, 5);