[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. A small portion of the code is in FG.<br><br>Starting in \
controls.cxx (version 2.4) you will find at<br><br>line \
#312<br> <em> <strong> _tiedProperties.Tie( \
"feed_tank", this, index, &FGControls::get_feed_tank, \
&FGControls::set_feed_tank )</strong></em><br style="font-style: italic; \
font-weight: bold;"><span style="font-style: italic; font-weight: \
bold;"> \
->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;"> if ( engine == \
ALL_ENGINES ) {</span><br style="font-style: italic; font-weight: bold;"><span \
style="font-style: italic; font-weight: \
bold;"> for ( int i = 0; i < \
MAX_ENGINES; i++ ) {</span><br style="font-style: italic; font-weight: bold;"><span \
style="font-style: italic; font-weight: \
bold;"> \
feed_tank[i] = tank;</span><br style="font-style: italic; font-weight: bold;"><span \
style="font-style: italic; font-weight: \
bold;"> \
SG_CLAMP_RANGE<int>( feed_tank[i], -1, 8 );</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;"> } else {</span><br style="font-style: italic; font-weight: \
bold;"><span style="font-style: italic; font-weight: \
bold;"> if ( (engine >= 0) && \
(engine < MAX_ENGINES) ) {</span><br style="font-style: italic; font-weight: \
bold;"><span style="font-style: italic; font-weight: \
bold;"> \
feed_tank[engine] = tank;</span><br style="font-style: italic; font-weight: \
bold;"><span style="font-style: italic; font-weight: \
bold;"> \
SG_CLAMP_RANGE<int>( feed_tank[engine], -1, 8 );</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;"> } </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. 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.<br><br> <span style="font-weight: bold; \
font-style: italic;"> node->getChild( \
"feed_tank" )->setIntValue( net->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. 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<span \
style="font-weight: bold; font-style: italic;"><br><br> \
eng->SetFuelTank( globals->get_controls()->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;"> if ( \
Active_Tank >= 0 ) {</span></strong><br style="font-weight: bold; font-style: \
italic;"><span style="font-weight: bold; font-style: \
italic;"> Tank = \
Propulsion->GetTank(Active_Tank);</span><br style="font-weight: bold; font-style: \
italic;"><span style="font-weight: bold; font-style: italic;"> \
if (Tank->GetType() == FGTank::ttFUEL) \
{</span><br style="font-weight: bold; font-style: italic;"><span style="font-weight: \
bold; font-style: italic;"> //Fshortage += \
Tank->Drain(CalcFuelNeed()/TanksWithFuel); // SEE NOTE ABOVE</span><br \
style="font-weight: bold; font-style: italic;"><span style="font-weight: bold; \
font-style: italic;"> \
Fshortage += Tank->Drain(CalcFuelNeed() );</span><br \
style="font-weight: bold; font-style: italic;"><span style="font-weight: bold; \
font-style: italic;"> }</span><br \
style="font-weight: bold; font-style: italic;"><span style="font-weight: bold; \
font-style: italic;"> } else Starved = true;</span><br \
style="font-weight: bold; font-style: italic;"><span style="font-weight: bold; \
font-style: italic;"> if (Fshortage < 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. 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. <br><br><span \
style="font-weight: bold; font-style: italic;"> Tank_0 = \
Propulsion->GetTank(0);</span><br style="font-weight: bold; font-style: \
italic;"><span style="font-weight: bold; font-style: italic;"> \
double center_fuel = Tank_0->GetContents();</span><br style="font-weight: bold; \
font-style: italic;"><span style="font-weight: bold; font-style: \
italic;"> if ( center_fuel < 6000.0 ) transfer = true;</span><br \
style="font-weight: bold; font-style: italic;"><span style="font-weight: bold; \
font-style: italic;"> else if ( center_fuel > \
9000.0 ) transfer = false;</span><br style="font-weight: bold; font-style: \
italic;"><span style="font-weight: bold; font-style: italic;"> if ( \
transfer ) {</span><br style="font-weight: bold; font-style: italic;"><span \
style="font-weight: bold; font-style: italic;"> \
Tank_1 = Propulsion->GetTank(1);</span><br style="font-weight: bold; font-style: \
italic;"><span style="font-weight: bold; font-style: italic;"> \
if ( Tank_1->GetContents() > 100.0 ) {</span><br \
style="font-weight: bold; font-style: italic;"><span style="font-weight: bold; \
font-style: italic;"> \
Tank_0->Fill( 0.040 );</span><br style="font-weight: bold; font-style: \
italic;"><span style="font-weight: bold; font-style: italic;"> \
Tank_1->Drain( 0.040 );</span><br \
style="font-weight: bold; font-style: italic;"><span style="font-weight: bold; \
font-style: italic;"> \
}</span><br style="font-weight: bold; font-style: italic;"><span style="font-weight: \
bold; font-style: italic;"> Tank_2 = \
Propulsion->GetTank(2);</span><br style="font-weight: bold; font-style: \
italic;"><span style="font-weight: bold; font-style: italic;"> \
if ( Tank_2->GetContents() > 100.0 ) {</span><br \
style="font-weight: bold; font-style: italic;"><span style="font-weight: bold; \
font-style: italic;"> \
Tank_0->Fill( 0.0401 );</span><br style="font-weight: bold; font-style: \
italic;"><span style="font-weight: bold; font-style: italic;"> \
Tank_2->Drain( 0.0401 ); // 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;"> }</span><br \
style="font-weight: bold; font-style: italic;"><span style="font-weight: bold; \
font-style: italic;"> }</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. 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. <br><br>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.<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