diff --git a/src/FDM/JSBSim/FGAerodynamics.cpp b/src/FDM/JSBSim/FGAerodynamics.cpp index 666dca618..2239c1502 100644 --- a/src/FDM/JSBSim/FGAerodynamics.cpp +++ b/src/FDM/JSBSim/FGAerodynamics.cpp @@ -37,6 +37,8 @@ INCLUDES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ #include "FGAerodynamics.h" +#include "FGFactorGroup.h" +#include "FGCoefficient.h" static const char *IdSrc = "$Id$"; static const char *IdHdr = ID_AERODYNAMICS; @@ -143,8 +145,13 @@ bool FGAerodynamics::Load(FGConfigFile* AC_cfg) axis = AC_cfg->GetValue("NAME"); AC_cfg->GetNextConfigLine(); while ((token = AC_cfg->GetValue()) != "/AXIS") { - ca.push_back(new FGCoefficient(FDMExec, AC_cfg)); - if (debug_lvl > 0) DisplayCoeffFactors(ca.back()->Getmultipliers()); + if( token == "COEFFICIENT" ) { + ca.push_back( new FGCoefficient(FDMExec) ); + ca.back()->Load(AC_cfg); + } else if ( token == "GROUP" ) { + ca.push_back( new FGFactorGroup(FDMExec) ); + ca.back()->Load(AC_cfg); + } } Coeff[AxisIdx[axis]] = ca; AC_cfg->GetNextConfigLine(); @@ -156,19 +163,6 @@ bool FGAerodynamics::Load(FGConfigFile* AC_cfg) //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -void FGAerodynamics::DisplayCoeffFactors(vector multipliers) -{ - unsigned int i; - - cout << " Non-Dimensionalized by: "; - - for (i=0; iparamdef[multipliers[i]]; - - cout << endl; -} - -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - string FGAerodynamics::GetCoefficientStrings(void) { string CoeffStrings = ""; @@ -182,7 +176,7 @@ string FGAerodynamics::GetCoefficientStrings(void) } else { CoeffStrings += ", "; } - CoeffStrings += Coeff[axis][sd]->Getname(); + CoeffStrings += Coeff[axis][sd]->GetCoefficientStrings(); } } return CoeffStrings; @@ -203,8 +197,7 @@ string FGAerodynamics::GetCoefficientValues(void) } else { SDValues += ", "; } - sprintf(buffer, "%9.6f", Coeff[axis][sd]->GetSD()); - SDValues += string(buffer); + SDValues += Coeff[axis][sd]->GetCoefficientValues(); } } diff --git a/src/FDM/JSBSim/FGAerodynamics.h b/src/FDM/JSBSim/FGAerodynamics.h index 817e01453..65cffbd7a 100644 --- a/src/FDM/JSBSim/FGAerodynamics.h +++ b/src/FDM/JSBSim/FGAerodynamics.h @@ -58,6 +58,7 @@ INCLUDES #include "FGMassBalance.h" #include "FGTranslation.h" #include "FGCoefficient.h" +#include "FGFactorGroup.h" /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DEFINITIONS @@ -65,6 +66,7 @@ DEFINITIONS #define ID_AERODYNAMICS "$Id$" + /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FORWARD DECLARATIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ @@ -107,12 +109,6 @@ public: @return true if successful */ bool Load(FGConfigFile* AC_cfg); - /** Outputs coefficient information. - Non-dimensionalizing parameter descriptions are output - for each aero coefficient defined. - @param multipliers the list of multipliers for this coefficient.*/ - void DisplayCoeffFactors(vector multipliers); - /** Gets the total aerodynamic force vector. @return a force vector reference. */ FGColumnVector& GetForces(void) {return vForces;} diff --git a/src/FDM/JSBSim/FGAircraft.h b/src/FDM/JSBSim/FGAircraft.h index 213fef773..48bfbdc18 100644 --- a/src/FDM/JSBSim/FGAircraft.h +++ b/src/FDM/JSBSim/FGAircraft.h @@ -162,15 +162,15 @@ public: inline float GetAlphaCLMax(void) { return alphaclmax; } inline float GetAlphaCLMin(void) { return alphaclmin; } - inline void SetGearUp(bool tt) { GearUp = tt; } + inline void SetGear(bool tt) { GearUp = tt; } + inline void SetGearUp(void) { GearUp = true; } + inline void SetGearDown(bool tt) { GearUp = false; } inline void SetAlphaCLMax(float tt) { alphaclmax=tt; } inline void SetAlphaCLMin(float tt) { alphaclmin=tt; } string GetGroundReactionStrings(void); string GetGroundReactionValues(void); - float GetLoD(void); - /// Subsystem types for specifying which will be output in the FDM data logging enum SubSystems { /** Subsystem: Simulation (= 1) */ ssSimulation = 1, diff --git a/src/FDM/JSBSim/FGCoefficient.cpp b/src/FDM/JSBSim/FGCoefficient.cpp index b8ec8528f..e1c0dc5b7 100644 --- a/src/FDM/JSBSim/FGCoefficient.cpp +++ b/src/FDM/JSBSim/FGCoefficient.cpp @@ -75,22 +75,35 @@ extern short debug_lvl; CLASS IMPLEMENTATION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ -FGCoefficient::FGCoefficient(FGFDMExec* fdex, FGConfigFile* AC_cfg) +FGCoefficient::FGCoefficient( FGFDMExec* fdex ) { - int start, end, n; - string multparms; FDMExec = fdex; State = FDMExec->GetState(); Table = 0; + if (debug_lvl & 2) cout << "Instantiated: FGCoefficient" << endl; +} + +//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +FGCoefficient::~FGCoefficient() +{ + if (Table) delete Table; + if (debug_lvl & 2) cout << "Destroyed: FGCoefficient" << endl; +} + +//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +bool FGCoefficient::Load(FGConfigFile *AC_cfg) { + int start, end, n; + string multparms, mult; + if (AC_cfg) { name = AC_cfg->GetValue("NAME"); method = AC_cfg->GetValue("TYPE"); - AC_cfg->GetNextConfigLine(); *AC_cfg >> description; - if (debug_lvl > 0) { cout << "\n " << highint << underon << name << underoff << normint << endl; cout << " " << description << endl; @@ -137,17 +150,18 @@ FGCoefficient::FGCoefficient(FGFDMExec* fdex, FGConfigFile* AC_cfg) n = multparms.find("|"); start = 0; - while (n < end && n >= 0) { - n -= start; + if(multparms != "FG_NONE") { + while (n < end && n >= 0) { + n -= start; + mult = multparms.substr(start,n); + multipliers.push_back( State->GetParameterIndex(mult) ); + start += n+1; + n = multparms.find("|",start); + } multipliers.push_back(State->GetParameterIndex(multparms.substr(start,n))); - start += n+1; - n = multparms.find("|",start); + // End of non-dimensionalizing parameter read-in } - multipliers.push_back(State->GetParameterIndex(multparms.substr(start,n))); - - // End of non-dimensionalizing parameter read-in - switch(type) { case VALUE: *AC_cfg >> StaticValue; @@ -164,17 +178,14 @@ FGCoefficient::FGCoefficient(FGFDMExec* fdex, FGConfigFile* AC_cfg) break; } AC_cfg->GetNextConfigLine(); - } - if (debug_lvl & 2) cout << "Instantiated: FGCoefficient" << endl; + if (debug_lvl > 0) DisplayCoeffFactors(); + return true; + } else { + return false; + } } -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -FGCoefficient::~FGCoefficient() -{ - if (Table) delete Table; - if (debug_lvl & 2) cout << "Destroyed: FGCoefficient" << endl; -} //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -253,3 +264,32 @@ void FGCoefficient::Debug(void) //TODO: Add your source code here } +//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +void FGCoefficient::DisplayCoeffFactors(void) +{ + unsigned int i; + + cout << " Non-Dimensionalized by: "; + + if( multipliers.size() == 0) { + cout << "none" << endl; + } else { + for (i=0; iGetState()->paramdef[multipliers[i]]; + } + cout << endl; +} + +//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +string FGCoefficient::GetCoefficientValues(void) { + char buffer[10]; + string value; + //value = ", "; + snprintf(buffer,10,"%9.6f",SD); + value += string(buffer); + return value; +} + +//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/src/FDM/JSBSim/FGCoefficient.h b/src/FDM/JSBSim/FGCoefficient.h index ce236f131..e279f6b17 100644 --- a/src/FDM/JSBSim/FGCoefficient.h +++ b/src/FDM/JSBSim/FGCoefficient.h @@ -98,16 +98,25 @@ CLASS DECLARATION class FGCoefficient { public: - FGCoefficient(FGFDMExec*, FGConfigFile*); + FGCoefficient(FGFDMExec*); ~FGCoefficient(); - + + virtual bool Load(FGConfigFile* AC_cfg); + typedef vector MultVec; - float TotalValue(void); - inline string Getname(void) {return name;} - inline float GetSD(void) {return SD;} + virtual float TotalValue(void); + virtual inline string Getname(void) {return name;} + virtual inline float GetSD(void) { return SD;} inline MultVec Getmultipliers(void) {return multipliers;} - void DumpSD(void); - + void DumpSD(void); + + /** Outputs coefficient information. + Non-dimensionalizing parameter descriptions are output + for each aero coefficient defined. + @param multipliers the list of multipliers for this coefficient.*/ + virtual void DisplayCoeffFactors(void); + virtual inline string GetCoefficientStrings(void) { return name; } + virtual string GetCoefficientValues(void); private: enum Type {UNKNOWN, VALUE, VECTOR, TABLE, EQUATION}; diff --git a/src/FDM/JSBSim/FGPosition.cpp b/src/FDM/JSBSim/FGPosition.cpp index 078f495b8..29576930a 100644 --- a/src/FDM/JSBSim/FGPosition.cpp +++ b/src/FDM/JSBSim/FGPosition.cpp @@ -108,6 +108,8 @@ FGPosition::FGPosition(FGFDMExec* fdmex) : FGModel(fdmex), RunwayRadius = SeaLevelRadius; DistanceAGL = Radius - RunwayRadius; // Geocentric vRunwayNormal(3) = -1.0; // Initialized for standalone mode + b =1; + if (debug_lvl & 2) cout << "Instantiated: " << Name << endl; } @@ -157,7 +159,7 @@ bool FGPosition:: Run(void) { h = Radius - SeaLevelRadius; // Geocentric DistanceAGL = Radius - RunwayRadius; // Geocentric - + hoverb = DistanceAGL/b; if (Vt > 0) { @@ -186,7 +188,7 @@ void FGPosition::GetState(void) { Vt = Translation->GetVt(); vVel = State->GetTb2l() * Translation->GetUVW(); vVelDot = State->GetTb2l() * Translation->GetUVWdot(); - + b = Aircraft->GetWingSpan(); } @@ -196,6 +198,7 @@ void FGPosition::Seth(double tt) { h = tt; Radius = h + SeaLevelRadius; DistanceAGL = Radius - RunwayRadius; // Geocentric + hoverb = DistanceAGL/b; } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -204,6 +207,7 @@ void FGPosition::SetDistanceAGL(double tt) { DistanceAGL=tt; Radius = RunwayRadius + DistanceAGL; h = Radius - SeaLevelRadius; + hoverb = DistanceAGL/b; } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/src/FDM/JSBSim/FGPosition.h b/src/FDM/JSBSim/FGPosition.h index 97d57d610..ca93d258a 100644 --- a/src/FDM/JSBSim/FGPosition.h +++ b/src/FDM/JSBSim/FGPosition.h @@ -129,7 +129,7 @@ private: double SeaLevelRadius; double gamma; double Vt, Vground; - double hoverb,b; + float hoverb,b; double psigt; diff --git a/src/FDM/JSBSim/Makefile.am b/src/FDM/JSBSim/Makefile.am index 24c8783b4..6f547a3b3 100644 --- a/src/FDM/JSBSim/Makefile.am +++ b/src/FDM/JSBSim/Makefile.am @@ -21,6 +21,7 @@ libJSBSim_a_SOURCES = \ FGDefs.h \ FGFCS.cpp FGFCS.h \ FGFDMExec.cpp FGFDMExec.h \ + FGFactorGroup.cpp FGFactorGroup.h \ FGForce.cpp FGForce.h \ FGInertial.cpp FGInertial.h \ FGInitialCondition.cpp FGInitialCondition.h \