]> git.mxchange.org Git - flightgear.git/commitdiff
Fix use of properties for fuel-tank levels.
authordavid <david>
Sat, 19 Jan 2002 18:26:30 +0000 (18:26 +0000)
committerdavid <david>
Sat, 19 Jan 2002 18:26:30 +0000 (18:26 +0000)
src/FDM/JSBSim.cxx
src/FDM/LaRCsim.cxx

index 42eec349a3152e51809a58748682d8cb10be42ab..da4bd24f49e21b0a12389e37b7644ceb627e194c 100644 (file)
@@ -123,6 +123,14 @@ FGJSBsim::FGJSBsim( double dt )
         
     
     init_gear();
+
+                               // Set initial fuel levels if provided.
+    for (int i = 0; i < Propulsion->GetNumTanks(); i++) {
+      SGPropertyNode * node = fgGetNode("/consumables/fuel/tank", i, true);
+      if (node->getChild("level-gal_us", 0, false) != 0)
+       Propulsion->GetTank(i)
+         ->SetContents(node->getDoubleValue("level-gal_us") * 6.6);
+    }
     
     fgSetDouble("/fdm/trim/pitch-trim", FCS->GetPitchTrimCmd());
     fgSetDouble("/fdm/trim/throttle",   FCS->GetThrottleCmd(0));
@@ -327,9 +335,10 @@ bool FGJSBsim::copy_to_JSBsim() {
 //                  << get_V_down_airmass() );
 
     for (i = 0; i < Propulsion->GetNumTanks(); i++) {
+      SGPropertyNode * node = fgGetNode("/consumables/fuel/tank", i, true);
       FGTank * tank = Propulsion->GetTank(i);
-      tank->SetContents(fgGetNode("consumables/fuel/tank", i, true)
-                       ->getDoubleValue());
+      tank->SetContents(node->getDoubleValue("level-gal_us") * 6.6);
+//       tank->SetContents(node->getDoubleValue("level-lb"));
     }
 
     return true;
@@ -455,9 +464,12 @@ bool FGJSBsim::copy_from_JSBsim() {
     }
 
                                // Copy the fuel levels from JSBSim.
-    for (i = 0; i < Propulsion->GetNumTanks(); i++)
-      fgGetNode("consumables/fuel/tank", i, true)
-       ->setDoubleValue(Propulsion->GetTank(i)->GetContents());
+    for (i = 0; i < Propulsion->GetNumTanks(); i++) {
+      SGPropertyNode * node = fgGetNode("/consumables/fuel/tank", i, true);
+      double contents = Propulsion->GetTank(i)->GetContents();
+      node->setDoubleValue("level-gal_us", contents/6.6);
+//       node->setDoubleValue("level-lb", contents);
+    }
 
     update_gear();
     
index d76287819ca66638615bd9a4840560178c1d3ce3..7d11ce73cfa2197b197c3adb27a1aff76feb1a9d 100644 (file)
@@ -120,11 +120,11 @@ void FGLaRCsim::update( int multiloop ) {
        fgSetDouble("/engines/engine/cranking", eng.getCrankingFlag());
 
         //Assume we are using both tanks equally for now
-       fgSetDouble("/consumables/fuel/tank[0]",
+       fgSetDouble("/consumables/fuel/tank[0]/level-gal_us",
                    fgGetDouble("/consumables/fuel/tank[0]")
                    - (eng.get_fuel_flow_gals_hr() / (2 * 3600))
                    * get_delta_t());
-       fgSetDouble("/consumables/fuel/tank[1]",
+       fgSetDouble("/consumables/fuel/tank[1]/level-gal_us",
                    fgGetDouble("/consumables/fuel/tank[1]")
                    - (eng.get_fuel_flow_gals_hr() / (2 * 3600))
                    * get_delta_t());