Re: [Flightgear-devel] Incorrect conversion used for lbs to gallon of fuel

2011-02-12 Thread Torsten Dreyer
> > Hi Bertrand,
> >
> > I am currently working on a more generic solution to the issue based on
> > your
> > patch. Currently we have at least three different places within
> > FlightGear
> > calculating tank contents and converting them between different units.
> > The idea is to have a TankProperties class encapsulating all property-
> > conversions and to have the fdm_shell create instances of the class.
> > With
> > that, you can write to any of it's properties (level, capacity,
> > density) using
> > any unit and have all other properties correct. There is no need to
> > have this
> > in every FDM and also in Nasal.
> > I'm curently testing various aircraft on Windows and Linux and I hope
> > to get
> > this commited later today.
> >
> > Greetings, Torsten
> 
> I've been so busy I missed this one earlier. Maybe I am missing something
> here. I certainly agree that doing things in several places (redundantly)
>  is a bad idea. But I wonder if the creation of a TankProperties class is
>  needed, or rather if there is some deficiency in the way tanks are handled
>  in the FDMs at this time? In JSBSim (and I assume in YASim) the JSBSim API
>  provides sufficient insight into the tank "state." Certain properties are
>  also available.
> 
> I know that the tank-related properties are probably not referred to the
> same way on the FlightGear side and on the JSBSim (and other FDM) side. Is
> that what your TankProperties class is supposed to coordinate? Would it be
> better to use the API rather than properties, if that is the case?
> 
> This also leads to an interesting situation which has probably been
> discussed before, but which I don't recall. The existing tanks in any
> vehicle model may be filled as specified by the modeler (hopefully the fuel
> tanks are filled up). That is very important for when running JSBSim in a
> standalone mode. Of course FlightGear can and should allow filling of the
> tanks to any degree desired, so the TankContents value in the JSBSim
> aircraft config file is irrelevant for FlightGear - although it might allow
> for a default fill level if desired. But the location, capacity, and other
> values should be respected, as I assume they are.
> 
> Jon
We used to have (and still have) a myriad of places where fuel-mass, -weight 
and -volume are computed in english, american und metric units - more or less 
correct, sometimes using hard-coded densities, sometimes using the provided 
density-property. Not only in the FDM but many aircraft-nasal scripts have 
very creative ways of implementing fuel consumption.

My idea was to have the FlightGear properties in /consumeables/fuel/ handled 
by instances of a class wrapping all the computation and keeping all props in 
a consistend state. Using tied properties ensures that, when changing the 
density, all volume properties change their value, too (assuming the mass of 
fuel is constant). Consuming fuel by decreasing content as volume 
automatically keeps the mass in sync and vice versa. Also (and newly) there is 
a property for unusable fuel (aka "pocket fuel") and and an "empty" property, 
all automatically computed. A tank is "empty" for example, if the content 
(volume) is less than the usable fuel (volume).
Also, some properties for total-fuel (sum of all tanks) as volume and mass 
come along with this.

Bertrand provided the initial work to make sure the values defined in 
FlightGear's aircraft configuration overwrite the values define in JSBSim 
config and JSBSim's values are used if no definition exists within FlightGear.

All this could obsolete a lot of nasal code for aircraft and should unify the 
fuel-properties across FDM. 

Torsten



--
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
___
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel


Re: [Flightgear-devel] Incorrect conversion used for lbs to gallon of fuel

2011-02-12 Thread Jon S. Berndt
> Hi Bertrand,
> 
> I am currently working on a more generic solution to the issue based on
> your
> patch. Currently we have at least three different places within
> FlightGear
> calculating tank contents and converting them between different units.
> The idea is to have a TankProperties class encapsulating all property-
> conversions and to have the fdm_shell create instances of the class.
> With
> that, you can write to any of it's properties (level, capacity,
> density) using
> any unit and have all other properties correct. There is no need to
> have this
> in every FDM and also in Nasal.
> I'm curently testing various aircraft on Windows and Linux and I hope
> to get
> this commited later today.
> 
> Greetings, Torsten


I've been so busy I missed this one earlier. Maybe I am missing something
here. I certainly agree that doing things in several places (redundantly) is
a bad idea. But I wonder if the creation of a TankProperties class is
needed, or rather if there is some deficiency in the way tanks are handled
in the FDMs at this time? In JSBSim (and I assume in YASim) the JSBSim API
provides sufficient insight into the tank "state." Certain properties are
also available.

I know that the tank-related properties are probably not referred to the
same way on the FlightGear side and on the JSBSim (and other FDM) side. Is
that what your TankProperties class is supposed to coordinate? Would it be
better to use the API rather than properties, if that is the case?

This also leads to an interesting situation which has probably been
discussed before, but which I don't recall. The existing tanks in any
vehicle model may be filled as specified by the modeler (hopefully the fuel
tanks are filled up). That is very important for when running JSBSim in a
standalone mode. Of course FlightGear can and should allow filling of the
tanks to any degree desired, so the TankContents value in the JSBSim
aircraft config file is irrelevant for FlightGear - although it might allow
for a default fill level if desired. But the location, capacity, and other
values should be respected, as I assume they are.

Jon




--
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
___
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel


Re: [Flightgear-devel] Incorrect conversion used for lbs to gallon of fuel

2011-02-12 Thread Torsten Dreyer
> That was not my point.
> I was talking about the Nasal error.
> Nasal runtime error: vector index 7 out of bounds (size: 7)
>   at
> /wrklvm/FlightGear/FlightGear_CVS/data/Aircraft/Boeing314/Nasal/Boeing314-f
> uel.nas, line 79
That should be fixed. However, the version in GIT is broken due to a missing 
file as Csaba allready pointed out.
The computation of fuel-levels and weights in the Nasal file can now be 
removed as this is the main intention of the new TankProperties class and 
handled there.

Regards, Torsten

--
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
___
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel


Re: [Flightgear-devel] Incorrect conversion used for lbs to gallon of fuel

2011-02-12 Thread Torsten Dreyer
> But you have broken my patch! :)
Apologies! It's been a busy week and I tried to commit smart fixes between 
long work-days. Obviously not a good idea ;-)

