A3XX: Improve FlyByWire Law Degrading

This commit is contained in:
Joshua Davidson 2017-07-04 22:20:23 -04:00
parent eb4b3ba9cb
commit a2e8e4852b
2 changed files with 58 additions and 11 deletions

View file

@ -50,6 +50,7 @@
<binding>
<command>nasal</command>
<script>
setprop("/it-fbw/degrade-law", 0);
setprop("/it-fbw/law", 0);
gui.popupTip("Fly By Wire switched to NORMAL law!");
</script>
@ -65,6 +66,7 @@
<binding>
<command>nasal</command>
<script>
setprop("/it-fbw/degrade-law", 1);
setprop("/it-fbw/law", 1);
gui.popupTip("Fly By Wire switched to ALTERNATE law!");
</script>
@ -80,6 +82,7 @@
<binding>
<command>nasal</command>
<script>
setprop("/it-fbw/degrade-law", 2);
setprop("/it-fbw/law", 2);
gui.popupTip("Fly By Wire switched to DIRECT law!");
</script>
@ -95,6 +98,7 @@
<binding>
<command>nasal</command>
<script>
setprop("/it-fbw/degrade-law", 3);
setprop("/it-fbw/law", 3);
gui.popupTip("Fly By Wire switched to MECHANICAL BACKUP law!");
</script>

View file

@ -26,8 +26,10 @@ var fctlInit = func {
setprop("/systems/fctl/elac2", 0);
setprop("/systems/fctl/sec1", 0);
setprop("/systems/fctl/sec2", 0);
setprop("/systems/fctl/sec3", 0);
setprop("/systems/fctl/fac1", 0);
setprop("/systems/fctl/fac2", 0);
setprop("/it-fbw/degrade-law", 0);
}
setprop("/it-fbw/roll-back", 0);
@ -38,7 +40,6 @@ setprop("/it-fbw/spd-hold", 0);
###################
var update_loop = func {
var elac1_sw = getprop("/controls/fctl/elac1");
var elac2_sw = getprop("/controls/fctl/elac2");
var sec1_sw = getprop("/controls/fctl/sec1");
@ -96,7 +97,46 @@ var update_loop = func {
} else {
setprop("/systems/fctl/fac2", 0);
}
var elac1 = getprop("/systems/fctl/elac1");
var elac2 = getprop("/systems/fctl/elac2");
var sec1 = getprop("/systems/fctl/sec1");
var sec2 = getprop("/systems/fctl/sec2");
var sec3 = getprop("/systems/fctl/sec3");
var fac1 = getprop("/systems/fctl/fac1");
var fac2 = getprop("/systems/fctl/fac2");
var law = getprop("/it-fbw/law");
# Degrade logic, all failures which degrade FBW need to go here. -JD
if (getprop("/gear/gear[1]/wow") == 0 and getprop("/gear/gear[2]/wow") == 0) {
if (!elac1 and !elac2) {
if (law == 0) {
setprop("/it-fbw/degrade-law", 1);
}
} else if (getprop("/systems/electrical/bus/ac-ess") >= 110 and getprop("/systems/hydraulic/blue-psi") >= 1500 and getprop("/systems/hydraulic/green-psi") < 1500 and getprop("/systems/hydraulic/yellow-psi") < 1500) {
if (law == 0 or law == 1) {
setprop("/it-fbw/degrade-law", 2);
}
} else if (getprop("/controls/gear/gear-down") == 1) {
if (law == 1) {
setprop("/it-fbw/degrade-law", 2);
}
} else if (getprop("/systems/electrical/bus/ac-ess") < 110 or (getprop("/systems/hydraulic/blue-psi") < 1500 and getprop("/systems/hydraulic/green-psi") < 1500 and getprop("/systems/hydraulic/yellow-psi") < 1500)) {
setprop("/it-fbw/degrade-law", 3);
}
}
var law = getprop("/it-fbw/law");
# Mech Backup can always return to direct, if it can.
if (law == 3 and getprop("/systems/electrical/bus/ac-ess") >= 110 and getprop("/systems/hydraulic/blue-psi") >= 1500) {
setprop("/it-fbw/degrade-law", 2);
}
}
var fbw_loop = func {
var ail = getprop("/controls/flight/aileron");
if (ail > 0.4 or ail < -0.4) {
@ -115,24 +155,25 @@ var update_loop = func {
}
if (getprop("/it-fbw/override") == 0) {
if ((getprop("/systems/electrical/bus/ac-ess") >= 110) and (getprop("/systems/hydraulic/green-psi") >= 1500) and (getprop("/systems/hydraulic/yellow-psi") >= 1500)) {
var degrade = getprop("/it-fbw/degrade-law");
if (degrade == 0) {
if (getprop("/it-fbw/law") != 0) {
setprop("/it-fbw/law", 0);
}
} else if ((getprop("/systems/electrical/bus/ac-ess") >= 110) and (getprop("/systems/hydraulic/blue-psi") >= 1500)) {
} else if (degrade == 1) {
if (getprop("/it-fbw/law") != 1) {
setprop("/it-fbw/law", 1);
}
} else if (degrade == 2) {
if (getprop("/it-fbw/law") != 2) {
setprop("/it-fbw/law", 2);
}
} else {
} else if (degrade == 3) {
if (getprop("/it-fbw/law") != 3) {
setprop("/it-fbw/law", 3);
}
}
}
if (getprop("/it-fbw/law") == 1 and getprop("/controls/gear/gear-down") == 1 and getprop("/it-fbw/override") == 0) {
setprop("/it-fbw/law", 2);
}
}
###########################
@ -141,11 +182,13 @@ var update_loop = func {
setlistener("/sim/signals/fdm-initialized", func {
setprop("/it-fbw/override", 0);
setprop("/it-fbw/law", 3);
setprop("/it-fbw/law", 0);
updatet.start();
fbwt.start();
});
##########
# Timers #
##########
var updatet = maketimer(0.05, update_loop);
var updatet = maketimer(0.1, update_loop);
var fbwt = maketimer(0.05, fbw_loop);