Hi, 

First, thank you to all who answered my query, especially Jon for the details 
on the new tanking system. 

I've designed a slightly different system that you all might want to consider. 
A small portion of the code is in FG. 

Starting in controls.cxx (version 2.4) you will find at 

line #312 
_tiedProperties.Tie( "feed_tank", this, index, &FGControls::get_feed_tank, 
&FGControls::set_feed_tank ) 
->setAttribute( SGPropertyNode::ARCHIVE, true ); 

then at line #944 
void 
FGControls::set_feed_tank( int engine, int tank ) 
{ 
if ( engine == ALL_ENGINES ) { 
for ( int i = 0; i < MAX_ENGINES; i++ ) { 
feed_tank[i] = tank; 
SG_CLAMP_RANGE<int>( feed_tank[i], -1, 8 ); 
} 
} else { 
if ( (engine >= 0) && (engine < MAX_ENGINES) ) { 
feed_tank[engine] = tank; 
SG_CLAMP_RANGE<int>( feed_tank[engine], -1, 8 ); 
} 
} 
} 

where the value of feed_tank[engine] is the number of the tank that feeds the 
engine. This also provided the ability to set the value via a network 
interface. See line #389 in native_ctrls.cxx. At init time all feed_tank values 
are set to -1. 

node->getChild( "feed_tank" )->setIntValue( net->feed_tank_to[i] ); 

This code was incorporated as part of FG back in 2.2 IIRC. 

Now here is where things got messy. Since JSBSim uses a table lookup method for 
engine models and we were using a physical model it did not fit well into the 
JSBSim modeling system. We essentially replaced FGTurbine.cpp with our physical 
model and made the following changes in the JSBSim code. In JSBSim.cxx we added 
at line #635 

eng->SetFuelTank( globals->get_controls()->get_feed_tank(i) ); //JW 

and pretty much iviscerated the ConsumeFuel() method in FGEngine.cpp and 
replaced it with 

if ( Active_Tank >= 0 ) { 
Tank = Propulsion->GetTank(Active_Tank); 
if (Tank->GetType() == FGTank::ttFUEL) { 
//Fshortage += Tank->Drain(CalcFuelNeed()/TanksWithFuel); // SEE NOTE ABOVE 
Fshortage += Tank->Drain(CalcFuelNeed() ); 
} 
} else Starved = true; 
if (Fshortage < 10.00) Starved = true; 

so if an engine did not have a tank value of 0 or greater it flamed out or 
would not start. This essentially moved all the logic and control of the fuel 
system out of FG and JSBSim over to the 747 simulator side. We made one "messy" 
accomodation for the 737 and added the fuel transfer function for the version 
of FG that runs the 737 sim. 

Tank_0 = Propulsion->GetTank(0); 
double center_fuel = Tank_0->GetContents(); 
if ( center_fuel < 6000.0 ) transfer = true; 
else if ( center_fuel > 9000.0 ) transfer = false; 
if ( transfer ) { 
Tank_1 = Propulsion->GetTank(1); 
if ( Tank_1->GetContents() > 100.0 ) { 
Tank_0->Fill( 0.040 ); 
Tank_1->Drain( 0.040 ); 
} 
Tank_2 = Propulsion->GetTank(2); 
if ( Tank_2->GetContents() > 100.0 ) { 
Tank_0->Fill( 0.0401 ); 
Tank_2->Drain( 0.0401 ); // just a little nuisance to create an imbalance ;-) 
} 
} 

In the 747 sim the hardware fuel control panel, fuel cutoff switches, and 
software determined which tanks fed which engines and fuel transfers. This, in 
turn, was sent via the network interface to FG and onto JSBSim. 

With all due respect to Jon and Dave, I think this is a simpler scheme than a 
priority system, requiring less code and logic and greater flexibility for 
modeling fuel malfunctions external to Fg and JSBSim. 

So I throw this idea out there as an alternative. Comments are always welcomed 
and if anyone wishes a complete set of the source changes, just email me. Have 
not posted them to the git repository, just to messy to handle all the ifdefs 
at compile time and build a coherent package. 

Actually, looking over the newer code in 2.6 and 2.8, we may not be that far 
apart after all. 

Thanks again for the responses. 
John 

oops, this may have been a double post, my apologies. 




------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_sfd2d_oct
_______________________________________________
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel

Reply via email to