Improve Electrical System

This commit is contained in:
Jonathan Redpath 2017-10-31 15:55:16 +00:00
parent fba8e3d909
commit 2f6186ce30
6 changed files with 79 additions and 13 deletions

View file

@ -203,6 +203,16 @@
<live>true</live>
</checkbox>
<checkbox>
<label>Blower Fan</label>
<halign>left</halign>
<property>/systems/failures/ventfan</property>
<binding>
<command>dialog-apply</command>
</binding>
<live>true</live>
</checkbox>
</group>
<vrule/>

View file

@ -1180,6 +1180,11 @@ var canvas_lowerECAM_elec = {
me["BAT2a"].show();
me["BAT2off"].hide();
}
me["BAT1volts"].setText(sprintf("%2.0f", getprop("/systems/electrical/battery1-volts")));
me["BAT2volts"].setText(sprintf("%2.0f", getprop("/systems/electrical/battery2-volts")));
me["BAT1amps"].setText(sprintf("%2.0f", getprop("/systems/electrical/battery1-amps")));
me["BAT2amps"].setText(sprintf("%2.0f", getprop("/systems/electrical/battery2-amps")));
me.updateBottomStatus();
},
};

View file

@ -17,9 +17,7 @@
<type>select</type>
<object-name>ACESSFeedBtn1F</object-name>
<object-name>ACESSFeedBtn2O</object-name>
<object-name>ACPack1Btn1F</object-name>
<object-name>ACPack1Btn2O</object-name>
<object-name>ACPack2Btn1F</object-name>
<object-name>ACPack2Btn2O</object-name>
<object-name>APUBleedBtn1F</object-name>
<object-name>APUBleedBtn2O</object-name>
@ -47,11 +45,19 @@
<object-name>Eng2FireAgt2Btn1S</object-name>
<object-name>Eng2FireAgt2Btn2D</object-name>
<object-name>ExtPwrBtn2O</object-name>
<object-name>Gen1Btn1F</object-name>
<object-name>Gen1Btn2O</object-name>
<object-name>Gen2Btn1F</object-name>
<object-name>Gen2Btn2O</object-name>
<object-name>RamAirBtn2O</object-name>
<!-- the following come on when you turn on BAT 2 -->
<object-name>ELAC1Btn1F</object-name>
<object-name>FAC1Btn1F</object-name>
<object-name>SECBtn1F</object-name>
<object-name>VentBlowBtn1F</object-name>
<object-name>Gen1Btn1F</object-name>
<object-name>Gen2Btn1F</object-name>
<object-name>ACPack1Btn1F</object-name>
<object-name>ACPack2Btn1F</object-name>
<condition>
<or>
<greater-than-equals>
@ -98,7 +104,6 @@
<object-name>CFuelTank2Btn1F</object-name>
<object-name>CFuelTank2Btn2O</object-name>
<object-name>CrewOxyBtn2O</object-name>
<object-name>ELAC1Btn1F</object-name>
<object-name>ELAC1Btn2O</object-name>
<object-name>ELAC2Btn1F</object-name>
<object-name>ELAC2Btn2O</object-name>
@ -117,7 +122,6 @@
<object-name>Eng2ManStartBtn2O</object-name>
<object-name>EvacCommandBtn1E</object-name>
<object-name>EvacCommandBtn2O</object-name>
<object-name>FAC1Btn1F</object-name>
<object-name>FAC1Btn2O</object-name>
<object-name>FAC2Btn1F</object-name>
<object-name>FAC2Btn2O</object-name>
@ -165,13 +169,11 @@
<object-name>RFuelTank1Btn2O</object-name>
<object-name>RFuelTank2Btn1F</object-name>
<object-name>RFuelTank2Btn2O</object-name>
<object-name>SEC1Btn1F</object-name>
<object-name>SEC1Btn2O</object-name>
<object-name>SEC2Btn1F</object-name>
<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>
@ -220,7 +222,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>
@ -248,6 +249,23 @@
</diffuse>
</animation>
<!-- Ventilation -->
<animation>
<type>select</type>
<object-name>VentBlowBtn1F</object-name>
<condition>
<or>
<equals>
<property>/systems/ventilation/ventfan-fault</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>

