]> git.mxchange.org Git - flightgear.git/commitdiff
Latest JSBSim updates -- includes fix for control surface animations.
authortony <tony>
Sun, 29 Sep 2002 13:33:53 +0000 (13:33 +0000)
committertony <tony>
Sun, 29 Sep 2002 13:33:53 +0000 (13:33 +0000)
20 files changed:
src/FDM/JSBSim/FGAerodynamics.cpp
src/FDM/JSBSim/FGAuxiliary.cpp
src/FDM/JSBSim/FGFCS.cpp
src/FDM/JSBSim/FGFCS.h
src/FDM/JSBSim/FGFDMExec.cpp
src/FDM/JSBSim/FGPropertyManager.cpp
src/FDM/JSBSim/FGPropertyManager.h
src/FDM/JSBSim/FGTranslation.cpp
src/FDM/JSBSim/JSBSim.cxx
src/FDM/JSBSim/filtersjb/FGDeadBand.cpp
src/FDM/JSBSim/filtersjb/FGFCSComponent.cpp
src/FDM/JSBSim/filtersjb/FGFCSComponent.h
src/FDM/JSBSim/filtersjb/FGFilter.cpp
src/FDM/JSBSim/filtersjb/FGGain.cpp
src/FDM/JSBSim/filtersjb/FGGain.h
src/FDM/JSBSim/filtersjb/FGGradient.cpp
src/FDM/JSBSim/filtersjb/FGKinemat.cpp
src/FDM/JSBSim/filtersjb/FGKinemat.h
src/FDM/JSBSim/filtersjb/FGSummer.cpp
src/FDM/JSBSim/filtersjb/FGSwitch.cpp

index 16bd979fb74fbde05cece62045d151707aeabf3a..eaeaa194d13ef51bfe2551adf8f2e9fb21caf967 100644 (file)
@@ -347,6 +347,7 @@ void FGAerodynamics::unbind(void)
   PropertyManager->Untie("aero/bi2vel");
   PropertyManager->Untie("aero/ci2vel");
   PropertyManager->Untie("aero/alpha-wing-rad");