> Also, Anders pointed out that more tanks may be needed even if they
> are not (yet) in the property tree, so ultimately the FDM should be
> consulted.
I wouldn't want to do that. Each FDM handles tanks in a different way and I 
don't like the idea of implementing an individual query for JSBSim, yasim and 
all other known (and probably unknown) FDM. The idea behind the tank-
properties class is to have a generic handling of fuel weight/mass/volume and 
not to depend on the FDM implementation.

I'd prefer to ask the aircraft designer to at least set num-tanks to have the 
required tanks created.

Torsten

--
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
___
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel


Re: [Flightgear-devel] Incorrect conversion used for lbs to gallon of fuel

2011-02-10 Thread Csaba Halász
On Thu, Feb 10, 2011 at 3:21 PM, henri orange  wrote:
> That was not my point.
> I was talking about the Nasal error.

I know. I just pointed out that the GIT version is broken anyway.
BUT working around the missing file, it DOES now fly, without the fuel
nasal error.

-- 
Csaba/Jester

--
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
___
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel


Re: [Flightgear-devel] Incorrect conversion used for lbs to gallon of fuel

2011-02-10 Thread henri orange
That was not my point.
I was talking about the Nasal error.
Nasal runtime error: vector index 7 out of bounds (size: 7)
  at
/wrklvm/FlightGear/FlightGear_CVS/data/Aircraft/Boeing314/Nasal/Boeing314-fuel.nas,
line 79
  called from:
/wrklvm/FlightGear/FlightGear_CVS/data/Aircraft/Boeing314/Nasal/Boeing314-fuel.nas,
line 70
  called from:
/wrklvm/FlightGear/FlightGear_CVS/data/Aircraft/Boeing314/Nasal/Boeing314-fuel.nas,
line 59
  called from:
/wrklvm/FlightGear/FlightGear_CVS/data/Aircraft/Boeing314/Nasal/Boeing314-fuel.nas,
line 19
  called from:
/wrklvm/FlightGear/FlightGear_CVS/data/Aircraft/Boeing314/Nasal/Boeing314.nas,
line 92
  called from:
/wrklvm/FlightGear/FlightGear_CVS/data/Aircraft/Boeing314/Nasal/Boeing314.nas,
line 111
  called from:
/wrklvm/FlightGear/FlightGear_CVS/data/Aircraft/Boeing314/Nasal/Boeing314.nas,
line 17
  called from:
/wrklvm/FlightGear/FlightGear_CVS/data/Aircraft/Boeing314/Nasal/Boeing314.nas,
line 125
  called from: /wrklvm/FlightGear/FlightGear_CVS/data/Nasal/globals.nas,
line 100



2011/2/8 Csaba Halász 

> On Tue, Feb 8, 2011 at 10:05 PM, henri orange  wrote:
> > Will it solved the Boeing314 issue ?
>
> The Boeing314 in GIT doesn't even get that far, it is missing a file
> "Nasal/Boeing314-limits.xml"
> Commenting the reference out, the aircraft at least takes off.
>
> --
> Csaba/Jester
>
>
>


-- 
Best regards,

Henri, aka Alva
Official grtux hangar maintainer
--
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb___
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel


Re: [Flightgear-devel] Incorrect conversion used for lbs to gallon of fuel

2011-02-08 Thread Csaba Halász
On Tue, Feb 8, 2011 at 10:05 PM, henri orange  wrote:
> Will it solved the Boeing314 issue ?

The Boeing314 in GIT doesn't even get that far, it is missing a file
"Nasal/Boeing314-limits.xml"
Commenting the reference out, the aircraft at least takes off.

-- 
Csaba/Jester

--
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
___
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel


Re: [Flightgear-devel] Incorrect conversion used for lbs to gallon of fuel

2011-02-08 Thread Csaba Halász
On Tue, Feb 8, 2011 at 9:27 PM, Torsten Dreyer  wrote:
>> And that is because of the hardcoded default of 8 fuel tanks. Attached
>> patch makes sure at least the existing tanks are covered by the
>> properties.
>>
> Thanks for spotting this. I was naive enough to think no aircraft ever has
> more then eight tanks. Now TankProperties are created for every configured
> tank in /consumeables/fuel.
>
> This should keep the Concorde for a bit longer again.

But you have broken my patch! :)
The code should specifically check for the number of "tank" subnodes
(although overestimating the number is harmless).
However, this doesn't work as intended:

  int n = rootNode->nChildren();
  if( n == 0 ) n = rootNode->getIntValue( "numtanks", 8 );

Since if n is zero, that means no children whatsoever, so no
"numtanks" either. Thus then it will always be 8, and can not be set
via a "numtanks" property (because then n will be one).

Also, Anders pointed out that more tanks may be needed even if they
are not (yet) in the property tree, so ultimately the FDM should be
consulted.

-- 
Csaba/Jester

--
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
___
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel


Re: [Flightgear-devel] Incorrect conversion used for lbs to gallon of fuel

2011-02-08 Thread henri orange
Will it solved the Boeing314 issue ?

2011/2/8 Torsten Dreyer 

> > And that is because of the hardcoded default of 8 fuel tanks. Attached
> > patch makes sure at least the existing tanks are covered by the
> > properties.
> >
> Thanks for spotting this. I was naive enough to think no aircraft ever has
> more then eight tanks. Now TankProperties are created for every configured
> tank in /consumeables/fuel.
>
> This should keep the Concorde for a bit longer again.
>
> Torsten
>
>

-- 
Best regards,

Henri, aka Alva
Official grtux hangar maintainer
--
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb___
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel


Re: [Flightgear-devel] Incorrect conversion used for lbs to gallon of fuel

2011-02-08 Thread Torsten Dreyer
> And that is because of the hardcoded default of 8 fuel tanks. Attached
> patch makes sure at least the existing tanks are covered by the
> properties.
> 
Thanks for spotting this. I was naive enough to think no aircraft ever has 
more then eight tanks. Now TankProperties are created for every configured 
tank in /consumeables/fuel.

This should keep the Concorde for a bit longer again.

Torsten

--
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
___
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel


Re: [Flightgear-devel] Incorrect conversion used for lbs to gallon of fuel

2011-02-07 Thread henri orange
Hello,

