A3XX: Overhaul LOC G/S system, more improvements

This commit is contained in:
Joshua Davidson 2017-07-12 17:31:04 -04:00
parent a046abcd3a
commit d91e34e613
2 changed files with 56 additions and 64 deletions

View file

@ -5,6 +5,13 @@
# IT-AUTOFLIGHT Based Autopilot # # IT-AUTOFLIGHT Based Autopilot #
################################# #################################
setlistener("/sim/signals/fdm-initialized", func {
var trueSpeedKts = getprop("/instrumentation/airspeed-indicator/true-speed-kt");
var locdefl = getprop("/instrumentation/nav[0]/heading-needle-deflection-norm");
var locdefl_b = getprop("/instrumentation/nav[1]/heading-needle-deflection-norm");
var signal = getprop("/instrumentation/nav[0]/gs-needle-deflection-norm");
});
var APinit = func { var APinit = func {
setprop("/instrumentation/efis[0]/mfd/true-north", 0); setprop("/instrumentation/efis[0]/mfd/true-north", 0);
setprop("/instrumentation/efis[1]/mfd/true-north", 0); setprop("/instrumentation/efis[1]/mfd/true-north", 0);
@ -56,8 +63,7 @@ var APinit = func {
setprop("/it-autoflight/input/spd-kts", 100); setprop("/it-autoflight/input/spd-kts", 100);
setprop("/it-autoflight/input/spd-mach", 0.50); setprop("/it-autoflight/input/spd-mach", 0.50);
setprop("/it-autoflight/custom/show-hdg", 0); setprop("/it-autoflight/custom/show-hdg", 0);
update_armst.start(); ap_varioust.start();
lnavwptt.start();
thrustmode(); thrustmode();
} }
@ -425,12 +431,20 @@ var toggle_trkfpa = func {
} }
} }
var lnavwpt = func { var ap_various = func {
trueSpeedKts = getprop("/instrumentation/airspeed-indicator/true-speed-kt");
if (trueSpeedKts > 420) {
setprop("/it-autoflight/internal/bank-limit", 15);
} else if (trueSpeedKts > 340) {
setprop("/it-autoflight/internal/bank-limit", 20);
} else {
setprop("/it-autoflight/internal/bank-limit", 25);
}
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) {
if (getprop("/autopilot/route-manager/wp/dist") <= 1.0) { if (getprop("/autopilot/route-manager/wp/dist") <= 1.0) {
var wptnum = getprop("/autopilot/route-manager/current-wp"); if ((getprop("/autopilot/route-manager/current-wp") + 1) < getprop("/autopilot/route-manager/route/num")) {
if ((wptnum + 1) < getprop("/autopilot/route-manager/route/num")) { setprop("/autopilot/route-manager/current-wp", getprop("/autopilot/route-manager/current-wp") + 1);
setprop("/autopilot/route-manager/current-wp", wptnum + 1);
} }
} }
} }
@ -663,38 +677,41 @@ var thrustmode = func {
# ILS and Autoland # ILS and Autoland
# LOC and G/S arming # LOC and G/S arming
setlistener("/it-autoflight/output/loc-armed", func {
check_arms();
});
setlistener("/it-autoflight/output/appr-armed", func {
check_arms();
});
var check_arms = func {
if (getprop("/it-autoflight/output/loc-armed") or getprop("/it-autoflight/output/appr-armed")) {
update_armst.start();
} else {
update_armst.stop();
}
}
var update_arms = func { var update_arms = func {
update_locarmelec(); if (getprop("/it-autoflight/output/loc-armed")) {
update_apparmelec(); locdefl = getprop("/instrumentation/nav[0]/heading-needle-deflection-norm");
} locdefl_b = getprop("/instrumentation/nav[1]/heading-needle-deflection-norm");
if ((locdefl < 0.9233) and (getprop("/instrumentation/nav[0]/signal-quality-norm") > 0.99) and (getprop("/FMGC/internal/loc-source") == "NAV0")) {
var update_locarmelec = func { make_loc_active();
var loca = getprop("/it-autoflight/output/loc-armed"); } else if ((locdefl_b < 0.9233) and (getprop("/instrumentation/nav[2]/signal-quality-norm") > 0.99) and (getprop("/FMGC/internal/loc-source") == "VOR0")) {
if (loca) { make_loc_active();
locarmcheck(); } else {
} else { return 0;
return 0; }
} }
} if (getprop("/it-autoflight/output/appr-armed")) {
signal = getprop("/instrumentation/nav[0]/gs-needle-deflection-norm");
var update_apparmelec = func { if (((signal < 0 and signal >= -0.30) or (signal > 0 and signal <= 0.30)) and (getprop("/FMGC/internal/loc-source") == "NAV0") and (getprop("/it-autoflight/output/lat") == 2)) {
var appra = getprop("/it-autoflight/output/appr-armed"); make_appr_active();
if (appra) { } else {
apparmcheck(); return 0;
} else { }
return 0;
}
}
var locarmcheck = func {
var locdefl = getprop("instrumentation/nav[0]/heading-needle-deflection-norm");
var locdefl_b = getprop("instrumentation/nav[1]/heading-needle-deflection-norm");
if ((locdefl < 0.9233) and (getprop("instrumentation/nav[0]/signal-quality-norm") > 0.99) and (getprop("/FMGC/internal/loc-source") == "NAV0")) {
make_loc_active();
} else if ((locdefl_b < 0.9233) and (getprop("instrumentation/nav[1]/signal-quality-norm") > 0.99) and (getprop("/FMGC/internal/loc-source") == "NAV1")) {
make_loc_active();
} else {
return 0;
} }
} }
@ -710,15 +727,6 @@ var make_loc_active = func {
} }
} }
var apparmcheck = func {
var signal = getprop("/instrumentation/nav[0]/gs-needle-deflection-norm");
if (((signal < 0 and signal >= 0.45) or (signal > 0 and signal <= 0.30)) and (getprop("/FMGC/internal/loc-source") == "NAV0") and (getprop("/it-autoflight/output/lat") == 2)) {
make_appr_active();
} else {
return 0;
}
}
var make_appr_active = func { var make_appr_active = func {
mng_sys_stop(); mng_sys_stop();
setprop("/it-autoflight/output/appr-armed", 0); setprop("/it-autoflight/output/appr-armed", 0);
@ -1105,7 +1113,7 @@ var alandt1 = maketimer(0.5, aland1);
var reduct = maketimer(0.5, toga_reduc); var reduct = maketimer(0.5, toga_reduc);
var latarmt = maketimer(0.5, latarms); var latarmt = maketimer(0.5, latarms);
var fpa_calct = maketimer(0.1, fpa_calc); var fpa_calct = maketimer(0.1, fpa_calc);
var lnavwptt = maketimer(1, lnavwpt); var ap_varioust = maketimer(1, ap_various);
var mng_maint = maketimer(0.5, mng_main); var mng_maint = maketimer(0.5, mng_main);
var mng_altcaptt = maketimer(0.5, mng_altcapt); var mng_altcaptt = maketimer(0.5, mng_altcapt);
var mng_minmaxt = maketimer(0.5, mng_minmax); var mng_minmaxt = maketimer(0.5, mng_minmax);

View file

@ -209,33 +209,17 @@ setlistener("/sim/signals/fdm-initialized", func {
}); });
var librariesLoop = maketimer(0.1, func { var librariesLoop = maketimer(0.1, func {
var groundpwr = getprop("/controls/switches/cart"); if ((getprop("/controls/pneumatic/switches/groundair") or getprop("/controls/switches/cart")) and ((getprop("/velocities/groundspeed-kt") > 2) or getprop("controls/gear/brake-parking") == 0)) {
var groundair = getprop("/controls/pneumatic/switches/groundair");
var gs = getprop("/velocities/groundspeed-kt");
var parkbrake = getprop("controls/gear/brake-parking");
if ((groundair or groundpwr) and ((gs > 2) or !parkbrake)) {
setprop("/controls/switches/cart", 0); setprop("/controls/switches/cart", 0);
setprop("/controls/pneumatic/switches/groundair", 0); setprop("/controls/pneumatic/switches/groundair", 0);
} }
var V = getprop("/velocities/groundspeed-kt"); if (getprop("/velocities/groundspeed-kt") > 15) {
if (V > 15) {
setprop("/systems/shake/effect", 1); setprop("/systems/shake/effect", 1);
} else { } else {
setprop("/systems/shake/effect", 0); setprop("/systems/shake/effect", 0);
} }
var trueSpeedKts = getprop("/instrumentation/airspeed-indicator/true-speed-kt");
if(trueSpeedKts > 420) {
setprop("/it-autoflight/internal/bank-limit", 15);
} else if(trueSpeedKts > 340) {
setprop("/it-autoflight/internal/bank-limit", 20);
} else {
setprop("/it-autoflight/internal/bank-limit", 25);
}
if (getprop("/it-autoflight/custom/show-hdg") == 0 and getprop("/it-autoflight/output/lat") != 4) { if (getprop("/it-autoflight/custom/show-hdg") == 0 and getprop("/it-autoflight/output/lat") != 4) {
setprop("/it-autoflight/input/hdg", math.round(getprop("/orientation/heading-magnetic-deg"))); setprop("/it-autoflight/input/hdg", math.round(getprop("/orientation/heading-magnetic-deg")));
} }