+  PropertyManager->Untie("aero/stall-hyst-norm");
   PropertyManager->Untie("systems/stall-warn-norm");
 
   for ( i=0; i<NAxes; i++ ) {
index 0ef2a322193579863976f8d9400d8d6fc956d275..033e9153a35d1c7b8f5af12470e3ce809033dfc4 100644 (file)
@@ -83,6 +83,7 @@ FGAuxiliary::FGAuxiliary(FGFDMExec* fdmex) : FGModel(fdmex)
 
 FGAuxiliary::~FGAuxiliary()
 {
+  unbind();
   Debug(1);
 }
 
index 3fcaab4aa6ae2f31cd73611994a3e8693d389af5..c6ee9bd831788338d6bafc9eda2d540bc31e542c 100644 (file)
@@ -96,6 +96,11 @@ FGFCS::FGFCS(FGFDMExec* fdmex) : FGModel(fdmex)
 
 FGFCS::~FGFCS()
 {
+  unbind( PropertyManager->GetNode("fcs") );
+  unbind( PropertyManager->GetNode("ap") );
+  PropertyManager->Untie( "gear/gear-cmd-norm" );
+  PropertyManager->Untie( "gear/gear-pos-norm" );
+
   ThrottleCmd.clear();
   ThrottlePos.clear();
   MixtureCmd.clear();
@@ -103,13 +108,12 @@ FGFCS::~FGFCS()
   PropAdvanceCmd.clear();
   PropAdvance.clear();
 
-  unbind();
 
   unsigned int i;
 
   for (i=0;i<APComponents.size();i++) delete APComponents[i];
   for (i=0;i<FCSComponents.size();i++) delete FCSComponents[i];
-
+  
   Debug(1);
 }
 
@@ -380,7 +384,7 @@ bool FGFCS::Load(FGConfigFile* AC_cfg)
     if ( (((*Components)[i])->GetType() == "AEROSURFACE_SCALE" 
           || ((*Components)[i])->GetType() == "KINEMAT")  
                     && ((*Components)[i])->GetOutputNode() ) { 
-      nodeName = ((*Components)[i])->GetOutputNode()->GetName();  
+      nodeName = ((*Components)[i])->GetOutputNode()->GetName();
       if ( nodeName == "elevator-pos-rad" ) {
         ToNormalize[iDe]=i;
       } else if ( nodeName  == "left-aileron-pos-rad" 
@@ -834,56 +838,16 @@ void FGFCS::bindModel(void)
                           
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-void FGFCS::unbind(void)
+void FGFCS::unbind(FGPropertyManager *node)
 {
-  PropertyManager->Untie("fcs/aileron-cmd-norm");
-  PropertyManager->Untie("fcs/elevator-cmd-norm");
-  PropertyManager->Untie("fcs/rudder-cmd-norm");
-  PropertyManager->Untie("fcs/flap-cmd-norm");
-  PropertyManager->Untie("fcs/speedbrake-cmd-norm");
-  PropertyManager->Untie("fcs/spoiler-cmd-norm");
-  PropertyManager->Untie("fcs/pitch-trim-cmd-norm");
-  PropertyManager->Untie("fcs/roll-trim-cmd-norm");
-  PropertyManager->Untie("fcs/yaw-trim-cmd-norm");
-  PropertyManager->Untie("gear/gear-cmd-norm");
-  PropertyManager->Untie("fcs/left-aileron-pos-rad");
-  PropertyManager->Untie("fcs/mag-left-aileron-pos-rad");
-  PropertyManager->Untie("fcs/left-aileron-pos-norm");
-  PropertyManager->Untie("fcs/right-aileron-pos-rad");
-  PropertyManager->Untie("fcs/mag-right-aileron-pos-rad");
-  PropertyManager->Untie("fcs/right-aileron-pos-norm");
-  PropertyManager->Untie("fcs/elevator-pos-rad");
-  PropertyManager->Untie("fcs/mag-elevator-pos-rad");
-  PropertyManager->Untie("fcs/elevator-pos-norm");
-  PropertyManager->Untie("fcs/rudder-pos-rad");
-  PropertyManager->Untie("fcs/mag-rudder-pos-rad");
-  PropertyManager->Untie("fcs/rudder-pos-norm");
-  PropertyManager->Untie("fcs/flap-pos-deg");
-  PropertyManager->Untie("fcs/flap-pos-norm");
-  PropertyManager->Untie("fcs/speedbrake-pos-rad");
-  PropertyManager->Untie("fcs/mag-speedbrake-pos-rad");
-  PropertyManager->Untie("fcs/speedbrake-pos-norm");
-  PropertyManager->Untie("fcs/spoiler-pos-rad");
-  PropertyManager->Untie("fcs/mag-spoiler-pos-rad");
-  PropertyManager->Untie("fcs/spoiler-pos-norm");
-  PropertyManager->Untie("gear/gear-pos-norm");
-  PropertyManager->Untie("ap/elevator_cmd");
-  PropertyManager->Untie("ap/aileron_cmd");
-  PropertyManager->Untie("ap/rudder_cmd");
-  PropertyManager->Untie("ap/throttle_cmd");
-  PropertyManager->Untie("ap/attitude_setpoint");
-  PropertyManager->Untie("ap/altitude_setpoint");
-  PropertyManager->Untie("ap/heading_setpoint");
-  PropertyManager->Untie("ap/airspeed_setpoint");
-  PropertyManager->Untie("ap/acquire_attitude");
-  PropertyManager->Untie("ap/acquire_altitude");
-  PropertyManager->Untie("ap/acquire_heading");
-  PropertyManager->Untie("ap/acquire_airspeed");
-  PropertyManager->Untie("ap/attitude_hold");
-  PropertyManager->Untie("ap/altitude_hold");
-  PropertyManager->Untie("ap/heading_hold");
-  PropertyManager->Untie("ap/airspeed_hold");
-  PropertyManager->Untie("ap/wingslevel_hold");
+  int N = node->nChildren();
+  for(int i=0;i<N;i++) {
+    if(node->getChild(i)->nChildren() ) {
+      unbind( (FGPropertyManager*)node->getChild(i) );
+    } else if( node->getChild(i)->isTied() ) {
+      node->getChild(i)->untie();
+    } 
+  }        
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
index a1a3a55c22b7accb0a40f79d4fd6466d9d34bd00..4af471e749f11849302e1be6c2a4d4e27454f76e 100644 (file)
@@ -613,7 +613,7 @@ public:
   
   void bind(void);
   void bindModel(void);
-  void unbind(void);
+  void unbind(FGPropertyManager *node);
   
 private:
   double DaCmd, DeCmd, DrCmd, DfCmd, DsbCmd, DspCmd;
index 20cacbe6720dcbbba00bed3cc596ca2bbd305ef7..75ee4615aee88a1c36eb1d8d8fe2e26e923db679 100644 (file)
@@ -87,6 +87,19 @@ FGPropertyManager* FGFDMExec::master=0;
 CLASS IMPLEMENTATION
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
+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) );
+    } else if( node->getChild(i)->isTied() ) {
+      name=((FGPropertyManager*)node->getChild(i))->GetFullyQualifiedName();
+      cerr << name << " is tied" << endl;
+    } 
+  }
+}        
+
 // Constructor
 
 FGFDMExec::FGFDMExec(FGPropertyManager* root)