Beware that version, break  the tanks system of Boeing 314

Here the Nasal error
Nasal runtime error: vector index 7 out of bounds (size: 7)
  at
/wrklvm/FlightGear/FlightGear_CVS/data/Aircraft/Boeing314/Nasal/Boeing314-fuel.nas,
line 79
  called from:
/wrklvm/FlightGear/FlightGear_CVS/data/Aircraft/Boeing314/Nasal/Boeing314-fuel.nas,
line 70
  called from:
/wrklvm/FlightGear/FlightGear_CVS/data/Aircraft/Boeing314/Nasal/Boeing314-fuel.nas,
line 59
  called from:
/wrklvm/FlightGear/FlightGear_CVS/data/Aircraft/Boeing314/Nasal/Boeing314-fuel.nas,
line 19
  called from:
/wrklvm/FlightGear/FlightGear_CVS/data/Aircraft/Boeing314/Nasal/Boeing314.nas,
line 92
  called from:
/wrklvm/FlightGear/FlightGear_CVS/data/Aircraft/Boeing314/Nasal/Boeing314.nas,
line 111
  called from:
/wrklvm/FlightGear/FlightGear_CVS/data/Aircraft/Boeing314/Nasal/Boeing314.nas,
line 17
  called from:
/wrklvm/FlightGear/FlightGear_CVS/data/Aircraft/Boeing314/Nasal/Boeing314.nas,
line 125
  called from: /wrklvm/FlightGear/FlightGear_CVS/data/Nasal/globals.nas,
line 100

My previous version didn't
Revision: 133cfbfa7f4ec62ddc97bd93d4a50fec81b52362





2011/2/6 Hal V. Engel 

>  On Sunday, February 06, 2011 01:13:28 PM Torsten Dreyer wrote:
>
> > > I have checked your code and it breaks the previous behaviour for
>
> > > JSBSim. Your code is overwriting JSBSim values during initialization,
>
> > > I would rather do it the other way around and make JSBSim overwrite
>
> > > FlightGear default values. Especially because the capacity of all the
>
> > > tanks is now set to zero instead of using the FDM model definition.
>
> > >
>
> > > Enclosed is a patch that restores the normal behaviour : fuel
>
> > > capacity, level and density are set after the values defined in the
>
> > > aircraft JSBSim XML definition.
>
> >
>
> > Ouch - that was my bad. I only initialized JSBSim properties from
>
> > FlightGear properties which didn't work if tanks are only defined within
>
> > the JSBSim config file.
>
> > Your patch turns this the other way round. I tried to combine both
> versions
>
> > and set JSBSim properties from FlightGear properties if they exist and
>
> > create the FlightGear properties from JSBSim properties if not.
>
> >
>
> > Looks good for me with the p51d-jsbsim, the c172p and the SenecaII.
>
> >
>
> > Thanks for the fast bug-report and the solution!
>
> >
>
> > Torsten
>
>
> Did you test the P-51D drop tanks to make sure these work OK? The unusual
> thing it does is to prevent the drop tank contents from being non-zero
> unless the tank is currently in place. This is to prevent the pilot from
> using the Equipment --> Fuel and Payload menu to put fuel into a
> non-existant drop tank. This should be tested just to make sure it is still
> working.
>
>
> Hal
>
>
> --
> The modern datacenter depends on network connectivity to access resources
> and provide services. The best practices for maximizing a physical server's
> connectivity to a physical network are well understood - see how these
> rules translate into the virtual world?
> http://p.sf.net/sfu/oracle-sfdevnlfb
> ___
> Flightgear-devel mailing list
> Flightgear-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/flightgear-devel
>
>


-- 
Best regards,

Henri, aka Alva
Official grtux hangar maintainer
--
The modern datacenter depends on network connectivity to access resources
and provide services. The best practices for maximizing a physical server's
connectivity to a physical network are well understood - see how these
rules translate into the virtual world? 
http://p.sf.net/sfu/oracle-sfdevnlfb___
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel


Re: [Flightgear-devel] Incorrect conversion used for lbs to gallon of fuel

2011-02-06 Thread Hal V. Engel
On Sunday, February 06, 2011 01:13:28 PM Torsten Dreyer wrote:
> > I have checked your code and it breaks the previous behaviour for
> > JSBSim. Your code is overwriting JSBSim values during initialization,
> > I would rather do it the other way around and make JSBSim overwrite
> > FlightGear default values. Especially because the capacity of all the
> > tanks is now set to zero instead of using the FDM model definition.
> > 
> > Enclosed is a patch that restores the normal behaviour : fuel
> > capacity, level and density are set after the values defined in the
> > aircraft JSBSim XML definition.
> 
> Ouch - that was my bad. I only initialized JSBSim properties from
> FlightGear properties which didn't work if tanks are only defined within
> the JSBSim config file.
> Your patch turns this the other way round. I tried to combine both versions
> and set JSBSim properties from FlightGear properties if they exist and
> create the FlightGear properties from JSBSim properties if not.
> 
> Looks good for me with the p51d-jsbsim, the c172p and the SenecaII.
> 
> Thanks for the fast bug-report and the solution!
> 
> Torsten

Did you test the P-51D drop tanks to make sure these work OK?  The unusual 
thing it does is to prevent the drop tank contents from being non-zero unless 
the tank is currently in place.  This is to prevent the pilot from using the 
Equipment --> Fuel and Payload menu to put fuel into a non-existant drop tank.  
This should be tested just to make sure it is still working.

Hal 
--
The modern datacenter depends on network connectivity to access resources
and provide services. The best practices for maximizing a physical server's
connectivity to a physical network are well understood - see how these
rules translate into the virtual world? 
http://p.sf.net/sfu/oracle-sfdevnlfb___
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel


Re: [Flightgear-devel] Incorrect conversion used for lbs to gallon of fuel

