From fcf1709df61ec93182dc51ca4afa58ea152749a0 Mon Sep 17 00:00:00 2001 From: Torsten Dreyer Date: Sun, 6 Feb 2011 22:08:46 +0100 Subject: [PATCH] Fix the tank properties if no content was defined in fg --- src/FDM/JSBSim/JSBSim.cxx | 13 +++++++++++-- src/FDM/TankProperties.cxx | 2 +- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/FDM/JSBSim/JSBSim.cxx b/src/FDM/JSBSim/JSBSim.cxx index c6f193336..b86c2403d 100644 --- a/src/FDM/JSBSim/JSBSim.cxx +++ b/src/FDM/JSBSim/JSBSim.cxx @@ -26,6 +26,7 @@ #endif #include +#include #include // size_t #include @@ -217,12 +218,20 @@ FGJSBsim::FGJSBsim( double dt ) FGTank* tank = Propulsion->GetTank(i); d = node->getNode( "density-ppg", true )->getDoubleValue(); - if( d > 0.0 ) + if( d > 0.0 ) { tank->SetDensity( d ); + } else { + node->getNode( "density-ppg", true )->setDoubleValue( SG_MAX2(tank->GetDensity(), 0.1) ); + } d = node->getNode( "level-lbs", true )->getDoubleValue(); - if( d > 0.0 ) + if( d > 0.0 ) { tank->SetContents( d ); + } else { + node->getNode( "level-lbs", true )->setDoubleValue( tank->GetContents() ); + } + /* Capacity is read-only in FGTank and can't be overwritten from FlightGear */ + node->getNode("capacity-gal_us", true )->setDoubleValue( tank->GetCapacityGallons() ); } Propulsion->SetFuelFreeze((fgGetNode("/sim/freeze/fuel",true))->getBoolValue()); diff --git a/src/FDM/TankProperties.cxx b/src/FDM/TankProperties.cxx index 7bd24fb1e..8cfc768b3 100644 --- a/src/FDM/TankProperties.cxx +++ b/src/FDM/TankProperties.cxx @@ -37,7 +37,7 @@ static const double M3_PER_IMPGAL = 1.0/IMPGAL_PER_M3; TankProperties::TankProperties(SGPropertyNode_ptr rootNode ) : _content_kg(0.0), - _density_kgpm3(755.0), // avg. AVGAS density (more or less) + _density_kgpm3(0.0), _capacity_m3(0.0) { _tiedProperties.setRoot( rootNode );