From 5c3f4e999db5cc882f6f47630084ff00b53a4516 Mon Sep 17 00:00:00 2001 From: david Date: Thu, 13 Dec 2001 04:48:34 +0000 Subject: [PATCH] Latest JSBSim changes. --- src/FDM/JSBSim/FGAerodynamics.cpp | 2 +- src/FDM/JSBSim/FGAerodynamics.h | 2 +- src/FDM/JSBSim/FGAircraft.cpp | 2 +- src/FDM/JSBSim/FGAircraft.h | 2 +- src/FDM/JSBSim/FGAtmosphere.cpp | 61 +++- src/FDM/JSBSim/FGAtmosphere.h | 2 +- src/FDM/JSBSim/FGAuxiliary.cpp | 2 +- src/FDM/JSBSim/FGAuxiliary.h | 2 +- src/FDM/JSBSim/FGCoefficient.cpp | 117 ++++--- src/FDM/JSBSim/FGCoefficient.h | 5 +- src/FDM/JSBSim/FGColumnVector3.cpp | 2 +- src/FDM/JSBSim/FGColumnVector3.h | 2 +- src/FDM/JSBSim/FGColumnVector4.cpp | 2 +- src/FDM/JSBSim/FGColumnVector4.h | 2 +- src/FDM/JSBSim/FGConfigFile.cpp | 41 ++- src/FDM/JSBSim/FGConfigFile.h | 2 +- src/FDM/JSBSim/FGEngine.cpp | 44 ++- src/FDM/JSBSim/FGEngine.h | 2 +- src/FDM/JSBSim/FGFCS.cpp | 49 ++- src/FDM/JSBSim/FGFCS.h | 2 +- src/FDM/JSBSim/FGFDMExec.cpp | 219 ++++++------ src/FDM/JSBSim/FGFDMExec.h | 2 +- src/FDM/JSBSim/FGFactorGroup.cpp | 89 +++-- src/FDM/JSBSim/FGFactorGroup.h | 2 +- src/FDM/JSBSim/FGForce.cpp | 43 ++- src/FDM/JSBSim/FGForce.h | 4 +- src/FDM/JSBSim/FGGroundReactions.cpp | 47 ++- src/FDM/JSBSim/FGGroundReactions.h | 4 +- src/FDM/JSBSim/FGInertial.cpp | 43 ++- src/FDM/JSBSim/FGInertial.h | 2 +- src/FDM/JSBSim/FGInitialCondition.cpp | 2 + src/FDM/JSBSim/FGJSBBase.h | 2 +- src/FDM/JSBSim/FGLGear.cpp | 78 +++-- src/FDM/JSBSim/FGLGear.h | 3 +- src/FDM/JSBSim/FGMassBalance.cpp | 58 +++- src/FDM/JSBSim/FGMassBalance.h | 2 +- src/FDM/JSBSim/FGMatrix33.cpp | 49 ++- src/FDM/JSBSim/FGMatrix33.h | 2 +- src/FDM/JSBSim/FGNozzle.cpp | 55 ++- src/FDM/JSBSim/FGNozzle.h | 2 +- src/FDM/JSBSim/FGOutput.cpp | 47 ++- src/FDM/JSBSim/FGOutput.h | 2 +- src/FDM/JSBSim/FGPiston.cpp | 117 ++++--- src/FDM/JSBSim/FGPiston.h | 2 +- src/FDM/JSBSim/FGPosition.cpp | 45 ++- src/FDM/JSBSim/FGPosition.h | 2 +- src/FDM/JSBSim/FGPropeller.cpp | 79 ++++- src/FDM/JSBSim/FGPropeller.h | 351 ++++++++++---------- src/FDM/JSBSim/FGPropulsion.cpp | 68 +++- src/FDM/JSBSim/FGPropulsion.h | 2 +- src/FDM/JSBSim/FGRocket.cpp | 63 +++- src/FDM/JSBSim/FGRocket.h | 2 +- src/FDM/JSBSim/FGRotation.cpp | 57 +++- src/FDM/JSBSim/FGRotation.h | 2 +- src/FDM/JSBSim/FGRotor.cpp | 44 ++- src/FDM/JSBSim/FGRotor.h | 2 +- src/FDM/JSBSim/FGState.cpp | 43 ++- src/FDM/JSBSim/FGState.h | 2 +- src/FDM/JSBSim/FGTable.cpp | 53 ++- src/FDM/JSBSim/FGTable.h | 2 +- src/FDM/JSBSim/FGTank.cpp | 56 +++- src/FDM/JSBSim/FGTank.h | 3 +- src/FDM/JSBSim/FGThruster.cpp | 43 ++- src/FDM/JSBSim/FGThruster.h | 2 +- src/FDM/JSBSim/FGTranslation.cpp | 47 ++- src/FDM/JSBSim/FGTranslation.h | 2 +- src/FDM/JSBSim/FGTrimAxis.cpp | 44 ++- src/FDM/JSBSim/FGTrimAxis.h | 2 +- src/FDM/JSBSim/FGTurboJet.cpp | 43 ++- src/FDM/JSBSim/FGTurboJet.h | 2 +- src/FDM/JSBSim/FGTurboProp.cpp | 43 ++- src/FDM/JSBSim/FGTurboProp.h | 2 +- src/FDM/JSBSim/FGTurboShaft.cpp | 44 ++- src/FDM/JSBSim/FGTurboShaft.h | 2 +- src/FDM/JSBSim/FGUtility.cpp | 43 ++- src/FDM/JSBSim/FGUtility.h | 2 +- src/FDM/JSBSim/FGfdmSocket.h | 1 + src/FDM/JSBSim/JSBSim.cpp | 11 +- src/FDM/JSBSim/filtersjb/FGDeadBand.cpp | 43 ++- src/FDM/JSBSim/filtersjb/FGDeadBand.h | 2 +- src/FDM/JSBSim/filtersjb/FGFCSComponent.cpp | 41 ++- src/FDM/JSBSim/filtersjb/FGFCSComponent.h | 2 +- src/FDM/JSBSim/filtersjb/FGFilter.cpp | 63 +++- src/FDM/JSBSim/filtersjb/FGFilter.h | 2 +- src/FDM/JSBSim/filtersjb/FGGain.cpp | 66 ++-- src/FDM/JSBSim/filtersjb/FGGain.h | 2 +- src/FDM/JSBSim/filtersjb/FGGradient.cpp | 43 ++- src/FDM/JSBSim/filtersjb/FGGradient.h | 2 +- src/FDM/JSBSim/filtersjb/FGKinemat.cpp | 73 ++-- src/FDM/JSBSim/filtersjb/FGKinemat.h | 2 +- src/FDM/JSBSim/filtersjb/FGSummer.cpp | 61 +++- src/FDM/JSBSim/filtersjb/FGSummer.h | 2 +- src/FDM/JSBSim/filtersjb/FGSwitch.cpp | 43 ++- src/FDM/JSBSim/filtersjb/FGSwitch.h | 2 +- 94 files changed, 2091 insertions(+), 788 deletions(-) diff --git a/src/FDM/JSBSim/FGAerodynamics.cpp b/src/FDM/JSBSim/FGAerodynamics.cpp index 10e0b18ba..ac33907bd 100644 --- a/src/FDM/JSBSim/FGAerodynamics.cpp +++ b/src/FDM/JSBSim/FGAerodynamics.cpp @@ -203,7 +203,7 @@ double FGAerodynamics::GetLoD(void) //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -void FGAerodynamics::Debug(void) +void FGAerodynamics::Debug(int from) { //TODO: Add your source code here } diff --git a/src/FDM/JSBSim/FGAerodynamics.h b/src/FDM/JSBSim/FGAerodynamics.h index 21b4230eb..d70f8145e 100644 --- a/src/FDM/JSBSim/FGAerodynamics.h +++ b/src/FDM/JSBSim/FGAerodynamics.h @@ -146,7 +146,7 @@ private: FGColumnVector3 vLastFs; FGColumnVector3 vDXYZcg; - void Debug(void); + void Debug(int from); }; //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/src/FDM/JSBSim/FGAircraft.cpp b/src/FDM/JSBSim/FGAircraft.cpp index 52c8ef5ab..ac3f48459 100644 --- a/src/FDM/JSBSim/FGAircraft.cpp +++ b/src/FDM/JSBSim/FGAircraft.cpp @@ -377,7 +377,7 @@ bool FGAircraft::ReadOutput(FGConfigFile* AC_cfg) //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -void FGAircraft::Debug(void) +void FGAircraft::Debug(int from) { //TODO: Add your source code here } diff --git a/src/FDM/JSBSim/FGAircraft.h b/src/FDM/JSBSim/FGAircraft.h index 8dc7beb7c..3346de06d 100644 --- a/src/FDM/JSBSim/FGAircraft.h +++ b/src/FDM/JSBSim/FGAircraft.h @@ -232,7 +232,7 @@ private: bool ReadUndercarriage(FGConfigFile*); bool ReadPrologue(FGConfigFile*); bool ReadOutput(FGConfigFile*); - void Debug(void); + void Debug(int from); }; //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/src/FDM/JSBSim/FGAtmosphere.cpp b/src/FDM/JSBSim/FGAtmosphere.cpp index 318516a5f..2f9f24066 100644 --- a/src/FDM/JSBSim/FGAtmosphere.cpp +++ b/src/FDM/JSBSim/FGAtmosphere.cpp @@ -87,14 +87,14 @@ FGAtmosphere::FGAtmosphere(FGFDMExec* fdmex) : FGModel(fdmex) // turbType = ttBerndt; // temporarily disable turbulence until fully tested TurbGain = 100.0; - if (debug_lvl & 2) cout << "Instantiated: " << Name << endl; + Debug(0); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FGAtmosphere::~FGAtmosphere() { - if (debug_lvl & 2) cout << "Destroyed: FGAtmosphere" << endl; + Debug(1); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -145,7 +145,7 @@ bool FGAtmosphere::Run(void) State->Seta(soundspeed); - if (debug_lvl > 1) Debug(); + Debug(2); } else { // skip Run() execution this time } @@ -291,17 +291,52 @@ void FGAtmosphere::Turbulence(void) } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -void FGAtmosphere::Debug(void) +// The bitmasked value choices are as follows: +// unset: In this case (the default) JSBSim would only print +// out the normally expected messages, essentially echoing +// the config files as they are read. If the environment +// variable is not set, debug_lvl is set to 1 internally +// 0: This requests JSBSim not to output any messages +// whatsoever. +// 1: This value explicity requests the normal JSBSim +// startup messages +// 2: This value asks for a message to be printed out when +// a class is instantiated +// 4: When this value is set, a message is displayed when a +// FGModel object executes its Run() method +// 8: When this value is set, various runtime state variables +// are printed out periodically +// 16: When set various parameters are sanity checked and +// a message is printed out when they go out of bounds + +void FGAtmosphere::Debug(int from) { - if (frame == 0) { - cout << "vTurbulence(X), vTurbulence(Y), vTurbulence(Z), " - << "vTurbulenceGrad(X), vTurbulenceGrad(Y), vTurbulenceGrad(Z), " - << "vDirection(X), vDirection(Y), vDirection(Z), " - << "Magnitude, " - << "vTurbPQR(P), vTurbPQR(Q), vTurbPQR(R), " << endl; - } else { - cout << vTurbulence << ", " << vTurbulenceGrad << ", " << vDirection << ", " << Magnitude << ", " << vTurbPQR << endl; + if (debug_lvl <= 0) return; + + if (debug_lvl & 1) { // Standard console startup message output + if (from == 0) { // Constructor + } + } + if (debug_lvl & 2 ) { // Instantiation/Destruction notification + if (from == 0) cout << "Instantiated: FGAtmosphere" << endl; + if (from == 1) cout << "Destroyed: FGAtmosphere" << endl; + } + if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects + } + if (debug_lvl & 8 ) { // Runtime state variables + } + if (debug_lvl & 16) { // Sanity checking + } + if (debug_lvl & 32) { // Turbulence + if (frame == 0 && from == 2) { + cout << "vTurbulence(X), vTurbulence(Y), vTurbulence(Z), " + << "vTurbulenceGrad(X), vTurbulenceGrad(Y), vTurbulenceGrad(Z), " + << "vDirection(X), vDirection(Y), vDirection(Z), " + << "Magnitude, " + << "vTurbPQR(P), vTurbPQR(Q), vTurbPQR(R), " << endl; + } else if (from == 2) { + cout << vTurbulence << ", " << vTurbulenceGrad << ", " << vDirection << ", " << Magnitude << ", " << vTurbPQR << endl; + } } } diff --git a/src/FDM/JSBSim/FGAtmosphere.h b/src/FDM/JSBSim/FGAtmosphere.h index 5b1e8648c..f88031280 100644 --- a/src/FDM/JSBSim/FGAtmosphere.h +++ b/src/FDM/JSBSim/FGAtmosphere.h @@ -176,7 +176,7 @@ private: void Calculate(double altitude); void Turbulence(void); - void Debug(void); + void Debug(int from); }; /******************************************************************************/ diff --git a/src/FDM/JSBSim/FGAuxiliary.cpp b/src/FDM/JSBSim/FGAuxiliary.cpp index 65c9fd755..4657cb34c 100644 --- a/src/FDM/JSBSim/FGAuxiliary.cpp +++ b/src/FDM/JSBSim/FGAuxiliary.cpp @@ -213,7 +213,7 @@ void FGAuxiliary::GetState(void) //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -void FGAuxiliary::Debug(void) +void FGAuxiliary::Debug(int from) { //TODO: Add your source code here } diff --git a/src/FDM/JSBSim/FGAuxiliary.h b/src/FDM/JSBSim/FGAuxiliary.h index a29ae2303..e0b8a575a 100644 --- a/src/FDM/JSBSim/FGAuxiliary.h +++ b/src/FDM/JSBSim/FGAuxiliary.h @@ -119,7 +119,7 @@ private: double earthPosAngle; void GetState(void); - void Debug(void); + void Debug(int from); }; //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/src/FDM/JSBSim/FGCoefficient.cpp b/src/FDM/JSBSim/FGCoefficient.cpp index 927084f82..c7c2d06e2 100644 --- a/src/FDM/JSBSim/FGCoefficient.cpp +++ b/src/FDM/JSBSim/FGCoefficient.cpp @@ -85,20 +85,16 @@ FGCoefficient::~FGCoefficient() //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -bool FGCoefficient::Load(FGConfigFile *AC_cfg) { +bool FGCoefficient::Load(FGConfigFile *AC_cfg) +{ int start, end, n; - string multparms, mult; + string 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; - cout << " " << method << endl; - } if (method == "EQUATION") type = EQUATION; else if (method == "TABLE") type = TABLE; @@ -108,26 +104,20 @@ bool FGCoefficient::Load(FGConfigFile *AC_cfg) { if (type == VECTOR || type == TABLE) { *AC_cfg >> rows; - if (debug_lvl > 0) cout << " Rows: " << rows << " "; if (type == TABLE) { *AC_cfg >> columns; - if (debug_lvl > 0) cout << "Cols: " << columns; Table = new FGTable(rows, columns); } else { Table = new FGTable(rows); } - if (debug_lvl > 0) cout << endl; - - *AC_cfg >> multparms; - LookupR = State->GetParameterIndex(multparms); - if (debug_lvl > 0) cout << " Row indexing parameter: " << multparms << endl; + *AC_cfg >> multparmsRow; + LookupR = State->GetParameterIndex(multparmsRow); } if (type == TABLE) { - *AC_cfg >> multparms; - LookupC = State->GetParameterIndex(multparms); - if (debug_lvl > 0) cout << " Column indexing parameter: " << multparms << endl; + *AC_cfg >> multparmsCol; + LookupC = State->GetParameterIndex(multparmsCol); } // Here, read in the line of the form (e.g.) FG_MACH|FG_QBAR|FG_ALPHA @@ -152,23 +142,17 @@ bool FGCoefficient::Load(FGConfigFile *AC_cfg) { // End of non-dimensionalizing parameter read-in } - switch(type) { - case VALUE: + if (type == VALUE) { *AC_cfg >> StaticValue; - if (debug_lvl > 0) cout << " Value = " << StaticValue << endl; - break; - case VECTOR: - case TABLE: + } else if (type == VECTOR || type == TABLE) { *Table << *AC_cfg; - if (debug_lvl > 0) Table->Print(); - break; - case EQUATION: - case UNKNOWN: + } else { cerr << "Unimplemented coefficient type: " << type << endl; - break; } + AC_cfg->GetNextConfigLine(); - if (debug_lvl > 0) DisplayCoeffFactors(); + Debug(2); + return true; } else { return false; @@ -224,7 +208,6 @@ double FGCoefficient::Value(void) double FGCoefficient::TotalValue() { - switch(type) { case 0: return -1; @@ -249,23 +232,16 @@ void FGCoefficient::DumpSD(void) //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -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) { + if (multipliers.size() == 0) { cout << "none" << endl; } else { - for (i=0; iGetState()->paramdef[multipliers[i]]; } cout << endl; @@ -273,7 +249,8 @@ void FGCoefficient::DisplayCoeffFactors(void) //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -string FGCoefficient::GetCoefficientValues(void) { +string FGCoefficient::GetCoefficientValues(void) +{ char buffer[10]; string value; @@ -283,4 +260,64 @@ string FGCoefficient::GetCoefficientValues(void) { } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +// The bitmasked value choices are as follows: +// unset: In this case (the default) JSBSim would only print +// out the normally expected messages, essentially echoing +// the config files as they are read. If the environment +// variable is not set, debug_lvl is set to 1 internally +// 0: This requests JSBSim not to output any messages +// whatsoever. +// 1: This value explicity requests the normal JSBSim +// startup messages +// 2: This value asks for a message to be printed out when +// a class is instantiated +// 4: When this value is set, a message is displayed when a +// FGModel object executes its Run() method +// 8: When this value is set, various runtime state variables +// are printed out periodically +// 16: When set various parameters are sanity checked and +// a message is printed out when they go out of bounds + +void FGCoefficient::Debug(int from) +{ + if (debug_lvl <= 0) return; + + if (debug_lvl & 1) { // Standard console startup message output + if (from == 2) { // Loading + cout << "\n " << highint << underon << name << underoff << normint << endl; + cout << " " << description << endl; + cout << " " << method << endl; + + if (type == VECTOR || type == TABLE) { + cout << " Rows: " << rows << " "; + if (type == TABLE) { + cout << "Cols: " << columns; + } + cout << endl << " Row indexing parameter: " << multparmsRow << endl; + } + + if (type == TABLE) { + cout << " Column indexing parameter: " << multparmsCol << endl; + } + + if (type == VALUE) { + cout << " Value = " << StaticValue << endl; + } else if (type == VECTOR || type == TABLE) { + Table->Print(); + } + + DisplayCoeffFactors(); + } + } + if (debug_lvl & 2 ) { // Instantiation/Destruction notification + if (from == 0) cout << "Instantiated: FGCoefficient" << endl; + if (from == 1) cout << "Destroyed: FGCoefficient" << endl; + } + if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects + } + if (debug_lvl & 8 ) { // Runtime state variables + } + if (debug_lvl & 16) { // Sanity checking + } +} diff --git a/src/FDM/JSBSim/FGCoefficient.h b/src/FDM/JSBSim/FGCoefficient.h index fb574aa71..0c1e1c951 100644 --- a/src/FDM/JSBSim/FGCoefficient.h +++ b/src/FDM/JSBSim/FGCoefficient.h @@ -126,6 +126,9 @@ private: string description; string name; string method; + string multparms; + string multparmsRow; + string multparmsCol; double Value(double, double); double Value(double); double Value(void); @@ -148,7 +151,7 @@ private: FGAuxiliary* Auxiliary; FGOutput* Output; - virtual void Debug(void); + virtual void Debug(int from); }; //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/src/FDM/JSBSim/FGColumnVector3.cpp b/src/FDM/JSBSim/FGColumnVector3.cpp index b974bea86..70a785dff 100644 --- a/src/FDM/JSBSim/FGColumnVector3.cpp +++ b/src/FDM/JSBSim/FGColumnVector3.cpp @@ -285,7 +285,7 @@ FGColumnVector3& FGColumnVector3::operator<<(const double ff) //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -void FGColumnVector3::Debug(void) +void FGColumnVector3::Debug(int from) { //TODO: Add your source code here } diff --git a/src/FDM/JSBSim/FGColumnVector3.h b/src/FDM/JSBSim/FGColumnVector3.h index 20572e427..032333cfa 100644 --- a/src/FDM/JSBSim/FGColumnVector3.h +++ b/src/FDM/JSBSim/FGColumnVector3.h @@ -110,7 +110,7 @@ public: private: double data[4]; int rowCtr; - void Debug(void); + void Debug(int from); }; //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/src/FDM/JSBSim/FGColumnVector4.cpp b/src/FDM/JSBSim/FGColumnVector4.cpp index 6f76cdc24..30a100913 100644 --- a/src/FDM/JSBSim/FGColumnVector4.cpp +++ b/src/FDM/JSBSim/FGColumnVector4.cpp @@ -273,7 +273,7 @@ FGColumnVector4& FGColumnVector4::operator<<(const double ff) //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -void FGColumnVector4::Debug(void) +void FGColumnVector4::Debug(int from) { //TODO: Add your source code here } diff --git a/src/FDM/JSBSim/FGColumnVector4.h b/src/FDM/JSBSim/FGColumnVector4.h index db311dfcb..d1e10d802 100644 --- a/src/FDM/JSBSim/FGColumnVector4.h +++ b/src/FDM/JSBSim/FGColumnVector4.h @@ -109,7 +109,7 @@ public: private: double data[5]; int rowCtr; - void Debug(void); + void Debug(int from); }; //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/src/FDM/JSBSim/FGConfigFile.cpp b/src/FDM/JSBSim/FGConfigFile.cpp index 4816cb291..29dc717ac 100644 --- a/src/FDM/JSBSim/FGConfigFile.cpp +++ b/src/FDM/JSBSim/FGConfigFile.cpp @@ -45,7 +45,7 @@ FGConfigFile::FGConfigFile(string cfgFileName) #endif else Opened = false; - if (debug_lvl & 2) cout << "Instantiated: FGConfigFile" << endl; + Debug(0); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -53,14 +53,13 @@ FGConfigFile::FGConfigFile(string cfgFileName) FGConfigFile::~FGConfigFile() { cfgfile.close(); - if (debug_lvl & 2) cout << "Destroyed: FGConfigFile" << endl; + Debug(1); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% string FGConfigFile::GetNextConfigLine(void) { - int comment_starts_at; int comment_ends_at; int comment_length; @@ -317,9 +316,39 @@ void FGConfigFile::ResetLineIndexToZero(void) } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -void FGConfigFile::Debug(void) +// The bitmasked value choices are as follows: +// unset: In this case (the default) JSBSim would only print +// out the normally expected messages, essentially echoing +// the config files as they are read. If the environment +// variable is not set, debug_lvl is set to 1 internally +// 0: This requests JSBSim not to output any messages +// whatsoever. +// 1: This value explicity requests the normal JSBSim +// startup messages +// 2: This value asks for a message to be printed out when +// a class is instantiated +// 4: When this value is set, a message is displayed when a +// FGModel object executes its Run() method +// 8: When this value is set, various runtime state variables +// are printed out periodically +// 16: When set various parameters are sanity checked and +// a message is printed out when they go out of bounds + +void FGConfigFile::Debug(int from) { - //TODO: Add your source code here + if (debug_lvl <= 0) return; + + if (debug_lvl & 1) { // Standard console startup message output + } + if (debug_lvl & 2 ) { // Instantiation/Destruction notification + if (from == 0) cout << "Instantiated: FGConfigFile" << endl; + if (from == 1) cout << "Destroyed: FGConfigFile" << endl; + } + if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects + } + if (debug_lvl & 8 ) { // Runtime state variables + } + if (debug_lvl & 16) { // Sanity checking + } } diff --git a/src/FDM/JSBSim/FGConfigFile.h b/src/FDM/JSBSim/FGConfigFile.h index 258f65cad..d4144b561 100644 --- a/src/FDM/JSBSim/FGConfigFile.h +++ b/src/FDM/JSBSim/FGConfigFile.h @@ -134,7 +134,7 @@ private: bool CommentsOn; bool Opened; unsigned int CurrentIndex; - void Debug(void); + void Debug(int from); }; //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/src/FDM/JSBSim/FGEngine.cpp b/src/FDM/JSBSim/FGEngine.cpp index 4c24dcc64..7f7c2956c 100644 --- a/src/FDM/JSBSim/FGEngine.cpp +++ b/src/FDM/JSBSim/FGEngine.cpp @@ -85,7 +85,7 @@ FGEngine::FGEngine(FGFDMExec* exec) Running = false; Cranking = Starter = false; - if (debug_lvl & 2) cout << "Instantiated: FGEngine" << endl; + Debug(0); TrimMode = false; } @@ -93,7 +93,7 @@ FGEngine::FGEngine(FGFDMExec* exec) FGEngine::~FGEngine() { - if (debug_lvl & 2) cout << "Destroyed: FGEngine" << endl; + Debug(1); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -154,9 +154,41 @@ void FGEngine::AddFeedTank(int tkID) } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -void FGEngine::Debug(void) +// The bitmasked value choices are as follows: +// unset: In this case (the default) JSBSim would only print +// out the normally expected messages, essentially echoing +// the config files as they are read. If the environment +// variable is not set, debug_lvl is set to 1 internally +// 0: This requests JSBSim not to output any messages +// whatsoever. +// 1: This value explicity requests the normal JSBSim +// startup messages +// 2: This value asks for a message to be printed out when +// a class is instantiated +// 4: When this value is set, a message is displayed when a +// FGModel object executes its Run() method +// 8: When this value is set, various runtime state variables +// are printed out periodically +// 16: When set various parameters are sanity checked and +// a message is printed out when they go out of bounds + +void FGEngine::Debug(int from) { - //TODO: Add your source code here -} + if (debug_lvl <= 0) return; + + if (debug_lvl & 1) { // Standard console startup message output + if (from == 0) { // Constructor + } + } + if (debug_lvl & 2 ) { // Instantiation/Destruction notification + if (from == 0) cout << "Instantiated: FGEngine" << endl; + if (from == 1) cout << "Destroyed: FGEngine" << endl; + } + if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects + } + if (debug_lvl & 8 ) { // Runtime state variables + } + if (debug_lvl & 16) { // Sanity checking + } +} diff --git a/src/FDM/JSBSim/FGEngine.h b/src/FDM/JSBSim/FGEngine.h index e919bf3b6..8e2f92471 100644 --- a/src/FDM/JSBSim/FGEngine.h +++ b/src/FDM/JSBSim/FGEngine.h @@ -234,7 +234,7 @@ protected: FGOutput* Output; vector SourceTanks; - void Debug(void); + virtual void Debug(int from); }; #include "FGState.h" diff --git a/src/FDM/JSBSim/FGFCS.cpp b/src/FDM/JSBSim/FGFCS.cpp index b08c7c967..0a3b63cd3 100644 --- a/src/FDM/JSBSim/FGFCS.cpp +++ b/src/FDM/JSBSim/FGFCS.cpp @@ -72,7 +72,7 @@ FGFCS::FGFCS(FGFDMExec* fdmex) : FGModel(fdmex) GearCmd = GearPos = 1; // default to gear down LeftBrake = RightBrake = CenterBrake = 0.0; - if (debug_lvl & 2) cout << "Instantiated: " << Name << endl; + Debug(0); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -89,7 +89,7 @@ FGFCS::~FGFCS() unsigned int i; for (i=0;i Components; - void Debug(void); + void Debug(int from); }; #include "FGState.h" diff --git a/src/FDM/JSBSim/FGFDMExec.cpp b/src/FDM/JSBSim/FGFDMExec.cpp index 5666b2ef0..b679cccbc 100644 --- a/src/FDM/JSBSim/FGFDMExec.cpp +++ b/src/FDM/JSBSim/FGFDMExec.cpp @@ -43,17 +43,14 @@ INCLUDES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ #ifdef FGFS -# include # include # include STL_IOSTREAM # include STL_ITERATOR #else # if defined(sgi) && !defined(__GNUC__) # include -# include # else # include -# include # endif # include #endif @@ -146,29 +143,24 @@ FGFDMExec::FGFDMExec(void) debug_lvl = 1; } - if (debug_lvl > 0) { - cout << "\n\n " << highint << underon << "JSBSim Flight Dynamics Model v" - << JSBSim_version << underoff << normint << endl; - cout << halfint << " [cfg file spec v" << needed_cfg_version << "]\n\n"; - cout << normint << "JSBSim startup beginning ...\n\n"; - } - - if (debug_lvl & 2) cout << "Instantiated: FGFDMExec" << endl; + Debug(0); Allocate(); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -FGFDMExec::~FGFDMExec() { +FGFDMExec::~FGFDMExec() +{ DeAllocate(); - if (debug_lvl & 2) cout << "Destroyed: FGFDMExec" << endl; + + Debug(1); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -bool FGFDMExec::Allocate(void) { - +bool FGFDMExec::Allocate(void) +{ bool result=true; Atmosphere = new FGAtmosphere(this); @@ -340,9 +332,7 @@ bool FGFDMExec::Run(void) if (State->Getsim_time() >= EndTime) return false; } - if (debug_lvl & 4) - cout << "================== Frame: " << Frame << " Time: " - << State->Getsim_time() << endl; + Debug(2); while (!model_iterator->Run()) { model_iterator = model_iterator->NextModel; @@ -395,7 +385,7 @@ bool FGFDMExec::LoadModel(string APath, string EPath, string model) if (result) { modelLoaded = true; - if (debug_lvl > 0) cout << "\n\nJSBSim startup complete\n\n"; + Debug(3); } else { cerr << fgred << " FGFDMExec: Failed to load aircraft and/or engine model" @@ -497,6 +487,8 @@ bool FGFDMExec::LoadScript(string script) } } + } else if (token.empty()) { + // do nothing } else { cerr << "Unrecognized keyword in script file: \"" << token << "\" [runscript] " << endl; } @@ -507,76 +499,7 @@ bool FGFDMExec::LoadScript(string script) exit(-1); } - // print out conditions for double-checking if requested - - if (debug_lvl > 0) { - vector ::iterator iterConditions = Conditions.begin(); - int count=0; - - cout << "\n Script goes from " << StartTime << " to " << EndTime - << " with dt = " << dt << endl << endl; - - while (iterConditions < Conditions.end()) { - cout << " Condition: " << count++ << endl; - cout << " if ("; - - for (i=0; iTestValue.size(); i++) { - if (i>0) cout << " and" << endl << " "; - cout << "(" << State->paramdef[iterConditions->TestParam[i]] - << iterConditions->Comparison[i] << " " - << iterConditions->TestValue[i] << ")"; - } - cout << ") then {"; - - for (i=0; iSetValue.size(); i++) { - cout << endl << " set" << State->paramdef[iterConditions->SetParam[i]] - << "to " << iterConditions->SetValue[i]; - - switch (iterConditions->Type[i]) { - case FG_VALUE: - cout << " (constant"; - break; - case FG_DELTA: - cout << " (delta"; - break; - case FG_BOOL: - cout << " (boolean"; - break; - default: - cout << " (unspecified type"; - } - - switch (iterConditions->Action[i]) { - case FG_RAMP: - cout << " via ramp"; - break; - case FG_STEP: - cout << " via step"; - break; - case FG_EXP: - cout << " via exponential approach"; - break; - default: - cout << " via unspecified action"; - } - - if (!iterConditions->Persistent[i]) cout << endl - << " once"; - else cout << endl - << " repeatedly"; - - if (iterConditions->Action[i] == FG_RAMP || - iterConditions->Action[i] == FG_EXP) cout << endl - << " with time constant " - << iterConditions->TC[i]; - } - cout << ")" << endl << " }" << endl << endl; - - iterConditions++; - } - - cout << endl; - } + Debug(4); result = LoadModel("aircraft", "engine", aircraft); if (!result) { @@ -673,9 +596,119 @@ void FGFDMExec::RunScript(void) } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -void FGFDMExec::Debug(void) +// The bitmasked value choices are as follows: +// unset: In this case (the default) JSBSim would only print +// out the normally expected messages, essentially echoing +// the config files as they are read. If the environment +// variable is not set, debug_lvl is set to 1 internally +// 0: This requests JSBSim not to output any messages +// whatsoever. +// 1: This value explicity requests the normal JSBSim +// startup messages +// 2: This value asks for a message to be printed out when +// a class is instantiated +// 4: When this value is set, a message is displayed when a +// FGModel object executes its Run() method +// 8: When this value is set, various runtime state variables +// are printed out periodically +// 16: When set various parameters are sanity checked and +// a message is printed out when they go out of bounds + +void FGFDMExec::Debug(int from) { - //TODO: Add your source code here -} + unsigned int i; + + if (debug_lvl <= 0) return; + + if (debug_lvl & 1) { // Standard console startup message output + if (from == 0) { // Constructor + cout << "\n\n " << highint << underon << "JSBSim Flight Dynamics Model v" + << JSBSim_version << underoff << normint << endl; + cout << halfint << " [cfg file spec v" << needed_cfg_version << "]\n\n"; + cout << normint << "JSBSim startup beginning ...\n\n"; + } else if (from == 3) { + cout << "\n\nJSBSim startup complete\n\n"; + } else if (from == 4) { // print out script data + vector ::iterator iterConditions = Conditions.begin(); + int count=0; + + cout << "\n Script goes from " << StartTime << " to " << EndTime + << " with dt = " << State->Getdt() << endl << endl; + + while (iterConditions < Conditions.end()) { + cout << " Condition: " << count++ << endl; + cout << " if ("; + + for (i=0; iTestValue.size(); i++) { + if (i>0) cout << " and" << endl << " "; + cout << "(" << State->paramdef[iterConditions->TestParam[i]] + << iterConditions->Comparison[i] << " " + << iterConditions->TestValue[i] << ")"; + } + cout << ") then {"; + + for (i=0; iSetValue.size(); i++) { + cout << endl << " set" << State->paramdef[iterConditions->SetParam[i]] + << "to " << iterConditions->SetValue[i]; + switch (iterConditions->Type[i]) { + case FG_VALUE: + cout << " (constant"; + break; + case FG_DELTA: + cout << " (delta"; + break; + case FG_BOOL: + cout << " (boolean"; + break; + default: + cout << " (unspecified type"; + } + + switch (iterConditions->Action[i]) { + case FG_RAMP: + cout << " via ramp"; + break; + case FG_STEP: + cout << " via step"; + break; + case FG_EXP: + cout << " via exponential approach"; + break; + default: + cout << " via unspecified action"; + } + + if (!iterConditions->Persistent[i]) cout << endl + << " once"; + else cout << endl + << " repeatedly"; + + if (iterConditions->Action[i] == FG_RAMP || + iterConditions->Action[i] == FG_EXP) cout << endl + << " with time constant " + << iterConditions->TC[i]; + } + cout << ")" << endl << " }" << endl << endl; + + iterConditions++; + } + + cout << endl; + } + } + if (debug_lvl & 2 ) { // Instantiation/Destruction notification + if (from == 0) cout << "Instantiated: FGFDMExec" << endl; + if (from == 1) cout << "Destroyed: FGFDMExec" << endl; + } + if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects + if (from == 2) { + cout << "================== Frame: " << Frame << " Time: " + << State->Getsim_time() << endl; + } + } + if (debug_lvl & 8 ) { // Runtime state variables + } + if (debug_lvl & 16) { // Sanity checking + } +} diff --git a/src/FDM/JSBSim/FGFDMExec.h b/src/FDM/JSBSim/FGFDMExec.h index 9fde7b6a9..dd9e63300 100644 --- a/src/FDM/JSBSim/FGFDMExec.h +++ b/src/FDM/JSBSim/FGFDMExec.h @@ -347,7 +347,7 @@ private: bool Allocate(void); bool DeAllocate(void); - void Debug(void); + void Debug(int from); }; //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/src/FDM/JSBSim/FGFactorGroup.cpp b/src/FDM/JSBSim/FGFactorGroup.cpp index 37ef3d921..5b3e0b9a0 100644 --- a/src/FDM/JSBSim/FGFactorGroup.cpp +++ b/src/FDM/JSBSim/FGFactorGroup.cpp @@ -69,41 +69,39 @@ CLASS IMPLEMENTATION FGFactorGroup::FGFactorGroup( FGFDMExec* fdmex ) : FGCoefficient( fdmex) { - FDMExec=fdmex; - if (debug_lvl & 2) cout << "Instantiated: FGFactorGroup" << endl; + FDMExec = fdmex; + + Debug(0); } /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ FGFactorGroup::~FGFactorGroup() { - unsigned i; - for (i=0; iGetValue("NAME"); AC_cfg->GetNextConfigLine(); *AC_cfg >> description; token = AC_cfg->GetValue(); - if( token == "FACTOR") { + if (token == "FACTOR") { FGCoefficient::Load(AC_cfg); - //if (debug_lvl > 0) DisplayCoeffFactors(ca.back()->Getmultipliers()); } token = AC_cfg->GetValue(); - while ( token != string("/GROUP") ) { - sum.push_back( new FGCoefficient(FDMExec) ); - sum.back()->Load(AC_cfg); - //if (debug_lvl > 0) DisplayCoeffFactors(ca.back()->Getmultipliers()); - token = AC_cfg->GetValue(); + while (token != string("/GROUP") ) { + sum.push_back( new FGCoefficient(FDMExec) ); + sum.back()->Load(AC_cfg); + token = AC_cfg->GetValue(); } AC_cfg->GetNextConfigLine(); return true; @@ -114,25 +112,58 @@ bool FGFactorGroup::Load(FGConfigFile *AC_cfg) { /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ -double FGFactorGroup::TotalValue(void) { - unsigned i; - double totalsum=0; - SDtotal=0.0; - for(i=0;iTotalValue(); +double FGFactorGroup::TotalValue(void) +{ + unsigned int i; + double totalsum = 0; + SDtotal = 0.0; + for (i=0; iTotalValue(); SDtotal += sum[i]->GetSD(); } totalsum *= FGCoefficient::TotalValue(); SDtotal *= FGCoefficient::GetSD(); - if (debug_lvl & 8) Debug(); + Debug(2); return totalsum; -} +} /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ - -void FGFactorGroup::Debug(void) +// The bitmasked value choices are as follows: +// unset: In this case (the default) JSBSim would only print +// out the normally expected messages, essentially echoing +// the config files as they are read. If the environment +// variable is not set, debug_lvl is set to 1 internally +// 0: This requests JSBSim not to output any messages +// whatsoever. +// 1: This value explicity requests the normal JSBSim +// startup messages +// 2: This value asks for a message to be printed out when +// a class is instantiated +// 4: When this value is set, a message is displayed when a +// FGModel object executes its Run() method +// 8: When this value is set, various runtime state variables +// are printed out periodically +// 16: When set various parameters are sanity checked and +// a message is printed out when they go out of bounds + +void FGFactorGroup::Debug(int from) { - cout << "FGCoefficient::GetSD(): " << FGCoefficient::GetSD() << endl; - cout << "FGFactorGroup::SDtotal: " << SDtotal << endl; -} + if (debug_lvl <= 0) return; + if (debug_lvl & 1) { // Standard console startup message output + } + if (debug_lvl & 2 ) { // Instantiation/Destruction notification + if (from == 0) cout << "Instantiated: FGFactorGroup" << endl; + if (from == 1) cout << "Destroyed: FGFactorGroup" << endl; + } + if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects + } + if (debug_lvl & 8 ) { // Runtime state variables + if (from == 2) { + cout << "FGCoefficient::GetSD(): " << FGCoefficient::GetSD() << endl; + cout << "FGFactorGroup::SDtotal: " << SDtotal << endl; + } + } + if (debug_lvl & 16) { // Sanity checking + } +} diff --git a/src/FDM/JSBSim/FGFactorGroup.h b/src/FDM/JSBSim/FGFactorGroup.h index 2a2b418aa..0484119a1 100644 --- a/src/FDM/JSBSim/FGFactorGroup.h +++ b/src/FDM/JSBSim/FGFactorGroup.h @@ -111,7 +111,7 @@ class FGFactorGroup: public FGCoefficient { typedef vector CoeffArray; CoeffArray sum; double SDtotal; - void Debug(void); + void Debug(int from); }; #endif diff --git a/src/FDM/JSBSim/FGForce.cpp b/src/FDM/JSBSim/FGForce.cpp index a1bd2172f..d2da596c2 100644 --- a/src/FDM/JSBSim/FGForce.cpp +++ b/src/FDM/JSBSim/FGForce.cpp @@ -61,14 +61,14 @@ FGForce::FGForce(FGFDMExec *FDMExec) : mT(2,2) = 1; mT(3,3) = 1; vSense.InitMatrix(1); - if (debug_lvl & 2) cout << "Instantiated: FGForce" << endl; + Debug(0); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FGForce::~FGForce() { - if (debug_lvl & 2) cout << "Destroyed: FGForce" << endl; + Debug(1); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -135,9 +135,42 @@ void FGForce::SetAnglesToBody(double broll, double bpitch, double byaw) } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -void FGForce::Debug(void) +// The bitmasked value choices are as follows: +// unset: In this case (the default) JSBSim would only print +// out the normally expected messages, essentially echoing +// the config files as they are read. If the environment +// variable is not set, debug_lvl is set to 1 internally +// 0: This requests JSBSim not to output any messages +// whatsoever. +// 1: This value explicity requests the normal JSBSim +// startup messages +// 2: This value asks for a message to be printed out when +// a class is instantiated +// 4: When this value is set, a message is displayed when a +// FGModel object executes its Run() method +// 8: When this value is set, various runtime state variables +// are printed out periodically +// 16: When set various parameters are sanity checked and +// a message is printed out when they go out of bounds + +void FGForce::Debug(int from) { - //TODO: Add your source code here + if (debug_lvl <= 0) return; + + if (debug_lvl & 1) { // Standard console startup message output + if (from == 0) { // Constructor + + } + } + if (debug_lvl & 2 ) { // Instantiation/Destruction notification + if (from == 0) cout << "Instantiated: FGForce" << endl; + if (from == 1) cout << "Destroyed: FGForce" << endl; + } + if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects + } + if (debug_lvl & 8 ) { // Runtime state variables + } + if (debug_lvl & 16) { // Sanity checking + } } diff --git a/src/FDM/JSBSim/FGForce.h b/src/FDM/JSBSim/FGForce.h index 595667574..dfacc4a19 100644 --- a/src/FDM/JSBSim/FGForce.h +++ b/src/FDM/JSBSim/FGForce.h @@ -316,8 +316,6 @@ protected: FGColumnVector3 vMn; FGColumnVector3 vH; - virtual void Debug(void); - private: FGColumnVector3 vFb; FGColumnVector3 vM; @@ -327,6 +325,8 @@ private: FGColumnVector3 vSense; FGMatrix33 mT; + + virtual void Debug(int from); }; #endif diff --git a/src/FDM/JSBSim/FGGroundReactions.cpp b/src/FDM/JSBSim/FGGroundReactions.cpp index 5d478f6a7..b041df3bd 100644 --- a/src/FDM/JSBSim/FGGroundReactions.cpp +++ b/src/FDM/JSBSim/FGGroundReactions.cpp @@ -49,11 +49,17 @@ FGGroundReactions::FGGroundReactions(FGFDMExec* fgex) : FGModel(fgex) { Name = "FGGroundReactions"; - if (debug_lvl & 2) cout << "Instantiated: " << Name << endl; + Debug(0); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +FGGroundReactions::~FGGroundReactions(void) +{ + Debug(1); +} + +//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% bool FGGroundReactions::Run(void) { double steerAngle = 0.0; @@ -194,9 +200,42 @@ string FGGroundReactions::GetGroundReactionValues(void) } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -void FGGroundReactions::Debug(void) +// The bitmasked value choices are as follows: +// unset: In this case (the default) JSBSim would only print +// out the normally expected messages, essentially echoing +// the config files as they are read. If the environment +// variable is not set, debug_lvl is set to 1 internally +// 0: This requests JSBSim not to output any messages +// whatsoever. +// 1: This value explicity requests the normal JSBSim +// startup messages +// 2: This value asks for a message to be printed out when +// a class is instantiated +// 4: When this value is set, a message is displayed when a +// FGModel object executes its Run() method +// 8: When this value is set, various runtime state variables +// are printed out periodically +// 16: When set various parameters are sanity checked and +// a message is printed out when they go out of bounds + +void FGGroundReactions::Debug(int from) { - //TODO: Add your source code here + if (debug_lvl <= 0) return; + + if (debug_lvl & 1) { // Standard console startup message output + if (from == 0) { // Constructor + + } + } + if (debug_lvl & 2 ) { // Instantiation/Destruction notification + if (from == 0) cout << "Instantiated: FGGroundReactions" << endl; + if (from == 1) cout << "Destroyed: FGGroundReactions" << endl; + } + if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects + } + if (debug_lvl & 8 ) { // Runtime state variables + } + if (debug_lvl & 16) { // Sanity checking + } } diff --git a/src/FDM/JSBSim/FGGroundReactions.h b/src/FDM/JSBSim/FGGroundReactions.h index 7c0ffdcf3..21b774ab5 100644 --- a/src/FDM/JSBSim/FGGroundReactions.h +++ b/src/FDM/JSBSim/FGGroundReactions.h @@ -69,7 +69,7 @@ class FGGroundReactions : public FGModel { public: FGGroundReactions(FGFDMExec*); - ~FGGroundReactions() {}; + ~FGGroundReactions(void); bool Run(void); bool Load(FGConfigFile* AC_cfg); @@ -93,7 +93,7 @@ private: FGColumnVector3 vMaxStaticGrip; FGColumnVector3 vMaxMomentResist; - void Debug(void); + void Debug(int from); }; //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/src/FDM/JSBSim/FGInertial.cpp b/src/FDM/JSBSim/FGInertial.cpp index f5189108f..9f680d203 100644 --- a/src/FDM/JSBSim/FGInertial.cpp +++ b/src/FDM/JSBSim/FGInertial.cpp @@ -60,14 +60,14 @@ FGInertial::FGInertial(FGFDMExec* fgex) : FGModel(fgex) gAccelReference = GM/(RadiusReference*RadiusReference); gAccel = GM/(RadiusReference*RadiusReference); - if (debug_lvl & 2) cout << "Instantiated: FGInertial" << endl; + Debug(0); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FGInertial::~FGInertial(void) { - if (debug_lvl & 2) cout << "Destroyed: FGInertial" << endl; + Debug(1); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -123,9 +123,42 @@ bool FGInertial::LoadInertial(FGConfigFile* AC_cfg) } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -void FGInertial::Debug(void) +// The bitmasked value choices are as follows: +// unset: In this case (the default) JSBSim would only print +// out the normally expected messages, essentially echoing +// the config files as they are read. If the environment +// variable is not set, debug_lvl is set to 1 internally +// 0: This requests JSBSim not to output any messages +// whatsoever. +// 1: This value explicity requests the normal JSBSim +// startup messages +// 2: This value asks for a message to be printed out when +// a class is instantiated +// 4: When this value is set, a message is displayed when a +// FGModel object executes its Run() method +// 8: When this value is set, various runtime state variables +// are printed out periodically +// 16: When set various parameters are sanity checked and +// a message is printed out when they go out of bounds + +void FGInertial::Debug(int from) { - //TODO: Add your source code here + if (debug_lvl <= 0) return; + + if (debug_lvl & 1) { // Standard console startup message output + if (from == 0) { // Constructor + + } + } + if (debug_lvl & 2 ) { // Instantiation/Destruction notification + if (from == 0) cout << "Instantiated: FGInertial" << endl; + if (from == 1) cout << "Destroyed: FGInertial" << endl; + } + if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects + } + if (debug_lvl & 8 ) { // Runtime state variables + } + if (debug_lvl & 16) { // Sanity checking + } } diff --git a/src/FDM/JSBSim/FGInertial.h b/src/FDM/JSBSim/FGInertial.h index 6c0031b96..7a1da74cf 100644 --- a/src/FDM/JSBSim/FGInertial.h +++ b/src/FDM/JSBSim/FGInertial.h @@ -83,7 +83,6 @@ public: double RefRadius(void) {return RadiusReference;} private: - void Debug(void); FGColumnVector3 vOmegaLocal; FGColumnVector3 vForces; FGColumnVector3 vRadius; @@ -93,6 +92,7 @@ private: double RadiusReference; double RotationRate; double GM; + void Debug(int from); }; //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/src/FDM/JSBSim/FGInitialCondition.cpp b/src/FDM/JSBSim/FGInitialCondition.cpp index e641fa86c..99cad97a5 100644 --- a/src/FDM/JSBSim/FGInitialCondition.cpp +++ b/src/FDM/JSBSim/FGInitialCondition.cpp @@ -366,6 +366,8 @@ void FGInitialCondition::calcWindUVW(void) { wnorth=whead*cos(psi) + wcross*cos(psi+M_PI/2); weast=whead*sin(psi) + wcross*sin(psi+M_PI/2); break; + case setwned: + break; } uw=wnorth*ctheta*cpsi + weast*ctheta*spsi - diff --git a/src/FDM/JSBSim/FGJSBBase.h b/src/FDM/JSBSim/FGJSBBase.h index b805f056b..ee55600d2 100644 --- a/src/FDM/JSBSim/FGJSBBase.h +++ b/src/FDM/JSBSim/FGJSBBase.h @@ -262,7 +262,7 @@ protected: static queue Messages; - virtual void Debug(void) {}; + virtual void Debug(int from) {}; static short debug_lvl; static unsigned int frame; diff --git a/src/FDM/JSBSim/FGLGear.cpp b/src/FDM/JSBSim/FGLGear.cpp index eb42ff08a..e7cc9e4ef 100644 --- a/src/FDM/JSBSim/FGLGear.cpp +++ b/src/FDM/JSBSim/FGLGear.cpp @@ -60,27 +60,12 @@ CLASS IMPLEMENTATION FGLGear::FGLGear(FGConfigFile* AC_cfg, FGFDMExec* fdmex) : Exec(fdmex) { string tmp; - string Retractable; *AC_cfg >> tmp >> name >> vXYZ(1) >> vXYZ(2) >> vXYZ(3) >> kSpring >> bDamp>> dynamicFCoeff >> staticFCoeff >> rollingFCoeff >> sSteerType >> sBrakeGroup >> maxSteerAngle >> Retractable; - if (debug_lvl > 0) { - cout << " Name: " << name << endl; - cout << " Location: " << vXYZ << endl; - cout << " Spring Constant: " << kSpring << endl; - cout << " Damping Constant: " << bDamp << endl; - cout << " Dynamic Friction: " << dynamicFCoeff << endl; - cout << " Static Friction: " << staticFCoeff << endl; - cout << " Rolling Friction: " << rollingFCoeff << endl; - cout << " Steering Type: " << sSteerType << endl; - cout << " Grouping: " << sBrakeGroup << endl; - cout << " Max Steer Angle: " << maxSteerAngle << endl; - cout << " Retractable: " << Retractable << endl; - } - if (sBrakeGroup == "LEFT" ) eBrakeGrp = bgLeft; else if (sBrakeGroup == "RIGHT" ) eBrakeGrp = bgRight; else if (sBrakeGroup == "CENTER") eBrakeGrp = bgCenter; @@ -100,7 +85,7 @@ FGLGear::FGLGear(FGConfigFile* AC_cfg, FGFDMExec* fdmex) : Exec(fdmex) << sSteerType << " is undefined." << endl; } - if( Retractable == "RETRACT" ) { + if ( Retractable == "RETRACT" ) { isRetractable=true; } else { isRetractable=false; @@ -132,7 +117,7 @@ FGLGear::FGLGear(FGConfigFile* AC_cfg, FGFDMExec* fdmex) : Exec(fdmex) vLocalGear = State->GetTb2l() * vWhlBodyVec; - if (debug_lvl & 2) cout << "Instantiated: FGLGear" << endl; + Debug(0); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -181,13 +166,15 @@ FGLGear::FGLGear(const FGLGear& lgear) isRetractable = lgear.isRetractable; GearUp = lgear.GearUp; GearDown = lgear.GearDown; + + Debug(0); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FGLGear::~FGLGear() { - if (debug_lvl & 2) cout << "Destroyed: FGLGear" << endl; + Debug(1); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -413,9 +400,7 @@ FGColumnVector3& FGLGear::Force(void) MaximumStrutForce = MaximumStrutTravel = 0.0; } - compressLength = 0.0;// reset compressLength to zero for data output validity - - + compressLength = 0.0; // reset compressLength to zero for data output validity } if (FirstContact) { @@ -442,8 +427,6 @@ FGColumnVector3& FGLGear::Force(void) PutMessage("Crash Detected"); Exec->Freeze(); } - - } return vForce; } @@ -467,9 +450,52 @@ void FGLGear::Report(void) } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -void FGLGear::Debug(void) +// The bitmasked value choices are as follows: +// unset: In this case (the default) JSBSim would only print +// out the normally expected messages, essentially echoing +// the config files as they are read. If the environment +// variable is not set, debug_lvl is set to 1 internally +// 0: This requests JSBSim not to output any messages +// whatsoever. +// 1: This value explicity requests the normal JSBSim +// startup messages +// 2: This value asks for a message to be printed out when +// a class is instantiated +// 4: When this value is set, a message is displayed when a +// FGModel object executes its Run() method +// 8: When this value is set, various runtime state variables +// are printed out periodically +// 16: When set various parameters are sanity checked and +// a message is printed out when they go out of bounds + +void FGLGear::Debug(int from) { - // TODO: Add user code here + if (debug_lvl <= 0) return; + + if (debug_lvl & 1) { // Standard console startup message output + if (from == 0) { // Constructor + cout << " Name: " << name << endl; + cout << " Location: " << vXYZ << endl; + cout << " Spring Constant: " << kSpring << endl; + cout << " Damping Constant: " << bDamp << endl; + cout << " Dynamic Friction: " << dynamicFCoeff << endl; + cout << " Static Friction: " << staticFCoeff << endl; + cout << " Rolling Friction: " << rollingFCoeff << endl; + cout << " Steering Type: " << sSteerType << endl; + cout << " Grouping: " << sBrakeGroup << endl; + cout << " Max Steer Angle: " << maxSteerAngle << endl; + cout << " Retractable: " << Retractable << endl; + } + } + if (debug_lvl & 2 ) { // Instantiation/Destruction notification + if (from == 0) cout << "Instantiated: FGLGear" << endl; + if (from == 1) cout << "Destroyed: FGLGear" << endl; + } + if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects + } + if (debug_lvl & 8 ) { // Runtime state variables + } + if (debug_lvl & 16) { // Sanity checking + } } diff --git a/src/FDM/JSBSim/FGLGear.h b/src/FDM/JSBSim/FGLGear.h index fe2aff02b..575a78146 100644 --- a/src/FDM/JSBSim/FGLGear.h +++ b/src/FDM/JSBSim/FGLGear.h @@ -268,6 +268,7 @@ private: string name; string sSteerType; string sBrakeGroup; + string Retractable; BrakeGroup eBrakeGrp; SteerType eSteerType; @@ -282,7 +283,7 @@ private: FGMassBalance* MassBalance; void Report(void); - void Debug(void); + void Debug(int from); }; #include "FGAircraft.h" diff --git a/src/FDM/JSBSim/FGMassBalance.cpp b/src/FDM/JSBSim/FGMassBalance.cpp index a7f2eb93b..2770191ab 100644 --- a/src/FDM/JSBSim/FGMassBalance.cpp +++ b/src/FDM/JSBSim/FGMassBalance.cpp @@ -52,14 +52,14 @@ FGMassBalance::FGMassBalance(FGFDMExec* fdmex) : FGModel(fdmex) { Name = "FGMassBalance"; - if (debug_lvl & 2) cout << "Instantiated: FGMassBalance" << endl; + Debug(0); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FGMassBalance::~FGMassBalance() { - if (debug_lvl & 2) cout << "Destroyed: FGMassBalance" << endl; + Debug(1); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -85,7 +85,7 @@ bool FGMassBalance::Run(void) Ixy = baseIxy + Propulsion->GetTanksIxy(vXYZcg) + GetPMIxy(); Ixz = baseIxz + Propulsion->GetTanksIxz(vXYZcg) + GetPMIxz(); - if (debug_lvl > 1) Debug(); + Debug(2); return false; } else { @@ -186,16 +186,50 @@ double FGMassBalance::GetPMIxz(void) } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -void FGMassBalance::Debug(void) +// The bitmasked value choices are as follows: +// unset: In this case (the default) JSBSim would only print +// out the normally expected messages, essentially echoing +// the config files as they are read. If the environment +// variable is not set, debug_lvl is set to 1 internally +// 0: This requests JSBSim not to output any messages +// whatsoever. +// 1: This value explicity requests the normal JSBSim +// startup messages +// 2: This value asks for a message to be printed out when +// a class is instantiated +// 4: When this value is set, a message is displayed when a +// FGModel object executes its Run() method +// 8: When this value is set, various runtime state variables +// are printed out periodically +// 16: When set various parameters are sanity checked and +// a message is printed out when they go out of bounds + +void FGMassBalance::Debug(int from) { - if (debug_lvl & 16) { // Sanity check variables - if (EmptyWeight <= 0.0 || EmptyWeight > 1e9) - cout << "MassBalance::EmptyWeight out of bounds: " << EmptyWeight << endl; - if (Weight <= 0.0 || Weight > 1e9) - cout << "MassBalance::Weight out of bounds: " << Weight << endl; - if (Mass <= 0.0 || Mass > 1e9) - cout << "MassBalance::Mass out of bounds: " << Mass << endl; + if (debug_lvl <= 0) return; + + if (debug_lvl & 1) { // Standard console startup message output + if (from == 0) { // Constructor + + } + } + if (debug_lvl & 2 ) { // Instantiation/Destruction notification + if (from == 0) cout << "Instantiated: FGPiston" << endl; + if (from == 1) cout << "Destroyed: FGPiston" << endl; + } + if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects + } + if (debug_lvl & 8 ) { // Runtime state variables + } + if (debug_lvl & 16) { // Sanity checking + if (from == 2) { + if (EmptyWeight <= 0.0 || EmptyWeight > 1e9) + cout << "MassBalance::EmptyWeight out of bounds: " << EmptyWeight << endl; + if (Weight <= 0.0 || Weight > 1e9) + cout << "MassBalance::Weight out of bounds: " << Weight << endl; + if (Mass <= 0.0 || Mass > 1e9) + cout << "MassBalance::Mass out of bounds: " << Mass << endl; + } } } diff --git a/src/FDM/JSBSim/FGMassBalance.h b/src/FDM/JSBSim/FGMassBalance.h index 5efda6698..69c84fd46 100644 --- a/src/FDM/JSBSim/FGMassBalance.h +++ b/src/FDM/JSBSim/FGMassBalance.h @@ -108,7 +108,7 @@ private: vector PointMassLoc; vector PointMassWeight; FGColumnVector3 PointMassCG; - void Debug(void); + void Debug(int from); }; //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/src/FDM/JSBSim/FGMatrix33.cpp b/src/FDM/JSBSim/FGMatrix33.cpp index dba368991..0c066df59 100644 --- a/src/FDM/JSBSim/FGMatrix33.cpp +++ b/src/FDM/JSBSim/FGMatrix33.cpp @@ -35,7 +35,7 @@ FGMatrix33::FGMatrix33(void) InitMatrix(); rowCtr = colCtr = 1; - if (debug_lvl & 2) cout << "Instantiated: FGMatrix33" << endl; + Debug(0); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -45,7 +45,7 @@ FGMatrix33::FGMatrix33(int r, int c) InitMatrix(); rowCtr = colCtr = 1; - if (debug_lvl & 2) cout << "Instantiated: FGMatrix33" << endl; + Debug(0); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -64,7 +64,7 @@ FGMatrix33::FGMatrix33(const FGMatrix33& M) data[3][2] = M.data[3][2]; data[3][3] = M.data[3][3]; - if (debug_lvl & 2) cout << "Instantiated: FGMatrix33" << endl; + Debug(0); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -73,7 +73,7 @@ FGMatrix33::~FGMatrix33(void) { rowCtr = colCtr = 1; - if (debug_lvl & 2) cout << "Destroyed: FGMatrix33" << endl; + Debug(1); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -396,11 +396,42 @@ FGColumnVector3 FGMatrix33::operator*(const FGColumnVector3& Col) } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -void FGMatrix33::Debug(void) +// The bitmasked value choices are as follows: +// unset: In this case (the default) JSBSim would only print +// out the normally expected messages, essentially echoing +// the config files as they are read. If the environment +// variable is not set, debug_lvl is set to 1 internally +// 0: This requests JSBSim not to output any messages +// whatsoever. +// 1: This value explicity requests the normal JSBSim +// startup messages +// 2: This value asks for a message to be printed out when +// a class is instantiated +// 4: When this value is set, a message is displayed when a +// FGModel object executes its Run() method +// 8: When this value is set, various runtime state variables +// are printed out periodically +// 16: When set various parameters are sanity checked and +// a message is printed out when they go out of bounds + +void FGMatrix33::Debug(int from) { - //TODO: Add your source code here -} + if (debug_lvl <= 0) return; -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + if (debug_lvl & 1) { // Standard console startup message output + if (from == 0) { // Constructor + + } + } + if (debug_lvl & 2 ) { // Instantiation/Destruction notification + if (from == 0) cout << "Instantiated: FGMatrix33" << endl; + if (from == 1) cout << "Destroyed: FGMatrix33" << endl; + } + if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects + } + if (debug_lvl & 8 ) { // Runtime state variables + } + if (debug_lvl & 16) { // Sanity checking + } +} diff --git a/src/FDM/JSBSim/FGMatrix33.h b/src/FDM/JSBSim/FGMatrix33.h index df5922280..7eff24dd7 100644 --- a/src/FDM/JSBSim/FGMatrix33.h +++ b/src/FDM/JSBSim/FGMatrix33.h @@ -128,7 +128,7 @@ protected: private: void TransposeSquare(void); unsigned int rowCtr, colCtr; - void Debug(void); + void Debug(int from); }; #endif diff --git a/src/FDM/JSBSim/FGNozzle.cpp b/src/FDM/JSBSim/FGNozzle.cpp index 3f0869081..001df2463 100644 --- a/src/FDM/JSBSim/FGNozzle.cpp +++ b/src/FDM/JSBSim/FGNozzle.cpp @@ -67,27 +67,19 @@ FGNozzle::FGNozzle(FGFDMExec* FDMExec, FGConfigFile* Nzl_cfg) : FGThruster(FDMEx else cerr << "Unhandled token in Nozzle config file: " << token << endl; } - if (debug_lvl > 0) { - cout << " Nozzle Name: " << Name << endl; - cout << " Nozzle Exit Pressure = " << PE << endl; - cout << " Nozzle Expansion Ratio = " << ExpR << endl; - cout << " Nozzle Efficiency = " << nzlEff << endl; - cout << " Nozzle Diameter = " << Diameter << endl; - } - Thrust = 0; Type = ttNozzle; Area2 = (Diameter*Diameter/4.0)*M_PI; AreaT = Area2/ExpR; - if (debug_lvl & 2) cout << "Instantiated: FGNozzle" << endl; + Debug(0); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FGNozzle::~FGNozzle() { - if (debug_lvl & 2) cout << "Destroyed: FGNozzle" << endl; + Debug(1); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -109,9 +101,46 @@ double FGNozzle::GetPowerRequired(void) } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -void FGNozzle::Debug(void) +// The bitmasked value choices are as follows: +// unset: In this case (the default) JSBSim would only print +// out the normally expected messages, essentially echoing +// the config files as they are read. If the environment +// variable is not set, debug_lvl is set to 1 internally +// 0: This requests JSBSim not to output any messages +// whatsoever. +// 1: This value explicity requests the normal JSBSim +// startup messages +// 2: This value asks for a message to be printed out when +// a class is instantiated +// 4: When this value is set, a message is displayed when a +// FGModel object executes its Run() method +// 8: When this value is set, various runtime state variables +// are printed out periodically +// 16: When set various parameters are sanity checked and +// a message is printed out when they go out of bounds + +void FGNozzle::Debug(int from) { - //TODO: Add your source code here + if (debug_lvl <= 0) return; + + if (debug_lvl & 1) { // Standard console startup message output + if (from == 0) { // Constructor + cout << " Nozzle Name: " << Name << endl; + cout << " Nozzle Exit Pressure = " << PE << endl; + cout << " Nozzle Expansion Ratio = " << ExpR << endl; + cout << " Nozzle Efficiency = " << nzlEff << endl; + cout << " Nozzle Diameter = " << Diameter << endl; + } + } + if (debug_lvl & 2 ) { // Instantiation/Destruction notification + if (from == 0) cout << "Instantiated: FGNozzle" << endl; + if (from == 1) cout << "Destroyed: FGNozzle" << endl; + } + if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects + } + if (debug_lvl & 8 ) { // Runtime state variables + } + if (debug_lvl & 16) { // Sanity checking + } } diff --git a/src/FDM/JSBSim/FGNozzle.h b/src/FDM/JSBSim/FGNozzle.h index 93c4d39d2..c0b0b9b56 100644 --- a/src/FDM/JSBSim/FGNozzle.h +++ b/src/FDM/JSBSim/FGNozzle.h @@ -83,7 +83,7 @@ private: double Diameter; double AreaT; double Area2; - void Debug(void); + void Debug(int from); }; //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/src/FDM/JSBSim/FGOutput.cpp b/src/FDM/JSBSim/FGOutput.cpp index aff96cc48..02f8eff17 100644 --- a/src/FDM/JSBSim/FGOutput.cpp +++ b/src/FDM/JSBSim/FGOutput.cpp @@ -72,7 +72,7 @@ FGOutput::FGOutput(FGFDMExec* fdmex) : FGModel(fdmex) #ifdef FG_WITH_JSBSIM_SOCKET socket = new FGfdmSocket("localhost",1138); #endif - if (debug_lvl & 2) cout << "Instantiated: " << Name << endl; + Debug(0); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -80,7 +80,7 @@ FGOutput::FGOutput(FGFDMExec* fdmex) : FGModel(fdmex) FGOutput::~FGOutput() { if (socket) delete socket; - if (debug_lvl & 2) cout << "Destroyed: FGOutput" << endl; + Debug(1); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -209,7 +209,7 @@ void FGOutput::DelimitedOutput(string fname) outstream << ", "; outstream << GroundReactions->GetGroundReactionStrings(); } - if (SubSystems & ssPropulsion) { + if (SubSystems & ssPropulsion && Propulsion->GetNumEngines() > 0) { outstream << ", "; outstream << Propulsion->GetPropulsionStrings(); } @@ -284,7 +284,7 @@ void FGOutput::DelimitedOutput(string fname) outstream << ", "; outstream << GroundReactions->GetGroundReactionValues(); } - if (SubSystems & ssPropulsion) { + if (SubSystems & ssPropulsion && Propulsion->GetNumEngines() > 0) { outstream << ", "; outstream << Propulsion->GetPropulsionValues(); } @@ -481,9 +481,42 @@ bool FGOutput::Load(FGConfigFile* AC_cfg) } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -void FGOutput::Debug(void) +// The bitmasked value choices are as follows: +// unset: In this case (the default) JSBSim would only print +// out the normally expected messages, essentially echoing +// the config files as they are read. If the environment +// variable is not set, debug_lvl is set to 1 internally +// 0: This requests JSBSim not to output any messages +// whatsoever. +// 1: This value explicity requests the normal JSBSim +// startup messages +// 2: This value asks for a message to be printed out when +// a class is instantiated +// 4: When this value is set, a message is displayed when a +// FGModel object executes its Run() method +// 8: When this value is set, various runtime state variables +// are printed out periodically +// 16: When set various parameters are sanity checked and +// a message is printed out when they go out of bounds + +void FGOutput::Debug(int from) { - //TODO: Add your source code here + if (debug_lvl <= 0) return; + + if (debug_lvl & 1) { // Standard console startup message output + if (from == 0) { // Constructor + + } + } + if (debug_lvl & 2 ) { // Instantiation/Destruction notification + if (from == 0) cout << "Instantiated: FGOutput" << endl; + if (from == 1) cout << "Destroyed: FGOutput" << endl; + } + if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects + } + if (debug_lvl & 8 ) { // Runtime state variables + } + if (debug_lvl & 16) { // Sanity checking + } } diff --git a/src/FDM/JSBSim/FGOutput.h b/src/FDM/JSBSim/FGOutput.h index a22157ec2..a87f6348b 100644 --- a/src/FDM/JSBSim/FGOutput.h +++ b/src/FDM/JSBSim/FGOutput.h @@ -105,7 +105,7 @@ private: enum {otNone, otCSV, otTab, otSocket, otTerminal, otUnknown} Type; ofstream datafile; FGfdmSocket* socket; - void Debug(void); + void Debug(int from); }; //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/src/FDM/JSBSim/FGPiston.cpp b/src/FDM/JSBSim/FGPiston.cpp index de5b7db5f..725499f1a 100644 --- a/src/FDM/JSBSim/FGPiston.cpp +++ b/src/FDM/JSBSim/FGPiston.cpp @@ -48,9 +48,7 @@ static const char *IdHdr = ID_PISTON; CLASS IMPLEMENTATION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ -FGPiston::FGPiston(FGFDMExec* exec, FGConfigFile* Eng_cfg) - : FGEngine(exec), - //these must be initialized this way as they are declared const +FGPiston::FGPiston(FGFDMExec* exec, FGConfigFile* Eng_cfg) : FGEngine(exec), CONVERT_CUBIC_INCHES_TO_METERS_CUBED(1.638706e-5), R_air(287.3), rho_fuel(800), // estimate @@ -58,16 +56,14 @@ FGPiston::FGPiston(FGFDMExec* exec, FGConfigFile* Eng_cfg) Cp_air(1005), Cp_fuel(1700) { - string token; - MinManifoldPressure_inHg=6.5; - MaxManifoldPressure_inHg=28.5; - Displacement=360; - MaxHP=200; - Cycles=2; - IdleRPM=600; - // Set constants + MinManifoldPressure_inHg = 6.5; + MaxManifoldPressure_inHg = 28.5; + Displacement = 360; + MaxHP = 200; + Cycles = 2; + IdleRPM = 600; Name = Eng_cfg->GetValue("NAME"); Eng_cfg->GetNextConfigLine(); @@ -85,23 +81,10 @@ FGPiston::FGPiston(FGFDMExec* exec, FGConfigFile* Eng_cfg) else cerr << "Unhandled token in Engine config file: " << token << endl; } - if (debug_lvl > 0) { - cout << "\n Engine Name: " << Name << endl; - cout << " MinManifoldPressure: " << MinManifoldPressure_inHg << endl; - cout << " MaxManifoldPressure: " << MaxManifoldPressure_inHg << endl; - cout << " Displacement: " << Displacement << endl; - cout << " MaxHP: " << MaxHP << endl; - cout << " Cycles: " << Cycles << endl; - cout << " IdleRPM: " << IdleRPM << endl; - cout << " MaxThrottle: " << MaxThrottle << endl; - cout << " MinThrottle: " << MinThrottle << endl; - cout << " SLFuelFlowMax: " << SLFuelFlowMax << endl; - } - Type = etPiston; crank_counter = 0; - EngineNumber = 0; // FIXME: this should be the actual number - OilTemp_degK = 298; // FIXME: should be initialized in FGEngine + EngineNumber = 0; + OilTemp_degK = 298; dt = State->Getdt(); @@ -123,11 +106,6 @@ FGPiston::FGPiston(FGFDMExec* exec, FGConfigFile* Eng_cfg) *Lookup_Combustion_Efficiency << 1.60 << 0.525; *Lookup_Combustion_Efficiency << 2.00 << 0.345; - cout << endl; - cout << " Combustion Efficiency table:" << endl; - Lookup_Combustion_Efficiency->Print(); - cout << endl; - Power_Mixture_Correlation = new FGTable(13); *Power_Mixture_Correlation << (14.7/1.6) << 78.0; *Power_Mixture_Correlation << 10 << 86.0; @@ -143,27 +121,21 @@ FGPiston::FGPiston(FGFDMExec* exec, FGConfigFile* Eng_cfg) *Power_Mixture_Correlation << 20 << 74.0; *Power_Mixture_Correlation << (14.7/0.6) << 58; - cout << endl; - cout << " Power Mixture Correlation table:" << endl; - Power_Mixture_Correlation->Print(); - cout << endl; - - if (debug_lvl & 2) cout << "Instantiated: FGPiston" << endl; + Debug(0); // Call Debug() routine from constructor if needed } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FGPiston::~FGPiston() { - if (debug_lvl & 2) cout << "Destroyed: FGPiston" << endl; + Debug(1); // Call Debug() routine from constructor if needed } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% double FGPiston::Calculate(double PowerRequired) { - - // FIXME: calculate from actual fuel flow + // FIXME: calculate from actual fuel flow ConsumeFuel(); Throttle = FCS->GetThrottlePos(EngineNumber); @@ -357,10 +329,10 @@ void FGPiston::doFuelFlow(void) /** * Calculate the power produced by the engine. * - *

