David Megginson wrote:
> I agree that the gravity feed thing is important. For example,
> high-wing Cessna singles usually have a "both" fuel-selector
> position, because the fuel flows down via gravity, while low-wing
> Piper singles do not, because the fuel is pumped (imagine sucking
> through two straws, one in a full glass and the other in an empty
> glass).
>
> That makes fuel management an important issue in a Piper -- owners
> tend to do it instinctively after a while (I set a timer on the yoke
> just to make sure), but renters who are used to Cessnas sometimes
> get into trouble: one Ottawa pilot ditched (successfully) in Toronto
> harbour a few weeks back after running one tank dry.
Hark! This is a job for a Nasal script! :)
Seriously, this is a great example of what can be done with Nasal: it
requires some programming, so it can't be done easily with straight
property bindings. Its output, though, lives almost entirely in the
property tree; only minimal FDM intervention is required. And it
isn't performance critical; fuel state updates need to be done only a
few times per second at most. But it's complicated enough that you
wouldn't want to write it inline in PSL; Nasal modules are cleaner and
saner.
So here's an idea: have the FDM stop managing tank contents and simply
read the tank values out of the property tree (YASim needs these for
C.G. computation, JSBSim may not care). Instead of setting the fuel
properties themselves, they add to a single
/consumables/fuel/consumed-lbs property each iteration. A few times
every second, a Nasal script takes this amount and modifies the tank
contents appropriately.
A prototype is attached. Basically, it looks at the "selected"
property of a tank to determine how much fuel to draw; setting it to 1
or 0 gives behavior that matches a single tank selector. Using
relative values can give you much fancier behavior (rocket engines
with two fuel components and differing flow rates, for example). When
all the selected tanks run dry, it sets the
/consumables/fuel/out-of-fuel property that the FDM can use to shut
down the engine(s).
This isn't quite ready to run; I need to hack at YASim to get it to
set the consumed property, honor the out-of-fuel property, and to stop
setting the tank content values. It also works right now only with
the "-lbs" property variants. It doesn't do conversions for
configurations that specify or read only "-gal_us" values.
I'll work on getting that working today. But the idea should be clear
from the attached code. People have to start reading this stuff at
some point. :)
Andy
# Utility
tank = func { "/consumables/fuel/tank[" ~ arg[0] ~ "]" }
# Count the tanks. This is ugly; Nasal should have a more complete
# SGPropertyNode API...
nTanks = 0;
while(getprop(tank(nTanks), "level-lbs") != nil)
{
nTanks = nTanks + 1;
}
update = func {
# Grab the consumed fuel amount and set it to zero for the next iteration
fuel = getprop("/consumables/fuel/consumed-lbs");
if(fuel == nil) { fuel = 0; }
setprop("/consumables/fuel/consumed-lbs", 0);
# Build a table of relative flow rates based on the "selected"
# properties of the tanks. Clamp to a very small positive value,
# so missing properties don't explode (setting them all to zero
# results in equal draw).
rates = [];
total = 0;
for(i=0; i<nTanks; i=i+1) {
w = getprop(tank(i), "selected");
if(w == nil or w == 0) { w = 1e-06; }
append(rates, w);
total = total + w;
}
# Go through and turn into real fuel flow amounts
# Subtract from the tanks. See if they all ran out.
dry = 1;
for(i=0; i<nTanks; i=i+1) {
consumed = fuel * rates[i] / total;
amt = getprop(tank(i), "level-lbs");
amt = amt - consumed;
if(amt <= 0) {
setprop(tank(i), "selected", 0);
amt = 0;
} else {
dry = 0;
}
setprop(tank(i), "level-lbs", amt);
}
if(dry) { setprop("/consumables/fuel/out-of-fuel", 1); }
# Set us up to run again at 4Hz
settimer(update, 0.25);
}
# Kick it off
settimer(update, 0.25);
_______________________________________________
Flightgear-devel mailing list
[EMAIL PROTECTED]
http://mail.flightgear.org/mailman/listinfo/flightgear-devel