2017-06-16 18:52:45 +00:00
|
|
|
# A3XX Electrical System
|
|
|
|
# Joshua Davidson (it0uchpods) and Jonathan Redpath (legoboyvdlp)
|
2017-04-06 02:24:04 +00:00
|
|
|
|
2017-08-16 20:53:35 +00:00
|
|
|
#########################################
|
|
|
|
# Copyright (c) it0uchpods Design Group #
|
|
|
|
#########################################
|
2017-07-13 17:30:33 +00:00
|
|
|
|
2017-04-25 17:13:15 +00:00
|
|
|
#############
|
|
|
|
# Init Vars #
|
|
|
|
#############
|
|
|
|
|
|
|
|
var ac_volt_std = 115;
|
|
|
|
var ac_volt_min = 110;
|
|
|
|
var dc_volt_std = 28;
|
|
|
|
var dc_volt_min = 25;
|
2017-05-04 13:30:53 +00:00
|
|
|
var dc_amps_std = 150;
|
|
|
|
var ac_hz_std = 400;
|
2017-04-06 02:24:04 +00:00
|
|
|
|
2017-07-11 18:52:21 +00:00
|
|
|
setlistener("/sim/signals/fdm-initialized", func {
|
|
|
|
var galley_sw = getprop("/controls/electrical/switches/galley");
|
|
|
|
var idg1_sw = getprop("/controls/electrical/switches/idg1");
|
|
|
|
var idg2_sw = getprop("/controls/electrical/switches/idg2");
|
|
|
|
var gen1_sw = getprop("/controls/electrical/switches/gen1");
|
|
|
|
var gen2_sw = getprop("/controls/electrical/switches/gen2");
|
|
|
|
var gen_apu_sw = getprop("/controls/electrical/switches/gen-apu");
|
|
|
|
var gen_ext_sw = getprop("/controls/electrical/switches/gen-ext");
|
|
|
|
var apu_ext_crosstie_sw = getprop("/controls/electrical/switches/apu-ext-crosstie");
|
|
|
|
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 battery1_volts = getprop("/systems/electrical/battery1-volts");
|
|
|
|
var battery2_volts = getprop("/systems/electrical/battery2-volts");
|
|
|
|
var rpmapu = getprop("/systems/apu/rpm");
|
|
|
|
var extpwr_on = getprop("/controls/switches/cart");
|
|
|
|
var stateL = getprop("/engines/engine[0]/state");
|
|
|
|
var stateR = getprop("/engines/engine[1]/state");
|
|
|
|
var xtieL = getprop("/controls/electrical/xtie/xtieL");
|
|
|
|
var xtieR = getprop("/controls/electrical/xtie/xtieR");
|
|
|
|
var ac1 = getprop("/systems/electrical/bus/ac1");
|
|
|
|
var ac2 = getprop("/systems/electrical/bus/ac2");
|
|
|
|
var ac_ess = getprop("/systems/electrical/bus/ac-ess");
|
|
|
|
var dc1 = getprop("/systems/electrical/bus/dc1");
|
|
|
|
var dc2 = getprop("/systems/electrical/bus/dc2");
|
|
|
|
var dcbat = getprop("/systems/electrical/bus/dcbat");
|
|
|
|
var dc_ess = getprop("/systems/electrical/bus/dc-ess");
|
|
|
|
var gen_1_volts = getprop("/systems/electrical/extra/gen1-volts");
|
2017-10-05 18:56:08 +00:00
|
|
|
var gen_2_volts = getprop("/systems/electrical/extra/gen2-volts");
|
2017-07-11 18:52:21 +00:00
|
|
|
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 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");
|
|
|
|
var gallery_fail = getprop("/systems/failures/elec-galley");
|
|
|
|
var genapu_fail = getprop("/systems/failures/elec-genapu");
|
|
|
|
var gen1_fail = getprop("/systems/failures/elec-gen1");
|
|
|
|
var gen2_fail = getprop("/systems/failures/elec-gen2");
|
|
|
|
var bat1_volts = getprop("/systems/electrical/battery1-volts");
|
|
|
|
var bat2_volts = getprop("/systems/electrical/battery2-volts");
|
2017-08-07 14:58:52 +00:00
|
|
|
var replay = getprop("/sim/replay/replay-state");
|
2017-07-11 18:52:21 +00:00
|
|
|
});
|
|
|
|
|
2017-04-06 02:24:04 +00:00
|
|
|
var elec_init = func {
|
|
|
|
setprop("/controls/switches/annun-test", 0);
|
2017-06-10 13:53:57 +00:00
|
|
|
setprop("/controls/electrical/switches/galley", 1);
|
2017-04-06 02:24:04 +00:00
|
|
|
setprop("/controls/electrical/switches/idg1", 0);
|
|
|
|
setprop("/controls/electrical/switches/idg2", 0);
|
2017-06-10 13:53:57 +00:00
|
|
|
setprop("/controls/electrical/switches/gen1", 1);
|
|
|
|
setprop("/controls/electrical/switches/gen2", 1);
|
2017-05-31 12:04:36 +00:00
|
|
|
setprop("/controls/electrical/switches/emer-gen", 0);
|
2017-06-10 13:53:57 +00:00
|
|
|
setprop("/controls/electrical/switches/gen-apu", 1);
|
2017-04-06 02:24:04 +00:00
|
|
|
setprop("/controls/electrical/switches/gen-ext", 0);
|
|
|
|
setprop("/controls/electrical/switches/apu-ext-crosstie", 1);
|
2017-04-07 18:09:40 +00:00
|
|
|
setprop("/controls/electrical/switches/ac-ess-feed", 1);
|
2017-04-06 02:24:04 +00:00
|
|
|
setprop("/controls/electrical/switches/battery1", 0);
|
|
|
|
setprop("/controls/electrical/switches/battery2", 0);
|
|
|
|
setprop("/systems/electrical/battery1-volts", 25.9);
|
|
|
|
setprop("/systems/electrical/battery2-volts", 25.9);
|
2017-05-04 13:30:53 +00:00
|
|
|
setprop("/systems/electrical/battery1-amps", 0);
|
|
|
|
setprop("/systems/electrical/battery2-amps", 0);
|
2017-04-06 02:24:04 +00:00
|
|
|
setprop("/systems/electrical/bus/dc1", 0);
|
|
|
|
setprop("/systems/electrical/bus/dc2", 0);
|
2017-05-11 20:03:55 +00:00
|
|
|
setprop("/systems/electrical/bus/dcbat", 0);
|
2017-05-04 13:30:53 +00:00
|
|
|
setprop("/systems/electrical/bus/dc1-amps", 0);
|
|
|
|
setprop("/systems/electrical/bus/dc2-amps", 0);
|
2017-04-07 18:09:40 +00:00
|
|
|
setprop("/systems/electrical/bus/dc-ess", 0);
|
2017-04-06 02:24:04 +00:00
|
|
|
setprop("/systems/electrical/bus/ac1", 0);
|
|
|
|
setprop("/systems/electrical/bus/ac2", 0);
|
2017-05-05 16:04:15 +00:00
|
|
|
setprop("/systems/electrical/bus/gen1-hz", 0);
|
|
|
|
setprop("/systems/electrical/bus/gen2-hz", 0);
|
2017-04-06 02:24:04 +00:00
|
|
|
setprop("/systems/electrical/bus/ac-ess", 0);
|
2017-05-04 20:06:21 +00:00
|
|
|
setprop("/systems/electrical/extra/ext-volts", 0);
|
|
|
|
setprop("/systems/electrical/extra/apu-volts", 0);
|
2017-05-08 11:30:17 +00:00
|
|
|
setprop("/systems/electrical/extra/gen1-volts", 0);
|
|
|
|
setprop("/systems/electrical/extra/gen2-volts", 0);
|
2017-05-05 15:34:52 +00:00
|
|
|
setprop("/systems/electrical/extra/ext-hz", 0);
|
|
|
|
setprop("/systems/electrical/extra/apu-hz", 0);
|
2017-05-08 11:30:17 +00:00
|
|
|
setprop("/systems/electrical/extra/galleyshed", 0);
|
2017-05-09 12:27:28 +00:00
|
|
|
setprop("/systems/electrical/gen-apu", 0);
|
2017-05-11 20:03:55 +00:00
|
|
|
setprop("/systems/electrical/gen-ext", 0);
|
|
|
|
setprop("/systems/electrical/on", 0);
|
2017-07-25 04:09:58 +00:00
|
|
|
setprop("/systems/electrical/galley-fault", 0);
|
|
|
|
setprop("/systems/electrical/idg1-fault", 0);
|
|
|
|
setprop("/systems/electrical/gen1-fault", 0);
|
|
|
|
setprop("/systems/electrical/apugen-fault", 0);
|
|
|
|
setprop("/systems/electrical/batt1-fault", 0);
|
|
|
|
setprop("/systems/electrical/batt2-fault", 0);
|
|
|
|
setprop("/systems/electrical/ac-ess-feed-fault", 0);
|
2017-10-05 18:46:05 +00:00
|
|
|
setprop("/systems/electrical/gen2-fault", 0);
|
|
|
|
setprop("/systems/electrical/idg2-fault", 0);
|
2017-04-06 02:24:04 +00:00
|
|
|
setprop("/controls/electrical/xtie/xtieL", 0);
|
|
|
|
setprop("/controls/electrical/xtie/xtieR", 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);
|
|
|
|
setprop("/systems/electrical/outputs/audio-panel[1]", 0);
|
|
|
|
setprop("/systems/electrical/outputs/autopilot", 0);
|
|
|
|
setprop("/systems/electrical/outputs/avionics-fan", 0);
|
|
|
|
setprop("/systems/electrical/outputs/beacon", 0);
|
|
|
|
setprop("/systems/electrical/outputs/bus", 0);
|
|
|
|
setprop("/systems/electrical/outputs/cabin-lights", 0);
|
|
|
|
setprop("/systems/electrical/outputs/dme", 0);
|
|
|
|
setprop("/systems/electrical/outputs/efis", 0);
|
|
|
|
setprop("/systems/electrical/outputs/flaps", 0);
|
|
|
|
setprop("/systems/electrical/outputs/fuel-pump", 0);
|
|
|
|
setprop("/systems/electrical/outputs/fuel-pump[1]", 0);
|
|
|
|
setprop("/systems/electrical/outputs/gps", 0);
|
|
|
|
setprop("/systems/electrical/outputs/gps-mfd", 0);
|
|
|
|
setprop("/systems/electrical/outputs/hsi", 0);
|
|
|
|
setprop("/systems/electrical/outputs/instr-ignition-switch", 0);
|
|
|
|
setprop("/systems/electrical/outputs/instrument-lights", 0);
|
|
|
|
setprop("/systems/electrical/outputs/landing-lights", 0);
|
|
|
|
setprop("/systems/electrical/outputs/map-lights", 0);
|
|
|
|
setprop("/systems/electrical/outputs/mk-viii", 0);
|
|
|
|
setprop("/systems/electrical/outputs/nav", 0);
|
|
|
|
setprop("/systems/electrical/outputs/nav[1]", 0);
|
2017-07-06 03:57:57 +00:00
|
|
|
setprop("/systems/electrical/outputs/nav[2]", 0);
|
|
|
|
setprop("/systems/electrical/outputs/nav[3]", 0);
|
2017-04-06 02:24:04 +00:00
|
|
|
setprop("/systems/electrical/outputs/pitot-head", 0);
|
|
|
|
setprop("/systems/electrical/outputs/stobe-lights", 0);
|
|
|
|
setprop("/systems/electrical/outputs/tacan", 0);
|
|
|
|
setprop("/systems/electrical/outputs/taxi-lights", 0);
|
|
|
|
setprop("/systems/electrical/outputs/transponder", 0);
|
|
|
|
setprop("/systems/electrical/outputs/turn-coordinator", 0);
|
2017-04-25 17:13:15 +00:00
|
|
|
elec_timer.start();
|
2016-11-04 22:13:12 +00:00
|
|
|
}
|
|
|
|
|
2017-04-25 17:13:15 +00:00
|
|
|
######################
|
|
|
|
# Main Electric Loop #
|
|
|
|
######################
|
|
|
|
|
2017-04-06 02:24:04 +00:00
|
|
|
var master_elec = func {
|
2017-07-11 18:52:21 +00:00
|
|
|
galley_sw = getprop("/controls/electrical/switches/galley");
|
|
|
|
idg1_sw = getprop("/controls/electrical/switches/idg1");
|
|
|
|
idg2_sw = getprop("/controls/electrical/switches/idg2");
|
|
|
|
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");
|
|
|
|
apu_ext_crosstie_sw = getprop("/controls/electrical/switches/apu-ext-crosstie");
|
|
|
|
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");
|
|
|
|
battery1_volts = getprop("/systems/electrical/battery1-volts");
|
|
|
|
battery2_volts = getprop("/systems/electrical/battery2-volts");
|
|
|
|
rpmapu = getprop("/systems/apu/rpm");
|
|
|
|
extpwr_on = getprop("/controls/switches/cart");
|
|
|
|
stateL = getprop("/engines/engine[0]/state");
|
|
|
|
stateR = getprop("/engines/engine[1]/state");
|
|
|
|
ac1 = getprop("/systems/electrical/bus/ac1");
|
|
|
|
ac2 = getprop("/systems/electrical/bus/ac2");
|
|
|
|
ac_ess = getprop("/systems/electrical/bus/ac-ess");
|
|
|
|
dc1 = getprop("/systems/electrical/bus/dc1");
|
|
|
|
dc2 = getprop("/systems/electrical/bus/dc2");
|
|
|
|
dcbat = getprop("/systems/electrical/bus/dcbat");
|
|
|
|
dc_ess = getprop("/systems/electrical/bus/dc-ess");
|
|
|
|
gen_1_volts = getprop("/systems/electrical/extra/gen1-volts");
|
2017-10-05 18:56:08 +00:00
|
|
|
gen_2_volts = getprop("/systems/electrical/extra/gen2-volts");
|
2017-07-11 18:52:21 +00:00
|
|
|
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");
|
|
|
|
ac_ess_fail = getprop("/systems/failures/elec-ac-ess");
|
|
|
|
batt1_fail = getprop("/systems/failures/elec-batt1");
|
|
|
|
batt2_fail = getprop("/systems/failures/elec-batt2");
|
|
|
|
gallery_fail = getprop("/systems/failures/elec-galley");
|
|
|
|
genapu_fail = getprop("/systems/failures/elec-genapu");
|
|
|
|
gen1_fail = getprop("/systems/failures/elec-gen1");
|
|
|
|
gen2_fail = getprop("/systems/failures/elec-gen2");
|
2017-08-07 14:58:52 +00:00
|
|
|
replay = getprop("/sim/replay/replay-state");
|
2017-05-04 13:30:53 +00:00
|
|
|
|
2017-06-09 18:17:54 +00:00
|
|
|
if (extpwr_on and gen_ext_sw) {
|
|
|
|
setprop("/systems/electrical/gen-ext", 1);
|
|
|
|
} else {
|
|
|
|
setprop("/systems/electrical/gen-ext", 0);
|
2017-08-07 14:21:47 +00:00
|
|
|
}
|
|
|
|
|
2017-10-04 21:47:16 +00:00
|
|
|
if (rpmapu >= 94.9 and gen_apu_sw and !gen_ext_sw) {
|
2017-08-07 14:21:47 +00:00
|
|
|
setprop("/systems/electrical/gen-apu", 1);
|
|
|
|
} else {
|
|
|
|
setprop("/systems/electrical/gen-apu", 0);
|
2017-06-09 18:17:54 +00:00
|
|
|
}
|
|
|
|
|
2017-07-11 18:52:21 +00:00
|
|
|
gen_apu = getprop("/systems/electrical/gen-apu");
|
|
|
|
gen_ext = getprop("/systems/electrical/gen-ext");
|
2017-06-09 18:17:54 +00:00
|
|
|
|
2017-04-06 02:24:04 +00:00
|
|
|
# Left cross tie yes?
|
2017-08-07 14:21:47 +00:00
|
|
|
if (stateL == 3 and gen1_sw and !gen1_fail) {
|
2017-04-06 02:24:04 +00:00
|
|
|
setprop("/controls/electrical/xtie/xtieR", 1);
|
2017-08-07 14:21:47 +00:00
|
|
|
} else if (extpwr_on and gen_ext_sw) {
|
2017-04-06 02:24:04 +00:00
|
|
|
setprop("/controls/electrical/xtie/xtieR", 1);
|
2017-08-07 14:21:47 +00:00
|
|
|
} else if (rpmapu >= 94.9 and gen_apu_sw and !genapu_fail) {
|
2017-04-06 02:24:04 +00:00
|
|
|
setprop("/controls/electrical/xtie/xtieR", 1);
|
|
|
|
} else {
|
|
|
|
setprop("/controls/electrical/xtie/xtieR", 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
# Right cross tie yes?
|
2017-08-07 14:21:47 +00:00
|
|
|
if (stateR == 3 and gen2_sw and !gen2_fail) {
|
2017-04-06 02:24:04 +00:00
|
|
|
setprop("/controls/electrical/xtie/xtieL", 1);
|
2017-08-07 14:21:47 +00:00
|
|
|
} else if (extpwr_on and gen_ext_sw) {
|
2017-04-06 02:24:04 +00:00
|
|
|
setprop("/controls/electrical/xtie/xtieL", 1);
|
2017-08-07 14:21:47 +00:00
|
|
|
} else if (rpmapu >= 94.9 and gen_apu_sw and !genapu_fail) {
|
2017-04-06 02:24:04 +00:00
|
|
|
setprop("/controls/electrical/xtie/xtieL", 1);
|
|
|
|
} else {
|
|
|
|
setprop("/controls/electrical/xtie/xtieL", 0);
|
|
|
|
}
|
|
|
|
|
2017-09-26 18:56:35 +00:00
|
|
|
xtieL = getprop("/controls/electrical/xtie/xtieL");
|
|
|
|
xtieR = getprop("/controls/electrical/xtie/xtieR");
|
|
|
|
|
2017-06-09 18:17:54 +00:00
|
|
|
# Left DC bus yes?
|
2017-06-16 18:52:45 +00:00
|
|
|
if (stateL == 3 and gen1_sw and !gen1_fail) {
|
2017-06-09 18:17:54 +00:00
|
|
|
setprop("/systems/electrical/bus/dc1", dc_volt_std);
|
|
|
|
setprop("/systems/electrical/bus/dc-ess", dc_volt_std);
|
|
|
|
setprop("/systems/electrical/bus/dc1-amps", dc_amps_std);
|
2017-09-26 18:12:16 +00:00
|
|
|
} else if (extpwr_on and gen_ext_sw and apu_ext_crosstie_sw) {
|
2017-06-09 18:17:54 +00:00
|
|
|
setprop("/systems/electrical/bus/dc1", dc_volt_std);
|
|
|
|
setprop("/systems/electrical/bus/dc-ess", dc_volt_std);
|
|
|
|
setprop("/systems/electrical/bus/dc1-amps", dc_amps_std);
|
2017-09-26 18:12:16 +00:00
|
|
|
} else if (gen_apu and !genapu_fail and apu_ext_crosstie_sw) {
|
2017-06-09 18:17:54 +00:00
|
|
|
setprop("/systems/electrical/bus/dc1", dc_volt_std);
|
|
|
|
setprop("/systems/electrical/bus/dc-ess", dc_volt_std);
|
|
|
|
setprop("/systems/electrical/bus/dc1-amps", dc_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/bus/dc1-amps", dc_amps_std);
|
|
|
|
} else if (emergen) {
|
|
|
|
setprop("/systems/electrical/bus/dc1", dc_volt_std);
|
|
|
|
setprop("/systems/electrical/bus/dc-ess", dc_volt_std);
|
|
|
|
setprop("/systems/electrical/bus/dc1-amps", dc_amps_std);
|
2017-06-09 17:06:47 +00:00
|
|
|
} else {
|
2017-06-09 18:17:54 +00:00
|
|
|
setprop("/systems/electrical/bus/dc1", 0);
|
|
|
|
setprop("/systems/electrical/bus/dc1-amps", 0);
|
|
|
|
if (getprop("/systems/electrical/bus/dc2") == 0) {
|
|
|
|
setprop("/systems/electrical/bus/dc-ess", 0);
|
|
|
|
}
|
2017-06-09 17:06:47 +00:00
|
|
|
}
|
|
|
|
|
2017-06-09 18:17:54 +00:00
|
|
|
# Right DC bus yes?
|
2017-06-16 18:52:45 +00:00
|
|
|
if (stateR == 3 and gen2_sw and !gen2_fail) {
|
2017-06-09 18:17:54 +00:00
|
|
|
setprop("/systems/electrical/bus/dc2", dc_volt_std);
|
|
|
|
setprop("/systems/electrical/bus/dc-ess", dc_volt_std);
|
|
|
|
setprop("/systems/electrical/bus/dc2-amps", dc_amps_std);
|
2017-09-26 18:12:16 +00:00
|
|
|
} else if (extpwr_on and gen_ext_sw and apu_ext_crosstie_sw) {
|
2017-06-09 18:17:54 +00:00
|
|
|
setprop("/systems/electrical/bus/dc2", dc_volt_std);
|
|
|
|
setprop("/systems/electrical/bus/dc-ess", dc_volt_std);
|
|
|
|
setprop("/systems/electrical/bus/dc2-amps", dc_amps_std);
|
2017-09-26 18:12:16 +00:00
|
|
|
} else if (gen_apu and !genapu_fail and apu_ext_crosstie_sw) {
|
2017-06-09 18:17:54 +00:00
|
|
|
setprop("/systems/electrical/bus/dc2", dc_volt_std);
|
|
|
|
setprop("/systems/electrical/bus/dc-ess", dc_volt_std);
|
|
|
|
setprop("/systems/electrical/bus/dc2-amps", dc_amps_std);
|
|
|
|
} else if (apu_ext_crosstie_sw == 1 and xtieR) {
|
|
|
|
setprop("/systems/electrical/bus/dc2", dc_volt_std);
|
|
|
|
setprop("/systems/electrical/bus/dc-ess", dc_volt_std);
|
|
|
|
setprop("/systems/electrical/bus/dc2-amps", dc_amps_std);
|
|
|
|
} else if (emergen) {
|
|
|
|
setprop("/systems/electrical/bus/dc2", dc_volt_std);
|
|
|
|
setprop("/systems/electrical/bus/dc-ess", dc_volt_std);
|
|
|
|
setprop("/systems/electrical/bus/dc2-amps", dc_amps_std);
|
2017-06-09 17:06:47 +00:00
|
|
|
} else {
|
2017-06-09 18:17:54 +00:00
|
|
|
setprop("/systems/electrical/bus/dc2", 0);
|
|
|
|
setprop("/systems/electrical/bus/dc2-amps", 0);
|
|
|
|
if (getprop("/systems/electrical/bus/dc1") == 0) {
|
|
|
|
setprop("/systems/electrical/bus/dc-ess", 0);
|
|
|
|
}
|
2017-06-09 17:06:47 +00:00
|
|
|
}
|
|
|
|
|
2017-06-09 18:17:54 +00:00
|
|
|
# Left AC bus yes?
|
2017-06-16 18:52:45 +00:00
|
|
|
if (stateL == 3 and gen1_sw and !gen1_fail) {
|
2017-06-01 03:55:43 +00:00
|
|
|
setprop("/systems/electrical/bus/ac1", ac_volt_std);
|
2017-09-26 18:12:16 +00:00
|
|
|
} else if (extpwr_on and gen_ext_sw and apu_ext_crosstie_sw) {
|
2017-06-09 18:17:54 +00:00
|
|
|
setprop("/systems/electrical/bus/ac1", ac_volt_std);
|
2017-09-26 18:12:16 +00:00
|
|
|
} else if (gen_apu and !genapu_fail and apu_ext_crosstie_sw) {
|
2017-07-07 03:51:33 +00:00
|
|
|
setprop("/systems/electrical/bus/ac1", ac_volt_std);
|
2017-06-09 18:17:54 +00:00
|
|
|
} else if (apu_ext_crosstie_sw == 1 and xtieL) {
|
|
|
|
setprop("/systems/electrical/bus/ac1", ac_volt_std);
|
|
|
|
} else if (emergen) {
|
2017-06-02 20:08:32 +00:00
|
|
|
setprop("/systems/electrical/bus/ac1", ac_volt_std);
|
2017-06-01 03:55:43 +00:00
|
|
|
} else {
|
|
|
|
setprop("/systems/electrical/bus/ac1", 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
# Right AC bus yes?
|
2017-06-16 18:52:45 +00:00
|
|
|
if (stateR == 3 and gen2_sw and !gen2_fail) {
|
2017-06-01 03:55:43 +00:00
|
|
|
setprop("/systems/electrical/bus/ac2", ac_volt_std);
|
2017-09-26 18:12:16 +00:00
|
|
|
} else if (extpwr_on and gen_ext_sw and apu_ext_crosstie_sw) {
|
2017-06-09 18:17:54 +00:00
|
|
|
setprop("/systems/electrical/bus/ac2", ac_volt_std);
|
2017-09-26 18:12:16 +00:00
|
|
|
} else if (gen_apu and !genapu_fail and apu_ext_crosstie_sw) {
|
2017-07-07 03:51:33 +00:00
|
|
|
setprop("/systems/electrical/bus/ac2", ac_volt_std);
|
2017-06-09 18:17:54 +00:00
|
|
|
} else if (apu_ext_crosstie_sw == 1 and xtieR) {
|
|
|
|
setprop("/systems/electrical/bus/ac2", ac_volt_std);
|
|
|
|
} else if (emergen) {
|
|
|
|
setprop("/systems/electrical/bus/ac2", ac_volt_std);
|
|
|
|
} else {
|
|
|
|
setprop("/systems/electrical/bus/ac2", 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
# HZ/Volts yes?
|
2017-06-11 04:17:34 +00:00
|
|
|
if (stateL == 3 and gen1_sw and !gen1_fail) {
|
|
|
|
setprop("/systems/electrical/extra/gen1-volts", ac_volt_std);
|
|
|
|
setprop("/systems/electrical/bus/gen1-hz", ac_hz_std);
|
|
|
|
} else {
|
|
|
|
setprop("/systems/electrical/extra/gen1-volts", 0);
|
|
|
|
setprop("/systems/electrical/bus/gen1-hz", 0);
|
|
|
|
}
|
|
|
|
|
2017-06-09 17:06:47 +00:00
|
|
|
if (stateR == 3 and gen2_sw and !gen2_fail) {
|
2017-06-01 03:55:43 +00:00
|
|
|
setprop("/systems/electrical/extra/gen2-volts", ac_volt_std);
|
|
|
|
setprop("/systems/electrical/bus/gen2-hz", ac_hz_std);
|
2017-06-09 17:06:47 +00:00
|
|
|
} else {
|
2017-05-08 11:30:17 +00:00
|
|
|
setprop("/systems/electrical/extra/gen2-volts", 0);
|
|
|
|
setprop("/systems/electrical/bus/gen2-hz", 0);
|
2017-04-06 02:24:04 +00:00
|
|
|
}
|
|
|
|
|
2017-06-16 18:52:45 +00:00
|
|
|
if (extpwr_on and gen_ext_sw) {
|
|
|
|
setprop("/systems/electrical/extra/ext-volts", ac_volt_std);
|
|
|
|
setprop("/systems/electrical/extra/ext-hz", ac_hz_std);
|
|
|
|
} else {
|
|
|
|
setprop("/systems/electrical/extra/ext-volts", 0);
|
|
|
|
setprop("/systems/electrical/extra/ext-hz", 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (gen_apu and !genapu_fail) {
|
|
|
|
setprop("/systems/electrical/extra/apu-volts", ac_volt_std);
|
|
|
|
setprop("/systems/electrical/extra/apu-hz", ac_hz_std);
|
|
|
|
} else {
|
|
|
|
setprop("/systems/electrical/extra/apu-volts", 0);
|
|
|
|
setprop("/systems/electrical/extra/apu-hz", 0);
|
|
|
|
}
|
|
|
|
|
2017-07-11 18:52:21 +00:00
|
|
|
ac1 = getprop("/systems/electrical/bus/ac1");
|
|
|
|
ac2 = getprop("/systems/electrical/bus/ac2");
|
2017-06-01 03:55:43 +00:00
|
|
|
|
|
|
|
if (!ac_ess_fail and (ac1 >= 110 or ac2 >= 110)) {
|
|
|
|
setprop("/systems/electrical/bus/ac-ess", ac_volt_std);
|
|
|
|
} else {
|
|
|
|
setprop("/systems/electrical/bus/ac-ess", 0);
|
|
|
|
}
|
|
|
|
|
2017-07-11 18:52:21 +00:00
|
|
|
ac_ess = getprop("/systems/electrical/bus/ac-ess");
|
2017-06-01 03:55:43 +00:00
|
|
|
|
|
|
|
if (ac_ess >= 110 and !gallery_fail) {
|
2017-05-09 11:59:43 +00:00
|
|
|
if (galley_sw == 1 and !galley_shed) {
|
2017-04-25 17:13:15 +00:00
|
|
|
setprop("/systems/electrical/bus/galley", ac_volt_std);
|
2017-05-09 11:59:43 +00:00
|
|
|
} else if (galley_sw or galley_shed) {
|
2017-04-06 02:24:04 +00:00
|
|
|
setprop("/systems/electrical/bus/galley", 0);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
setprop("/systems/electrical/bus/galley", 0);
|
|
|
|
}
|
|
|
|
|
2017-05-11 21:26:31 +00:00
|
|
|
if (!gen_apu and !gen_ext_sw and (!gen1_sw or !gen2_sw)) {
|
2017-05-09 11:59:43 +00:00
|
|
|
setprop("/systems/electrical/extra/galleyshed", 1);
|
|
|
|
} else {
|
|
|
|
setprop("/systems/electrical/extra/galleyshed", 0);
|
|
|
|
}
|
|
|
|
|
2017-08-07 14:58:52 +00:00
|
|
|
if ((ac1 == 0) and (ac2 == 0) and (ias > 100) or (manrat) and replay == 0) {
|
2017-05-31 12:04:36 +00:00
|
|
|
setprop("/controls/hydraulic/rat-deployed", 1);
|
|
|
|
setprop("/controls/hydraulic/rat", 1);
|
|
|
|
setprop("/controls/electrical/switches/emer-gen", 1);
|
|
|
|
}
|
|
|
|
|
2017-06-02 20:08:32 +00:00
|
|
|
if (ias < 100) {
|
2017-05-31 12:04:36 +00:00
|
|
|
setprop("/controls/electrical/switches/emer-gen", 0);
|
|
|
|
}
|
|
|
|
|
2017-05-04 13:30:53 +00:00
|
|
|
# Battery Amps
|
2017-06-01 03:55:43 +00:00
|
|
|
if (battery1_sw and !batt1_fail) {
|
2017-05-11 21:26:31 +00:00
|
|
|
setprop("/systems/electrical/battery1-amps", dc_amps_std);
|
|
|
|
} else {
|
|
|
|
setprop("/systems/electrical/battery1-amps", 0);
|
|
|
|
}
|
2017-05-04 13:30:53 +00:00
|
|
|
|
2017-06-01 03:55:43 +00:00
|
|
|
if (battery2_sw and !batt2_fail) {
|
2017-05-11 21:26:31 +00:00
|
|
|
setprop("/systems/electrical/battery2-amps", dc_amps_std);
|
|
|
|
} else {
|
|
|
|
setprop("/systems/electrical/battery2-amps", 0);
|
|
|
|
}
|
|
|
|
|
2017-11-06 22:16:42 +00:00
|
|
|
if ((getprop("/systems/electrical/battery1-amps") > 120) or (getprop("/systems/electrical/battery2-amps") > 120)) {
|
2017-05-11 21:26:31 +00:00
|
|
|
setprop("/systems/electrical/bus/dcbat", dc_volt_std);
|
|
|
|
} else {
|
|
|
|
setprop("/systems/electrical/bus/dcbat", 0);
|
|
|
|
}
|
|
|
|
|
2017-11-06 22:16:42 +00:00
|
|
|
dc1 = getprop("/systems/electrical/bus/dc1");
|
|
|
|
dc2 = getprop("/systems/electrical/bus/dc2");
|
2017-08-11 16:32:27 +00:00
|
|
|
|
2017-11-06 22:16:42 +00:00
|
|
|
if (battery1_volts < 27.9 and (dc1 > 25 or dc2 > 25) and battery1_sw and !batt1_fail) {
|
2017-05-11 21:26:31 +00:00
|
|
|
decharge1.stop();
|
|
|
|
charge1.start();
|
2017-11-06 22:16:42 +00:00
|
|
|
} else if (battery1_volts == 27.9 and (dc1 > 25 or dc2 > 25) and battery1_sw and !batt1_fail) {
|
2017-10-06 03:35:36 +00:00
|
|
|
charge1.stop();
|
|
|
|
decharge1.stop();
|
|
|
|
} else if (battery1_sw and !batt1_fail) {
|
|
|
|
charge1.stop();
|
|
|
|
decharge1.start();
|
|
|
|
} else {
|
|
|
|
decharge1.stop();
|
|
|
|
charge1.stop();
|
2017-05-11 21:26:31 +00:00
|
|
|
}
|
|
|
|
|
2017-11-06 22:16:42 +00:00
|
|
|
if (battery2_volts < 27.9 and (dc1 > 25 or dc2 > 25) and battery2_sw and !batt2_fail) {
|
2017-09-21 19:38:05 +00:00
|
|
|
decharge2.stop();
|
2017-05-11 21:26:31 +00:00
|
|
|
charge2.start();
|
2017-10-06 03:35:36 +00:00
|
|
|
} else if (battery2_volts == 27.9 and (dc1 > 25 or dc2 > 25) and battery2_sw and !batt2_fail) {
|
|
|
|
charge2.stop();
|
|
|
|
decharge2.stop();
|
|
|
|
} else if (battery2_sw and !batt2_fail) {
|
|
|
|
charge2.stop();
|
2017-05-11 21:26:31 +00:00
|
|
|
decharge2.start();
|
2017-10-06 03:35:36 +00:00
|
|
|
} else {
|
|
|
|
decharge2.stop();
|
|
|
|
charge2.stop();
|
2017-05-11 21:26:31 +00:00
|
|
|
}
|
2017-05-11 20:03:55 +00:00
|
|
|
|
2017-06-05 23:42:02 +00:00
|
|
|
if (getprop("/systems/electrical/bus/ac-ess") < 110) {
|
2017-11-02 21:08:08 +00:00
|
|
|
if (getprop("/it-autoflight/output/ap1") == 1) {
|
|
|
|
setprop("/it-autoflight/input/ap1", 0);
|
|
|
|
}
|
|
|
|
if (getprop("/it-autoflight/output/ap2") == 1) {
|
|
|
|
setprop("/it-autoflight/input/ap2", 0);
|
|
|
|
}
|
2017-04-06 02:24:04 +00:00
|
|
|
setprop("systems/electrical/on", 0);
|
|
|
|
# ai_spin.setValue(0.2);
|
|
|
|
# aispin.stop();
|
2017-06-05 23:42:02 +00:00
|
|
|
setprop("/systems/electrical/outputs/adf", 0);
|
|
|
|
setprop("/systems/electrical/outputs/audio-panel", 0);
|
|
|
|
setprop("/systems/electrical/outputs/audio-panel[1]", 0);
|
|
|
|
setprop("/systems/electrical/outputs/autopilot", 0);
|
|
|
|
setprop("/systems/electrical/outputs/avionics-fan", 0);
|
|
|
|
setprop("/systems/electrical/outputs/beacon", 0);
|
|
|
|
setprop("/systems/electrical/outputs/bus", 0);
|
|
|
|
setprop("/systems/electrical/outputs/cabin-lights", 0);
|
|
|
|
setprop("/systems/electrical/outputs/dme", 0);
|
|
|
|
setprop("/systems/electrical/outputs/efis", 0);
|
|
|
|
setprop("/systems/electrical/outputs/flaps", 0);
|
|
|
|
setprop("/systems/electrical/outputs/fuel-pump", 0);
|
|
|
|
setprop("/systems/electrical/outputs/fuel-pump[1]", 0);
|
|
|
|
setprop("/systems/electrical/outputs/gps", 0);
|
|
|
|
setprop("/systems/electrical/outputs/gps-mfd", 0);
|
|
|
|
setprop("/systems/electrical/outputs/hsi", 0);
|
|
|
|
setprop("/systems/electrical/outputs/instr-ignition-switch", 0);
|
|
|
|
setprop("/systems/electrical/outputs/instrument-lights", 0);
|
|
|
|
setprop("/systems/electrical/outputs/landing-lights", 0);
|
|
|
|
setprop("/systems/electrical/outputs/map-lights", 0);
|
|
|
|
setprop("/systems/electrical/outputs/mk-viii", 0);
|
|
|
|
setprop("/systems/electrical/outputs/nav", 0);
|
|
|
|
setprop("/systems/electrical/outputs/nav[1]", 0);
|
2017-07-06 03:57:57 +00:00
|
|
|
setprop("/systems/electrical/outputs/nav[2]", 0);
|
|
|
|
setprop("/systems/electrical/outputs/nav[3]", 0);
|
2017-06-05 23:42:02 +00:00
|
|
|
setprop("/systems/electrical/outputs/pitot-head", 0);
|
|
|
|
setprop("/systems/electrical/outputs/stobe-lights", 0);
|
|
|
|
setprop("/systems/electrical/outputs/tacan", 0);
|
|
|
|
setprop("/systems/electrical/outputs/taxi-lights", 0);
|
|
|
|
setprop("/systems/electrical/outputs/transponder", 0);
|
|
|
|
setprop("/systems/electrical/outputs/turn-coordinator", 0);
|
2017-10-27 20:22:22 +00:00
|
|
|
setprop("/controls/lighting/fcu-panel-norm", 0);
|
|
|
|
setprop("/controls/lighting/main-panel-norm", 0);
|
|
|
|
setprop("/controls/lighting/overhead-panel-norm", 0);
|
2017-04-06 02:24:04 +00:00
|
|
|
} else {
|
2017-06-05 23:42:02 +00:00
|
|
|
setprop("/systems/electrical/on", 1);
|
2017-04-06 02:24:04 +00:00
|
|
|
# aispin.start();
|
2017-06-05 23:42:02 +00:00
|
|
|
setprop("/systems/electrical/outputs/adf", dc_volt_std);
|
|
|
|
setprop("/systems/electrical/outputs/audio-panel", dc_volt_std);
|
|
|
|
setprop("/systems/electrical/outputs/audio-panel[1]", dc_volt_std);
|
|
|
|
setprop("/systems/electrical/outputs/autopilot", dc_volt_std);
|
|
|
|
setprop("/systems/electrical/outputs/avionics-fan", dc_volt_std);
|
|
|
|
setprop("/systems/electrical/outputs/beacon", dc_volt_std);
|
|
|
|
setprop("/systems/electrical/outputs/bus", dc_volt_std);
|
|
|
|
setprop("/systems/electrical/outputs/cabin-lights", dc_volt_std);
|
|
|
|
setprop("/systems/electrical/outputs/dme", dc_volt_std);
|
|
|
|
setprop("/systems/electrical/outputs/efis", dc_volt_std);
|
|
|
|
setprop("/systems/electrical/outputs/flaps", dc_volt_std);
|
|
|
|
setprop("/systems/electrical/outputs/fuel-pump", dc_volt_std);
|
|
|
|
setprop("/systems/electrical/outputs/fuel-pump[1]", dc_volt_std);
|
|
|
|
setprop("/systems/electrical/outputs/gps", dc_volt_std);
|
|
|
|
setprop("/systems/electrical/outputs/gps-mfd", dc_volt_std);
|
|
|
|
setprop("/systems/electrical/outputs/hsi", dc_volt_std);
|
|
|
|
setprop("/systems/electrical/outputs/instr-ignition-switch", dc_volt_std);
|
|
|
|
setprop("/systems/electrical/outputs/instrument-lights", dc_volt_std);
|
|
|
|
setprop("/systems/electrical/outputs/landing-lights", dc_volt_std);
|
|
|
|
setprop("/systems/electrical/outputs/map-lights", dc_volt_std);
|
|
|
|
setprop("/systems/electrical/outputs/mk-viii", dc_volt_std);
|
|
|
|
setprop("/systems/electrical/outputs/nav", dc_volt_std);
|
|
|
|
setprop("/systems/electrical/outputs/nav[1]", dc_volt_std);
|
2017-07-06 03:57:57 +00:00
|
|
|
setprop("/systems/electrical/outputs/nav[2]", dc_volt_std);
|
|
|
|
setprop("/systems/electrical/outputs/nav[3]", dc_volt_std);
|
2017-06-05 23:42:02 +00:00
|
|
|
setprop("/systems/electrical/outputs/pitot-head", dc_volt_std);
|
|
|
|
setprop("/systems/electrical/outputs/stobe-lights", dc_volt_std);
|
|
|
|
setprop("/systems/electrical/outputs/tacan", dc_volt_std);
|
|
|
|
setprop("/systems/electrical/outputs/taxi-lights", dc_volt_std);
|
|
|
|
setprop("/systems/electrical/outputs/transponder", dc_volt_std);
|
|
|
|
setprop("/systems/electrical/outputs/turn-coordinator", dc_volt_std);
|
2017-10-27 20:22:22 +00:00
|
|
|
setprop("/controls/lighting/fcu-panel-norm", getprop("/controls/lighting/fcu-panel-knb"));
|
|
|
|
setprop("/controls/lighting/main-panel-norm", getprop("/controls/lighting/main-panel-knb"));
|
|
|
|
setprop("/controls/lighting/overhead-panel-norm", getprop("/controls/lighting/overhead-panel-knb"));
|
2017-04-06 02:24:04 +00:00
|
|
|
}
|
2017-07-25 04:09:58 +00:00
|
|
|
|
|
|
|
# Fault lights
|
|
|
|
if (gallery_fail and galley_sw) {
|
|
|
|
setprop("/systems/electrical/galley-fault", 1);
|
|
|
|
} else {
|
|
|
|
setprop("/systems/electrical/galley-fault", 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (batt1_fail and battery1_sw) {
|
|
|
|
setprop("/systems/electrical/batt1-fault", 1);
|
|
|
|
} else {
|
|
|
|
setprop("/systems/electrical/batt1-fault", 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (batt2_fail and battery2_sw) {
|
|
|
|
setprop("/systems/electrical/batt2-fault", 1);
|
|
|
|
} else {
|
|
|
|
setprop("/systems/electrical/batt2-fault", 0);
|
|
|
|
}
|
|
|
|
|
2017-11-06 22:16:42 +00:00
|
|
|
if ((gen1_fail and gen1_sw) or (gen1_sw and stateL != 3)) {
|
2017-07-25 04:09:58 +00:00
|
|
|
setprop("/systems/electrical/gen1-fault", 1);
|
|
|
|
} else {
|
|
|
|
setprop("/systems/electrical/gen1-fault", 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ac_ess_fail and ac_ess_feed_sw) {
|
|
|
|
setprop("/systems/electrical/ac-ess-feed-fault", 1);
|
|
|
|
} else {
|
|
|
|
setprop("/systems/electrical/ac-ess-feed-fault", 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (genapu_fail and gen_apu_sw) {
|
|
|
|
setprop("/systems/electrical/apugen-fault", 1);
|
|
|
|
} else {
|
|
|
|
setprop("/systems/electrical/apugen-fault", 0);
|
|
|
|
}
|
|
|
|
|
2017-11-06 22:16:42 +00:00
|
|
|
if ((gen2_fail and gen2_sw) or (gen2_sw and stateR != 3)) {
|
2017-07-25 04:09:58 +00:00
|
|
|
setprop("/systems/electrical/gen2-fault", 1);
|
|
|
|
} else {
|
|
|
|
setprop("/systems/electrical/gen2-fault", 0);
|
|
|
|
}
|
2017-04-25 17:13:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
###################
|
|
|
|
# Update Function #
|
|
|
|
###################
|
2016-11-04 22:13:12 +00:00
|
|
|
|
2017-04-06 02:24:04 +00:00
|
|
|
var update_electrical = func {
|
2017-04-25 17:13:15 +00:00
|
|
|
master_elec();
|
2016-11-04 22:13:12 +00:00
|
|
|
}
|
|
|
|
|
2017-05-11 21:26:31 +00:00
|
|
|
##########
|
|
|
|
# Timers #
|
|
|
|
##########
|
2017-05-11 20:03:55 +00:00
|
|
|
|
2017-08-07 14:24:15 +00:00
|
|
|
var elec_timer = maketimer(0.2, update_electrical);
|
2017-05-13 13:24:02 +00:00
|
|
|
|
2017-05-11 21:26:31 +00:00
|
|
|
var charge1 = maketimer(6, func {
|
2017-07-11 18:52:21 +00:00
|
|
|
bat1_volts = getprop("/systems/electrical/battery1-volts");
|
2017-05-11 21:26:31 +00:00
|
|
|
setprop("/systems/electrical/battery1-volts", bat1_volts + 0.1);
|
|
|
|
});
|
|
|
|
var charge2 = maketimer(6, func {
|
2017-07-11 18:52:21 +00:00
|
|
|
bat2_volts = getprop("/systems/electrical/battery2-volts");
|
2017-05-11 21:26:31 +00:00
|
|
|
setprop("/systems/electrical/battery2-volts", bat2_volts + 0.1);
|
|
|
|
});
|
2017-05-31 12:04:36 +00:00
|
|
|
var decharge1 = maketimer(69, func { # interval is at 69 seconds, to allow about 30 min from 25.9
|
2017-07-11 18:52:21 +00:00
|
|
|
bat1_volts = getprop("/systems/electrical/battery1-volts");
|
2017-05-11 21:26:31 +00:00
|
|
|
setprop("/systems/electrical/battery1-volts", bat1_volts - 0.1);
|
|
|
|
});
|
2017-05-31 12:04:36 +00:00
|
|
|
var decharge2 = maketimer(69, func {
|
2017-07-11 18:52:21 +00:00
|
|
|
bat2_volts = getprop("/systems/electrical/battery2-volts");
|
2017-05-11 21:26:31 +00:00
|
|
|
setprop("/systems/electrical/battery2-volts", bat2_volts - 0.1);
|
|
|
|
});
|