@@ -132,7 +145,7 @@ FGFDMExec::FGFDMExec(FGPropertyManager* root)
   else            master = root;
 
   instance = master->GetNode("/fdm/jsbsim",IdFDM,true);
-  instance->SetDouble("zero",0);  
+
   
   Debug(0);
   
@@ -152,13 +165,14 @@ FGFDMExec::~FGFDMExec()
 {
   try {
     DeAllocate();
+    checkTied( instance );
   } catch ( string msg ) {
     cout << "Caught error: " << msg << endl;
   }    
-
+  
   for (unsigned int i=1; i<SlaveFDMList.size(); i++) delete SlaveFDMList[i]->exec;
   SlaveFDMList.clear();
+  
   Debug(1);
 }
 
@@ -281,7 +295,9 @@ bool FGFDMExec::DeAllocate(void) {
   
   delete IC;
   delete Trim;
-
+  
+  
+    
   FirstModel  = 0L;
   Error       = 0;
 
index 1253d6d2d03884684fd6bbfb1801a7305c02c753..2a33172ad2bf63423a85031ea5baf403031c3912 100644 (file)
@@ -102,6 +102,32 @@ string FGPropertyManager::GetName( void ) {
   return string( getName() );
 }  
 
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+string FGPropertyManager::GetFullyQualifiedName(void) {
+    vector<string> stack;
+    stack.push_back( getDisplayName(true) );
+    SGPropertyNode* tmpn=getParent();
+    bool atroot=false;
+    while( !atroot ) {
+     stack.push_back( tmpn->getDisplayName(true) );
+     if( !tmpn->getParent() ) 
+      atroot=true;
+     else 
+      tmpn=tmpn->getParent();
+    }
+    
+    string fqname="";
+    for(unsigned i=stack.size()-1;i>0;i--) {
+      fqname+= stack[i];
+      fqname+= "/";
+    }
+    fqname+= stack[0];
+    return fqname;  
+       
+}    
+    
+    
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 bool FGPropertyManager::GetBool (const string &name, bool defaultValue)
index 06eea8498e7679a16af0015e84ec91d34948bf0e..aefa5cb58f9a180e834b42d4326fa8a5396d8b86 100644 (file)
@@ -111,6 +111,12 @@ class FGPropertyManager : public SGPropertyNode {
      * Get the name of a node
      */
     string GetName( void );
+    
+    /**
+     * Get the fully qualified name of a node
+     * This function is very slow, so is probably useful for debugging only.
+     */
+    string GetFullyQualifiedName(void);
 
     /**
      * Get a bool value for a property.
index 9cdaf9e4ff391f5717c8085ab72c923be29ae91f..8f19d519366194601df895d8a0d3834b838328e9 100644 (file)
@@ -258,6 +258,7 @@ void FGTranslation::unbind(void)
   PropertyManager->Untie("velocities/mach-norm");
   PropertyManager->Untie("aero/alphadot-rad_sec");
   PropertyManager->Untie("aero/betadot-rad_sec");
+  PropertyManager->Untie("aero/mag-beta-rad");
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
index 0e152a82cd6434cafd18db10dd032cd859e7e8b5..ffaf8543e1eb46c7a2581117b2eeb2ee5b1112e5 100644 (file)
@@ -72,8 +72,7 @@ FGJSBsim::FGJSBsim( double dt )
 {
     bool result;
    
-    //fdmex = new FGFDMExec( (FGPropertyManager*)globals->get_props() );
-    fdmex = new FGFDMExec();
+    fdmex = new FGFDMExec( (FGPropertyManager*)globals->get_props() );
     
     State           = fdmex->GetState();
     Atmosphere      = fdmex->GetAtmosphere();
@@ -185,7 +184,7 @@ FGJSBsim::FGJSBsim( double dt )
 }
 /******************************************************************************/
 FGJSBsim::~FGJSBsim(void) {
-    delete fdmex;
+        delete fdmex;
 }
 
 /******************************************************************************/
index 4b0f4191dcf3c59c34a3fa0d612b580cd5a69d13..00d99177f9beda2d3fe9d6ca6723010a74709032 100644 (file)
@@ -66,7 +66,7 @@ FGDeadBand::FGDeadBand(FGFCS* fcs, FGConfigFile* AC_cfg) : FGFCSComponent(fcs),
       *AC_cfg >> token;
     }
   }
