diff --git a/AircraftConfig/fbw.xml b/AircraftConfig/fbw.xml index f1aacb88..e0ed45a4 100644 --- a/AircraftConfig/fbw.xml +++ b/AircraftConfig/fbw.xml @@ -50,6 +50,7 @@ nasal @@ -65,6 +66,7 @@ nasal @@ -80,6 +82,7 @@ nasal @@ -95,6 +98,7 @@ nasal diff --git a/Nasal/it-fbw.nas b/Nasal/it-fbw.nas index 5ef89cd7..daa387a2 100644 --- a/Nasal/it-fbw.nas +++ b/Nasal/it-fbw.nas @@ -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);