2011-02-06 Thread Torsten Dreyer
> I have checked your code and it breaks the previous behaviour for
> JSBSim. Your code is overwriting JSBSim values during initialization,
> I would rather do it the other way around and make JSBSim overwrite
> FlightGear default values. Especially because the capacity of all the
> tanks is now set to zero instead of using the FDM model definition.
> 
> Enclosed is a patch that restores the normal behaviour : fuel
> capacity, level and density are set after the values defined in the
> aircraft JSBSim XML definition.
Ouch - that was my bad. I only initialized JSBSim properties from FlightGear 
properties which didn't work if tanks are only defined within the JSBSim 
config file. 
Your patch turns this the other way round. I tried to combine both versions 
and set JSBSim properties from FlightGear properties if they exist and create 
the FlightGear properties from JSBSim properties if not.

Looks good for me with the p51d-jsbsim, the c172p and the SenecaII.

Thanks for the fast bug-report and the solution!

Torsten 

--
The modern datacenter depends on network connectivity to access resources
and provide services. The best practices for maximizing a physical server's
connectivity to a physical network are well understood - see how these
rules translate into the virtual world? 
http://p.sf.net/sfu/oracle-sfdevnlfb
___
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel


Re: [Flightgear-devel] Incorrect conversion used for lbs to gallon of fuel

2011-02-06 Thread Csaba Halász
On Sun, Feb 6, 2011 at 9:35 PM, Csaba Halász  wrote:
>
> But the Concorde still doesn't fly, it now runs out of fuel after a
> few seconds. Still investigating that issue.

And that is because of the hardcoded default of 8 fuel tanks. Attached
patch makes sure at least the existing tanks are covered by the
properties.

-- 
Csaba/Jester
diff --git a/src/FDM/TankProperties.cxx b/src/FDM/TankProperties.cxx
index 7bd24fb..d72362c 100644
--- a/src/FDM/TankProperties.cxx
+++ b/src/FDM/TankProperties.cxx
@@ -174,6 +174,9 @@ TankPropertiesList::TankPropertiesList( SGPropertyNode_ptr 
rootNode )
   // we don't have a global rule how many tanks we support, so I assume eight.
   // Because hard coded values suck, make it settable by a property
   size_type n = rootNode->getIntValue( "numtanks", 8 );
+  // but make sure it at least covers the existing children
+  size_type existing = rootNode->getChildren( "tank" ).size();
+  if ( n < existing ) n = existing;
   for( size_type i = 0; i < n; i++ ) {
 push_back( new TankProperties( rootNode->getChild( "tank", i, true ) ) );
   }
--
The modern datacenter depends on network connectivity to access resources
and provide services. The best practices for maximizing a physical server's
connectivity to a physical network are well understood - see how these
rules translate into the virtual world? 
http://p.sf.net/sfu/oracle-sfdevnlfb___
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel


Re: [Flightgear-devel] Incorrect conversion used for lbs to gallon of fuel

2011-02-06 Thread Csaba Halász
On Sun, Feb 6, 2011 at 9:24 PM, Bertrand Coconnier  wrote:
> 2011/2/6 Torsten Dreyer :
>>
>> I tried the few JSBSim and YASim aircraft that I'm able to handle, please
>> report if I broke anything.
>>
>
> Have you read my previous e-mail ? I attached a patch because JSBSim
> fuel calcs are broken (tested aircraft is p51d). All P51d tank
> capacities, levels and fuel densities are wrongly overwritten and set
> to 0.0 (except the density which is set to 6.3 lbs/gal instead of 6.02
> lbs/gal).
> Jester tested my patch as well and reported it to work.

Indeed it fixes the problem it is supposed to fix.
But the Concorde still doesn't fly, it now runs out of fuel after a
few seconds. Still investigating that issue.

-- 
Csaba/Jester

--
The modern datacenter depends on network connectivity to access resources
and provide services. The best practices for maximizing a physical server's
connectivity to a physical network are well understood - see how these
rules translate into the virtual world? 
http://p.sf.net/sfu/oracle-sfdevnlfb
___
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel


Re: [Flightgear-devel] Incorrect conversion used for lbs to gallon of fuel

2011-02-06 Thread Bertrand Coconnier
2011/2/6 Torsten Dreyer :
>
> I tried the few JSBSim and YASim aircraft that I'm able to handle, please
> report if I broke anything.
>

Have you read my previous e-mail ? I attached a patch because JSBSim
fuel calcs are broken (tested aircraft is p51d). All P51d tank
capacities, levels and fuel densities are wrongly overwritten and set
to 0.0 (except the density which is set to 6.3 lbs/gal instead of 6.02
lbs/gal).
Jester tested my patch as well and reported it to work.

Could you please check and give me your comments ?

Thanks

Bertrand.

--
The modern datacenter depends on network connectivity to access resources
and provide services. The best practices for maximizing a physical server's
connectivity to a physical network are well understood - see how these
rules translate into the virtual world? 
http://p.sf.net/sfu/oracle-sfdevnlfb
___
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel


Re: [Flightgear-devel] Incorrect conversion used for lbs to gallon of fuel

2011-02-06 Thread Torsten Dreyer
> Need to update the MSVC90 project file?
Yep - that's done.

All builds should be "green" again. 

This patch provides consistent tank properties for 
/consumables/fuel/tank[0..7]. The handled properties under each branch are
* level-kg (fuel level in kilogramm)
* density-kgpm3 (fuel density in kg per m^3)
* capacity-m3 (tank capacity in m^3)
* level-m3 (fuel level in m^3)
* level-norm (relative fuel level wrt. volume)
* density-ppg (fuel density lbs per galon)
* level-lbs (fuel level in lbs)
* level-gal_us (fuel level in us-gallons)
* level-gal_imp (fuel level in imperial gallons)
* capacity-gal_us (tank capacity in us gallons)
* capacity-gal_imp (tank capacity in imperial gallons)
All these properties are tied properties, they don't trigger listeners but 
they automatically update the depending properties when they are written to.
The number of tanks created defaults to eight but is configurable by setting 
/consumables/fuel/numtanks to the number of tanks required.

Aditionally, there are properties summing the fuel of all tanks under 
/consumables/fuel, these are
* total-fuel-kg (total fuel in kilogramm)
* total-fuel-lbs (total fuel in lbs)
* total-fuel-gal_us (total fuel in us gallons)
* total-fuel-gals (total fuel in us gallons, used for compatibility)
* total-fuel-gal_imp (total fuel in imperial gallons)
* total-fuel-norm (relative fuel level wrt. volume)
These properties are read-only properties.

