From: tony Date: Sun, 29 Sep 2002 13:33:53 +0000 (+0000) Subject: Latest JSBSim updates -- includes fix for control surface animations. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=eb05a298e9a9a830b23b6337d812dafa48d39bba;p=flightgear.git Latest JSBSim updates -- includes fix for control surface animations. --- diff --git a/src/FDM/JSBSim/FGAerodynamics.cpp b/src/FDM/JSBSim/FGAerodynamics.cpp index 16bd979fb..eaeaa194d 100644 --- a/src/FDM/JSBSim/FGAerodynamics.cpp +++ b/src/FDM/JSBSim/FGAerodynamics.cpp @@ -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; iGetNode("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;iGetType() == "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;igetChild(i)->nChildren() ) { + unbind( (FGPropertyManager*)node->getChild(i) ); + } else if( node->getChild(i)->isTied() ) { + node->getChild(i)->untie(); + } + } } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/src/FDM/JSBSim/FGFCS.h b/src/FDM/JSBSim/FGFCS.h index a1a3a55c2..4af471e74 100644 --- a/src/FDM/JSBSim/FGFCS.h +++ b/src/FDM/JSBSim/FGFCS.h @@ -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; diff --git a/src/FDM/JSBSim/FGFDMExec.cpp b/src/FDM/JSBSim/FGFDMExec.cpp index 20cacbe67..75ee4615a 100644 --- a/src/FDM/JSBSim/FGFDMExec.cpp +++ b/src/FDM/JSBSim/FGFDMExec.cpp @@ -87,6 +87,19 @@ FGPropertyManager* FGFDMExec::master=0; CLASS IMPLEMENTATION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ +void checkTied( FGPropertyManager *node ) { + int N = node->nChildren(); + string name; + for(int i=0;igetChild(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; iexec; SlaveFDMList.clear(); - + Debug(1); } @@ -281,7 +295,9 @@ bool FGFDMExec::DeAllocate(void) { delete IC; delete Trim; - + + + FirstModel = 0L; Error = 0; diff --git a/src/FDM/JSBSim/FGPropertyManager.cpp b/src/FDM/JSBSim/FGPropertyManager.cpp index 1253d6d2d..2a33172ad 100644 --- a/src/FDM/JSBSim/FGPropertyManager.cpp +++ b/src/FDM/JSBSim/FGPropertyManager.cpp @@ -102,6 +102,32 @@ string FGPropertyManager::GetName( void ) { return string( getName() ); } +//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +string FGPropertyManager::GetFullyQualifiedName(void) { + vector 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) diff --git a/src/FDM/JSBSim/FGPropertyManager.h b/src/FDM/JSBSim/FGPropertyManager.h index 06eea8498..aefa5cb58 100644 --- a/src/FDM/JSBSim/FGPropertyManager.h +++ b/src/FDM/JSBSim/FGPropertyManager.h @@ -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. diff --git a/src/FDM/JSBSim/FGTranslation.cpp b/src/FDM/JSBSim/FGTranslation.cpp index 9cdaf9e4f..8f19d5193 100644 --- a/src/FDM/JSBSim/FGTranslation.cpp +++ b/src/FDM/JSBSim/FGTranslation.cpp @@ -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"); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/src/FDM/JSBSim/JSBSim.cxx b/src/FDM/JSBSim/JSBSim.cxx index 0e152a82c..ffaf8543e 100644 --- a/src/FDM/JSBSim/JSBSim.cxx +++ b/src/FDM/JSBSim/JSBSim.cxx @@ -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; } /******************************************************************************/ diff --git a/src/FDM/JSBSim/filtersjb/FGDeadBand.cpp b/src/FDM/JSBSim/filtersjb/FGDeadBand.cpp index 4b0f4191d..00d99177f 100644 --- a/src/FDM/JSBSim/filtersjb/FGDeadBand.cpp +++ b/src/FDM/JSBSim/filtersjb/FGDeadBand.cpp @@ -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); } diff --git a/src/FDM/JSBSim/filtersjb/FGFCSComponent.cpp b/src/FDM/JSBSim/filtersjb/FGFCSComponent.cpp index 56b5ee83e..14608d121 100644 --- a/src/FDM/JSBSim/filtersjb/FGFCSComponent.cpp +++ b/src/FDM/JSBSim/filtersjb/FGFCSComponent.cpp @@ -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;iGetNode( "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 diff --git a/src/FDM/JSBSim/filtersjb/FGFCSComponent.h b/src/FDM/JSBSim/filtersjb/FGFCSComponent.h index 07c6a03a6..2e7f8e858 100644 --- a/src/FDM/JSBSim/filtersjb/FGFCSComponent.h +++ b/src/FDM/JSBSim/filtersjb/FGFCSComponent.h @@ -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; diff --git a/src/FDM/JSBSim/filtersjb/FGFilter.cpp b/src/FDM/JSBSim/filtersjb/FGFilter.cpp index 5ca2f7930..15a685faa 100644 --- a/src/FDM/JSBSim/filtersjb/FGFilter.cpp +++ b/src/FDM/JSBSim/filtersjb/FGFilter.cpp @@ -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); } diff --git a/src/FDM/JSBSim/filtersjb/FGGain.cpp b/src/FDM/JSBSim/filtersjb/FGGain.cpp index 7c6f6f1da..1bb99ba75 100644 --- a/src/FDM/JSBSim/filtersjb/FGGain.cpp +++ b/src/FDM/JSBSim/filtersjb/FGGain.cpp @@ -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); } diff --git a/src/FDM/JSBSim/filtersjb/FGGain.h b/src/FDM/JSBSim/filtersjb/FGGain.h index 48e2105fd..592da07e7 100644 --- a/src/FDM/JSBSim/filtersjb/FGGain.h +++ b/src/FDM/JSBSim/filtersjb/FGGain.h @@ -72,7 +72,7 @@ public: FGGain(FGFCS* fcs, FGConfigFile* AC_cfg); ~FGGain(); - double GetOutputPct() { return OutputPct; } + double GetOutputPct() const { return OutputPct; } bool Run (void); diff --git a/src/FDM/JSBSim/filtersjb/FGGradient.cpp b/src/FDM/JSBSim/filtersjb/FGGradient.cpp index 2f344bfe2..c1efab8dd 100644 --- a/src/FDM/JSBSim/filtersjb/FGGradient.cpp +++ b/src/FDM/JSBSim/filtersjb/FGGradient.cpp @@ -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); } diff --git a/src/FDM/JSBSim/filtersjb/FGKinemat.cpp b/src/FDM/JSBSim/filtersjb/FGKinemat.cpp index 887016825..798f42c13 100644 --- a/src/FDM/JSBSim/filtersjb/FGKinemat.cpp +++ b/src/FDM/JSBSim/filtersjb/FGKinemat.cpp @@ -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); } diff --git a/src/FDM/JSBSim/filtersjb/FGKinemat.h b/src/FDM/JSBSim/filtersjb/FGKinemat.h index c4891b96f..56f612f46 100644 --- a/src/FDM/JSBSim/filtersjb/FGKinemat.h +++ b/src/FDM/JSBSim/filtersjb/FGKinemat.h @@ -71,7 +71,7 @@ public: FGKinemat(FGFCS* fcs, FGConfigFile* AC_cfg); ~FGKinemat(); - double GetOutputPct() { return OutputPct; } + double GetOutputPct() const { return OutputPct; } bool Run (void ); diff --git a/src/FDM/JSBSim/filtersjb/FGSummer.cpp b/src/FDM/JSBSim/filtersjb/FGSummer.cpp index a8cf19ee2..2b367b5a2 100644 --- a/src/FDM/JSBSim/filtersjb/FGSummer.cpp +++ b/src/FDM/JSBSim/filtersjb/FGSummer.cpp @@ -81,7 +81,7 @@ FGSummer::FGSummer(FGFCS* fcs, FGConfigFile* AC_cfg) : FGFCSComponent(fcs), } } - FGFCSComponent::bind( PropertyManager->GetNode("fcs/components",true) ); + FGFCSComponent::bind(); Debug(0); } diff --git a/src/FDM/JSBSim/filtersjb/FGSwitch.cpp b/src/FDM/JSBSim/filtersjb/FGSwitch.cpp index 33e459425..c2521bf3a 100644 --- a/src/FDM/JSBSim/filtersjb/FGSwitch.cpp +++ b/src/FDM/JSBSim/filtersjb/FGSwitch.cpp @@ -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); }