]> git.mxchange.org Git - flightgear.git/commitdiff
Fix for bug #204 and #222 by Bertrand Coconnier; NaNs (bug #222) were basically gener...
authorThorstenB <brehmt@gmail.com>
Sun, 6 Feb 2011 14:33:27 +0000 (15:33 +0100)
committerThorstenB <brehmt@gmail.com>
Sun, 6 Feb 2011 14:33:27 +0000 (15:33 +0100)
src/FDM/JSBSim/JSBSim.cxx
src/FDM/JSBSim/JSBSim.hxx
src/FDM/JSBSim/models/FGPropulsion.cpp

index 4fb0f43edce0fc3eee2a4921aa3b60279e7a6933..a2d217ba2989dbc8774f296fc7c0cc62d4ed30b2 100644 (file)
@@ -424,6 +424,33 @@ void FGJSBsim::init()
 
 /******************************************************************************/
 
+void checkTied ( FGPropertyManager *node )
+{
+  int N = node->nChildren();
+  string name;
+
+  for (int i=0; i<N; i++) {
+    if (node->getChild(i)->nChildren() ) {
+      checkTied( (FGPropertyManager*)node->getChild(i) );
+    }
+    if ( node->getChild(i)->isTied() ) {
+      name = ((FGPropertyManager*)node->getChild(i))->GetFullyQualifiedName();
+      node->Untie(name);
+    }
+  }
+}
+
+/******************************************************************************/
+
+void FGJSBsim::unbind()
+{
+  SGPropertyNode* instance = globals->get_props()->getNode("/fdm/jsbsim");
+  checkTied((FGPropertyManager*)instance);
+  FGInterface::unbind();
+}
+
+/******************************************************************************/
+
 // Run an iteration of the EOM (equations of motion)
 
 void FGJSBsim::update( double dt )
index 1a80371677d69ec2927a9f8d63bed724244060e9..a01146bcc0447aa5e06b744707553081e9cb7dd7 100644 (file)
@@ -110,6 +110,9 @@ public:
     /// Reset flight params to a specific position
     void init();
 
+    /// Unbind properties
+    void unbind();
+
     /// @name Position Parameter Set
     //@{
     /** Set geocentric latitude
@@ -283,8 +286,6 @@ private:
     void update_gear(void);
 
     void update_external_forces(double t_off);
-
-    void resetPropertyState();
 };
 
 
index 57d2852f3c46c9fe9a897018e312dc3496dae9ff..05a2da4c415d3bd95dcd60db1695dfcbabd09467 100644 (file)
@@ -307,18 +307,23 @@ bool FGPropulsion::Load(Element* el)
     try {
       if (type == "piston_engine") {
         HavePistonEngine = true;
+        if (!IsBound) bind();
         Engines.push_back(new FGPiston(FDMExec, document, numEngines));
       } else if (type == "turbine_engine") {
         HaveTurbineEngine = true;
+        if (!IsBound) bind();
         Engines.push_back(new FGTurbine(FDMExec, document, numEngines));
       } else if (type == "turboprop_engine") {
         HaveTurboPropEngine = true;
+        if (!IsBound) bind();
         Engines.push_back(new FGTurboProp(FDMExec, document, numEngines));
       } else if (type == "rocket_engine") {
         HaveRocketEngine = true;
+        if (!IsBound) bind();
         Engines.push_back(new FGRocket(FDMExec, document, numEngines));
       } else if (type == "electric_engine") {
         HaveElectricEngine = true;
+        if (!IsBound) bind();
         Engines.push_back(new FGElectric(FDMExec, document, numEngines));
       } else {
         cerr << "Unknown engine type: " << type << endl;
@@ -345,7 +350,6 @@ bool FGPropulsion::Load(Element* el)
   if (el->FindElement("dump-rate"))
     DumpRate = el->FindElementValueAsNumberConvertTo("dump-rate", "LBS/MIN");
 
-  if (!IsBound) bind();
   PostLoad(el, PropertyManager);
 
   return true;
@@ -642,7 +646,7 @@ void FGPropulsion::bind(void)
   typedef int (FGPropulsion::*iPMF)(void) const;
 
   IsBound = true;
-  PropertyManager->Tie("propulsion/set-running", this, (iPMF)0, &FGPropulsion::InitRunning, true);
+  PropertyManager->Tie("propulsion/set-running", this, (iPMF)0, &FGPropulsion::InitRunning, false);
   if (HaveTurbineEngine) {
     PropertyManager->Tie("propulsion/starter_cmd", this, (iPMF)0, &FGPropulsion::SetStarter,  true);
     PropertyManager->Tie("propulsion/cutoff_cmd", this,  (iPMF)0, &FGPropulsion::SetCutoff,   true);