I think I found all places in the core code that compute fuel levels, this 
should now live in a single place. There is still fuel.nas requiring some 
cleanup, that will be done during the next days.

I tried the few JSBSim and YASim aircraft that I'm able to handle, please 
report if I broke anything.

Torsten

--
The modern datacenter depends on network connectivity to access resources
and provide services. The best practices for maximizing a physical server's
connectivity to a physical network are well understood - see how these
rules translate into the virtual world? 
http://p.sf.net/sfu/oracle-sfdevnlfb
___
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel


Re: [Flightgear-devel] Incorrect conversion used for lbs to gallon of fuel

2011-02-06 Thread Bertrand Coconnier
2011/2/6 Torsten Dreyer :
> I'm curently testing various aircraft on Windows and Linux and I hope to get
> this commited later today.
>

Torsten,

I have checked your code and it breaks the previous behaviour for
JSBSim. Your code is overwriting JSBSim values during initialization,
I would rather do it the other way around and make JSBSim overwrite
FlightGear default values. Especially because the capacity of all the
tanks is now set to zero instead of using the FDM model definition.

Enclosed is a patch that restores the normal behaviour : fuel
capacity, level and density are set after the values defined in the
aircraft JSBSim XML definition.

Bertrand.
diff --git a/src/FDM/JSBSim/JSBSim.cxx b/src/FDM/JSBSim/JSBSim.cxx
index c6f1933..006c66e 100644
--- a/src/FDM/JSBSim/JSBSim.cxx
+++ b/src/FDM/JSBSim/JSBSim.cxx
@@ -212,17 +212,21 @@ FGJSBsim::FGJSBsim( double dt )
 
 // Set initial fuel levels if provided.
 for (unsigned int i = 0; i < Propulsion->GetNumTanks(); i++) {
-  double d;
   SGPropertyNode * node = fgGetNode("/consumables/fuel/tank", i, true);
   FGTank* tank = Propulsion->GetTank(i);
+  double fuelDensity = tank->GetDensity();
+  double contents = tank->GetContents();
 
-  d = node->getNode( "density-ppg", true )->getDoubleValue();
-  if( d > 0.0 )
-tank->SetDensity( d );
+  if (fuelDensity > 0.0) {
+double capacity = tank->GetCapacity();
 
-  d = node->getNode( "level-lbs", true )->getDoubleValue();
-  if( d > 0.0 )
-tank->SetContents( d );
+node->setDoubleValue("density-ppg", fuelDensity);
+if (capacity > 0.0)
+  node->setDoubleValue("capacity-gal_us", capacity / fuelDensity);
+  }
+
+  if (contents > 0.0)
+node->setDoubleValue("level-lbs", contents);
 }
 Propulsion->SetFuelFreeze((fgGetNode("/sim/freeze/fuel",true))->getBoolValue());
 
--
The modern datacenter depends on network connectivity to access resources
and provide services. The best practices for maximizing a physical server's
connectivity to a physical network are well understood - see how these
rules translate into the virtual world? 
http://p.sf.net/sfu/oracle-sfdevnlfb___
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel


Re: [Flightgear-devel] Incorrect conversion used for lbs to gallon of fuel

2011-02-06 Thread James Turner

On 6 Feb 2011, at 14:34, Torsten Dreyer wrote:

> I'm curently testing various aircraft on Windows and Linux and I hope to get 
> this commited later today.

Need to update the MSVC90 project file?

http://flightgear.simpits.org:8080/job/FlightGear-next-Win/395/

James




--
The modern datacenter depends on network connectivity to access resources
and provide services. The best practices for maximizing a physical server's
connectivity to a physical network are well understood - see how these
rules translate into the virtual world? 
http://p.sf.net/sfu/oracle-sfdevnlfb
___
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel


Re: [Flightgear-devel] Incorrect conversion used for lbs to gallon of fuel

2011-02-06 Thread Bertrand Coconnier
2011/2/6 Torsten Dreyer :
>
> I am currently working on a more generic solution to the issue based on your
> patch. Currently we have at least three different places within FlightGear
> calculating tank contents and converting them between different units.
> The idea is to have a TankProperties class encapsulating all property-
> conversions and to have the fdm_shell create instances of the class. With
> that, you can write to any of it's properties (level, capacity, density) using
> any unit and have all other properties correct. There is no need to have this
> in every FDM and also in Nasal.
> I'm curently testing various aircraft on Windows and Linux and I hope to get
> this commited later today.
>
> Greetings, Torsten

Great !
Thanks for the update.

Bertrand.

--
The modern datacenter depends on network connectivity to access resources
and provide services. The best practices for maximizing a physical server's
connectivity to a physical network are well understood - see how these
rules translate into the virtual world? 
http://p.sf.net/sfu/oracle-sfdevnlfb
___
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel


Re: [Flightgear-devel] Incorrect conversion used for lbs to gallon of fuel

2011-02-06 Thread Torsten Dreyer
> Hi FG developers,
> 
> Since no further comments have been made, is there any chance to see
> this patch committed in Flight Gear ?
> 
> In case you would have additional comments or questions before
> committing, I am of course open to answer them
> 
> Cheers,
> 
> Bertrand.
Hi Bertrand,

I am currently working on a more generic solution to the issue based on your 
patch. Currently we have at least three different places within FlightGear 
calculating tank contents and converting them between different units.
The idea is to have a TankProperties class encapsulating all property-
conversions and to have the fdm_shell create instances of the class. With 
that, you can write to any of it's properties (level, capacity, density) using 
any unit and have all other properties correct. There is no need to have this 
in every FDM and also in Nasal.
I'm curently testing various aircraft on Windows and Linux and I hope to get 
this commited later today.

Greetings, Torsten

--
The modern datacenter depends on network connectivity to access resources
and provide services. The best practices for maximizing a physical server's
connectivity to a physical network are well understood - see how these
rules translate into the virtual world? 
http://p.sf.net/sfu/oracle-sfdevnlfb
___
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel


Re: [Flightgear-devel] Incorrect conversion used for lbs to gallon of fuel

