diff --git a/src/FDM/JSBSim/FGFDMExec.cpp b/src/FDM/JSBSim/FGFDMExec.cpp
index 890342316..94088579a 100644
--- a/src/FDM/JSBSim/FGFDMExec.cpp
+++ b/src/FDM/JSBSim/FGFDMExec.cpp
@@ -134,6 +134,7 @@ FGFDMExec::FGFDMExec(FGPropertyManager* root) : Root(root)
modelLoaded = false;
IsSlave = false;
holding = false;
+ Terminate = false;
// Multiple FDM's are stopped for now. We need to ensure that
// the "user" instance always gets the zeroeth instance number,
@@ -168,6 +169,7 @@ FGFDMExec::FGFDMExec(FGPropertyManager* root) : Root(root)
Constructing = true;
typedef int (FGFDMExec::*iPMF)(void) const;
instance->Tie("simulation/do_trim", this, (iPMF)0, &FGFDMExec::DoTrim);
+ instance->Tie("simulation/terminate", (int *)&Terminate);
Constructing = false;
}
@@ -176,6 +178,7 @@ FGFDMExec::FGFDMExec(FGPropertyManager* root) : Root(root)
FGFDMExec::~FGFDMExec()
{
instance->Untie("simulation/do_trim");
+ instance->Untie("simulation/terminate");
try {
DeAllocate();
@@ -354,7 +357,7 @@ int FGFDMExec::Schedule(FGModel* model, int rate)
bool FGFDMExec::Run(void)
{
- bool success = false;
+ bool success=false;
FGModel* model_iterator;
model_iterator = FirstModel;
@@ -376,6 +379,7 @@ bool FGFDMExec::Run(void)
Frame++;
if (!Holding()) State->IncrTime();
+ if (Terminate) success = false;
return (success);
}
@@ -459,6 +463,9 @@ bool FGFDMExec::LoadModel(string model, bool addModelToPath)
string token;
string aircraftCfgFileName;
string separator = "/";
+ Element* element = 0L;
+
+ modelName = model; // Set the class modelName attribute
# ifdef macintosh
separator = ";";
@@ -474,27 +481,12 @@ bool FGFDMExec::LoadModel(string model, bool addModelToPath)
if (addModelToPath) FullAircraftPath += separator + model;
aircraftCfgFileName = FullAircraftPath + separator + model + ".xml";
- FGXMLParse *XMLParse = new FGXMLParse();
- Element* element = 0L;
- Element* document;
-
- ifstream input_file(aircraftCfgFileName.c_str());
-
- if (!input_file.is_open()) { // file open failed
- cerr << "Could not open file " << aircraftCfgFileName.c_str() << endl;
- return false;
- }
-
- readXML(input_file, *XMLParse);
- document = XMLParse->GetDocument();
-
- modelName = model;
-
if (modelLoaded) {
DeAllocate();
Allocate();
}
+ document = LoadXMLDocument(aircraftCfgFileName); // "document" is a class member
ReadPrologue(document);
element = document->GetElement();
@@ -553,7 +545,7 @@ void FGFDMExec::BuildPropertyCatalog(struct PropertyCatalogStructure* pcs)
int node_idx = 0;
char int_buf[10];
- for (int i=0; inode->nChildren(); i++) {
+ for (unsigned int i=0; inode->nChildren(); i++) {
pcsNew->base_string = pcs->base_string + "/" + pcs->node->getChild(i)->getName();
node_idx = pcs->node->getChild(i)->getIndex();
sprintf(int_buf, "[%d]", node_idx);
diff --git a/src/FDM/JSBSim/FGFDMExec.h b/src/FDM/JSBSim/FGFDMExec.h
index 6ae678cfd..b286fab9c 100644
--- a/src/FDM/JSBSim/FGFDMExec.h
+++ b/src/FDM/JSBSim/FGFDMExec.h
@@ -48,8 +48,8 @@ INCLUDES
#include
#include
#include
-#include
#include
+#include
#include
#include
@@ -173,7 +173,7 @@ CLASS DOCUMENTATION
CLASS DECLARATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-class FGFDMExec : public FGJSBBase
+class FGFDMExec : public FGJSBBase, public FGXMLFileRead
{
public:
@@ -414,6 +414,7 @@ private:
int Error;
unsigned int Frame;
unsigned int IdFDM;
+ unsigned short Terminate;
bool holding;
bool Constructing;
bool modelLoaded;
diff --git a/src/FDM/JSBSim/FGJSBBase.cpp b/src/FDM/JSBSim/FGJSBBase.cpp
index a9912cb69..259220dbb 100644
--- a/src/FDM/JSBSim/FGJSBBase.cpp
+++ b/src/FDM/JSBSim/FGJSBBase.cpp
@@ -94,9 +94,9 @@ const double FGJSBBase::slugtolb = 32.174049;
const double FGJSBBase::lbtoslug = 1.0/slugtolb;
const string FGJSBBase::needed_cfg_version = "2.0";
-const string FGJSBBase::JSBSim_version = "0.9.12 "__DATE__" "__TIME__;
+const string FGJSBBase::JSBSim_version = "Pre-1.0 "__DATE__" "__TIME__;
-std::queue FGJSBBase::Messages;
+std::queue FGJSBBase::Messages;
FGJSBBase::Message FGJSBBase::localMsg;
unsigned int FGJSBBase::messageId = 0;
@@ -104,83 +104,75 @@ short FGJSBBase::debug_lvl = 1;
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-FGJSBBase::Message* FGJSBBase::PutMessage(Message* msg)
+void FGJSBBase::PutMessage(const Message& msg)
{
Messages.push(msg);
- return msg;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-FGJSBBase::Message* FGJSBBase::PutMessage(const string& text)
+void FGJSBBase::PutMessage(const string& text)
{
- Message *msg = new Message();
- msg->text = text;
- msg->messageId = messageId++;
- msg->subsystem = "FDM";
- msg->type = Message::eText;
+ Message msg;
+ msg.text = text;
+ msg.messageId = messageId++;
+ msg.subsystem = "FDM";
+ msg.type = Message::eText;
Messages.push(msg);
- return msg;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-FGJSBBase::Message* FGJSBBase::PutMessage(const string& text, bool bVal)
+void FGJSBBase::PutMessage(const string& text, bool bVal)
{
- Message *msg = new Message();
- msg->text = text;
- msg->messageId = messageId++;
- msg->subsystem = "FDM";
- msg->type = Message::eBool;
- msg->bVal = bVal;
+ Message msg;
+ msg.text = text;
+ msg.messageId = messageId++;
+ msg.subsystem = "FDM";
+ msg.type = Message::eBool;
+ msg.bVal = bVal;
Messages.push(msg);
- return msg;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-FGJSBBase::Message* FGJSBBase::PutMessage(const string& text, int iVal)
+void FGJSBBase::PutMessage(const string& text, int iVal)
{
- Message *msg = new Message();
- msg->text = text;
- msg->messageId = messageId++;
- msg->subsystem = "FDM";
- msg->type = Message::eInteger;
- msg->bVal = (iVal != 0);
+ Message msg;
+ msg.text = text;
+ msg.messageId = messageId++;
+ msg.subsystem = "FDM";
+ msg.type = Message::eInteger;
+ msg.bVal = (iVal != 0);
Messages.push(msg);
- return msg;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-FGJSBBase::Message* FGJSBBase::PutMessage(const string& text, double dVal)
+void FGJSBBase::PutMessage(const string& text, double dVal)
{
- Message *msg = new Message();
- msg->text = text;
- msg->messageId = messageId++;
- msg->subsystem = "FDM";
- msg->type = Message::eDouble;
- msg->bVal = (dVal != 0.0);
+ Message msg;
+ msg.text = text;
+ msg.messageId = messageId++;
+ msg.subsystem = "FDM";
+ msg.type = Message::eDouble;
+ msg.bVal = (dVal != 0.0);
Messages.push(msg);
- return msg;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-FGJSBBase::Message* FGJSBBase::ReadMessage(void)
+int FGJSBBase::SomeMessages(void)
{
- if (!Messages.empty()) return Messages.front();
- else return NULL;
+ return !Messages.empty();
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FGJSBBase::Message* FGJSBBase::ProcessMessage(void)
{
- if (!Messages.empty())
- localMsg = *(Messages.front());
- else
- return NULL;
+ if (Messages.empty()) return NULL;
+ localMsg = Messages.front();
Messages.pop();
return &localMsg;
}
diff --git a/src/FDM/JSBSim/FGJSBBase.h b/src/FDM/JSBSim/FGJSBBase.h
index 6147248e6..2dd363738 100644
--- a/src/FDM/JSBSim/FGJSBBase.h
+++ b/src/FDM/JSBSim/FGJSBBase.h
@@ -125,7 +125,8 @@ public:
~FGJSBBase() {};
/// JSBSim Message structure
- typedef struct Msg {
+ class Message {
+ public:
unsigned int fdmId;
unsigned int messageId;
string text;
@@ -134,7 +135,7 @@ public:
bool bVal;
int iVal;
double dVal;
- } Message;
+ };
///@name JSBSim console output highlighting terms.
//@{
@@ -167,29 +168,29 @@ public:
/** Places a Message structure on the Message queue.
@param msg pointer to a Message structure
@return pointer to a Message structure */
- Message* PutMessage(Message* msg);
+void PutMessage(const Message& msg);
/** Creates a message with the given text and places it on the queue.
@param text message text
@return pointer to a Message structure */
- Message* PutMessage(const string& text);
+ void PutMessage(const string& text);
/** Creates a message with the given text and boolean value and places it on the queue.
@param text message text
@param bVal boolean value associated with the message
@return pointer to a Message structure */
- Message* PutMessage(const string& text, bool bVal);
+void PutMessage(const string& text, bool bVal);
/** Creates a message with the given text and integer value and places it on the queue.
@param text message text
@param iVal integer value associated with the message
@return pointer to a Message structure */
- Message* PutMessage(const string& text, int iVal);
+void PutMessage(const string& text, int iVal);
/** Creates a message with the given text and double value and places it on the queue.
@param text message text
@param dVal double value associated with the message
@return pointer to a Message structure */
- Message* PutMessage(const string& text, double dVal);
+void PutMessage(const string& text, double dVal);
/** Reads the message on the queue (but does not delete it).
- @return pointer to a Message structure (or NULL if no mesage) */
- Message* ReadMessage(void);
+ @return 1 if some messages */
+ int SomeMessages(void);
/** Reads the message on the queue and removes it from the queue.
@return pointer to a Message structure (or NULL if no mesage) */
Message* ProcessMessage(void);
@@ -276,7 +277,7 @@ public:
protected:
static Message localMsg;
- static std::queue Messages;
+ static std::queue Messages;
void Debug(int from) {};
diff --git a/src/FDM/JSBSim/FGState.cpp b/src/FDM/JSBSim/FGState.cpp
index 8945abdd4..29c174132 100644
--- a/src/FDM/JSBSim/FGState.cpp
+++ b/src/FDM/JSBSim/FGState.cpp
@@ -47,10 +47,6 @@ INCLUDES
# endif
#endif
-#ifdef _WIN32
-//#define snprintf _snprintf
-#endif
-
#include "FGState.h"
namespace JSBSim {
@@ -190,86 +186,6 @@ FGMatrix33& FGState::GetTb2s(void)
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-void FGState::ReportState(void)
-{
-#if 0
-#if !defined(__BORLANDCPP__)
- char out[80], flap[10], gear[12];
-
- cout << endl << " JSBSim State" << endl;
- snprintf(out,80," Weight: %7.0f lbs. CG: %5.1f, %5.1f, %5.1f inches\n",
- FDMExec->GetMassBalance()->GetWeight(),
- FDMExec->GetMassBalance()->GetXYZcg(1),
- FDMExec->GetMassBalance()->GetXYZcg(2),
- FDMExec->GetMassBalance()->GetXYZcg(3));
- cout << out;
- if ( FCS->GetDfPos() <= 0.01)
- snprintf(flap,10,"Up");
- else
- snprintf(flap,10,"%2.0f",FCS->GetDfPos());
-
- if (FCS->GetGearPos() < 0.01)
- snprintf(gear,12,"Up");
- else if (FCS->GetGearPos() > 0.99)
- snprintf(gear,12,"Down");
- else
- snprintf(gear,12,"In Transit");
-
- snprintf(out,80, " Flaps: %3s Gear: %12s\n",flap,gear);
- cout << out;
- snprintf(out,80, " Speed: %4.0f KCAS Mach: %5.2f\n",
- Auxiliary->GetVcalibratedKTS(),
- Auxiliary->GetMach() );
- cout << out;
- snprintf(out,80, " Altitude: %7.0f ft. AGL Altitude: %7.0f ft.\n",
- Propagate->Geth(),
- Propagate->GetDistanceAGL() );
- cout << out;
- snprintf(out,80, " Angle of Attack: %6.2f deg Pitch Angle: %6.2f deg\n",
- Auxiliary->Getalpha()*radtodeg,
- Propagate->Gettht()*radtodeg );
- cout << out;
- snprintf(out,80, " Flight Path Angle: %6.2f deg Climb Rate: %5.0f ft/min\n",
- Auxiliary->GetGamma()*radtodeg,
- Propagate->Gethdot()*60 );
- cout << out;
- snprintf(out,80, " Normal Load Factor: %4.2f g's Pitch Rate: %5.2f deg/s\n",
- Aircraft->GetNlf(),
- Propagate->GetPQR(2)*radtodeg );
- cout << out;
- snprintf(out,80, " Heading: %3.0f deg true Sideslip: %5.2f deg Yaw Rate: %5.2f deg/s\n",
- Propagate->Getpsi()*radtodeg,
- Auxiliary->Getbeta()*radtodeg,
- Propagate->GetPQR(3)*radtodeg );
- cout << out;
- snprintf(out,80, " Bank Angle: %5.2f deg Roll Rate: %5.2f deg/s\n",
- Propagate->Getphi()*radtodeg,
- Propagate->GetPQR(1)*radtodeg );
- cout << out;
- snprintf(out,80, " Elevator: %5.2f deg Left Aileron: %5.2f deg Rudder: %5.2f deg\n",
- FCS->GetDePos(ofRad)*radtodeg,
- FCS->GetDaLPos(ofRad)*radtodeg,
- FCS->GetDrPos(ofRad)*radtodeg );
- cout << out;
- snprintf(out,80, " Throttle: %5.2f%c\n",
- FCS->GetThrottlePos(0)*100,'%' );
- cout << out;
-
- snprintf(out,80, " Wind Components: %5.2f kts head wind, %5.2f kts cross wind\n",
- Auxiliary->GetHeadWind()*fpstokts,
- Auxiliary->GetCrossWind()*fpstokts );
- cout << out;
-
- snprintf(out,80, " Ground Speed: %4.0f knots , Ground Track: %3.0f deg true\n",
- Auxiliary->GetVground()*fpstokts,
- Auxiliary->GetGroundTrack()*radtodeg );
- cout << out;
-#endif
-#endif
-}
-
-//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
void FGState::bind(void)
{
PropertyManager->Tie("sim-time-sec", this, &FGState::Getsim_time);
diff --git a/src/FDM/JSBSim/JSBSim.cxx b/src/FDM/JSBSim/JSBSim.cxx
index e8e489846..2b59f3240 100644
--- a/src/FDM/JSBSim/JSBSim.cxx
+++ b/src/FDM/JSBSim/JSBSim.cxx
@@ -466,7 +466,7 @@ void FGJSBsim::update( double dt )
}
FGJSBBase::Message* msg;
- while (fdmex->ReadMessage()) {
+ while (fdmex->SomeMessages()) {
msg = fdmex->ProcessMessage();
switch (msg->type) {
case FGJSBBase::Message::eText:
@@ -1105,8 +1105,10 @@ void FGJSBsim::do_trim(void)
} else {
trimmed->setBoolValue(true);
}
+#if 0
if (FGJSBBase::debug_lvl > 0)
- State->ReportState();
+ State->ReportState(); /* FIXME: Function not implemented */
+#endif
delete fgtrim;
diff --git a/src/FDM/JSBSim/initialization/FGInitialCondition.cpp b/src/FDM/JSBSim/initialization/FGInitialCondition.cpp
index 9ee9d094e..7c2dc3dfc 100644
--- a/src/FDM/JSBSim/initialization/FGInitialCondition.cpp
+++ b/src/FDM/JSBSim/initialization/FGInitialCondition.cpp
@@ -732,9 +732,6 @@ double FGInitialCondition::GetWindDirDegIC(void) const {
bool FGInitialCondition::Load(string rstfile, bool useStoredPath)
{
string resetDef;
- ifstream initialization_file;
- FGXMLParse initialization_file_parser;
- Element *document, *el;
int n;
string sep = "/";
@@ -748,15 +745,8 @@ bool FGInitialCondition::Load(string rstfile, bool useStoredPath)
resetDef = rstfile;
}
- initialization_file.open(resetDef.c_str());
- if ( !initialization_file.is_open()) {
- cerr << "Could not open initialization file: " << resetDef << endl;
- return false;
- }
+ document = LoadXMLDocument(resetDef);
- readXML(initialization_file, initialization_file_parser);
- document = initialization_file_parser.GetDocument(); // document holds the
- // initialization description
if (document->GetName() != string("initialize")) {
cerr << "File: " << resetDef << " is not a reset file" << endl;
exit(-1);
@@ -803,10 +793,10 @@ bool FGInitialCondition::Load(string rstfile, bool useStoredPath)
if (document->FindElement("vground"))
SetVgroundKtsIC(document->FindElementValueAsNumberConvertTo("vground", "FT/SEC"));
if (document->FindElement("running")) {
- n = document->FindElementValueAsNumber("running");
+ n = int(document->FindElementValueAsNumber("running"));
if (n != 0) {
FGPropulsion* propulsion = fdmex->GetPropulsion();
- for(int i=0; iGetNumEngines(); i++) {
+ for(unsigned int i=0; iGetNumEngines(); i++) {
propulsion->GetEngine(i)->SetRunning(true);
}
}
diff --git a/src/FDM/JSBSim/initialization/FGInitialCondition.h b/src/FDM/JSBSim/initialization/FGInitialCondition.h
index 077f001f7..105297c1a 100644
--- a/src/FDM/JSBSim/initialization/FGInitialCondition.h
+++ b/src/FDM/JSBSim/initialization/FGInitialCondition.h
@@ -50,6 +50,7 @@ INCLUDES
#include
#include
#include
This method is where the bulk of the work gets done so calling it more than
once for the same set of native forces and moments should probably be avoided.
-Note that the moment calculations are done here as well so they should not be
+Note that the moment calculations are done here as well so they should be
retrieved after calling the GetBodyForces() method:
vM=fgf.GetMoments();
@@ -230,24 +230,7 @@ public:
/// Destructor
~FGForce();
- enum TransformType { tNone, tWindBody, tLocalBody, tCustom } ttype;
-
- inline void SetNativeForces(double Fnx, double Fny, double Fnz) {
- vFn(1)=Fnx;
- vFn(2)=Fny;
- vFn(3)=Fnz;
- }
- inline void SetNativeForces(FGColumnVector3 vv) { vFn = vv; };
-
- inline void SetNativeMoments(double Ln,double Mn, double Nn) {
- vMn(1)=Ln;
- vMn(2)=Mn;
- vMn(3)=Nn;
- }
- inline void SetNativeMoments(FGColumnVector3 vv) { vMn = vv; }
-
- inline FGColumnVector3& GetNativeForces(void) { return vFn; }
- inline FGColumnVector3& GetNativeMoments(void) { return vMn; }
+ enum TransformType { tNone, tWindBody, tLocalBody, tCustom };
FGColumnVector3& GetBodyForces(void);
@@ -305,18 +288,15 @@ public:
SetAnglesToBody(vv(eRoll), vv(ePitch), vv(eYaw));
}
- void SetPitch(double pitch) {vOrient(ePitch) = pitch;}
- void SetYaw(double yaw) {vOrient(eYaw) = yaw;}
+ void UpdateCustomTransformMatrix(void);
+ void SetPitch(double pitch) {vOrient(ePitch) = pitch; UpdateCustomTransformMatrix();}
+ void SetYaw(double yaw) {vOrient(eYaw) = yaw; UpdateCustomTransformMatrix();}
double GetPitch(void) const {return vOrient(ePitch);}
double GetYaw(void) const {return vOrient(eYaw);}
- inline void SetSense(double x, double y, double z) { vSense(eX)=x, vSense(eY)=y, vSense(eZ)=z; }
- inline void SetSense(FGColumnVector3 vv) { vSense=vv; }
-
inline FGColumnVector3& GetAnglesToBody(void) {return vOrient;}
inline double GetAnglesToBody(int axis) {return vOrient(axis);}
- inline FGColumnVector3& GetSense(void) { return vSense; }
inline void SetTransformType(TransformType ii) { ttype=ii; }
inline TransformType GetTransformType(void) { return ttype; }
@@ -329,14 +309,14 @@ protected:
FGColumnVector3 vMn;
FGColumnVector3 vH;
FGColumnVector3 vOrient;
+ TransformType ttype;
+ FGColumnVector3 vXYZn;
+ FGColumnVector3 vActingXYZn;
private:
FGColumnVector3 vFb;
FGColumnVector3 vM;
- FGColumnVector3 vXYZn;
- FGColumnVector3 vActingXYZn;
FGColumnVector3 vDXYZ;
- FGColumnVector3 vSense;
FGMatrix33 mT;
diff --git a/src/FDM/JSBSim/models/propulsion/FGNozzle.cpp b/src/FDM/JSBSim/models/propulsion/FGNozzle.cpp
index 5b0b58a20..476f4a988 100644
--- a/src/FDM/JSBSim/models/propulsion/FGNozzle.cpp
+++ b/src/FDM/JSBSim/models/propulsion/FGNozzle.cpp
@@ -83,7 +83,7 @@ FGNozzle::FGNozzle(FGFDMExec* FDMExec, Element* nozzle_element, int num)
Type = ttNozzle;
Area2 = (Diameter*Diameter/4.0)*M_PI;
AreaT = Area2/ExpR;
-
+
Debug(0);
}
@@ -99,7 +99,11 @@ FGNozzle::~FGNozzle()
double FGNozzle::Calculate(double CfPc)
{
double pAtm = fdmex->GetAtmosphere()->GetPressure();
- Thrust = max((double)0.0, (CfPc * AreaT + (PE - pAtm)*Area2) * nzlEff);
+ if (CfPc > 0)
+ Thrust = max((double)0.0, (CfPc * AreaT + (PE - pAtm)*Area2) * nzlEff);
+ else
+ Thrust = 0.0;
+
vFn(1) = Thrust * cos(ReverserAngle);
ThrustCoeff = max((double)0.0, CfPc / ((pAtm - PE) * Area2));
@@ -120,7 +124,7 @@ string FGNozzle::GetThrusterLabels(int id, string delimeter)
{
std::ostringstream buf;
- buf << Name << "_Thrust[" << id << ']';
+ buf << Name << " Thrust (engine " << id << " in lbs)";
return buf.str();
}
diff --git a/src/FDM/JSBSim/models/propulsion/FGPiston.cpp b/src/FDM/JSBSim/models/propulsion/FGPiston.cpp
index 94b54c35d..3526b6d7d 100644
--- a/src/FDM/JSBSim/models/propulsion/FGPiston.cpp
+++ b/src/FDM/JSBSim/models/propulsion/FGPiston.cpp
@@ -198,7 +198,7 @@ FGPiston::FGPiston(FGFDMExec* exec, Element* el, int engine_number)
}
minMAP = MinManifoldPressure_inHg * 3386.38; // inHg to Pa
maxMAP = MaxManifoldPressure_inHg * 3386.38;
- StarterHP = sqrt(MaxHP) * 0.2;
+ StarterHP = sqrt(MaxHP) * 0.4;
// Set up and sanity-check the turbo/supercharging configuration based on the input values.
if (TakeoffBoost > RatedBoost[0]) bTakeoffBoost = true;
@@ -580,7 +580,7 @@ void FGPiston::doEnginePower(void)
if (RPM < 10) {
HP = StarterHP;
} else if (RPM < 480) {
- HP = StarterHP + ((480 - RPM) / 10.0);
+ HP = StarterHP + ((480 - RPM) / 8.0);
// This is a guess - would be nice to find a proper starter moter torque curve
} else {
HP = StarterHP;
@@ -593,7 +593,7 @@ void FGPiston::doEnginePower(void)
HP = 0.0;
}
}
- //cout << "Power = " << HP << '\n';
+// cout << "Power = " << HP << " RPM = " << RPM << " Running = " << Running << " Cranking = " << Cranking << endl;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -729,10 +729,10 @@ string FGPiston::GetEngineLabels(string delimeter)
{
std::ostringstream buf;
- buf << Name << "_PwrAvail[" << EngineNumber << "]" << delimeter
- << Name << "_HP[" << EngineNumber << "]" << delimeter
- << Name << "_equiv_ratio[" << EngineNumber << "]" << delimeter
- << Name << "_MAP[" << EngineNumber << "]" << delimeter
+ buf << Name << " Power Available (engine " << EngineNumber << " in HP)" << delimeter
+ << Name << " HP (engine " << EngineNumber << ")" << delimeter
+ << Name << " equivalent ratio (engine " << EngineNumber << ")" << delimeter
+ << Name << " MAP (engine " << EngineNumber << ")" << delimeter
<< Thruster->GetThrusterLabels(EngineNumber, delimeter);
return buf.str();
diff --git a/src/FDM/JSBSim/models/propulsion/FGPropeller.cpp b/src/FDM/JSBSim/models/propulsion/FGPropeller.cpp
index ea5ad91b2..4925d5a05 100644
--- a/src/FDM/JSBSim/models/propulsion/FGPropeller.cpp
+++ b/src/FDM/JSBSim/models/propulsion/FGPropeller.cpp
@@ -60,7 +60,6 @@ FGPropeller::FGPropeller(FGFDMExec* exec, Element* prop_element, int num)
: FGThruster(exec, prop_element, num)
{
string token;
- int rows, cols;
Element *table_element, *local_element;
string name="";
FGPropertyManager* PropertyManager = exec->GetPropertyManager();
@@ -297,13 +296,13 @@ string FGPropeller::GetThrusterLabels(int id, string delimeter)
{
std::ostringstream buf;
- buf << Name << "_Torque[" << id << "]" << delimeter
- << Name << "_PFactor_Pitch[" << id << "]" << delimeter
- << Name << "_PFactor_Yaw[" << id << "]" << delimeter
- << Name << "_Thrust[" << id << "]" << delimeter;
+ buf << Name << " Torque (engine " << id << ")" << delimeter
+ << Name << " PFactor Pitch (engine " << id << ")" << delimeter
+ << Name << " PFactor Yaw (engine " << id << ")" << delimeter
+ << Name << " Thrust (engine " << id << " in lbs)" << delimeter;
if (IsVPitch())
- buf << Name << "_Pitch[" << id << "]" << delimeter;
- buf << Name << "_RPM[" << id << "]";
+ buf << Name << " Pitch (engine " << id << ")" << delimeter;
+ buf << Name << " RPM (engine " << id << ")";
return buf.str();
}
diff --git a/src/FDM/JSBSim/models/propulsion/FGRocket.cpp b/src/FDM/JSBSim/models/propulsion/FGRocket.cpp
index d4c0fa0e1..ada946f9d 100644
--- a/src/FDM/JSBSim/models/propulsion/FGRocket.cpp
+++ b/src/FDM/JSBSim/models/propulsion/FGRocket.cpp
@@ -54,6 +54,15 @@ CLASS IMPLEMENTATION
FGRocket::FGRocket(FGFDMExec* exec, Element *el, int engine_number)
: FGEngine(exec, el, engine_number)
{
+ Element* thrust_table_element = 0;
+ ThrustTable = 0L;
+ BurnTime = 0.0;
+
+ // Defaults
+ Variance = 0.0;
+ MinThrottle = 0.0;
+ MaxThrottle = 1.0;
+
if (el->FindElement("shr"))
SHR = el->FindElementValueAsNumber("shr");
if (el->FindElement("max_pc"))
@@ -71,6 +80,11 @@ FGRocket::FGRocket(FGFDMExec* exec, Element *el, int engine_number)
if (el->FindElement("variance"))
Variance = el->FindElementValueAsNumber("variance");
+ thrust_table_element = el->FindElement("thrust_table");
+ if (thrust_table_element) {
+ ThrustTable = new FGTable(PropertyManager, thrust_table_element);
+ }
+
Debug(0);
Type = etRocket;
@@ -97,6 +111,18 @@ double FGRocket::Calculate(void)
Throttle = FCS->GetThrottlePos(EngineNumber);
+ // If there is a thrust table, it is a function of elapsed burn time. The engine
+ // is started when the throttle is advanced to 1.0. After that, it burns
+ // without regard to throttle setting. The table returns a value between zero
+ // and one, representing the percentage of maximum vacuum thrust being applied.
+
+ if (ThrustTable != 0L) {
+ if (Throttle == 1 || BurnTime > 0.0) {
+ BurnTime += State->Getdt();
+ }
+ Throttle = ThrustTable->GetValue(BurnTime);
+ }
+
if (Throttle < MinThrottle || Starved) {
PctPower = Thrust = 0.0; // desired thrust
Flameout = true;
@@ -122,7 +148,7 @@ string FGRocket::GetEngineLabels(string delimeter)
{
std::ostringstream buf;
- buf << Name << "_ChamberPress[" << EngineNumber << "]" << delimeter
+ buf << Name << " Chamber Pressure (engine " << EngineNumber << " in psf)" << delimeter
<< Thruster->GetThrusterLabels(EngineNumber, delimeter);
return buf.str();
diff --git a/src/FDM/JSBSim/models/propulsion/FGRocket.h b/src/FDM/JSBSim/models/propulsion/FGRocket.h
index eac74251c..42436cc33 100644
--- a/src/FDM/JSBSim/models/propulsion/FGRocket.h
+++ b/src/FDM/JSBSim/models/propulsion/FGRocket.h
@@ -39,6 +39,7 @@ INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#include "FGEngine.h"
+#include
#include
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -83,6 +84,45 @@ CLASS DOCUMENTATION
coefficient is multiplied by the chamber pressure and then passed
to the nozzle Calculate() routine, where the thrust force is
determined.
+
+ One can model the thrust of a solid rocket by providing a normalized thrust table
+ as a function of time. For instance, the space shuttle solid rocket booster
+ normalized thrust value looks roughly like this:
+
+
+
+The left column is time, the right column is normalized thrust. Inside the
+FGRocket class code, the maximum thrust is calculated, and multiplied by this
+table. The Rocket class also tracks burn time. All that needs to be done is
+for the rocket engine to be throttle up to 1. At that time, the solid rocket
+fuel begins burning and thrust is provided.
@author Jon S. Berndt
$Id$
@@ -133,7 +173,9 @@ private:
double kFactor;
double Variance;
double PC;
+ double BurnTime;
bool Flameout;
+ FGTable* ThrustTable;
void Debug(int from);
};
diff --git a/src/FDM/JSBSim/models/propulsion/FGThruster.cpp b/src/FDM/JSBSim/models/propulsion/FGThruster.cpp
index 8cf4bf894..02875b2a1 100644
--- a/src/FDM/JSBSim/models/propulsion/FGThruster.cpp
+++ b/src/FDM/JSBSim/models/propulsion/FGThruster.cpp
@@ -58,7 +58,7 @@ FGThruster::FGThruster(FGFDMExec *FDMExec, Element *el, int num ): FGForce(FDMEx
Type = ttDirect;
SetTransformType(FGForce::tCustom);
- Name = el->GetName();
+ Name = el->GetAttributeValue("name");
GearRatio = 1.0;
ReverserAngle = 0.0;
@@ -73,7 +73,7 @@ FGThruster::FGThruster(FGFDMExec *FDMExec, Element *el, int num ): FGForce(FDMEx
else cerr << "No thruster location found." << endl;
element = thruster_element->FindElement("orient");
- if (element) orientation = element->FindElementTripletConvertTo("IN");
+ if (element) orientation = element->FindElementTripletConvertTo("RAD");
else cerr << "No thruster orientation found." << endl;
SetLocation(location);
@@ -122,7 +122,7 @@ string FGThruster::GetThrusterLabels(int id, string delimeter)
{
std::ostringstream buf;
- buf << Name << "_Thrust[" << id << "]";
+ buf << Name << " Thrust (engine " << id << " in lbs)";
return buf.str();
}
diff --git a/src/FDM/JSBSim/models/propulsion/FGTurboProp.cpp b/src/FDM/JSBSim/models/propulsion/FGTurboProp.cpp
index 057d961f0..6191e2149 100755
--- a/src/FDM/JSBSim/models/propulsion/FGTurboProp.cpp
+++ b/src/FDM/JSBSim/models/propulsion/FGTurboProp.cpp
@@ -278,7 +278,7 @@ double FGTurboProp::Off(void)
double FGTurboProp::Run(void)
{
- double idlethrust, milthrust, thrust = 0.0, EngPower_HP, eff_coef;
+ double thrust = 0.0, EngPower_HP, eff_coef;
Running = true; Starter = false; EngStarting = false;
//---