From: ehofman Date: Thu, 16 Dec 2004 12:47:20 +0000 (+0000) Subject: Sync. w. JSBSim CVS X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=c09d1c92cae5e705f4cd57e85dc38a7f3e154b06;p=flightgear.git Sync. w. JSBSim CVS --- diff --git a/src/FDM/JSBSim/FGAerodynamics.cpp b/src/FDM/JSBSim/FGAerodynamics.cpp index d77ab2f6d..8a95e85e1 100644 --- a/src/FDM/JSBSim/FGAerodynamics.cpp +++ b/src/FDM/JSBSim/FGAerodynamics.cpp @@ -220,7 +220,7 @@ bool FGAerodynamics::Load(FGConfigFile* AC_cfg) //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -string FGAerodynamics::GetCoefficientStrings(void) +string FGAerodynamics::GetCoefficientStrings(string delimeter) { string CoeffStrings = ""; bool firstime = true; @@ -231,7 +231,7 @@ string FGAerodynamics::GetCoefficientStrings(void) if (firstime) { firstime = false; } else { - CoeffStrings += ", "; + CoeffStrings += delimeter; } CoeffStrings += Coeff[axis][sd]->GetCoefficientName(); } @@ -241,7 +241,7 @@ string FGAerodynamics::GetCoefficientStrings(void) //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -string FGAerodynamics::GetCoefficientValues(void) +string FGAerodynamics::GetCoefficientValues(string delimeter) { string SDValues = ""; bool firstime = true; @@ -251,7 +251,7 @@ string FGAerodynamics::GetCoefficientValues(void) if (firstime) { firstime = false; } else { - SDValues += ", "; + SDValues += delimeter; } SDValues += Coeff[axis][sd]->GetSDstring(); } diff --git a/src/FDM/JSBSim/FGAerodynamics.h b/src/FDM/JSBSim/FGAerodynamics.h index 35c35820a..3947101de 100644 --- a/src/FDM/JSBSim/FGAerodynamics.h +++ b/src/FDM/JSBSim/FGAerodynamics.h @@ -156,13 +156,15 @@ public: inline void SetAlphaCLMin(double tt) { alphaclmin=tt; } /** Gets the strings for the current set of coefficients. + @param delimeter either a tab or comma string depending on output type @return a string containing the descriptive names for all coefficients */ - string GetCoefficientStrings(void); + string GetCoefficientStrings(string delimeter); /** Gets the coefficient values. + @param delimeter either a tab or comma string depending on output type @return a string containing the numeric values for the current set of coefficients */ - string GetCoefficientValues(void); + string GetCoefficientValues(string delimeter); void bind(void); void bindModel(void); diff --git a/src/FDM/JSBSim/FGCoefficient.cpp b/src/FDM/JSBSim/FGCoefficient.cpp index 3f42398e3..32f70fc51 100644 --- a/src/FDM/JSBSim/FGCoefficient.cpp +++ b/src/FDM/JSBSim/FGCoefficient.cpp @@ -168,9 +168,10 @@ bool FGCoefficient::Load(FGConfigFile *AC_cfg) end = multparms.length(); n = multparms.find("|"); + if (n == string::npos) n = end; start = 0; if (multparms != string("none")) { - while (n < end && n >= 0) { + while (n < end && n != string::npos) { n -= start; mult = multparms.substr(start,n); multipliers.push_back( resolveSymbol( mult ) ); diff --git a/src/FDM/JSBSim/FGColumnVector3.cpp b/src/FDM/JSBSim/FGColumnVector3.cpp index ebb16e1dd..a52cc6e10 100644 --- a/src/FDM/JSBSim/FGColumnVector3.cpp +++ b/src/FDM/JSBSim/FGColumnVector3.cpp @@ -19,6 +19,7 @@ INCLUDES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ #include "FGColumnVector3.h" +#include namespace JSBSim { @@ -37,6 +38,15 @@ FGColumnVector3::FGColumnVector3(void) //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +string FGColumnVector3::Dump(string delimeter) const +{ + char buffer[256]; + sprintf(buffer, "%f%s%f%s%f", Entry(1), delimeter.c_str(), Entry(2), delimeter.c_str(), Entry(3)); + return string(buffer); +} + +//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + FGColumnVector3 FGColumnVector3::operator/(const double scalar) const { if (scalar != 0.0) @@ -44,7 +54,7 @@ FGColumnVector3 FGColumnVector3::operator/(const double scalar) const cerr << "Attempt to divide by zero in method " "FGColumnVector3::operator/(const double scalar), " - "object " << this << endl; + "object " << this << endl; return FGColumnVector3(); } @@ -97,7 +107,7 @@ ostream& operator<<(ostream& os, const FGColumnVector3& col) { os << col(1) << " , " << col(2) << " , " << col(3); return os; -} +} /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ // The bitmasked value choices are as follows: diff --git a/src/FDM/JSBSim/FGColumnVector3.h b/src/FDM/JSBSim/FGColumnVector3.h index a83afacdd..19a508b6b 100644 --- a/src/FDM/JSBSim/FGColumnVector3.h +++ b/src/FDM/JSBSim/FGColumnVector3.h @@ -89,19 +89,14 @@ class FGColumnVector3 : public FGJSBBase { public: /** Default initializer. - - Create a zero vector. - */ + Create a zero vector. */ FGColumnVector3(void); /** Initialization by given values. - @param X value of the x-conponent. @param Y value of the y-conponent. @param Z value of the z-conponent. - - Create a vector from the doubles given in the arguments. - */ + Create a vector from the doubles given in the arguments. */ FGColumnVector3(double X, double Y, double Z) { data[0] = X; data[1] = Y; @@ -110,11 +105,8 @@ public: } /** Copy constructor. - @param v Vector which is used for initialization. - - Create copy of the vector given in the argument. - */ + Create copy of the vector given in the argument. */ FGColumnVector3(const FGColumnVector3& v) { data[0] = v.data[0]; data[1] = v.data[1]; @@ -122,69 +114,51 @@ public: Debug(0); } - /** Destructor. - */ + /// Destructor. ~FGColumnVector3(void) { Debug(1); } - /** Read access the entries of the vector. - @param idx the component index. - Return the value of the matrix entry at the given index. Indices are counted starting with 1. - - Note that the index given in the argument is unchecked. - */ + Note that the index given in the argument is unchecked. */ double operator()(unsigned int idx) const { return Entry(idx); } /** Write access the entries of the vector. - @param idx the component index. - Return a reference to the vector entry at the given index. Indices are counted starting with 1. - - Note that the index given in the argument is unchecked. - */ + Note that the index given in the argument is unchecked. */ double& operator()(unsigned int idx) { return Entry(idx); } /** Read access the entries of the vector. - @param idx the component index. - Return the value of the matrix entry at the given index. Indices are counted starting with 1. - This function is just a shortcut for the @ref double operator()(unsigned int idx) const function. It is used internally to access the elements in a more convenient way. - - Note that the index given in the argument is unchecked. - */ + Note that the index given in the argument is unchecked. */ double Entry(unsigned int idx) const { return data[idx-1]; } /** Write access the entries of the vector. - @param idx the component index. - Return a reference to the vector entry at the given index. Indices are counted starting with 1. - This function is just a shortcut for the @ref double& operator()(unsigned int idx) function. It is used internally to access the elements in a more convenient way. - - Note that the index given in the argument is unchecked. - */ + Note that the index given in the argument is unchecked. */ double& Entry(unsigned int idx) { return data[idx-1]; } - /** Assignment operator. + /** Prints the contents of the vector + @param delimeter the item separator (tab or comma) + @return a string with the delimeter-separated contents of the vector */ + string Dump(string delimeter) const; + /** Assignment operator. @param b source vector. - - Copy the content of the vector given in the argument into *this. - */ + Copy the content of the vector given in the argument into *this. */ FGColumnVector3& operator=(const FGColumnVector3& b) { data[0] = b.data[0]; data[1] = b.data[1]; @@ -193,71 +167,53 @@ public: } /** Comparison operator. - @param b other vector. - - Returns true if both vectors are exactly the same. - */ + Returns true if both vectors are exactly the same. */ bool operator==(const FGColumnVector3& b) const { return data[0] == b.data[0] && data[1] == b.data[1] && data[2] == b.data[2]; } /** Comparison operator. - @param b other vector. - - Returns false if both vectors are exactly the same. - */ + Returns false if both vectors are exactly the same. */ bool operator!=(const FGColumnVector3& b) const { return ! operator==(b); } /** Multiplication by a scalar. - @param scalar scalar value to multiply the vector with. @return The resulting vector from the multiplication with that scalar. - - Multiply the vector with the scalar given in the argument. - */ + Multiply the vector with the scalar given in the argument. */ FGColumnVector3 operator*(const double scalar) const { return FGColumnVector3(scalar*Entry(1), scalar*Entry(2), scalar*Entry(3)); } /** Multiply by 1/scalar. - @param scalar scalar value to devide the vector through. @return The resulting vector from the division through that scalar. - - Multiply the vector with the 1/scalar given in the argument. - */ + Multiply the vector with the 1/scalar given in the argument. */ FGColumnVector3 operator/(const double scalar) const; /** Cross product multiplication. - @param v vector to multiply with. @return The resulting vector from the cross product multiplication. - Compute and return the cross product of the current vector with - the given argument. - */ + the given argument. */ FGColumnVector3 operator*(const FGColumnVector3& V) const { return FGColumnVector3( Entry(2) * V(3) - Entry(3) * V(2), Entry(3) * V(1) - Entry(1) * V(3), Entry(1) * V(2) - Entry(2) * V(1) ); } - /** Addition operator. - */ + /// Addition operator. FGColumnVector3 operator+(const FGColumnVector3& B) const { return FGColumnVector3( Entry(1) + B(1), Entry(2) + B(2), Entry(3) + B(3) ); } - /** Subtraction operator. - */ + /// Subtraction operator. FGColumnVector3 operator-(const FGColumnVector3& B) const { return FGColumnVector3( Entry(1) - B(1), Entry(2) - B(2), Entry(3) - B(3) ); } - /** Subtract an other vector. - */ + /// Subtract an other vector. FGColumnVector3& operator-=(const FGColumnVector3 &B) { Entry(1) -= B(1); Entry(2) -= B(2); @@ -265,8 +221,7 @@ public: return *this; } - /** Add an other vector. - */ + /// Add an other vector. FGColumnVector3& operator+=(const FGColumnVector3 &B) { Entry(1) += B(1); Entry(2) += B(2); @@ -274,8 +229,7 @@ public: return *this; } - /** Scale by a scalar. - */ + /// Scale by a scalar. FGColumnVector3& operator*=(const double scalar) { Entry(1) *= scalar; Entry(2) *= scalar; @@ -283,8 +237,7 @@ public: return *this; } - /** Scale by a 1/scalar. - */ + /// Scale by a 1/scalar. FGColumnVector3& operator/=(const double scalar); void InitMatrix(void) { data[0] = data[1] = data[2] = 0.0; } @@ -294,25 +247,19 @@ public: } /** Length of the vector. - - Compute and return the euclidean norm of this vector. - */ + Compute and return the euclidean norm of this vector. */ double Magnitude(void) const; /** Length of the vector in a coordinate axis plane. - Compute and return the euclidean norm of this vector projected into - the coordinate axis plane idx1-idx2. - */ + the coordinate axis plane idx1-idx2. */ double Magnitude(int idx1, int idx2) const { return sqrt( Entry(idx1)*Entry(idx1) + Entry(idx2)*Entry(idx2) ); } /** Normalize. - Normalize the vector to have the Magnitude() == 1.0. If the vector - is equal to zero it is left untouched. - */ + is equal to zero it is left untouched. */ FGColumnVector3& Normalize(void); // ??? Is this something sensible ?? @@ -340,24 +287,18 @@ private: }; /** Scalar multiplication. - @param scalar scalar value to multiply with. @param A Vector to multiply. - - Multiply the Vector with a scalar value. -*/ + Multiply the Vector with a scalar value.*/ inline FGColumnVector3 operator*(double scalar, const FGColumnVector3& A) { // use already defined operation. return A*scalar; } /** Write vector to a stream. - @param os Stream to write to. @param M Matrix to write. - - Write the matrix to a stream. -*/ + Write the matrix to a stream.*/ ostream& operator<<(ostream& os, const FGColumnVector3& col); } // namespace JSBSim diff --git a/src/FDM/JSBSim/FGConfigFile.cpp b/src/FDM/JSBSim/FGConfigFile.cpp index 8930caafd..f994aba06 100644 --- a/src/FDM/JSBSim/FGConfigFile.cpp +++ b/src/FDM/JSBSim/FGConfigFile.cpp @@ -214,7 +214,7 @@ string FGConfigFile::GetLine(void) } } else { if ((test = cfgfile.get()) != EOF) { // get *next* character -#if defined ( sgi ) && !defined( __GNUC__ ) && (_COMPILER_VERSION < 740) +#if defined ( sgi ) && !defined( __GNUC__ ) && (_COMPILER_VERSION < 740) || defined (_MSC_VER) if (test >= 0x20 || test == 0x09) cfgfile.putback(test); #else if (test >= 0x20 || test == 0x09) cfgfile.unget(); diff --git a/src/FDM/JSBSim/FGElectric.cpp b/src/FDM/JSBSim/FGElectric.cpp index 4cc12f006..c62c5e328 100644 --- a/src/FDM/JSBSim/FGElectric.cpp +++ b/src/FDM/JSBSim/FGElectric.cpp @@ -91,19 +91,19 @@ double FGElectric::Calculate(void) PowerAvailable = (HP * hptoftlbssec) - Thruster->GetPowerRequired(); - return Thruster->Calculate(PowerAvailable); + return Thrust = Thruster->Calculate(PowerAvailable); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -string FGElectric::GetEngineLabels(void) +string FGElectric::GetEngineLabels(string delimeter) { return ""; // currently no labels are returned for this engine } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -string FGElectric::GetEngineValues(void) +string FGElectric::GetEngineValues(string delimeter) { return ""; // currently no values are returned for this engine } diff --git a/src/FDM/JSBSim/FGElectric.h b/src/FDM/JSBSim/FGElectric.h index 7e865e2db..20884f5f0 100644 --- a/src/FDM/JSBSim/FGElectric.h +++ b/src/FDM/JSBSim/FGElectric.h @@ -82,8 +82,8 @@ public: double GetPowerAvailable(void) {return PowerAvailable;} double CalcFuelNeed(void); double getRPM(void) {return RPM;} - string GetEngineLabels(void); - string GetEngineValues(void); + string GetEngineLabels(string delimeter); + string GetEngineValues(string delimeter); private: diff --git a/src/FDM/JSBSim/FGEngine.cpp b/src/FDM/JSBSim/FGEngine.cpp index 38193a2a2..a76a6acf4 100644 --- a/src/FDM/JSBSim/FGEngine.cpp +++ b/src/FDM/JSBSim/FGEngine.cpp @@ -87,6 +87,7 @@ FGEngine::FGEngine(FGFDMExec* exec, int engine_number) : EngineNumber(engine_num TrimMode = false; FuelFlow_gph = 0.0; FuelFlow_pph = 0.0; + FuelFreeze = false; FDMExec = exec; State = FDMExec->GetState(); @@ -99,7 +100,11 @@ FGEngine::FGEngine(FGFDMExec* exec, int engine_number) : EngineNumber(engine_num Output = FDMExec->GetOutput(); PropertyManager = FDMExec->GetPropertyManager(); - + + char property_name[80]; + snprintf(property_name, 80, "propulsion/engine[%u]/thrust", EngineNumber); + PropertyManager->Tie( property_name, &Thrust); + Debug(0); } @@ -107,9 +112,12 @@ FGEngine::FGEngine(FGFDMExec* exec, int engine_number) : EngineNumber(engine_num FGEngine::~FGEngine() { - if (Thruster) - delete Thruster; + if (Thruster) delete Thruster; + char property_name[80]; + snprintf(property_name, 80, "propulsion/engine[%u]/thrust", EngineNumber); + PropertyManager->Untie( property_name); + Debug(1); } @@ -121,6 +129,8 @@ FGEngine::~FGEngine() void FGEngine::ConsumeFuel(void) { + if (FuelFreeze) return; + unsigned int i; double Fshortage, Oshortage, TanksWithFuel; FGTank* Tank; @@ -128,7 +138,7 @@ void FGEngine::ConsumeFuel(void) Fshortage = Oshortage = TanksWithFuel = 0.0; // count how many assigned tanks have fuel - for (unsigned int i=0; iGetTank(SourceTanks[i]); if (Tank->GetContents() > 0.0) { ++TanksWithFuel; @@ -136,7 +146,7 @@ void FGEngine::ConsumeFuel(void) } if (!TanksWithFuel) return; - for (unsigned int i=0; iGetTank(SourceTanks[i]); if (Tank->GetType() == FGTank::ttFUEL) { Fshortage += Tank->Drain(CalcFuelNeed()/TanksWithFuel); diff --git a/src/FDM/JSBSim/FGEngine.h b/src/FDM/JSBSim/FGEngine.h index a4d63c2d1..82705413f 100644 --- a/src/FDM/JSBSim/FGEngine.h +++ b/src/FDM/JSBSim/FGEngine.h @@ -135,6 +135,7 @@ public: virtual void SetRunning(bool bb) { Running=bb; } virtual void SetName(string name) { Name = name; } virtual void AddFeedTank(int tkID); + virtual void SetFuelFreeze(bool f) { FuelFreeze = f; } virtual void SetStarter(bool s) { Starter = s; } @@ -175,8 +176,8 @@ public: bool LoadThruster(FGConfigFile* AC_cfg); FGThruster* GetThruster(void) {return Thruster;} - virtual string GetEngineLabels(void) = 0; - virtual string GetEngineValues(void) = 0; + virtual string GetEngineLabels(string delimeter) = 0; + virtual string GetEngineValues(string delimeter) = 0; protected: FGPropertyManager* PropertyManager; @@ -202,6 +203,7 @@ protected: bool Running; bool Cranking; bool TrimMode; + bool FuelFreeze; double FuelFlow_gph; double FuelFlow_pph; diff --git a/src/FDM/JSBSim/FGFCS.cpp b/src/FDM/JSBSim/FGFCS.cpp index cfeb2d571..daa900a68 100644 --- a/src/FDM/JSBSim/FGFCS.cpp +++ b/src/FDM/JSBSim/FGFCS.cpp @@ -420,7 +420,7 @@ double FGFCS::GetBrake(FGLGear::BrakeGroup bg) //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -string FGFCS::GetComponentStrings(void) +string FGFCS::GetComponentStrings(string delimeter) { unsigned int comp; string CompStrings = ""; @@ -428,14 +428,14 @@ string FGFCS::GetComponentStrings(void) for (comp = 0; comp < FCSComponents.size(); comp++) { if (firstime) firstime = false; - else CompStrings += ", "; + else CompStrings += delimeter; CompStrings += FCSComponents[comp]->GetName(); } for (comp = 0; comp < APComponents.size(); comp++) { - CompStrings += ", "; + CompStrings += delimeter; CompStrings += APComponents[comp]->GetName(); } @@ -444,7 +444,7 @@ string FGFCS::GetComponentStrings(void) //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -string FGFCS::GetComponentValues(void) +string FGFCS::GetComponentValues(string delimeter) { unsigned int comp; string CompValues = ""; @@ -453,14 +453,14 @@ string FGFCS::GetComponentValues(void) for (comp = 0; comp < FCSComponents.size(); comp++) { if (firstime) firstime = false; - else CompValues += ", "; + else CompValues += delimeter; sprintf(buffer, "%9.6f", FCSComponents[comp]->GetOutput()); CompValues += string(buffer); } for (comp = 0; comp < APComponents.size(); comp++) { - sprintf(buffer, ", %9.6f", APComponents[comp]->GetOutput()); + sprintf(buffer, "%s%9.6f", delimeter.c_str(), APComponents[comp]->GetOutput()); CompValues += string(buffer); } diff --git a/src/FDM/JSBSim/FGFCS.h b/src/FDM/JSBSim/FGFCS.h index 43d8822b2..4775e6901 100644 --- a/src/FDM/JSBSim/FGFCS.h +++ b/src/FDM/JSBSim/FGFCS.h @@ -425,11 +425,16 @@ public: @return pointer to the State object */ inline FGState* GetState(void) { return State; } - /** Retrieves all component names for inclusion in output stream */ - string GetComponentStrings(void); - - /** Retrieves all component outputs for inclusion in output stream */ - string GetComponentValues(void); + /** Retrieves all component names for inclusion in output stream + @param delimeter either a tab or comma string depending on output type + @return a string containing the descriptive names for all components */ + string GetComponentStrings(string delimeter); + + /** Retrieves all component outputs for inclusion in output stream + @param delimeter either a tab or comma string depending on output type + @return a string containing the numeric values for the current set of + component outputs */ + string GetComponentValues(string delimeter); /// @name Pilot input command setting //@{ diff --git a/src/FDM/JSBSim/FGGroundReactions.cpp b/src/FDM/JSBSim/FGGroundReactions.cpp index abd19c88d..2a30b6234 100644 --- a/src/FDM/JSBSim/FGGroundReactions.cpp +++ b/src/FDM/JSBSim/FGGroundReactions.cpp @@ -120,30 +120,30 @@ bool FGGroundReactions::Load(FGConfigFile* AC_cfg) //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -string FGGroundReactions::GetGroundReactionStrings(void) +string FGGroundReactions::GetGroundReactionStrings(string delimeter) { std::ostringstream buf; for (unsigned int i=0;i>(istream& is, FGMatrix33& M); } // namespace JSBSim diff --git a/src/FDM/JSBSim/FGNozzle.cpp b/src/FDM/JSBSim/FGNozzle.cpp index bbab52686..c159c12a7 100644 --- a/src/FDM/JSBSim/FGNozzle.cpp +++ b/src/FDM/JSBSim/FGNozzle.cpp @@ -66,7 +66,6 @@ FGNozzle::FGNozzle(FGFDMExec* FDMExec, FGConfigFile* Nzl_cfg, int num) : FGThrus } Thrust = 0; - ReverserAngle = 0.0; Type = ttNozzle; Area2 = (Diameter*Diameter/4.0)*M_PI; AreaT = Area2/ExpR; @@ -95,7 +94,7 @@ double FGNozzle::Calculate(double CfPc) { double pAtm = fdmex->GetAtmosphere()->GetPressure(); Thrust = max((double)0.0, (CfPc * AreaT + (PE - pAtm)*Area2) * nzlEff); - vFn(1) = Thrust * cos(ReverserAngle); + vFn(1) = Thrust; ThrustCoeff = max((double)0.0, CfPc / ((pAtm - PE) * Area2)); @@ -111,7 +110,7 @@ double FGNozzle::GetPowerRequired(void) //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -string FGNozzle::GetThrusterLabels(int id) +string FGNozzle::GetThrusterLabels(int id, string delimeter) { std::ostringstream buf; @@ -122,7 +121,7 @@ string FGNozzle::GetThrusterLabels(int id) //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -string FGNozzle::GetThrusterValues(int id) +string FGNozzle::GetThrusterValues(int id, string delimeter) { std::ostringstream buf; diff --git a/src/FDM/JSBSim/FGNozzle.h b/src/FDM/JSBSim/FGNozzle.h index 5c9e76c18..d329fa1e1 100644 --- a/src/FDM/JSBSim/FGNozzle.h +++ b/src/FDM/JSBSim/FGNozzle.h @@ -75,11 +75,11 @@ public: double Calculate(double CfPc); double GetPowerRequired(void); - string GetThrusterLabels(int id); - string GetThrusterValues(int id); + string GetThrusterLabels(int id, string delimeter); + string GetThrusterValues(int id, string delimeter); private: - double ReverserAngle; + double PE; double ExpR; double nzlEff; diff --git a/src/FDM/JSBSim/FGOutput.cpp b/src/FDM/JSBSim/FGOutput.cpp index dc7730d66..dc3e43fac 100644 --- a/src/FDM/JSBSim/FGOutput.cpp +++ b/src/FDM/JSBSim/FGOutput.cpp @@ -72,6 +72,7 @@ FGOutput::FGOutput(FGFDMExec* fdmex) : FGModel(fdmex) SubSystems = 0; enabled = true; outputInFileName = ""; + delimeter = ", "; Debug(0); } @@ -94,7 +95,7 @@ bool FGOutput::Run(void) if (FGModel::Run()) return true; if (Type == otSocket) { SocketOutput(); - } else if (Type == otCSV) { + } else if (Type == otCSV || Type == otTab) { DelimitedOutput(Filename); } else if (Type == otTerminal) { // Not done yet @@ -113,8 +114,10 @@ void FGOutput::SetType(string type) { if (type == "CSV") { Type = otCSV; + delimeter = ", "; } else if (type == "TABULAR") { Type = otTab; + delimeter = "\t"; } else if (type == "SOCKET") { Type = otSocket; } else if (type == "TERMINAL") { @@ -147,89 +150,89 @@ void FGOutput::DelimitedOutput(string fname) // Nothing here, yet } if (SubSystems & ssAerosurfaces) { - outstream << ", "; - outstream << "Aileron Cmd, "; - outstream << "Elevator Cmd, "; - outstream << "Rudder Cmd, "; - outstream << "Flap Cmd, "; - outstream << "Left Aileron Pos, "; - outstream << "Right Aileron Pos, "; - outstream << "Elevator Pos, "; - outstream << "Rudder Pos, "; + outstream << delimeter; + outstream << "Aileron Cmd" + delimeter; + outstream << "Elevator Cmd" + delimeter; + outstream << "Rudder Cmd" + delimeter; + outstream << "Flap Cmd" + delimeter; + outstream << "Left Aileron Pos" + delimeter; + outstream << "Right Aileron Pos" + delimeter; + outstream << "Elevator Pos" + delimeter; + outstream << "Rudder Pos" + delimeter; outstream << "Flap Pos"; } if (SubSystems & ssRates) { - outstream << ", "; - outstream << "P, Q, R, "; - outstream << "Pdot, Qdot, Rdot"; + outstream << delimeter; + outstream << "P" + delimeter + "Q" + delimeter + "R" + delimeter; + outstream << "Pdot" + delimeter + "Qdot" + delimeter + "Rdot"; } if (SubSystems & ssVelocities) { - outstream << ", "; - outstream << "QBar, "; - outstream << "Vtotal, "; - outstream << "UBody, VBody, WBody, "; - outstream << "UAero, VAero, WAero, "; - outstream << "Vn, Ve, Vd"; + outstream << delimeter; + outstream << "QBar" + delimeter; + outstream << "Vtotal" + delimeter; + outstream << "UBody" + delimeter + "VBody" + delimeter + "WBody" + delimeter; + outstream << "UAero" + delimeter + "VAero" + delimeter + "WAero" + delimeter; + outstream << "Vn" + delimeter + "Ve" + delimeter + "Vd"; } if (SubSystems & ssForces) { - outstream << ", "; - outstream << "Drag, Side, Lift, "; - outstream << "L/D, "; - outstream << "Xforce, Yforce, Zforce"; + outstream << delimeter; + outstream << "Drag" + delimeter + "Side" + delimeter + "Lift" + delimeter; + outstream << "L/D" + delimeter; + outstream << "Xforce" + delimeter + "Yforce" + delimeter + "Zforce"; } if (SubSystems & ssMoments) { - outstream << ", "; - outstream << "L, M, N"; + outstream << delimeter; + outstream << "L" + delimeter + "M" + delimeter + "N"; } if (SubSystems & ssAtmosphere) { - outstream << ", "; - outstream << "Rho, "; - outstream << "NWind, EWind, DWind"; + outstream << delimeter; + outstream << "Rho" + delimeter; + outstream << "NWind" + delimeter + "EWind" + delimeter + "DWind"; } if (SubSystems & ssMassProps) { - outstream << ", "; - outstream << "Ixx, "; - outstream << "Ixy, "; - outstream << "Ixz, "; - outstream << "Iyx, "; - outstream << "Iyy, "; - outstream << "Iyz, "; - outstream << "Izx, "; - outstream << "Izy, "; - outstream << "Izz, "; - outstream << "Mass, "; - outstream << "Xcg, Ycg, Zcg"; + outstream << delimeter; + outstream << "Ixx" + delimeter; + outstream << "Ixy" + delimeter; + outstream << "Ixz" + delimeter; + outstream << "Iyx" + delimeter; + outstream << "Iyy" + delimeter; + outstream << "Iyz" + delimeter; + outstream << "Izx" + delimeter; + outstream << "Izy" + delimeter; + outstream << "Izz" + delimeter; + outstream << "Mass" + delimeter; + outstream << "Xcg" + delimeter + "Ycg" + delimeter + "Zcg"; } if (SubSystems & ssPropagate) { - outstream << ", "; - outstream << "Altitude, "; - outstream << "Phi, Tht, Psi, "; - outstream << "Alpha, "; - outstream << "Beta, "; - outstream << "Latitude (Deg), "; - outstream << "Longitude (Deg), "; - outstream << "Distance AGL, "; + outstream << delimeter; + outstream << "Altitude" + delimeter; + outstream << "Phi" + delimeter + "Tht" + delimeter + "Psi" + delimeter; + outstream << "Alpha" + delimeter; + outstream << "Beta" + delimeter; + outstream << "Latitude (Deg)" + delimeter; + outstream << "Longitude (Deg)" + delimeter; + outstream << "Distance AGL" + delimeter; outstream << "Runway Radius"; } if (SubSystems & ssCoefficients) { - scratch = Aerodynamics->GetCoefficientStrings(); - if (scratch.length() != 0) outstream << ", " << scratch; + scratch = Aerodynamics->GetCoefficientStrings(delimeter); + if (scratch.length() != 0) outstream << delimeter << scratch; } if (SubSystems & ssFCS) { - scratch = FCS->GetComponentStrings(); - if (scratch.length() != 0) outstream << ", " << scratch; + scratch = FCS->GetComponentStrings(delimeter); + if (scratch.length() != 0) outstream << delimeter << scratch; } if (SubSystems & ssGroundReactions) { - outstream << ", "; - outstream << GroundReactions->GetGroundReactionStrings(); + outstream << delimeter; + outstream << GroundReactions->GetGroundReactionStrings(delimeter); } if (SubSystems & ssPropulsion && Propulsion->GetNumEngines() > 0) { - outstream << ", "; - outstream << Propulsion->GetPropulsionStrings(); + outstream << delimeter; + outstream << Propulsion->GetPropulsionStrings(delimeter); } if (OutputProperties.size() > 0) { for (unsigned int i=0;iGetName(); + outstream << delimeter << OutputProperties[i]->GetName(); } } @@ -241,81 +244,81 @@ void FGOutput::DelimitedOutput(string fname) if (SubSystems & ssSimulation) { } if (SubSystems & ssAerosurfaces) { - outstream << ", "; - outstream << FCS->GetDaCmd() << ", "; - outstream << FCS->GetDeCmd() << ", "; - outstream << FCS->GetDrCmd() << ", "; - outstream << FCS->GetDfCmd() << ", "; - outstream << FCS->GetDaLPos() << ", "; - outstream << FCS->GetDaRPos() << ", "; - outstream << FCS->GetDePos() << ", "; - outstream << FCS->GetDrPos() << ", "; + outstream << delimeter; + outstream << FCS->GetDaCmd() << delimeter; + outstream << FCS->GetDeCmd() << delimeter; + outstream << FCS->GetDrCmd() << delimeter; + outstream << FCS->GetDfCmd() << delimeter; + outstream << FCS->GetDaLPos() << delimeter; + outstream << FCS->GetDaRPos() << delimeter; + outstream << FCS->GetDePos() << delimeter; + outstream << FCS->GetDrPos() << delimeter; outstream << FCS->GetDfPos(); } if (SubSystems & ssRates) { - outstream << ", "; - outstream << Propagate->GetPQR() << ", "; - outstream << Propagate->GetPQRdot(); + outstream << delimeter; + outstream << Propagate->GetPQR().Dump(delimeter) << delimeter; + outstream << Propagate->GetPQRdot().Dump(delimeter); } if (SubSystems & ssVelocities) { - outstream << ", "; - outstream << Auxiliary->Getqbar() << ", "; - outstream << setprecision(12) << Auxiliary->GetVt() << ", "; - outstream << setprecision(12) << Propagate->GetUVW() << ", "; - outstream << Auxiliary->GetAeroUVW() << ", "; - outstream << Propagate->GetVel(); + outstream << delimeter; + outstream << Auxiliary->Getqbar() << delimeter; + outstream << setprecision(12) << Auxiliary->GetVt() << delimeter; + outstream << setprecision(12) << Propagate->GetUVW().Dump(delimeter) << delimeter; + outstream << Auxiliary->GetAeroUVW().Dump(delimeter) << delimeter; + outstream << Propagate->GetVel().Dump(delimeter); } if (SubSystems & ssForces) { - outstream << ", "; - outstream << Aerodynamics->GetvFs() << ", "; - outstream << Aerodynamics->GetLoD() << ", "; - outstream << Aircraft->GetForces(); + outstream << delimeter; + outstream << Aerodynamics->GetvFs() << delimeter; + outstream << Aerodynamics->GetLoD() << delimeter; + outstream << Aircraft->GetForces().Dump(delimeter); } if (SubSystems & ssMoments) { - outstream << ", "; - outstream << Aircraft->GetMoments(); + outstream << delimeter; + outstream << Aircraft->GetMoments().Dump(delimeter); } if (SubSystems & ssAtmosphere) { - outstream << ", "; - outstream << Atmosphere->GetDensity() << ", "; - outstream << Atmosphere->GetWindNED(); + outstream << delimeter; + outstream << Atmosphere->GetDensity() << delimeter; + outstream << Atmosphere->GetWindNED().Dump(delimeter); } if (SubSystems & ssMassProps) { - outstream << ", "; - outstream << MassBalance->GetJ() << ", "; - outstream << MassBalance->GetMass() << ", "; + outstream << delimeter; + outstream << MassBalance->GetJ() << delimeter; + outstream << MassBalance->GetMass() << delimeter; outstream << MassBalance->GetXYZcg(); } if (SubSystems & ssPropagate) { - outstream << ", "; - outstream << Propagate->Geth() << ", "; - outstream << Propagate->GetEuler() << ", "; - outstream << Auxiliary->Getalpha(inDegrees) << ", "; - outstream << Auxiliary->Getbeta(inDegrees) << ", "; - outstream << Propagate->GetLocation().GetLatitudeDeg() << ", "; - outstream << Propagate->GetLocation().GetLongitudeDeg() << ", "; - outstream << Propagate->GetDistanceAGL() << ", "; + outstream << delimeter; + outstream << Propagate->Geth() << delimeter; + outstream << Propagate->GetEuler().Dump(delimeter) << delimeter; + outstream << Auxiliary->Getalpha(inDegrees) << delimeter; + outstream << Auxiliary->Getbeta(inDegrees) << delimeter; + outstream << Propagate->GetLocation().GetLatitudeDeg() << delimeter; + outstream << Propagate->GetLocation().GetLongitudeDeg() << delimeter; + outstream << Propagate->GetDistanceAGL() << delimeter; outstream << Propagate->GetRunwayRadius(); } if (SubSystems & ssCoefficients) { - scratch = Aerodynamics->GetCoefficientValues(); - if (scratch.length() != 0) outstream << ", " << scratch; + scratch = Aerodynamics->GetCoefficientValues(delimeter); + if (scratch.length() != 0) outstream << delimeter << scratch; } if (SubSystems & ssFCS) { - scratch = FCS->GetComponentValues(); - if (scratch.length() != 0) outstream << ", " << scratch; + scratch = FCS->GetComponentValues(delimeter); + if (scratch.length() != 0) outstream << delimeter << scratch; } if (SubSystems & ssGroundReactions) { - outstream << ", "; - outstream << GroundReactions->GetGroundReactionValues(); + outstream << delimeter; + outstream << GroundReactions->GetGroundReactionValues(delimeter); } if (SubSystems & ssPropulsion && Propulsion->GetNumEngines() > 0) { - outstream << ", "; - outstream << Propulsion->GetPropulsionValues(); + outstream << delimeter; + outstream << Propulsion->GetPropulsionValues(delimeter); } for (unsigned int i=0;igetDoubleValue(); + outstream << delimeter << OutputProperties[i]->getDoubleValue(); } outstream << endl; diff --git a/src/FDM/JSBSim/FGOutput.h b/src/FDM/JSBSim/FGOutput.h index 40064d036..410e62fcb 100644 --- a/src/FDM/JSBSim/FGOutput.h +++ b/src/FDM/JSBSim/FGOutput.h @@ -161,7 +161,7 @@ public: private: bool sFirstPass, dFirstPass, enabled; int SubSystems; - string Filename, outputInFileName; + string Filename, outputInFileName, delimeter; enum {otNone, otCSV, otTab, otSocket, otTerminal, otUnknown} Type; ofstream datafile; FGfdmSocket* socket; diff --git a/src/FDM/JSBSim/FGPiston.cpp b/src/FDM/JSBSim/FGPiston.cpp index dde46eea4..0981f2e70 100644 --- a/src/FDM/JSBSim/FGPiston.cpp +++ b/src/FDM/JSBSim/FGPiston.cpp @@ -93,7 +93,7 @@ FGPiston::FGPiston(FGFDMExec* exec, FGConfigFile* Eng_cfg, int engine_number) bTakeoffBoost = false; TakeoffBoost = 0.0; // Default to no extra takeoff-boost int i; - for(i=0; iGetPowerRequired(); - return Thruster->Calculate(PowerAvailable); + return Thrust = Thruster->Calculate(PowerAvailable); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -698,23 +702,25 @@ void FGPiston::doOilPressure(void) //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -string FGPiston::GetEngineLabels(void) +string FGPiston::GetEngineLabels(string delimeter) { std::ostringstream buf; - buf << Name << "_PwrAvail[" << EngineNumber << "], " - << Thruster->GetThrusterLabels(EngineNumber); + buf << Name << "_PwrAvail[" << EngineNumber << "]" << delimeter + << Name << "_HP[" << EngineNumber << "]" << delimeter + << Thruster->GetThrusterLabels(EngineNumber, delimeter); return buf.str(); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -string FGPiston::GetEngineValues(void) +string FGPiston::GetEngineValues(string delimeter) { std::ostringstream buf; - buf << PowerAvailable << ", " << Thruster->GetThrusterValues(EngineNumber); + buf << PowerAvailable << delimeter << HP << delimeter + << Thruster->GetThrusterValues(EngineNumber, delimeter); return buf.str(); } diff --git a/src/FDM/JSBSim/FGPiston.h b/src/FDM/JSBSim/FGPiston.h index 197f36cc4..7039aa4d7 100644 --- a/src/FDM/JSBSim/FGPiston.h +++ b/src/FDM/JSBSim/FGPiston.h @@ -146,8 +146,8 @@ public: /// Destructor ~FGPiston(); - string GetEngineLabels(void); - string GetEngineValues(void); + string GetEngineLabels(string delimeter); + string GetEngineValues(string delimeter); double Calculate(void); double GetPowerAvailable(void) {return PowerAvailable;} diff --git a/src/FDM/JSBSim/FGPropagate.cpp b/src/FDM/JSBSim/FGPropagate.cpp index 57f489b5b..3890d6e64 100644 --- a/src/FDM/JSBSim/FGPropagate.cpp +++ b/src/FDM/JSBSim/FGPropagate.cpp @@ -210,12 +210,12 @@ bool FGPropagate::Run(void) // Compute body frame accelerations based on the current body forces vUVWdot = VState.vUVW*VState.vPQR + vForces/mass; - // Centrifugal acceleration. + // Coriolis acceleration. FGColumnVector3 ecVel = Tl2ec*vVel; FGColumnVector3 ace = 2.0*omega*ecVel; vUVWdot -= Tl2b*(Tec2l*ace); - // Coriolis acceleration. + // Centrifugal acceleration. FGColumnVector3 aeec = omega*(omega*VState.vLocation); vUVWdot -= Tl2b*(Tec2l*aeec); diff --git a/src/FDM/JSBSim/FGPropeller.cpp b/src/FDM/JSBSim/FGPropeller.cpp index 2832498ca..d205a3a62 100644 --- a/src/FDM/JSBSim/FGPropeller.cpp +++ b/src/FDM/JSBSim/FGPropeller.cpp @@ -124,7 +124,7 @@ FGPropeller::~FGPropeller() char property_name[80]; snprintf(property_name, 80, "propulsion/c-thrust[%u]", EngineNum); PropertyManager->Untie( property_name ); - + Debug(1); } @@ -252,16 +252,16 @@ FGColumnVector3 FGPropeller::GetPFactor() //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -string FGPropeller::GetThrusterLabels(int id) +string FGPropeller::GetThrusterLabels(int id, string delimeter) { std::ostringstream buf; - buf << Name << "_Torque[" << id << "], " - << Name << "_PFactor_Pitch[" << id << "], " - << Name << "_PFactor_Yaw[" << id << "], " - << Name << "_Thrust[" << id << "], "; + buf << Name << "_Torque[" << id << "]" << delimeter + << Name << "_PFactor_Pitch[" << id << "]" << delimeter + << Name << "_PFactor_Yaw[" << id << "]" << delimeter + << Name << "_Thrust[" << id << "]" << delimeter; if (IsVPitch()) - buf << Name << "_Pitch[" << id << "], "; + buf << Name << "_Pitch[" << id << "]" << delimeter; buf << Name << "_RPM[" << id << "]"; return buf.str(); @@ -269,17 +269,17 @@ string FGPropeller::GetThrusterLabels(int id) //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -string FGPropeller::GetThrusterValues(int id) +string FGPropeller::GetThrusterValues(int id, string delimeter) { std::ostringstream buf; FGColumnVector3 vPFactor = GetPFactor(); - buf << vTorque(eX) << ", " - << vPFactor(ePitch) << ", " - << vPFactor(eYaw) << ", " - << Thrust << ", "; + buf << vTorque(eX) << delimeter + << vPFactor(ePitch) << delimeter + << vPFactor(eYaw) << delimeter + << Thrust << delimeter; if (IsVPitch()) - buf << Pitch << ", "; + buf << Pitch << delimeter; buf << RPM; return buf.str(); diff --git a/src/FDM/JSBSim/FGPropeller.h b/src/FDM/JSBSim/FGPropeller.h index 0c8ba9f17..2d5037a97 100644 --- a/src/FDM/JSBSim/FGPropeller.h +++ b/src/FDM/JSBSim/FGPropeller.h @@ -153,8 +153,8 @@ public: @return the thrust in pounds */ double Calculate(double PowerAvailable); FGColumnVector3 GetPFactor(void); - string GetThrusterLabels(int id); - string GetThrusterValues(int id); + string GetThrusterLabels(int id, string delimeter); + string GetThrusterValues(int id, string delimeter); private: int numBlades; diff --git a/src/FDM/JSBSim/FGPropertyManager.cpp b/src/FDM/JSBSim/FGPropertyManager.cpp index 2b3843b89..42d632d4b 100644 --- a/src/FDM/JSBSim/FGPropertyManager.cpp +++ b/src/FDM/JSBSim/FGPropertyManager.cpp @@ -75,9 +75,9 @@ FGPropertyManager* FGPropertyManager::GetNode (const string &path, bool create) { SGPropertyNode* node=this->getNode(path.c_str(), create); - if(node == 0) - cout << "FGPropertyManager::GetNode() No node found for " - << path << endl; + //if(node == 0) + // cout << "FGPropertyManager::GetNode() No node found for " + // << path << endl; return (FGPropertyManager*)node; } diff --git a/src/FDM/JSBSim/FGPropulsion.cpp b/src/FDM/JSBSim/FGPropulsion.cpp index 09cf080c8..bdb0a211b 100644 --- a/src/FDM/JSBSim/FGPropulsion.cpp +++ b/src/FDM/JSBSim/FGPropulsion.cpp @@ -50,6 +50,7 @@ INCLUDES #include "FGPiston.h" #include "FGElectric.h" #include "FGPropertyManager.h" +#include namespace JSBSim { @@ -73,6 +74,7 @@ FGPropulsion::FGPropulsion(FGFDMExec* exec) : FGModel(exec) ActiveEngine = -1; // -1: ALL, 0: Engine 1, 1: Engine 2 ... tankJ.InitMatrix(); refuel = false; + fuel_freeze = false; bind(); @@ -93,6 +95,8 @@ FGPropulsion::~FGPropulsion() bool FGPropulsion::Run(void) { + unsigned int i; + if (FGModel::Run()) return true; double dt = State->Getdt(); @@ -100,18 +104,18 @@ bool FGPropulsion::Run(void) vForces.InitMatrix(); vMoments.InitMatrix(); - for (unsigned int i=0; iCalculate(); vForces += Engines[i]->GetBodyForces(); // sum body frame forces vMoments += Engines[i]->GetMoments(); // sum body frame moments } - for (unsigned int i=0; iCalculate( dt * rate ); } if (refuel) DoRefuel( dt * rate ); - + return false; } @@ -318,16 +322,23 @@ bool FGPropulsion::Load(FGConfigFile* AC_cfg) //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -string FGPropulsion::GetPropulsionStrings(void) +string FGPropulsion::GetPropulsionStrings(string delimeter) { + unsigned int i; + string PropulsionStrings = ""; bool firstime = true; + stringstream buf; - for (unsigned int i=0;iGetEngineLabels(); + PropulsionStrings += Engines[i]->GetEngineLabels(delimeter); + } + for (i=0; iGetType() == FGTank::ttFUEL) buf << delimeter << "Fuel Tank " << i; + else if (Tanks[i]->GetType() == FGTank::ttOXIDIZER) buf << delimeter << "Oxidizer Tank " << i; } return PropulsionStrings; @@ -335,16 +346,23 @@ string FGPropulsion::GetPropulsionStrings(void) //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -string FGPropulsion::GetPropulsionValues(void) +string FGPropulsion::GetPropulsionValues(string delimeter) { + unsigned int i; + string PropulsionValues = ""; bool firstime = true; + stringstream buf; - for (unsigned int i=0;iGetEngineValues(); + PropulsionValues += Engines[i]->GetEngineValues(delimeter); + } + for (i=0; iGetContents(); } return PropulsionValues; @@ -498,6 +516,16 @@ void FGPropulsion::DoRefuel(double time_slice) //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +void FGPropulsion::SetFuelFreeze(bool f) +{ + fuel_freeze = f; + for (unsigned int i=0; iSetFuelFreeze(f); + } +} + +//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + void FGPropulsion::bind(void) { typedef double (FGPropulsion::*PMF)(int) const; diff --git a/src/FDM/JSBSim/FGPropulsion.h b/src/FDM/JSBSim/FGPropulsion.h index 11a1fbb51..6d143f79b 100644 --- a/src/FDM/JSBSim/FGPropulsion.h +++ b/src/FDM/JSBSim/FGPropulsion.h @@ -150,8 +150,8 @@ public: be done before calling this (i.e. magnetos, starter engage, etc.) */ bool ICEngineStart(void); - string GetPropulsionStrings(void); - string GetPropulsionValues(void); + string GetPropulsionStrings(string delimeter); + string GetPropulsionValues(string delimeter); inline FGColumnVector3& GetForces(void) {return vForces; } inline double GetForces(int n) const { return vForces(n);} @@ -172,11 +172,13 @@ public: } inline int GetActiveEngine(void); + inline bool GetFuelFreeze(void) {return fuel_freeze;} void SetMagnetos(int setting); void SetStarter(int setting); void SetCutoff(int setting=0); void SetActiveEngine(int engine); + void SetFuelFreeze(bool f); FGMatrix33& CalculateTankInertias(void); void bind(); @@ -199,6 +201,7 @@ private: FGColumnVector3 vXYZtank_arm; FGMatrix33 tankJ; bool refuel; + bool fuel_freeze; void Debug(int from); }; diff --git a/src/FDM/JSBSim/FGRocket.cpp b/src/FDM/JSBSim/FGRocket.cpp index 0d0497b99..c7131f341 100644 --- a/src/FDM/JSBSim/FGRocket.cpp +++ b/src/FDM/JSBSim/FGRocket.cpp @@ -113,28 +113,28 @@ double FGRocket::Calculate(void) Flameout = false; } - return Thruster->Calculate(Cf*maxPC*PctPower*propEff); + return Thrust = Thruster->Calculate(Cf*maxPC*PctPower*propEff); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -string FGRocket::GetEngineLabels(void) +string FGRocket::GetEngineLabels(string delimeter) { std::ostringstream buf; - buf << Name << "_ChamberPress[" << EngineNumber << "], " - << Thruster->GetThrusterLabels(EngineNumber); + buf << Name << "_ChamberPress[" << EngineNumber << "]" << delimeter + << Thruster->GetThrusterLabels(EngineNumber, delimeter); return buf.str(); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -string FGRocket::GetEngineValues(void) +string FGRocket::GetEngineValues(string delimeter) { std::ostringstream buf; - buf << PC << ", " << Thruster->GetThrusterValues(EngineNumber); + buf << PC << delimeter << Thruster->GetThrusterValues(EngineNumber, delimeter); return buf.str(); } diff --git a/src/FDM/JSBSim/FGRocket.h b/src/FDM/JSBSim/FGRocket.h index a4d237e8b..00befb0d4 100644 --- a/src/FDM/JSBSim/FGRocket.h +++ b/src/FDM/JSBSim/FGRocket.h @@ -123,8 +123,8 @@ public: sustainable setting. @return true if engine has flamed out. */ bool GetFlameout(void) {return Flameout;} - string GetEngineLabels(void); - string GetEngineValues(void); + string GetEngineLabels(string delimeter); + string GetEngineValues(string delimeter); private: double SHR; diff --git a/src/FDM/JSBSim/FGRotor.cpp b/src/FDM/JSBSim/FGRotor.cpp index 8332f13a8..b1efdde76 100644 --- a/src/FDM/JSBSim/FGRotor.cpp +++ b/src/FDM/JSBSim/FGRotor.cpp @@ -68,14 +68,14 @@ double FGRotor::Calculate(double PowerAvailable) //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -string FGRotor::GetThrusterLabels(int id) +string FGRotor::GetThrusterLabels(int id, string delimeter) { return ""; } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -string FGRotor::GetThrusterValues(int id) +string FGRotor::GetThrusterValues(int id, string delimeter) { return ""; } diff --git a/src/FDM/JSBSim/FGRotor.h b/src/FDM/JSBSim/FGRotor.h index 2fddbaf2a..2e4b3b34d 100644 --- a/src/FDM/JSBSim/FGRotor.h +++ b/src/FDM/JSBSim/FGRotor.h @@ -70,8 +70,8 @@ public: ~FGRotor(); double Calculate(double); - string GetThrusterLabels(int id); - string GetThrusterValues(int id); + string GetThrusterLabels(int id, string delimeter); + string GetThrusterValues(int id, string delimeter); private: void Debug(int from); diff --git a/src/FDM/JSBSim/FGScript.cpp b/src/FDM/JSBSim/FGScript.cpp index 7c9ec35dd..4d77492cb 100644 --- a/src/FDM/JSBSim/FGScript.cpp +++ b/src/FDM/JSBSim/FGScript.cpp @@ -56,6 +56,7 @@ INCLUDES #include "FGScript.h" #include "FGConfigFile.h" +#include "FGTrim.h" namespace JSBSim { @@ -105,7 +106,7 @@ bool FGScript::LoadScript( string script ) if (Script.GetValue("runscript").length() <= 0) { cerr << "File: " << script << " is not a script file" << endl; delete FDMExec; - return false; + return false; } ScriptName = Script.GetValue("name"); Scripted = true; @@ -168,14 +169,14 @@ bool FGScript::LoadScript( string script ) else if (tempCompare == "FG_STEP") newCondition->Action.push_back(FG_STEP); else if (tempCompare == "FG_EXP") newCondition->Action.push_back(FG_EXP); else newCondition->Action.push_back((eAction)0); - + if (Script.GetValue("persistent") == "true") newCondition->Persistent.push_back(true); else newCondition->Persistent.push_back(false); - + newCondition->TC.push_back(strtod(Script.GetValue("tc").c_str(), NULL)); - + } else { cerr << "Unrecognized keyword in script file: \" [when] " << token << "\"" << endl; } @@ -212,6 +213,12 @@ bool FGScript::LoadScript( string script ) exit(-1); } + FGTrim fgt(FDMExec, tFull); + if ( !fgt.DoTrim() ) { + cout << "Trim Failed" << endl; + } + fgt.Report(); + return true; } diff --git a/src/FDM/JSBSim/FGThruster.cpp b/src/FDM/JSBSim/FGThruster.cpp index 2573daa9c..4d4a4edcb 100644 --- a/src/FDM/JSBSim/FGThruster.cpp +++ b/src/FDM/JSBSim/FGThruster.cpp @@ -72,11 +72,15 @@ FGThruster::FGThruster(FGFDMExec *FDMExec, EngineNum = num; ThrustCoeff = 0.0; + ReverserAngle = 0.0; PropertyManager = FDMExec->GetPropertyManager(); char property_name[80]; snprintf(property_name, 80, "propulsion/c-thrust[%u]", EngineNum); PropertyManager->Tie( property_name, &ThrustCoeff ); + snprintf(property_name, 80, "propulsion/engine[%u]/reverser-angle", EngineNum); + PropertyManager->Tie( property_name, &ReverserAngle ); + Debug(0); } @@ -88,13 +92,15 @@ FGThruster::~FGThruster() char property_name[80]; snprintf(property_name, 80, "propulsion/c-thrust[%u]", EngineNum); PropertyManager->Untie( property_name ); + snprintf(property_name, 80, "propulsion/engine[%u]/reverser-angle", EngineNum); + PropertyManager->Untie( property_name ); Debug(1); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -string FGThruster::GetThrusterLabels(int id) +string FGThruster::GetThrusterLabels(int id, string delimeter) { std::ostringstream buf; @@ -105,7 +111,7 @@ string FGThruster::GetThrusterLabels(int id) //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -string FGThruster::GetThrusterValues(int id) +string FGThruster::GetThrusterValues(int id, string delimeter) { std::ostringstream buf; diff --git a/src/FDM/JSBSim/FGThruster.h b/src/FDM/JSBSim/FGThruster.h index 35cc9d3f0..ff523588d 100644 --- a/src/FDM/JSBSim/FGThruster.h +++ b/src/FDM/JSBSim/FGThruster.h @@ -80,8 +80,9 @@ public: enum eType {ttNozzle, ttRotor, ttPropeller, ttDirect}; virtual double Calculate(double tt) { - Thrust = tt; vFn(1) = Thrust; - return 0.0; + Thrust = tt; + vFn(1) = Thrust * cos(ReverserAngle); + return vFn(1); } void SetName(string name) {Name = name;} virtual void SetRPM(double rpm) {}; @@ -92,8 +93,11 @@ public: string GetName(void) {return Name;} virtual double GetRPM(void) { return 0.0; }; double GetGearRatio(void) {return GearRatio; } - virtual string GetThrusterLabels(int id); - virtual string GetThrusterValues(int id); + virtual string GetThrusterLabels(int id, string delimeter); + virtual string GetThrusterValues(int id, string delimeter); + void SetReverserAngle(double radians) { ReverserAngle = radians; } + double GetReverserAngle(void) {return ReverserAngle;} + inline void SetThrustCoefficient(double ct) { ThrustCoeff = ct; } @@ -105,6 +109,7 @@ protected: double deltaT; double GearRatio; double ThrustCoeff; + double ReverserAngle; int EngineNum; FGPropertyManager* PropertyManager; virtual void Debug(int from); diff --git a/src/FDM/JSBSim/FGTrim.h b/src/FDM/JSBSim/FGTrim.h index 6d8069813..401d4d7d3 100644 --- a/src/FDM/JSBSim/FGTrim.h +++ b/src/FDM/JSBSim/FGTrim.h @@ -1,44 +1,44 @@ /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - + Header: FGTrim.h Author: Tony Peden Date started: 7/1/99 - + ------------- Copyright (C) 1999 Anthony K. Peden (apeden@earthlink.net) ------------- - + 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 -------------------------------------------------------------------------------- 9/8/99 TP Created - - + + FUNCTIONAL DESCRIPTION -------------------------------------------------------------------------------- - + This class takes the given set of IC's and finds the aircraft state required to -maintain a specified flight condition. This flight condition can be +maintain a specified flight condition. This flight condition can be steady-level with non-zero sideslip, a steady turn, a pull-up or pushover. On-ground conditions can be trimmed as well, but this is currently limited to adjusting altitude and pitch angle only. It is implemented using an iterative, -one-axis-at-a-time scheme. - +one-axis-at-a-time scheme. + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SENTRY %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ @@ -72,8 +72,8 @@ FORWARD DECLARATIONS namespace JSBSim { -typedef enum { tLongitudinal, tFull, tGround, tPullup, - tCustom, tNone, tTurn +typedef enum { tLongitudinal, tFull, tGround, tPullup, + tCustom, tNone, tTurn } TrimMode; /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -85,10 +85,10 @@ CLASS DOCUMENTATION the steady state described by the FGInitialCondition object . It does this iteratively by assigning a control to each state and adjusting that control until the state is within a specified tolerance of zero. States include the - recti-linear accelerations udot, vdot, and wdot, the angular accelerations + recti-linear accelerations udot, vdot, and wdot, the angular accelerations qdot, pdot, and rdot, and the difference between heading and ground track. Controls include the usual flight deck controls available to the pilot plus - angle of attack (alpha), sideslip angle(beta), flight path angle (gamma), + angle of attack (alpha), sideslip angle(beta), flight path angle (gamma), pitch attitude(theta), roll attitude(phi), and altitude above ground. The last three are used for on-ground trimming. The state-control pairs used in a given trim are completely user configurable and several pre-defined modes @@ -99,32 +99,32 @@ CLASS DOCUMENTATION - tPullup: tLongitudinal but adjust alpha to achieve load factor input with SetTargetNlf() - tGround: wdot with altitude, qdot with theta, and pdot with phi - + The remaining modes include tCustom, which is completely user defined and tNone. Note that trims can (and do) fail for reasons that are completely outside - the control of the trimming routine itself. The most common problem is the + the control of the trimming routine itself. The most common problem is the initial conditions: is the model capable of steady state flight at those conditions? Check the speed, altitude, configuration (flaps, gear, etc.), weight, cg, and anything else that may be relevant. - + Example usage:
     FGFDMExec* FDMExec = new FGFDMExec();
 
     FGInitialCondition* fgic = new FGInitialCondition(FDMExec);