2011-02-06 Thread Bertrand Coconnier
2011/1/30 Bertrand Coconnier :
> 2011/1/29 Ron Jensen :
>>
>> +      double fuelDensity = Propulsion->GetTank(i)->GetDensity();
>>
>> ( ... )
>>
>> + Propulsion->GetTank(i)->GetContents() / fuelDensity);
>>
>>
>> Should we guard against GetDensity() returning 0?
>
> Correct.
>
> Please find an updated version of the patch that uses the standard
> fuel density (6.0 lbs/gal) if the density is too low or negative ( <
> 0.1). This is assuming that if the density goes below that threshold
> it can only be an error. Another policy would be to clamp the value to
> 0.1.
>
> Suggestions ?
>
> Also, unlike the existing code base, this patch is assuming that the
> fuel weight is the reference and that the fuel volume should be
> adjusted to the fuel density modifications. When the fuel temperature
> drops, its volume decreases but its weight is not changing. I would
> think that this does not break backward compatibility : the
> fuel/payload menu is checking the fuel volume against the tank
> capacity and is reacting well to density modifications in the property
> tree. But I would like to have other opinions.
>
> This version 3 of the patches supersedes the other two.
>

Hi FG developers,

Since no further comments have been made, is there any chance to see
this patch committed in Flight Gear ?

In case you would have additional comments or questions before
committing, I am of course open to answer them

Cheers,

Bertrand.

--
The modern datacenter depends on network connectivity to access resources
and provide services. The best practices for maximizing a physical server's
connectivity to a physical network are well understood - see how these
rules translate into the virtual world? 
http://p.sf.net/sfu/oracle-sfdevnlfb
___
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel


Re: [Flightgear-devel] Incorrect conversion used for lbs to gallon of fuel

2011-01-30 Thread Bertrand Coconnier
2011/1/29 Ron Jensen :
>
> +      double fuelDensity = Propulsion->GetTank(i)->GetDensity();
>
> ( ... )
>
> + Propulsion->GetTank(i)->GetContents() / fuelDensity);
>
>
> Should we guard against GetDensity() returning 0?

Correct.

Please find an updated version of the patch that uses the standard
fuel density (6.0 lbs/gal) if the density is too low or negative ( <
0.1). This is assuming that if the density goes below that threshold
it can only be an error. Another policy would be to clamp the value to
0.1.

Suggestions ?

Also, unlike the existing code base, this patch is assuming that the
fuel weight is the reference and that the fuel volume should be
adjusted to the fuel density modifications. When the fuel temperature
drops, its volume decreases but its weight is not changing. I would
think that this does not break backward compatibility : the
fuel/payload menu is checking the fuel volume against the tank
capacity and is reacting well to density modifications in the property
tree. But I would like to have other opinions.

This version 3 of the patches supersedes the other two.

Cheers,

Bertrand.
diff --git a/src/FDM/JSBSim/JSBSim.cxx b/src/FDM/JSBSim/JSBSim.cxx
index a9e9be7..2e75e44 100644
--- a/src/FDM/JSBSim/JSBSim.cxx
+++ b/src/FDM/JSBSim/JSBSim.cxx
@@ -213,14 +213,28 @@ FGJSBsim::FGJSBsim( double dt )
 // Set initial fuel levels if provided.
 for (unsigned int i = 0; i < Propulsion->GetNumTanks(); i++) {
   SGPropertyNode * node = fgGetNode("/consumables/fuel/tank", i, true);
+  FGTank* tank = Propulsion->GetTank(i);
+  double fuelDensity;
+
+  if (node->getChild("density-ppg", 0, false) != 0) {
+fuelDensity = node->getDoubleValue("density-ppg");
+tank->SetDensity(fuelDensity);
+  }
+  else {
+fuelDensity = tank->GetDensity();
+node->setDoubleValue("density-ppg", fuelDensity);
+  }
+
+  if (fuelDensity < 0.1)
+fuelDensity = 6.0; // Use average fuel value
+
   if (node->getChild("level-gal_us", 0, false) != 0) {
-Propulsion->GetTank(i)->SetContents(node->getDoubleValue("level-gal_us") * 6.6);
+tank->SetContents(node->getDoubleValue("level-gal_us") * fuelDensity);
   } else {
-node->setDoubleValue("level-lbs", Propulsion->GetTank(i)->GetContents());
-node->setDoubleValue("level-gal_us", Propulsion->GetTank(i)->GetContents() / 6.6);
+node->setDoubleValue("level-lbs", tank->GetContents());
+node->setDoubleValue("level-gal_us", tank->GetContents() / fuelDensity);
   }
-  node->setDoubleValue("capacity-gal_us",
-   Propulsion->GetTank(i)->GetCapacity() / 6.6);
+  node->setDoubleValue("capacity-gal_us", tank->GetCapacity() / fuelDensity);
 }
 Propulsion->SetFuelFreeze((fgGetNode("/sim/freeze/fuel",true))->getBoolValue());
 
@@ -695,8 +709,14 @@ bool FGJSBsim::copy_to_JSBsim()
 for (i = 0; i < Propulsion->GetNumTanks(); i++) {
   SGPropertyNode * node = fgGetNode("/consumables/fuel/tank", i, true);
   FGTank * tank = Propulsion->GetTank(i);
-  tank->SetContents(node->getDoubleValue("level-gal_us") * 6.6);
-//   tank->SetContents(node->getDoubleValue("level-lbs"));
+  double fuelDensity = node->getDoubleValue("density-ppg");
+
+  if (fuelDensity < 0.1)
+fuelDensity = 6.0; // Use average fuel value
+
+  tank->SetDensity(fuelDensity);
+//  tank->SetContents(node->getDoubleValue("level-gal_us") * fuelDensity);
+  tank->SetContents(node->getDoubleValue("level-lbs"));
 }
 
 Propulsion->SetFuelFreeze((fgGetNode("/sim/freeze/fuel",true))->getBoolValue());
@@ -934,7 +954,13 @@ bool FGJSBsim::copy_from_JSBsim()
 FGTank* tank = Propulsion->GetTank(i);
 double contents = tank->GetContents();
 double temp = tank->GetTemperature_degC();
