From 18f868a0c2a8a1788b37ffdd46b2802bdfd37dbe Mon Sep 17 00:00:00 2001 From: Joshua Davidson Date: Fri, 28 Sep 2018 14:54:44 -0400 Subject: [PATCH 01/10] Control: AP: He do not engage below 100ft, fixes #38 --- Nasal/FMGC-b.nas | 4 ++-- revision.txt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Nasal/FMGC-b.nas b/Nasal/FMGC-b.nas index 8de3b2a7..14a3f777 100644 --- a/Nasal/FMGC-b.nas +++ b/Nasal/FMGC-b.nas @@ -110,7 +110,7 @@ setlistener("/it-autoflight/input/ap1", func { fmabox(); updateTimers(); } else if (apmas == 1 and ac_ess >= 110 and law == 0) { - if ((getprop("/gear/gear[1]/wow") == 0) and (getprop("/gear/gear[2]/wow") == 0)) { + if (getprop("/gear/gear[1]/wow") == 0 and getprop("/gear/gear[2]/wow") == 0 and getprop("/position/gear-agl-ft") >= 100) { if (getprop("/it-autoflight/output/lat") == 9) { setprop("/it-autoflight/input/lat", 3); } @@ -146,7 +146,7 @@ setlistener("/it-autoflight/input/ap2", func { fmabox(); updateTimers(); } else if (apmas == 1 and ac_ess >= 110 and law == 0) { - if ((getprop("/gear/gear[1]/wow") == 0) and (getprop("/gear/gear[2]/wow") == 0)) { + if (getprop("/gear/gear[1]/wow") == 0 and getprop("/gear/gear[2]/wow") == 0 and getprop("/position/gear-agl-ft") >= 100) { if (getprop("/it-autoflight/output/lat") == 9) { setprop("/it-autoflight/input/lat", 3); } diff --git a/revision.txt b/revision.txt index 032fb5c3..da61b691 100644 --- a/revision.txt +++ b/revision.txt @@ -1 +1 @@ -4655 \ No newline at end of file +4656 \ No newline at end of file From 08a4e0849218efde07141c713dbf0123a6e7d8b7 Mon Sep 17 00:00:00 2001 From: Joshua Davidson Date: Fri, 28 Sep 2018 15:34:35 -0400 Subject: [PATCH 02/10] Control: Fix spoiler 4 not working on landing, fixes #46 --- Systems/a320-spoiler.xml | 1 - revision.txt | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/Systems/a320-spoiler.xml b/Systems/a320-spoiler.xml index 8bc62a68..390f1961 100644 --- a/Systems/a320-spoiler.xml +++ b/Systems/a320-spoiler.xml @@ -666,7 +666,6 @@ /systems/hydraulic/yellow-psi ge 1500 - spoilers/main-gear-and eq 0 /systems/failures/spoiler-r4 eq 0 spoilers/main-cmd gt 0 diff --git a/revision.txt b/revision.txt index da61b691..f3972440 100644 --- a/revision.txt +++ b/revision.txt @@ -1 +1 @@ -4656 \ No newline at end of file +4657 \ No newline at end of file From 198298c270b09911f9f1f84391042a94e80c4c32 Mon Sep 17 00:00:00 2001 From: Joshua Davidson Date: Fri, 28 Sep 2018 15:38:26 -0400 Subject: [PATCH 03/10] System: APU Bleed now makes APU wait 1min before shutdown, fixes #10 --- AircraftConfig/acconfig.nas | 8 -------- Nasal/engines-cfm.nas | 1 + Nasal/engines-common.nas | 32 ++++++++++++++++++++++++++++++-- Nasal/engines-iae.nas | 1 + Nasal/libraries.nas | 3 --- Nasal/pneumatics.nas | 5 +++-- revision.txt | 2 +- 7 files changed, 36 insertions(+), 16 deletions(-) diff --git a/AircraftConfig/acconfig.nas b/AircraftConfig/acconfig.nas index 46082679..c2205bab 100644 --- a/AircraftConfig/acconfig.nas +++ b/AircraftConfig/acconfig.nas @@ -229,9 +229,6 @@ var colddark_b = func { # Continues the Cold and Dark script, after engines fully shutdown. setprop("/controls/APU/master", 0); setprop("/controls/APU/start", 0); - setprop("/controls/bleed/OHP/bleedapu", 0); - setprop("/controls/electrical/switches/battery1", 0); - setprop("/controls/electrical/switches/battery2", 0); setprop("/controls/gear/brake-left", 0); setprop("/controls/gear/brake-right", 0); setprop("/systems/acconfig/autoconfig-running", 0); @@ -265,9 +262,6 @@ var beforestart = func { failReset(); setprop("/controls/APU/master", 0); setprop("/controls/APU/start", 0); - setprop("/controls/bleed/OHP/bleedapu", 0); - setprop("/controls/electrical/switches/battery1", 0); - setprop("/controls/electrical/switches/battery2", 0); # Now the Startup! setprop("/controls/electrical/switches/battery1", 1); @@ -343,8 +337,6 @@ var taxi = func { failReset(); setprop("/controls/APU/master", 0); setprop("/controls/APU/start", 0); - setprop("/controls/electrical/switches/battery1", 0); - setprop("/controls/electrical/switches/battery2", 0); # Now the Startup! setprop("/controls/electrical/switches/battery1", 1); diff --git a/Nasal/engines-cfm.nas b/Nasal/engines-cfm.nas index 271ee991..a7082f0a 100644 --- a/Nasal/engines-cfm.nas +++ b/Nasal/engines-cfm.nas @@ -31,6 +31,7 @@ setprop("/controls/engines/engine[1]/last-igniter", "B"); var eng_init = func { setprop("/controls/engines/engine[0]/man-start", 0); setprop("/controls/engines/engine[1]/man-start", 0); + eng_common_init(); } # Trigger Startups and Stops diff --git a/Nasal/engines-common.nas b/Nasal/engines-common.nas index 0d9ff2c9..a4cf7a93 100644 --- a/Nasal/engines-common.nas +++ b/Nasal/engines-common.nas @@ -17,6 +17,13 @@ var apu_egt_min = 352; var apu_egt_max = 704; setprop("/systems/apu/rpm", 0); setprop("/systems/apu/egt", 42); +setprop("/systems/apu/bleed-used", 0); +setprop("/systems/apu/bleed-counting", 0); +setprop("/systems/apu/bleed-time", 0); + +var eng_common_init = func { + setprop("/systems/apu/bleed-used", 0); +} # Start APU setlistener("/controls/APU/start", func { @@ -60,10 +67,31 @@ setlistener("/controls/APU/master", func { }); var apu_stop = func { - interpolate("/systems/apu/rpm", 0, 30); - interpolate("/systems/apu/egt", 42, 40); + if (getprop("/systems/apu/bleed-used") == 1 and getprop("/systems/apu/bleed-counting") != 1) { + setprop("/systems/apu/bleed-counting", 1); + setprop("/systems/apu/bleed-time", getprop("/sim/time/elapsed-sec")); + } + if (getprop("/systems/apu/bleed-used") == 1 and getprop("/systems/apu/bleed-counting") == 1) { + apuBleedChk.start(); + } else { + apuBleedChk.stop(); + interpolate("/systems/apu/rpm", 0, 30); + interpolate("/systems/apu/egt", 42, 40); + setprop("/systems/apu/bleed-counting", 0); + } } +var apuBleedChk = maketimer(0.1, func { + if (getprop("/systems/apu/bleed-used") == 1 and getprop("/systems/apu/bleed-counting") == 1) { + if (getprop("/systems/apu/bleed-time") + 60 <= getprop("/sim/time/elapsed-sec")) { + apuBleedChk.stop(); + interpolate("/systems/apu/rpm", 0, 30); + interpolate("/systems/apu/egt", 42, 40); + setprop("/systems/apu/bleed-counting", 0); + } + } +}); + # Various Other Stuff var doIdleThrust = func { setprop("/controls/engines/engine[0]/throttle", 0.0); diff --git a/Nasal/engines-iae.nas b/Nasal/engines-iae.nas index b8ba6853..ec26ddb7 100644 --- a/Nasal/engines-iae.nas +++ b/Nasal/engines-iae.nas @@ -31,6 +31,7 @@ setprop("/controls/engines/engine[1]/last-igniter", "B"); var eng_init = func { setprop("/controls/engines/engine[0]/man-start", 0); setprop("/controls/engines/engine[1]/man-start", 0); + eng_common_init(); } # Trigger Startups and Stops diff --git a/Nasal/libraries.nas b/Nasal/libraries.nas index a7669e9f..7522c476 100644 --- a/Nasal/libraries.nas +++ b/Nasal/libraries.nas @@ -16,9 +16,6 @@ setprop("/controls/lighting/ndl-norm", 1); setprop("/controls/lighting/ndr-norm", 1); setprop("/controls/lighting/upper-norm", 1); -# Surprise -setprop("/controls/tray/surprise", 1); - # Lights setprop("/sim/model/lights/nose-lights", 0); setprop("/sim/model/lights/turnoffsw", 0); diff --git a/Nasal/pneumatics.nas b/Nasal/pneumatics.nas index 06b469ff..281ca14f 100644 --- a/Nasal/pneumatics.nas +++ b/Nasal/pneumatics.nas @@ -200,6 +200,7 @@ var PNEU = { # Air Sources/PSI if (rpmapu >= 94.9 and bleedapu_sw and !bleedapu_fail) { setprop("/systems/pneumatic/bleedapu", 34); + setprop("/systems/apu/bleed-used", 1); } else { setprop("/systems/pneumatic/bleedapu", 0); } @@ -372,10 +373,10 @@ var PNEU = { acess = getprop("/systems/electrical/bus/ac-ess"); fanon = getprop("/systems/ventilation/avionics/fan"); - if ((dcess > 25) or (acess > 110)) { + if (dcess > 25 or acess > 110) { setprop("/systems/ventilation/avionics/fan", 1); setprop("/systems/ventilation/lavatory/extractfan", 1); - } else if ((dcess == 0) and (acess == 0)) { + } else if (dcess == 0 and acess == 0) { setprop("/systems/ventilation/avionics/fan", 0); setprop("/systems/ventilation/lavatory/extractfan", 0); } diff --git a/revision.txt b/revision.txt index f3972440..b840a9e9 100644 --- a/revision.txt +++ b/revision.txt @@ -1 +1 @@ -4657 \ No newline at end of file +4658 \ No newline at end of file From 8267a12d26c3eecd7d17e60628a0a98507347c6e Mon Sep 17 00:00:00 2001 From: Joshua Davidson Date: Fri, 28 Sep 2018 15:58:30 -0400 Subject: [PATCH 04/10] System: Fix bug in APU Shutdown --- Nasal/engines-common.nas | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Nasal/engines-common.nas b/Nasal/engines-common.nas index a4cf7a93..9567b715 100644 --- a/Nasal/engines-common.nas +++ b/Nasal/engines-common.nas @@ -27,7 +27,9 @@ var eng_common_init = func { # Start APU setlistener("/controls/APU/start", func { - if ((getprop("/controls/APU/master") == 1) and (getprop("/controls/APU/start") == 1)) { + if (getprop("/controls/APU/master") == 1 and getprop("/controls/APU/start") == 1) { + apuBleedChk.stop(); + setprop("/systems/apu/bleed-counting", 0); if (getprop("/systems/acconfig/autoconfig-running") == 0) { interpolate("/systems/apu/rpm", apu_max, spinup_time); apu_egt_check.start(); From 338b921d4cf493818c9087cba3fd7aa4e0e62d40 Mon Sep 17 00:00:00 2001 From: Joshua Davidson Date: Fri, 28 Sep 2018 16:05:11 -0400 Subject: [PATCH 05/10] System: Fix bug in APU Shutdown --- Nasal/engines-common.nas | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Nasal/engines-common.nas b/Nasal/engines-common.nas index 9567b715..f0d3a6df 100644 --- a/Nasal/engines-common.nas +++ b/Nasal/engines-common.nas @@ -65,6 +65,9 @@ setlistener("/controls/APU/master", func { apu_egt_check.stop(); apu_egt2_check.stop(); apu_stop(); + } else if (getprop("/controls/APU/master") = 1) { + apuBleedChk.stop(); + setprop("/systems/apu/bleed-counting", 0); } }); From 493d3aa1a3d8106f6798f162977e9ca8bfb5d70b Mon Sep 17 00:00:00 2001 From: Joshua Davidson Date: Fri, 28 Sep 2018 16:08:39 -0400 Subject: [PATCH 06/10] System: Fix I AM STUPID --- Nasal/engines-common.nas | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Nasal/engines-common.nas b/Nasal/engines-common.nas index f0d3a6df..685e3fc3 100644 --- a/Nasal/engines-common.nas +++ b/Nasal/engines-common.nas @@ -65,7 +65,7 @@ setlistener("/controls/APU/master", func { apu_egt_check.stop(); apu_egt2_check.stop(); apu_stop(); - } else if (getprop("/controls/APU/master") = 1) { + } else if (getprop("/controls/APU/master") == 1) { apuBleedChk.stop(); setprop("/systems/apu/bleed-counting", 0); } From cf87cce3b10315fdc3e6899113cc3d95a6eac11c Mon Sep 17 00:00:00 2001 From: Joshua Davidson Date: Fri, 28 Sep 2018 16:12:28 -0400 Subject: [PATCH 07/10] System: FADECs do not go to XX until 5mins after shutdown, fixes #39 --- Nasal/fadec-cfm.nas | 190 ++++++++++++++++++----------- Nasal/fadec-iae.nas | 286 ++++++++++++++++++++++++++------------------ Nasal/libraries.nas | 3 +- revision.txt | 2 +- 4 files changed, 289 insertions(+), 192 deletions(-) diff --git a/Nasal/fadec-cfm.nas b/Nasal/fadec-cfm.nas index ba85a4a9..45262272 100644 --- a/Nasal/fadec-cfm.nas +++ b/Nasal/fadec-cfm.nas @@ -17,78 +17,126 @@ 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/powered-time", -300); setprop("/systems/fadec/powerup", 0); +setprop("/systems/fadec/eng1-master-count", 0); +setprop("/systems/fadec/eng1-master-time", -300); +setprop("/systems/fadec/eng1-off-power", 0); +setprop("/systems/fadec/eng2-master-count", 0); +setprop("/systems/fadec/eng2-master-time", -300); +setprop("/systems/fadec/eng2-off-power", 0); -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"); - var state1 = getprop("/engines/engine[0]/state"); - var state2 = getprop("/engines/engine[1]/state"); - var master1 = getprop("/controls/engines/engine[0]/cutoff-switch"); - var master2 = getprop("/controls/engines/engine[1]/cutoff-switch"); - var modeSel = getprop("/controls/engines/engine-start-switch"); - - if (ac1 >= 110 or ac2 >= 110 or acess >= 110) { - if (getprop("/systems/fadec/power-avail") != 1) { - setprop("/systems/fadec/powered-time", getprop("/sim/time/elapsed-sec")); - setprop("/systems/fadec/power-avail", 1); +var FADEC = { + init: func() { + setprop("/systems/fadec/powered-time", 0); + setprop("/systems/fadec/eng1-master-time", -300); + setprop("/systems/fadec/eng2-master-time", -300); + }, + loop: func() { + var ac1 = getprop("/systems/electrical/bus/ac1"); + var ac2 = getprop("/systems/electrical/bus/ac2"); + var acess = getprop("/systems/electrical/bus/ac-ess"); + var state1 = getprop("/engines/engine[0]/state"); + var state2 = getprop("/engines/engine[1]/state"); + var master1 = getprop("/controls/engines/engine[0]/cutoff-switch"); + var master2 = getprop("/controls/engines/engine[1]/cutoff-switch"); + var modeSel = getprop("/controls/engines/engine-start-switch"); + var elapsedSec = getprop("/sim/time/elapsed-sec"); + + if (ac1 >= 110 or ac2 >= 110 or acess >= 110) { + if (getprop("/systems/fadec/power-avail") != 1) { + setprop("/systems/fadec/powered-time", elapsedSec); + setprop("/systems/fadec/power-avail", 1); + } + } else { + if (getprop("/systems/fadec/power-avail") != 0) { + setprop("/systems/fadec/power-avail", 0); + } } - } else { - 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 >= elapsedSec) { + setprop("/systems/fadec/powerup", 1); + } else { + setprop("/systems/fadec/powerup", 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) { - setprop("/systems/fadec/powered1", 1); - } else { - setprop("/systems/fadec/powered1", 0); - } - - if (state2 == 3) { - setprop("/systems/fadec/powered2", 1); - } else if (powerAvail and modeSel == 2) { - setprop("/systems/fadec/powered2", 1); - } else { - setprop("/systems/fadec/powered2", 0); - } - - var powered1 = getprop("/systems/fadec/powered1"); - var powered2 = getprop("/systems/fadec/powered2"); - - 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); - setprop("/systems/fadec/eng1/ff", 1); - } else { - setprop("/systems/fadec/eng1/n1", 0); - setprop("/systems/fadec/eng1/egt", 0); - setprop("/systems/fadec/eng1/n2", 0); - setprop("/systems/fadec/eng1/ff", 0); - } - - 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); - setprop("/systems/fadec/eng2/ff", 1); - } else { - setprop("/systems/fadec/eng2/n1", 0); - setprop("/systems/fadec/eng2/egt", 0); - setprop("/systems/fadec/eng2/n2", 0); - setprop("/systems/fadec/eng2/ff", 0); - } -} + + if (master1 == 1) { + if (getprop("/systems/fadec/eng1-master-count") != 1) { + setprop("/systems/fadec/eng1-master-time", elapsedSec); + setprop("/systems/fadec/eng1-master-count", 1); + } + } else { + if (getprop("/systems/fadec/eng1-master-count") != 0) { + setprop("/systems/fadec/eng1-master-count", 0); + } + } + + if (getprop("/systems/fadec/eng1-master-time") + 300 >= elapsedSec) { + setprop("/systems/fadec/eng1-off-power", 1); + } else { + setprop("/systems/fadec/eng1-off-power", 0); + } + + if (master2 == 1) { + if (getprop("/systems/fadec/eng2-master-count") != 1) { + setprop("/systems/fadec/eng2-master-time", elapsedSec); + setprop("/systems/fadec/eng2-master-count", 1); + } + } else { + if (getprop("/systems/fadec/eng2-master-count") != 0) { + setprop("/systems/fadec/eng2-master-count", 0); + } + } + + if (getprop("/systems/fadec/eng2-master-time") + 300 >= elapsedSec) { + setprop("/systems/fadec/eng2-off-power", 1); + } else { + setprop("/systems/fadec/eng2-off-power", 0); + } + + if (state1 == 3) { + setprop("/systems/fadec/powered1", 1); + } else if (powerAvail and modeSel == 2) { + setprop("/systems/fadec/powered1", 1); + } else { + setprop("/systems/fadec/powered1", 0); + } + + if (state2 == 3) { + setprop("/systems/fadec/powered2", 1); + } else if (powerAvail and modeSel == 2) { + setprop("/systems/fadec/powered2", 1); + } else { + setprop("/systems/fadec/powered2", 0); + } + + var powered1 = getprop("/systems/fadec/powered1"); + var powered2 = getprop("/systems/fadec/powered2"); + + if (powered1 or getprop("/systems/fadec/powerup") or getprop("/systems/fadec/eng1-off-power")) { + setprop("/systems/fadec/eng1/n1", 1); + setprop("/systems/fadec/eng1/egt", 1); + setprop("/systems/fadec/eng1/n2", 1); + setprop("/systems/fadec/eng1/ff", 1); + } else { + setprop("/systems/fadec/eng1/n1", 0); + setprop("/systems/fadec/eng1/egt", 0); + setprop("/systems/fadec/eng1/n2", 0); + setprop("/systems/fadec/eng1/ff", 0); + } + + if (powered2 or getprop("/systems/fadec/powerup") or getprop("/systems/fadec/eng2-off-power")) { + setprop("/systems/fadec/eng2/n1", 1); + setprop("/systems/fadec/eng2/egt", 1); + setprop("/systems/fadec/eng2/n2", 1); + setprop("/systems/fadec/eng2/ff", 1); + } else { + setprop("/systems/fadec/eng2/n1", 0); + setprop("/systems/fadec/eng2/egt", 0); + setprop("/systems/fadec/eng2/n2", 0); + setprop("/systems/fadec/eng2/ff", 0); + } + }, +}; diff --git a/Nasal/fadec-iae.nas b/Nasal/fadec-iae.nas index 388ef910..27464783 100644 --- a/Nasal/fadec-iae.nas +++ b/Nasal/fadec-iae.nas @@ -21,126 +21,174 @@ 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/powered-time", -300); setprop("/systems/fadec/powerup", 0); +setprop("/systems/fadec/eng1-master-count", 0); +setprop("/systems/fadec/eng1-master-time", -300); +setprop("/systems/fadec/eng1-off-power", 0); +setprop("/systems/fadec/eng2-master-count", 0); +setprop("/systems/fadec/eng2-master-time", -300); +setprop("/systems/fadec/eng2-off-power", 0); -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"); - var state1 = getprop("/engines/engine[0]/state"); - var state2 = getprop("/engines/engine[1]/state"); - var master1 = getprop("/controls/engines/engine[0]/cutoff-switch"); - var master2 = getprop("/controls/engines/engine[1]/cutoff-switch"); - var modeSel = getprop("/controls/engines/engine-start-switch"); - var N1Mode1_sw = getprop("/controls/fadec/n1mode1"); - var N1Mode2_sw = getprop("/controls/fadec/n1mode2"); - - if (ac1 >= 110 or ac2 >= 110 or acess >= 110) { - if (getprop("/systems/fadec/power-avail") != 1) { - setprop("/systems/fadec/powered-time", getprop("/sim/time/elapsed-sec")); - setprop("/systems/fadec/power-avail", 1); +var FADEC = { + init: func() { + setprop("/systems/fadec/powered-time", 0); + setprop("/systems/fadec/eng1-master-time", -300); + setprop("/systems/fadec/eng2-master-time", -300); + }, + loop: func() { + var ac1 = getprop("/systems/electrical/bus/ac1"); + var ac2 = getprop("/systems/electrical/bus/ac2"); + var acess = getprop("/systems/electrical/bus/ac-ess"); + var state1 = getprop("/engines/engine[0]/state"); + var state2 = getprop("/engines/engine[1]/state"); + var master1 = getprop("/controls/engines/engine[0]/cutoff-switch"); + var master2 = getprop("/controls/engines/engine[1]/cutoff-switch"); + var modeSel = getprop("/controls/engines/engine-start-switch"); + var N1Mode1_sw = getprop("/controls/fadec/n1mode1"); + var N1Mode2_sw = getprop("/controls/fadec/n1mode2"); + var elapsedSec = getprop("/sim/time/elapsed-sec"); + + if (ac1 >= 110 or ac2 >= 110 or acess >= 110) { + if (getprop("/systems/fadec/power-avail") != 1) { + setprop("/systems/fadec/powered-time", elapsedSec); + setprop("/systems/fadec/power-avail", 1); + } + } else { + if (getprop("/systems/fadec/power-avail") != 0) { + setprop("/systems/fadec/power-avail", 0); + } } - } else { - 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 >= elapsedSec) { + setprop("/systems/fadec/powerup", 1); + } else { + setprop("/systems/fadec/powerup", 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) { - setprop("/systems/fadec/powered1", 1); - } else { - setprop("/systems/fadec/powered1", 0); - } - - if (state2 == 3) { - setprop("/systems/fadec/powered2", 1); - } else if (powerAvail and modeSel == 2) { - setprop("/systems/fadec/powered2", 1); - } else { - 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"); - var N1Mode2 = getprop("/systems/fadec/n1mode2"); - var N11 = getprop("/engines/engine[0]/n1-actual"); - var N12 = getprop("/engines/engine[1]/n1-actual"); - var N21 = getprop("/engines/engine[0]/n2-actual"); - var N22 = getprop("/engines/engine[1]/n2-actual"); - - 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 or getprop("/systems/fadec/powerup")) and N1Mode2 == 0) { - setprop("/systems/fadec/eng2/epr", 1); - } else { - setprop("/systems/fadec/eng2/epr", 0); - } - - if (powered1 or getprop("/systems/fadec/powerup")) { - setprop("/systems/fadec/eng1/egt", 1); - setprop("/systems/fadec/eng1/ff", 1); - } else { - setprop("/systems/fadec/eng1/egt", 0); - setprop("/systems/fadec/eng1/ff", 0); - } - - if (powered2 or getprop("/systems/fadec/powerup")) { - setprop("/systems/fadec/eng2/egt", 1); - setprop("/systems/fadec/eng2/ff", 1); - } else { - setprop("/systems/fadec/eng2/egt", 0); - setprop("/systems/fadec/eng2/ff", 0); - } - - if (powered1 and N11 >= 3.5) { - setprop("/systems/fadec/eng1/n1", 1); - } else { - setprop("/systems/fadec/eng1/n1", 0); - } - - if (powered2 and N12 >= 3.5) { - setprop("/systems/fadec/eng2/n1", 1); - } else { - setprop("/systems/fadec/eng2/n1", 0); - } - - if (powered1 and N21 >= 3.5) { - setprop("/systems/fadec/eng1/n2", 1); - } else { - setprop("/systems/fadec/eng1/n2", 0); - } - - if (powered2 and N22 >= 3.5) { - setprop("/systems/fadec/eng2/n2", 1); - } else { - setprop("/systems/fadec/eng2/n2", 0); - } -} + + if (master1 == 1) { + if (getprop("/systems/fadec/eng1-master-count") != 1) { + setprop("/systems/fadec/eng1-master-time", elapsedSec); + setprop("/systems/fadec/eng1-master-count", 1); + } + } else { + if (getprop("/systems/fadec/eng1-master-count") != 0) { + setprop("/systems/fadec/eng1-master-count", 0); + } + } + + if (getprop("/systems/fadec/eng1-master-time") + 300 >= elapsedSec) { + setprop("/systems/fadec/eng1-off-power", 1); + } else { + setprop("/systems/fadec/eng1-off-power", 0); + } + + if (master2 == 1) { + if (getprop("/systems/fadec/eng2-master-count") != 1) { + setprop("/systems/fadec/eng2-master-time", elapsedSec); + setprop("/systems/fadec/eng2-master-count", 1); + } + } else { + if (getprop("/systems/fadec/eng2-master-count") != 0) { + setprop("/systems/fadec/eng2-master-count", 0); + } + } + + if (getprop("/systems/fadec/eng2-master-time") + 300 >= elapsedSec) { + setprop("/systems/fadec/eng2-off-power", 1); + } else { + setprop("/systems/fadec/eng2-off-power", 0); + } + + if (state1 == 3) { + setprop("/systems/fadec/powered1", 1); + } else if (powerAvail and modeSel == 2) { + setprop("/systems/fadec/powered1", 1); + } else { + setprop("/systems/fadec/powered1", 0); + } + + if (state2 == 3) { + setprop("/systems/fadec/powered2", 1); + } else if (powerAvail and modeSel == 2) { + setprop("/systems/fadec/powered2", 1); + } else { + 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"); + var N1Mode2 = getprop("/systems/fadec/n1mode2"); + var N11 = getprop("/engines/engine[0]/n1-actual"); + var N12 = getprop("/engines/engine[1]/n1-actual"); + var N21 = getprop("/engines/engine[0]/n2-actual"); + var N22 = getprop("/engines/engine[1]/n2-actual"); + + if ((powered1 or getprop("/systems/fadec/powerup") or getprop("/systems/fadec/eng1-off-power")) and N1Mode1 == 0) { + setprop("/systems/fadec/eng1/epr", 1); + } else { + setprop("/systems/fadec/eng1/epr", 0); + } + + if ((powered2 or getprop("/systems/fadec/powerup") or getprop("/systems/fadec/eng2-off-power")) and N1Mode2 == 0) { + setprop("/systems/fadec/eng2/epr", 1); + } else { + setprop("/systems/fadec/eng2/epr", 0); + } + + if (powered1 or getprop("/systems/fadec/powerup") or getprop("/systems/fadec/eng1-off-power")) { + setprop("/systems/fadec/eng1/egt", 1); + setprop("/systems/fadec/eng1/ff", 1); + } else { + setprop("/systems/fadec/eng1/egt", 0); + setprop("/systems/fadec/eng1/ff", 0); + } + + if (powered2 or getprop("/systems/fadec/powerup") or getprop("/systems/fadec/eng2-off-power")) { + setprop("/systems/fadec/eng2/egt", 1); + setprop("/systems/fadec/eng2/ff", 1); + } else { + setprop("/systems/fadec/eng2/egt", 0); + setprop("/systems/fadec/eng2/ff", 0); + } + + if (powered1 and N11 >= 3.5) { + setprop("/systems/fadec/eng1/n1", 1); + } else { + setprop("/systems/fadec/eng1/n1", 0); + } + + if (powered2 and N12 >= 3.5) { + setprop("/systems/fadec/eng2/n1", 1); + } else { + setprop("/systems/fadec/eng2/n1", 0); + } + + if (powered1 and N21 >= 3.5) { + setprop("/systems/fadec/eng1/n2", 1); + } else { + setprop("/systems/fadec/eng1/n2", 0); + } + + if (powered2 and N22 >= 3.5) { + setprop("/systems/fadec/eng2/n2", 1); + } else { + setprop("/systems/fadec/eng2/n2", 0); + } + }, +}; diff --git a/Nasal/libraries.nas b/Nasal/libraries.nas index 7522c476..a9dfecbf 100644 --- a/Nasal/libraries.nas +++ b/Nasal/libraries.nas @@ -177,6 +177,7 @@ var systemsInit = func { systems.eng_init(); systems.fire_init(); systems.autobrake_init(); + fadec.FADEC.init(); fmgc.APinit(); fmgc.FMGCinit(); mcdu1.MCDU_init(); @@ -205,7 +206,7 @@ var systemsLoop = maketimer(0.1, func { systems.ADIRS.loop(); libraries.ECAM.loop(); libraries.BUTTONS.update(); - fadec.fadecLoop(); + fadec.FADEC.loop(); 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 b840a9e9..b60249d1 100644 --- a/revision.txt +++ b/revision.txt @@ -1 +1 @@ -4658 \ No newline at end of file +4659 \ No newline at end of file From 560c375ad37d208989cc11190a8797a02f2382ca Mon Sep 17 00:00:00 2001 From: Joshua Davidson Date: Fri, 28 Sep 2018 17:00:56 -0400 Subject: [PATCH 08/10] System: Fix buggy, broken, and incorrect RAT logic, fixes #45 --- Models/Instruments/Lower-ECAM/Lower-ECAM.nas | 2 + Models/Instruments/OHpanel/OHpanel.xml | 83 +++++++++++++++++++- Nasal/electrical.nas | 20 +++-- Nasal/hydraulics.nas | 2 +- revision.txt | 2 +- 5 files changed, 99 insertions(+), 10 deletions(-) diff --git a/Models/Instruments/Lower-ECAM/Lower-ECAM.nas b/Models/Instruments/Lower-ECAM/Lower-ECAM.nas index 457daece..f9dc911d 100644 --- a/Models/Instruments/Lower-ECAM/Lower-ECAM.nas +++ b/Models/Instruments/Lower-ECAM/Lower-ECAM.nas @@ -1054,10 +1054,12 @@ var canvas_lowerECAM_elec = { if (getprop("/controls/electrical/switches/emer-gen") == 0) { me["EMERGEN-group"].hide(); me["ELEC-Line-Emergen-ESSTR"].hide(); + me["ELEC-Line-Emergen-ESSTR-off"].show(); me["EMERGEN-Label-off"].show(); } else { me["EMERGEN-group"].show(); me["ELEC-Line-Emergen-ESSTR"].show(); + me["ELEC-Line-Emergen-ESSTR-off"].hide(); me["EMERGEN-Label-off"].hide(); } diff --git a/Models/Instruments/OHpanel/OHpanel.xml b/Models/Instruments/OHpanel/OHpanel.xml index 51c88147..d7722b72 100644 --- a/Models/Instruments/OHpanel/OHpanel.xml +++ b/Models/Instruments/OHpanel/OHpanel.xml @@ -3312,7 +3312,88 @@ - + + + ELEC RAT MAN pick + pick + EmerElecManOnBtn + + + false + + + + + controls/OH/protectors/elecratman + 1 + + + + systems/electrical/bus/dcbat + 25 + + + systems/electrical/bus/dc-ess + 25 + + + + + property-toggle + controls/electrical/switches/rat-man + + + + + controls/OH/protectors/elecratman + 1 + + + nasal + + + + + + + pick + EmerManOnGuard + + + + property-assign + controls/OH/protectors/elecratman + 1 + + + + property-assign + controls/OH/protectors/elecratman + 0 + + + nasal + + + + + + + + rotate + EmerManOnGuard + controls/OH/protectors/elecratman + -145 + + -0.00273 + -0.20848 + -0.02796 + -0.00420 + -0.19657 + -0.02796 + + + AC pack flow pick diff --git a/Nasal/electrical.nas b/Nasal/electrical.nas index 73600e7a..8fa710da 100644 --- a/Nasal/electrical.nas +++ b/Nasal/electrical.nas @@ -34,6 +34,7 @@ setlistener("/sim/signals/fdm-initialized", func { var ac_ess_feed_sw = getprop("/controls/electrical/switches/ac-ess-feed"); var battery1_sw = getprop("/controls/electrical/switches/battery1"); var battery2_sw = getprop("/controls/electrical/switches/battery2"); + var manrat = getprop("/controls/electrical/switches/rat-man"); var battery1_volts = getprop("/systems/electrical/battery1-volts"); var battery2_volts = getprop("/systems/electrical/battery2-volts"); var battery1_amps = getprop("/systems/electrical/battery1-amps"); @@ -62,8 +63,7 @@ setlistener("/sim/signals/fdm-initialized", func { var galley_shed = getprop("/systems/electrical/extra/galleyshed"); var emergen = getprop("/controls/electrical/switches/emer-gen"); var ias = getprop("/instrumentation/airspeed-indicator/indicated-speed-kt"); - var rat = getprop("/controls/hydraulic/rat"); - var manrat = getprop("/controls/hydraulic/rat-man"); + var rat = getprop("/controls/electrical/rat"); var ac_ess_fail = getprop("/systems/failures/elec-ac-ess"); var batt1_fail = getprop("/systems/failures/elec-batt1"); var batt2_fail = getprop("/systems/failures/elec-batt2"); @@ -158,6 +158,7 @@ var ELEC = { setprop("/controls/electrical/switches/ac-ess-feed", 0); setprop("/controls/electrical/switches/battery1", 0); setprop("/controls/electrical/switches/battery2", 0); + setprop("/controls/electrical/switches/rat-man", 0); setprop("/systems/electrical/battery1-volts", 26.5); setprop("/systems/electrical/battery2-volts", 26.5); setprop("/systems/electrical/battery1-amps", 0); @@ -206,6 +207,7 @@ var ELEC = { setprop("/systems/electrical/idg2-fault", 0); setprop("/controls/electrical/xtie/xtieL", 0); setprop("/controls/electrical/xtie/xtieR", 0); + setprop("/controls/electrical/rat", 0); setprop("/systems/electrical/battery-available", 0); setprop("/systems/electrical/dc2-available", 0); # Below are standard FG Electrical stuff to keep things working when the plane is powered @@ -280,6 +282,7 @@ var ELEC = { ac_ess_feed_sw = getprop("/controls/electrical/switches/ac-ess-feed"); battery1_sw = getprop("/controls/electrical/switches/battery1"); battery2_sw = getprop("/controls/electrical/switches/battery2"); + manrat = getprop("/controls/electrical/switches/rat-man"); battery1_volts = getprop("/systems/electrical/battery1-volts"); battery2_volts = getprop("/systems/electrical/battery2-volts"); battery1_percent = getprop("/systems/electrical/battery1-percent"); @@ -302,8 +305,7 @@ var ELEC = { galley_shed = getprop("/systems/electrical/extra/galleyshed"); emergen = getprop("/controls/electrical/switches/emer-gen"); ias = getprop("/instrumentation/airspeed-indicator/indicated-speed-kt"); - rat = getprop("/controls/hydraulic/rat"); - manrat = getprop("/controls/hydraulic/rat-man"); + rat = getprop("/controls/electrical/rat"); ac_ess_fail = getprop("/systems/failures/elec-ac-ess"); batt1_fail = getprop("/systems/failures/elec-batt1"); batt2_fail = getprop("/systems/failures/elec-batt2"); @@ -594,13 +596,17 @@ var ELEC = { setprop("/systems/electrical/extra/galleyshed", 0); } - if (((ac1 == 0 and ac2 == 0 and ias >= 100) or manrat) and replay == 0) { + if (ac1 < 110 and ac2 < 110 and ias >= 100 and replay == 0) { setprop("/controls/hydraulic/rat-deployed", 1); - setprop("/controls/hydraulic/rat", 1); + setprop("/controls/electrical/rat", 1); + setprop("/controls/electrical/switches/emer-gen", 1); + } else if (manrat) { + setprop("/controls/hydraulic/rat-deployed", 1); + setprop("/controls/electrical/rat", 1); setprop("/controls/electrical/switches/emer-gen", 1); } - if (ias < 100 or (ac1 == 1) or (ac2 == 1)) { + if (ias < 100 or ac1 >= 110 or ac2 >= 110) { setprop("/controls/electrical/switches/emer-gen", 0); } diff --git a/Nasal/hydraulics.nas b/Nasal/hydraulics.nas index 05a43167..2d5319d4 100644 --- a/Nasal/hydraulics.nas +++ b/Nasal/hydraulics.nas @@ -125,7 +125,7 @@ var HYD = { setprop("/systems/hydraulic/ptu-active", 0); } - if ((rat_man_sw == 1 or getprop("/controls/electrical/switches/emer-gen") == 1) and gs > 100) { + if ((rat_man_sw == 1 or getprop("/controls/electrical/switches/emer-gen") == 1) and gs >= 100) { setprop("/controls/hydraulic/rat", 1); setprop("/controls/hydraulic/rat-deployed", 1); } else if (gs < 100) { diff --git a/revision.txt b/revision.txt index b60249d1..1399793f 100644 --- a/revision.txt +++ b/revision.txt @@ -1 +1 @@ -4659 \ No newline at end of file +4660 \ No newline at end of file From a35fe463921fbd305f05629388fa9b29ae72ff2b Mon Sep 17 00:00:00 2001 From: Joshua Davidson Date: Fri, 28 Sep 2018 17:02:37 -0400 Subject: [PATCH 09/10] Sim: Fix something I forgot to init --- A320-main.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/A320-main.xml b/A320-main.xml index 64f507ef..336ec80f 100644 --- a/A320-main.xml +++ b/A320-main.xml @@ -615,6 +615,7 @@ 0 + 0 0 0 0 From 6dd36477bab91dfbef09731dc54d106f3067aa7f Mon Sep 17 00:00:00 2001 From: Joshua Davidson Date: Fri, 28 Sep 2018 17:33:01 -0400 Subject: [PATCH 10/10] MCDU: Fix ADF on RADNAV being STUPID --- Models/Instruments/MCDU/MCDU.nas | 4 ++-- Nasal/FMGC.nas | 2 ++ revision.txt | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Models/Instruments/MCDU/MCDU.nas b/Models/Instruments/MCDU/MCDU.nas index 7bb54580..3efd934f 100644 --- a/Models/Instruments/MCDU/MCDU.nas +++ b/Models/Instruments/MCDU/MCDU.nas @@ -643,7 +643,7 @@ var canvas_MCDU_base = { if (getprop("/FMGC/internal/adf1freq-set") == 1) { me["Simple_L5"].setFont(default); me["Simple_L5"].setFontSize(normal); - me["Simple_L5"].setText(sprintf("%3.0f", adf1)); + me["Simple_L5"].setText(sprintf("%s", adf1)); } else { me["Simple_L5"].setFont(symbol); me["Simple_L5"].setFontSize(small); @@ -663,7 +663,7 @@ var canvas_MCDU_base = { if (getprop("/FMGC/internal/adf2freq-set") == 1) { me["Simple_R5"].setFont(default); me["Simple_R5"].setFontSize(normal); - me["Simple_R5"].setText(sprintf("%3.0f", adf2)); + me["Simple_R5"].setText(sprintf("%s", adf2)); } else { me["Simple_R5"].setFont(symbol); me["Simple_R5"].setFontSize(small); diff --git a/Nasal/FMGC.nas b/Nasal/FMGC.nas index 0d990054..d36f1b07 100644 --- a/Nasal/FMGC.nas +++ b/Nasal/FMGC.nas @@ -25,6 +25,8 @@ setprop("/FMGC/internal/ils1-mcdu", "XXX/999.99"); setprop("/FMGC/internal/ils2-mcdu", "XXX/999.99"); setprop("/FMGC/internal/vor1-mcdu", "XXX/999.99"); setprop("/FMGC/internal/vor2-mcdu", "999.99/XXX"); +setprop("/FMGC/internal/adf1-mcdu", "XXX/999.99"); +setprop("/FMGC/internal/adf2-mcdu", "999.99/XXX"); setprop("/gear/gear[0]/wow-fmgc", 1); setlistener("/sim/signals/fdm-initialized", func { diff --git a/revision.txt b/revision.txt index 1399793f..4c7368f7 100644 --- a/revision.txt +++ b/revision.txt @@ -1 +1 @@ -4660 \ No newline at end of file +4661 \ No newline at end of file