-    FGTrim *fgt(FDMExec,fgic,tFull);
+    FGTrim fgt(FDMExec, fgic, tFull);
     fgic->SetVcaibratedKtsIC(100);
     fgic->SetAltitudeFtIC(1000);
     fgic->SetClimbRate(500);
-    if( !fgt->DoTrim() ) {
+    if( !fgt.DoTrim() ) {
       cout << "Trim Failed" << endl;
     }
-    fgt->ReportState(); 
+ fgt.Report(); @author Tony Peden @version "$Id$" -*/ - +*/ + /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% CLASS DECLARATION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ @@ -155,14 +155,14 @@ private: double xlo,xhi,alo,ahi; double targetNlf; int debug_axis; - + double psidot,thetadot; FGFDMExec* fdmex; FGInitialCondition* fgic; - + bool solve(void); - + /** @return false if there is no change in the current axis accel between accel(control_min) and accel(control_max). If there is a change, sets solutionDomain to: @@ -173,10 +173,10 @@ private: bool findInterval(void); bool checkLimits(void); - + void setupPullup(void); void setupTurn(void); - + void updateRates(void); void setDebug(void); @@ -194,17 +194,17 @@ public: */ bool DoTrim(void); - /** Print the results of the trim. For each axis trimmed, this + /** Print the results of the trim. For each axis trimmed, this includes the final state value, control value, and tolerance used. @return true if trim succeeds - */ + */ void Report(void); - + /** Iteration statistics */ void TrimStats(); - + /** Clear all state-control pairs and set a predefined trim mode @param tm the set of axes to trim. Can be: tLongitudinal, tFull, tGround, tCustom, or tNone @@ -214,26 +214,26 @@ public: /** Clear all state-control pairs from the current configuration. The trimming routine must have at least one state-control pair configured to be useful - */ + */ void ClearStates(void); /** Add a state-control pair to the current configuration. See the enums State and Control in FGTrimAxis.h for the available options. Will fail if the given state is already configured. - @param state the accel or other condition to zero + @param state the accel or other condition to zero @param control the control used to zero the state @return true if add is successful - */ + */ bool AddState( State state, Control control ); - + /** Remove a specific state-control pair from the current configuration @param state the state to remove @return true if removal is successful - */ + */ bool RemoveState( State state ); - + /** Change the control used to zero a state previously configured - @param state the accel or other condition to zero + @param state the accel or other condition to zero @param new_control the control used to zero the state */ bool EditState( State state, Control new_control ); @@ -242,9 +242,9 @@ public: flight path angle (gamma) once it becomes apparent that there is not enough/too much thrust. @param bb true to enable fallback - */ + */ inline void SetGammaFallback(bool bb) { gamma_fallback=bb; } - + /** query the fallback state @return true if fallback is enabled. */ @@ -253,40 +253,40 @@ public: /** Set the iteration limit. DoTrim() will return false if limit iterations are reached before trim is achieved. The default is 60. This does not ordinarily need to be changed. - @param ii integer iteration limit + @param ii integer iteration limit */ inline void SetMaxCycles(int ii) { max_iterations = ii; } - + /** Set the per-axis iteration limit. Attempt to zero each state by iterating limit times before moving on to the next. The default limit is 100 and also does not ordinarily need to be changed. - @param ii integer iteration limit - */ + @param ii integer iteration limit + */ inline void SetMaxCyclesPerAxis(int ii) { max_sub_iterations = ii; } - + /** Set the tolerance for declaring a state trimmed. Angular accels are - held to a tolerance of 1/10th of the given. The default is + held to a tolerance of 1/10th of the given. The default is 0.001 for the recti-linear accelerations and 0.0001 for the angular. - */ + */ inline void SetTolerance(double tt) { Tolerance = tt; A_Tolerance = tt / 10; } - - /** + + /** Debug level 1 shows results of each top-level iteration Debug level 2 shows level 1 & results of each per-axis iteration - */ + */ inline void SetDebug(int level) { DebugLevel = level; } inline void ClearDebug(void) { DebugLevel = 0; } - + /** Output debug data for one of the axes The State enum is defined in FGTrimAxis.h - */ + */ inline void DebugState(State state) { debug_axis=state; } - + inline void SetTargetNlf(float nlf) { targetNlf=nlf; } inline double GetTargetNlf(void) { return targetNlf; } diff --git a/src/FDM/JSBSim/FGTurbine.cpp b/src/FDM/JSBSim/FGTurbine.cpp index 909413f8b..d43031b38 100644 --- a/src/FDM/JSBSim/FGTurbine.cpp +++ b/src/FDM/JSBSim/FGTurbine.cpp @@ -113,21 +113,19 @@ double FGTurbine::Calculate(void) if (Stalled) phase = tpStall; if (Seized) phase = tpSeize; - double CT = 0.0; switch (phase) { case tpOff: Thrust = Off(); break; - case tpRun: Thrust = Run(CT); break; + case tpRun: Thrust = Run(); break; case tpSpinUp: Thrust = SpinUp(); break; case tpStart: Thrust = Start(); break; case tpStall: Thrust = Stall(); break; case tpSeize: Thrust = Seize(); break; - case tpTrim: Thrust = Trim(CT); break; + case tpTrim: Thrust = Trim(); break; default: Thrust = Off(); } - Thruster->SetThrustCoefficient(CT); - - return Thruster->Calculate(Thrust); + // The thruster can modify the thrust, eg. thrust reverser + return Thrust = Thruster->Calculate(Thrust); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -150,13 +148,12 @@ double FGTurbine::Off(void) //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -double FGTurbine::Run(double &TC) +double FGTurbine::Run(void) { double idlethrust, milthrust, thrust; double N2norm; // 0.0 = idle N2, 1.0 = maximum N2 - - idlethrust = ThrustTables[0]->TotalValue(); - milthrust = (1.0 - idlethrust) * ThrustTables[1]->TotalValue(); + idlethrust = MilThrust * ThrustTables[0]->TotalValue(); + milthrust = (MilThrust - idlethrust) * ThrustTables[1]->TotalValue(); Running = true; Starter = false; @@ -164,19 +161,18 @@ double FGTurbine::Run(double &TC) N2 = Seek(&N2, IdleN2 + ThrottlePos * N2_factor, delay, delay * 3.0); N1 = Seek(&N1, IdleN1 + ThrottlePos * N1_factor, delay, delay * 2.4); N2norm = (N2 - IdleN2) / N2_factor; - TC = idlethrust + (milthrust * N2norm * N2norm); - thrust = TC * MilThrust; + thrust = idlethrust + (milthrust * N2norm * N2norm); EGT_degC = TAT + 363.1 + ThrottlePos * 357.1; OilPressure_psi = N2 * 0.62; OilTemp_degK = Seek(&OilTemp_degK, 366.0, 1.2, 0.1); if (!Augmentation) { - double correctedTSFC = TSFC + TSFC - (N2norm * TSFC); + double correctedTSFC = TSFC * (0.84 + (1-N2norm)*(1-N2norm)); FuelFlow_pph = Seek(&FuelFlow_pph, thrust * correctedTSFC, 1000.0, 100000); if (FuelFlow_pph < IdleFF) FuelFlow_pph = IdleFF; NozzlePosition = Seek(&NozzlePosition, 1.0 - N2norm, 0.8, 0.8); - TC = TC * (1.0 - BleedDemand); - EPR = 1.0 + TC; + thrust = thrust * (1.0 - BleedDemand); + EPR = 1.0 + thrust/MilThrust; } if (AugMethod == 1) { @@ -185,8 +181,7 @@ double FGTurbine::Run(double &TC) } if ((Augmented == 1) && Augmentation && (AugMethod < 2)) { - TC = ThrustTables[2]->TotalValue(); - thrust = TC * MaxThrust; + thrust = MaxThrust * ThrustTables[2]->TotalValue(); FuelFlow_pph = Seek(&FuelFlow_pph, thrust * ATSFC, 5000.0, 10000.0); NozzlePosition = Seek(&NozzlePosition, 1.0, 0.8, 0.8); } @@ -194,9 +189,8 @@ double FGTurbine::Run(double &TC) if (AugMethod == 2) { if (AugmentCmd > 0.0) { Augmentation = true; - double tdiff = ThrustTables[2]->TotalValue() - TC; - TC += (tdiff * AugmentCmd); - thrust = TC * MaxThrust; + double tdiff = (MaxThrust * ThrustTables[2]->TotalValue()) - thrust; + thrust += (tdiff * AugmentCmd); FuelFlow_pph = Seek(&FuelFlow_pph, thrust * ATSFC, 5000.0, 10000.0); NozzlePosition = Seek(&NozzlePosition, 1.0, 0.8, 0.8); } else { @@ -205,8 +199,7 @@ double FGTurbine::Run(double &TC) } if ((Injected == 1) && Injection) { - TC = TC * ThrustTables[3]->TotalValue(); - thrust = thrust * ThrustTables[3]->TotalValue(); + thrust = thrust * ThrustTables[3]->TotalValue(); } ConsumeFuel(); @@ -244,6 +237,7 @@ double FGTurbine::Start(void) EGT_degC = Seek(&EGT_degC, TAT + 363.1, 21.3, 7.3); FuelFlow_pph = Seek(&FuelFlow_pph, IdleFF, 103.7, 103.7); OilPressure_psi = N2 * 0.62; + ConsumeFuel(); } else { phase = tpRun; @@ -269,6 +263,7 @@ double FGTurbine::Stall(void) FuelFlow_pph = IdleFF; N1 = Seek(&N1, qbar/10.0, 0, N1/10.0); N2 = Seek(&N2, qbar/15.0, 0, N2/10.0); + ConsumeFuel(); if (ThrottlePos < 0.01) phase = tpRun; // clear the stall with throttle return 0.0; @@ -282,6 +277,7 @@ double FGTurbine::Seize(void) N2 = 0.0; N1 = Seek(&N1, qbar/20.0, 0, N1/15.0); FuelFlow_pph = IdleFF; + ConsumeFuel(); OilPressure_psi = 0.0; OilTemp_degK = Seek(&OilTemp_degK, TAT + 273.0, 0, 0.2); Running = false; @@ -290,20 +286,17 @@ double FGTurbine::Seize(void) //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -double FGTurbine::Trim(double &TC) +double FGTurbine::Trim(void) { double idlethrust, milthrust, thrust, tdiff; - idlethrust = ThrustTables[0]->TotalValue();; - milthrust = (1.0 - TC) * ThrustTables[1]->TotalValue(); - TC = (idlethrust + (milthrust * ThrottlePos * ThrottlePos)) + idlethrust = MilThrust * ThrustTables[0]->TotalValue();; + milthrust = (MilThrust - idlethrust) * ThrustTables[1]->TotalValue(); + thrust = (idlethrust + (milthrust * ThrottlePos * ThrottlePos)) * (1.0 - BleedDemand); if (AugmentCmd > 0.0) { - tdiff = ThrustTables[2]->TotalValue() - TC; - TC += (tdiff * AugmentCmd); - thrust = TC * MaxThrust; - - } else - thrust = TC * MilThrust; + tdiff = (MaxThrust * ThrustTables[2]->TotalValue()) - thrust; + thrust += (tdiff * AugmentCmd); + } return thrust; } @@ -427,26 +420,26 @@ bool FGTurbine::Load(FGConfigFile *Eng_cfg) //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -string FGTurbine::GetEngineLabels(void) +string FGTurbine::GetEngineLabels(string delimeter) { std::ostringstream buf; - buf << Name << "_N1[" << EngineNumber << "], " - << Name << "_N2[" << EngineNumber << "], " - << Thruster->GetThrusterLabels(EngineNumber); + buf << Name << "_N1[" << EngineNumber << "]" << delimeter + << Name << "_N2[" << EngineNumber << "]" << delimeter + << Thruster->GetThrusterLabels(EngineNumber, delimeter); return buf.str(); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -string FGTurbine::GetEngineValues(void) +string FGTurbine::GetEngineValues(string delimeter) { std::ostringstream buf; - buf << N1 << ", " - << N2 << ", " - << Thruster->GetThrusterValues(EngineNumber); + buf << N1 << delimeter + << N2 << delimeter + << Thruster->GetThrusterValues(EngineNumber, delimeter); return buf.str(); } @@ -457,10 +450,12 @@ void FGTurbine::bindmodel() { char property_name[80]; - snprintf(property_name, 80, "propulsion/n1[%u]", EngineNumber); + snprintf(property_name, 80, "propulsion/engine[%u]/n1", EngineNumber); PropertyManager->Tie( property_name, &N1); - snprintf(property_name, 80, "propulsion/n2[%u]", EngineNumber); + snprintf(property_name, 80, "propulsion/engine[%u]/n2", EngineNumber); PropertyManager->Tie( property_name, &N2); + snprintf(property_name, 80, "propulsion/engine[%u]/fuel-flow", EngineNumber); + PropertyManager->Tie( property_name, &FuelFlow_pph); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -469,10 +464,12 @@ void FGTurbine::unbind() { char property_name[80]; - snprintf(property_name, 80, "propulsion/n1[%u]", EngineNumber); + snprintf(property_name, 80, "propulsion/engine[%u]/n1", EngineNumber); PropertyManager->Untie(property_name); - snprintf(property_name, 80, "propulsion/n2[%u]", EngineNumber); + snprintf(property_name, 80, "propulsion/engine[%u]/n2", EngineNumber); PropertyManager->Untie(property_name); + snprintf(property_name, 80, "propulsion/engine[%u]/fuel-flow", EngineNumber); + PropertyManager->Untie( property_name); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/src/FDM/JSBSim/FGTurbine.h b/src/FDM/JSBSim/FGTurbine.h index 547d5da75..5f685e611 100644 --- a/src/FDM/JSBSim/FGTurbine.h +++ b/src/FDM/JSBSim/FGTurbine.h @@ -182,8 +182,8 @@ public: void SetReverse(bool reversed) { Reversed = reversed; } void SetCutoff(bool cutoff) { Cutoff = cutoff; } - string GetEngineLabels(void); - string GetEngineValues(void); + string GetEngineLabels(string delimeter); + string GetEngineValues(string delimeter); private: @@ -233,12 +233,12 @@ private: double NozzlePosition; double Off(void); - double Run(double &CT); + double Run(); double SpinUp(void); double Start(void); double Stall(void); double Seize(void); - double Trim(double &CT); + double Trim(); void SetDefaults(void); bool Load(FGConfigFile *ENG_cfg); diff --git a/src/FDM/JSBSim/JSBSim.cxx b/src/FDM/JSBSim/JSBSim.cxx index 6a69fef38..3129a961e 100644 --- a/src/FDM/JSBSim/JSBSim.cxx +++ b/src/FDM/JSBSim/JSBSim.cxx @@ -2,7 +2,7 @@ // // Written by Curtis Olson, started February 1999. // -// Copyright (C) 1999 Curtis L. Olson - http://www.flightgear.org/~curt +// Copyright (C) 1999 Curtis L. Olson - curt@flightgear.org // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as @@ -171,7 +171,8 @@ FGJSBsim::FGJSBsim( double dt ) node->setDoubleValue("level-gal_us", Propulsion->GetTank(i)->GetContents() / 6.6); } } - + Propulsion->SetFuelFreeze((fgGetNode("/sim/freeze/fuel",true))->getBoolValue()); + fgSetDouble("/fdm/trim/pitch-trim", FCS->GetPitchTrimCmd()); fgSetDouble("/fdm/trim/throttle", FCS->GetThrottleCmd(0)); fgSetDouble("/fdm/trim/aileron", FCS->GetDaCmd()); @@ -503,7 +504,8 @@ bool FGJSBsim::copy_to_JSBsim() } SGPropertyNode* node = fgGetNode("/systems/refuel", true); Propulsion->SetRefuel(node->getDoubleValue("contact")); - + Propulsion->SetFuelFreeze((fgGetNode("/sim/freeze/fuel",true))->getBoolValue()); + return true; } @@ -692,11 +694,9 @@ bool FGJSBsim::copy_from_JSBsim() } - static const SGPropertyNode *fuel_freeze = fgGetNode("/sim/freeze/fuel"); - // Copy the fuel levels from JSBSim if fuel // freeze not enabled. - if ( ! fuel_freeze->getBoolValue() ) { + if ( ! Propulsion->GetFuelFreeze() ) { for (i = 0; i < Propulsion->GetNumTanks(); i++) { SGPropertyNode * node = fgGetNode("/consumables/fuel/tank", i, true); FGTank* tank = Propulsion->GetTank(i); diff --git a/src/FDM/JSBSim/JSBSim.hxx b/src/FDM/JSBSim/JSBSim.hxx index 961f88b1b..d1a54a5a3 100644 --- a/src/FDM/JSBSim/JSBSim.hxx +++ b/src/FDM/JSBSim/JSBSim.hxx @@ -5,7 +5,7 @@ Maintained by: Tony Peden, Curt Olson Date started: 02/01/1999 ------- Copyright (C) 1999 - 2000 Curtis L. Olson (http://www.flightgear.org/~curt) ------ +------ Copyright (C) 1999 - 2000 Curtis L. Olson (curt@flightgear.org) ------ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as diff --git a/src/FDM/JSBSim/filtersjb/FGFCSComponent.cpp b/src/FDM/JSBSim/filtersjb/FGFCSComponent.cpp index de20fad4e..41bb1ac39 100644 --- a/src/FDM/JSBSim/filtersjb/FGFCSComponent.cpp +++ b/src/FDM/JSBSim/filtersjb/FGFCSComponent.cpp @@ -89,7 +89,7 @@ FGPropertyManager* FGFCSComponent::resolveSymbol(string token) FGPropertyManager* tmp = PropertyManager->GetNode(token,false); if (!tmp) { if (token.find("/") == token.npos) prop = "model/" + token; - cerr << "Creating new property " << prop << endl; + //cerr << "Creating new property " << prop << endl; tmp = PropertyManager->GetNode(token,true); } return tmp;