-  FGFCSComponent::bind( PropertyManager->GetNode("fcs/components",true) );
+  FGFCSComponent::bind();
   Debug(0);
 }
 
index 56b5ee83e59db80cda1aaf568ce349e336e696e4..14608d1215dccaf7f156e49a97bb570421f7ead0 100644 (file)
@@ -52,9 +52,10 @@ FGFCSComponent::FGFCSComponent(FGFCS* _fcs) : fcs(_fcs)
   ID         = 0;
   Input      = 0.0;
   Output     = 0.0;
-  OutputNode  = 0;
+  OutputNode = 0;
   IsOutput   = false;
   PropertyManager=fcs->GetPropertyManager();
+  treenode   = 0;
   Debug(0);
 }
 
@@ -62,7 +63,6 @@ FGFCSComponent::FGFCSComponent(FGFCS* _fcs) : fcs(_fcs)
 
 FGFCSComponent::~FGFCSComponent()
 {
-  unbind();
   Debug(1);
 }
 
@@ -97,34 +97,21 @@ FGPropertyManager* FGFCSComponent::resolveSymbol(string token) {
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-void FGFCSComponent::bind(FGPropertyManager *node) {
-  string tmp = "fcs/" + node->mkPropertyName(Name, true);
+void FGFCSComponent::bind(void) {
+  string tmp = "fcs/" + PropertyManager->mkPropertyName(Name, true);
   FGPropertyManager *tmpn;
   PropertyManager->Tie( tmp,this, &FGFCSComponent::GetOutput);
-  node = node->GetNode( node->mkPropertyName(Name, true), true );
+  tmp = "fcs/components/" + PropertyManager->mkPropertyName(Name, true);
+  treenode = PropertyManager->GetNode( tmp, true );
   for(unsigned i=0;i<InputNodes.size();i++) {
-    tmpn=node->GetNode( "input-property",(int)i,true );
+    tmpn=treenode->GetNode( "input-property",(int)i,true );
     tmpn->setStringValue( InputNodes[i]->GetName().c_str() );
   }  
-  if(OutputNode) node->SetString("output-property",OutputNode->GetName());
-  node->Tie("output-value",this,&FGFCSComponent::GetOutput);
-  node->SetString("type",Type);
+  if(OutputNode) treenode->SetString("output-property",OutputNode->GetName());
+  treenode->Tie("output-value",this,&FGFCSComponent::GetOutput);
+  treenode->SetString("type",Type);
 }  
 
-//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-void FGFCSComponent::unbind(void) { 
-  string name = "fcs";
-  FGPropertyManager *node=PropertyManager->GetNode(name);
-  name += "/" + PropertyManager->mkPropertyName(Name, true);
-  PropertyManager->Untie( name );
-  
-  name = "fcs/components/" 
-                 + PropertyManager->mkPropertyName(Name, true); 
-  node= PropertyManager->GetNode(name);
-  node->Untie("output-value");
-}
-                
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 //    The bitmasked value choices are as follows:
 //    unset: In this case (the default) JSBSim would only print
index 07c6a03a66f254fffb32870c99cd148fea7e5604..2e7f8e858183f59cb6b8a5170629a8c5fc06bdcf 100644 (file)
@@ -108,8 +108,7 @@ public:
   inline string GetType(void) const { return Type; }
   virtual double GetOutputPct(void) const { return 0; }
   
-  virtual void bind(FGPropertyManager *node);
-  virtual void unbind( void );
+  virtual void bind();
   FGPropertyManager* resolveSymbol(string token);
   
 protected:
@@ -117,6 +116,7 @@ protected:
   enum eInputType {itPilotAC, itFCS, itAP, itBias} InputType;
   FGFCS* fcs;
   FGPropertyManager* PropertyManager;
+  FGPropertyManager* treenode;
   string Type;
   string Name;
   int ID;
index 5ca2f7930de2ffc9858ce1083f5f85626161984f..15a685faa4e4baa3e288350413127eff69f5a1e4 100644 (file)
@@ -129,7 +129,7 @@ FGFilter::FGFilter(FGFCS* fcs, FGConfigFile* AC_cfg) : FGFCSComponent(fcs),
       cerr << "Unknown filter type" << endl;
     break;
   }