-node->setDoubleValue("level-gal_us", contents/6.6);
+double fuelDensity = tank->GetDensity();
+
+if (fuelDensity < 0.1)
+  fuelDensity = 6.0; // Use average fuel value
+
+node->setDoubleValue("density-ppg" , fuelDensity);
+node->setDoubleValue("level-gal_us", contents/fuelDensity);
 node->setDoubleValue("level-lbs", contents);
 if (temp != -.0) node->setDoubleValue("temperature_degC", temp);
   }
--
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d___
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel


Re: [Flightgear-devel] Incorrect conversion used for lbs to gallon of fuel

2011-01-29 Thread Ron Jensen
On Saturday 29 January 2011 07:36:54 Bertrand Coconnier wrote:
> 2011/1/28 Hal V. Engel :
> > A thread was opened on the forum about how the C172P appeared to be
> > incorrectly calculating the amount of fuel in gallons based on the weight
> > of the fuel.  It appears that the conversion is using 6.6 lbs/gal when it
> > should be using something close to 6.0.  That is
> >
> > /fdm/jsbsim/propulsion/tank[n]/contents-lbs divided by
> > /consumables/fuel/tank[n]/level-us_gal == 6.6
> >
> > I also had an issue with this for the p51d-jsbsim model and I had to use
> > 6.6 as the conversion factor when setting up the fuel tanks in order to
> > get /consumables/fuel/tank[n]/level-us_gal to report the correct amount
> > of fuel. What is really strange is that
> > /consumables/fuel/tank[n]/density-ppg = 6.0. Is this a bug or is there
> > some other issue that aircraft developers need to be aware of to get this
> > to work correctly?
> >
> > Hal
>
> Hi Hal,
>
> This is somehow a bug since the fuel density is hardcoded to 6.6
> lbs/gal in src/FDM/JSBSim/JSBSim.cxx. Enclosed patch reads the fuel
> density from JSBSim to make conversion between volume and density.
>
> Note that JSBSim allows different sort of fuel density to be used (see
> JSBSim reference manual chapter 3.1.7.1 pp. 39-40). Most of the fuels
> seem to be around 6.6 lbs/gal with the notable exception of AVGAS and
> HYDRAZINE.
>
> Cheers,
>
> Bertrand.

+  double fuelDensity = Propulsion->GetTank(i)->GetDensity();

( ... )

+ Propulsion->GetTank(i)->GetContents() / fuelDensity);


Should we guard against GetDensity() returning 0?

Thanks,
Ron

--
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d
___
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel


Re: [Flightgear-devel] Incorrect conversion used for lbs to gallon of fuel

2011-01-29 Thread Bertrand Coconnier
A better improved patch that supersedes the previous FuelDensity.diff
I sent to this list.
This one takes /consumables/fuel/tank[n]/density-ppg into account in the calcs.

Cheers,

Bertrand.

2011/1/29 Bertrand Coconnier :
> 2011/1/28 Hal V. Engel :
>> A thread was opened on the forum about how the C172P appeared to be
>> incorrectly calculating the amount of fuel in gallons based on the weight of
>> the fuel.  It appears that the conversion is using 6.6 lbs/gal when it should
>> be using something close to 6.0.  That is
>>
>> /fdm/jsbsim/propulsion/tank[n]/contents-lbs divided by
>> /consumables/fuel/tank[n]/level-us_gal == 6.6
>>
>> I also had an issue with this for the p51d-jsbsim model and I had to use 6.6
>> as the conversion factor when setting up the fuel tanks in order to get
>> /consumables/fuel/tank[n]/level-us_gal to report the correct amount of fuel.
>> What is really strange is that /consumables/fuel/tank[n]/density-ppg = 6.0.
>> Is this a bug or is there some other issue that aircraft developers need to 
>> be
>> aware of to get this to work correctly?
>>
>> Hal
>>
>
> Hi Hal,
>
> This is somehow a bug since the fuel density is hardcoded to 6.6
> lbs/gal in src/FDM/JSBSim/JSBSim.cxx. Enclosed patch reads the fuel
> density from JSBSim to make conversion between volume and density.
>
> Note that JSBSim allows different sort of fuel density to be used (see
> JSBSim reference manual chapter 3.1.7.1 pp. 39-40). Most of the fuels
> seem to be around 6.6 lbs/gal with the notable exception of AVGAS and
> HYDRAZINE.
>
> Cheers,
>
> Bertrand.
>
diff --git a/src/FDM/JSBSim/JSBSim.cxx b/src/FDM/JSBSim/JSBSim.cxx
index f802c8c..fc09b0b 100644
--- a/src/FDM/JSBSim/JSBSim.cxx
+++ b/src/FDM/JSBSim/JSBSim.cxx
@@ -215,14 +213,25 @@ FGJSBsim::FGJSBsim( double dt )
 // Set initial fuel levels if provided.
 for (unsigned int i = 0; i < Propulsion->GetNumTanks(); i++) {
   SGPropertyNode * node = fgGetNode("/consumables/fuel/tank", i, true);
+  FGTank* tank = Propulsion->GetTank(i);
+  double fuelDensity;
+
+  if (node->getChild("density-ppg", 0, false) != 0) {
+fuelDensity = node->getDoubleValue("density-ppg");
+tank->SetDensity(fuelDensity);
+  }
+  else {
+fuelDensity = tank->GetDensity();
+node->setDoubleValue("density-ppg", fuelDensity);
+  }
+
   if (node->getChild("level-gal_us", 0, false) != 0) {
-Propulsion->GetTank(i)->SetContents(node->getDoubleValue("level-gal_us") * 6.6);
+tank->SetContents(node->getDoubleValue("level-gal_us") * fuelDensity);
   } else {
-node->setDoubleValue("level-lbs", Propulsion->GetTank(i)->GetContents());
-node->setDoubleValue("level-gal_us", Propulsion->GetTank(i)->GetContents() / 6.6);
+node->setDoubleValue("level-lbs", tank->GetContents());
+node->setDoubleValue("level-gal_us", tank->GetContents() / fuelDensity);
   }
-  node->setDoubleValue("capacity-gal_us",
-   Propulsion->GetTank(i)->GetCapacity() / 6.6);
+  node->setDoubleValue("capacity-gal_us", tank->GetCapacity() / fuelDensity);
 }
 Propulsion->SetFuelFreeze((fgGetNode("/sim/freeze/fuel",true))->getBoolValue());
 