Currently, the JSBSim propellor model does not allow the + * Currently, the JSBSim propellor model does not allow the * engine to produce enough RPMs to get up to a high horsepower. * When tested with sufficient RPM, it has no trouble reaching - * 200HP.

+ * 200HP. * * Inputs: ManifoldPressure_inHg, p_amb, p_amb_sea_level, RPM, T_amb, * equivalence_ratio, Cycles, MaxHP @@ -522,9 +494,64 @@ void FGPiston::doOilPressure(void) } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -void FGPiston::Debug(void) +// +// The bitmasked value choices are as follows: +// unset: In this case (the default) JSBSim would only print +// out the normally expected messages, essentially echoing +// the config files as they are read. If the environment +// variable is not set, debug_lvl is set to 1 internally +// 0: This requests JSBSim not to output any messages +// whatsoever. +// 1: This value explicity requests the normal JSBSim +// startup messages +// 2: This value asks for a message to be printed out when +// a class is instantiated +// 4: When this value is set, a message is displayed when a +// FGModel object executes its Run() method +// 8: When this value is set, various runtime state variables +// are printed out periodically +// 16: When set various parameters are sanity checked and +// a message is printed out when they go out of bounds + +void FGPiston::Debug(int from) { - //TODO: Add your source code here + if (debug_lvl <= 0) return; + + if (debug_lvl & 1) { // Standard console startup message output + if (from == 0) { // Constructor + + cout << "\n Engine Name: " << Name << endl; + cout << " MinManifoldPressure: " << MinManifoldPressure_inHg << endl; + cout << " MaxManifoldPressure: " << MaxManifoldPressure_inHg << endl; + cout << " Displacement: " << Displacement << endl; + cout << " MaxHP: " << MaxHP << endl; + cout << " Cycles: " << Cycles << endl; + cout << " IdleRPM: " << IdleRPM << endl; + cout << " MaxThrottle: " << MaxThrottle << endl; + cout << " MinThrottle: " << MinThrottle << endl; + cout << " SLFuelFlowMax: " << SLFuelFlowMax << endl; + + cout << endl; + cout << " Combustion Efficiency table:" << endl; + Lookup_Combustion_Efficiency->Print(); + cout << endl; + + cout << endl; + cout << " Power Mixture Correlation table:" << endl; + Power_Mixture_Correlation->Print(); + cout << endl; + + } + } + if (debug_lvl & 2 ) { // Instantiation/Destruction notification + if (from == 0) cout << "Instantiated: FGPiston" << endl; + if (from == 1) cout << "Destroyed: FGPiston" << endl; + } + if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects + } + if (debug_lvl & 8 ) { // Runtime state variables + } + if (debug_lvl & 16) { // Sanity checking + } } diff --git a/src/FDM/JSBSim/FGPiston.h b/src/FDM/JSBSim/FGPiston.h index 7aab17ebb..7d9eb1916 100644 --- a/src/FDM/JSBSim/FGPiston.h +++ b/src/FDM/JSBSim/FGPiston.h @@ -156,7 +156,7 @@ private: double HP; double combustion_efficiency; - void Debug(void); + void Debug(int from); }; //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/src/FDM/JSBSim/FGPosition.cpp b/src/FDM/JSBSim/FGPosition.cpp index cc3a95cef..33f244dfb 100644 --- a/src/FDM/JSBSim/FGPosition.cpp +++ b/src/FDM/JSBSim/FGPosition.cpp @@ -103,14 +103,14 @@ FGPosition::FGPosition(FGFDMExec* fdmex) : FGModel(fdmex) Longitude = Latitude = 0.0; gamma = Vt = Vground = 0.0; - if (debug_lvl & 2) cout << "Instantiated: " << Name << endl; + Debug(0); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -FGPosition::~FGPosition() +FGPosition::~FGPosition(void) { - if (debug_lvl & 2) cout << "Destroyed: FGPosition" << endl; + Debug(1); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -226,9 +226,42 @@ void FGPosition::SetDistanceAGL(double tt) { } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -void FGPosition::Debug(void) +// The bitmasked value choices are as follows: +// unset: In this case (the default) JSBSim would only print +// out the normally expected messages, essentially echoing +// the config files as they are read. If the environment +// variable is not set, debug_lvl is set to 1 internally +// 0: This requests JSBSim not to output any messages +// whatsoever. +// 1: This value explicity requests the normal JSBSim +// startup messages +// 2: This value asks for a message to be printed out when +// a class is instantiated +// 4: When this value is set, a message is displayed when a +// FGModel object executes its Run() method +// 8: When this value is set, various runtime state variables +// are printed out periodically +// 16: When set various parameters are sanity checked and +// a message is printed out when they go out of bounds + +void FGPosition::Debug(int from) { - //TODO: Add your source code here + if (debug_lvl <= 0) return; + + if (debug_lvl & 1) { // Standard console startup message output + if (from == 0) { // Constructor + + } + } + if (debug_lvl & 2 ) { // Instantiation/Destruction notification + if (from == 0) cout << "Instantiated: FGPosition" << endl; + if (from == 1) cout << "Destroyed: FGPosition" << endl; + } + if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects + } + if (debug_lvl & 8 ) { // Runtime state variables + } + if (debug_lvl & 16) { // Sanity checking + } } diff --git a/src/FDM/JSBSim/FGPosition.h b/src/FDM/JSBSim/FGPosition.h index 86479afa4..0e91ab26f 100644 --- a/src/FDM/JSBSim/FGPosition.h +++ b/src/FDM/JSBSim/FGPosition.h @@ -139,7 +139,7 @@ private: double psigt; void GetState(void); - void Debug(void); + void Debug(int from); }; //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/src/FDM/JSBSim/FGPropeller.cpp b/src/FDM/JSBSim/FGPropeller.cpp index 9ae5abcdd..92e4c5340 100644 --- a/src/FDM/JSBSim/FGPropeller.cpp +++ b/src/FDM/JSBSim/FGPropeller.cpp @@ -45,6 +45,10 @@ static const char *IdHdr = ID_PROPELLER; CLASS IMPLEMENTATION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ +// This class currently makes certain assumptions when calculating torque and +// p-factor. That is, that the axis of rotation is the X axis of the aircraft - +// not just the X-axis of the engine/propeller. This may or may not work for a +// helicopter. FGPropeller::FGPropeller(FGFDMExec* exec, FGConfigFile* Prop_cfg) : FGThruster(exec) { @@ -90,24 +94,11 @@ FGPropeller::FGPropeller(FGFDMExec* exec, FGConfigFile* Prop_cfg) : FGThruster(e } } - if (debug_lvl > 0) { - cout << "\n Propeller Name: " << Name << endl; - cout << " IXX = " << Ixx << endl; - cout << " Diameter = " << Diameter << " ft." << endl; - cout << " Number of Blades = " << numBlades << endl; - cout << " Minimum Pitch = " << MinPitch << endl; - cout << " Maximum Pitch = " << MaxPitch << endl; - cout << " Thrust Coefficient: " << endl; - cThrust->Print(); - cout << " Power Coefficient: " << endl; - cPower->Print(); - } - Type = ttPropeller; RPM = 0; vTorque.InitMatrix(); - if (debug_lvl & 2) cout << "Instantiated: FGPropeller" << endl; + Debug(0); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -116,7 +107,7 @@ FGPropeller::~FGPropeller() { if (cThrust) delete cThrust; if (cPower) delete cPower; - if (debug_lvl & 2) cout << "Destroyed: FGPropeller" << endl; + Debug(1); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -224,8 +215,62 @@ double FGPropeller::GetPowerRequired(void) //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -void FGPropeller::Debug(void) +FGColumnVector3 FGPropeller::GetPFactor() +{ + double px=0.0, py, pz; + + py = Thrust * Sense * (GetActingLocationY() - GetLocationY()) / 12.0; + pz = Thrust * Sense * (GetActingLocationZ() - GetLocationZ()) / 12.0; + + return FGColumnVector3(px, py, pz); +} + +//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +// The bitmasked value choices are as follows: +// unset: In this case (the default) JSBSim would only print +// out the normally expected messages, essentially echoing +// the config files as they are read. If the environment +// variable is not set, debug_lvl is set to 1 internally +// 0: This requests JSBSim not to output any messages +// whatsoever. +// 1: This value explicity requests the normal JSBSim +// startup messages +// 2: This value asks for a message to be printed out when +// a class is instantiated +// 4: When this value is set, a message is displayed when a +// FGModel object executes its Run() method +// 8: When this value is set, various runtime state variables +// are printed out periodically +// 16: When set various parameters are sanity checked and +// a message is printed out when they go out of bounds + +void FGPropeller::Debug(int from) { - //TODO: Add your source code here + if (debug_lvl <= 0) return; + + if (debug_lvl & 1) { // Standard console startup message output + if (from == 0) { // Constructor + cout << "\n Propeller Name: " << Name << endl; + cout << " IXX = " << Ixx << endl; + cout << " Diameter = " << Diameter << " ft." << endl; + cout << " Number of Blades = " << numBlades << endl; + cout << " Minimum Pitch = " << MinPitch << endl; + cout << " Maximum Pitch = " << MaxPitch << endl; + cout << " Thrust Coefficient: " << endl; + cThrust->Print(); + cout << " Power Coefficient: " << endl; + cPower->Print(); + } + } + if (debug_lvl & 2 ) { // Instantiation/Destruction notification + if (from == 0) cout << "Instantiated: FGPropeller" << endl; + if (from == 1) cout << "Destroyed: FGPropeller" << endl; + } + if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects + } + if (debug_lvl & 8 ) { // Runtime state variables + } + if (debug_lvl & 16) { // Sanity checking + } } diff --git a/src/FDM/JSBSim/FGPropeller.h b/src/FDM/JSBSim/FGPropeller.h index 23c9aaadc..14fe39bdd 100644 --- a/src/FDM/JSBSim/FGPropeller.h +++ b/src/FDM/JSBSim/FGPropeller.h @@ -1,171 +1,180 @@ -/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - Header: FGPropeller.h - Author: Jon S. Berndt - Date started: 08/24/00 - - ------------- Copyright (C) 2000 Jon S. Berndt (jsb@hal-pc.org) ------------- - - This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software - Foundation; either version 2 of the License, or (at your option) any later - version. - - This program is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - details. - - You should have received a copy of the GNU General Public License along with - this program; if not, write to the Free Software Foundation, Inc., 59 Temple - Place - Suite 330, Boston, MA 02111-1307, USA. - - Further information about the GNU General Public License can also be found on - the world wide web at http://www.gnu.org. - -HISTORY --------------------------------------------------------------------------------- -08/24/00 JSB Created - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -SENTRY -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ - -#ifndef FGPROPELLER_H -#define FGPROPELLER_H - -/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -INCLUDES -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ - -#include "FGThruster.h" -#include "FGTable.h" -#include "FGTranslation.h" -#include "FGRotation.h" - -/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -DEFINITIONS -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ - -#define ID_PROPELLER "$Id$" - -/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -FORWARD DECLARATIONS -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ - -/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -COMMENTS, REFERENCES, and NOTES [use "class documentation" below for API docs] -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ - -/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -CLASS DOCUMENTATION -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ - -/** Propeller modeling class. - FGPropeller models a propeller given the tabular data for Ct and Cp - indexed by advance ratio "J". The data for the propeller is - stored in a config file named "prop_name.xml". The propeller config file - is referenced from the main aircraft config file in the "Propulsion" section. - See the constructor for FGPropeller to see what is read in and what should - be stored in the config file.
- Several references were helpful, here:
    -
  • Barnes W. McCormick, "Aerodynamics, Aeronautics, and Flight Mechanics", - Wiley & Sons, 1979 ISBN 0-471-03032-5
  • -
  • Edwin Hartman, David Biermann, "The Aerodynamic Characteristics of - Full Scale Propellers Having 2, 3, and 4 Blades of Clark Y and R.A.F. 6 - Airfoil Sections", NACA Report TN-640, 1938 (?)
  • -
  • Various NACA Technical Notes and Reports
  • -
      - @author Jon S. Berndt - @version $Id$ - @see FGEngine - @see FGThruster - @see FGTable -*/ - -/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -CLASS DECLARATION -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ - -class FGPropeller : public FGThruster { - -public: - /** Constructor for FGPropeller. - @param exec a pointer to the main executive object - @param AC_cfg a pointer to the main aircraft config file object */ - FGPropeller(FGFDMExec* exec, FGConfigFile* AC_cfg); - - /// Destructor for FGPropeller - deletes the FGTable objects - ~FGPropeller(); - - /** Sets the Revolutions Per Minute for the propeller. Normally the propeller - instance will calculate its own rotational velocity, given the Torque - produced by the engine and integrating over time using the standard - equation for rotational acceleration "a": a = Q/I , where Q is Torque and - I is moment of inertia for the propeller. - @param rpm the rotational velocity of the propeller */ - void SetRPM(double rpm) {RPM = rpm;} - - /** This commands the pitch of the blade to change to the value supplied. - This call is meant to be issued either from the cockpit or by the flight - control system (perhaps to maintain constant RPM for a constant-speed - propeller). This value will be limited to be within whatever is specified - in the config file for Max and Min pitch. It is also one of the lookup - indices to the power and thrust tables for variable-pitch propellers. - @param pitch the pitch of the blade in degrees. */ - void SetPitch(double pitch) {Pitch = pitch;} - - void SetPFactor(double pf) {P_Factor = pf;} - - void SetSense(double s) { Sense = s;} - - /// Retrieves the pitch of the propeller in degrees. - double GetPitch(void) { return Pitch; } - - /// Retrieves the RPMs of the propeller - double GetRPM(void) { return RPM; } - - /// Retrieves the propeller moment of inertia - double GetIxx(void) { return Ixx; } - - /// Retrieves the Torque in foot-pounds (Don't you love the English system?) - double GetTorque(void) { return vTorque(eX); } - - /** Retrieves the power required (or "absorbed") by the propeller - - i.e. the power required to keep spinning the propeller at the current - velocity, air density, and rotational rate. */ - double GetPowerRequired(void); - - /** Calculates and returns the thrust produced by this propeller. - Given the excess power available from the engine (in foot-pounds), the thrust is - calculated, as well as the current RPM. The RPM is calculated by integrating - the torque provided by the engine over what the propeller "absorbs" - (essentially the "drag" of the propeller). - @param PowerAvailable this is the excess power provided by the engine to - accelerate the prop. It could be negative, dictating that the propeller - would be slowed. - @return the thrust in pounds */ - double Calculate(double PowerAvailable); - -private: - int numBlades; - double RPM; - double Ixx; - double Diameter; - double MaxPitch; - double MinPitch; - double MinRPM; - double MaxRPM; - double P_Factor; - double Sense; - double Pitch; - double ExcessTorque; - FGColumnVector3 vTorque; - FGTable *cThrust; - FGTable *cPower; - void Debug(void); -}; - -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -#endif - +/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + Header: FGPropeller.h + Author: Jon S. Berndt + Date started: 08/24/00 + + ------------- Copyright (C) 2000 Jon S. Berndt (jsb@hal-pc.org) ------------- + + This program is free software; you can redistribute it and/or modify it under + the terms of the GNU General Public License as published by the Free Software + Foundation; either version 2 of the License, or (at your option) any later + version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + details. + + You should have received a copy of the GNU General Public License along with + this program; if not, write to the Free Software Foundation, Inc., 59 Temple + Place - Suite 330, Boston, MA 02111-1307, USA. + + Further information about the GNU General Public License can also be found on + the world wide web at http://www.gnu.org. + +HISTORY +-------------------------------------------------------------------------------- +08/24/00 JSB Created + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +SENTRY +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ + +#ifndef FGPROPELLER_H +#define FGPROPELLER_H + +/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +INCLUDES +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ + +#include "FGThruster.h" +#include "FGTable.h" +#include "FGTranslation.h" +#include "FGRotation.h" + +/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +DEFINITIONS +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ + +#define ID_PROPELLER "$Id$" + +/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +FORWARD DECLARATIONS +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ + +/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +COMMENTS, REFERENCES, and NOTES [use "class documentation" below for API docs] +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ + +/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +CLASS DOCUMENTATION +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ + +/** Propeller modeling class. + FGPropeller models a propeller given the tabular data for Ct and Cp + indexed by advance ratio "J". The data for the propeller is + stored in a config file named "prop_name.xml". The propeller config file + is referenced from the main aircraft config file in the "Propulsion" section. + See the constructor for FGPropeller to see what is read in and what should + be stored in the config file.
      + Several references were helpful, here:
        +
      • Barnes W. McCormick, "Aerodynamics, Aeronautics, and Flight Mechanics", + Wiley & Sons, 1979 ISBN 0-471-03032-5
      • +
      • Edwin Hartman, David Biermann, "The Aerodynamic Characteristics of + Full Scale Propellers Having 2, 3, and 4 Blades of Clark Y and R.A.F. 6 + Airfoil Sections", NACA Report TN-640, 1938 (?)
      • +
      • Various NACA Technical Notes and Reports
      • +
          + @author Jon S. Berndt + @version $Id$ + @see FGEngine + @see FGThruster + @see FGTable +*/ + +/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +CLASS DECLARATION +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ + +class FGPropeller : public FGThruster { + +public: + /** Constructor for FGPropeller. + @param exec a pointer to the main executive object + @param AC_cfg a pointer to the main aircraft config file object */ + FGPropeller(FGFDMExec* exec, FGConfigFile* AC_cfg); + + /// Destructor for FGPropeller - deletes the FGTable objects + ~FGPropeller(); + + /** Sets the Revolutions Per Minute for the propeller. Normally the propeller + instance will calculate its own rotational velocity, given the Torque + produced by the engine and integrating over time using the standard + equation for rotational acceleration "a": a = Q/I , where Q is Torque and + I is moment of inertia for the propeller. + @param rpm the rotational velocity of the propeller */ + void SetRPM(double rpm) {RPM = rpm;} + + /// Returns true of this propeller is variable pitch + bool IsVPitch(void) {return MaxPitch != MinPitch;} + + /** This commands the pitch of the blade to change to the value supplied. + This call is meant to be issued either from the cockpit or by the flight + control system (perhaps to maintain constant RPM for a constant-speed + propeller). This value will be limited to be within whatever is specified + in the config file for Max and Min pitch. It is also one of the lookup + indices to the power and thrust tables for variable-pitch propellers. + @param pitch the pitch of the blade in degrees. */ + void SetPitch(double pitch) {Pitch = pitch;} + + /// Sets the P-Factor constant + void SetPFactor(double pf) {P_Factor = pf;} + + /** Sets the rotation sense of the propeller. + @param s this value should be +/- 1 ONLY. +1 indicates clockwise rotation as + viewed by someone standing behind the engine looking forward into + the direction of flight. */ + void SetSense(double s) { Sense = s;} + + /// Retrieves the pitch of the propeller in degrees. + double GetPitch(void) { return Pitch; } + + /// Retrieves the RPMs of the propeller + double GetRPM(void) { return RPM; } + + /// Retrieves the propeller moment of inertia + double GetIxx(void) { return Ixx; } + + /// Retrieves the Torque in foot-pounds (Don't you love the English system?) + double GetTorque(void) { return vTorque(eX); } + + /** Retrieves the power required (or "absorbed") by the propeller - + i.e. the power required to keep spinning the propeller at the current + velocity, air density, and rotational rate. */ + double GetPowerRequired(void); + + /** Calculates and returns the thrust produced by this propeller. + Given the excess power available from the engine (in foot-pounds), the thrust is + calculated, as well as the current RPM. The RPM is calculated by integrating + the torque provided by the engine over what the propeller "absorbs" + (essentially the "drag" of the propeller). + @param PowerAvailable this is the excess power provided by the engine to + accelerate the prop. It could be negative, dictating that the propeller + would be slowed. + @return the thrust in pounds */ + double Calculate(double PowerAvailable); + FGColumnVector3 GetPFactor(void); + +private: + int numBlades; + double RPM; + double Ixx; + double Diameter; + double MaxPitch; + double MinPitch; + double MinRPM; + double MaxRPM; + double P_Factor; + double Sense; + double Pitch; + double ExcessTorque; + FGColumnVector3 vTorque; + FGTable *cThrust; + FGTable *cPower; + void Debug(int from); +}; + +//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +#endif + diff --git a/src/FDM/JSBSim/FGPropulsion.cpp b/src/FDM/JSBSim/FGPropulsion.cpp index e8a148e1f..177e954fe 100644 --- a/src/FDM/JSBSim/FGPropulsion.cpp +++ b/src/FDM/JSBSim/FGPropulsion.cpp @@ -61,7 +61,6 @@ static const char *IdHdr = ID_PROPULSION; CLASS IMPLEMENTATION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ - FGPropulsion::FGPropulsion(FGFDMExec* exec) : FGModel(exec) { Name = "FGPropulsion"; @@ -69,7 +68,7 @@ FGPropulsion::FGPropulsion(FGFDMExec* exec) : FGModel(exec) numTanks = numEngines = numThrusters = 0; numOxiTanks = numFuelTanks = 0; - if (debug_lvl & 2) cout << "Instantiated: " << Name << endl; + Debug(0); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -78,7 +77,7 @@ FGPropulsion::~FGPropulsion() { for (unsigned int i=0; iSetAnglesToBody(0, Pitch, Yaw); if (thrType == "FG_PROPELLER" && P_Factor > 0.001) { ((FGPropeller*)Thrusters[numThrusters])->SetPFactor(P_Factor); - cout << " P-Factor: " << P_Factor << endl; + if (debug_lvl > 0) cout << " P-Factor: " << P_Factor << endl; ((FGPropeller*)Thrusters[numThrusters])->SetSense(Sense); - cout << " Sense: " << Sense << endl; + if (debug_lvl > 0) cout << " Sense: " << Sense << endl; } Thrusters[numThrusters]->SetdeltaT(dt*rate); Thrusters[numThrusters]->SetThrusterNumber(numThrusters); @@ -373,6 +371,7 @@ string FGPropulsion::GetPropulsionStrings(void) PropulsionStrings += ", "; + FGPropeller* Propeller = (FGPropeller*)Thrusters[i]; switch(Thrusters[i]->GetType()) { case FGThruster::ttNozzle: PropulsionStrings += (Thrusters[i]->GetName() + "_Thrust[" + buffer + "]"); @@ -381,7 +380,12 @@ string FGPropulsion::GetPropulsionStrings(void) break; case FGThruster::ttPropeller: PropulsionStrings += (Thrusters[i]->GetName() + "_Torque[" + buffer + "], "); + PropulsionStrings += (Thrusters[i]->GetName() + "_PFactor_Roll[" + buffer + "], "); + PropulsionStrings += (Thrusters[i]->GetName() + "_PFactor_Pitch[" + buffer + "], "); + PropulsionStrings += (Thrusters[i]->GetName() + "_PFactor_Yaw[" + buffer + "], "); PropulsionStrings += (Thrusters[i]->GetName() + "_Thrust[" + buffer + "], "); + if (Propeller->IsVPitch()) + PropulsionStrings += (Thrusters[i]->GetName() + "_Pitch[" + buffer + "], "); PropulsionStrings += (Thrusters[i]->GetName() + "_RPM[" + buffer + "]"); break; default: @@ -427,9 +431,16 @@ string FGPropulsion::GetPropulsionValues(void) case FGThruster::ttRotor: break; case FGThruster::ttPropeller: - PropulsionValues += (string(gcvt(((FGPropeller*)Thrusters[i])->GetTorque(), 10, buff)) + ", "); - PropulsionValues += (string(gcvt(((FGPropeller*)Thrusters[i])->GetThrust(), 10, buff)) + ", "); - PropulsionValues += (string(gcvt(((FGPropeller*)Thrusters[i])->GetRPM(), 10, buff))); + FGPropeller* Propeller = (FGPropeller*)Thrusters[i]; + FGColumnVector3 vPFactor = Propeller->GetPFactor(); + PropulsionValues += string(gcvt(Propeller->GetTorque(), 10, buff)) + ", "; + PropulsionValues += string(gcvt(vPFactor(eRoll), 10, buff)) + ", "; + PropulsionValues += string(gcvt(vPFactor(ePitch), 10, buff)) + ", "; + PropulsionValues += string(gcvt(vPFactor(eYaw), 10, buff)) + ", "; + PropulsionValues += string(gcvt(Propeller->GetThrust(), 10, buff)) + ", "; + if (Propeller->IsVPitch()) + PropulsionValues += string(gcvt(Propeller->GetPitch(), 10, buff)) + ", "; + PropulsionValues += string(gcvt(Propeller->GetRPM(), 10, buff)); break; } } @@ -532,9 +543,42 @@ double FGPropulsion::GetTanksIxy(const FGColumnVector3& vXYZcg) } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -void FGPropulsion::Debug(void) +// The bitmasked value choices are as follows: +// unset: In this case (the default) JSBSim would only print +// out the normally expected messages, essentially echoing +// the config files as they are read. If the environment +// variable is not set, debug_lvl is set to 1 internally +// 0: This requests JSBSim not to output any messages +// whatsoever. +// 1: This value explicity requests the normal JSBSim +// startup messages +// 2: This value asks for a message to be printed out when +// a class is instantiated +// 4: When this value is set, a message is displayed when a +// FGModel object executes its Run() method +// 8: When this value is set, various runtime state variables +// are printed out periodically +// 16: When set various parameters are sanity checked and +// a message is printed out when they go out of bounds + +void FGPropulsion::Debug(int from) { - //TODO: Add your source code here + if (debug_lvl <= 0) return; + + if (debug_lvl & 1) { // Standard console startup message output + if (from == 0) { // Constructor + + } + } + if (debug_lvl & 2 ) { // Instantiation/Destruction notification + if (from == 0) cout << "Instantiated: FGPropulsion" << endl; + if (from == 1) cout << "Destroyed: FGPropulsion" << endl; + } + if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects + } + if (debug_lvl & 8 ) { // Runtime state variables + } + if (debug_lvl & 16) { // Sanity checking + } } diff --git a/src/FDM/JSBSim/FGPropulsion.h b/src/FDM/JSBSim/FGPropulsion.h index 6cb2342a8..6072da1b1 100644 --- a/src/FDM/JSBSim/FGPropulsion.h +++ b/src/FDM/JSBSim/FGPropulsion.h @@ -198,7 +198,7 @@ private: FGColumnVector3 vForces; FGColumnVector3 vMoments; FGColumnVector3 vXYZtank; - void Debug(void); + void Debug(int from); }; //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/src/FDM/JSBSim/FGRocket.cpp b/src/FDM/JSBSim/FGRocket.cpp index 9a2e7bba5..c5ca65d68 100644 --- a/src/FDM/JSBSim/FGRocket.cpp +++ b/src/FDM/JSBSim/FGRocket.cpp @@ -67,32 +67,20 @@ FGRocket::FGRocket(FGFDMExec* exec, FGConfigFile* Eng_cfg) : FGEngine(exec) else cerr << "Unhandled token in Engine config file: " << token << endl; } - if (debug_lvl > 0) { - cout << " Engine Name: " << Name << endl; - cout << " Specific Heat Ratio = " << SHR << endl; - cout << " Maximum Chamber Pressure = " << maxPC << endl; - cout << " Propulsive Efficiency = " << propEff << endl; - cout << " MaxThrottle = " << MaxThrottle << endl; - cout << " MinThrottle = " << MinThrottle << endl; - cout << " FuelFlowMax = " << SLFuelFlowMax << endl; - cout << " OxiFlowMax = " << SLOxiFlowMax << endl; - cout << " Variance = " << Variance << endl; - } + Debug(0); EngineNumber = 0; Type = etRocket; PC = 0.0; kFactor = (2.0*SHR*SHR/(SHR-1.0))*pow(2.0/(SHR+1), (SHR+1)/(SHR-1)); - - if (debug_lvl & 2) cout << "Instantiated: FGRocket" << endl; } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FGRocket::~FGRocket() { - if (debug_lvl & 2) cout << "Destroyed: FGRocket" << endl; + Debug(1); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -120,9 +108,50 @@ double FGRocket::Calculate(double pe) } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -void FGRocket::Debug(void) +// The bitmasked value choices are as follows: +// unset: In this case (the default) JSBSim would only print +// out the normally expected messages, essentially echoing +// the config files as they are read. If the environment +// variable is not set, debug_lvl is set to 1 internally +// 0: This requests JSBSim not to output any messages +// whatsoever. +// 1: This value explicity requests the normal JSBSim +// startup messages +// 2: This value asks for a message to be printed out when +// a class is instantiated +// 4: When this value is set, a message is displayed when a +// FGModel object executes its Run() method +// 8: When this value is set, various runtime state variables +// are printed out periodically +// 16: When set various parameters are sanity checked and +// a message is printed out when they go out of bounds + +void FGRocket::Debug(int from) { - //TODO: Add your source code here + if (debug_lvl <= 0) return; + + if (debug_lvl & 1) { // Standard console startup message output + if (from == 0) { // Constructor + cout << " Engine Name: " << Name << endl; + cout << " Specific Heat Ratio = " << SHR << endl; + cout << " Maximum Chamber Pressure = " << maxPC << endl; + cout << " Propulsive Efficiency = " << propEff << endl; + cout << " MaxThrottle = " << MaxThrottle << endl; + cout << " MinThrottle = " << MinThrottle << endl; + cout << " FuelFlowMax = " << SLFuelFlowMax << endl; + cout << " OxiFlowMax = " << SLOxiFlowMax << endl; + cout << " Variance = " << Variance << endl; + } + } + if (debug_lvl & 2 ) { // Instantiation/Destruction notification + if (from == 0) cout << "Instantiated: FGRocket" << endl; + if (from == 1) cout << "Destroyed: FGRocket" << endl; + } + if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects + } + if (debug_lvl & 8 ) { // Runtime state variables + } + if (debug_lvl & 16) { // Sanity checking + } } diff --git a/src/FDM/JSBSim/FGRocket.h b/src/FDM/JSBSim/FGRocket.h index 35b49de9c..dd54ae2a0 100644 --- a/src/FDM/JSBSim/FGRocket.h +++ b/src/FDM/JSBSim/FGRocket.h @@ -129,7 +129,7 @@ private: double kFactor; double Variance; double PC; - void Debug(void); + void Debug(int from); }; //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/src/FDM/JSBSim/FGRotation.cpp b/src/FDM/JSBSim/FGRotation.cpp index d7a440040..e56205b02 100644 --- a/src/FDM/JSBSim/FGRotation.cpp +++ b/src/FDM/JSBSim/FGRotation.cpp @@ -81,14 +81,14 @@ FGRotation::FGRotation(FGFDMExec* fdmex) : FGModel(fdmex) cTht=cPhi=cPsi=1.0; sTht=sPhi=sPsi=0.0; - if (debug_lvl & 2) cout << "Instantiated: " << Name << endl; + Debug(0); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FGRotation::~FGRotation() { - if (debug_lvl & 2) cout << "Destroyed: FGRotation" << endl; + Debug(1); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -128,7 +128,7 @@ bool FGRotation::Run(void) vlastPQRdot = vPQRdot; - if (debug_lvl > 1) Debug(); + if (debug_lvl > 1) Debug(2); return false; } else { @@ -150,16 +150,49 @@ void FGRotation::GetState(void) } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -void FGRotation::Debug(void) +// The bitmasked value choices are as follows: +// unset: In this case (the default) JSBSim would only print +// out the normally expected messages, essentially echoing +// the config files as they are read. If the environment +// variable is not set, debug_lvl is set to 1 internally +// 0: This requests JSBSim not to output any messages +// whatsoever. +// 1: This value explicity requests the normal JSBSim +// startup messages +// 2: This value asks for a message to be printed out when +// a class is instantiated +// 4: When this value is set, a message is displayed when a +// FGModel object executes its Run() method +// 8: When this value is set, various runtime state variables +// are printed out periodically +// 16: When set various parameters are sanity checked and +// a message is printed out when they go out of bounds + +void FGRotation::Debug(int from) { + if (debug_lvl <= 0) return; + + if (debug_lvl & 1) { // Standard console startup message output + if (from == 0) { // Constructor + + } + } + if (debug_lvl & 2 ) { // Instantiation/Destruction notification + if (from == 0) cout << "Instantiated: FGRotation" << endl; + if (from == 1) cout << "Destroyed: FGRotation" << endl; + } + if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects + } + if (debug_lvl & 8 ) { // Runtime state variables + } if (debug_lvl & 16) { // Sanity check variables - if (fabs(vPQR(eP)) > 100) - cout << "FGRotation::P (Roll Rate) out of bounds: " << vPQR(eP) << endl; - if (fabs(vPQR(eQ)) > 100) - cout << "FGRotation::Q (Pitch Rate) out of bounds: " << vPQR(eQ) << endl; - if (fabs(vPQR(eR)) > 100) - cout << "FGRotation::R (Yaw Rate) out of bounds: " << vPQR(eR) << endl; + if (from == 2) { + if (fabs(vPQR(eP)) > 100) + cout << "FGRotation::P (Roll Rate) out of bounds: " << vPQR(eP) << endl; + if (fabs(vPQR(eQ)) > 100) + cout << "FGRotation::Q (Pitch Rate) out of bounds: " << vPQR(eQ) << endl; + if (fabs(vPQR(eR)) > 100) + cout << "FGRotation::R (Yaw Rate) out of bounds: " << vPQR(eR) << endl; + } } } - diff --git a/src/FDM/JSBSim/FGRotation.h b/src/FDM/JSBSim/FGRotation.h index 7bd3f61d6..3952a4f39 100644 --- a/src/FDM/JSBSim/FGRotation.h +++ b/src/FDM/JSBSim/FGRotation.h @@ -129,7 +129,7 @@ private: void GetState(void); - void Debug(void); + void Debug(int from); }; //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/src/FDM/JSBSim/FGRotor.cpp b/src/FDM/JSBSim/FGRotor.cpp index 51bc5d491..195795bbc 100644 --- a/src/FDM/JSBSim/FGRotor.cpp +++ b/src/FDM/JSBSim/FGRotor.cpp @@ -47,14 +47,14 @@ CLASS IMPLEMENTATION FGRotor::FGRotor(FGFDMExec *FDMExec) : FGThruster(FDMExec) { - if (debug_lvl & 2) cout << "Instantiated: FGRotor" << endl; + Debug(0); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FGRotor::~FGRotor() { - if (debug_lvl & 2) cout << "Destroyed: FGRotor" << endl; + Debug(1); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -65,10 +65,42 @@ double FGRotor::Calculate(double PowerAvailable) } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -void FGRotor::Debug(void) +// The bitmasked value choices are as follows: +// unset: In this case (the default) JSBSim would only print +// out the normally expected messages, essentially echoing +// the config files as they are read. If the environment +// variable is not set, debug_lvl is set to 1 internally +// 0: This requests JSBSim not to output any messages +// whatsoever. +// 1: This value explicity requests the normal JSBSim +// startup messages +// 2: This value asks for a message to be printed out when +// a class is instantiated +// 4: When this value is set, a message is displayed when a +// FGModel object executes its Run() method +// 8: When this value is set, various runtime state variables +// are printed out periodically +// 16: When set various parameters are sanity checked and +// a message is printed out when they go out of bounds + +void FGRotor::Debug(int from) { - //TODO: Add your source code here + if (debug_lvl <= 0) return; + + if (debug_lvl & 1) { // Standard console startup message output + if (from == 0) { // Constructor + + } + } + if (debug_lvl & 2 ) { // Instantiation/Destruction notification + if (from == 0) cout << "Instantiated: FGRotor" << endl; + if (from == 1) cout << "Destroyed: FGRotor" << endl; + } + if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects + } + if (debug_lvl & 8 ) { // Runtime state variables + } + if (debug_lvl & 16) { // Sanity checking + } } - diff --git a/src/FDM/JSBSim/FGRotor.h b/src/FDM/JSBSim/FGRotor.h index a13408408..dde526de5 100644 --- a/src/FDM/JSBSim/FGRotor.h +++ b/src/FDM/JSBSim/FGRotor.h @@ -59,7 +59,7 @@ public: double Calculate(double); private: - void Debug(void); + void Debug(int from); }; //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/src/FDM/JSBSim/FGState.cpp b/src/FDM/JSBSim/FGState.cpp index 5e3996a19..c36af44e8 100644 --- a/src/FDM/JSBSim/FGState.cpp +++ b/src/FDM/JSBSim/FGState.cpp @@ -153,14 +153,14 @@ FGState::FGState(FGFDMExec* fdex) RegisterVariable(FG_VBARV, " v-tail volume " ); RegisterVariable(FG_SET_LOGGING, " data_logging " ); - if (debug_lvl & 2) cout << "Instantiated: FGState" << endl; + Debug(0); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FGState::~FGState() { - if (debug_lvl & 2) cout << "Destroyed: FGState" << endl; + Debug(1); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -843,9 +843,42 @@ void FGState::ReportState(void) { } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -void FGState::Debug(void) +// The bitmasked value choices are as follows: +// unset: In this case (the default) JSBSim would only print +// out the normally expected messages, essentially echoing +// the config files as they are read. If the environment +// variable is not set, debug_lvl is set to 1 internally +// 0: This requests JSBSim not to output any messages +// whatsoever. +// 1: This value explicity requests the normal JSBSim +// startup messages +// 2: This value asks for a message to be printed out when +// a class is instantiated +// 4: When this value is set, a message is displayed when a +// FGModel object executes its Run() method +// 8: When this value is set, various runtime state variables +// are printed out periodically +// 16: When set various parameters are sanity checked and +// a message is printed out when they go out of bounds + +void FGState::Debug(int from) { - //TODO: Add your source code here + if (debug_lvl <= 0) return; + + if (debug_lvl & 1) { // Standard console startup message output + if (from == 0) { // Constructor + + } + } + if (debug_lvl & 2 ) { // Instantiation/Destruction notification + if (from == 0) cout << "Instantiated: FGState" << endl; + if (from == 1) cout << "Destroyed: FGState" << endl; + } + if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects + } + if (debug_lvl & 8 ) { // Runtime state variables + } + if (debug_lvl & 16) { // Sanity checking + } } diff --git a/src/FDM/JSBSim/FGState.h b/src/FDM/JSBSim/FGState.h index a60abaea1..b3e7267e5 100644 --- a/src/FDM/JSBSim/FGState.h +++ b/src/FDM/JSBSim/FGState.h @@ -340,8 +340,8 @@ private: typedef map CoeffMap; CoeffMap coeffdef; - void Debug(void); int ActiveEngine; + void Debug(int from); }; //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/src/FDM/JSBSim/FGTable.cpp b/src/FDM/JSBSim/FGTable.cpp index 58e7e688b..0c564a1c7 100644 --- a/src/FDM/JSBSim/FGTable.cpp +++ b/src/FDM/JSBSim/FGTable.cpp @@ -69,7 +69,7 @@ FGTable::FGTable(int NRows, int NCols) : nRows(NRows), nCols(NCols) Data = Allocate(); - if (debug_lvl & 2) cout << "Instantiated: FGTable" << endl; + Debug(0); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -81,7 +81,7 @@ FGTable::FGTable(int NRows) : nRows(NRows), nCols(1) rowCounter = 1; Data = Allocate(); - if (debug_lvl & 2) cout << "Instantiated: FGTable" << endl; + Debug(0); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -104,7 +104,7 @@ FGTable::~FGTable() { for (int r=0; r<=nRows; r++) if (Data[r]) delete[] Data[r]; if (Data) delete[] Data; - if (debug_lvl & 2) cout << "Destroyed: FGTable" << endl; + Debug(1); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -202,14 +202,6 @@ FGTable& FGTable::operator<<(const int n) return *this; } -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -/* -FGTable& FGTable::operator<<(const double n) -{ - *this << (double)n; - return *this; -} -*/ //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% void FGTable::Print(void) @@ -237,10 +229,43 @@ void FGTable::Print(void) } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -void FGTable::Debug(void) +// The bitmasked value choices are as follows: +// unset: In this case (the default) JSBSim would only print +// out the normally expected messages, essentially echoing +// the config files as they are read. If the environment +// variable is not set, debug_lvl is set to 1 internally +// 0: This requests JSBSim not to output any messages +// whatsoever. +// 1: This value explicity requests the normal JSBSim +// startup messages +// 2: This value asks for a message to be printed out when +// a class is instantiated +// 4: When this value is set, a message is displayed when a +// FGModel object executes its Run() method +// 8: When this value is set, various runtime state variables +// are printed out periodically +// 16: When set various parameters are sanity checked and +// a message is printed out when they go out of bounds + +void FGTable::Debug(int from) { - //TODO: Add your source code here + if (debug_lvl <= 0) return; + + if (debug_lvl & 1) { // Standard console startup message output + if (from == 0) { // Constructor + + } + } + if (debug_lvl & 2 ) { // Instantiation/Destruction notification + if (from == 0) cout << "Instantiated: FGTable" << endl; + if (from == 1) cout << "Destroyed: FGTable" << endl; + } + if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects + } + if (debug_lvl & 8 ) { // Runtime state variables + } + if (debug_lvl & 16) { // Sanity checking + } } diff --git a/src/FDM/JSBSim/FGTable.h b/src/FDM/JSBSim/FGTable.h index 4a20d688a..6d5b55b2d 100644 --- a/src/FDM/JSBSim/FGTable.h +++ b/src/FDM/JSBSim/FGTable.h @@ -105,7 +105,7 @@ private: int colCounter; int rowCounter; double** Allocate(void); - void Debug(void); + void Debug(int from); }; //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/src/FDM/JSBSim/FGTank.cpp b/src/FDM/JSBSim/FGTank.cpp index 65f7242df..5ed969909 100644 --- a/src/FDM/JSBSim/FGTank.cpp +++ b/src/FDM/JSBSim/FGTank.cpp @@ -53,9 +53,10 @@ using std::cout; FGTank::FGTank(FGConfigFile* AC_cfg) { - string type = AC_cfg->GetValue("TYPE"); string token; + type = AC_cfg->GetValue("TYPE"); + if (type == "FUEL") Type = ttFUEL; else if (type == "OXIDIZER") Type = ttOXIDIZER; else Type = ttUNKNOWN; @@ -80,21 +81,14 @@ FGTank::FGTank(FGConfigFile* AC_cfg) PctFull = 0; } - if (debug_lvl > 0) { - cout << " " << type << " tank holds " << Capacity << " lbs. " << type << endl; - cout << " currently at " << PctFull << "% of maximum capacity" << endl; - cout << " Tank location (X, Y, Z): " << X << ", " << Y << ", " << Z << endl; - cout << " Effective radius: " << Radius << " inches" << endl; - } - - if (debug_lvl & 2) cout << "Instantiated: FGTank" << endl; + Debug(0); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FGTank::~FGTank() { - if (debug_lvl & 2) cout << "Destroyed: FGTank" << endl; + Debug(1); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -117,9 +111,45 @@ double FGTank::Reduce(double used) } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -void FGTank::Debug(void) +// The bitmasked value choices are as follows: +// unset: In this case (the default) JSBSim would only print +// out the normally expected messages, essentially echoing +// the config files as they are read. If the environment +// variable is not set, debug_lvl is set to 1 internally +// 0: This requests JSBSim not to output any messages +// whatsoever. +// 1: This value explicity requests the normal JSBSim +// startup messages +// 2: This value asks for a message to be printed out when +// a class is instantiated +// 4: When this value is set, a message is displayed when a +// FGModel object executes its Run() method +// 8: When this value is set, various runtime state variables +// are printed out periodically +// 16: When set various parameters are sanity checked and +// a message is printed out when they go out of bounds + +void FGTank::Debug(int from) { - //TODO: Add your source code here + if (debug_lvl <= 0) return; + + if (debug_lvl & 1) { // Standard console startup message output + if (from == 0) { // Constructor + cout << " " << type << " tank holds " << Capacity << " lbs. " << type << endl; + cout << " currently at " << PctFull << "% of maximum capacity" << endl; + cout << " Tank location (X, Y, Z): " << X << ", " << Y << ", " << Z << endl; + cout << " Effective radius: " << Radius << " inches" << endl; + } + } + if (debug_lvl & 2 ) { // Instantiation/Destruction notification + if (from == 0) cout << "Instantiated: FGTank" << endl; + if (from == 1) cout << "Destroyed: FGTank" << endl; + } + if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects + } + if (debug_lvl & 8 ) { // Runtime state variables + } + if (debug_lvl & 16) { // Sanity checking + } } diff --git a/src/FDM/JSBSim/FGTank.h b/src/FDM/JSBSim/FGTank.h index 15be71714..2408ed9dd 100644 --- a/src/FDM/JSBSim/FGTank.h +++ b/src/FDM/JSBSim/FGTank.h @@ -95,13 +95,14 @@ public: private: TankType Type; + string type; double X, Y, Z; double Capacity; double Radius; double PctFull; double Contents; bool Selected; - void Debug(void); + void Debug(int from); }; //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/src/FDM/JSBSim/FGThruster.cpp b/src/FDM/JSBSim/FGThruster.cpp index 07cb48f3b..ebe861803 100644 --- a/src/FDM/JSBSim/FGThruster.cpp +++ b/src/FDM/JSBSim/FGThruster.cpp @@ -50,20 +50,53 @@ FGThruster::FGThruster(FGFDMExec *FDMExec) : FGForce(FDMExec), { SetTransformType(FGForce::tCustom); - if (debug_lvl & 2) cout << "Instantiated: FGThruster" << endl; + Debug(0); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FGThruster::~FGThruster() { - if (debug_lvl & 2) cout << "Destroyed: FGThruster" << endl; + Debug(1); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -void FGThruster::Debug(void) +// The bitmasked value choices are as follows: +// unset: In this case (the default) JSBSim would only print +// out the normally expected messages, essentially echoing +// the config files as they are read. If the environment +// variable is not set, debug_lvl is set to 1 internally +// 0: This requests JSBSim not to output any messages +// whatsoever. +// 1: This value explicity requests the normal JSBSim +// startup messages +// 2: This value asks for a message to be printed out when +// a class is instantiated +// 4: When this value is set, a message is displayed when a +// FGModel object executes its Run() method +// 8: When this value is set, various runtime state variables +// are printed out periodically +// 16: When set various parameters are sanity checked and +// a message is printed out when they go out of bounds + +void FGThruster::Debug(int from) { - //TODO: Add your source code here + if (debug_lvl <= 0) return; + + if (debug_lvl & 1) { // Standard console startup message output + if (from == 0) { // Constructor + + } + } + if (debug_lvl & 2 ) { // Instantiation/Destruction notification + if (from == 0) cout << "Instantiated: FGThruster" << endl; + if (from == 1) cout << "Destroyed: FGThruster" << endl; + } + if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects + } + if (debug_lvl & 8 ) { // Runtime state variables + } + if (debug_lvl & 16) { // Sanity checking + } } diff --git a/src/FDM/JSBSim/FGThruster.h b/src/FDM/JSBSim/FGThruster.h index bf0eb1a9b..d46956e0c 100644 --- a/src/FDM/JSBSim/FGThruster.h +++ b/src/FDM/JSBSim/FGThruster.h @@ -92,7 +92,7 @@ protected: double Thrust; double PowerRequired; double deltaT; - virtual void Debug(void); + virtual void Debug(int from); }; //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/src/FDM/JSBSim/FGTranslation.cpp b/src/FDM/JSBSim/FGTranslation.cpp index 5c76642f8..d191b8c74 100644 --- a/src/FDM/JSBSim/FGTranslation.cpp +++ b/src/FDM/JSBSim/FGTranslation.cpp @@ -86,14 +86,14 @@ FGTranslation::FGTranslation(FGFDMExec* fdmex) : FGModel(fdmex) alpha = beta = 0.0; adot = bdot = 0.0; - if (debug_lvl & 2) cout << "Instantiated: " << Name << endl; + Debug(0); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -FGTranslation::~FGTranslation() +FGTranslation::~FGTranslation(void) { - if (debug_lvl & 2) cout << "Destroyed: FGTranslation" << endl; + Debug(1); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -150,7 +150,7 @@ bool FGTranslation::Run(void) vlastUVWdot = vUVWdot; - if (debug_lvl > 1) Debug(); + if (debug_lvl > 1) Debug(1); return false; } else { @@ -159,10 +159,42 @@ bool FGTranslation::Run(void) } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -void FGTranslation::Debug(void) +// The bitmasked value choices are as follows: +// unset: In this case (the default) JSBSim would only print +// out the normally expected messages, essentially echoing +// the config files as they are read. If the environment +// variable is not set, debug_lvl is set to 1 internally +// 0: This requests JSBSim not to output any messages +// whatsoever. +// 1: This value explicity requests the normal JSBSim +// startup messages +// 2: This value asks for a message to be printed out when +// a class is instantiated +// 4: When this value is set, a message is displayed when a +// FGModel object executes its Run() method +// 8: When this value is set, various runtime state variables +// are printed out periodically +// 16: When set various parameters are sanity checked and +// a message is printed out when they go out of bounds + +void FGTranslation::Debug(int from) { - if (debug_lvl & 16) { // Sanity check variables + if (debug_lvl <= 0) return; + + if (debug_lvl & 1) { // Standard console startup message output + if (from == 0) { // Constructor + + } + } + if (debug_lvl & 2 ) { // Instantiation/Destruction notification + if (from == 0) cout << "Instantiated: FGTranslation" << endl; + if (from == 1) cout << "Destroyed: FGTranslation" << endl; + } + if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects + } + if (debug_lvl & 8 ) { // Runtime state variables + } + if (debug_lvl & 16) { // Sanity checking if (fabs(vUVW(eU)) > 1e6) cout << "FGTranslation::U velocity out of bounds: " << vUVW(eU) << endl; if (fabs(vUVW(eV)) > 1e6) @@ -181,4 +213,3 @@ void FGTranslation::Debug(void) cout << "FGTranslation::qbar is out of bounds: " << qbar << endl; } } - diff --git a/src/FDM/JSBSim/FGTranslation.h b/src/FDM/JSBSim/FGTranslation.h index d15e92011..a49396380 100644 --- a/src/FDM/JSBSim/FGTranslation.h +++ b/src/FDM/JSBSim/FGTranslation.h @@ -128,7 +128,7 @@ private: double alpha, beta; double adot,bdot; - void Debug(void); + void Debug(int from); }; //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/src/FDM/JSBSim/FGTrimAxis.cpp b/src/FDM/JSBSim/FGTrimAxis.cpp index 4412bf6c7..2fe3213f1 100644 --- a/src/FDM/JSBSim/FGTrimAxis.cpp +++ b/src/FDM/JSBSim/FGTrimAxis.cpp @@ -139,14 +139,14 @@ FGTrimAxis::FGTrimAxis(FGFDMExec* fdex, FGInitialCondition* ic, State st, } - if (debug_lvl & 2) cout << "Instantiated: FGTrimAxis" << endl; + Debug(0); } /*****************************************************************************/ -FGTrimAxis::~FGTrimAxis() +FGTrimAxis::~FGTrimAxis(void) { - if (debug_lvl & 2) cout << "Destroyed: FGTrimAxis" << endl; + Debug(1); } /*****************************************************************************/ @@ -430,8 +430,42 @@ double FGTrimAxis::GetAvgStability( void ) { } /*****************************************************************************/ - -void FGTrimAxis::Debug(void) +// The bitmasked value choices are as follows: +// unset: In this case (the default) JSBSim would only print +// out the normally expected messages, essentially echoing +// the config files as they are read. If the environment +// variable is not set, debug_lvl is set to 1 internally +// 0: This requests JSBSim not to output any messages +// whatsoever. +// 1: This value explicity requests the normal JSBSim +// startup messages +// 2: This value asks for a message to be printed out when +// a class is instantiated +// 4: When this value is set, a message is displayed when a +// FGModel object executes its Run() method +// 8: When this value is set, various runtime state variables +// are printed out periodically +// 16: When set various parameters are sanity checked and +// a message is printed out when they go out of bounds + +void FGTrimAxis::Debug(int from) { + if (debug_lvl <= 0) return; + + if (debug_lvl & 1) { // Standard console startup message output + if (from == 0) { // Constructor + + } + } + if (debug_lvl & 2 ) { // Instantiation/Destruction notification + if (from == 0) cout << "Instantiated: FGTrimAxis" << endl; + if (from == 1) cout << "Destroyed: FGTrimAxis" << endl; + } + if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects + } + if (debug_lvl & 8 ) { // Runtime state variables + } + if (debug_lvl & 16) { // Sanity checking + } } diff --git a/src/FDM/JSBSim/FGTrimAxis.h b/src/FDM/JSBSim/FGTrimAxis.h index a5ea5c00d..86537800a 100644 --- a/src/FDM/JSBSim/FGTrimAxis.h +++ b/src/FDM/JSBSim/FGTrimAxis.h @@ -167,7 +167,7 @@ private: double computeHmgt(void); - void Debug(void); + void Debug(int from); }; #endif diff --git a/src/FDM/JSBSim/FGTurboJet.cpp b/src/FDM/JSBSim/FGTurboJet.cpp index 4f0b867ac..3812fdc7f 100644 --- a/src/FDM/JSBSim/FGTurboJet.cpp +++ b/src/FDM/JSBSim/FGTurboJet.cpp @@ -50,14 +50,14 @@ CLASS IMPLEMENTATION FGTurboJet::FGTurboJet(FGFDMExec* exec, FGConfigFile* cfg) : FGEngine(exec) { - if (debug_lvl & 2) cout << "Instantiated: FGTurboJet" << endl; + Debug(0); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FGTurboJet::~FGTurboJet() { - if (debug_lvl & 2) cout << "Destroyed: FGTurboJet" << endl; + Debug(1); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -69,9 +69,42 @@ double FGTurboJet::Calculate(double dummy) } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -void FGTurboJet::Debug(void) +// The bitmasked value choices are as follows: +// unset: In this case (the default) JSBSim would only print +// out the normally expected messages, essentially echoing +// the config files as they are read. If the environment +// variable is not set, debug_lvl is set to 1 internally +// 0: This requests JSBSim not to output any messages +// whatsoever. +// 1: This value explicity requests the normal JSBSim +// startup messages +// 2: This value asks for a message to be printed out when +// a class is instantiated +// 4: When this value is set, a message is displayed when a +// FGModel object executes its Run() method +// 8: When this value is set, various runtime state variables +// are printed out periodically +// 16: When set various parameters are sanity checked and +// a message is printed out when they go out of bounds + +void FGTurboJet::Debug(int from) { - //TODO: Add your source code here + if (debug_lvl <= 0) return; + + if (debug_lvl & 1) { // Standard console startup message output + if (from == 0) { // Constructor + + } + } + if (debug_lvl & 2 ) { // Instantiation/Destruction notification + if (from == 0) cout << "Instantiated: FGTurboJet" << endl; + if (from == 1) cout << "Destroyed: FGTurboJet" << endl; + } + if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects + } + if (debug_lvl & 8 ) { // Runtime state variables + } + if (debug_lvl & 16) { // Sanity checking + } } diff --git a/src/FDM/JSBSim/FGTurboJet.h b/src/FDM/JSBSim/FGTurboJet.h index 1db6bc8e3..214ae6e85 100644 --- a/src/FDM/JSBSim/FGTurboJet.h +++ b/src/FDM/JSBSim/FGTurboJet.h @@ -60,7 +60,7 @@ public: double Calculate(double); private: - void Debug(void); + void Debug(int from); }; //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/src/FDM/JSBSim/FGTurboProp.cpp b/src/FDM/JSBSim/FGTurboProp.cpp index 5cad270ce..1179cbfaf 100644 --- a/src/FDM/JSBSim/FGTurboProp.cpp +++ b/src/FDM/JSBSim/FGTurboProp.cpp @@ -49,14 +49,14 @@ CLASS IMPLEMENTATION FGTurboProp::FGTurboProp(FGFDMExec* exec, FGConfigFile* cfg) : FGEngine(exec) { - if (debug_lvl & 2) cout << "Instantiated: FGTurboProp" << endl; + Debug(0); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FGTurboProp::~FGTurboProp() { - if (debug_lvl & 2) cout << "Destroyed: FGTurboProp" << endl; + Debug(1); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -68,9 +68,42 @@ double FGTurboProp::Calculate(double dummy) } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -void FGTurboProp::Debug(void) +// The bitmasked value choices are as follows: +// unset: In this case (the default) JSBSim would only print +// out the normally expected messages, essentially echoing +// the config files as they are read. If the environment +// variable is not set, debug_lvl is set to 1 internally +// 0: This requests JSBSim not to output any messages +// whatsoever. +// 1: This value explicity requests the normal JSBSim +// startup messages +// 2: This value asks for a message to be printed out when +// a class is instantiated +// 4: When this value is set, a message is displayed when a +// FGModel object executes its Run() method +// 8: When this value is set, various runtime state variables +// are printed out periodically +// 16: When set various parameters are sanity checked and +// a message is printed out when they go out of bounds + +void FGTurboProp::Debug(int from) { - //TODO: Add your source code here + if (debug_lvl <= 0) return; + + if (debug_lvl & 1) { // Standard console startup message output + if (from == 0) { // Constructor + + } + } + if (debug_lvl & 2 ) { // Instantiation/Destruction notification + if (from == 0) cout << "Instantiated: FGTurboProp" << endl; + if (from == 1) cout << "Destroyed: FGTurboProp" << endl; + } + if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects + } + if (debug_lvl & 8 ) { // Runtime state variables + } + if (debug_lvl & 16) { // Sanity checking + } } diff --git a/src/FDM/JSBSim/FGTurboProp.h b/src/FDM/JSBSim/FGTurboProp.h index 822f73505..3b855714a 100644 --- a/src/FDM/JSBSim/FGTurboProp.h +++ b/src/FDM/JSBSim/FGTurboProp.h @@ -59,7 +59,7 @@ public: double Calculate(double); private: - void Debug(void); + void Debug(int from); }; //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/src/FDM/JSBSim/FGTurboShaft.cpp b/src/FDM/JSBSim/FGTurboShaft.cpp index 0c454e1e4..ce414d274 100644 --- a/src/FDM/JSBSim/FGTurboShaft.cpp +++ b/src/FDM/JSBSim/FGTurboShaft.cpp @@ -49,14 +49,14 @@ CLASS IMPLEMENTATION FGTurboShaft::FGTurboShaft(FGFDMExec* exec, FGConfigFile* cfg) : FGEngine(exec) { - if (debug_lvl & 2) cout << "Instantiated: FGTurboShaft" << endl; + Debug(0); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FGTurboShaft::~FGTurboShaft() { - if (debug_lvl & 2) cout << "Destroyed: FGTurboShaft" << endl; + Debug(1); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -67,8 +67,42 @@ double FGTurboShaft::Calculate(double dummy) { } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -void FGTurboShaft::Debug(void) +// The bitmasked value choices are as follows: +// unset: In this case (the default) JSBSim would only print +// out the normally expected messages, essentially echoing +// the config files as they are read. If the environment +// variable is not set, debug_lvl is set to 1 internally +// 0: This requests JSBSim not to output any messages +// whatsoever. +// 1: This value explicity requests the normal JSBSim +// startup messages +// 2: This value asks for a message to be printed out when +// a class is instantiated +// 4: When this value is set, a message is displayed when a +// FGModel object executes its Run() method +// 8: When this value is set, various runtime state variables +// are printed out periodically +// 16: When set various parameters are sanity checked and +// a message is printed out when they go out of bounds + +void FGTurboShaft::Debug(int from) { - //TODO: Add your source code here + if (debug_lvl <= 0) return; + + if (debug_lvl & 1) { // Standard console startup message output + if (from == 0) { // Constructor + + } + } + if (debug_lvl & 2 ) { // Instantiation/Destruction notification + if (from == 0) cout << "Instantiated: FGTurboShaft" << endl; + if (from == 1) cout << "Destroyed: FGTurboShaft" << endl; + } + if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects + } + if (debug_lvl & 8 ) { // Runtime state variables + } + if (debug_lvl & 16) { // Sanity checking + } } + diff --git a/src/FDM/JSBSim/FGTurboShaft.h b/src/FDM/JSBSim/FGTurboShaft.h index 3f2d2aba7..beceb9b18 100644 --- a/src/FDM/JSBSim/FGTurboShaft.h +++ b/src/FDM/JSBSim/FGTurboShaft.h @@ -59,7 +59,7 @@ public: double Calculate(double); private: - void Debug(void); + void Debug(int from); }; //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/src/FDM/JSBSim/FGUtility.cpp b/src/FDM/JSBSim/FGUtility.cpp index 9866eac9f..7e275a8e4 100644 --- a/src/FDM/JSBSim/FGUtility.cpp +++ b/src/FDM/JSBSim/FGUtility.cpp @@ -70,20 +70,53 @@ CLASS IMPLEMENTATION FGUtility::FGUtility() { - if (debug_lvl & 2) cout << "Instantiated: FGUtility" << endl; + Debug(0); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FGUtility::~FGUtility() { - if (debug_lvl & 2) cout << "Destroyed: FGUtility" << endl; + Debug(1); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -void FGUtility::Debug(void) +// The bitmasked value choices are as follows: +// unset: In this case (the default) JSBSim would only print +// out the normally expected messages, essentially echoing +// the config files as they are read. If the environment +// variable is not set, debug_lvl is set to 1 internally +// 0: This requests JSBSim not to output any messages +// whatsoever. +// 1: This value explicity requests the normal JSBSim +// startup messages +// 2: This value asks for a message to be printed out when +// a class is instantiated +// 4: When this value is set, a message is displayed when a +// FGModel object executes its Run() method +// 8: When this value is set, various runtime state variables +// are printed out periodically +// 16: When set various parameters are sanity checked and +// a message is printed out when they go out of bounds + +void FGUtility::Debug(int from) { + if (debug_lvl <= 0) return; + + if (debug_lvl & 1) { // Standard console startup message output + if (from == 0) { // Constructor + + } + } + if (debug_lvl & 2 ) { // Instantiation/Destruction notification + if (from == 0) cout << "Instantiated: FGUtility" << endl; + if (from == 1) cout << "Destroyed: FGUtility" << endl; + } + if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects + } + if (debug_lvl & 8 ) { // Runtime state variables + } + if (debug_lvl & 16) { // Sanity checking + } } - diff --git a/src/FDM/JSBSim/FGUtility.h b/src/FDM/JSBSim/FGUtility.h index 061fa90c9..4514c253c 100644 --- a/src/FDM/JSBSim/FGUtility.h +++ b/src/FDM/JSBSim/FGUtility.h @@ -62,7 +62,7 @@ public: private: FGState* State; FGFDMExec* FDMExec; - void Debug(void); + void Debug(int from); }; //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/src/FDM/JSBSim/FGfdmSocket.h b/src/FDM/JSBSim/FGfdmSocket.h index a01dae7ce..1aa09bda3 100644 --- a/src/FDM/JSBSim/FGfdmSocket.h +++ b/src/FDM/JSBSim/FGfdmSocket.h @@ -107,6 +107,7 @@ private: struct sockaddr_in scktName; struct hostent *host; string buffer; + void Debug(int from) {} }; #endif diff --git a/src/FDM/JSBSim/JSBSim.cpp b/src/FDM/JSBSim/JSBSim.cpp index 59d8672e0..8d3db58bc 100644 --- a/src/FDM/JSBSim/JSBSim.cpp +++ b/src/FDM/JSBSim/JSBSim.cpp @@ -54,18 +54,11 @@ INCLUDES #ifdef FGFS #include #include STL_IOSTREAM -# ifdef SG_HAVE_STD_INCLUDES -# include -# else -# include -# endif #else # if defined(sgi) && !defined(__GNUC__) # include -# include # else # include -# include # endif #endif @@ -152,6 +145,10 @@ int main(int argc, char** argv) } } +// +// RUN loop. MESSAGES are read inside the Run() loop and output as necessary. +// + FGJSBBase::Message* msg; while (FDMExec->Run()) { while (FDMExec->ReadMessage()) { diff --git a/src/FDM/JSBSim/filtersjb/FGDeadBand.cpp b/src/FDM/JSBSim/filtersjb/FGDeadBand.cpp index 45210296c..1ffeeebbc 100644 --- a/src/FDM/JSBSim/filtersjb/FGDeadBand.cpp +++ b/src/FDM/JSBSim/filtersjb/FGDeadBand.cpp @@ -67,14 +67,14 @@ FGDeadBand::FGDeadBand(FGFCS* fcs, FGConfigFile* AC_cfg) : FGFCSComponent(fcs), } } - if (debug_lvl & 2) cout << "Instantiated: FGDeadBand" << endl; + Debug(0); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FGDeadBand::~FGDeadBand() { - if (debug_lvl & 2) cout << "Destroyed: FGDeadBand" << endl; + Debug(1); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -87,9 +87,42 @@ bool FGDeadBand::Run(void ) } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -void FGDeadBand::Debug(void) +// The bitmasked value choices are as follows: +// unset: In this case (the default) JSBSim would only print +// out the normally expected messages, essentially echoing +// the config files as they are read. If the environment +// variable is not set, debug_lvl is set to 1 internally +// 0: This requests JSBSim not to output any messages +// whatsoever. +// 1: This value explicity requests the normal JSBSim +// startup messages +// 2: This value asks for a message to be printed out when +// a class is instantiated +// 4: When this value is set, a message is displayed when a +// FGModel object executes its Run() method +// 8: When this value is set, various runtime state variables +// are printed out periodically +// 16: When set various parameters are sanity checked and +// a message is printed out when they go out of bounds + +void FGDeadBand::Debug(int from) { - //TODO: Add your source code here + if (debug_lvl <= 0) return; + + if (debug_lvl & 1) { // Standard console startup message output + if (from == 0) { // Constructor + + } + } + if (debug_lvl & 2 ) { // Instantiation/Destruction notification + if (from == 0) cout << "Instantiated: FGDeadBand" << endl; + if (from == 1) cout << "Destroyed: FGDeadBand" << endl; + } + if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects + } + if (debug_lvl & 8 ) { // Runtime state variables + } + if (debug_lvl & 16) { // Sanity checking + } } diff --git a/src/FDM/JSBSim/filtersjb/FGDeadBand.h b/src/FDM/JSBSim/filtersjb/FGDeadBand.h index 9f91dfe0e..a20f4b152 100644 --- a/src/FDM/JSBSim/filtersjb/FGDeadBand.h +++ b/src/FDM/JSBSim/filtersjb/FGDeadBand.h @@ -81,7 +81,7 @@ public: private: FGConfigFile* AC_cfg; - void Debug(void); + void Debug(int from); }; //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/src/FDM/JSBSim/filtersjb/FGFCSComponent.cpp b/src/FDM/JSBSim/filtersjb/FGFCSComponent.cpp index b4b1e3e45..ec7a596b2 100644 --- a/src/FDM/JSBSim/filtersjb/FGFCSComponent.cpp +++ b/src/FDM/JSBSim/filtersjb/FGFCSComponent.cpp @@ -57,14 +57,14 @@ FGFCSComponent::FGFCSComponent(FGFCS* _fcs) : fcs(_fcs) OutputIdx = FG_UNDEF; IsOutput = false; - if (debug_lvl & 2) cout << "Instantiated: FGFCSComponent" << endl; + Debug(0); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FGFCSComponent::~FGFCSComponent() { - if (debug_lvl & 2) cout << "Destroyed: FGFCSComponent" << endl; + Debug(1); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -94,9 +94,38 @@ bool FGFCSComponent::Run(void) } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -void FGFCSComponent::Debug(void) +// The bitmasked value choices are as follows: +// unset: In this case (the default) JSBSim would only print +// out the normally expected messages, essentially echoing +// the config files as they are read. If the environment +// variable is not set, debug_lvl is set to 1 internally +// 0: This requests JSBSim not to output any messages +// whatsoever. +// 1: This value explicity requests the normal JSBSim +// startup messages +// 2: This value asks for a message to be printed out when +// a class is instantiated +// 4: When this value is set, a message is displayed when a +// FGModel object executes its Run() method +// 8: When this value is set, various runtime state variables +// are printed out periodically +// 16: When set various parameters are sanity checked and +// a message is printed out when they go out of bounds + +void FGFCSComponent::Debug(int from) { - //TODO: Add your source code here -} + if (debug_lvl <= 0) return; + if (debug_lvl & 1) { // Standard console startup message output + } + if (debug_lvl & 2 ) { // Instantiation/Destruction notification + if (from == 0) cout << "Instantiated: FGFCSComponent" << endl; + if (from == 1) cout << "Destroyed: FGFCSComponent" << endl; + } + if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects + } + if (debug_lvl & 8 ) { // Runtime state variables + } + if (debug_lvl & 16) { // Sanity checking + } +} diff --git a/src/FDM/JSBSim/filtersjb/FGFCSComponent.h b/src/FDM/JSBSim/filtersjb/FGFCSComponent.h index a1a558213..8a6ec33f8 100644 --- a/src/FDM/JSBSim/filtersjb/FGFCSComponent.h +++ b/src/FDM/JSBSim/filtersjb/FGFCSComponent.h @@ -115,7 +115,7 @@ protected: eParam OutputIdx; double Output; bool IsOutput; - virtual void Debug(void); + virtual void Debug(int from); }; #include "../FGFCS.h" diff --git a/src/FDM/JSBSim/filtersjb/FGFilter.cpp b/src/FDM/JSBSim/filtersjb/FGFilter.cpp index 842aa6d8a..d95c8c30a 100644 --- a/src/FDM/JSBSim/filtersjb/FGFilter.cpp +++ b/src/FDM/JSBSim/filtersjb/FGFilter.cpp @@ -131,26 +131,14 @@ FGFilter::FGFilter(FGFCS* fcs, FGConfigFile* AC_cfg) : FGFCSComponent(fcs), break; } - if (debug_lvl > 0) { - cout << " ID: " << ID << endl; - cout << " INPUT: " << InputIdx << endl; - cout << " C1: " << C1 << endl; - cout << " C2: " << C2 << endl; - cout << " C3: " << C3 << endl; - cout << " C4: " << C4 << endl; - cout << " C5: " << C5 << endl; - cout << " C6: " << C6 << endl; - if (IsOutput) cout << " OUTPUT: " << sOutputIdx << endl; - } - - if (debug_lvl & 2) cout << "Instantiated: FGFilter" << endl; + Debug(0); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FGFilter::~FGFilter() { - if (debug_lvl & 2) cout << "Destroyed: FGFilter" << endl; + Debug(1); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -198,9 +186,50 @@ bool FGFilter::Run(void) } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -void FGFilter::Debug(void) +// The bitmasked value choices are as follows: +// unset: In this case (the default) JSBSim would only print +// out the normally expected messages, essentially echoing +// the config files as they are read. If the environment +// variable is not set, debug_lvl is set to 1 internally +// 0: This requests JSBSim not to output any messages +// whatsoever. +// 1: This value explicity requests the normal JSBSim +// startup messages +// 2: This value asks for a message to be printed out when +// a class is instantiated +// 4: When this value is set, a message is displayed when a +// FGModel object executes its Run() method +// 8: When this value is set, various runtime state variables +// are printed out periodically +// 16: When set various parameters are sanity checked and +// a message is printed out when they go out of bounds + +void FGFilter::Debug(int from) { - //TODO: Add your source code here + if (debug_lvl <= 0) return; + + if (debug_lvl & 1) { // Standard console startup message output + if (from == 0) { // Constructor + cout << " ID: " << ID << endl; + cout << " INPUT: " << InputIdx << endl; + cout << " C1: " << C1 << endl; + cout << " C2: " << C2 << endl; + cout << " C3: " << C3 << endl; + cout << " C4: " << C4 << endl; + cout << " C5: " << C5 << endl; + cout << " C6: " << C6 << endl; + if (IsOutput) cout << " OUTPUT: " << sOutputIdx << endl; + } + } + if (debug_lvl & 2 ) { // Instantiation/Destruction notification + if (from == 0) cout << "Instantiated: FGFilter" << endl; + if (from == 1) cout << "Destroyed: FGFilter" << endl; + } + if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects + } + if (debug_lvl & 8 ) { // Runtime state variables + } + if (debug_lvl & 16) { // Sanity checking + } } diff --git a/src/FDM/JSBSim/filtersjb/FGFilter.h b/src/FDM/JSBSim/filtersjb/FGFilter.h index 8a6255aff..d085bb7b9 100644 --- a/src/FDM/JSBSim/filtersjb/FGFilter.h +++ b/src/FDM/JSBSim/filtersjb/FGFilter.h @@ -115,7 +115,7 @@ private: double PreviousOutput1; double PreviousOutput2; FGConfigFile* AC_cfg; - void Debug(void); + void Debug(int from); }; #endif diff --git a/src/FDM/JSBSim/filtersjb/FGGain.cpp b/src/FDM/JSBSim/filtersjb/FGGain.cpp index b89b72fbc..0ca990c9c 100644 --- a/src/FDM/JSBSim/filtersjb/FGGain.cpp +++ b/src/FDM/JSBSim/filtersjb/FGGain.cpp @@ -104,28 +104,14 @@ FGGain::FGGain(FGFCS* fcs, FGConfigFile* AC_cfg) : FGFCSComponent(fcs), *Table << *AC_cfg; } } - - if (debug_lvl > 0) { - cout << " ID: " << ID << endl; - cout << " INPUT: " << InputIdx << endl; - cout << " GAIN: " << Gain << endl; - if (IsOutput) cout << " OUTPUT: " << sOutputIdx << endl; - cout << " MIN: " << Min << endl; - cout << " MAX: " << Max << endl; - if (ScheduledBy != FG_UNDEF) { - cout << " Scheduled by parameter: " << ScheduledBy << endl; - Table->Print(); - } - } - - if (debug_lvl & 2) cout << "Instantiated: FGGain" << endl; + Debug(0); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FGGain::~FGGain() { - if (debug_lvl & 2) cout << "Destroyed: FGGain" << endl; + Debug(1); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -155,9 +141,51 @@ bool FGGain::Run(void ) } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -void FGGain::Debug(void) +// The bitmasked value choices are as follows: +// unset: In this case (the default) JSBSim would only print +// out the normally expected messages, essentially echoing +// the config files as they are read. If the environment +// variable is not set, debug_lvl is set to 1 internally +// 0: This requests JSBSim not to output any messages +// whatsoever. +// 1: This value explicity requests the normal JSBSim +// startup messages +// 2: This value asks for a message to be printed out when +// a class is instantiated +// 4: When this value is set, a message is displayed when a +// FGModel object executes its Run() method +// 8: When this value is set, various runtime state variables +// are printed out periodically +// 16: When set various parameters are sanity checked and +// a message is printed out when they go out of bounds + +void FGGain::Debug(int from) { - //TODO: Add your source code here + if (debug_lvl <= 0) return; + + if (debug_lvl & 1) { // Standard console startup message output + if (from == 0) { // Constructor + cout << " ID: " << ID << endl; + cout << " INPUT: " << InputIdx << endl; + cout << " GAIN: " << Gain << endl; + if (IsOutput) cout << " OUTPUT: " << sOutputIdx << endl; + cout << " MIN: " << Min << endl; + cout << " MAX: " << Max << endl; + if (ScheduledBy != FG_UNDEF) { + cout << " Scheduled by parameter: " << ScheduledBy << endl; + Table->Print(); + } + } + } + if (debug_lvl & 2 ) { // Instantiation/Destruction notification + if (from == 0) cout << "Instantiated: FGGain" << endl; + if (from == 1) cout << "Destroyed: FGGain" << endl; + } + if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects + } + if (debug_lvl & 8 ) { // Runtime state variables + } + if (debug_lvl & 16) { // Sanity checking + } } diff --git a/src/FDM/JSBSim/filtersjb/FGGain.h b/src/FDM/JSBSim/filtersjb/FGGain.h index a5f33c6ea..7fced50e1 100644 --- a/src/FDM/JSBSim/filtersjb/FGGain.h +++ b/src/FDM/JSBSim/filtersjb/FGGain.h @@ -82,7 +82,7 @@ private: int Rows; eParam ScheduledBy; - void Debug(void); + void Debug(int from); }; #endif diff --git a/src/FDM/JSBSim/filtersjb/FGGradient.cpp b/src/FDM/JSBSim/filtersjb/FGGradient.cpp index af22700fa..27aadf392 100644 --- a/src/FDM/JSBSim/filtersjb/FGGradient.cpp +++ b/src/FDM/JSBSim/filtersjb/FGGradient.cpp @@ -53,14 +53,14 @@ FGGradient::FGGradient(FGFCS* fcs, FGConfigFile* AC_cfg) : FGFCSComponent(fcs), Type = AC_cfg->GetValue("TYPE"); Name = AC_cfg->GetValue("NAME"); - if (debug_lvl & 2) cout << "Instantiated: FGGradient" << endl; + Debug(0); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FGGradient::~FGGradient() { - if (debug_lvl & 2) cout << "Destroyed: FGGradient" << endl; + Debug(1); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -73,9 +73,42 @@ bool FGGradient::Run(void ) } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -void FGGradient::Debug(void) +// The bitmasked value choices are as follows: +// unset: In this case (the default) JSBSim would only print +// out the normally expected messages, essentially echoing +// the config files as they are read. If the environment +// variable is not set, debug_lvl is set to 1 internally +// 0: This requests JSBSim not to output any messages +// whatsoever. +// 1: This value explicity requests the normal JSBSim +// startup messages +// 2: This value asks for a message to be printed out when +// a class is instantiated +// 4: When this value is set, a message is displayed when a +// FGModel object executes its Run() method +// 8: When this value is set, various runtime state variables +// are printed out periodically +// 16: When set various parameters are sanity checked and +// a message is printed out when they go out of bounds + +void FGGradient::Debug(int from) { - //TODO: Add your source code here + if (debug_lvl <= 0) return; + + if (debug_lvl & 1) { // Standard console startup message output + if (from == 0) { // Constructor + + } + } + if (debug_lvl & 2 ) { // Instantiation/Destruction notification + if (from == 0) cout << "Instantiated: FGGradient" << endl; + if (from == 1) cout << "Destroyed: FGGradient" << endl; + } + if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects + } + if (debug_lvl & 8 ) { // Runtime state variables + } + if (debug_lvl & 16) { // Sanity checking + } } diff --git a/src/FDM/JSBSim/filtersjb/FGGradient.h b/src/FDM/JSBSim/filtersjb/FGGradient.h index 66d335d50..dd87aaeb6 100644 --- a/src/FDM/JSBSim/filtersjb/FGGradient.h +++ b/src/FDM/JSBSim/filtersjb/FGGradient.h @@ -66,7 +66,7 @@ public: private: FGConfigFile* AC_cfg; - void Debug(void); + void Debug(int from); }; #endif diff --git a/src/FDM/JSBSim/filtersjb/FGKinemat.cpp b/src/FDM/JSBSim/filtersjb/FGKinemat.cpp index 934d64d3b..cea8cb313 100644 --- a/src/FDM/JSBSim/filtersjb/FGKinemat.cpp +++ b/src/FDM/JSBSim/filtersjb/FGKinemat.cpp @@ -47,7 +47,8 @@ CLASS IMPLEMENTATION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ FGKinemat::FGKinemat(FGFCS* fcs, FGConfigFile* AC_cfg) : FGFCSComponent(fcs), -AC_cfg(AC_cfg) { + AC_cfg(AC_cfg) +{ string token; double tmpDetent; double tmpTime; @@ -86,17 +87,7 @@ AC_cfg(AC_cfg) { } } - if (debug_lvl > 1) { - cout << " ID: " << ID << endl; - cout << " INPUT: " << InputIdx << endl; - cout << " DETENTS: " << NumDetents << endl; - for(int i=0;i 0) { - cout << " ID: " << ID << endl; - cout << " INPUTS: " << endl; - for (unsigned i=0;i clipmin) cout << " CLIPTO: " << clipmin - << ", " << clipmax << endl; - if (IsOutput) cout << " OUTPUT: " < clipmin) cout << " CLIPTO: " << clipmin + << ", " << clipmax << endl; + if (IsOutput) cout << " OUTPUT: " < InputTypes; bool clip; double clipmin,clipmax; - void Debug(void); + void Debug(int from); }; #endif diff --git a/src/FDM/JSBSim/filtersjb/FGSwitch.cpp b/src/FDM/JSBSim/filtersjb/FGSwitch.cpp index 8c369f58d..0d0a93ace 100644 --- a/src/FDM/JSBSim/filtersjb/FGSwitch.cpp +++ b/src/FDM/JSBSim/filtersjb/FGSwitch.cpp @@ -53,14 +53,14 @@ FGSwitch::FGSwitch(FGFCS* fcs, FGConfigFile* AC_cfg) : FGFCSComponent(fcs), Type = AC_cfg->GetValue("TYPE"); Name = AC_cfg->GetValue("NAME"); - if (debug_lvl & 2) cout << "Instantiated: FGSwitch" << endl; + Debug(0); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FGSwitch::~FGSwitch() { - if (debug_lvl & 2) cout << "Destroyed: FGSwitch" << endl; + Debug(1); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -73,9 +73,42 @@ bool FGSwitch::Run(void ) } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -void FGSwitch::Debug(void) +// The bitmasked value choices are as follows: +// unset: In this case (the default) JSBSim would only print +// out the normally expected messages, essentially echoing +// the config files as they are read. If the environment +// variable is not set, debug_lvl is set to 1 internally +// 0: This requests JSBSim not to output any messages +// whatsoever. +// 1: This value explicity requests the normal JSBSim +// startup messages +// 2: This value asks for a message to be printed out when +// a class is instantiated +// 4: When this value is set, a message is displayed when a +// FGModel object executes its Run() method +// 8: When this value is set, various runtime state variables +// are printed out periodically +// 16: When set various parameters are sanity checked and +// a message is printed out when they go out of bounds + +void FGSwitch::Debug(int from) { - //TODO: Add your source code here + if (debug_lvl <= 0) return; + + if (debug_lvl & 1) { // Standard console startup message output + if (from == 0) { // Constructor + + } + } + if (debug_lvl & 2 ) { // Instantiation/Destruction notification + if (from == 0) cout << "Instantiated: FGSwitch" << endl; + if (from == 1) cout << "Destroyed: FGSwitch" << endl; + } + if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects + } + if (debug_lvl & 8 ) { // Runtime state variables + } + if (debug_lvl & 16) { // Sanity checking + } } diff --git a/src/FDM/JSBSim/filtersjb/FGSwitch.h b/src/FDM/JSBSim/filtersjb/FGSwitch.h index 9d5997b31..8bfe0e1b1 100644 --- a/src/FDM/JSBSim/filtersjb/FGSwitch.h +++ b/src/FDM/JSBSim/filtersjb/FGSwitch.h @@ -63,9 +63,9 @@ public: bool Run(void); private: - void Debug(void); FGFCS* fcs; FGConfigFile* AC_cfg; + void Debug(int from); }; #endif -- 2.39.5