Hook up FACS to elec

This commit is contained in:
Jonathan Redpath 2018-03-24 13:52:19 +00:00
parent 58b7778412
commit 2d954d5b5b
3 changed files with 82 additions and 27 deletions

View file

@ -71,6 +71,7 @@
<object-name>RamAirBtn2O</object-name>
<object-name>SEC1Btn1F</object-name>
<object-name>SEC1Btn2O</object-name>
<object-name>VentBlowBtn1F</object-name>
<condition>
<or>
<greater-than-equals>
@ -167,8 +168,6 @@
<object-name>SEC2Btn2O</object-name>
<object-name>SEC3Btn1F</object-name>
<object-name>SEC3Btn2O</object-name>
<object-name>VentBlowBtn1F</object-name>
<object-name>VentBlowBtn2O</object-name>
<object-name>VentExtractBtn1F</object-name>
<object-name>VentExtractBtn2O</object-name>
<object-name>WingAntiIceBtn1F</object-name>
@ -210,7 +209,6 @@
<object-name>Gen1LineBtn1S</object-name>
<object-name>Gen1LineBtn2O</object-name>
<object-name>RcdrGndCtlBtn2O</object-name>
<object-name>VentBlowBtn1F</object-name>
<object-name>VentBlowBtn2O</object-name>
<object-name>VentExtractBtn1F</object-name>
<object-name>VentExtractBtn2O</object-name>
@ -238,6 +236,24 @@
</diffuse>
</animation>
<!-- Ventilation -->
<animation>
<type>select</type>
<object-name>VentBlowBtn1F</object-name>
<condition>
<or>
<equals>
<property>/controls/ventilation/blowFail</property>
<value>1</value>
</equals>
<equals>
<property>controls/switches/annun-test</property>
<value>1</value>
</equals>
</or>
</condition>
</animation>
<!-- Cargo Smoke -->
<animation>
<type>select</type>
@ -1132,7 +1148,7 @@
<or>
<and>
<equals>
<property>systems/failures/fac1</property>
<property>systems/failures/fac1-fault</property>
<value>1</value>
</equals>
<equals>
@ -1400,7 +1416,7 @@
<or>
<and>
<equals>
<property>systems/failures/fac2</property>
<property>systems/failures/fac2-fault</property>
<value>1</value>
</equals>
<equals>
@ -2720,7 +2736,7 @@
</binding>
<binding>
<command>nasal</command>
<script>systems.batflash();</script>
<script>systems.fctlpoweruptest();</script>
</binding>
</action>
</animation>
@ -2785,7 +2801,7 @@
</binding>
<binding>
<command>nasal</command>
<script>systems.batflash();</script>
<script>systems.fctlpoweruptest();</script>
</binding>
</action>
</animation>

View file

