A3XX: FMGC: Rework NAV, LOC, and G/S arm system

This commit is contained in:
Joshua Davidson 2017-12-21 09:14:42 -05:00
parent add0282fa9
commit 9da19e8d03
3 changed files with 55 additions and 31 deletions

View file

@ -237,15 +237,17 @@ var lateral = func {
if (latset == 0) {
alandt.stop();
alandt1.stop();
setprop("/it-autoflight/input/lat-arm", 0);
setprop("/it-autoflight/output/loc-armed", 0);
setprop("/it-autoflight/output/appr-armed", 0);
setprop("/it-autoflight/output/lat", 0);
setprop("/it-autoflight/mode/lat", "HDG");
setprop("/it-autoflight/mode/arm", " ");
} else if (latset == 1) {
if (getprop("/autopilot/route-manager/route/num") > 0 and getprop("/autopilot/route-manager/active") == 1) {
if (getprop("/autopilot/route-manager/route/num") > 0 and getprop("/autopilot/route-manager/active") == 1 and getprop("/position/gear-agl-ft") >= 30) {
alandt.stop();
alandt1.stop();
setprop("/it-autoflight/input/lat-arm", 0);
setprop("/it-autoflight/output/loc-armed", 0);
setprop("/it-autoflight/output/appr-armed", 0);
setprop("/it-autoflight/output/lat", 1);
@ -253,13 +255,20 @@ var lateral = func {
setprop("/it-autoflight/mode/arm", " ");
setprop("/it-autoflight/custom/show-hdg", 0);
} else {
gui.popupTip("Please make sure you have a route set, and that it is Activated!");
setprop("/it-autoflight/input/lat-arm", 1);
setprop("/it-autoflight/mode/arm", "LNV");
}
} else if (latset == 2) {
if (getprop("/instrumentation/nav[0]/in-range") == 1) {
if (getprop("/it-autoflight/output/lat") != 2) {
setprop("/it-autoflight/output/loc-armed", 1);
setprop("/it-autoflight/mode/arm", "LOC");
locdefl = abs(getprop("/instrumentation/nav[0]/heading-needle-deflection-norm"));
if (locdefl < 0.95 and locdefl != 0 and getprop("/instrumentation/nav[0]/signal-quality-norm") > 0.99) {
make_loc_active();
} else {
if (getprop("/it-autoflight/output/lat") != 2) {
setprop("/it-autoflight/input/lat-arm", 0);
setprop("/it-autoflight/output/loc-armed", 1);
setprop("/it-autoflight/mode/arm", "LOC");
}
}
} else {
setprop("/instrumentation/nav[0]/signal-quality-norm", 0);
@ -267,6 +276,7 @@ var lateral = func {
} else if (latset == 3) {
alandt.stop();
alandt1.stop();
setprop("/it-autoflight/input/lat-arm", 0);
setprop("/it-autoflight/output/loc-armed", 0);
setprop("/it-autoflight/output/appr-armed", 0);
var hdg5sec = math.round(getprop("/it-autoflight/internal/heading-5-sec-ahead"));
@ -275,13 +285,16 @@ var lateral = func {
setprop("/it-autoflight/mode/lat", "HDG");
setprop("/it-autoflight/mode/arm", " ");
} else if (latset == 4) {
setprop("/it-autoflight/input/lat-arm", 0);
setprop("/it-autoflight/output/lat", 4);
setprop("/it-autoflight/mode/lat", "ALGN");
setprop("/it-autoflight/custom/show-hdg", 0);
} else if (latset == 5) {
setprop("/it-autoflight/input/lat-arm", 0);
setprop("/it-autoflight/output/lat", 5);
setprop("/it-autoflight/custom/show-hdg", 0);
} else if (latset == 9) {
setprop("/it-autoflight/input/lat-arm", 0);
setprop("/it-autoflight/output/loc-armed", 0);
setprop("/it-autoflight/output/lat", 9);
setprop("/it-autoflight/mode/lat", " ");
@ -297,13 +310,8 @@ var lat_arm = func {
setprop("/it-autoflight/mode/arm", " ");
setprop("/it-autoflight/custom/show-hdg", 1);
} else if (latset == 1) {
if (getprop("/autopilot/route-manager/route/num") > 0 and getprop("/autopilot/route-manager/active") == 1) {
setprop("/it-autoflight/input/lat-arm", 1);
setprop("/it-autoflight/mode/arm", "LNV");
setprop("/it-autoflight/custom/show-hdg", 0);
} else {
gui.popupTip("Please make sure you have a route set, and that it is Activated!");
}
setprop("/it-autoflight/input/lat-arm", 1);
setprop("/it-autoflight/mode/arm", "LNV");
} else if (latset == 3) {
if (getprop("/it-autoflight/custom/trk-fpa") == 1) {
var hdgnow = math.round(getprop("/it-autoflight/internal/track-deg"));
@ -365,12 +373,23 @@ var vertical = func {
thrustmode();
} else if (vertset == 2) {
if (getprop("/instrumentation/nav[0]/in-range") == 1) {
if (getprop("/it-autoflight/output/lat") != 2) {
setprop("/it-autoflight/output/loc-armed", 1);
locdefl = abs(getprop("/instrumentation/nav[0]/heading-needle-deflection-norm"));
if (locdefl < 0.95 and locdefl != 0 and getprop("/instrumentation/nav[0]/signal-quality-norm") > 0.99) {
make_loc_active();
} else {
if (getprop("/it-autoflight/output/lat") != 2) {
setprop("/it-autoflight/input/lat-arm", 0);
setprop("/it-autoflight/output/loc-armed", 1);
}
}
if (getprop("/it-autoflight/output/vert") != 2 and getprop("/it-autoflight/output/vert") != 6) {
setprop("/it-autoflight/output/appr-armed", 1);
setprop("/it-autoflight/mode/arm", "ILS");
signal = getprop("/instrumentation/nav[0]/gs-needle-deflection-norm");
if (((signal < 0 and signal >= -0.20) or (signal > 0 and signal <= 0.20)) and getprop("/it-autoflight/output/lat") == 2) {
make_appr_active();
} else {
if (getprop("/it-autoflight/output/vert") != 2 and getprop("/it-autoflight/output/vert") != 6) {
setprop("/it-autoflight/output/appr-armed", 1);
setprop("/it-autoflight/mode/arm", "ILS");
}
}
} else {
setprop("/instrumentation/nav[0]/signal-quality-norm", 0);
@ -656,7 +675,7 @@ setlistener("/it-autoflight/input/kts-mach", func {
# Takeoff Modes
# Lat Active
var latarms = func {
if (getprop("/position/gear-agl-ft") >= 30) {
if () {
if (getprop("/it-autoflight/input/lat-arm") == 1) {
setprop("/it-autoflight/input/lat", getprop("/it-autoflight/input/lat-arm"));
setprop("/it-autoflight/input/lat-arm", 0);
@ -700,15 +719,6 @@ setlistener("/it-autoflight/mode/vert", func {
}
});
setlistener("/it-autoflight/mode/lat", func {
var vertm = getprop("/it-autoflight/mode/lat");
if (vertm == "T/O" or vertm == " ") {
latarmt.start();
} else {
latarmt.stop();
}
});
var toga_reduc = func {
if (getprop("/instrumentation/altimeter/indicated-altitude-ft") >= getprop("/it-autoflight/settings/reduc-agl-ft") and getprop("/gear/gear[1]/wow") == 0 and getprop("/gear/gear[2]/wow") == 0) {
setprop("/it-autoflight/input/vert", 4);
@ -848,6 +858,10 @@ var thrustmode = func {
# ILS and Autoland
# LOC and G/S arming
setlistener("/it-autoflight/input/lat-arm", func {
check_arms();
});
setlistener("/it-autoflight/output/loc-armed", func {
check_arms();
});
@ -857,7 +871,7 @@ setlistener("/it-autoflight/output/appr-armed", func {
});
var check_arms = func {
if (getprop("/it-autoflight/output/loc-armed") or getprop("/it-autoflight/output/appr-armed")) {
if (getprop("/it-autoflight/input/lat-arm") or getprop("/it-autoflight/output/loc-armed") or getprop("/it-autoflight/output/appr-armed")) {
update_armst.start();
} else {
update_armst.stop();
@ -865,6 +879,17 @@ var check_arms = func {
}
var update_arms = func {
if (getprop("/it-autoflight/input/lat-arm") == 1 and getprop("/autopilot/route-manager/route/num") > 0 and getprop("/autopilot/route-manager/active") == 1 and getprop("/position/gear-agl-ft") >= 30) {
alandt.stop();
alandt1.stop();
setprop("/it-autoflight/input/lat-arm", 0);
setprop("/it-autoflight/output/loc-armed", 0);
setprop("/it-autoflight/output/appr-armed", 0);
setprop("/it-autoflight/output/lat", 1);
setprop("/it-autoflight/mode/lat", "LNAV");
setprop("/it-autoflight/mode/arm", " ");
setprop("/it-autoflight/custom/show-hdg", 0);
}
if (getprop("/instrumentation/nav[0]/in-range") == 1) {
if (getprop("/it-autoflight/output/loc-armed")) {
locdefl = abs(getprop("/instrumentation/nav[0]/heading-needle-deflection-norm"));
@ -1278,7 +1303,6 @@ var minmaxtimer = maketimer(0.5, minmax);
var alandt = maketimer(0.5, aland);
var alandt1 = maketimer(0.5, aland1);
var reduct = maketimer(0.5, toga_reduc);
var latarmt = maketimer(0.5, latarms);
var fpa_calct = maketimer(0.1, fpa_calc);
var ap_varioust = maketimer(1, ap_various);
var mng_maint = maketimer(0.5, mng_main);

View file

@ -647,7 +647,7 @@
</input>
<output>/controls/flight/elevator-trim</output>
<min>-1.0</min>
<max>0.32</max>
<max>0.14</max>
<max-rate-of-change>0.01</max-rate-of-change>
</filter>

View file

@ -1 +1 @@
4105
4106