From ddce64bce8e382dbf67268fe99146381eecfb453 Mon Sep 17 00:00:00 2001 From: Jonathan Redpath Date: Sat, 24 Mar 2018 17:43:41 +0000 Subject: [PATCH] Hook up ELACS --- Models/Instruments/OHpanel/OHpanel.xml | 8 +--- Nasal/electrical.nas | 59 +++++++++++++++++++------- Nasal/it-fbw.nas | 21 +++++++-- 3 files changed, 62 insertions(+), 26 deletions(-) diff --git a/Models/Instruments/OHpanel/OHpanel.xml b/Models/Instruments/OHpanel/OHpanel.xml index 9d76c1f1..bd7ddc82 100644 --- a/Models/Instruments/OHpanel/OHpanel.xml +++ b/Models/Instruments/OHpanel/OHpanel.xml @@ -1014,11 +1014,7 @@ - systems/failures/elac1 - 1 - - - controls/fctl/elac1 + /systems/failures/elac1-fault 1 @@ -1215,7 +1211,7 @@ - systems/failures/elac2 + systems/failures/elac2-fault 1 diff --git a/Nasal/electrical.nas b/Nasal/electrical.nas index be8063ba..4ab88759 100644 --- a/Nasal/electrical.nas +++ b/Nasal/electrical.nas @@ -131,10 +131,44 @@ var light = { } }; +var fctlpoweruptest = func { + if (getprop("/systems/electrical/battery-available") == 0 and (getprop("/controls/electrical/switches/battery1") == 1 or getprop("/controls/electrical/switches/battery2") == 1)) { + setprop("/systems/failures/elac1-fault", 1); + setprop("/systems/failures/sec1", 1); + setprop("/systems/electrical/battery-available", 1); + setprop("/systems/electrical/elac1-test", 1); + settimer(func(){ + setprop("/systems/failures/elac1-fault", 0); + setprop("/systems/electrical/elac1-test", 0); + },8); + settimer(func(){ + setprop("/systems/failures/sec1", 0); + },8.5); + } + + gen1_sw = getprop("/controls/electrical/switches/gen1"); + gen2_sw = getprop("/controls/electrical/switches/gen2"); + gen_apu_sw = getprop("/controls/electrical/switches/gen-apu"); + gen_ext_sw = getprop("/controls/electrical/switches/gen-ext"); + + if (getprop("/systems/electrical/dc2-available") == 0 and getprop("/systems/electrical/bus/dc2") > 25) { + setprop("/systems/failures/elac2-fault", 1); + setprop("/systems/electrical/dc2-available", 1); + setprop("/systems/electrical/elac2-test", 1); + settimer(func(){ + setprop("/systems/failures/elac2-fault", 0); + setprop("/systems/electrical/elac2-test", 0); + },8); + } +} + + + # Main Elec System var ELEC = { init: func() { + setprop("/systems/electrical/elac-test", 0); setprop("/controls/switches/annun-test", 0); setprop("/systems/electrical/nav-lights-power", 0); setprop("/controls/electrical/switches/galley", 1); @@ -190,6 +224,7 @@ var ELEC = { setprop("/controls/electrical/xtie/xtieL", 0); setprop("/controls/electrical/xtie/xtieR", 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 setprop("/systems/electrical/outputs/adf", 0); setprop("/systems/electrical/outputs/audio-panel", 0); @@ -304,10 +339,17 @@ var ELEC = { setprop("/systems/electrical/battery-available", 0); } + if (dc2 >= 25) { + fctlpoweruptest(); + } else { + setprop("/systems/electrical/dc2-available", 0); + } + dcbat = getprop("/systems/electrical/bus/dcbat"); if (extpwr_on and gen_ext_sw) { setprop("/systems/electrical/gen-ext", 1); + } else { setprop("/systems/electrical/gen-ext", 0); } @@ -740,19 +782,4 @@ var decharge1 = maketimer(69, func { # interval is at 69 seconds, to allow about var decharge2 = maketimer(69, func { bat2_volts = getprop("/systems/electrical/battery2-volts"); setprop("/systems/electrical/battery2-volts", bat2_volts - 0.1); -}); - -var fctlpoweruptest = func { - if (getprop("/systems/electrical/battery-available") == 0) { - setprop("/systems/failures/elac1", 1); - setprop("/systems/failures/sec1", 1); - setprop("/systems/electrical/battery-available", 1); - settimer(func(){ - setprop("/systems/failures/elac1", 0); - },8); - settimer(func(){ - setprop("/systems/failures/sec1", 0); - },8.5); - } -} - +}); \ No newline at end of file diff --git a/Nasal/it-fbw.nas b/Nasal/it-fbw.nas index 2007a1f8..a1a84610 100644 --- a/Nasal/it-fbw.nas +++ b/Nasal/it-fbw.nas @@ -54,6 +54,7 @@ var update_loop = func { var fac2_fail = getprop("/systems/failures/fac2"); var ac_ess = getprop("/systems/electrical/bus/ac-ess"); + var dc_ess = getprop("/systems/electrical/bus/dc-ess"); var dc_ess_shed = getprop("/systems/electrical/bus/dc-ess-shed"); var ac1 = getprop("/systems/electrical/bus/ac1"); var ac2 = getprop("/systems/electrical/bus/ac2"); @@ -61,17 +62,29 @@ var update_loop = func { var dc2 = getprop("/systems/electrical/bus/dc2"); var battery1_sw = getprop("/controls/electrical/switches/battery1"); var battery2_sw = getprop("/controls/electrical/switches/battery2"); + var elac1_test = getprop("/systems/electrical/elac1-test"); + var elac2_test = getprop("/systems/electrical/elac2-test"); - if (elac1_sw and !elac1_fail and ac_ess >= 110) { + if (elac1_sw and !elac1_fail and (dc_ess >= 25 or battery1_sw) and !elac1_test) { setprop("/systems/fctl/elac1", 1); - } else { + setprop("/systems/failures/elac1-fault", 0); + } else if (elac1_sw and (elac1_fail or (dc_ess < 25 and !battery1_sw)) and !elac1_test) { + setprop("/systems/failures/elac1-fault", 1); setprop("/systems/fctl/elac1", 0); + } else if (!elac1_test) { + setprop("/systems/failures/elac1-fault", 0); + setprop("/systems/fctl/elac1", 1); } - if (elac2_sw and !elac2_fail and ac_ess >= 110) { + if (elac2_sw and !elac2_fail and (dc2 >= 25 or battery2_sw) and !elac2_test) { setprop("/systems/fctl/elac2", 1); - } else { + setprop("/systems/failures/elac2-fault", 0); + } else if (elac2_sw and (elac2_fail or (dc2 < 25 and !battery2_sw)) and !elac2_test) { + setprop("/systems/failures/elac2-fault", 1); setprop("/systems/fctl/elac2", 0); + } else if (!elac2_test) { + setprop("/systems/failures/elac2-fault", 0); + setprop("/systems/fctl/elac2", 1); } if (sec1_sw and !sec1_fail and ac_ess >= 110) {