From a73adc0b9eff325c2849fe1cc5f560e6a12e1595 Mon Sep 17 00:00:00 2001 From: Joshua Davidson Date: Mon, 12 Jun 2017 14:41:52 -0400 Subject: [PATCH] A3XX: Add Gravity Feed to Fuel --- Nasal/fuel.nas | 47 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/Nasal/fuel.nas b/Nasal/fuel.nas index d4cba1ce..b41b179e 100644 --- a/Nasal/fuel.nas +++ b/Nasal/fuel.nas @@ -6,6 +6,10 @@ ############# 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/tank2pump1", 0); setprop("/controls/fuel/tank2pump2", 0); @@ -40,15 +44,37 @@ var master_fuel = func { var xfeed = getprop("/systems/fuel/x-feed"); var ac1 = getprop("/systems/electrical/bus/ac1"); var ac2 = getprop("/systems/electrical/bus/ac2"); + var gravityfeedL = getprop("/systems/fuel/gravityfeedL"); + var gravityfeedR = getprop("/systems/fuel/gravityfeedR"); + var gload = getprop("/accelerations/pilot-gdamped"); + + 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); + } + + var gravityfeedL_output = getprop("/systems/fuel/gravityfeedL-output"); + var gravityfeedR_output = getprop("/systems/fuel/gravityfeedR-output"); if ((ac1 >= 110 or ac2 >= 110) and tank2pump1_sw) { setprop("/systems/fuel/tank[2]/feed0", 1); + } else if (gravityfeedL_output) { + setprop("/systems/fuel/tank[2]/feed0", 1); } else { setprop("/systems/fuel/tank[2]/feed0", 0); } if ((ac1 >= 110 or ac2 >= 110) and tank2pump2_sw) { setprop("/systems/fuel/tank[2]/feed1", 1); + } else if (gravityfeedL_output) { + setprop("/systems/fuel/tank[2]/feed1", 1); } else { setprop("/systems/fuel/tank[2]/feed1", 0); } @@ -67,12 +93,16 @@ var master_fuel = func { if ((ac1 >= 110 or ac2 >= 110) and tank4pump1_sw) { setprop("/systems/fuel/tank[4]/feed0", 1); + } else if (gravityfeedR_output) { + setprop("/systems/fuel/tank[2]/feed0", 1); } else { setprop("/systems/fuel/tank[4]/feed0", 0); } if ((ac1 >= 110 or ac2 >= 110) and tank4pump2_sw) { setprop("/systems/fuel/tank[4]/feed1", 1); + } else if (gravityfeedR_output) { + setprop("/systems/fuel/tank[2]/feed1", 1); } else { setprop("/systems/fuel/tank[4]/feed1", 0); } @@ -90,7 +120,22 @@ var master_fuel = func { var tank4feed0 = getprop("/systems/fuel/tank[4]/feed0"); var tank4feed1 = getprop("/systems/fuel/tank[4]/feed1"); - if ((getprop("/fdm/jsbsim/propulsion/tank[3]/contents-lbs") >= 50) and tank3feed0 and tank3feed1) { + if (((ac1 >= 110 or ac2 >= 110) and tank2pump1_sw and tank2pump1_sw)) { + setprop("/systems/fuel/gravityfeedL", 0); + } else { + setprop("/systems/fuel/gravityfeedL", 1); + } + + if (((ac1 >= 110 or ac2 >= 110) and tank4pump1_sw and tank4pump1_sw)) { + setprop("/systems/fuel/gravityfeedR", 0); + } else { + setprop("/systems/fuel/gravityfeedR", 1); + } + + var gravityfeedL = getprop("/systems/fuel/gravityfeedL"); + var gravityfeedR = getprop("/systems/fuel/gravityfeedR"); + + if ((getprop("/fdm/jsbsim/propulsion/tank[3]/contents-lbs") >= 50) and tank3feed0 and tank3feed1 and !gravityfeedL and !gravityfeedR) { setprop("/systems/fuel/only-use-ctr-tank", 1); } else { setprop("/systems/fuel/only-use-ctr-tank", 0);