From 220828980b9eb7a1f454159bdf7c48a4dfe45343 Mon Sep 17 00:00:00 2001 From: Joshua Davidson Date: Sat, 30 Dec 2017 00:25:11 -0500 Subject: [PATCH] A3XX: FADEC awake for 5 mins then go to sleep --- A320-100-CFM-set.xml | 4 +- A320-200-CFM-set.xml | 4 +- A320-200-IAE-set.xml | 3 - A320-main.xml | 4 +- A320neo-CFM-set.xml | 3 - A320neo-PW-set.xml | 3 - Models/Instruments/Upper-ECAM/Upper-ECAM.nas | 8 +-- Nasal/fadec-cfm.nas | 29 +++++--- Nasal/fadec-common.nas | 75 ++++++++++---------- Nasal/fadec-iae.nas | 57 ++++++++------- Nasal/libraries.nas | 1 + revision.txt | 2 +- 12 files changed, 101 insertions(+), 92 deletions(-) diff --git a/A320-100-CFM-set.xml b/A320-100-CFM-set.xml index 3cdaf01e..2ff9f8ba 100644 --- a/A320-100-CFM-set.xml +++ b/A320-100-CFM-set.xml @@ -196,8 +196,6 @@ Aircraft/IDG-A32X/Nasal/a320livery-cfm-100.nas - - Aircraft/IDG-A32X/Nasal/fadec-cfm.nas - + diff --git a/A320-200-CFM-set.xml b/A320-200-CFM-set.xml index 3a401c54..e7872a7e 100644 --- a/A320-200-CFM-set.xml +++ b/A320-200-CFM-set.xml @@ -195,8 +195,6 @@ Aircraft/IDG-A32X/Nasal/a320livery-cfm.nas - - Aircraft/IDG-A32X/Nasal/fadec-cfm.nas - + diff --git a/A320-200-IAE-set.xml b/A320-200-IAE-set.xml index 5f2d96fd..ce866cdb 100644 --- a/A320-200-IAE-set.xml +++ b/A320-200-IAE-set.xml @@ -195,9 +195,6 @@ Aircraft/IDG-A32X/Nasal/a320livery-iae.nas - - Aircraft/IDG-A32X/Nasal/fadec-iae.nas - diff --git a/A320-main.xml b/A320-main.xml index 3000b434..b58507b2 100644 --- a/A320-main.xml +++ b/A320-main.xml @@ -1395,9 +1395,9 @@ Aircraft/IDG-A32X/Nasal/ground_services.nas Aircraft/IDG-A32X/Nasal/effects.nas - + Aircraft/IDG-A32X/Nasal/fadec-common.nas - + Aircraft/IDG-A32X/Nasal/it-fbw.nas diff --git a/A320neo-CFM-set.xml b/A320neo-CFM-set.xml index a0b01e2c..53aaba9f 100644 --- a/A320neo-CFM-set.xml +++ b/A320neo-CFM-set.xml @@ -195,9 +195,6 @@ Aircraft/IDG-A32X/Nasal/a320livery-neocfm.nas - - Aircraft/IDG-A32X/Nasal/fadec-cfm.nas - diff --git a/A320neo-PW-set.xml b/A320neo-PW-set.xml index 34a0fa9e..730ef05c 100644 --- a/A320neo-PW-set.xml +++ b/A320neo-PW-set.xml @@ -195,9 +195,6 @@ Aircraft/IDG-A32X/Nasal/a320livery-neopw.nas - - Aircraft/IDG-A32X/Nasal/fadec-cfm.nas - diff --git a/Models/Instruments/Upper-ECAM/Upper-ECAM.nas b/Models/Instruments/Upper-ECAM/Upper-ECAM.nas index 9afd5c88..e40eb2e1 100644 --- a/Models/Instruments/Upper-ECAM/Upper-ECAM.nas +++ b/Models/Instruments/Upper-ECAM/Upper-ECAM.nas @@ -492,7 +492,7 @@ var canvas_upperECAM_cfm_eis2 = { me["N1Lim"].setText(sprintf("%s", math.floor(getprop("/controls/engines/n1-limit") + 0.05))); me["N1Lim-decimal"].setText(sprintf("%s", int(10*math.mod(getprop("/controls/engines/n1-limit") + 0.05,1)))); - if (getprop("/systems/fadec/powered1") == 1 or getprop("/systems/fadec/powered2") == 1) { + if (getprop("/systems/fadec/powered1") == 1 or getprop("/systems/fadec/powered2") == 1 or getprop("/systems/fadec/powerup")) { me["N1Lim-mode"].show(); me["N1Lim-XX"].hide(); me["N1Lim-XX2"].hide(); @@ -502,7 +502,7 @@ var canvas_upperECAM_cfm_eis2 = { me["N1Lim-XX2"].show(); } - if ((getprop("/systems/fadec/powered1") == 1 or getprop("/systems/fadec/powered2") == 1) and getprop("/controls/engines/thrust-limit") != "MREV") { + if ((getprop("/systems/fadec/powered1") == 1 or getprop("/systems/fadec/powered2") == 1 or getprop("/systems/fadec/powerup")) and getprop("/controls/engines/thrust-limit") != "MREV") { me["N1Lim"].show(); me["N1Lim-decpnt"].show(); me["N1Lim-decimal"].show(); @@ -783,7 +783,7 @@ var canvas_upperECAM_iae_eis2 = { me["EPRLim"].setText(sprintf("%1.0f", math.floor(getprop("/controls/engines/epr-limit")))); me["EPRLim-decimal"].setText(sprintf("%03d", (getprop("/controls/engines/epr-limit") - int(getprop("/controls/engines/epr-limit"))) * 1000)); - if (getprop("/systems/fadec/powered1") == 1 or getprop("/systems/fadec/powered2") == 1) { + if (getprop("/systems/fadec/powered1") == 1 or getprop("/systems/fadec/powered2") == 1 or getprop("/systems/fadec/powerup")) { me["EPRLim-mode"].show(); me["EPRLim-XX"].hide(); me["EPRLim-XX2"].hide(); @@ -793,7 +793,7 @@ var canvas_upperECAM_iae_eis2 = { me["EPRLim-XX2"].show(); } - if ((getprop("/systems/fadec/powered1") == 1 or getprop("/systems/fadec/powered2") == 1) and getprop("/controls/engines/thrust-limit") != "MREV") { + if ((getprop("/systems/fadec/powered1") == 1 or getprop("/systems/fadec/powered2") == 1 or getprop("/systems/fadec/powerup")) and getprop("/controls/engines/thrust-limit") != "MREV") { me["EPRLim"].show(); me["EPRLim-decpnt"].show(); me["EPRLim-decimal"].show(); diff --git a/Nasal/fadec-cfm.nas b/Nasal/fadec-cfm.nas index 09aa6604..ba85a4a9 100644 --- a/Nasal/fadec-cfm.nas +++ b/Nasal/fadec-cfm.nas @@ -17,12 +17,10 @@ setprop("/systems/fadec/eng2/ff", 1); setprop("/systems/fadec/power-avail", 0); setprop("/systems/fadec/powered1", 0); setprop("/systems/fadec/powered2", 0); +setprop("/systems/fadec/powered-time", 0); +setprop("/systems/fadec/powerup", 0); -setlistener("/sim/signals/fdm-initialized", func { - fadecLoop.start(); -}); - -var fadecLoop = maketimer(0.7, func { +var fadecLoop = func { var ac1 = getprop("/systems/electrical/bus/ac1"); var ac2 = getprop("/systems/electrical/bus/ac2"); var acess = getprop("/systems/electrical/bus/ac-ess"); @@ -33,13 +31,24 @@ var fadecLoop = maketimer(0.7, func { var modeSel = getprop("/controls/engines/engine-start-switch"); if (ac1 >= 110 or ac2 >= 110 or acess >= 110) { - setprop("/systems/fadec/power-avail", 1); + if (getprop("/systems/fadec/power-avail") != 1) { + setprop("/systems/fadec/powered-time", getprop("/sim/time/elapsed-sec")); + setprop("/systems/fadec/power-avail", 1); + } } else { - setprop("/systems/fadec/power-avail", 0); + if (getprop("/systems/fadec/power-avail") != 0) { + setprop("/systems/fadec/power-avail", 0); + } } var powerAvail = getprop("/systems/fadec/power-avail"); + if (getprop("/systems/fadec/powered-time") + 300 >= getprop("/sim/time/elapsed-sec")) { + setprop("/systems/fadec/powerup", 1); + } else { + setprop("/systems/fadec/powerup", 0); + } + if (state1 == 3) { setprop("/systems/fadec/powered1", 1); } else if (powerAvail and modeSel == 2) { @@ -59,7 +68,7 @@ var fadecLoop = maketimer(0.7, func { var powered1 = getprop("/systems/fadec/powered1"); var powered2 = getprop("/systems/fadec/powered2"); - if (powered1) { + if (powered1 or getprop("/systems/fadec/powerup")) { setprop("/systems/fadec/eng1/n1", 1); setprop("/systems/fadec/eng1/egt", 1); setprop("/systems/fadec/eng1/n2", 1); @@ -71,7 +80,7 @@ var fadecLoop = maketimer(0.7, func { setprop("/systems/fadec/eng1/ff", 0); } - if (powered2) { + if (powered2 or getprop("/systems/fadec/powerup")) { setprop("/systems/fadec/eng2/n1", 1); setprop("/systems/fadec/eng2/egt", 1); setprop("/systems/fadec/eng2/n2", 1); @@ -82,4 +91,4 @@ var fadecLoop = maketimer(0.7, func { setprop("/systems/fadec/eng2/n2", 0); setprop("/systems/fadec/eng2/ff", 0); } -}); +} diff --git a/Nasal/fadec-common.nas b/Nasal/fadec-common.nas index 179a28ab..d8b2816f 100644 --- a/Nasal/fadec-common.nas +++ b/Nasal/fadec-common.nas @@ -5,6 +5,12 @@ # Copyright (c) Joshua Davidson (it0uchpods) # ############################################## +if (getprop("/options/eng") == "IAE") { + io.include("fadec-iae.nas"); +} else { + io.include("fadec-cfm.nas"); +} + setprop("/systems/thrust/alpha-floor", 0); setprop("/systems/thrust/toga-lk", 0); setprop("/systems/thrust/epr/toga-lim", 0.0); @@ -50,8 +56,8 @@ setlistener("/sim/signals/fdm-initialized", func { var alphaProt = 0; var togaLock = 0; var gs = getprop("/velocities/groundspeed-kt"); - thrust_lim.start(); - thrustt.start(); + thrust_loop.start(); + thrust_flash.start(); }); setlistener("/controls/engines/engine[0]/throttle-pos", func { @@ -194,7 +200,7 @@ var atoff_request = func { } } -var thrust_lim = maketimer(0.04, func { +var thrust_loop = maketimer(0.04, func { state1 = getprop("/systems/thrust/state1"); state2 = getprop("/systems/thrust/state2"); engstate1 = getprop("/engines/engine[0]/state"); @@ -252,6 +258,34 @@ var thrust_lim = maketimer(0.04, func { setprop("/controls/engines/epr-limit", eprtoga); setprop("/controls/engines/n1-limit", n1toga); } + + alpha = getprop("/fdm/jsbsim/aero/alpha-deg"); + flaps = getprop("/controls/flight/flap-pos"); + if (flaps == 0) { + alphaProt = 9.5; + } else if (flaps == 1 or flaps == 2 or flaps == 3) { + alphaProt = 15.0; + } else if (flaps == 4) { + alphaProt = 14.0; + } else if (flaps == 5) { + alphaProt = 13.0; + } + togaLock = alphaProt - 1; + if (getprop("/gear/gear[1]/wow") == 0 and getprop("/gear/gear[2]/wow") == 0 and getprop("/it-fbw/law") == 0 and (getprop("/systems/thrust/eng-out") == 0 or (getprop("/systems/thrust/eng-out") == 1 and flaps == 0)) and getprop("/systems/fadec/n1mode1") == 0 + and getprop("/systems/fadec/n1mode2") == 0) { + if (alpha > alphaProt and getprop("/position/gear-agl-ft") >= 100) { + setprop("/systems/thrust/alpha-floor", 1); + setprop("/systems/thrust/toga-lk", 0); + setprop("/it-autoflight/input/athr", 1); + } else if (getprop("/systems/thrust/alpha-floor") == 1 and alpha < togaLock) { + setprop("/systems/thrust/alpha-floor", 0); + setprop("/it-autoflight/input/athr", 1); + setprop("/systems/thrust/toga-lk", 1); + } + } else { + setprop("/systems/thrust/alpha-floor", 0); + setprop("/systems/thrust/toga-lk", 0); + } }); var unflex = func { @@ -262,7 +296,7 @@ var unflex = func { } } -var thrust_loop = func { +var thrust_flash = maketimer(0.5, func { state1 = getprop("/systems/thrust/state1"); state2 = getprop("/systems/thrust/state2"); @@ -296,35 +330,4 @@ var thrust_loop = func { setprop("/systems/thrust/lvrclb", 0); } } - - alpha = getprop("/fdm/jsbsim/aero/alpha-deg"); - flaps = getprop("/controls/flight/flap-pos"); - if (flaps == 0) { - alphaProt = 9.5; - } else if (flaps == 1 or flaps == 2 or flaps == 3) { - alphaProt = 15.0; - } else if (flaps == 4) { - alphaProt = 14.0; - } else if (flaps == 5) { - alphaProt = 13.0; - } - togaLock = alphaProt - 1; - if (getprop("/gear/gear[1]/wow") == 0 and getprop("/gear/gear[2]/wow") == 0 and getprop("/it-fbw/law") == 0 and (getprop("/systems/thrust/eng-out") == 0 or (getprop("/systems/thrust/eng-out") == 1 and flaps == 0)) and getprop("/systems/fadec/n1mode1") == 0 - and getprop("/systems/fadec/n1mode2") == 0) { - if (alpha > alphaProt and getprop("/position/gear-agl-ft") >= 100) { - setprop("/systems/thrust/alpha-floor", 1); - setprop("/systems/thrust/toga-lk", 0); - setprop("/it-autoflight/input/athr", 1); - } else if (getprop("/systems/thrust/alpha-floor") == 1 and alpha < togaLock) { - setprop("/systems/thrust/alpha-floor", 0); - setprop("/it-autoflight/input/athr", 1); - setprop("/systems/thrust/toga-lk", 1); - } - } else { - setprop("/systems/thrust/alpha-floor", 0); - setprop("/systems/thrust/toga-lk", 0); - } -} - -# Timers -var thrustt = maketimer(0.5, thrust_loop); +}); diff --git a/Nasal/fadec-iae.nas b/Nasal/fadec-iae.nas index c3819a12..388ef910 100644 --- a/Nasal/fadec-iae.nas +++ b/Nasal/fadec-iae.nas @@ -21,12 +21,10 @@ setprop("/systems/fadec/eng2/ff", 1); setprop("/systems/fadec/power-avail", 0); setprop("/systems/fadec/powered1", 0); setprop("/systems/fadec/powered2", 0); +setprop("/systems/fadec/powered-time", 0); +setprop("/systems/fadec/powerup", 0); -setlistener("/sim/signals/fdm-initialized", func { - fadecLoop.start(); -}); - -var fadecLoop = maketimer(0.7, func { +var fadecLoop = func { var ac1 = getprop("/systems/electrical/bus/ac1"); var ac2 = getprop("/systems/electrical/bus/ac2"); var acess = getprop("/systems/electrical/bus/ac-ess"); @@ -39,13 +37,24 @@ var fadecLoop = maketimer(0.7, func { var N1Mode2_sw = getprop("/controls/fadec/n1mode2"); if (ac1 >= 110 or ac2 >= 110 or acess >= 110) { - setprop("/systems/fadec/power-avail", 1); + if (getprop("/systems/fadec/power-avail") != 1) { + setprop("/systems/fadec/powered-time", getprop("/sim/time/elapsed-sec")); + setprop("/systems/fadec/power-avail", 1); + } } else { - setprop("/systems/fadec/power-avail", 0); + if (getprop("/systems/fadec/power-avail") != 0) { + setprop("/systems/fadec/power-avail", 0); + } } var powerAvail = getprop("/systems/fadec/power-avail"); + if (getprop("/systems/fadec/powered-time") + 300 >= getprop("/sim/time/elapsed-sec")) { + setprop("/systems/fadec/powerup", 1); + } else { + setprop("/systems/fadec/powerup", 0); + } + if (state1 == 3) { setprop("/systems/fadec/powered1", 1); } else if (powerAvail and modeSel == 2) { @@ -62,6 +71,18 @@ var fadecLoop = maketimer(0.7, func { setprop("/systems/fadec/powered2", 0); } + if (N1Mode1_sw == 1) { + setprop("/systems/fadec/n1mode1", 1); + } else { + setprop("/systems/fadec/n1mode1", 0); + } + + if (N1Mode2_sw == 1) { + setprop("/systems/fadec/n1mode2", 1); + } else { + setprop("/systems/fadec/n1mode2", 0); + } + var powered1 = getprop("/systems/fadec/powered1"); var powered2 = getprop("/systems/fadec/powered2"); var N1Mode1 = getprop("/systems/fadec/n1mode1"); @@ -71,19 +92,19 @@ var fadecLoop = maketimer(0.7, func { var N21 = getprop("/engines/engine[0]/n2-actual"); var N22 = getprop("/engines/engine[1]/n2-actual"); - if (powered1 and N1Mode1 == 0) { + if ((powered1 or getprop("/systems/fadec/powerup")) and N1Mode1 == 0) { setprop("/systems/fadec/eng1/epr", 1); } else { setprop("/systems/fadec/eng1/epr", 0); } - if (powered2 and N1Mode2 == 0) { + if ((powered2 or getprop("/systems/fadec/powerup")) and N1Mode2 == 0) { setprop("/systems/fadec/eng2/epr", 1); } else { setprop("/systems/fadec/eng2/epr", 0); } - if (powered1) { + if (powered1 or getprop("/systems/fadec/powerup")) { setprop("/systems/fadec/eng1/egt", 1); setprop("/systems/fadec/eng1/ff", 1); } else { @@ -91,7 +112,7 @@ var fadecLoop = maketimer(0.7, func { setprop("/systems/fadec/eng1/ff", 0); } - if (powered2) { + if (powered2 or getprop("/systems/fadec/powerup")) { setprop("/systems/fadec/eng2/egt", 1); setprop("/systems/fadec/eng2/ff", 1); } else { @@ -122,16 +143,4 @@ var fadecLoop = maketimer(0.7, func { } else { setprop("/systems/fadec/eng2/n2", 0); } - - if (N1Mode1_sw == 1) { - setprop("/systems/fadec/n1mode1", 1); - } else { - setprop("/systems/fadec/n1mode1", 0); - } - - if (N1Mode2_sw == 1) { - setprop("/systems/fadec/n1mode2", 1); - } else { - setprop("/systems/fadec/n1mode2", 0); - } -}); +} diff --git a/Nasal/libraries.nas b/Nasal/libraries.nas index 1653ce3b..93f5d798 100644 --- a/Nasal/libraries.nas +++ b/Nasal/libraries.nas @@ -204,6 +204,7 @@ var systemsLoop = maketimer(0.1, func { systems.FUEL.loop(); systems.ADIRS.loop(); libraries.ECAM.loop(); + fadec.fadecLoop(); if ((getprop("/controls/pneumatic/switches/groundair") or getprop("/controls/switches/cart")) and ((getprop("/velocities/groundspeed-kt") > 2) or getprop("/controls/gear/brake-parking") == 0)) { setprop("/controls/switches/cart", 0); diff --git a/revision.txt b/revision.txt index 549d0ba3..2f16f2d4 100644 --- a/revision.txt +++ b/revision.txt @@ -1 +1 @@ -4205 \ No newline at end of file +4206 \ No newline at end of file