View file

@ -538,7 +538,7 @@ var master_elec = func {
setprop("/systems/electrical/batt2-fault", 0);
}
if ((gen1_fail and gen1_sw) or (gen1_sw and stateL != 3)) {
if (getprop("systems/electrical/battery2-amps") > 120 and (gen1_fail and gen1_sw) or (gen1_sw and stateL != 3)) {
setprop("/systems/electrical/gen1-fault", 1);
} else {
setprop("/systems/electrical/gen1-fault", 0);
@ -556,13 +556,44 @@ var master_elec = func {
setprop("/systems/electrical/apugen-fault", 0);
}
if ((gen2_fail and gen2_sw) or (gen2_sw and stateR != 3)) {
if (getprop("systems/electrical/battery2-amps") > 120 and (gen2_fail and gen2_sw) or (gen2_sw and stateR != 3)) {
setprop("/systems/electrical/gen2-fault", 1);
} else {
setprop("/systems/electrical/gen2-fault", 0);
}
if (getprop("/systems/failures/sec1-fail-time") + 5 >= getprop("/sim/time/elapsed-sec")) {
setprop("/systems/failures/sec1", 1);
} else {
setprop("/systems/failures/sec1", 0);
setprop("/systems/failures/sec1-fail-time", 0);
}
if (getprop("/systems/electrical/bus/ac1") >= 110 or getprop("/systems/electrical/bus/dc1") >= 25 or getprop("/systems/failures/ventfan") == 1) {
setprop("/systems/ventilation/ventfan-fault", 0);
} else if (getprop("/systems/electrical/battery2-amps") > 120) {
setprop("/systems/ventilation/ventfan-fault", 1);
}
}
setlistener("/controls/electrical/switches/battery2", func {
if (getprop("/controls/electrical/switches/battery2") == 1) {
setprop("/systems/failures/elac1", 1);
setprop("/systems/failures/sec1", 1);
setprop("/systems/failures/fac1", 1);
setprop("/systems/failures/sec1-fail-time", getprop("/sim/time/elapsed-sec"));
} else if (getprop("/systems/electrical/bus/dc-ess") >= 25 or getprop("/systems/electrical/bus/ac-ess") >= 25) {
setprop("/systems/failures/elac1", 0);
setprop("/systems/failures/sec1", 0);
setprop("/systems/failures/fac1", 0);
} else {
setprop("/systems/failures/elac1", 1);
setprop("/systems/failures/sec1", 1);
setprop("/systems/failures/fac1", 1);
}
});
###################
# Update Function #
###################

View file

@ -27,6 +27,8 @@ var qty2 = math.round((rand() * 5 ) + 20, 0.1);
setprop("/engines/engine[0]/oil-qt-actual", qty1);
setprop("/engines/engine[1]/oil-qt-actual", qty2);
# Failures
setprop("/systems/failures/sec1-fail-time", 0);
##########
# Lights #
##########

View file

@ -369,13 +369,13 @@ var master_pneu = func {
setprop("/systems/pneumatic/bleedapu-fault", 0);
}
if ((pack1_fail and pack1_sw) or (pack1_sw and pack1 <= 5)) {
if (getprop("systems/electrical/battery2-amps") > 120 and (pack1_fail and pack1_sw) or (pack1_sw and pack1 <= 5)) {
setprop("/systems/pneumatic/pack1-fault", 1);
} else {
setprop("/systems/pneumatic/pack1-fault", 0);
}
if ((pack2_fail and pack2_sw) or (pack2_sw and pack2 <= 5)) {
if (getprop("systems/electrical/battery2-amps") > 120 and (pack2_fail and pack2_sw) or (pack2_sw and pack2 <= 5)) {
setprop("/systems/pneumatic/pack2-fault", 1);
} else {
setprop("/systems/pneumatic/pack2-fault", 0);