Merge branch 'master' into Lower-ECAM

This commit is contained in:
Joshua Davidson 2018-05-17 00:17:57 -04:00
commit cc247b21c0
2 changed files with 79 additions and 38 deletions

View file

@ -1,6 +1,5 @@
# A3XX Electrical System
# Joshua Davidson (it0uchpods) and Jonathan Redpath (legoboyvdlp)
# Some parts are in JSBsim system!
##############################################
# Copyright (c) Joshua Davidson (it0uchpods) #
@ -36,6 +35,12 @@ setlistener("/sim/signals/fdm-initialized", func {
var battery2_sw = getprop("/controls/electrical/switches/battery2");
var battery1_volts = getprop("/systems/electrical/battery1-volts");
var battery2_volts = getprop("/systems/electrical/battery2-volts");
var battery1_amps = getprop("/systems/electrical/battery1-amps");
var battery2_amps = getprop("/systems/electrical/battery2-amps");
var battery1_percent = getprop("/systems/electrical/battery1-percent");
var battery2_percent = getprop("/systems/electrical/battery2-percent");
var battery1_percent_calc = 0;
var battery2_percent_calc = 0;
var rpmapu = getprop("/systems/apu/rpm");
var extpwr_on = getprop("/controls/switches/cart");
var stateL = getprop("/engines/engine[0]/state");
@ -156,6 +161,8 @@ var ELEC = {
setprop("/systems/electrical/battery2-volts", 26.5);
setprop("/systems/electrical/battery1-amps", 0);
setprop("/systems/electrical/battery2-amps", 0);
setprop("/systems/electrical/battery1-percent", 68);
setprop("/systems/electrical/battery2-percent", 68);
setprop("/systems/electrical/bus/dc1", 0);
setprop("/systems/electrical/bus/dc2", 0);
setprop("/systems/electrical/bus/dcbat", 0);
@ -274,6 +281,8 @@ var ELEC = {
battery2_sw = getprop("/controls/electrical/switches/battery2");
battery1_volts = getprop("/systems/electrical/battery1-volts");
battery2_volts = getprop("/systems/electrical/battery2-volts");
battery1_percent = getprop("/systems/electrical/battery1-percent");
battery2_percent = getprop("/systems/electrical/battery2-percent");
rpmapu = getprop("/systems/apu/rpm");
extpwr_on = getprop("/controls/switches/cart");
stateL = getprop("/engines/engine[0]/state");
@ -304,19 +313,22 @@ var ELEC = {
replay = getprop("/sim/replay/replay-state");
wow = getprop("/gear/gear[1]/wow");
if (battery1_sw and !batt1_fail) {
if (battery1_volts >= 20 and battery1_sw and !batt1_fail) {
setprop("/systems/electrical/battery1-amps", dc_amps_std);
} else {
setprop("/systems/electrical/battery1-amps", 0);
}
if (battery2_sw and !batt2_fail) {
if (battery2_volts >= 20 and battery2_sw and !batt2_fail) {
setprop("/systems/electrical/battery2-amps", dc_amps_std);
} else {
setprop("/systems/electrical/battery2-amps", 0);
}
if (getprop("/systems/electrical/battery1-amps") > 120 or getprop("/systems/electrical/battery2-amps") > 120) {
battery1_amps = getprop("/systems/electrical/battery1-amps");
battery2_amps = getprop("/systems/electrical/battery2-amps");
if (battery1_amps > 120 or battery2_amps > 120) {
setprop("/systems/electrical/bus/dcbat", dc_volt_std);
} else {
setprop("/systems/electrical/bus/dcbat", 0);
@ -380,43 +392,43 @@ var ELEC = {
setprop("/systems/electrical/bus/dc1", dc_volt_std);
setprop("/systems/electrical/bus/dc-ess", dc_volt_std);
setprop("/systems/electrical/extra/tr1-volts", dc_volt_std);
setprop("/systems/electrical/bus/dc1-amps", dc_amps_std);
setprop("/systems/electrical/bus/dc1-amps", dc_amps_std);
setprop("/systems/electrical/extra/tr1-amps", tr_amps_std);
} else if (extpwr_on and gen_ext_sw and apu_ext_crosstie_sw) {
setprop("/systems/electrical/bus/dc1", dc_volt_std);
setprop("/systems/electrical/bus/dc-ess", dc_volt_std);
setprop("/systems/electrical/extra/tr1-volts", dc_volt_std);
setprop("/systems/electrical/bus/dc1-amps", dc_amps_std);
setprop("/systems/electrical/bus/dc1-amps", dc_amps_std);
setprop("/systems/electrical/extra/tr1-amps", tr_amps_std);
} else if (gen_apu and !genapu_fail and apu_ext_crosstie_sw) {
setprop("/systems/electrical/bus/dc1", dc_volt_std);
setprop("/systems/electrical/bus/dc-ess", dc_volt_std);
setprop("/systems/electrical/extra/tr1-volts", dc_volt_std);
setprop("/systems/electrical/bus/dc1-amps", dc_amps_std);
setprop("/systems/electrical/bus/dc1-amps", dc_amps_std);
setprop("/systems/electrical/extra/tr1-amps", tr_amps_std);
} else if (apu_ext_crosstie_sw == 1 and xtieL) {
setprop("/systems/electrical/bus/dc1", dc_volt_std);
setprop("/systems/electrical/bus/dc-ess", dc_volt_std);
setprop("/systems/electrical/extra/tr1-volts", dc_volt_std);
setprop("/systems/electrical/bus/dc1-amps", dc_amps_std);
setprop("/systems/electrical/bus/dc1-amps", dc_amps_std);
setprop("/systems/electrical/extra/tr1-amps", tr_amps_std);
} else if (emergen) {
setprop("/systems/electrical/bus/dc1", 0);
setprop("/systems/electrical/bus/dc-ess", dc_volt_std);
setprop("/systems/electrical/extra/tr1-volts", 0);
setprop("/systems/electrical/bus/dc1-amps", 0);
setprop("/systems/electrical/bus/dc1-amps", 0);
setprop("/systems/electrical/extra/tr1-amps", 0);
} else if (dcbat and ias >= 50) {
setprop("/systems/electrical/bus/dc1", 0);
setprop("/systems/electrical/bus/dc-ess", dc_volt_std);
setprop("/systems/electrical/extra/tr1-volts", 0);
setprop("/systems/electrical/bus/dc1-amps", 0);
setprop("/systems/electrical/bus/dc1-amps", 0);
setprop("/systems/electrical/extra/tr1-amps", 0);
} else {
setprop("/systems/electrical/bus/dc1", 0);
setprop("/systems/electrical/extra/tr1-volts", 0);
setprop("/systems/electrical/bus/dc1-amps", 0);
setprop("/systems/electrical/extra/tr1-amps", 0);
setprop("/systems/electrical/bus/dc1-amps", 0);
setprop("/systems/electrical/extra/tr1-amps", 0);
setprop("/systems/electrical/bus/dc-ess", 0);
}
@ -424,39 +436,37 @@ var ELEC = {
if (stateR == 3 and gen2_sw and !gen2_fail) {
setprop("/systems/electrical/bus/dc2", dc_volt_std);
setprop("/systems/electrical/extra/tr2-volts", dc_volt_std);
setprop("/systems/electrical/bus/dc2-amps", dc_amps_std);
setprop("/systems/electrical/bus/dc2-amps", dc_amps_std);
setprop("/systems/electrical/extra/tr2-amps", tr_amps_std);
} else if (extpwr_on and gen_ext_sw and apu_ext_crosstie_sw) {
setprop("/systems/electrical/bus/dc2", dc_volt_std);
setprop("/systems/electrical/extra/tr2-volts", dc_volt_std);
setprop("/systems/electrical/bus/dc2-amps", dc_amps_std);
setprop("/systems/electrical/bus/dc2-amps", dc_amps_std);
setprop("/systems/electrical/extra/tr2-amps", tr_amps_std);
} else if (gen_apu and !genapu_fail and apu_ext_crosstie_sw) {
setprop("/systems/electrical/bus/dc2", dc_volt_std);
setprop("/systems/electrical/extra/tr2-volts", dc_volt_std);
setprop("/systems/electrical/bus/dc2-amps", dc_amps_std);
setprop("/systems/electrical/bus/dc2-amps", dc_amps_std);
setprop("/systems/electrical/extra/tr2-amps", tr_amps_std);
} else if (apu_ext_crosstie_sw == 1 and xtieR) {
setprop("/systems/electrical/bus/dc2", dc_volt_std);
setprop("/systems/electrical/extra/tr2-volts", dc_volt_std);
setprop("/systems/electrical/bus/dc2-amps", dc_amps_std);
setprop("/systems/electrical/bus/dc2-amps", dc_amps_std);
setprop("/systems/electrical/extra/tr2-amps", tr_amps_std);
} else if (emergen) {
setprop("/systems/electrical/bus/dc2", 0);
setprop("/systems/electrical/extra/tr2-volts", 0);
setprop("/systems/electrical/bus/dc2-amps", 0);
setprop("/systems/electrical/bus/dc2-amps", 0);
setprop("/systems/electrical/extra/tr2-amps", 0);
} else if (dcbat and ias >= 50) {
setprop("/systems/electrical/bus/dc2", 0);
setprop("/systems/electrical/extra/tr2-volts", 0);
setprop("/systems/electrical/bus/dc2-amps", 0);
setprop("/systems/electrical/bus/dc2-amps", 0);
setprop("/systems/electrical/extra/tr2-amps", 0);
} else {
setprop("/systems/electrical/bus/dc2", 0);
setprop("/systems/electrical/extra/tr2-volts", 0);
setprop("/systems/electrical/bus/dc2-amps", 0);
setprop("/systems/electrical/bus/dc2-amps", 0);
setprop("/systems/electrical/extra/tr2-amps", 0);
}
@ -578,9 +588,9 @@ var ELEC = {
}
if (!gen_apu and !gen_ext_sw and (!gen1_sw or !gen2_sw)) {
setprop("/systems/electrical/extra/galleyshed", 1);
setprop("/systems/electrical/extra/galleyshed", 1);
} else {
setprop("/systems/electrical/extra/galleyshed", 0);
setprop("/systems/electrical/extra/galleyshed", 0);
}
if (((ac1 == 0 and ac2 == 0 and ias >= 100) or manrat) and replay == 0) {
@ -602,34 +612,65 @@ var ELEC = {
dc1 = getprop("/systems/electrical/bus/dc1");
dc2 = getprop("/systems/electrical/bus/dc2");
if (battery1_volts < 27.9 and (dc1 > 25 or dc2 > 25) and battery1_sw and !batt1_fail) {
if (getprop("/systems/electrical/battery1-time") + 60 < getprop("/sim/time/elapsed-sec")) {
setprop("/systems/electrical/battery1-volts", battery1_volts + 0.02877666); # Roughly 15mins to 25.9
if (battery1_percent < 100 and (dc1 > 25 or dc2 > 25) and battery1_sw and !batt1_fail) {
if (getprop("/systems/electrical/battery1-time") + 30 < getprop("/sim/time/elapsed-sec")) {
battery1_percent_calc = battery1_percent + 4.5; # Roughly 90 percent every 10 mins
if (battery1_percent_calc > 100) {
battery1_percent_calc = 100;
}
setprop("/systems/electrical/battery1-percent", battery1_percent_calc);
setprop("/systems/electrical/battery1-time", getprop("/sim/time/elapsed-sec"));
}
} else if (battery1_sw and !batt1_fail) {
if (getprop("/systems/electrical/battery1-time") + 60 < getprop("/sim/time/elapsed-sec")) {
setprop("/systems/electrical/battery1-volts", battery1_volts - 0.01438833); # Roughly 30mins from 25.9
} else if (battery1_amps >= 120 and battery1_sw and !batt1_fail) {
if (getprop("/systems/electrical/battery1-time") + 30 < getprop("/sim/time/elapsed-sec")) {
battery1_percent_calc = battery1_percent - 1.5; # Roughly 90 percent every 30 mins
if (battery1_percent_calc < 0) {
battery1_percent_calc = 0;
}
setprop("/systems/electrical/battery1-percent", battery1_percent_calc);
setprop("/systems/electrical/battery1-time", getprop("/sim/time/elapsed-sec"));
}
} else {
setprop("/systems/electrical/battery1-time", getprop("/sim/time/elapsed-sec"));
}
if (battery2_volts < 27.9 and (dc1 > 25 or dc2 > 25) and battery2_sw and !batt2_fail) {
if (getprop("/systems/electrical/battery2-time") + 60 < getprop("/sim/time/elapsed-sec")) {
setprop("/systems/electrical/battery2-volts", battery2_volts + 0.02877666); # Roughly 15mins to 25.9
if (battery1_percent < 100 and (dc1 > 25 or dc2 > 25) and battery2_sw and !batt2_fail) {
if (getprop("/systems/electrical/battery2-time") + 30 < getprop("/sim/time/elapsed-sec")) {
battery2_percent_calc = battery2_percent + 4.5; # Roughly 90 percent every 10 mins
if (battery2_percent_calc > 100) {
battery2_percent_calc = 100;
}
setprop("/systems/electrical/battery2-percent", battery2_percent_calc);
setprop("/systems/electrical/battery2-time", getprop("/sim/time/elapsed-sec"));
}
} else if (battery2_sw and !batt2_fail) {
if (getprop("/systems/electrical/battery2-time") + 60 < getprop("/sim/time/elapsed-sec")) {
setprop("/systems/electrical/battery2-volts", battery2_volts - 0.01438833); # Roughly 30mins from 25.9
} else if (battery2_amps >= 120 and battery2_sw and !batt2_fail) {
if (getprop("/systems/electrical/battery2-time") + 30 < getprop("/sim/time/elapsed-sec")) {
battery2_percent_calc = battery2_percent - 1.5; # Roughly 90 percent every 30 mins
if (battery2_percent_calc < 0) {
battery2_percent_calc = 0;
}
setprop("/systems/electrical/battery2-percent", battery2_percent_calc);
setprop("/systems/electrical/battery2-time", getprop("/sim/time/elapsed-sec"));
}
} else {
setprop("/systems/electrical/battery2-time", getprop("/sim/time/elapsed-sec"));
}
battery1_percent = getprop("/systems/electrical/battery1-percent");
battery2_percent = getprop("/systems/electrical/battery2-percent");
if (battery1_percent >= 10) {
setprop("/systems/electrical/battery1-volts", math.clamp(24 + (battery1_percent - 10) * (27.9 - 24) / (100 - 10), 24, 27.9));
} else {
setprop("/systems/electrical/battery1-volts", math.clamp(battery1_percent * (24) / (10), 0, 24));
}
if (battery2_percent >= 10) {
setprop("/systems/electrical/battery2-volts", math.clamp(24 + (battery2_percent - 10) * (27.9 - 24) / (100 - 10), 24, 30));
} else {
setprop("/systems/electrical/battery2-volts", math.clamp(battery2_percent * (24) / (10), 0, 24));
}
if (getprop("/systems/electrical/bus/ac-ess") < 110) {
if (getprop("/it-autoflight/output/ap1") == 1) {
setprop("/it-autoflight/input/ap1", 0);
@ -764,7 +805,7 @@ var ELEC = {
setprop("/controls/ventilation/blowFail", 0);
}
foreach(var screena; screens) {
foreach(var screena;screens) {
power_consumption = screena.power_consumption();
if (getprop(screena.elec_prop) != 0) {
setprop("/systems/electrical/DU/" ~ screena.name ~ "/watts", power_consumption);
@ -773,7 +814,7 @@ var ELEC = {
}
}
foreach(var lighta; lights) {
foreach(var lighta;lights) {
power_consumption = lighta.power_consumption();
if (getprop(lighta.elec_prop) != 0 and getprop(lighta.control_prop) != 0) {
setprop("/systems/electrical/light/" ~ lighta.name ~ "/watts", power_consumption);

View file

@ -1 +1 @@
4410
4411