-  FGFCSComponent::bind( PropertyManager->GetNode("fcs/components",true) );
+  FGFCSComponent::bind();
 
   Debug(0);
 }
index 7c6f6f1daacb4940317621b00c056733d4605909..1bb99ba751a705d88057095bda92c67d5193dbe8 100644 (file)
@@ -37,7 +37,7 @@ COMMENTS, REFERENCES,  and NOTES
 INCLUDES
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-#include "FGGain.h"            
+#include "FGGain.h" 
 
 static const char *IdSrc = "$Id$";
 static const char *IdHdr = ID_GAIN;
@@ -107,7 +107,9 @@ FGGain::FGGain(FGFCS* fcs, FGConfigFile* AC_cfg) : FGFCSComponent(fcs),
     }
   }
   
-  FGFCSComponent::bind( PropertyManager->GetNode("fcs/components",true) );
+  FGFCSComponent::bind();
+  if (Type == "AEROSURFACE_SCALE")
+    treenode->Tie( "output-norm", this, &FGGain::GetOutputPct );
 
   Debug(0);
 }
index 48e2105fd353fffe9fc7315600dea0e4b1520fd8..592da07e72d63d37214c6e4cb2bfeeace0a8894d 100644 (file)
@@ -72,7 +72,7 @@ public:
   FGGain(FGFCS* fcs, FGConfigFile* AC_cfg);
   ~FGGain();
   
-  double GetOutputPct() { return OutputPct; }
+  double GetOutputPct() const { return OutputPct; }
   
   bool Run (void);
 
index 2f344bfe23d8b40d2b315cff725fb8001569a5e9..c1efab8dda4880cae8c90ba3767227b1556723cc 100644 (file)
@@ -53,7 +53,7 @@ FGGradient::FGGradient(FGFCS* fcs, FGConfigFile* AC_cfg) : FGFCSComponent(fcs),
   Type = AC_cfg->GetValue("TYPE");
   Name = AC_cfg->GetValue("NAME");
   
-  FGFCSComponent::bind( PropertyManager->GetNode("fcs/components",true) );
+  FGFCSComponent::bind();
 
   Debug(0);
 }
index 88701682527a022f41914e7eab8457c755501450..798f42c139b85ce271dcc3c90a638e7f7f833ee6 100644 (file)
@@ -91,7 +91,8 @@ FGKinemat::FGKinemat(FGFCS* fcs, FGConfigFile* AC_cfg) : FGFCSComponent(fcs),
       OutputNode = PropertyManager->GetNode(sOutputIdx);
     }
   }
-  FGFCSComponent::bind( PropertyManager->GetNode("fcs/components") );
+  FGFCSComponent::bind();
+  treenode->Tie("output-norm", this, &FGKinemat::GetOutputPct );
 
   Debug(0);
 }
index c4891b96faa8d75fadbd24198b781cfcf6aaa89b..56f612f464a1f705a458f133306943e6e6277b06 100644 (file)
@@ -71,7 +71,7 @@ public:
   FGKinemat(FGFCS* fcs, FGConfigFile* AC_cfg);
   ~FGKinemat();
   
-  double GetOutputPct() { return OutputPct; }
+  double GetOutputPct() const { return OutputPct; }
     
   bool Run (void );
   
index a8cf19ee2ff35b9e6d11ae9f195eef31e1dcd58d..2b367b5a20cab6cdb9537edb40a3c96551593351 100644 (file)
@@ -81,7 +81,7 @@ FGSummer::FGSummer(FGFCS* fcs, FGConfigFile* AC_cfg) : FGFCSComponent(fcs),
     }
   }
  
-  FGFCSComponent::bind( PropertyManager->GetNode("fcs/components",true) );
+  FGFCSComponent::bind();
 
   Debug(0);
 }
index 33e4594257ef9ab94bbad6ffc1cf4a3484db132b..c2521bf3a0b175b95a47e6e2547d9ddbfb297c63 100644 (file)
@@ -53,7 +53,7 @@ FGSwitch::FGSwitch(FGFCS* fcs, FGConfigFile* AC_cfg) : FGFCSComponent(fcs),
   Type = AC_cfg->GetValue("TYPE");
   Name = AC_cfg->GetValue("NAME");
 
-  FGFCSComponent::bind( PropertyManager->GetNode("fcs/components",true) );
+  FGFCSComponent::bind();
 
   Debug(0);
 }