@@ -670,7 +706,9 @@ bool FGJSBsim::copy_to_JSBsim()
 for (i = 0; i < Propulsion->GetNumTanks(); i++) {
   SGPropertyNode * node = fgGetNode("/consumables/fuel/tank", i, true);
   FGTank * tank = Propulsion->GetTank(i);
-  tank->SetContents(node->getDoubleValue("level-gal_us") * 6.6);
+  double fuelDensity = node->getDoubleValue("density-ppg");
+  tank->SetDensity(fuelDensity);
+  tank->SetContents(node->getDoubleValue("level-gal_us") * fuelDensity);
 //   tank->SetContents(node->getDoubleValue("level-lbs"));
 }
 
@@ -909,7 +947,9 @@ bool FGJSBsim::copy_from_JSBsim()
 FGTank* tank = Propulsion->GetTank(i);
 double contents = tank->GetContents();
 double temp = tank->GetTemperature_degC();
-node->setDoubleValue("level-gal_us", contents/6.6);
+double fuelDensity = tank->GetDensity();
+node->setDoubleValue("density-ppg" , fuelDensity);
+node->setDoubleValue("level-gal_us", contents/fuelDensity);
 node->setDoubleValue("level-lbs", contents);
 if (temp != -.0) node->setDoubleValue("temperature_degC", temp);
   }

--
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d___
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel


Re: [Flightgear-devel] Incorrect conversion used for lbs to gallon of fuel

2011-01-29 Thread Bertrand Coconnier
2011/1/28 Hal V. Engel :
> A thread was opened on the forum about how the C172P appeared to be
> incorrectly calculating the amount of fuel in gallons based on the weight of
> the fuel.  It appears that the conversion is using 6.6 lbs/gal when it should
> be using something close to 6.0.  That is
>
> /fdm/jsbsim/propulsion/tank[n]/contents-lbs divided by
> /consumables/fuel/tank[n]/level-us_gal == 6.6
>
> I also had an issue with this for the p51d-jsbsim model and I had to use 6.6
> as the conversion factor when setting up the fuel tanks in order to get
> /consumables/fuel/tank[n]/level-us_gal to report the correct amount of fuel.
> What is really strange is that /consumables/fuel/tank[n]/density-ppg = 6.0.
> Is this a bug or is there some other issue that aircraft developers need to be
> aware of to get this to work correctly?
>
> Hal
>

Hi Hal,

This is somehow a bug since the fuel density is hardcoded to 6.6
lbs/gal in src/FDM/JSBSim/JSBSim.cxx. Enclosed patch reads the fuel
density from JSBSim to make conversion between volume and density.

Note that JSBSim allows different sort of fuel density to be used (see
JSBSim reference manual chapter 3.1.7.1 pp. 39-40). Most of the fuels
seem to be around 6.6 lbs/gal with the notable exception of AVGAS and
HYDRAZINE.

Cheers,

Bertrand.
diff --git a/src/FDM/JSBSim/JSBSim.cxx b/src/FDM/JSBSim/JSBSim.cxx
index f802c8c..c752e5e 100644
--- a/src/FDM/JSBSim/JSBSim.cxx
+++ b/src/FDM/JSBSim/JSBSim.cxx
@@ -215,14 +213,15 @@ FGJSBsim::FGJSBsim( double dt )
 // Set initial fuel levels if provided.
 for (unsigned int i = 0; i < Propulsion->GetNumTanks(); i++) {
   SGPropertyNode * node = fgGetNode("/consumables/fuel/tank", i, true);
+  double fuelDensity = Propulsion->GetTank(i)->GetDensity();
   if (node->getChild("level-gal_us", 0, false) != 0) {
-Propulsion->GetTank(i)->SetContents(node->getDoubleValue("level-gal_us") * 6.6);
+Propulsion->GetTank(i)->SetContents(node->getDoubleValue("level-gal_us") * fuelDensity);
   } else {
 node->setDoubleValue("level-lbs", Propulsion->GetTank(i)->GetContents());
-node->setDoubleValue("level-gal_us", Propulsion->GetTank(i)->GetContents() / 6.6);
+node->setDoubleValue("level-gal_us", Propulsion->GetTank(i)->GetContents() / fuelDensity);
   }
   node->setDoubleValue("capacity-gal_us",
-   Propulsion->GetTank(i)->GetCapacity() / 6.6);
+   Propulsion->GetTank(i)->GetCapacity() / fuelDensity);
 }
 Propulsion->SetFuelFreeze((fgGetNode("/sim/freeze/fuel",true))->getBoolValue());
 
@@ -670,7 +696,7 @@ bool FGJSBsim::copy_to_JSBsim()
 for (i = 0; i < Propulsion->GetNumTanks(); i++) {
   SGPropertyNode * node = fgGetNode("/consumables/fuel/tank", i, true);
   FGTank * tank = Propulsion->GetTank(i);
-  tank->SetContents(node->getDoubleValue("level-gal_us") * 6.6);
+  tank->SetContents(node->getDoubleValue("level-gal_us") * Propulsion->GetTank(i)->GetDensity());
 //   tank->SetContents(node->getDoubleValue("level-lbs"));
 }
 

--
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d___
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel


[Flightgear-devel] Incorrect conversion used for lbs to gallon of fuel

2011-01-28 Thread Hal V. Engel
A thread was opened on the forum about how the C172P appeared to be 
incorrectly calculating the amount of fuel in gallons based on the weight of 
the fuel.  It appears that the conversion is using 6.6 lbs/gal when it should 
be using something close to 6.0.  That is
 
/fdm/jsbsim/propulsion/tank[n]/contents-lbs divided by 
/consumables/fuel/tank[n]/level-us_gal == 6.6 

I also had an issue with this for the p51d-jsbsim model and I had to use 6.6 
as the conversion factor when setting up the fuel tanks in order to get 
/consumables/fuel/tank[n]/level-us_gal to report the correct amount of fuel.  
What is really strange is that /consumables/fuel/tank[n]/density-ppg = 6.0.  
Is this a bug or is there some other issue that aircraft developers need to be 
aware of to get this to work correctly?

Hal

--
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d
___
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel