2011/2/6 Torsten Dreyer <tors...@t3r.de>:
> 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

Reply via email to