[prev in list] [next in list] [prev in thread] [next in thread] 

List:       flightgear-devel
Subject:    Re: [Flightgear-devel] Fg Fuel System Changes
From:       castle.64 () comcast ! net
Date:       2012-10-23 16:48:17
Message-ID: 999121447.657263.1351010897822.JavaMail.root () sz0139a ! emeryville ! ca ! mail ! comcast ! net
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


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. 


[Attachment #5 (text/html)]

<html><head><style type='text/css'>p { margin: 0; }</style></head><body><div \
style='font-family: Arial; font-size: 12pt; color: #000000'>Hi,<br><br>First, thank \
you to all who answered my query, especially Jon for the details on the new tanking \
system.<br><br>I've designed a slightly different system that you all might want to \
consider.&nbsp; A small portion of the code is in FG.<br><br>Starting in \
controls.cxx&nbsp; (version 2.4) you will find at<br><br>line \
#312<br>&nbsp;<em>&nbsp;<strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; _tiedProperties.Tie( \
"feed_tank", this, index, &amp;FGControls::get_feed_tank, \
&amp;FGControls::set_feed_tank )</strong></em><br style="font-style: italic; \
font-weight: bold;"><span style="font-style: italic; font-weight: \
bold;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
-&gt;setAttribute( SGPropertyNode::ARCHIVE, true );</span><br><br>then at line \
#944<br><span style="font-style: italic; font-weight: bold;">void</span><br \
style="font-style: italic; font-weight: bold;"><span style="font-style: italic; \
font-weight: bold;">FGControls::set_feed_tank( int engine, int tank )</span><br \
style="font-style: italic; font-weight: bold;"><span style="font-style: italic; \
font-weight: bold;">{ </span><br style="font-style: italic; font-weight: bold;"><span \
style="font-style: italic; font-weight: bold;">&nbsp;&nbsp;&nbsp; if ( engine == \
ALL_ENGINES ) {</span><br style="font-style: italic; font-weight: bold;"><span \
style="font-style: italic; font-weight: \
bold;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for ( int i = 0; i &lt; \
MAX_ENGINES; i++ ) {</span><br style="font-style: italic; font-weight: bold;"><span \
style="font-style: italic; font-weight: \
bold;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
feed_tank[i] = tank;</span><br style="font-style: italic; font-weight: bold;"><span \
style="font-style: italic; font-weight: \
bold;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
SG_CLAMP_RANGE&lt;int&gt;( feed_tank[i], -1, 8 );</span><br style="font-style: \
italic; font-weight: bold;"><span style="font-style: italic; font-weight: \
bold;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span><br style="font-style: \
italic; font-weight: bold;"><span style="font-style: italic; font-weight: \
bold;">&nbsp;&nbsp;&nbsp; } else {</span><br style="font-style: italic; font-weight: \
bold;"><span style="font-style: italic; font-weight: \
bold;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ( (engine &gt;= 0) &amp;&amp; \
(engine &lt; MAX_ENGINES) ) {</span><br style="font-style: italic; font-weight: \
bold;"><span style="font-style: italic; font-weight: \
bold;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
feed_tank[engine] = tank;</span><br style="font-style: italic; font-weight: \
bold;"><span style="font-style: italic; font-weight: \
bold;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
SG_CLAMP_RANGE&lt;int&gt;( feed_tank[engine], -1, 8 );</span><br style="font-style: \
italic; font-weight: bold;"><span style="font-style: italic; font-weight: \
bold;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span><br style="font-style: \
italic; font-weight: bold;"><span style="font-style: italic; font-weight: \
bold;">&nbsp;&nbsp;&nbsp; } </span><span style="font-style: italic; font-weight: \
bold;"></span><br style="font-style: italic; font-weight: bold;"><span \
style="font-style: italic; font-weight: bold;">}</span><br style="font-style: \
italic;"><br>where the value of feed_tank[engine] is the number of the tank that \
feeds the engine.&nbsp;&nbsp; This also provided the ability to set the value via a \
network interface.&nbsp; See line #389 in native_ctrls.cxx.&nbsp; At init time all
feed_tank values are set to -1.<br><br>&nbsp;<span style="font-weight: bold; \
font-style: italic;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; node-&gt;getChild( \
"feed_tank" )-&gt;setIntValue( net-&gt;feed_tank_to[i] );<br><br></span>This code was \
incorporated as part of FG back in 2.2 IIRC.<br><br>Now here is where things got \
messy.&nbsp; 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.&nbsp; We \
essentially replaced FGTurbine.cpp with our physical model and made the following \
changes in the JSBSim code.&nbsp; In JSBSim.cxx we added at line #635<span \
style="font-weight: bold; font-style: italic;"><br><br>&nbsp;&nbsp;&nbsp; \
eng-&gt;SetFuelTank( globals-&gt;get_controls()-&gt;get_feed_tank(i) ); \
//JW<br></span><strong><br><span style="font-weight: normal;">and pretty much \
iviscerated the ConsumeFuel() method in FGEngine.cpp and replaced it with \
</span><br><br><span style="font-weight: bold; font-style: italic;">&nbsp;&nbsp; if ( \
Active_Tank &gt;= 0 ) {</span></strong><br style="font-weight: bold; font-style: \
italic;"><span style="font-weight: bold; font-style: \
italic;">&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Tank = \
Propulsion-&gt;GetTank(Active_Tank);</span><br style="font-weight: bold; font-style: \
italic;"><span style="font-weight: bold; font-style: italic;">&nbsp;&nbsp;&nbsp; \
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (Tank-&gt;GetType() == FGTank::ttFUEL) \
{</span><br style="font-weight: bold; font-style: italic;"><span style="font-weight: \
bold; font-style: italic;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //Fshortage += \
Tank-&gt;Drain(CalcFuelNeed()/TanksWithFuel);&nbsp; // SEE NOTE ABOVE</span><br \
style="font-weight: bold; font-style: italic;"><span style="font-weight: bold; \
font-style: italic;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; \
&nbsp;&nbsp;&nbsp; Fshortage += Tank-&gt;Drain(CalcFuelNeed() );</span><br \
style="font-weight: bold; font-style: italic;"><span style="font-weight: bold; \
font-style: italic;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</span><br \
style="font-weight: bold; font-style: italic;"><span style="font-weight: bold; \
font-style: italic;">&nbsp; &nbsp;&nbsp;&nbsp; } else Starved = true;</span><br \
style="font-weight: bold; font-style: italic;"><span style="font-weight: bold; \
font-style: italic;">&nbsp; if (Fshortage &lt; 10.00) Starved = \
true;<br><br></span>so if an engine did not have a tank value of 0 or greater it \
flamed out or would not start.&nbsp; This essentially moved all the logic and control \
of the fuel system out of FG and JSBSim over to the 747 simulator side.&nbsp;
We made one "messy" accomodation for the 737 and added the fuel
transfer function for the version of FG that runs the 737 sim.&nbsp; <br><br><span \
style="font-weight: bold; font-style: italic;">&nbsp;&nbsp;&nbsp; Tank_0 = \
Propulsion-&gt;GetTank(0);</span><br style="font-weight: bold; font-style: \
italic;"><span style="font-weight: bold; font-style: italic;">&nbsp;&nbsp;&nbsp; \
double center_fuel = Tank_0-&gt;GetContents();</span><br style="font-weight: bold; \
font-style: italic;"><span style="font-weight: bold; font-style: \
italic;">&nbsp;&nbsp;&nbsp; if ( center_fuel &lt; 6000.0 ) transfer = true;</span><br \
style="font-weight: bold; font-style: italic;"><span style="font-weight: bold; \
font-style: italic;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; else if ( center_fuel &gt; \
9000.0 ) transfer = false;</span><br style="font-weight: bold; font-style: \
italic;"><span style="font-weight: bold; font-style: italic;">&nbsp;&nbsp;&nbsp; if ( \
transfer ) {</span><br style="font-weight: bold; font-style: italic;"><span \
style="font-weight: bold; font-style: italic;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; \
Tank_1 = Propulsion-&gt;GetTank(1);</span><br style="font-weight: bold; font-style: \
italic;"><span style="font-weight: bold; font-style: italic;">&nbsp;&nbsp;&nbsp; \
&nbsp;&nbsp;&nbsp; if ( Tank_1-&gt;GetContents() &gt; 100.0 ) {</span><br \
style="font-weight: bold; font-style: italic;"><span style="font-weight: bold; \
font-style: italic;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; \
Tank_0-&gt;Fill( 0.040 );</span><br style="font-weight: bold; font-style: \
italic;"><span style="font-weight: bold; font-style: italic;">&nbsp;&nbsp;&nbsp; \
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Tank_1-&gt;Drain( 0.040 );</span><br \
style="font-weight: bold; font-style: italic;"><span style="font-weight: bold; \
font-style: italic;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; \
}</span><br style="font-weight: bold; font-style: italic;"><span style="font-weight: \
bold; font-style: italic;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Tank_2 = \
Propulsion-&gt;GetTank(2);</span><br style="font-weight: bold; font-style: \
italic;"><span style="font-weight: bold; font-style: italic;">&nbsp;&nbsp;&nbsp; \
&nbsp;&nbsp;&nbsp; if ( Tank_2-&gt;GetContents() &gt; 100.0 ) {</span><br \
style="font-weight: bold; font-style: italic;"><span style="font-weight: bold; \
font-style: italic;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; \
Tank_0-&gt;Fill( 0.0401 );</span><br style="font-weight: bold; font-style: \
italic;"><span style="font-weight: bold; font-style: italic;">&nbsp;&nbsp;&nbsp; \
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Tank_2-&gt;Drain( 0.0401 );&nbsp; // just a \
little nuisance to create an imbalance ;-)</span><br style="font-weight: bold; \
font-style: italic;"><span style="font-weight: bold; font-style: \
italic;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</span><br \
style="font-weight: bold; font-style: italic;"><span style="font-weight: bold; \
font-style: italic;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</span><br><br>In the 747 \
sim the hardware fuel control panel, fuel cutoff switches, and software determined \
which tanks fed which engines and fuel transfers.&nbsp; This, in turn, was sent via \
the network interface to FG and onto JSBSim.<br><br>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.&nbsp; <br><br>So I throw this idea out there as an alternative.&nbsp;&nbsp; \
Comments are always welcomed and if anyone wishes a complete set of the source \
changes, just email me.&nbsp; Have not posted them to the git repository,&nbsp; just \
to messy to handle all the ifdefs at compile time and build a coherent \
package.<br><br>Actually, looking over the newer code in 2.6 and 2.8, we may not be \
that far apart after all.<br><br>Thanks again for the responses.<br>John<br><br>oops, \
this may have been a double post, my apologies.<br><br><br><br>

<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:Calibri
}
--></style><br></div></body></html>



------------------------------------------------------------------------------
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


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic