1
0
Fork 0

Latest JSBSim updates -- includes fix for control surface animations.

This commit is contained in:
tony 2002-09-29 13:33:53 +00:00
parent 2c1889a8b5
commit eb05a298e9
20 changed files with 99 additions and 95 deletions

View 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++ ) {

View file

@ -83,6 +83,7 @@ FGAuxiliary::FGAuxiliary(FGFDMExec* fdmex) : FGModel(fdmex)
FGAuxiliary::~FGAuxiliary()
{
unbind();
Debug(1);
}

View 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();
}
}
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

View 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;

View 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;

View 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)

View 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.

View 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");
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

View 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;
}
/******************************************************************************/

View 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);
}

View 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

View 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;

View 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);
}

View 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);
}

View 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);

View 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);
}

View 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);
}

View 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 );

View 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);
}

View 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);
}