diff --git a/A320-main.xml b/A320-main.xml
index 4d865009..67357663 100644
--- a/A320-main.xml
+++ b/A320-main.xml
@@ -157,29 +157,6 @@
Aircraft/IDG-A32X/Systems/instrumentation.xml
-
-
- false
-
-
- 0
-
-
-
- false
-
-
- 0
-
-
-
- false
-
-
- 0
-
-
-
diff --git a/AircraftConfig/acconfig.nas b/AircraftConfig/acconfig.nas
index 0da98aac..cff37aa2 100644
--- a/AircraftConfig/acconfig.nas
+++ b/AircraftConfig/acconfig.nas
@@ -151,11 +151,11 @@ saveSettings();
var systemsReset = func {
fbw.fctlInit();
- systems.elec_init();
- systems.ADIRSreset();
- systems.pneu_init();
- systems.hyd_init();
- systems.fuel_init();
+ systems.ELEC.init();
+ systems.PNEU.init();
+ systems.HYD.init();
+ systems.FUEL.init();
+ systems.ADIRS.init();
systems.eng_init();
systems.autobrake_init();
fmgc.FMGCinit();
diff --git a/Nasal/ADIRS.nas b/Nasal/ADIRS.nas
index 2be59fe3..e4f046c3 100644
--- a/Nasal/ADIRS.nas
+++ b/Nasal/ADIRS.nas
@@ -1,23 +1,10 @@
# A3XX ADIRS system
-# Jonathan Redpath and Joshua Davidson
+# Joshua Davidson
##############################################
# Copyright (c) Joshua Davidson (it0uchpods) #
##############################################
-#####################
-# Initializing Vars #
-#####################
-
-setprop("/systems/electrical/bus/dc1", 0);
-setprop("/systems/electrical/bus/dc2", 0);
-setprop("/systems/electrical/bus/dc-ess", 0);
-setprop("/systems/electrical/bus/ac1", 0);
-setprop("/systems/electrical/bus/ac2", 0);
-setprop("/systems/electrical/bus/ac-ess", 0);
-var ttn = 0;
-var knob = 0;
-
setlistener("/sim/signals/fdm-initialized", func {
var roll = getprop("/orientation/roll-deg");
var pitch = getprop("/orientation/pitch-deg");
@@ -26,271 +13,48 @@ setlistener("/sim/signals/fdm-initialized", func {
var selected_ir = getprop("/controls/adirs/display/selected");
});
-var adirs_init = func {
- setprop("/controls/adirs/mcducbtn",0);
- adirs_timer.start();
-}
-
-var ADIRSreset = func {
- setprop("/controls/adirs/numm", 0);
- setprop("/instrumentation/adirs/ir[0]/aligned",0);
- setprop("/instrumentation/adirs/ir[1]/aligned",0);
- setprop("/instrumentation/adirs/ir[2]/aligned",0);
- setprop("/instrumentation/adirs/ir[0]/display/ttn",0);
- setprop("/instrumentation/adirs/ir[1]/display/ttn",0);
- setprop("/instrumentation/adirs/ir[2]/display/ttn",0);
- setprop("/instrumentation/adirs/ir[0]/display/status","- - - - - - - - ");
- setprop("/instrumentation/adirs/ir[1]/display/status","- - - - - - - - ");
- setprop("/instrumentation/adirs/ir[2]/display/status","- - - - - - - - ");
- setprop("/controls/adirs/adr[0]/fault",0);
- setprop("/controls/adirs/adr[1]/fault",0);
- setprop("/controls/adirs/adr[2]/fault",0);
- setprop("/controls/adirs/adr[0]/off",0);
- setprop("/controls/adirs/adr[1]/off",0);
- setprop("/controls/adirs/adr[2]/off",0);
- setprop("/controls/adirs/display/text","");
- setprop("/controls/adirs/display/dataknob","5");
- setprop("/controls/adirs/display/selected","1");
- setprop("/controls/adirs/ir[0]/align",0);
- setprop("/controls/adirs/ir[1]/align",0);
- setprop("/controls/adirs/ir[2]/align",0);
- setprop("/controls/adirs/ir[0]/knob", 0);
- setprop("/controls/adirs/ir[1]/knob", 0);
- setprop("/controls/adirs/ir[2]/knob", 0);
- setprop("/controls/adirs/ir[0]/fault",0);
- setprop("/controls/adirs/ir[1]/fault",0);
- setprop("/controls/adirs/ir[2]/fault",0);
- setprop("/controls/adirs/onbat",0);
- setprop("/controls/adirs/mcducbtn",0);
- setprop("/controls/adirs/mcdu/mode1", ""); # INVAL ALIGN NAV ATT or off (blank)
- setprop("/controls/adirs/mcdu/mode2", "");
- setprop("/controls/adirs/mcdu/mode3", "");
- setprop("/controls/adirs/mcdu/status1", ""); # see smith thales p487
- setprop("/controls/adirs/mcdu/status2", "");
- setprop("/controls/adirs/mcdu/status3", "");
- setprop("/controls/adirs/mcdu/hdg", ""); # only shown if in ATT mode
- setprop("/controls/adirs/mcdu/avgdrift1", "");
- setprop("/controls/adirs/mcdu/avgdrift2", "");
- setprop("/controls/adirs/mcdu/avgdrift3", "");
- adirs_init();
-}
-
-var ir_align_loop = func(i) {
- ttn = getprop("/instrumentation/adirs/ir[" ~ i ~ "]/display/ttn");
- if ((ttn >= 0) and (ttn < 0.99)) { # Make it less sensitive
- ir_align_finish(i);
- } else {
- setprop("/instrumentation/adirs/ir[" ~ i ~ "]/display/ttn", ttn - 1);
- }
- roll = getprop("/orientation/roll-deg");
- pitch = getprop("/orientation/pitch-deg");
- gs = getprop("/velocities/groundspeed-kt");
- if (gs > 2) {
- setprop("/instrumentation/adirs/ir[" ~ i ~ "]/display/status", "STS-XCESS MOTION");
- ir_align_abort(i);
- }
-
-}
-
-var ir0_align_loop_timer = maketimer(1, func{ir_align_loop(0)});
-var ir1_align_loop_timer = maketimer(1, func{ir_align_loop(1)});
-var ir2_align_loop_timer = maketimer(1, func{ir_align_loop(2)});
-
-var ir_align_start = func(i) {
- if (((i == 0) and !ir0_align_loop_timer.isRunning) or
- ((i == 1) and !ir1_align_loop_timer.isRunning) or
- ((i == 2) and !ir2_align_loop_timer.isRunning)) {
- setprop("/instrumentation/adirs/ir[" ~ i ~ "]/display/ttn", (math.sin((getprop("/position/latitude-deg") / 90) * (math.pi / 2)) * 720) + 300);
- if (i == 0) {
- ir0_align_loop_timer.start();
- } else if (i == 1) {
- ir1_align_loop_timer.start();
- } else if (i == 2) {
- ir2_align_loop_timer.start();
- }
- setprop("/controls/adirs/ir[" ~ i ~ "]/align", 1);
- }
-}
-
-var ir_align_finish = func(i) {
- setprop("/instrumentation/adirs/ir[" ~ i ~ "]/aligned", 1);
- if (i == 0) {
- ir0_align_loop_timer.stop();
- } else if (i == 1) {
- ir1_align_loop_timer.stop();
- } else if (i == 2) {
- ir2_align_loop_timer.stop();
- }
- setprop("/controls/adirs/ir[" ~ i ~ "]/align", 0);
-}
-
-var ir_align_abort = func(i) {
- setprop("/controls/adirs/ir[" ~ i ~ "]/fault", 1);
- if (i == 0) {
- ir0_align_loop_timer.stop();
- } else if (i == 1) {
- ir1_align_loop_timer.stop();
- } else if (i == 2) {
- ir2_align_loop_timer.stop();
- }
- setprop("/controls/adirs/ir[" ~ i ~ "]/align", 0);
-}
-
-var ir_knob_move = func(i) {
- knob = getprop("/controls/adirs/ir[" ~ i ~ "]/knob");
- if (knob == 1) {
- setprop("/controls/adirs/ir[" ~ i ~ "]/align", 0);
- setprop("/controls/adirs/ir[" ~ i ~ "]/fault", 0);
- setprop("/instrumentation/adirs/ir[" ~ i ~ "]/aligned", 0);
- setprop("/instrumentation/adirs/ir[" ~ i ~ "]/display/status", "- - - - - - - - ");
- if (i == 0) {
- ir0_align_loop_timer.stop();
- } else if (i == 1) {
- ir1_align_loop_timer.stop();
- } else if (i == 2) {
- ir2_align_loop_timer.stop();
- }
- } else if (knob == 2) {
- if ( !getprop("/instrumentation/adirs/ir[" ~ i ~ "]/aligned") and
- (getprop("/systems/electrical/bus/ac-ess") > 9) ) {
- ir_align_start(i);
- }
- }
-}
-
-setlistener("/controls/adirs/ir[0]/knob", func {
- ir_knob_move(0);
- knobmcducheck();
-});
-setlistener("/controls/adirs/ir[1]/knob", func {
- ir_knob_move(1);
- knobmcducheck();
-});
-setlistener("/controls/adirs/ir[2]/knob", func {
- ir_knob_move(2);
- knobmcducheck();
-});
-
-var knobmcducheck = func {
- if (getprop("/controls/adirs/ir[0]/knob") == 1 and getprop("/controls/adirs/ir[1]/knob") == 1 and getprop("/controls/adirs/ir[2]/knob") == 1) {
- setprop("/controls/adirs/mcducbtn", 0);
- }
-}
-
-var onbat_light = func {
- if (((getprop("/systems/electrical/bus/dc1") > 25) or (getprop("/systems/electrical/bus/dc2") > 25)) and
- ((getprop("/systems/electrical/bus/ac1") < 110) and getprop("/systems/electrical/bus/ac2") < 110) and
- ((getprop("/controls/adirs/ir[0]/knob") > 1) or
- (getprop("/controls/adirs/ir[1]/knob") > 1) or
- (getprop("/controls/adirs/ir[2]/knob") > 1))) {
- setprop("/controls/adirs/onbat", 1);
- } else {
+var ADIRS = {
+ init: func() {
+ setprop("/controls/adirs/numm", 0);
+ setprop("/instrumentation/adirs/ir[0]/aligned", 0);
+ setprop("/instrumentation/adirs/ir[1]/aligned", 0);
+ setprop("/instrumentation/adirs/ir[2]/aligned", 0);
+ setprop("/instrumentation/adirs/ir[0]/display/ttn", 0);
+ setprop("/instrumentation/adirs/ir[1]/display/ttn", 0);
+ setprop("/instrumentation/adirs/ir[2]/display/ttn", 0);
+ setprop("/controls/adirs/adr[0]/fault", 0);
+ setprop("/controls/adirs/adr[1]/fault", 0);
+ setprop("/controls/adirs/adr[2]/fault", 0);
+ setprop("/controls/adirs/adr[0]/off", 0);
+ setprop("/controls/adirs/adr[1]/off", 0);
+ setprop("/controls/adirs/adr[2]/off", 0);
+ setprop("/controls/adirs/ir[0]/align", 0);
+ setprop("/controls/adirs/ir[1]/align", 0);
+ setprop("/controls/adirs/ir[2]/align", 0);
+ setprop("/controls/adirs/ir[0]/knob", 0);
+ setprop("/controls/adirs/ir[1]/knob", 0);
+ setprop("/controls/adirs/ir[2]/knob", 0);
+ setprop("/controls/adirs/ir[0]/fault", 0);
+ setprop("/controls/adirs/ir[1]/fault", 0);
+ setprop("/controls/adirs/ir[2]/fault", 0);
setprop("/controls/adirs/onbat", 0);
- }
-}
-
-var onbat_light_b = func {
- setprop("/controls/adirs/onbat", 1);
- settimer(func {
- onbat_light();
- }, 4);
- if (getprop("/controls/adirs/skip") == 1) {
- skip_ADIRS();
- }
-}
-
-setlistener("/controls/electrical/switches/gen-apu", onbat_light);
-setlistener("/controls/electrical/switches/gen1", onbat_light);
-setlistener("/controls/electrical/switches/gen2", onbat_light);
-setlistener("/controls/electrical/switches/gen-ext", onbat_light);
-setlistener("/systems/electrical/bus/ac-ess", onbat_light);
-setlistener("/controls/adirs/ir[0]/knob", onbat_light_b);
-setlistener("/controls/adirs/ir[1]/knob", onbat_light_b);
-setlistener("/controls/adirs/ir[2]/knob", onbat_light_b);
-
-
-var adirs_display = func() {
- data_knob = getprop("/controls/adirs/display/dataknob");
- selected_ir = getprop("/controls/adirs/display/selected");
- if ( selected_ir == 1 ) {
- setprop("/controls/adirs/display/text", "");
- } else {
- if ( data_knob == 1 ) {
- setprop("/controls/adirs/display/text", "888888888888888");
- } else if ( data_knob == 2 ) {
- if ( ((selected_ir == 2) and getprop("/instrumentation/adirs/ir[0]/aligned")) or
- ((selected_ir == 3) and getprop("/instrumentation/adirs/ir[2]/aligned")) or
- ((selected_ir == 4) and getprop("/instrumentation/adirs/ir[1]/aligned")) ) {
- setprop("/controls/adirs/display/text", sprintf(" %03i", getprop("/orientation/track-magnetic-deg")) ~ sprintf(" %03i", getprop("/velocities/groundspeed-kt")));
- } else {
- setprop("/controls/adirs/display/text", "- - - - - - - - ");
- }
- } else if ( data_knob == 3 ) {
- lat = abs(getprop("/position/latitude-deg"));
- lon = abs(getprop("/position/longitude-deg"));
- setprop("/controls/adirs/display/text", substr(getprop("/position/latitude-string"), -1, 1) ~
- sprintf("%2i", lat) ~ "'" ~
- sprintf("%2.1f", (lat - math.floor(lat)) * 60) ~
- substr(getprop("/position/longitude-string"), -1, 1) ~
- sprintf("%3i", lon) ~ "'" ~
- sprintf("%2.1f", (lon - math.floor(lon)) * 60));
- } else if ( data_knob == 4 ) {
- if ( ((selected_ir == 2) and getprop("/instrumentation/adirs/ir[0]/aligned")) or
- ((selected_ir == 3) and getprop("/instrumentation/adirs/ir[2]/aligned")) or
- ((selected_ir == 4) and getprop("/instrumentation/adirs/ir[1]/aligned")) ) {
- setprop("/controls/adirs/display/text", sprintf(" %03i", getprop("/environment/wind-from-heading-deg")) ~ sprintf(" %03i", getprop("/environment/wind-speed-kt")));
- } else {
- setprop("/controls/adirs/display/text", "- - - - - - - - ");
- }
- } else if ( data_knob == 5 ) {
- if ( ((selected_ir == 2) and getprop("/instrumentation/adirs/ir[0]/aligned")) or
- ((selected_ir == 3) and getprop("/instrumentation/adirs/ir[2]/aligned")) or
- ((selected_ir == 4) and getprop("/instrumentation/adirs/ir[1]/aligned")) ) {
- lat = getprop("/position/latitude-deg");
- lon = getprop("/position/longitude-deg");
- if ((lat > 82) or (lat < -60) or (lon < -90 and lon > -120 and lat > 73)) {
- setprop("/controls/adirs/display/text", sprintf(" %3.1f", getprop("/orientation/heading-deg")) ~ "- - - - "); # this is true heading
- } else {
- setprop("/controls/adirs/display/text", sprintf(" %3.1f", getprop("/orientation/heading-magnetic-deg")) ~ "- - - - ");
- }
- } else {
- if ( (selected_ir == 2) and getprop("/controls/adirs/ir[0]/align") ) {
- setprop("controls/adirs/display/text", "- - - - " ~ sprintf(" TTN %2i", (getprop("/instrumentation/adirs/ir[0]/display/ttn") / 60)));
- } else if ( (selected_ir == 3) and getprop("/controls/adirs/ir[2]/align") ) {
- setprop("controls/adirs/display/text", "- - - - " ~ sprintf(" TTN %2i", (getprop("/instrumentation/adirs/ir[2]/display/ttn") / 60)));
- } else if ( (selected_ir == 4) and getprop("/controls/adirs/ir[1]/align") ) {
- setprop("controls/adirs/display/text", "- - - - " ~ sprintf(" TTN %2i", (getprop("/instrumentation/adirs/ir[1]/display/ttn") / 60)));
- } else {
- setprop("/controls/adirs/display/text", "- - - - - - - - ");
- }
- }
- } else if ( data_knob == 6 ) {
- if ( selected_ir == 2 ) {
- setprop("/controls/adirs/display/text","- - - - - - - - ");
- } else if ( selected_ir == 3 ) {
- setprop("/controls/adirs/display/text","- - - - - - - - ");
- } else if ( selected_ir == 4 ) {
- setprop("/controls/adirs/display/text","- - - - - - - - ");
- }
- }
- }
-}
-var skip_ADIRS = func {
- if (getprop("/controls/adirs/ir[0]/knob") == 2) {
- setprop("/instrumentation/adirs/ir[0]/display/ttn",1); # Set it to 1 so it counts down from 1 to 0
- }
- if (getprop("/controls/adirs/ir[1]/knob") == 2) {
- setprop("/instrumentation/adirs/ir[1]/display/ttn",1); # Set it to 1 so it counts down from 1 to 0
- }
- if (getprop("/controls/adirs/ir[2]/knob") == 2) {
- setprop("/instrumentation/adirs/ir[2]/display/ttn",1); # Set it to 1 so it counts down from 1 to 0
- }
-}
-
-var adirs_skip = setlistener("/controls/adirs/skip", func {
- if (getprop("/controls/adirs/skip") == 1) {
- skip_ADIRS();
- }
-});
-
-var adirs_timer = maketimer(1, adirs_display);
+ setprop("/controls/adirs/mcducbtn", 0);
+ setprop("/controls/adirs/mcdu/mode1", ""); # INVAL ALIGN NAV ATT or off (blank)
+ setprop("/controls/adirs/mcdu/mode2", "");
+ setprop("/controls/adirs/mcdu/mode3", "");
+ setprop("/controls/adirs/mcdu/status1", ""); # see smith thales p487
+ setprop("/controls/adirs/mcdu/status2", "");
+ setprop("/controls/adirs/mcdu/status3", "");
+ setprop("/controls/adirs/mcdu/hdg", ""); # only shown if in ATT mode
+ setprop("/controls/adirs/mcdu/avgdrift1", "");
+ setprop("/controls/adirs/mcdu/avgdrift2", "");
+ setprop("/controls/adirs/mcdu/avgdrift3", "");
+ setprop("/controls/adirs/mcducbtn",0);
+ },
+ loop: func() {
+ # Temporary to make instruments work for now
+ setprop("/instrumentation/adirs/ir[0]/aligned", 1);
+ setprop("/instrumentation/adirs/ir[1]/aligned", 1);
+ setprop("/instrumentation/adirs/ir[2]/aligned", 1);
+ },
+};
diff --git a/Nasal/electrical.nas b/Nasal/electrical.nas
index f2a755d5..fd14cf35 100644
--- a/Nasal/electrical.nas
+++ b/Nasal/electrical.nas
@@ -5,10 +5,6 @@
# Copyright (c) Joshua Davidson (it0uchpods) #
##############################################
-#############
-# Init Vars #
-#############
-
var ac_volt_std = 115;
var ac_volt_min = 110;
var dc_volt_std = 28;
@@ -64,408 +60,60 @@ setlistener("/sim/signals/fdm-initialized", func {
var replay = getprop("/sim/replay/replay-state");
});
-var elec_init = func {
- setprop("/controls/switches/annun-test", 0);
- setprop("/controls/electrical/switches/galley", 1);
- setprop("/controls/electrical/switches/idg1", 0);
- setprop("/controls/electrical/switches/idg2", 0);
- setprop("/controls/electrical/switches/gen1", 1);
- setprop("/controls/electrical/switches/gen2", 1);
- setprop("/controls/electrical/switches/emer-gen", 0);
- setprop("/controls/electrical/switches/gen-apu", 1);
- setprop("/controls/electrical/switches/gen-ext", 0);
- setprop("/controls/electrical/switches/apu-ext-crosstie", 1);
- setprop("/controls/electrical/switches/ac-ess-feed", 1);
- 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);
- setprop("/systems/electrical/battery1-amps", 0);
- setprop("/systems/electrical/battery2-amps", 0);
- setprop("/systems/electrical/bus/dc1", 0);
- setprop("/systems/electrical/bus/dc2", 0);
- setprop("/systems/electrical/bus/dcbat", 0);
- setprop("/systems/electrical/bus/dc1-amps", 0);
- setprop("/systems/electrical/bus/dc2-amps", 0);
- setprop("/systems/electrical/bus/dc-ess", 0);
- setprop("/systems/electrical/bus/ac1", 0);
- setprop("/systems/electrical/bus/ac2", 0);
- setprop("/systems/electrical/bus/gen1-hz", 0);
- setprop("/systems/electrical/bus/gen2-hz", 0);
- setprop("/systems/electrical/bus/ac-ess", 0);
- setprop("/systems/electrical/extra/ext-volts", 0);
- setprop("/systems/electrical/extra/apu-volts", 0);
- setprop("/systems/electrical/extra/gen1-volts", 0);
- setprop("/systems/electrical/extra/gen2-volts", 0);
- setprop("/systems/electrical/extra/ext-hz", 0);
- setprop("/systems/electrical/extra/apu-hz", 0);
- setprop("/systems/electrical/extra/galleyshed", 0);
- setprop("/systems/electrical/gen-apu", 0);
- setprop("/systems/electrical/gen-ext", 0);
- setprop("/systems/electrical/on", 0);
- setprop("/systems/electrical/ac1-src", "XX");
- setprop("/systems/electrical/ac2-src", "XX");
- 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);
- setprop("/systems/electrical/gen2-fault", 0);
- setprop("/systems/electrical/idg2-fault", 0);
- 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);
- setprop("/systems/electrical/outputs/nav[2]", 0);
- setprop("/systems/electrical/outputs/nav[3]", 0);
- 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);
- elec_timer.start();
-}
-
-######################
-# Main Electric Loop #
-######################
-
-var master_elec = func {
- 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");
- gen_2_volts = getprop("/systems/electrical/extra/gen2-volts");
- 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");
- replay = getprop("/sim/replay/replay-state");
-
- if (extpwr_on and gen_ext_sw) {
- setprop("/systems/electrical/gen-ext", 1);
- } else {
- setprop("/systems/electrical/gen-ext", 0);
- }
-
- if (rpmapu >= 94.9 and gen_apu_sw and !gen_ext_sw) {
- setprop("/systems/electrical/gen-apu", 1);
- } else {
- setprop("/systems/electrical/gen-apu", 0);
- }
-
- gen_apu = getprop("/systems/electrical/gen-apu");
- gen_ext = getprop("/systems/electrical/gen-ext");
-
- # Left cross tie yes?
- if (stateL == 3 and gen1_sw and !gen1_fail) {
- setprop("/controls/electrical/xtie/xtieR", 1);
- } else if (extpwr_on and gen_ext_sw) {
- setprop("/controls/electrical/xtie/xtieR", 1);
- } else if (rpmapu >= 94.9 and gen_apu_sw and !genapu_fail) {
- setprop("/controls/electrical/xtie/xtieR", 1);
- } else {
- setprop("/controls/electrical/xtie/xtieR", 0);
- }
-
- # Right cross tie yes?
- if (stateR == 3 and gen2_sw and !gen2_fail) {
- setprop("/controls/electrical/xtie/xtieL", 1);
- } else if (extpwr_on and gen_ext_sw) {
- setprop("/controls/electrical/xtie/xtieL", 1);
- } else if (rpmapu >= 94.9 and gen_apu_sw and !genapu_fail) {
- setprop("/controls/electrical/xtie/xtieL", 1);
- } else {
- setprop("/controls/electrical/xtie/xtieL", 0);
- }
-
- xtieL = getprop("/controls/electrical/xtie/xtieL");
- xtieR = getprop("/controls/electrical/xtie/xtieR");
-
- # Left DC bus yes?
- if (stateL == 3 and gen1_sw and !gen1_fail) {
- 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 (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/bus/dc1-amps", dc_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/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);
- } else {
- 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);
- }
- }
-
- # Right DC bus yes?
- if (stateR == 3 and gen2_sw and !gen2_fail) {
- 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 (extpwr_on and gen_ext_sw and apu_ext_crosstie_sw) {
- 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 (gen_apu and !genapu_fail and apu_ext_crosstie_sw) {
- 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);
- } else {
- 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);
- }
- }
-
- # Left AC bus yes?
- if (stateL == 3 and gen1_sw and !gen1_fail) {
- setprop("/systems/electrical/bus/ac1", ac_volt_std);
- ac1_src = "GEN";
- } else if (extpwr_on and gen_ext_sw and apu_ext_crosstie_sw) {
- setprop("/systems/electrical/bus/ac1", ac_volt_std);
- ac1_src = "EXT";
- } else if (gen_apu and !genapu_fail and apu_ext_crosstie_sw) {
- setprop("/systems/electrical/bus/ac1", ac_volt_std);
- ac1_src = "APU";
- } else if (apu_ext_crosstie_sw == 1 and xtieL) {
- setprop("/systems/electrical/bus/ac1", ac_volt_std);
- ac1_src = "XTIE";
- } else if (emergen) {
- setprop("/systems/electrical/bus/ac1", ac_volt_std);
- ac1_src = "RAT";
- } else {
- setprop("/systems/electrical/bus/ac1", 0);
- ac1_src = "XX";
- }
-
- # Right AC bus yes?
- if (stateR == 3 and gen2_sw and !gen2_fail) {
- setprop("/systems/electrical/bus/ac2", ac_volt_std);
- ac2_src = "GEN";
- } else if (extpwr_on and gen_ext_sw and apu_ext_crosstie_sw) {
- setprop("/systems/electrical/bus/ac2", ac_volt_std);
- ac2_src = "EXT";
- } else if (gen_apu and !genapu_fail and apu_ext_crosstie_sw) {
- setprop("/systems/electrical/bus/ac2", ac_volt_std);
- ac2_src = "APU";
- } else if (apu_ext_crosstie_sw == 1 and xtieR) {
- setprop("/systems/electrical/bus/ac2", ac_volt_std);
- ac2_src = "XTIE";
- } else if (emergen) {
- setprop("/systems/electrical/bus/ac2", ac_volt_std);
- ac2_src = "RAT";
- } else {
- setprop("/systems/electrical/bus/ac2", 0);
- ac2_src = "XX";
- }
-
- # HZ/Volts yes?
- 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);
- }
-
- if (stateR == 3 and gen2_sw and !gen2_fail) {
- setprop("/systems/electrical/extra/gen2-volts", ac_volt_std);
- setprop("/systems/electrical/bus/gen2-hz", ac_hz_std);
- } else {
- setprop("/systems/electrical/extra/gen2-volts", 0);
- setprop("/systems/electrical/bus/gen2-hz", 0);
- }
-
- 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);
- }
-
- ac1 = getprop("/systems/electrical/bus/ac1");
- ac2 = getprop("/systems/electrical/bus/ac2");
-
- 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);
- }
-
- ac_ess = getprop("/systems/electrical/bus/ac-ess");
-
- if (ac_ess >= 110 and !gallery_fail) {
- if (galley_sw == 1 and !galley_shed) {
- setprop("/systems/electrical/bus/galley", ac_volt_std);
- } else if (galley_sw or galley_shed) {
- setprop("/systems/electrical/bus/galley", 0);
- }
- } else {
- setprop("/systems/electrical/bus/galley", 0);
- }
-
- if (!gen_apu and !gen_ext_sw and (!gen1_sw or !gen2_sw)) {
- setprop("/systems/electrical/extra/galleyshed", 1);
- } else {
- setprop("/systems/electrical/extra/galleyshed", 0);
- }
-
- if ((ac1 == 0) and (ac2 == 0) and (ias > 100) or (manrat) and replay == 0) {
- setprop("/controls/hydraulic/rat-deployed", 1);
- setprop("/controls/hydraulic/rat", 1);
- setprop("/controls/electrical/switches/emer-gen", 1);
- }
-
- if (ias < 100) {
+var ELEC = {
+ init: func() {
+ setprop("/controls/switches/annun-test", 0);
+ setprop("/controls/electrical/switches/galley", 1);
+ setprop("/controls/electrical/switches/idg1", 0);
+ setprop("/controls/electrical/switches/idg2", 0);
+ setprop("/controls/electrical/switches/gen1", 1);
+ setprop("/controls/electrical/switches/gen2", 1);
setprop("/controls/electrical/switches/emer-gen", 0);
- }
-
- # Battery Amps
- if (battery1_sw and !batt1_fail) {
- setprop("/systems/electrical/battery1-amps", dc_amps_std);
- } else {
+ setprop("/controls/electrical/switches/gen-apu", 1);
+ setprop("/controls/electrical/switches/gen-ext", 0);
+ setprop("/controls/electrical/switches/apu-ext-crosstie", 1);
+ setprop("/controls/electrical/switches/ac-ess-feed", 1);
+ 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);
setprop("/systems/electrical/battery1-amps", 0);
- }
-
- if (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)) {
- setprop("/systems/electrical/bus/dcbat", dc_volt_std);
- } else {
+ setprop("/systems/electrical/bus/dc1", 0);
+ setprop("/systems/electrical/bus/dc2", 0);
setprop("/systems/electrical/bus/dcbat", 0);
- }
-
- 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) {
- decharge1.stop();
- charge1.start();
- } else if (battery1_volts == 27.9 and (dc1 > 25 or dc2 > 25) and battery1_sw and !batt1_fail) {
- charge1.stop();
- decharge1.stop();
- } else if (battery1_sw and !batt1_fail) {
- charge1.stop();
- decharge1.start();
- } else {
- decharge1.stop();
- charge1.stop();
- }
-
- if (battery2_volts < 27.9 and (dc1 > 25 or dc2 > 25) and battery2_sw and !batt2_fail) {
- decharge2.stop();
- charge2.start();
- } 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();
- decharge2.start();
- } else {
- decharge2.stop();
- charge2.stop();
- }
-
- if (getprop("/systems/electrical/bus/ac-ess") < 110) {
- 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);
- }
- setprop("systems/electrical/on", 0);
-# ai_spin.setValue(0.2);
-# aispin.stop();
+ setprop("/systems/electrical/bus/dc1-amps", 0);
+ setprop("/systems/electrical/bus/dc2-amps", 0);
+ setprop("/systems/electrical/bus/dc-ess", 0);
+ setprop("/systems/electrical/bus/ac1", 0);
+ setprop("/systems/electrical/bus/ac2", 0);
+ setprop("/systems/electrical/bus/gen1-hz", 0);
+ setprop("/systems/electrical/bus/gen2-hz", 0);
+ setprop("/systems/electrical/bus/ac-ess", 0);
+ setprop("/systems/electrical/extra/ext-volts", 0);
+ setprop("/systems/electrical/extra/apu-volts", 0);
+ setprop("/systems/electrical/extra/gen1-volts", 0);
+ setprop("/systems/electrical/extra/gen2-volts", 0);
+ setprop("/systems/electrical/extra/ext-hz", 0);
+ setprop("/systems/electrical/extra/apu-hz", 0);
+ setprop("/systems/electrical/extra/galleyshed", 0);
+ setprop("/systems/electrical/gen-apu", 0);
+ setprop("/systems/electrical/gen-ext", 0);
+ setprop("/systems/electrical/on", 0);
+ setprop("/systems/electrical/ac1-src", "XX");
+ setprop("/systems/electrical/ac2-src", "XX");
+ 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);
+ setprop("/systems/electrical/gen2-fault", 0);
+ setprop("/systems/electrical/idg2-fault", 0);
+ 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);
@@ -497,108 +145,435 @@ var master_elec = func {
setprop("/systems/electrical/outputs/taxi-lights", 0);
setprop("/systems/electrical/outputs/transponder", 0);
setprop("/systems/electrical/outputs/turn-coordinator", 0);
- setprop("/controls/lighting/fcu-panel-norm", 0);
- setprop("/controls/lighting/main-panel-norm", 0);
- setprop("/controls/lighting/overhead-panel-norm", 0);
- } else {
- setprop("/systems/electrical/on", 1);
-# aispin.start();
- 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);
- setprop("/systems/electrical/outputs/nav[2]", dc_volt_std);
- setprop("/systems/electrical/outputs/nav[3]", dc_volt_std);
- 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);
- 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"));
- }
-
- setprop("/systems/electrical/ac1-src", ac1_src);
- setprop("/systems/electrical/ac2-src", ac2_src);
-
- # 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);
- }
-
- if ((gen1_fail and gen1_sw) or (gen1_sw and stateL != 3)) {
- 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);
- }
-
- if ((gen2_fail and gen2_sw) or (gen2_sw and stateR != 3)) {
- setprop("/systems/electrical/gen2-fault", 1);
- } else {
- setprop("/systems/electrical/gen2-fault", 0);
- }
-}
-
-###################
-# Update Function #
-###################
-
-var update_electrical = func {
- master_elec();
-}
-
-##########
-# Timers #
-##########
-
-var elec_timer = maketimer(0.2, update_electrical);
+ },
+ loop: func() {
+ 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");
+ gen_2_volts = getprop("/systems/electrical/extra/gen2-volts");
+ 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");
+ replay = getprop("/sim/replay/replay-state");
+
+ if (extpwr_on and gen_ext_sw) {
+ setprop("/systems/electrical/gen-ext", 1);
+ } else {
+ setprop("/systems/electrical/gen-ext", 0);
+ }
+
+ if (rpmapu >= 94.9 and gen_apu_sw and !gen_ext_sw) {
+ setprop("/systems/electrical/gen-apu", 1);
+ } else {
+ setprop("/systems/electrical/gen-apu", 0);
+ }
+
+ gen_apu = getprop("/systems/electrical/gen-apu");
+ gen_ext = getprop("/systems/electrical/gen-ext");
+
+ # Left cross tie yes?
+ if (stateL == 3 and gen1_sw and !gen1_fail) {
+ setprop("/controls/electrical/xtie/xtieR", 1);
+ } else if (extpwr_on and gen_ext_sw) {
+ setprop("/controls/electrical/xtie/xtieR", 1);
+ } else if (rpmapu >= 94.9 and gen_apu_sw and !genapu_fail) {
+ setprop("/controls/electrical/xtie/xtieR", 1);
+ } else {
+ setprop("/controls/electrical/xtie/xtieR", 0);
+ }
+
+ # Right cross tie yes?
+ if (stateR == 3 and gen2_sw and !gen2_fail) {
+ setprop("/controls/electrical/xtie/xtieL", 1);
+ } else if (extpwr_on and gen_ext_sw) {
+ setprop("/controls/electrical/xtie/xtieL", 1);
+ } else if (rpmapu >= 94.9 and gen_apu_sw and !genapu_fail) {
+ setprop("/controls/electrical/xtie/xtieL", 1);
+ } else {
+ setprop("/controls/electrical/xtie/xtieL", 0);
+ }
+
+ xtieL = getprop("/controls/electrical/xtie/xtieL");
+ xtieR = getprop("/controls/electrical/xtie/xtieR");
+
+ # Left DC bus yes?
+ if (stateL == 3 and gen1_sw and !gen1_fail) {
+ 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 (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/bus/dc1-amps", dc_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/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);
+ } else {
+ 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);
+ }
+ }
+
+ # Right DC bus yes?
+ if (stateR == 3 and gen2_sw and !gen2_fail) {
+ 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 (extpwr_on and gen_ext_sw and apu_ext_crosstie_sw) {
+ 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 (gen_apu and !genapu_fail and apu_ext_crosstie_sw) {
+ 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);
+ } else {
+ 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);
+ }
+ }
+
+ # Left AC bus yes?
+ if (stateL == 3 and gen1_sw and !gen1_fail) {
+ setprop("/systems/electrical/bus/ac1", ac_volt_std);
+ ac1_src = "GEN";
+ } else if (extpwr_on and gen_ext_sw and apu_ext_crosstie_sw) {
+ setprop("/systems/electrical/bus/ac1", ac_volt_std);
+ ac1_src = "EXT";
+ } else if (gen_apu and !genapu_fail and apu_ext_crosstie_sw) {
+ setprop("/systems/electrical/bus/ac1", ac_volt_std);
+ ac1_src = "APU";
+ } else if (apu_ext_crosstie_sw == 1 and xtieL) {
+ setprop("/systems/electrical/bus/ac1", ac_volt_std);
+ ac1_src = "XTIE";
+ } else if (emergen) {
+ setprop("/systems/electrical/bus/ac1", ac_volt_std);
+ ac1_src = "RAT";
+ } else {
+ setprop("/systems/electrical/bus/ac1", 0);
+ ac1_src = "XX";
+ }
+
+ # Right AC bus yes?
+ if (stateR == 3 and gen2_sw and !gen2_fail) {
+ setprop("/systems/electrical/bus/ac2", ac_volt_std);
+ ac2_src = "GEN";
+ } else if (extpwr_on and gen_ext_sw and apu_ext_crosstie_sw) {
+ setprop("/systems/electrical/bus/ac2", ac_volt_std);
+ ac2_src = "EXT";
+ } else if (gen_apu and !genapu_fail and apu_ext_crosstie_sw) {
+ setprop("/systems/electrical/bus/ac2", ac_volt_std);
+ ac2_src = "APU";
+ } else if (apu_ext_crosstie_sw == 1 and xtieR) {
+ setprop("/systems/electrical/bus/ac2", ac_volt_std);
+ ac2_src = "XTIE";
+ } else if (emergen) {
+ setprop("/systems/electrical/bus/ac2", ac_volt_std);
+ ac2_src = "RAT";
+ } else {
+ setprop("/systems/electrical/bus/ac2", 0);
+ ac2_src = "XX";
+ }
+
+ # HZ/Volts yes?
+ 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);
+ }
+
+ if (stateR == 3 and gen2_sw and !gen2_fail) {
+ setprop("/systems/electrical/extra/gen2-volts", ac_volt_std);
+ setprop("/systems/electrical/bus/gen2-hz", ac_hz_std);
+ } else {
+ setprop("/systems/electrical/extra/gen2-volts", 0);
+ setprop("/systems/electrical/bus/gen2-hz", 0);
+ }
+
+ 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);
+ }
+
+ ac1 = getprop("/systems/electrical/bus/ac1");
+ ac2 = getprop("/systems/electrical/bus/ac2");
+
+ 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);
+ }
+
+ ac_ess = getprop("/systems/electrical/bus/ac-ess");
+
+ if (ac_ess >= 110 and !gallery_fail) {
+ if (galley_sw == 1 and !galley_shed) {
+ setprop("/systems/electrical/bus/galley", ac_volt_std);
+ } else if (galley_sw or galley_shed) {
+ setprop("/systems/electrical/bus/galley", 0);
+ }
+ } else {
+ setprop("/systems/electrical/bus/galley", 0);
+ }
+
+ if (!gen_apu and !gen_ext_sw and (!gen1_sw or !gen2_sw)) {
+ setprop("/systems/electrical/extra/galleyshed", 1);
+ } else {
+ setprop("/systems/electrical/extra/galleyshed", 0);
+ }
+
+ if ((ac1 == 0) and (ac2 == 0) and (ias > 100) or (manrat) and replay == 0) {
+ setprop("/controls/hydraulic/rat-deployed", 1);
+ setprop("/controls/hydraulic/rat", 1);
+ setprop("/controls/electrical/switches/emer-gen", 1);
+ }
+
+ if (ias < 100) {
+ setprop("/controls/electrical/switches/emer-gen", 0);
+ }
+
+ # Battery Amps
+ if (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) {
+ 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)) {
+ setprop("/systems/electrical/bus/dcbat", dc_volt_std);
+ } else {
+ setprop("/systems/electrical/bus/dcbat", 0);
+ }
+
+ 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) {
+ decharge1.stop();
+ charge1.start();
+ } else if (battery1_volts == 27.9 and (dc1 > 25 or dc2 > 25) and battery1_sw and !batt1_fail) {
+ charge1.stop();
+ decharge1.stop();
+ } else if (battery1_sw and !batt1_fail) {
+ charge1.stop();
+ decharge1.start();
+ } else {
+ decharge1.stop();
+ charge1.stop();
+ }
+
+ if (battery2_volts < 27.9 and (dc1 > 25 or dc2 > 25) and battery2_sw and !batt2_fail) {
+ decharge2.stop();
+ charge2.start();
+ } 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();
+ decharge2.start();
+ } else {
+ decharge2.stop();
+ charge2.stop();
+ }
+
+ if (getprop("/systems/electrical/bus/ac-ess") < 110) {
+ 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);
+ }
+ setprop("systems/electrical/on", 0);
+ 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);
+ setprop("/systems/electrical/outputs/nav[2]", 0);
+ setprop("/systems/electrical/outputs/nav[3]", 0);
+ 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);
+ setprop("/controls/lighting/fcu-panel-norm", 0);
+ setprop("/controls/lighting/main-panel-norm", 0);
+ setprop("/controls/lighting/overhead-panel-norm", 0);
+ } else {
+ setprop("/systems/electrical/on", 1);
+ 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);
+ setprop("/systems/electrical/outputs/nav[2]", dc_volt_std);
+ setprop("/systems/electrical/outputs/nav[3]", dc_volt_std);
+ 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);
+ 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"));
+ }
+
+ setprop("/systems/electrical/ac1-src", ac1_src);
+ setprop("/systems/electrical/ac2-src", ac2_src);
+
+ # 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);
+ }
+
+ if ((gen1_fail and gen1_sw) or (gen1_sw and stateL != 3)) {
+ 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);
+ }
+
+ if ((gen2_fail and gen2_sw) or (gen2_sw and stateR != 3)) {
+ setprop("/systems/electrical/gen2-fault", 1);
+ } else {
+ setprop("/systems/electrical/gen2-fault", 0);
+ }
+ },
+};
var charge1 = maketimer(6, func {
bat1_volts = getprop("/systems/electrical/battery1-volts");
@@ -615,4 +590,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);
-});
\ No newline at end of file
+});
diff --git a/Nasal/fuel.nas b/Nasal/fuel.nas
index eb5dc1cd..84852d6a 100644
--- a/Nasal/fuel.nas
+++ b/Nasal/fuel.nas
@@ -5,10 +5,6 @@
# Copyright (c) Joshua Davidson (it0uchpods) #
##############################################
-#############
-# Init Vars #
-#############
-
setlistener("/sim/signals/fdm-initialized", func {
var xfeed_sw = getprop("/controls/fuel/x-feed");
var tank0pump1_sw = getprop("/controls/fuel/tank0pump1");
@@ -39,177 +35,164 @@ setlistener("/sim/signals/fdm-initialized", func {
var tank2pump2_fail = getprop("/systems/failures/tank2pump2");
});
-var fuel_init = func {
- setprop("/systems/fuel/gravityfeedL", 0);
- setprop("/systems/fuel/gravityfeedR", 0);
- setprop("/systems/fuel/gravityfeedL-output", 0);
- setprop("/systems/fuel/gravityfeedR-output", 0);
- setprop("/controls/fuel/x-feed", 0);
- setprop("/controls/fuel/tank0pump1", 0);
- setprop("/controls/fuel/tank0pump2", 0);
- setprop("/controls/fuel/tank1pump1", 0);
- setprop("/controls/fuel/tank1pump2", 0);
- setprop("/controls/fuel/tank2pump1", 0);
- setprop("/controls/fuel/tank2pump2", 0);
- setprop("/controls/fuel/mode", 1);
- setprop("/systems/fuel/x-feed", 0);
- setprop("/systems/fuel/tank[0]/feed", 0);
- setprop("/systems/fuel/tank[1]/feed", 0);
- setprop("/systems/fuel/tank[2]/feed", 0);
- setprop("/systems/fuel/only-use-ctr-tank", 0);
- setprop("/systems/fuel/tank0pump1-fault", 0);
- setprop("/systems/fuel/tank0pump2-fault", 0);
- setprop("/systems/fuel/tank1pump1-fault", 0);
- setprop("/systems/fuel/tank1pump2-fault", 0);
- setprop("/systems/fuel/tank2pump1-fault", 0);
- setprop("/systems/fuel/tank2pump2-fault", 0);
- setprop("/systems/fuel/mode-fault", 0);
- fuel_timer.start();
-}
-
-##############
-# Main Loops #
-##############
-var master_fuel = func {
- xfeed_sw = getprop("/controls/fuel/x-feed");
- tank0pump1_sw = getprop("/controls/fuel/tank0pump1");
- tank0pump2_sw = getprop("/controls/fuel/tank0pump2");
- tank1pump1_sw = getprop("/controls/fuel/tank1pump1");
- tank1pump2_sw = getprop("/controls/fuel/tank1pump2");
- tank2pump1_sw = getprop("/controls/fuel/tank2pump1");
- tank2pump2_sw = getprop("/controls/fuel/tank2pump2");
- mode_sw = getprop("/controls/fuel/mode");
- xfeed = getprop("/systems/fuel/x-feed");
- ac1 = getprop("/systems/electrical/bus/ac1");
- ac2 = getprop("/systems/electrical/bus/ac2");
- gravityfeedL = getprop("/systems/fuel/gravityfeedL");
- gravityfeedR = getprop("/systems/fuel/gravityfeedR");
- gload = getprop("/accelerations/pilot-gdamped");
- tank0pump1_fail = getprop("/systems/failures/tank0pump1");
- tank0pump2_fail = getprop("/systems/failures/tank0pump2");
- tank1pump1_fail = getprop("/systems/failures/tank1pump1");
- tank1pump2_fail = getprop("/systems/failures/tank1pump2");
- tank2pump1_fail = getprop("/systems/failures/tank2pump1");
- tank2pump2_fail = getprop("/systems/failures/tank2pump2");
-
- if (gload >= 0.7 and gravityfeedL) {
- setprop("/systems/fuel/gravityfeedL-output", 1);
- } else {
- setprop("/systems/fuel/gravityfeedL-output", 0);
- }
-
- if (gload >= 0.7 and gravityfeedR) {
- setprop("/systems/fuel/gravityfeedR-output", 1);
- } else {
- setprop("/systems/fuel/gravityfeedR-output", 0);
- }
-
- gravityfeedL_output = getprop("/systems/fuel/gravityfeedL-output");
- gravityfeedR_output = getprop("/systems/fuel/gravityfeedR-output");
-
- if ((ac1 >= 110 or ac2 >= 110) and tank0pump1_sw and !tank0pump1_fail) {
- setprop("/systems/fuel/tank[0]/feed", 1);
- } else if ((ac1 >= 110 or ac2 >= 110) and tank0pump2_sw and !tank0pump2_fail) {
- setprop("/systems/fuel/tank[0]/feed", 1);
- } else if (gravityfeedL_output) {
- setprop("/systems/fuel/tank[0]/feed", 1);
- } else {
- setprop("/systems/fuel/tank[0]/feed", 0);
- }
-
- if ((ac1 >= 110 or ac2 >= 110) and tank1pump1_sw and !tank1pump1_fail) {
- setprop("/systems/fuel/tank[1]/feed", 1);
- } else if ((ac1 >= 110 or ac2 >= 110) and tank1pump2_sw and !tank1pump2_fail) {
- setprop("/systems/fuel/tank[1]/feed", 1);
- } else {
- setprop("/systems/fuel/tank[1]/feed", 0);
- }
-
- if ((ac1 >= 110 or ac2 >= 110) and tank2pump1_sw and !tank2pump1_fail) {
- setprop("/systems/fuel/tank[2]/feed", 1);
- } else if ((ac1 >= 110 or ac2 >= 110) and tank2pump2_sw and !tank2pump2_fail) {
- setprop("/systems/fuel/tank[2]/feed", 1);
- } else if (gravityfeedR_output) {
- setprop("/systems/fuel/tank[2]/feed", 1);
- } else {
- setprop("/systems/fuel/tank[2]/feed", 0);
- }
-
- if ((ac1 >= 110 or ac2 >= 110) and xfeed_sw) {
- setprop("/systems/fuel/x-feed", 1);
- } else {
- setprop("/systems/fuel/x-feed", 0);
- }
-
- tank0 = getprop("/systems/fuel/tank[0]/feed");
- tank1 = getprop("/systems/fuel/tank[1]/feed");
- tank2 = getprop("/systems/fuel/tank[2]/feed");
-
- if ((ac1 >= 110 or ac2 >= 110) and (tank0pump1_sw or tank0pump2_sw)) {
+var FUEL = {
+ init: func() {
setprop("/systems/fuel/gravityfeedL", 0);
- } else {
- setprop("/systems/fuel/gravityfeedL", 1);
- }
-
- if ((ac1 >= 110 or ac2 >= 110) and (tank2pump1_sw or tank2pump2_sw)) {
setprop("/systems/fuel/gravityfeedR", 0);
- } else {
- setprop("/systems/fuel/gravityfeedR", 1);
- }
-
- gravityfeedL = getprop("/systems/fuel/gravityfeedL");
- gravityfeedR = getprop("/systems/fuel/gravityfeedR");
-
- if ((getprop("/fdm/jsbsim/propulsion/tank[1]/contents-lbs") >= 50) and (tank1pump1_sw or tank1pump2_sw) and !gravityfeedL and !gravityfeedR) {
- setprop("/systems/fuel/only-use-ctr-tank", 1);
- } else {
+ setprop("/systems/fuel/gravityfeedL-output", 0);
+ setprop("/systems/fuel/gravityfeedR-output", 0);
+ setprop("/controls/fuel/x-feed", 0);
+ setprop("/controls/fuel/tank0pump1", 0);
+ setprop("/controls/fuel/tank0pump2", 0);
+ setprop("/controls/fuel/tank1pump1", 0);
+ setprop("/controls/fuel/tank1pump2", 0);
+ setprop("/controls/fuel/tank2pump1", 0);
+ setprop("/controls/fuel/tank2pump2", 0);
+ setprop("/controls/fuel/mode", 1);
+ setprop("/systems/fuel/x-feed", 0);
+ setprop("/systems/fuel/tank[0]/feed", 0);
+ setprop("/systems/fuel/tank[1]/feed", 0);
+ setprop("/systems/fuel/tank[2]/feed", 0);
setprop("/systems/fuel/only-use-ctr-tank", 0);
- }
-
- # Fault lights
- if (tank0pump1_sw and tank0pump1_fail) {
- setprop("/systems/fuel/tank0pump1-fault", 1);
- } else {
setprop("/systems/fuel/tank0pump1-fault", 0);
- }
-
- if (tank0pump2_sw and tank0pump2_fail) {
- setprop("/systems/fuel/tank0pump2-fault", 1);
- } else {
setprop("/systems/fuel/tank0pump2-fault", 0);
- }
-
- if (tank1pump1_sw and tank1pump1_fail) {
- setprop("/systems/fuel/tank1pump1-fault", 1);
- } else {
setprop("/systems/fuel/tank1pump1-fault", 0);
- }
-
- if (tank1pump2_sw and tank1pump2_fail) {
- setprop("/systems/fuel/tank1pump2-fault", 1);
- } else {
setprop("/systems/fuel/tank1pump2-fault", 0);
- }
-
- if (tank2pump1_sw and tank2pump1_fail) {
- setprop("/systems/fuel/tank2pump1-fault", 1);
- } else {
setprop("/systems/fuel/tank2pump1-fault", 0);
- }
-
- if (tank2pump2_sw and tank2pump2_fail) {
- setprop("/systems/fuel/tank2pump2-fault", 1);
- } else {
setprop("/systems/fuel/tank2pump2-fault", 0);
- }
-}
-
-###################
-# Update Function #
-###################
-
-var update_fuel = func {
- master_fuel();
-}
-
-var fuel_timer = maketimer(0.2, update_fuel);
+ setprop("/systems/fuel/mode-fault", 0);
+ },
+ loop: func() {
+ xfeed_sw = getprop("/controls/fuel/x-feed");
+ tank0pump1_sw = getprop("/controls/fuel/tank0pump1");
+ tank0pump2_sw = getprop("/controls/fuel/tank0pump2");
+ tank1pump1_sw = getprop("/controls/fuel/tank1pump1");
+ tank1pump2_sw = getprop("/controls/fuel/tank1pump2");
+ tank2pump1_sw = getprop("/controls/fuel/tank2pump1");
+ tank2pump2_sw = getprop("/controls/fuel/tank2pump2");
+ mode_sw = getprop("/controls/fuel/mode");
+ xfeed = getprop("/systems/fuel/x-feed");
+ ac1 = getprop("/systems/electrical/bus/ac1");
+ ac2 = getprop("/systems/electrical/bus/ac2");
+ gravityfeedL = getprop("/systems/fuel/gravityfeedL");
+ gravityfeedR = getprop("/systems/fuel/gravityfeedR");
+ gload = getprop("/accelerations/pilot-gdamped");
+ tank0pump1_fail = getprop("/systems/failures/tank0pump1");
+ tank0pump2_fail = getprop("/systems/failures/tank0pump2");
+ tank1pump1_fail = getprop("/systems/failures/tank1pump1");
+ tank1pump2_fail = getprop("/systems/failures/tank1pump2");
+ tank2pump1_fail = getprop("/systems/failures/tank2pump1");
+ tank2pump2_fail = getprop("/systems/failures/tank2pump2");
+
+ if (gload >= 0.7 and gravityfeedL) {
+ setprop("/systems/fuel/gravityfeedL-output", 1);
+ } else {
+ setprop("/systems/fuel/gravityfeedL-output", 0);
+ }
+
+ if (gload >= 0.7 and gravityfeedR) {
+ setprop("/systems/fuel/gravityfeedR-output", 1);
+ } else {
+ setprop("/systems/fuel/gravityfeedR-output", 0);
+ }
+
+ gravityfeedL_output = getprop("/systems/fuel/gravityfeedL-output");
+ gravityfeedR_output = getprop("/systems/fuel/gravityfeedR-output");
+
+ if ((ac1 >= 110 or ac2 >= 110) and tank0pump1_sw and !tank0pump1_fail) {
+ setprop("/systems/fuel/tank[0]/feed", 1);
+ } else if ((ac1 >= 110 or ac2 >= 110) and tank0pump2_sw and !tank0pump2_fail) {
+ setprop("/systems/fuel/tank[0]/feed", 1);
+ } else if (gravityfeedL_output) {
+ setprop("/systems/fuel/tank[0]/feed", 1);
+ } else {
+ setprop("/systems/fuel/tank[0]/feed", 0);
+ }
+
+ if ((ac1 >= 110 or ac2 >= 110) and tank1pump1_sw and !tank1pump1_fail) {
+ setprop("/systems/fuel/tank[1]/feed", 1);
+ } else if ((ac1 >= 110 or ac2 >= 110) and tank1pump2_sw and !tank1pump2_fail) {
+ setprop("/systems/fuel/tank[1]/feed", 1);
+ } else {
+ setprop("/systems/fuel/tank[1]/feed", 0);
+ }
+
+ if ((ac1 >= 110 or ac2 >= 110) and tank2pump1_sw and !tank2pump1_fail) {
+ setprop("/systems/fuel/tank[2]/feed", 1);
+ } else if ((ac1 >= 110 or ac2 >= 110) and tank2pump2_sw and !tank2pump2_fail) {
+ setprop("/systems/fuel/tank[2]/feed", 1);
+ } else if (gravityfeedR_output) {
+ setprop("/systems/fuel/tank[2]/feed", 1);
+ } else {
+ setprop("/systems/fuel/tank[2]/feed", 0);
+ }
+
+ if ((ac1 >= 110 or ac2 >= 110) and xfeed_sw) {
+ setprop("/systems/fuel/x-feed", 1);
+ } else {
+ setprop("/systems/fuel/x-feed", 0);
+ }
+
+ tank0 = getprop("/systems/fuel/tank[0]/feed");
+ tank1 = getprop("/systems/fuel/tank[1]/feed");
+ tank2 = getprop("/systems/fuel/tank[2]/feed");
+
+ if ((ac1 >= 110 or ac2 >= 110) and (tank0pump1_sw or tank0pump2_sw)) {
+ setprop("/systems/fuel/gravityfeedL", 0);
+ } else {
+ setprop("/systems/fuel/gravityfeedL", 1);
+ }
+
+ if ((ac1 >= 110 or ac2 >= 110) and (tank2pump1_sw or tank2pump2_sw)) {
+ setprop("/systems/fuel/gravityfeedR", 0);
+ } else {
+ setprop("/systems/fuel/gravityfeedR", 1);
+ }
+
+ gravityfeedL = getprop("/systems/fuel/gravityfeedL");
+ gravityfeedR = getprop("/systems/fuel/gravityfeedR");
+
+ if ((getprop("/fdm/jsbsim/propulsion/tank[1]/contents-lbs") >= 50) and (tank1pump1_sw or tank1pump2_sw) and !gravityfeedL and !gravityfeedR) {
+ setprop("/systems/fuel/only-use-ctr-tank", 1);
+ } else {
+ setprop("/systems/fuel/only-use-ctr-tank", 0);
+ }
+
+ # Fault lights
+ if (tank0pump1_sw and tank0pump1_fail) {
+ setprop("/systems/fuel/tank0pump1-fault", 1);
+ } else {
+ setprop("/systems/fuel/tank0pump1-fault", 0);
+ }
+
+ if (tank0pump2_sw and tank0pump2_fail) {
+ setprop("/systems/fuel/tank0pump2-fault", 1);
+ } else {
+ setprop("/systems/fuel/tank0pump2-fault", 0);
+ }
+
+ if (tank1pump1_sw and tank1pump1_fail) {
+ setprop("/systems/fuel/tank1pump1-fault", 1);
+ } else {
+ setprop("/systems/fuel/tank1pump1-fault", 0);
+ }
+
+ if (tank1pump2_sw and tank1pump2_fail) {
+ setprop("/systems/fuel/tank1pump2-fault", 1);
+ } else {
+ setprop("/systems/fuel/tank1pump2-fault", 0);
+ }
+
+ if (tank2pump1_sw and tank2pump1_fail) {
+ setprop("/systems/fuel/tank2pump1-fault", 1);
+ } else {
+ setprop("/systems/fuel/tank2pump1-fault", 0);
+ }
+
+ if (tank2pump2_sw and tank2pump2_fail) {
+ setprop("/systems/fuel/tank2pump2-fault", 1);
+ } else {
+ setprop("/systems/fuel/tank2pump2-fault", 0);
+ }
+ },
+};
diff --git a/Nasal/hydraulics.nas b/Nasal/hydraulics.nas
index 97c1e190..67a22bf1 100644
--- a/Nasal/hydraulics.nas
+++ b/Nasal/hydraulics.nas
@@ -5,10 +5,6 @@
# Copyright (c) Joshua Davidson (it0uchpods) #
##############################################
-#############
-# Init Vars #
-#############
-
setlistener("/sim/signals/fdm-initialized", func {
var eng1_pump_sw = getprop("/controls/hydraulic/eng1-pump");
var eng2_pump_sw = getprop("/controls/hydraulic/eng2-pump");
@@ -51,220 +47,212 @@ setlistener("/sim/signals/fdm-initialized", func {
var down = getprop("/controls/gear/gear-down");
});
-var hyd_init = func {
- setprop("/controls/hydraulic/eng1-pump", 1);
- setprop("/controls/hydraulic/eng2-pump", 1);
- setprop("/controls/hydraulic/elec-pump-blue", 1);
- setprop("/controls/hydraulic/elec-pump-yellow", 0);
- setprop("/controls/hydraulic/hand-pump-yellow", 0);
- setprop("/controls/hydraulic/ptu", 1);
- setprop("/controls/hydraulic/rat-man", 0);
- setprop("/controls/hydraulic/rat", 0);
- setprop("/controls/hydraulic/rat-deployed", 0);
- setprop("/systems/hydraulic/ptu-active", 0);
- setprop("/systems/hydraulic/blue-psi", 0);
- setprop("/systems/hydraulic/green-psi", 0);
- setprop("/systems/hydraulic/yellow-psi", 0);
- setprop("/controls/gear/brake-parking", 0);
- setprop("/systems/hydraulic/brakes/accumulator-pressure-psi", 0);
- setprop("/systems/hydraulic/brakes/pressure-left-psi", 0);
- setprop("/systems/hydraulic/brakes/pressure-right-psi", 0);
- setprop("/systems/hydraulic/brakes/askidnwssw", 1);
- setprop("/systems/hydraulic/brakes/mode", 0);
- setprop("/systems/hydraulic/brakes/lbrake", 0);
- setprop("/systems/hydraulic/brakes/rbrake", 0);
- setprop("/systems/hydraulic/brakes/nose-rubber", 0); # This stops the nose from spinning when you raise the gear
- setprop("/systems/hydraulic/brakes/counter", 0);
- setprop("/systems/hydraulic/brakes/accumulator-pressure-psi-1", 0);
- setprop("/systems/hydraulic/eng1-pump-fault", 0);
- setprop("/systems/hydraulic/eng2-pump-fault", 0);
- setprop("/systems/hydraulic/elec-pump-b-fault", 0);
- setprop("/systems/hydraulic/elec-pump-y-fault", 0);
- setprop("/systems/hydraulic/ptu-fault", 0);
- hyd_timer.start();
-}
-
-#######################
-# Main Hydraulic Loop #
-#######################
-
-var master_hyd = func {
- eng1_pump_sw = getprop("/controls/hydraulic/eng1-pump");
- eng2_pump_sw = getprop("/controls/hydraulic/eng2-pump");
- elec_pump_blue_sw = getprop("/controls/hydraulic/elec-pump-blue");
- elec_pump_yellow_sw = getprop("/controls/hydraulic/elec-pump-yellow");
- yellow_hand_pump = getprop("/controls/hydraulic/hand-pump-yellow");
- ptu_sw = getprop("/controls/hydraulic/ptu");
- rat_man_sw = getprop("/controls/hydraulic/rat-man");
- blue_psi = getprop("/systems/hydraulic/blue-psi");
- green_psi = getprop("/systems/hydraulic/green-psi");
- yellow_psi = getprop("/systems/hydraulic/yellow-psi");
- rpmapu = getprop("/systems/apu/rpm");
- stateL = getprop("/engines/engine[0]/state");
- stateR = getprop("/engines/engine[1]/state");
- dc_ess = getprop("/systems/electrical/bus/dc-ess");
- psi_diff = green_psi - yellow_psi;
- rat = getprop("/controls/hydraulic/rat");
- ratout = getprop("/controls/hydraulic/rat-deployed");
- gs = getprop("/velocities/groundspeed-kt");
- blue_leak = getprop("/systems/failures/hyd-blue");
- green_leak = getprop("/systems/failures/hyd-green");
- yellow_leak = getprop("/systems/failures/hyd-yellow");
- blue_pump_fail = getprop("/systems/failures/pump-blue");
- green_pump_fail = getprop("/systems/failures/pump-green");
- yellow_pump_eng_fail = getprop("/systems/failures/pump-yellow-eng");
- yellow_pump_elec_fail = getprop("/systems/failures/pump-yellow-elec");
- ptu_fail = getprop("/systems/failures/ptu");
- dc2 = getprop("/systems/electrical/bus/dc2");
-
- if ((psi_diff > 500 or psi_diff < -500) and ptu_sw and dc2 > 25) {
- setprop("/systems/hydraulic/ptu-active", 1);
- } else if (psi_diff < 20 and psi_diff > -20) {
- setprop("/systems/hydraulic/ptu-active", 0);
- }
-
- if ((rat_man_sw == 1 or getprop("/controls/electrical/switches/emer-gen") == 1) and (gs > 100)) {
- setprop("/controls/hydraulic/rat", 1);
- setprop("/controls/hydraulic/rat-deployed", 1);
- } else if (gs < 100) {
+var HYD = {
+ init: func() {
+ setprop("/controls/hydraulic/eng1-pump", 1);
+ setprop("/controls/hydraulic/eng2-pump", 1);
+ setprop("/controls/hydraulic/elec-pump-blue", 1);
+ setprop("/controls/hydraulic/elec-pump-yellow", 0);
+ setprop("/controls/hydraulic/hand-pump-yellow", 0);
+ setprop("/controls/hydraulic/ptu", 1);
+ setprop("/controls/hydraulic/rat-man", 0);
setprop("/controls/hydraulic/rat", 0);
- }
-
- ptu_active = getprop("/systems/hydraulic/ptu-active");
-
- if ((elec_pump_blue_sw and dc_ess >= 25 and !blue_pump_fail) and (stateL == 3 or stateR == 3) and !blue_leak) {
- if (blue_psi < 2900) {
- setprop("/systems/hydraulic/blue-psi", blue_psi + 100);
- } else {
- setprop("/systems/hydraulic/blue-psi", 3000);
- }
- } else if (gs >= 100 and rat and !blue_leak) {
- if (blue_psi < 2400) {
- setprop("/systems/hydraulic/blue-psi", blue_psi + 100);
- } else {
- setprop("/systems/hydraulic/blue-psi", 2500);
- }
- } else {
- if (blue_psi > 1) {
- setprop("/systems/hydraulic/blue-psi", blue_psi - 50);
- } else {
- setprop("/systems/hydraulic/blue-psi", 0);
- }
- }
-
- if ((eng1_pump_sw and stateL == 3 and !green_pump_fail) and !green_leak) {
- if (green_psi < 2900) {
- setprop("/systems/hydraulic/green-psi", green_psi + 100);
- } else {
- setprop("/systems/hydraulic/green-psi", 3000);
- }
- } else if ((ptu_active and stateL != 3 and !ptu_fail) and !green_leak) {
- if (green_psi < 2900) {
- setprop("/systems/hydraulic/green-psi", green_psi + 100);
- } else {
- setprop("/systems/hydraulic/green-psi", 3000);
- }
- } else {
- if (green_psi > 1) {
- setprop("/systems/hydraulic/green-psi", green_psi - 50);
- } else {
- setprop("/systems/hydraulic/green-psi", 0);
- }
- }
-
- if ((eng2_pump_sw and stateR == 3 and !yellow_pump_eng_fail) and !yellow_leak) {
- if (yellow_psi < 2900) {
- setprop("/systems/hydraulic/yellow-psi", yellow_psi + 100);
- } else {
- setprop("/systems/hydraulic/yellow-psi", 3000);
- }
- } else if ((elec_pump_yellow_sw and dc_ess >= 25 and !yellow_pump_elec_fail) and !yellow_leak) {
- if (yellow_psi < 2900) {
- setprop("/systems/hydraulic/yellow-psi", yellow_psi + 100);
- } else {
- setprop("/systems/hydraulic/yellow-psi", 3000);
- }
- } else if ((ptu_active and stateR != 3 and !ptu_fail) and !yellow_leak) {
- if (yellow_psi < 2900) {
- setprop("/systems/hydraulic/yellow-psi", yellow_psi + 100);
- } else {
- setprop("/systems/hydraulic/yellow-psi", 3000);
- }
- } else if (yellow_hand_pump and !yellow_leak and (getprop("/gear/gear[0]/wow") or getprop("/gear/gear[1]/wow") or getprop("/gear/gear[2]/wow"))) {
- if (yellow_psi < 2900) {
- setprop("/systems/hydraulic/yellow-psi", yellow_psi + 50);
- } else {
- setprop("/systems/hydraulic/yellow-psi", 3000);
- }
- } else {
- if (yellow_psi > 1) {
- setprop("/systems/hydraulic/yellow-psi", yellow_psi - 50);
- } else {
- setprop("/systems/hydraulic/yellow-psi", 0);
- }
- }
-
- accum = getprop("/systems/hydraulic/brakes/accumulator-pressure-psi");
- lpsi = getprop("/systems/hydraulic/brakes/pressure-left-psi");
- rpsi = getprop("/systems/hydraulic/brakes/pressure-right-psi");
- parking = getprop("/controls/gear/brake-parking");
- askidnws_sw = getprop("/systems/hydraulic/brakes/askidnwssw");
- brake_mode = getprop("/systems/hydraulic/brakes/mode");
- brake_l = getprop("/systems/hydraulic/brakes/lbrake");
- brake_r = getprop("/systems/hydraulic/brakes/rbrake");
- brake_nose = getprop("/systems/hydraulic/brakes/nose-rubber");
- counter = getprop("/systems/hydraulic/brakes/counter");
-
- if (!parking and askidnws_sw and green_psi > 2500) {
- # set mode to on
- setprop("/systems/hydraulic/brakes/mode", 1);
- } else if ((!parking and askidnws_sw and yellow_psi > 2500) or (!parking and askidnws_sw and accum > 0)) {
- # set mode to altn
- setprop("/systems/hydraulic/brakes/mode", 2);
- } else {
- # set mode to off
+ setprop("/controls/hydraulic/rat-deployed", 0);
+ setprop("/systems/hydraulic/ptu-active", 0);
+ setprop("/systems/hydraulic/blue-psi", 0);
+ setprop("/systems/hydraulic/green-psi", 0);
+ setprop("/systems/hydraulic/yellow-psi", 0);
+ setprop("/controls/gear/brake-parking", 0);
+ setprop("/systems/hydraulic/brakes/accumulator-pressure-psi", 0);
+ setprop("/systems/hydraulic/brakes/pressure-left-psi", 0);
+ setprop("/systems/hydraulic/brakes/pressure-right-psi", 0);
+ setprop("/systems/hydraulic/brakes/askidnwssw", 1);
setprop("/systems/hydraulic/brakes/mode", 0);
- }
-
- if (brake_mode == 2 and yellow_psi > 2500 and accum < 700) {
- setprop("/systems/hydraulic/brakes/accumulator-pressure-psi", accum + 50);
- }
-
- # Fault lights
- if (green_pump_fail and eng1_pump_sw) {
- setprop("/systems/hydraulic/eng1-pump-fault", 1);
- } else {
+ setprop("/systems/hydraulic/brakes/lbrake", 0);
+ setprop("/systems/hydraulic/brakes/rbrake", 0);
+ setprop("/systems/hydraulic/brakes/nose-rubber", 0);
+ setprop("/systems/hydraulic/brakes/counter", 0);
+ setprop("/systems/hydraulic/brakes/accumulator-pressure-psi-1", 0);
setprop("/systems/hydraulic/eng1-pump-fault", 0);
- }
-
- if (blue_pump_fail and elec_pump_blue_sw) {
- setprop("/systems/hydraulic/elec-pump-b-fault", 1);
- } else {
- setprop("/systems/hydraulic/elec-pump-b-fault", 0);
- }
-
- if (ptu_fail and ptu_sw) {
- setprop("/systems/hydraulic/ptu-fault", 1);
- } else {
- setprop("/systems/hydraulic/ptu-fault", 0);
- }
-
- if (yellow_pump_eng_fail and eng2_pump_sw) {
- setprop("/systems/hydraulic/eng2-pump-fault", 1);
- } else {
setprop("/systems/hydraulic/eng2-pump-fault", 0);
- }
-
- if (yellow_pump_elec_fail and elec_pump_yellow_sw) {
- setprop("/systems/hydraulic/elec-pump-y-fault", 1);
- } else {
+ setprop("/systems/hydraulic/elec-pump-b-fault", 0);
setprop("/systems/hydraulic/elec-pump-y-fault", 0);
- }
-}
+ setprop("/systems/hydraulic/ptu-fault", 0);
+ },
+ loop: func() {
+ eng1_pump_sw = getprop("/controls/hydraulic/eng1-pump");
+ eng2_pump_sw = getprop("/controls/hydraulic/eng2-pump");
+ elec_pump_blue_sw = getprop("/controls/hydraulic/elec-pump-blue");
+ elec_pump_yellow_sw = getprop("/controls/hydraulic/elec-pump-yellow");
+ yellow_hand_pump = getprop("/controls/hydraulic/hand-pump-yellow");
+ ptu_sw = getprop("/controls/hydraulic/ptu");
+ rat_man_sw = getprop("/controls/hydraulic/rat-man");
+ blue_psi = getprop("/systems/hydraulic/blue-psi");
+ green_psi = getprop("/systems/hydraulic/green-psi");
+ yellow_psi = getprop("/systems/hydraulic/yellow-psi");
+ rpmapu = getprop("/systems/apu/rpm");
+ stateL = getprop("/engines/engine[0]/state");
+ stateR = getprop("/engines/engine[1]/state");
+ dc_ess = getprop("/systems/electrical/bus/dc-ess");
+ psi_diff = green_psi - yellow_psi;
+ rat = getprop("/controls/hydraulic/rat");
+ ratout = getprop("/controls/hydraulic/rat-deployed");
+ gs = getprop("/velocities/groundspeed-kt");
+ blue_leak = getprop("/systems/failures/hyd-blue");
+ green_leak = getprop("/systems/failures/hyd-green");
+ yellow_leak = getprop("/systems/failures/hyd-yellow");
+ blue_pump_fail = getprop("/systems/failures/pump-blue");
+ green_pump_fail = getprop("/systems/failures/pump-green");
+ yellow_pump_eng_fail = getprop("/systems/failures/pump-yellow-eng");
+ yellow_pump_elec_fail = getprop("/systems/failures/pump-yellow-elec");
+ ptu_fail = getprop("/systems/failures/ptu");
+ dc2 = getprop("/systems/electrical/bus/dc2");
+
+ if ((psi_diff > 500 or psi_diff < -500) and ptu_sw and dc2 > 25) {
+ setprop("/systems/hydraulic/ptu-active", 1);
+ } else if (psi_diff < 20 and psi_diff > -20) {
+ setprop("/systems/hydraulic/ptu-active", 0);
+ }
-#######################
-# Various Other Stuff #
-#######################
+ if ((rat_man_sw == 1 or getprop("/controls/electrical/switches/emer-gen") == 1) and (gs > 100)) {
+ setprop("/controls/hydraulic/rat", 1);
+ setprop("/controls/hydraulic/rat-deployed", 1);
+ } else if (gs < 100) {
+ setprop("/controls/hydraulic/rat", 0);
+ }
+
+ ptu_active = getprop("/systems/hydraulic/ptu-active");
+
+ if ((elec_pump_blue_sw and dc_ess >= 25 and !blue_pump_fail) and (stateL == 3 or stateR == 3) and !blue_leak) {
+ if (blue_psi < 2900) {
+ setprop("/systems/hydraulic/blue-psi", blue_psi + 50);
+ } else {
+ setprop("/systems/hydraulic/blue-psi", 3000);
+ }
+ } else if (gs >= 50 and rat and !blue_leak) {
+ if (blue_psi < 2400) {
+ setprop("/systems/hydraulic/blue-psi", blue_psi + 50);
+ } else {
+ setprop("/systems/hydraulic/blue-psi", 2250);
+ }
+ } else {
+ if (blue_psi > 1) {
+ setprop("/systems/hydraulic/blue-psi", blue_psi - 25);
+ } else {
+ setprop("/systems/hydraulic/blue-psi", 0);
+ }
+ }
+
+ if ((eng1_pump_sw and stateL == 3 and !green_pump_fail) and !green_leak) {
+ if (green_psi < 2900) {
+ setprop("/systems/hydraulic/green-psi", green_psi + 50);
+ } else {
+ setprop("/systems/hydraulic/green-psi", 3000);
+ }
+ } else if ((ptu_active and stateL != 3 and !ptu_fail) and !green_leak) {
+ if (green_psi < 2900) {
+ setprop("/systems/hydraulic/green-psi", green_psi + 50);
+ } else {
+ setprop("/systems/hydraulic/green-psi", 3000);
+ }
+ } else {
+ if (green_psi > 1) {
+ setprop("/systems/hydraulic/green-psi", green_psi - 25);
+ } else {
+ setprop("/systems/hydraulic/green-psi", 0);
+ }
+ }
+
+ if ((eng2_pump_sw and stateR == 3 and !yellow_pump_eng_fail) and !yellow_leak) {
+ if (yellow_psi < 2900) {
+ setprop("/systems/hydraulic/yellow-psi", yellow_psi + 50);
+ } else {
+ setprop("/systems/hydraulic/yellow-psi", 3000);
+ }
+ } else if ((elec_pump_yellow_sw and dc_ess >= 25 and !yellow_pump_elec_fail) and !yellow_leak) {
+ if (yellow_psi < 2900) {
+ setprop("/systems/hydraulic/yellow-psi", yellow_psi + 50);
+ } else {
+ setprop("/systems/hydraulic/yellow-psi", 3000);
+ }
+ } else if ((ptu_active and stateR != 3 and !ptu_fail) and !yellow_leak) {
+ if (yellow_psi < 2900) {
+ setprop("/systems/hydraulic/yellow-psi", yellow_psi + 50);
+ } else {
+ setprop("/systems/hydraulic/yellow-psi", 3000);
+ }
+ } else if (yellow_hand_pump and !yellow_leak and (getprop("/gear/gear[0]/wow") or getprop("/gear/gear[1]/wow") or getprop("/gear/gear[2]/wow"))) {
+ if (yellow_psi < 2900) {
+ setprop("/systems/hydraulic/yellow-psi", yellow_psi + 25);
+ } else {
+ setprop("/systems/hydraulic/yellow-psi", 3000);
+ }
+ } else {
+ if (yellow_psi > 1) {
+ setprop("/systems/hydraulic/yellow-psi", yellow_psi - 25);
+ } else {
+ setprop("/systems/hydraulic/yellow-psi", 0);
+ }
+ }
+
+ accum = getprop("/systems/hydraulic/brakes/accumulator-pressure-psi");
+ lpsi = getprop("/systems/hydraulic/brakes/pressure-left-psi");
+ rpsi = getprop("/systems/hydraulic/brakes/pressure-right-psi");
+ parking = getprop("/controls/gear/brake-parking");
+ askidnws_sw = getprop("/systems/hydraulic/brakes/askidnwssw");
+ brake_mode = getprop("/systems/hydraulic/brakes/mode");
+ brake_l = getprop("/systems/hydraulic/brakes/lbrake");
+ brake_r = getprop("/systems/hydraulic/brakes/rbrake");
+ brake_nose = getprop("/systems/hydraulic/brakes/nose-rubber");
+ counter = getprop("/systems/hydraulic/brakes/counter");
+
+ if (!parking and askidnws_sw and green_psi > 2500) {
+ # set mode to on
+ setprop("/systems/hydraulic/brakes/mode", 1);
+ } else if ((!parking and askidnws_sw and yellow_psi > 2500) or (!parking and askidnws_sw and accum > 0)) {
+ # set mode to altn
+ setprop("/systems/hydraulic/brakes/mode", 2);
+ } else {
+ # set mode to off
+ setprop("/systems/hydraulic/brakes/mode", 0);
+ }
+
+ if (brake_mode == 2 and yellow_psi > 2500 and accum < 700) {
+ setprop("/systems/hydraulic/brakes/accumulator-pressure-psi", accum + 50);
+ }
+
+ # Fault lights
+ if (green_pump_fail and eng1_pump_sw) {
+ setprop("/systems/hydraulic/eng1-pump-fault", 1);
+ } else {
+ setprop("/systems/hydraulic/eng1-pump-fault", 0);
+ }
+
+ if (blue_pump_fail and elec_pump_blue_sw) {
+ setprop("/systems/hydraulic/elec-pump-b-fault", 1);
+ } else {
+ setprop("/systems/hydraulic/elec-pump-b-fault", 0);
+ }
+
+ if (ptu_fail and ptu_sw) {
+ setprop("/systems/hydraulic/ptu-fault", 1);
+ } else {
+ setprop("/systems/hydraulic/ptu-fault", 0);
+ }
+
+ if (yellow_pump_eng_fail and eng2_pump_sw) {
+ setprop("/systems/hydraulic/eng2-pump-fault", 1);
+ } else {
+ setprop("/systems/hydraulic/eng2-pump-fault", 0);
+ }
+
+ if (yellow_pump_elec_fail and elec_pump_yellow_sw) {
+ setprop("/systems/hydraulic/elec-pump-y-fault", 1);
+ } else {
+ setprop("/systems/hydraulic/elec-pump-y-fault", 0);
+ }
+ },
+};
setlistener("/controls/gear/gear-down", func {
down = getprop("/controls/gear/gear-down");
@@ -272,22 +260,3 @@ setlistener("/controls/gear/gear-down", func {
setprop("/controls/gear/gear-down", 1);
}
});
-
-###################
-# Update Function #
-###################
-
-var update_hydraulic = func {
- master_hyd();
-}
-
-var hyd_timer = maketimer(0.2, update_hydraulic);
-
-
-# FIXME:
-# Josh, please disable braking when:
-# /systems/hydraulic/brakes/accumulator-pressure-psi is equal to 0 and when /systems/hydraulic/brakes/mode is equal to 2
-# Thanks!
-
-# Will do -JD
-
diff --git a/Nasal/libraries.nas b/Nasal/libraries.nas
index a0f27c87..2e94910c 100644
--- a/Nasal/libraries.nas
+++ b/Nasal/libraries.nas
@@ -199,16 +199,16 @@ var triggerDoor = func(door, doorName, doorDesc) {
setlistener("/sim/signals/fdm-initialized", func {
fbw.fctlInit();
- systems.elec_init();
- systems.adirs_init();
- systems.pneu_init();
- systems.hyd_init();
- systems.fuel_init();
- systems.fire_init();
+ systems.ELEC.init();
+ systems.PNEU.init();
+ systems.HYD.init();
+ systems.FUEL.init();
+ systems.ADIRS.init();
systems.eng_init();
+ systems.fire_init();
systems.autobrake_init();
fmgc.APinit();
- librariesLoop.start();
+ systemsLoop.start();
fmgc.FMGCinit();
mcdu1.MCDU_init();
mcdu2.MCDU_init();
@@ -217,14 +217,19 @@ setlistener("/sim/signals/fdm-initialized", func {
var autopilot = gui.Dialog.new("sim/gui/dialogs/autopilot/dialog", "Aircraft/IDG-A32X/Systems/autopilot-dlg.xml");
setprop("/it-autoflight/input/fd1", 1);
setprop("/it-autoflight/input/fd2", 1);
- setprop("/sim/model/lights/floor-light", 0);
libraries.ECAMinit();
libraries.variousReset();
logoTimer.start();
noseLoop.start();
});
-var librariesLoop = maketimer(0.1, func {
+var systemsLoop = maketimer(0.1, func {
+ systems.ELEC.loop();
+ systems.PNEU.loop();
+ systems.HYD.loop();
+ systems.FUEL.loop();
+ systems.ADIRS.loop();
+
if ((getprop("/controls/pneumatic/switches/groundair") or getprop("/controls/switches/cart")) and ((getprop("/velocities/groundspeed-kt") > 2) or getprop("/controls/gear/brake-parking") == 0)) {
setprop("/controls/switches/cart", 0);
setprop("/controls/pneumatic/switches/groundair", 0);
diff --git a/Nasal/pneumatics.nas b/Nasal/pneumatics.nas
index a78c49fd..7af21e7c 100644
--- a/Nasal/pneumatics.nas
+++ b/Nasal/pneumatics.nas
@@ -5,10 +5,6 @@
# Copyright (c) Joshua Davidson (it0uchpods) #
##############################################
-#############
-# Init Vars #
-#############
-
setlistener("/sim/signals/fdm-initialized", func {
var altitude = getprop("/instrumentation/altimeter/indicated-altitude-ft");
var bleed1_sw = getprop("/controls/pneumatic/switches/bleed1");
@@ -78,309 +74,305 @@ setlistener("/sim/signals/fdm-initialized", func {
var guard = getprop("/controls/oxygen/masksGuard");
});
-var pneu_init = func {
- setprop("/controls/pneumatic/switches/bleed1", 1);
- setprop("/controls/pneumatic/switches/bleed2", 1);
- setprop("/controls/pneumatic/switches/bleedapu", 0);
- setprop("/controls/pneumatic/switches/groundair", 0);
- setprop("/controls/pneumatic/switches/pack1", 1);
- setprop("/controls/pneumatic/switches/pack2", 1);
- setprop("/controls/pneumatic/switches/hot-air", 1);
- setprop("/controls/pneumatic/switches/ram-air", 0);
- setprop("/controls/pneumatic/switches/pack-flo", 9); # LO: 7, NORM: 9, HI: 11.
- setprop("/controls/pneumatic/switches/xbleed", 1); # SHUT: 0, AUTO: 1, OPEN: 2.
- setprop("/systems/pneumatic/bleed1", 0);
- setprop("/systems/pneumatic/bleed2", 0);
- setprop("/systems/pneumatic/bleedapu", 0);
- setprop("/systems/pneumatic/groundair", 0);
- setprop("/systems/pneumatic/total-psi", 0);
- setprop("/systems/pneumatic/start-psi", 0);
- setprop("/systems/pneumatic/pack-psi", 0);
- setprop("/systems/pneumatic/pack1", 0);
- setprop("/systems/pneumatic/pack2", 0);
- setprop("/systems/pneumatic/start-psi", 0);
- setprop("/systems/pneumatic/eng1-starter", 0);
- setprop("/systems/pneumatic/eng2-starter", 0);
- setprop("/systems/pneumatic/bleed1-fault", 0);
- setprop("/systems/pneumatic/bleed2-fault", 0);
- setprop("/systems/pneumatic/bleedapu-fault", 0);
- setprop("/systems/pneumatic/hotair-fault", 0);
- setprop("/systems/pneumatic/pack1-fault", 0);
- setprop("/systems/pneumatic/pack2-fault", 0);
- setprop("/systems/pneumatic/xbleed", 0);
- setprop("/FMGC/internal/dep-arpt", "");
- altitude = getprop("/instrumentation/altimeter/indicated-altitude-ft");
- setprop("/systems/pressurization/mode", "GN");
- setprop("/systems/pressurization/vs", "0");
- setprop("/systems/pressurization/targetvs", "0");
- setprop("/systems/pressurization/vs-norm", "0");
- setprop("/systems/pressurization/auto", 1);
- setprop("/systems/pressurization/deltap", "0");
- setprop("/systems/pressurization/outflowpos", "0");
- setprop("/systems/pressurization/deltap-norm", "0");
- setprop("/systems/pressurization/outflowpos-norm", "0");
- setprop("/systems/pressurization/outflowpos-man", "0.5");
- setprop("/systems/pressurization/outflowpos-man-sw", "0");
- setprop("/systems/pressurization/outflowpos-norm-cmd", "0");
- setprop("/systems/pressurization/cabinalt", altitude);
- setprop("/systems/pressurization/targetalt", altitude);
- setprop("/systems/pressurization/diff-to-target", "0");
- setprop("/systems/pressurization/ditchingpb", 0);
- setprop("/systems/pressurization/targetvs", "0");
- setprop("/systems/pressurization/ambientpsi", "0");
- setprop("/systems/pressurization/cabinpsi", "0");
- setprop("/systems/pressurization/manvs-cmd", "0");
- setprop("/systems/ventilation/cabin/fans", 0); # aircon fans
- setprop("/systems/ventilation/avionics/fan", 0);
- setprop("/systems/ventilation/avionics/extractvalve", "0");
- setprop("/systems/ventilation/avionics/inletvalve", "0");
- setprop("/systems/ventilation/lavatory/extractfan", 0);
- setprop("/systems/ventilation/lavatory/extractvalve", "0");
- setprop("/controls/deice/eng1-on", 0);
- setprop("/controls/deice/eng2-on", 0);
- setprop("/controls/oxygen/masksDeploy", 0);
- setprop("/controls/oxygen/masksDeployMan", 0);
- setprop("/controls/oxygen/masksReset", 0); # this is the TMR RESET pb on the maintenance panel, needs 3D model
- setprop("/controls/oxygen/masksSys", 0);
- pneu_timer.start();
-}
-
-#######################
-# Main Pneumatic Loop #
-#######################
-
-var master_pneu = func {
- bleed1_sw = getprop("/controls/pneumatic/switches/bleed1");
- bleed2_sw = getprop("/controls/pneumatic/switches/bleed2");
- bleedapu_sw = getprop("/controls/pneumatic/switches/bleedapu");
- pack1_sw = getprop("/controls/pneumatic/switches/pack1");
- pack2_sw = getprop("/controls/pneumatic/switches/pack2");
- hot_air_sw = getprop("/controls/pneumatic/switches/hot-air");
- ram_air_sw = getprop("/controls/pneumatic/switches/ram-air");
- pack_flo_sw = getprop("/controls/pneumatic/switches/pack-flo");
- xbleed_sw = getprop("/controls/pneumatic/switches/xbleed");
- eng1_starter = getprop("/systems/pneumatic/eng1-starter");
- eng2_starter = getprop("/systems/pneumatic/eng2-starter");
- groundair = getprop("/systems/pneumatic/groundair");
- groundair_supp = getprop("/controls/pneumatic/switches/groundair");
- rpmapu = getprop("/systems/apu/rpm");
- stateL = getprop("/engines/engine[0]/state");
- stateR = getprop("/engines/engine[1]/state");
- bleedapu_fail = getprop("/systems/failures/bleed-apu");
- bleedext_fail = getprop("/systems/failures/bleed-ext");
- bleedeng1_fail = getprop("/systems/failures/bleed-eng1");
- bleedeng2_fail = getprop("/systems/failures/bleed-eng2");
- pack1_fail = getprop("/systems/failures/pack1");
- pack2_fail = getprop("/systems/failures/pack2");
- engantiice1 = getprop("/controls/deice/eng1-on");
- engantiice2 = getprop("/controls/deice/eng2-on");
-
- # Air Sources/PSI
- if (rpmapu >= 94.9 and bleedapu_sw and !bleedapu_fail) {
- setprop("/systems/pneumatic/bleedapu", 34);
- } else {
- setprop("/systems/pneumatic/bleedapu", 0);
- }
-
- ground = getprop("/systems/pneumatic/groundair");
- bleedapu = getprop("/systems/pneumatic/bleedapu");
-
- if (xbleed_sw == 0) {
- setprop("/systems/pneumatic/xbleed", 0);
- } else if (xbleed_sw == 1) {
- if (bleedapu >= 11) {
- setprop("/systems/pneumatic/xbleed", 1);
- } else {
- setprop("/systems/pneumatic/xbleed", 0);
- }
- } else if (xbleed_sw == 2) {
- setprop("/systems/pneumatic/xbleed", 1);
- }
-
- xbleed = getprop("/systems/pneumatic/xbleed", 0);
-
- if (stateL == 3 and bleed1_sw and !bleedeng1_fail) {
- setprop("/systems/pneumatic/bleed1", 31);
- } else {
+var PNEU = {
+ init: func() {
+ setprop("/controls/pneumatic/switches/bleed1", 1);
+ setprop("/controls/pneumatic/switches/bleed2", 1);
+ setprop("/controls/pneumatic/switches/bleedapu", 0);
+ setprop("/controls/pneumatic/switches/groundair", 0);
+ setprop("/controls/pneumatic/switches/pack1", 1);
+ setprop("/controls/pneumatic/switches/pack2", 1);
+ setprop("/controls/pneumatic/switches/hot-air", 1);
+ setprop("/controls/pneumatic/switches/ram-air", 0);
+ setprop("/controls/pneumatic/switches/pack-flo", 9); # LO: 7, NORM: 9, HI: 11.
+ setprop("/controls/pneumatic/switches/xbleed", 1); # SHUT: 0, AUTO: 1, OPEN: 2.
setprop("/systems/pneumatic/bleed1", 0);
- }
-
- if (stateR == 3 and bleed2_sw and !bleedeng2_fail) {
- setprop("/systems/pneumatic/bleed2", 32);
- } else {
setprop("/systems/pneumatic/bleed2", 0);
- }
-
- bleed1 = getprop("/systems/pneumatic/bleed1");
- bleed2 = getprop("/systems/pneumatic/bleed2");
-
- if (bleed1 >= 11 and (stateR != 3 or !bleed2_sw or bleedeng2_fail) and xbleed == 1) {
- setprop("/systems/pneumatic/bleed2", 31);
- }
-
- if (bleed2 >= 11 and (stateL != 3 or !bleed1_sw or bleedeng1_fail) and xbleed == 1) {
- setprop("/systems/pneumatic/bleed1", 32);
- }
-
- bleed1 = getprop("/systems/pneumatic/bleed1");
- bleed2 = getprop("/systems/pneumatic/bleed2");
-
- if (stateL == 1 or stateR == 1) {
- setprop("/systems/pneumatic/start-psi", 18);
- } else {
- setprop("/systems/pneumatic/start-psi", 0);
- }
-
- if (pack1_sw == 1 and (bleed1 >= 11 or bleedapu >= 11 or ground >= 11) and eng1_starter == 0 and eng2_starter == 0 and !pack1_fail) {
- setprop("/systems/pneumatic/pack1", pack_flo_sw);
- } else {
- setprop("/systems/pneumatic/pack1", 0);
- }
-
- if (pack2_sw == 1 and (bleed2 >= 11 or (bleedapu >= 11 and xbleed == 1)) and eng1_starter == 0 and eng2_starter == 0 and !pack2_fail) {
- setprop("/systems/pneumatic/pack2", pack_flo_sw);
- } else {
- setprop("/systems/pneumatic/pack2", 0);
- }
-
- pack1 = getprop("/systems/pneumatic/pack1");
- pack2 = getprop("/systems/pneumatic/pack2");
-
- if (pack1_sw == 1 and pack2_sw == 1) {
- setprop("/systems/pneumatic/pack-psi", pack1 + pack2);
- } else if (pack1_sw == 0 and pack2_sw == 0) {
- setprop("/systems/pneumatic/pack-psi", 0);
- } else {
- setprop("/systems/pneumatic/pack-psi", pack1 + pack2 + 5);
- }
-
- pack_psi = getprop("/systems/pneumatic/pack-psi");
- start_psi = getprop("/systems/pneumatic/start-psi");
-
- if ((bleed1 + bleed2 + bleedapu) > 42) {
- setprop("/systems/pneumatic/total-psi", 42);
- } else {
- total_psi_calc = ((bleed1 + bleed2 + bleedapu + ground) - start_psi - pack_psi);
- setprop("/systems/pneumatic/total-psi", total_psi_calc);
- }
-
- if (groundair_supp) {
- setprop("/systems/pneumatic/groundair", 39);
- } else {
+ setprop("/systems/pneumatic/bleedapu", 0);
setprop("/systems/pneumatic/groundair", 0);
- }
-
- if (engantiice1 and bleed1 > 20) { # shut down anti-ice if bleed is lost else turn it on
- setprop("/controls/deice/lengine", 0);
- setprop("/controls/deice/eng1-on", 0);
- }
-
- if (engantiice1) { # else turn it on
- setprop("/controls/deice/lengine", 1);
- }
-
- if (engantiice2 and bleed2 > 20) {
- setprop("/controls/deice/rengine", 0);
- setprop("/controls/deice/eng2-on", 0);
- }
-
- if (engantiice2) {
- setprop("/controls/deice/rengine", 1);
- }
-
- total_psi = getprop("/systems/pneumatic/total-psi");
-
- phase = getprop("/FMGC/status/phase");
- pressmode = getprop("/systems/pressurization/mode");
- state1 = getprop("/systems/thrust/state1");
- state2 = getprop("/systems/thrust/state2");
- wowl = getprop("/gear/gear[1]/wow");
- wowr = getprop("/gear/gear[2]/wow");
- deltap = getprop("/systems/pressurization/deltap");
- outflow = getprop("/systems/pressurization/outflowpos");
- speed = getprop("/velocities/groundspeed-kt");
- altitude = getprop("/instrumentation/altimeter/indicated-altitude-ft");
- airport_arr_elev_ft = getprop("autopilot/route-manager/destination/field-elevation-ft");
- vs = getprop("/systems/pressurization/vs-norm");
- manvs = getprop("/systems/pressurization/manvs-cmd");
- ditch = getprop("/systems/pressurization/ditchingpb");
- outflowpos = getprop("/systems/pressurization/outflowpos");
- cabinalt = getprop("/systems/pressurization/cabinalt");
- targetalt = getprop("/systems/pressurization/targetalt");
- targetvs = getprop("/systems/pressurization/targetvs");
- ambient = getprop("/systems/pressurization/ambientpsi");
- cabinpsi = getprop("/systems/pressurization/cabinpsi");
- pause = getprop("/sim/freeze/master");
- auto = getprop("/systems/pressurization/auto");
-
- setprop("/systems/pressurization/diff-to-target", targetalt - cabinalt);
- setprop("/systems/pressurization/deltap", cabinpsi - ambient);
-
- if ((pressmode == "GN") and (pressmode != "CL") and (wowl and wowr) and ((state1 == "MCT") or (state1 == "TOGA")) and ((state2 == "MCT") or (state2 == "TOGA"))) {
- setprop("/systems/pressurization/mode", "TO");
- } else if (((!wowl) or (!wowr)) and (speed > 100) and (pressmode == "TO")) {
- setprop("/systems/pressurization/mode", "CL");
- }
-
- if (vs != targetvs and !wowl and !wowr) {
- setprop("/systems/pressurization/vs", targetvs);
- }
-
- if (cabinalt != targetalt and !wowl and !wowr and !pause and auto) {
- setprop("/systems/pressurization/cabinalt", cabinalt + ((vs / 60) / 10));
- } else if (!auto and !pause) {
- setprop("/systems/pressurization/cabinalt", cabinalt + ((manvs / 60) / 10));
- }
-
- if (ditch and auto) {
- setprop("/systems/pressurization/outflowpos", "1");
- setprop("/systems/ventilation/avionics/extractvalve", "1");
- setprop("/systems/ventilation/avionics/inletvalve", "1");
- }
-
- dcess = getprop("/systems/electrical/bus/dc-ess");
- acess = getprop("/systems/electrical/bus/ac-ess");
- fanon = getprop("/systems/ventilation/avionics/fan");
-
- if ((dcess > 25) or (acess > 110)) {
- setprop("/systems/ventilation/avionics/fan", 1);
- setprop("/systems/ventilation/lavatory/extractfan", 1);
- } else if ((dcess == 0) and (acess == 0)) {
- setprop("/systems/ventilation/avionics/fan", 0);
- setprop("/systems/ventilation/lavatory/extractfan", 0);
- }
-
- # Fault lights
- if (bleedeng1_fail and bleed1_sw) {
- setprop("/systems/pneumatic/bleed1-fault", 1);
- } else {
+ setprop("/systems/pneumatic/total-psi", 0);
+ setprop("/systems/pneumatic/start-psi", 0);
+ setprop("/systems/pneumatic/pack-psi", 0);
+ setprop("/systems/pneumatic/pack1", 0);
+ setprop("/systems/pneumatic/pack2", 0);
+ setprop("/systems/pneumatic/start-psi", 0);
+ setprop("/systems/pneumatic/eng1-starter", 0);
+ setprop("/systems/pneumatic/eng2-starter", 0);
setprop("/systems/pneumatic/bleed1-fault", 0);
- }
-
- if (bleedeng2_fail and bleed2_sw) {
- setprop("/systems/pneumatic/bleed2-fault", 1);
- } else {
setprop("/systems/pneumatic/bleed2-fault", 0);
- }
-
- if (bleedapu_fail and bleedapu_sw) {
- setprop("/systems/pneumatic/bleedapu-fault", 1);
- } else {
setprop("/systems/pneumatic/bleedapu-fault", 0);
- }
-
- if ((pack1_fail and pack1_sw) or (pack1_sw and pack1 <= 5)) {
- setprop("/systems/pneumatic/pack1-fault", 1);
- } else {
+ setprop("/systems/pneumatic/hotair-fault", 0);
setprop("/systems/pneumatic/pack1-fault", 0);
- }
-
- if ((pack2_fail and pack2_sw) or (pack2_sw and pack2 <= 5)) {
- setprop("/systems/pneumatic/pack2-fault", 1);
- } else {
setprop("/systems/pneumatic/pack2-fault", 0);
- }
-}
+ setprop("/systems/pneumatic/xbleed", 0);
+ setprop("/FMGC/internal/dep-arpt", "");
+ altitude = getprop("/instrumentation/altimeter/indicated-altitude-ft");
+ setprop("/systems/pressurization/mode", "GN");
+ setprop("/systems/pressurization/vs", "0");
+ setprop("/systems/pressurization/targetvs", "0");
+ setprop("/systems/pressurization/vs-norm", "0");
+ setprop("/systems/pressurization/auto", 1);
+ setprop("/systems/pressurization/deltap", "0");
+ setprop("/systems/pressurization/outflowpos", "0");
+ setprop("/systems/pressurization/deltap-norm", "0");
+ setprop("/systems/pressurization/outflowpos-norm", "0");
+ setprop("/systems/pressurization/outflowpos-man", "0.5");
+ setprop("/systems/pressurization/outflowpos-man-sw", "0");
+ setprop("/systems/pressurization/outflowpos-norm-cmd", "0");
+ setprop("/systems/pressurization/cabinalt", altitude);
+ setprop("/systems/pressurization/targetalt", altitude);
+ setprop("/systems/pressurization/diff-to-target", "0");
+ setprop("/systems/pressurization/ditchingpb", 0);
+ setprop("/systems/pressurization/targetvs", "0");
+ setprop("/systems/pressurization/ambientpsi", "0");
+ setprop("/systems/pressurization/cabinpsi", "0");
+ setprop("/systems/pressurization/manvs-cmd", "0");
+ setprop("/systems/ventilation/cabin/fans", 0); # aircon fans
+ setprop("/systems/ventilation/avionics/fan", 0);
+ setprop("/systems/ventilation/avionics/extractvalve", "0");
+ setprop("/systems/ventilation/avionics/inletvalve", "0");
+ setprop("/systems/ventilation/lavatory/extractfan", 0);
+ setprop("/systems/ventilation/lavatory/extractvalve", "0");
+ setprop("/controls/deice/eng1-on", 0);
+ setprop("/controls/deice/eng2-on", 0);
+ setprop("/controls/oxygen/masksDeploy", 0);
+ setprop("/controls/oxygen/masksDeployMan", 0);
+ setprop("/controls/oxygen/masksReset", 0); # this is the TMR RESET pb on the maintenance panel, needs 3D model
+ setprop("/controls/oxygen/masksSys", 0);
+ },
+ loop: func() {
+ bleed1_sw = getprop("/controls/pneumatic/switches/bleed1");
+ bleed2_sw = getprop("/controls/pneumatic/switches/bleed2");
+ bleedapu_sw = getprop("/controls/pneumatic/switches/bleedapu");
+ pack1_sw = getprop("/controls/pneumatic/switches/pack1");
+ pack2_sw = getprop("/controls/pneumatic/switches/pack2");
+ hot_air_sw = getprop("/controls/pneumatic/switches/hot-air");
+ ram_air_sw = getprop("/controls/pneumatic/switches/ram-air");
+ pack_flo_sw = getprop("/controls/pneumatic/switches/pack-flo");
+ xbleed_sw = getprop("/controls/pneumatic/switches/xbleed");
+ eng1_starter = getprop("/systems/pneumatic/eng1-starter");
+ eng2_starter = getprop("/systems/pneumatic/eng2-starter");
+ groundair = getprop("/systems/pneumatic/groundair");
+ groundair_supp = getprop("/controls/pneumatic/switches/groundair");
+ rpmapu = getprop("/systems/apu/rpm");
+ stateL = getprop("/engines/engine[0]/state");
+ stateR = getprop("/engines/engine[1]/state");
+ bleedapu_fail = getprop("/systems/failures/bleed-apu");
+ bleedext_fail = getprop("/systems/failures/bleed-ext");
+ bleedeng1_fail = getprop("/systems/failures/bleed-eng1");
+ bleedeng2_fail = getprop("/systems/failures/bleed-eng2");
+ pack1_fail = getprop("/systems/failures/pack1");
+ pack2_fail = getprop("/systems/failures/pack2");
+ engantiice1 = getprop("/controls/deice/eng1-on");
+ engantiice2 = getprop("/controls/deice/eng2-on");
+
+ # Air Sources/PSI
+ if (rpmapu >= 94.9 and bleedapu_sw and !bleedapu_fail) {
+ setprop("/systems/pneumatic/bleedapu", 34);
+ } else {
+ setprop("/systems/pneumatic/bleedapu", 0);
+ }
+
+ ground = getprop("/systems/pneumatic/groundair");
+ bleedapu = getprop("/systems/pneumatic/bleedapu");
+
+ if (xbleed_sw == 0) {
+ setprop("/systems/pneumatic/xbleed", 0);
+ } else if (xbleed_sw == 1) {
+ if (bleedapu >= 11) {
+ setprop("/systems/pneumatic/xbleed", 1);
+ } else {
+ setprop("/systems/pneumatic/xbleed", 0);
+ }
+ } else if (xbleed_sw == 2) {
+ setprop("/systems/pneumatic/xbleed", 1);
+ }
+
+ xbleed = getprop("/systems/pneumatic/xbleed", 0);
+
+ if (stateL == 3 and bleed1_sw and !bleedeng1_fail) {
+ setprop("/systems/pneumatic/bleed1", 31);
+ } else {
+ setprop("/systems/pneumatic/bleed1", 0);
+ }
+
+ if (stateR == 3 and bleed2_sw and !bleedeng2_fail) {
+ setprop("/systems/pneumatic/bleed2", 32);
+ } else {
+ setprop("/systems/pneumatic/bleed2", 0);
+ }
+
+ bleed1 = getprop("/systems/pneumatic/bleed1");
+ bleed2 = getprop("/systems/pneumatic/bleed2");
+
+ if (bleed1 >= 11 and (stateR != 3 or !bleed2_sw or bleedeng2_fail) and xbleed == 1) {
+ setprop("/systems/pneumatic/bleed2", 31);
+ }
+
+ if (bleed2 >= 11 and (stateL != 3 or !bleed1_sw or bleedeng1_fail) and xbleed == 1) {
+ setprop("/systems/pneumatic/bleed1", 32);
+ }
+
+ bleed1 = getprop("/systems/pneumatic/bleed1");
+ bleed2 = getprop("/systems/pneumatic/bleed2");
+
+ if (stateL == 1 or stateR == 1) {
+ setprop("/systems/pneumatic/start-psi", 18);
+ } else {
+ setprop("/systems/pneumatic/start-psi", 0);
+ }
+
+ if (pack1_sw == 1 and (bleed1 >= 11 or bleedapu >= 11 or ground >= 11) and eng1_starter == 0 and eng2_starter == 0 and !pack1_fail) {
+ setprop("/systems/pneumatic/pack1", pack_flo_sw);
+ } else {
+ setprop("/systems/pneumatic/pack1", 0);
+ }
+
+ if (pack2_sw == 1 and (bleed2 >= 11 or (bleedapu >= 11 and xbleed == 1)) and eng1_starter == 0 and eng2_starter == 0 and !pack2_fail) {
+ setprop("/systems/pneumatic/pack2", pack_flo_sw);
+ } else {
+ setprop("/systems/pneumatic/pack2", 0);
+ }
+
+ pack1 = getprop("/systems/pneumatic/pack1");
+ pack2 = getprop("/systems/pneumatic/pack2");
+
+ if (pack1_sw == 1 and pack2_sw == 1) {
+ setprop("/systems/pneumatic/pack-psi", pack1 + pack2);
+ } else if (pack1_sw == 0 and pack2_sw == 0) {
+ setprop("/systems/pneumatic/pack-psi", 0);
+ } else {
+ setprop("/systems/pneumatic/pack-psi", pack1 + pack2 + 5);
+ }
+
+ pack_psi = getprop("/systems/pneumatic/pack-psi");
+ start_psi = getprop("/systems/pneumatic/start-psi");
+
+ if ((bleed1 + bleed2 + bleedapu) > 42) {
+ setprop("/systems/pneumatic/total-psi", 42);
+ } else {
+ total_psi_calc = ((bleed1 + bleed2 + bleedapu + ground) - start_psi - pack_psi);
+ setprop("/systems/pneumatic/total-psi", total_psi_calc);
+ }
+
+ if (groundair_supp) {
+ setprop("/systems/pneumatic/groundair", 39);
+ } else {
+ setprop("/systems/pneumatic/groundair", 0);
+ }
+
+ if (engantiice1 and bleed1 > 20) { # shut down anti-ice if bleed is lost else turn it on
+ setprop("/controls/deice/lengine", 0);
+ setprop("/controls/deice/eng1-on", 0);
+ }
+
+ if (engantiice1) { # else turn it on
+ setprop("/controls/deice/lengine", 1);
+ }
+
+ if (engantiice2 and bleed2 > 20) {
+ setprop("/controls/deice/rengine", 0);
+ setprop("/controls/deice/eng2-on", 0);
+ }
+
+ if (engantiice2) {
+ setprop("/controls/deice/rengine", 1);
+ }
+
+ total_psi = getprop("/systems/pneumatic/total-psi");
+
+ phase = getprop("/FMGC/status/phase");
+ pressmode = getprop("/systems/pressurization/mode");
+ state1 = getprop("/systems/thrust/state1");
+ state2 = getprop("/systems/thrust/state2");
+ wowl = getprop("/gear/gear[1]/wow");
+ wowr = getprop("/gear/gear[2]/wow");
+ deltap = getprop("/systems/pressurization/deltap");
+ outflow = getprop("/systems/pressurization/outflowpos");
+ speed = getprop("/velocities/groundspeed-kt");
+ altitude = getprop("/instrumentation/altimeter/indicated-altitude-ft");
+ airport_arr_elev_ft = getprop("autopilot/route-manager/destination/field-elevation-ft");
+ vs = getprop("/systems/pressurization/vs-norm");
+ manvs = getprop("/systems/pressurization/manvs-cmd");
+ ditch = getprop("/systems/pressurization/ditchingpb");
+ outflowpos = getprop("/systems/pressurization/outflowpos");
+ cabinalt = getprop("/systems/pressurization/cabinalt");
+ targetalt = getprop("/systems/pressurization/targetalt");
+ targetvs = getprop("/systems/pressurization/targetvs");
+ ambient = getprop("/systems/pressurization/ambientpsi");
+ cabinpsi = getprop("/systems/pressurization/cabinpsi");
+ pause = getprop("/sim/freeze/master");
+ auto = getprop("/systems/pressurization/auto");
+
+ setprop("/systems/pressurization/diff-to-target", targetalt - cabinalt);
+ setprop("/systems/pressurization/deltap", cabinpsi - ambient);
+
+ if ((pressmode == "GN") and (pressmode != "CL") and (wowl and wowr) and ((state1 == "MCT") or (state1 == "TOGA")) and ((state2 == "MCT") or (state2 == "TOGA"))) {
+ setprop("/systems/pressurization/mode", "TO");
+ } else if (((!wowl) or (!wowr)) and (speed > 100) and (pressmode == "TO")) {
+ setprop("/systems/pressurization/mode", "CL");
+ }
+
+ if (vs != targetvs and !wowl and !wowr) {
+ setprop("/systems/pressurization/vs", targetvs);
+ }
+
+ if (cabinalt != targetalt and !wowl and !wowr and !pause and auto) {
+ setprop("/systems/pressurization/cabinalt", cabinalt + ((vs / 60) / 10));
+ } else if (!auto and !pause) {
+ setprop("/systems/pressurization/cabinalt", cabinalt + ((manvs / 60) / 10));
+ }
+
+ if (ditch and auto) {
+ setprop("/systems/pressurization/outflowpos", "1");
+ setprop("/systems/ventilation/avionics/extractvalve", "1");
+ setprop("/systems/ventilation/avionics/inletvalve", "1");
+ }
+
+ dcess = getprop("/systems/electrical/bus/dc-ess");
+ acess = getprop("/systems/electrical/bus/ac-ess");
+ fanon = getprop("/systems/ventilation/avionics/fan");
+
+ if ((dcess > 25) or (acess > 110)) {
+ setprop("/systems/ventilation/avionics/fan", 1);
+ setprop("/systems/ventilation/lavatory/extractfan", 1);
+ } else if ((dcess == 0) and (acess == 0)) {
+ setprop("/systems/ventilation/avionics/fan", 0);
+ setprop("/systems/ventilation/lavatory/extractfan", 0);
+ }
+
+ # Fault lights
+ if (bleedeng1_fail and bleed1_sw) {
+ setprop("/systems/pneumatic/bleed1-fault", 1);
+ } else {
+ setprop("/systems/pneumatic/bleed1-fault", 0);
+ }
+
+ if (bleedeng2_fail and bleed2_sw) {
+ setprop("/systems/pneumatic/bleed2-fault", 1);
+ } else {
+ setprop("/systems/pneumatic/bleed2-fault", 0);
+ }
+
+ if (bleedapu_fail and bleedapu_sw) {
+ setprop("/systems/pneumatic/bleedapu-fault", 1);
+ } else {
+ setprop("/systems/pneumatic/bleedapu-fault", 0);
+ }
+
+ if ((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)) {
+ setprop("/systems/pneumatic/pack2-fault", 1);
+ } else {
+ setprop("/systems/pneumatic/pack2-fault", 0);
+ }
+ },
+};
setlistener("/controls/pneumatic/switches/pack1", func {
pack1_sw = getprop("/controls/pneumatic/switches/pack1");
@@ -456,13 +448,3 @@ var flashfault2 = func {
}
});
}
-
-###################
-# Update Function #
-###################
-
-var update_pneumatic = func {
- master_pneu();
-}
-
-var pneu_timer = maketimer(0.2, update_pneumatic);