@ -43,6 +43,7 @@ setlistener("/sim/signals/fdm-initialized", func {
var ac1 = getprop("/systems/electrical/bus/ac1");
var ac2 = getprop("/systems/electrical/bus/ac2");
var ac_ess = getprop("/systems/electrical/bus/ac-ess");
var dc_ess_shed = getprop("/systems/electrical/bus/dc-ess-shed");
var ac_ess_shed = getprop("/systems/electrical/bus/ac-ess-shed");
var dc1 = getprop("/systems/electrical/bus/dc1");
var dc2 = getprop("/systems/electrical/bus/dc2");
@ -163,6 +164,7 @@ var ELEC = {
setprop("/systems/electrical/bus/gen1-hz", 0);
setprop("/systems/electrical/bus/gen2-hz", 0);
setprop("/systems/electrical/bus/ac-ess", 0);
setprop("/systems/electrical/bus/dc-ess-shed", 0);
setprop("/systems/electrical/bus/ac-ess-shed", 0);
setprop("/systems/electrical/extra/ext-volts", 0);
setprop("/systems/electrical/extra/apu-volts", 0);
@ -269,6 +271,7 @@ var ELEC = {
ac1 = getprop("/systems/electrical/bus/ac1");
ac2 = getprop("/systems/electrical/bus/ac2");
ac_ess = getprop("/systems/electrical/bus/ac-ess");
dc_ess_shed = getprop("/systems/electrical/bus/dc-ess-shed");
ac_ess_shed = getprop("/systems/electrical/bus/ac-ess-shed");
dc1 = getprop("/systems/electrical/bus/dc1");
dc2 = getprop("/systems/electrical/bus/dc2");
@ -531,6 +534,12 @@ var ELEC = {
setprop("/controls/electrical/switches/emer-gen", 0);
}
if (emergen == 0 and ac1 == 0 and ac2 == 0) { # as far as I know dc ess is only shed when batteries only
setprop("/systems/electrical/bus/dc-ess-shed", 0);
} else {
setprop("/systems/electrical/bus/dc-ess-shed", ac_volt_std);
}
dc1 = getprop("/systems/electrical/bus/dc1");
dc2 = getprop("/systems/electrical/bus/dc2");
@ -688,6 +697,14 @@ var ELEC = {
setprop("/systems/electrical/gen2-fault", 0);
}
# these two are here because they are on whenever the battery switch is on with no ac source connected (youtube)
if ((battery1_sw or battery2_sw) and dc1 < 25 and ac1 < 110) {
setprop("/controls/ventilation/blowFail", 1);
} else {
setprop("/controls/ventilation/blowFail", 0);
}
foreach(var screena; screens) {
power_consumption = screena.power_consumption();
if (getprop(screena.elec_prop) != 0) {
@ -725,19 +742,17 @@ var decharge2 = maketimer(69, func {
setprop("/systems/electrical/battery2-volts", bat2_volts - 0.1);
});
var batflash = func {
var fctlpoweruptest = func {
if (getprop("/systems/electrical/battery-available") == 0) {
setprop("/systems/failures/elac1", 1);
setprop("/systems/failures/sec1", 1);
setprop("/systems/failures/fac1", 1);
setprop("/systems/electrical/battery-available", 1);
settimer(func(){
setprop("/systems/failures/elac1", 0);
},1.5);
},8);
settimer(func(){
setprop("/systems/failures/sec1", 0);
setprop("/systems/failures/fac1", 0);
},2);
},8.5);
}
}

View file

@ -52,7 +52,15 @@ var update_loop = func {
var sec3_fail = getprop("/systems/failures/sec3");
var fac1_fail = getprop("/systems/failures/fac1");
var fac2_fail = getprop("/systems/failures/fac2");
var ac_ess = getprop("/systems/electrical/bus/ac-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");
var dc1 = getprop("/systems/electrical/bus/dc1");
var dc2 = getprop("/systems/electrical/bus/dc2");
var battery1_sw = getprop("/controls/electrical/switches/battery1");
var battery2_sw = getprop("/controls/electrical/switches/battery2");
if (elac1_sw and !elac1_fail and ac_ess >= 110) {
setprop("/systems/fctl/elac1", 1);
@ -104,20 +112,36 @@ var update_loop = func {
setprop("/systems/failures/spoiler-r2", 1);
}
if (fac1_sw and !fac1_fail and ac_ess >= 110) {
if (fac1_sw and !fac1_fail and (ac_ess >= 110 or dc_ess_shed >= 25)) {
setprop("/systems/fctl/fac1", 1);
setprop("/systems/failures/rudder", 0);
setprop("/systems/failures/fac1-fault", 0);
} else if (fac1_sw and (battery1_sw or battery2_sw) and (fac1_fail or ac_ess < 110 or dc_ess_shed < 25)) {
setprop("/systems/failures/fac1-fault", 1);
setprop("/systems/fctl/fac1", 0);
if (!fac2_sw or fac2_fail) {
setprop("/systems/failures/rudder", 1);
}
} else {
setprop("/systems/failures/fac1-fault", 0);
setprop("/systems/fctl/fac1", 0);
if (!fac2_sw or fac2_fail) {
setprop("/systems/failures/rudder", 1);
}
}
if (fac2_sw and !fac2_fail and ac_ess >= 110) {
if (fac2_sw and !fac2_fail and (ac2 >= 110 or dc2 >= 25)) {
setprop("/systems/fctl/fac2", 1);
setprop("/systems/failures/fac2-fault", 0);
} else if (fac2_sw and (fac2_fail or ac2 < 110 or dc2 < 25)) {
setprop("/systems/failures/fac2-fault", 1);
setprop("/systems/fctl/fac2", 0);
if (!fac1_sw or fac1_fail) {
setprop("/systems/failures/rudder", 1);
}
} else {
setprop("/systems/fctl/fac2", 0);
setprop("/systems/failures/fac2-fault", 0);
if (!fac1_sw or fac1_fail) {
setprop("/systems/failures/rudder", 1);
}