From: Erik Hofman
Date: Fri, 30 Oct 2015 09:10:01 +0000 (+0100)
Subject: Sync. with JSBSim again
X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=a0e31b55654e6f1e98066e804f374220047389c4;p=flightgear.git
Sync. with JSBSim again
---
diff --git a/src/FDM/JSBSim/FGFDMExec.cpp b/src/FDM/JSBSim/FGFDMExec.cpp
index d955bc963..0c73e8cae 100644
--- a/src/FDM/JSBSim/FGFDMExec.cpp
+++ b/src/FDM/JSBSim/FGFDMExec.cpp
@@ -63,20 +63,17 @@ INCLUDES
#include "models/FGAuxiliary.h"
#include "models/FGInput.h"
#include "models/FGOutput.h"
-#include "initialization/FGInitialCondition.h"
#include "initialization/FGTrim.h"
#include "initialization/FGSimplexTrim.h"
#include "initialization/FGLinearization.h"
-#include "input_output/FGPropertyManager.h"
#include "input_output/FGScript.h"
#include "input_output/FGXMLFileRead.h"
-#include "input_output/FGXMLElement.h"
using namespace std;
namespace JSBSim {
-IDENT(IdSrc,"$Id: FGFDMExec.cpp,v 1.171 2015/02/15 12:03:21 bcoconni Exp $");
+IDENT(IdSrc,"$Id: FGFDMExec.cpp,v 1.181 2015/10/25 21:18:29 dpculp Exp $");
IDENT(IdHdr,ID_FDMEXEC);
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -162,6 +159,7 @@ FGFDMExec::FGFDMExec(FGPropertyManager* root, unsigned int* fdmctr) : Root(root)
trim_status = false;
ta_mode = 99;
+ trim_completed = 0;
Constructing = true;
typedef int (FGFDMExec::*iPMF)(void) const;
@@ -177,6 +175,7 @@ FGFDMExec::FGFDMExec(FGPropertyManager* root, unsigned int* fdmctr) : Root(root)
instance->Tie("simulation/dt", this, &FGFDMExec::GetDeltaT);
instance->Tie("simulation/jsbsim-debug", this, &FGFDMExec::GetDebugLevel, &FGFDMExec::SetDebugLevel);
instance->Tie("simulation/frame", (int *)&Frame, false);
+ instance->Tie("simulation/trim-completed", (int *)&trim_completed, false);
// simplex trim properties
instanceRoot->SetDouble("trim/solver/rtol",0.0001);
@@ -451,7 +450,6 @@ void FGFDMExec::LoadInputs(unsigned int idx)
// Dynamic inputs come into the components that FCS manages through properties
break;
case ePropulsion:
- Propulsion->in.SLPressure = Atmosphere->GetPressureSL();
Propulsion->in.Pressure = Atmosphere->GetPressure();
Propulsion->in.PressureRatio = Atmosphere->GetPressureRatio();
Propulsion->in.Temperature = Atmosphere->GetTemperature();
@@ -459,7 +457,6 @@ void FGFDMExec::LoadInputs(unsigned int idx)
Propulsion->in.Density = Atmosphere->GetDensity();
Propulsion->in.Soundspeed = Atmosphere->GetSoundSpeed();
Propulsion->in.TotalPressure = Auxiliary->GetTotalPressure();
- Propulsion->in.TotalTempearture = Auxiliary->GetTotalTemperature();
Propulsion->in.Vc = Auxiliary->GetVcalibratedKTS();
Propulsion->in.Vt = Auxiliary->GetVt();
Propulsion->in.qbar = Auxiliary->Getqbar();
@@ -577,7 +574,6 @@ void FGFDMExec::LoadPlanetConstants(void)
Propagate->in.SemiMajor = Inertial->GetSemimajor();
Propagate->in.SemiMinor = Inertial->GetSemiminor();
Auxiliary->in.SLGravity = Inertial->SLgravity();
- Auxiliary->in.ReferenceRadius = Inertial->GetRefRadius();
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -585,7 +581,6 @@ void FGFDMExec::LoadPlanetConstants(void)
void FGFDMExec::LoadModelConstants(void)
{
Winds->in.wingspan = Aircraft->GetWingSpan();
- FCS->in.NumGear = GroundReactions->GetNumGearUnits();
Aerodynamics->in.Wingarea = Aircraft->GetWingArea();
Aerodynamics->in.Wingchord = Aircraft->Getcbar();
Aerodynamics->in.Wingincidence = Aircraft->GetWingIncidence();
@@ -604,14 +599,24 @@ bool FGFDMExec::RunIC(void)
{
FGPropulsion* propulsion = (FGPropulsion*)Models[ePropulsion];
+ SuspendIntegration(); // saves the integration rate, dt, then sets it to 0.0.
+ Initialize(IC);
+
Models[eInput]->InitModel();
Models[eOutput]->InitModel();
- SuspendIntegration(); // saves the integration rate, dt, then sets it to 0.0.
- Initialize(IC);
Run();
ResumeIntegration(); // Restores the integration rate to what it was.
+ if (debug_lvl > 0) {
+ MassBalance->GetMassPropertiesReport(0);
+
+ cout << endl << fgblue << highint
+ << "End of vehicle configuration loading." << endl
+ << "-------------------------------------------------------------------------------"
+ << reset << setprecision(6) << endl;
+ }
+
for (unsigned int n=0; n < propulsion->GetNumEngines(); ++n) {
if (IC->IsEngineRunning(n)) {
try {
@@ -628,20 +633,12 @@ bool FGFDMExec::RunIC(void)
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-void FGFDMExec::Initialize(FGInitialCondition *FGIC)
+void FGFDMExec::Initialize(FGInitialCondition* FGIC)
{
- Setsim_time(0.0);
-
- Propagate->SetInitialState( FGIC );
- LoadInputs(eInertial);
- Inertial->Run(false);
- LoadInputs(eAccelerations);
- Accelerations->Run(false);
- LoadInputs(ePropagate);
- Propagate->InitializeDerivatives();
+ Propagate->SetInitialState(FGIC);
Winds->SetWindNED(FGIC->GetWindNEDFpsIC());
- LoadInputs(eMassBalance);
- MassBalance->Run(false);
+ Run();
+ Propagate->InitializeDerivatives();
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -660,9 +657,12 @@ void FGFDMExec::ResetToInitialConditions(int mode)
Models[i]->InitModel();
}
- if (Script) Script->ResetEvents();
-
RunIC();
+
+ if (Script)
+ Script->ResetEvents();
+ else
+ Setsim_time(0.0);
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -829,7 +829,7 @@ bool FGFDMExec::LoadModel(const string& model, bool addModelToPath)
// Process the system element[s]. This element is OPTIONAL, and there may be more than one.
element = document->FindElement("system");
while (element) {
- result = ((FGFCS*)Models[eSystems])->Load(element, FGFCS::stSystem);
+ result = ((FGFCS*)Models[eSystems])->Load(element);
if (!result) {
cerr << endl << "Aircraft system element has problems in file " << aircraftCfgFileName << endl;
return result;
@@ -840,7 +840,7 @@ bool FGFDMExec::LoadModel(const string& model, bool addModelToPath)
// Process the autopilot element. This element is OPTIONAL.
element = document->FindElement("autopilot");
if (element) {
- result = ((FGFCS*)Models[eSystems])->Load(element, FGFCS::stAutoPilot);
+ result = ((FGFCS*)Models[eSystems])->Load(element);
if (!result) {
cerr << endl << "Aircraft autopilot element has problems in file " << aircraftCfgFileName << endl;
return result;
@@ -850,7 +850,7 @@ bool FGFDMExec::LoadModel(const string& model, bool addModelToPath)
// Process the flight_control element. This element is OPTIONAL.
element = document->FindElement("flight_control");
if (element) {
- result = ((FGFCS*)Models[eSystems])->Load(element, FGFCS::stFCS);
+ result = ((FGFCS*)Models[eSystems])->Load(element);
if (!result) {
cerr << endl << "Aircraft flight_control element has problems in file " << aircraftCfgFileName << endl;
return result;
@@ -904,21 +904,6 @@ bool FGFDMExec::LoadModel(const string& model, bool addModelToPath)
modelLoaded = true;
- if (debug_lvl > 0) {
- LoadInputs(eMassBalance); // Update all input mass properties for the report.
- Models[eMassBalance]->Run(false); // Update all mass properties for the report.
- LoadInputs(ePropulsion); // Update propulsion properties for the report.
- Models[ePropulsion]->Run(false); // Update propulsion properties for the report.
- LoadInputs(eMassBalance); // Update all (one more time) input mass properties for the report.
- Models[eMassBalance]->Run(false); // Update all (one more time) mass properties for the report.
- ((FGMassBalance*)Models[eMassBalance])->GetMassPropertiesReport(0);
-
- cout << endl << fgblue << highint
- << "End of vehicle configuration loading." << endl
- << "-------------------------------------------------------------------------------"
- << reset << endl;
- }
-
if (IsChild) debug_lvl = saved_debug_lvl;
} else {
@@ -1188,19 +1173,18 @@ void FGFDMExec::CheckIncrementalHold(void)
void FGFDMExec::DoTrim(int mode)
{
- double saved_time;
-
if (Constructing) return;
if (mode < 0 || mode > JSBSim::tNone) {
cerr << endl << "Illegal trimming mode!" << endl << endl;
return;
}
- saved_time = sim_time;
+
+
FGTrim trim(this, (JSBSim::TrimMode)mode);
if ( !trim.DoTrim() ) cerr << endl << "Trim Failed" << endl << endl;
trim.Report();
- Setsim_time(saved_time);
+ trim_completed = 1;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -1217,6 +1201,7 @@ void FGFDMExec::DoSimplexTrim(int mode)
FGSimplexTrim trim(this, (JSBSim::TrimMode)mode);
Setsim_time(saved_time);
std::cout << "dT: " << dT << std::endl;
+ trim_completed = 1;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
diff --git a/src/FDM/JSBSim/FGFDMExec.h b/src/FDM/JSBSim/FGFDMExec.h
index d03f1b826..c1b4fc07c 100644
--- a/src/FDM/JSBSim/FGFDMExec.h
+++ b/src/FDM/JSBSim/FGFDMExec.h
@@ -54,7 +54,7 @@ INCLUDES
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_FDMEXEC "$Id: FGFDMExec.h,v 1.95 2015/02/07 17:52:36 bcoconni Exp $"
+#define ID_FDMEXEC "$Id: FGFDMExec.h,v 1.102 2015/10/25 21:18:29 dpculp Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
@@ -178,7 +178,7 @@ CLASS DOCUMENTATION
property actually maps toa function call of DoTrim().
@author Jon S. Berndt
- @version $Revision: 1.95 $
+ @version $Revision: 1.102 $
*/
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -361,6 +361,8 @@ public:
FGAuxiliary* GetAuxiliary(void) {return (FGAuxiliary*)Models[eAuxiliary];}
/// Returns the FGInput pointer.
FGInput* GetInput(void) {return (FGInput*)Models[eInput];}
+ /// Returns the FGOutput pointer.
+ FGOutput* GetOutput(void) {return (FGOutput*)Models[eOutput];}
/** Get a pointer to the ground callback currently used. It is recommanded
to store the returned pointer in a 'smart pointer' FGGroundCallback_ptr.
@return A pointer to the current ground callback object.
@@ -432,8 +434,8 @@ public:
/** Forces the specified output object to print its items once */
void ForceOutput(int idx=0) { Output->ForceOutput(idx); }
- /** Sets the logging rate for all output objects (if any). */
- void SetLoggingRate(double rate) { Output->SetRate(rate); }
+ /** Sets the logging rate in Hz for all output objects (if any). */
+ void SetLoggingRate(double rate) { Output->SetRateHz(rate); }
/** Sets (or overrides) the output filename
@param n index of file
@@ -564,12 +566,17 @@ public:
is also incremented.
@return the new simulation time. */
double IncrTime(void) {
- if (!holding) sim_time += dT;
- GetGroundCallback()->SetTime(sim_time);
- Frame++;
+ if (!holding && !IntegrationSuspended()) {
+ sim_time += dT;
+ GetGroundCallback()->SetTime(sim_time);
+ Frame++;
+ }
return sim_time;
}
+ /** Retrieves the current frame count. */
+ unsigned int GetFrame(void) const {return Frame;}
+
/** Retrieves the current debug level setting. */
int GetDebugLevel(void) const {return debug_lvl;};
@@ -621,6 +628,7 @@ private:
bool trim_status;
int ta_mode;
unsigned int ResetMode;
+ int trim_completed;
FGScript* Script;
FGInitialCondition* IC;
diff --git a/src/FDM/JSBSim/FGJSBBase.cpp b/src/FDM/JSBSim/FGJSBBase.cpp
index 71ce71d6a..d978da9cd 100644
--- a/src/FDM/JSBSim/FGJSBBase.cpp
+++ b/src/FDM/JSBSim/FGJSBBase.cpp
@@ -42,9 +42,11 @@ INCLUDES
#include
#include
+using namespace std;
+
namespace JSBSim {
-IDENT(IdSrc,"$Id: FGJSBBase.cpp,v 1.39 2014/09/03 17:35:04 bcoconni Exp $");
+IDENT(IdSrc,"$Id: FGJSBBase.cpp,v 1.40 2015/07/12 19:34:08 bcoconni Exp $");
IDENT(IdHdr,ID_JSBBASE);
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -108,7 +110,7 @@ const double FGJSBBase::kgtoslug = 0.06852168;
const string FGJSBBase::needed_cfg_version = "2.0";
const string FGJSBBase::JSBSim_version = "1.0 " __DATE__ " " __TIME__ ;
-std::queue FGJSBBase::Messages;
+queue FGJSBBase::Messages;
FGJSBBase::Message FGJSBBase::localMsg;
unsigned int FGJSBBase::messageId = 0;
@@ -116,10 +118,6 @@ int FGJSBBase::gaussian_random_number_phase = 0;
short FGJSBBase::debug_lvl = 1;
-using std::cerr;
-using std::cout;
-using std::endl;
-
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void FGJSBBase::PutMessage(const Message& msg)
@@ -180,19 +178,12 @@ void FGJSBBase::PutMessage(const string& text, double dVal)
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-int FGJSBBase::SomeMessages(void)
-{
- return !Messages.empty();
-}
-
-//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
void FGJSBBase::ProcessMessage(void)
{
if (Messages.empty()) return;
localMsg = Messages.front();
- while (Messages.size() > 0) {
+ while (SomeMessages()) {
switch (localMsg.type) {
case JSBSim::FGJSBBase::Message::eText:
cout << localMsg.messageId << ": " << localMsg.text << endl;
@@ -211,7 +202,7 @@ void FGJSBBase::ProcessMessage(void)
break;
}
Messages.pop();
- if (Messages.size() > 0) localMsg = Messages.front();
+ if (SomeMessages()) localMsg = Messages.front();
else break;
}
@@ -249,7 +240,7 @@ void FGJSBBase::disableHighLighting(void)
string FGJSBBase::CreateIndexedPropertyName(const string& Property, int index)
{
- std::ostringstream buf;
+ ostringstream buf;
buf << Property << '[' << index << ']';
return buf.str();
}
diff --git a/src/FDM/JSBSim/FGJSBBase.h b/src/FDM/JSBSim/FGJSBBase.h
index c0200d484..b3a5cf21a 100644
--- a/src/FDM/JSBSim/FGJSBBase.h
+++ b/src/FDM/JSBSim/FGJSBBase.h
@@ -43,9 +43,6 @@ INCLUDES
#include
#include
-using std::min;
-using std::max;
-
#include "input_output/string_utilities.h"
#ifndef M_PI
@@ -57,7 +54,7 @@ using std::max;
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_JSBBASE "$Id: FGJSBBase.h,v 1.41 2014/09/03 17:35:04 bcoconni Exp $"
+#define ID_JSBBASE "$Id: FGJSBBase.h,v 1.44 2015/09/17 19:44:13 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
@@ -73,7 +70,7 @@ CLASS DOCUMENTATION
* This class provides universal constants, utility functions, messaging
* functions, and enumerated constants to JSBSim.
@author Jon S. Berndt
- @version $Id: FGJSBBase.h,v 1.41 2014/09/03 17:35:04 bcoconni Exp $
+ @version $Id: FGJSBBase.h,v 1.44 2015/09/17 19:44:13 bcoconni Exp $
*/
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -175,7 +172,7 @@ public:
void PutMessage(const std::string& text, double dVal);
/** Reads the message on the queue (but does not delete it).
@return 1 if some messages */
- int SomeMessages(void);
+ int SomeMessages(void) { return !Messages.empty(); }
/** Reads the message on the queue and removes it from the queue.
This function also prints out the message.*/
void ProcessMessage(void);
@@ -293,7 +290,7 @@ public:
@return if the two values can be considered equal up to roundoff */
static bool EqualToRoundoff(double a, double b) {
double eps = 2.0*DBL_EPSILON;
- return std::fabs(a - b) <= eps * max(std::fabs(a), std::fabs(b));
+ return std::fabs(a - b) <= eps * std::max(std::fabs(a), std::fabs(b));
}
/** Finite precision comparison.
@@ -302,7 +299,7 @@ public:
@return if the two values can be considered equal up to roundoff */
static bool EqualToRoundoff(float a, float b) {
float eps = 2.0*FLT_EPSILON;
- return std::fabs(a - b) <= eps * max(std::fabs(a), std::fabs(b));
+ return std::fabs(a - b) <= eps * std::max(std::fabs(a), std::fabs(b));
}
/** Finite precision comparison.
diff --git a/src/FDM/JSBSim/initialization/FGInitialCondition.cpp b/src/FDM/JSBSim/initialization/FGInitialCondition.cpp
index 4fbac6f99..a230d1d92 100644
--- a/src/FDM/JSBSim/initialization/FGInitialCondition.cpp
+++ b/src/FDM/JSBSim/initialization/FGInitialCondition.cpp
@@ -44,29 +44,20 @@ you have chosen your IC's wisely) even after setting it up with this class.
INCLUDES
*******************************************************************************/
-#include
-#include
#include
#include "FGInitialCondition.h"
#include "FGFDMExec.h"
-#include "math/FGQuaternion.h"
#include "models/FGInertial.h"
#include "models/FGAtmosphere.h"
-#include "models/FGPropagate.h"
-#include "models/FGPropulsion.h"
#include "models/FGAccelerations.h"
-#include "models/FGFCS.h"
-#include "input_output/FGPropertyManager.h"
-#include "input_output/string_utilities.h"
#include "input_output/FGXMLFileRead.h"
-#include "input_output/FGXMLElement.h"
using namespace std;
namespace JSBSim {
-IDENT(IdSrc,"$Id: FGInitialCondition.cpp,v 1.99 2015/02/19 05:18:45 dpculp Exp $");
+IDENT(IdSrc,"$Id: FGInitialCondition.cpp,v 1.101 2015/09/27 15:45:31 bcoconni Exp $");
IDENT(IdHdr,ID_INITIALCONDITION);
//******************************************************************************
@@ -919,9 +910,23 @@ bool FGInitialCondition::Load_v1(Element* document)
{
bool result = true;
- if (document->FindElement("latitude")) {
+ Element* latitude_el = document->FindElement("latitude");
+ if (latitude_el) {
double latitude = document->FindElementValueAsNumberConvertTo("latitude", "RAD");
- string lat_type = document->FindElement("latitude")->GetAttributeValue("type");
+ if (fabs(latitude) > 0.5*M_PI) {
+ string unit_type = latitude_el->GetAttributeValue("unit");
+ if (unit_type.empty()) unit_type="RAD";
+ cerr << latitude_el->ReadFrom() << "The latitude value "
+ << latitude_el->GetDataAsNumber() << " " << unit_type
+ << " is outside the range [";
+ if (unit_type == "DEG")
+ cerr << "-90 DEG ; +90 DEG]" << endl;
+ else
+ cerr << "-PI/2 RAD; +PI/2 RAD]" << endl;
+ result = false;
+ }
+
+ string lat_type = latitude_el->GetAttributeValue("type");
if (lat_type == "geod" || lat_type == "geodetic")
position.SetPositionGeodetic(0.0, latitude, 0.0); // Longitude and altitude will be set later on
else
diff --git a/src/FDM/JSBSim/initialization/FGTrim.cpp b/src/FDM/JSBSim/initialization/FGTrim.cpp
index ff1601c36..dc2e2f18f 100644
--- a/src/FDM/JSBSim/initialization/FGTrim.cpp
+++ b/src/FDM/JSBSim/initialization/FGTrim.cpp
@@ -57,7 +57,7 @@ using namespace std;
namespace JSBSim {
-IDENT(IdSrc,"$Id: FGTrim.cpp,v 1.24 2014/11/30 12:35:32 bcoconni Exp $");
+IDENT(IdSrc,"$Id: FGTrim.cpp,v 1.28 2015/09/28 20:50:41 bcoconni Exp $");
IDENT(IdHdr,ID_TRIM);
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -202,8 +202,6 @@ bool FGTrim::DoTrim(void) {
fdmex->GetGroundReactions()->GetGearUnit(i)->SetReport(false);
}
- fdmex->DisableOutput();
-
fdmex->SetTrimStatus(true);
fdmex->SuspendIntegration();
@@ -342,7 +340,6 @@ bool FGTrim::DoTrim(void) {
fdmex->ResumeIntegration();
fdmex->SetTrimStatus(false);
- fdmex->EnableOutput();
for(int i=0;i < fdmex->GetGroundReactions()->GetNumGearUnits();i++){
fdmex->GetGroundReactions()->GetGearUnit(i)->SetReport(true);
diff --git a/src/FDM/JSBSim/initialization/FGTrimAxis.cpp b/src/FDM/JSBSim/initialization/FGTrimAxis.cpp
index 4eb1d63d5..69a03ab4a 100644
--- a/src/FDM/JSBSim/initialization/FGTrimAxis.cpp
+++ b/src/FDM/JSBSim/initialization/FGTrimAxis.cpp
@@ -56,7 +56,7 @@ using namespace std;
namespace JSBSim {
-IDENT(IdSrc,"$Id: FGTrimAxis.cpp,v 1.17 2014/01/13 10:46:00 ehofman Exp $");
+IDENT(IdSrc,"$Id: FGTrimAxis.cpp,v 1.19 2015/09/28 20:50:41 bcoconni Exp $");
IDENT(IdHdr,ID_TRIMAXIS);
/*****************************************************************************/
diff --git a/src/FDM/JSBSim/initialization/FGTrimmer.cpp b/src/FDM/JSBSim/initialization/FGTrimmer.cpp
old mode 100644
new mode 100755
diff --git a/src/FDM/JSBSim/input_output/FGInputType.cpp b/src/FDM/JSBSim/input_output/FGInputType.cpp
index 51a31ba75..2a7cb7ed7 100644
--- a/src/FDM/JSBSim/input_output/FGInputType.cpp
+++ b/src/FDM/JSBSim/input_output/FGInputType.cpp
@@ -46,7 +46,7 @@ INCLUDES
namespace JSBSim {
-IDENT(IdSrc,"$Id: FGInputType.cpp,v 1.2 2015/03/28 14:49:01 bcoconni Exp $");
+IDENT(IdSrc,"$Id: FGInputType.cpp,v 1.4 2015/08/23 09:43:31 bcoconni Exp $");
IDENT(IdHdr,ID_INPUTTYPE);
using namespace std;
@@ -106,9 +106,8 @@ bool FGInputType::InitModel(void)
bool FGInputType::Run(bool Holding)
{
- if (!enabled) return true;
if (FGModel::Run(Holding)) return true;
- // if (Holding) return false;
+ if (!enabled) return true;
RunPreFunctions();
Read(Holding);
@@ -140,8 +139,6 @@ bool FGInputType::Run(bool Holding)
void FGInputType::Debug(int from)
{
- string scratch="";
-
if (debug_lvl <= 0) return;
if (debug_lvl & 1) { // Standard console startup message input
diff --git a/src/FDM/JSBSim/input_output/FGInputType.h b/src/FDM/JSBSim/input_output/FGInputType.h
index 40291f765..ab55987c7 100644
--- a/src/FDM/JSBSim/input_output/FGInputType.h
+++ b/src/FDM/JSBSim/input_output/FGInputType.h
@@ -44,7 +44,7 @@ INCLUDES
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_INPUTTYPE "$Id: FGInputType.h,v 1.2 2015/03/28 14:49:01 bcoconni Exp $"
+#define ID_INPUTTYPE "$Id: FGInputType.h,v 1.3 2015/08/23 09:37:16 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
@@ -87,8 +87,8 @@ public:
/// Destructor
virtual ~FGInputType();
- /** Set the idx for this output instance
- @param idx ID of the output instance that is constructed
+ /** Set the idx for this input instance
+ @param idx ID of the input instance that is constructed
*/
void SetIdx(unsigned int idx);
@@ -114,13 +114,13 @@ public:
*/
virtual void Read(bool Holding) = 0;
- /// Enables the output generation.
+ /// Enables the input generation.
void Enable(void) { enabled = true; }
- /// Disables the output generation.
+ /// Disables the input generation.
void Disable(void) { enabled = false; }
- /** Toggles the output generation.
- @result the output generation status i.e. true if the output has been
- enabled, false if the output has been disabled. */
+ /** Toggles the input generation.
+ @result the input generation status i.e. true if the input has been
+ enabled, false if the input has been disabled. */
bool Toggle(void) {enabled = !enabled; return enabled;}
/** Overwrites the name identifier under which the input will be read.
diff --git a/src/FDM/JSBSim/input_output/FGOutputType.cpp b/src/FDM/JSBSim/input_output/FGOutputType.cpp
index 67c48ac9b..25d2edd2d 100644
--- a/src/FDM/JSBSim/input_output/FGOutputType.cpp
+++ b/src/FDM/JSBSim/input_output/FGOutputType.cpp
@@ -46,7 +46,7 @@ INCLUDES
namespace JSBSim {
-IDENT(IdSrc,"$Id: FGOutputType.cpp,v 1.12 2015/03/28 14:49:01 bcoconni Exp $");
+IDENT(IdSrc,"$Id: FGOutputType.cpp,v 1.17 2015/08/23 09:43:31 bcoconni Exp $");
IDENT(IdHdr,ID_OUTPUTTYPE);
using namespace std;
@@ -89,10 +89,10 @@ FGOutputType::~FGOutputType()
void FGOutputType::SetIdx(unsigned int idx)
{
- typedef double (FGOutputType::*iOPMF)(void) const;
- string outputProp = CreateIndexedPropertyName("simulation/output", idx) + "/log_rate_hz";
+ string outputProp = CreateIndexedPropertyName("simulation/output", idx);
- PropertyManager->Tie(outputProp, this, (iOPMF)0, &FGOutputType::SetRate, false);
+ PropertyManager->Tie(outputProp + "/log_rate_hz", this, &FGOutputType::GetRateHz, &FGOutputType::SetRateHz, false);
+ PropertyManager->Tie(outputProp + "/enabled", &enabled);
OutputIdx = idx;
}
@@ -130,7 +130,6 @@ bool FGOutputType::Load(Element* element)
Element *property_element = element->FindElement("property");
while (property_element) {
- string caption="";
string property_str = property_element->GetDataLine();
FGPropertyNode* node = PropertyManager->GetNode(property_str);
if (!node) {
@@ -153,7 +152,7 @@ bool FGOutputType::Load(Element* element)
if (!element->GetAttributeValue("rate").empty()) {
outRate = element->GetAttributeValueAsNumber("rate");
}
- SetRate(outRate);
+ SetRateHz(outRate);
return true;
}
@@ -170,11 +169,10 @@ bool FGOutputType::InitModel(void)
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-bool FGOutputType::Run(bool Holding)
+bool FGOutputType::Run(void)
{
+ if (FGModel::Run(false)) return true;
if (!enabled) return true;
- if (FGModel::Run(Holding)) return true;
- if (Holding) return false;
RunPreFunctions();
Print();
@@ -187,18 +185,25 @@ bool FGOutputType::Run(bool Holding)
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-void FGOutputType::SetRate(double rtHz)
+void FGOutputType::SetRateHz(double rtHz)
{
rtHz = rtHz>1000?1000:(rtHz<0?0:rtHz);
if (rtHz > 0) {
- FGModel::SetRate(0.5 + 1.0/(FDMExec->GetDeltaT()*rtHz));
+ SetRate(0.5 + 1.0/(FDMExec->GetDeltaT()*rtHz));
Enable();
} else {
- FGModel::SetRate(1);
+ SetRate(1);
Disable();
}
}
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+double FGOutputType::GetRateHz(void) const
+{
+ return 1.0 / (rate * FDMExec->GetDeltaT());
+}
+
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// The bitmasked value choices are as follows:
// unset: In this case (the default) JSBSim would only print
@@ -220,8 +225,6 @@ void FGOutputType::SetRate(double rtHz)
void FGOutputType::Debug(int from)
{
- string scratch="";
-
if (debug_lvl <= 0) return;
if (debug_lvl & 1) { // Standard console startup message output
diff --git a/src/FDM/JSBSim/input_output/FGOutputType.h b/src/FDM/JSBSim/input_output/FGOutputType.h
index d9dd5590d..1f3ccceb1 100644
--- a/src/FDM/JSBSim/input_output/FGOutputType.h
+++ b/src/FDM/JSBSim/input_output/FGOutputType.h
@@ -44,7 +44,7 @@ INCLUDES
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_OUTPUTTYPE "$Id: FGOutputType.h,v 1.6 2015/03/28 14:49:01 bcoconni Exp $"
+#define ID_OUTPUTTYPE "$Id: FGOutputType.h,v 1.11 2015/08/23 09:43:31 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
@@ -110,7 +110,10 @@ public:
/** Set the output rate for this output instances.
@param rtHz new output rate in Hz */
- void SetRate(double rtHz);
+ void SetRateHz(double rtHz);
+
+ /// Get the output rate in Hz for this output.
+ double GetRateHz(void) const;
/** Set the activated subsystems for this output instance.
@param subSystems bitfield that describes the activated subsystems
@@ -151,7 +154,7 @@ public:
generation and finally the "post" functions.
@result false if no error.
*/
- bool Run(bool Holding);
+ bool Run(void);
/** Generate the output. This is a pure method so it must be implemented by
the classes that inherits from FGOutputType. The Print name may not be
diff --git a/src/FDM/JSBSim/input_output/FGScript.cpp b/src/FDM/JSBSim/input_output/FGScript.cpp
old mode 100644
new mode 100755
index 12185869c..61b5acdf7
--- a/src/FDM/JSBSim/input_output/FGScript.cpp
+++ b/src/FDM/JSBSim/input_output/FGScript.cpp
@@ -58,7 +58,7 @@ using namespace std;
namespace JSBSim {
-IDENT(IdSrc,"$Id: FGScript.cpp,v 1.60 2014/06/08 12:50:05 bcoconni Exp $");
+IDENT(IdSrc,"$Id: FGScript.cpp,v 1.63 2015/09/28 21:14:15 bcoconni Exp $");
IDENT(IdHdr,ID_FGSCRIPT);
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -96,18 +96,15 @@ FGScript::~FGScript()
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-bool FGScript::LoadScript(string script, double deltaT, const string initfile)
+bool FGScript::LoadScript(const string& script, double default_dT,
+ const string& initfile)
{
- string aircraft="", initialize="", comparison = "", prop_name="";
+ string aircraft="", initialize="", prop_name="";
string notifyPropertyName="";
Element *element=0, *run_element=0, *event_element=0;
- Element *condition_element=0, *set_element=0, *delay_element=0;
+ Element *set_element=0;
Element *notify_element = 0L, *notify_property_element = 0L;
- Element *output_element = 0L;
- Element *input_element = 0L;
- bool result = false;
double dt = 0.0, value = 0.0;
- struct event *newEvent;
FGCondition *newCondition;
FGXMLFileRead XMLFileRead;
@@ -118,11 +115,6 @@ bool FGScript::LoadScript(string script, double deltaT, const string initfile)
return false;
}
- // Set up input and output files if specified
-
- output_element = document->FindElement("output");
- input_element = document->FindElement("input");
-
if (document->GetName() != string("runscript")) {
cerr << "File: " << script << " is not a script file" << endl;
return false;
@@ -141,7 +133,10 @@ bool FGScript::LoadScript(string script, double deltaT, const string initfile)
// Set sim timing
- if (run_element->HasAttribute("start")) StartTime = run_element->GetAttributeValueAsNumber("start");
+ if (run_element->HasAttribute("start"))
+ StartTime = run_element->GetAttributeValueAsNumber("start");
+ else
+ StartTime = 0.0;
FDMExec->Setsim_time(StartTime);
if (run_element->HasAttribute("end")) {
EndTime = run_element->GetAttributeValueAsNumber("end");
@@ -153,12 +148,12 @@ bool FGScript::LoadScript(string script, double deltaT, const string initfile)
// Make sure that the desired time is reached and executed.
EndTime += 0.99*FDMExec->GetDeltaT();
- if (deltaT == 0.0)
+ if (default_dT == 0.0)
dt = run_element->GetAttributeValueAsNumber("dt");
else {
- dt = deltaT;
+ dt = default_dT;
cout << endl << "Overriding simulation step size from the command line. New step size is: "
- << deltaT << " seconds (" << 1/deltaT << " Hz)" << endl << endl;
+ << default_dT << " seconds (" << 1/default_dT << " Hz)" << endl << endl;
}
FDMExec->Setdt(dt);
@@ -169,8 +164,8 @@ bool FGScript::LoadScript(string script, double deltaT, const string initfile)
if (element) {
aircraft = element->GetAttributeValue("aircraft");
if (!aircraft.empty()) {
- result = FDMExec->LoadModel(aircraft);
- if (!result) return false;
+ if (!FDMExec->LoadModel(aircraft))
+ return false;
} else {
cerr << "Aircraft must be specified in use element." << endl;
return false;
@@ -196,22 +191,25 @@ bool FGScript::LoadScript(string script, double deltaT, const string initfile)
FGInitialCondition *IC=FDMExec->GetIC();
if ( ! IC->Load( initialize )) {
cerr << "Initialization unsuccessful" << endl;
- exit(-1);
+ return false;
}
// Now, read input spec if given.
- if (input_element > 0) {
- FDMExec->GetInput()->Load(input_element);
+ element = document->FindElement("input");
+ while (element) {
+ if (!FDMExec->GetInput()->Load(element))
+ return false;
+
+ element = document->FindNextElement("input");
}
// Now, read output spec if given.
- if (output_element > 0) {
- string output_file = output_element->GetAttributeValue("file");
- if (output_file.empty()) {
- cerr << "No logging directives file was specified." << endl;
- } else {
- if (!FDMExec->SetOutputDirectives(output_file)) return false;
- }
+ element = document->FindElement("output");
+ while (element) {
+ if (!FDMExec->GetOutput()->Load(element))
+ return false;
+
+ element = document->FindNextElement("output");
}
// Read local property/value declarations
@@ -226,7 +224,7 @@ bool FGScript::LoadScript(string script, double deltaT, const string initfile)
while (event_element) { // event processing
// Create the event structure
- newEvent = new struct event();
+ struct event *newEvent = new struct event();
// Retrieve the event name if given
newEvent->Name = event_element->GetAttributeValue("name");
@@ -243,11 +241,11 @@ bool FGScript::LoadScript(string script, double deltaT, const string initfile)
}
// Process the conditions
- condition_element = event_element->FindElement("condition");
+ Element* condition_element = event_element->FindElement("condition");
if (condition_element != 0) {
try {
newCondition = new FGCondition(condition_element, PropertyManager);
- } catch(string str) {
+ } catch(string& str) {
cout << endl << fgred << str << reset << endl << endl;
delete newEvent;
return false;
@@ -262,9 +260,11 @@ bool FGScript::LoadScript(string script, double deltaT, const string initfile)
// Is there a delay between the time this event is triggered, and when the event
// actions are executed?
- delay_element = event_element->FindElement("delay");
- if (delay_element) newEvent->Delay = event_element->FindElementValueAsNumber("delay");
- else newEvent->Delay = 0.0;
+ Element* delay_element = event_element->FindElement("delay");
+ if (delay_element)
+ newEvent->Delay = event_element->FindElementValueAsNumber("delay");
+ else
+ newEvent->Delay = 0.0;
// Notify about when this event is triggered?
if ((notify_element = event_element->FindElement("notify")) != 0) {
@@ -299,7 +299,7 @@ bool FGScript::LoadScript(string script, double deltaT, const string initfile)
while (set_element) {
prop_name = set_element->GetAttributeValue("name");
if (PropertyManager->HasNode(prop_name)) {
- newEvent->SetParam.push_back( PropertyManager->GetNode(prop_name) );
+ newEvent->SetParam.push_back( PropertyManager->GetNode(prop_name) );
} else {
newEvent->SetParam.push_back( 0L );
}
@@ -354,6 +354,7 @@ bool FGScript::LoadScript(string script, double deltaT, const string initfile)
void FGScript::ResetEvents(void)
{
//LocalProperties.ResetToIC();
+ FDMExec->Setsim_time(StartTime);
for (unsigned int i=0; iGetValue();
- } catch (string msg) {
+ } catch (string& msg) {
std::cerr << std::endl << "A problem occurred in the execution of the script. " << msg << endl;
throw;
}
diff --git a/src/FDM/JSBSim/input_output/FGScript.h b/src/FDM/JSBSim/input_output/FGScript.h
index e04ef368e..c49200629 100644
--- a/src/FDM/JSBSim/input_output/FGScript.h
+++ b/src/FDM/JSBSim/input_output/FGScript.h
@@ -48,7 +48,7 @@ INCLUDES
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_FGSCRIPT "$Id: FGScript.h,v 1.29 2014/05/29 18:46:44 bcoconni Exp $"
+#define ID_FGSCRIPT "$Id: FGScript.h,v 1.30 2015/09/20 16:32:11 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
@@ -161,7 +161,7 @@ CLASS DOCUMENTATION
comes the "run" section, where the conditions are
described in "event" clauses.
@author Jon S. Berndt
- @version "$Id: FGScript.h,v 1.29 2014/05/29 18:46:44 bcoconni Exp $"
+ @version "$Id: FGScript.h,v 1.30 2015/09/20 16:32:11 bcoconni Exp $"
*/
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -178,16 +178,18 @@ public:
~FGScript();
/** Loads a script to drive JSBSim (usually in standalone mode).
- The language is the Script Directives for JSBSim. If a simulation step size
- has been supplied on the command line, it will be override the script-
+ The language is the Script Directives for JSBSim. If a simulation step
+ size has been supplied on the command line, it will override the script
specified simulation step size.
@param script the filename (including path name, if any) for the script.
- @param deltaT a simulation step size.
+ @param default_dT the default simulation step size if no value is specified
+ in the script
@param initfile An optional initialization file name passed in, empty by
default. If a file name is passed in, it will override the
one present in the script.
@return true if successful */
- bool LoadScript(std::string script, double deltaT, const std::string initfile);
+ bool LoadScript(const std::string& script, double default_dT,
+ const std::string& initfile);
/** This function is called each pass through the executive Run() method IF
scripting is enabled.
diff --git a/src/FDM/JSBSim/input_output/FGUDPInputSocket.cpp b/src/FDM/JSBSim/input_output/FGUDPInputSocket.cpp
index 3b7c8a485..679083477 100644
--- a/src/FDM/JSBSim/input_output/FGUDPInputSocket.cpp
+++ b/src/FDM/JSBSim/input_output/FGUDPInputSocket.cpp
@@ -80,7 +80,7 @@ bool FGUDPInputSocket::Load(Element* el)
return false;
rate = atoi(el->GetAttributeValue("rate").c_str());
- FGModel::SetRate(0.5 + 1.0/(FDMExec->GetDeltaT()*rate));
+ SetRate(0.5 + 1.0/(FDMExec->GetDeltaT()*rate));
SockPort = atoi(el->GetAttributeValue("port").c_str());
if (SockPort == 0) {
diff --git a/src/FDM/JSBSim/input_output/FGUDPOutputSocket.cpp b/src/FDM/JSBSim/input_output/FGUDPOutputSocket.cpp
index 056ea0c71..8ec0232af 100644
--- a/src/FDM/JSBSim/input_output/FGUDPOutputSocket.cpp
+++ b/src/FDM/JSBSim/input_output/FGUDPOutputSocket.cpp
@@ -50,7 +50,7 @@ using namespace std;
namespace JSBSim {
-IDENT(IdSrc,"$Id: FGUDPOutputSocket.cpp,v 1.1 2015/04/02 02:23:33 dpculp Exp $");
+IDENT(IdSrc,"$Id: FGUDPOutputSocket.cpp,v 1.2 2015/08/16 13:19:52 bcoconni Exp $");
IDENT(IdHdr,ID_UDPOUTPUTSOCKET);
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -84,7 +84,6 @@ bool FGUDPOutputSocket::Load(Element* el)
Element *property_element = el->FindElement("property");
while (property_element) {
- string caption="";
string property_str = property_element->GetDataLine();
FGPropertyNode* node = PropertyManager->GetNode(property_str);
if (!node) {
@@ -98,7 +97,7 @@ bool FGUDPOutputSocket::Load(Element* el)
if (!el->GetAttributeValue("rate").empty()) {
outRate = el->GetAttributeValueAsNumber("rate");
}
- SetRate(outRate);
+ SetRateHz(outRate);
SockPort = atoi(el->GetAttributeValue("port").c_str());
if (SockPort == 0) {
diff --git a/src/FDM/JSBSim/input_output/FGXMLElement.cpp b/src/FDM/JSBSim/input_output/FGXMLElement.cpp
old mode 100644
new mode 100755
index dd9bce1cc..1aebb93e4
--- a/src/FDM/JSBSim/input_output/FGXMLElement.cpp
+++ b/src/FDM/JSBSim/input_output/FGXMLElement.cpp
@@ -45,7 +45,7 @@ FORWARD DECLARATIONS
namespace JSBSim {
-IDENT(IdSrc,"$Id: FGXMLElement.cpp,v 1.52 2014/06/29 10:13:18 bcoconni Exp $");
+IDENT(IdSrc,"$Id: FGXMLElement.cpp,v 1.54 2015/09/27 15:39:45 bcoconni Exp $");
IDENT(IdHdr,ID_XMLELEMENT);
bool Element::converterIsInitialized = false;
@@ -464,10 +464,31 @@ double Element::FindElementValueAsNumberConvertTo(const string& el, const string
}
double value = element->GetDataAsNumber();
+
+ // Sanity check for angular values
+ if ((supplied_units == "RAD") && (fabs(value) > 2 * M_PI)) {
+ cerr << element->ReadFrom() << "The value " << value
+ << " RAD is outside the range [ -2*M_PI RAD ; +2*M_PI RAD ]" << endl;
+ }
+ if ((supplied_units == "DEG") && (fabs(value) > 360.0)) {
+ cerr << element->ReadFrom() << "The value " << value
+ << " DEG is outside the range [ -360 DEG ; +360 DEG ]" << endl;
+ }
+
+
if (!supplied_units.empty()) {
value *= convert[supplied_units][target_units];
}
+ if ((target_units == "RAD") && (fabs(value) > 2 * M_PI)) {
+ cerr << element->ReadFrom() << "The value " << value
+ << " RAD is outside the range [ -2*M_PI RAD ; +2*M_PI RAD ]" << endl;
+ }
+ if ((target_units == "DEG") && (fabs(value) > 360.0)) {
+ cerr << element->ReadFrom() << "The value " << value
+ << " DEG is outside the range [ -360 DEG ; +360 DEG ]" << endl;
+ }
+
value = DisperseValue(element, value, supplied_units, target_units);
return value;
@@ -569,10 +590,10 @@ FGColumnVector3 Element::FindElementTripletConvertTo( const string& target_units
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-double Element::DisperseValue(Element *e, double val, const std::string supplied_units, const std::string target_units)
+double Element::DisperseValue(Element *e, double val, const std::string& supplied_units,
+ const std::string& target_units)
{
double value=val;
- double disp=0.0;
bool disperse = false;
try {
@@ -586,7 +607,7 @@ double Element::DisperseValue(Element *e, double val, const std::string supplied
}
if (e->HasAttribute("dispersion") && disperse) {
- disp = e->GetAttributeValueAsNumber("dispersion");
+ double disp = e->GetAttributeValueAsNumber("dispersion");
if (!supplied_units.empty()) disp *= convert[supplied_units][target_units];
string attType = e->GetAttributeValue("type");
if (attType == "gaussian" || attType == "gaussiansigned") {
diff --git a/src/FDM/JSBSim/input_output/FGXMLElement.h b/src/FDM/JSBSim/input_output/FGXMLElement.h
old mode 100644
new mode 100755
index 22c1f39a8..ff9f62a34
--- a/src/FDM/JSBSim/input_output/FGXMLElement.h
+++ b/src/FDM/JSBSim/input_output/FGXMLElement.h
@@ -45,7 +45,7 @@ INCLUDES
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_XMLELEMENT "$Id: FGXMLElement.h,v 1.24 2014/06/29 10:13:18 bcoconni Exp $"
+#define ID_XMLELEMENT "$Id: FGXMLElement.h,v 1.25 2015/07/12 19:34:08 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
@@ -137,7 +137,7 @@ CLASS DOCUMENTATION
- GAL = gallon (U.S. liquid)
@author Jon S. Berndt
- @version $Id: FGXMLElement.h,v 1.24 2014/06/29 10:13:18 bcoconni Exp $
+ @version $Id: FGXMLElement.h,v 1.25 2015/07/12 19:34:08 bcoconni Exp $
*/
class Element;
@@ -328,7 +328,8 @@ public:
@return a column vector object built from the LOCATION or ORIENT components. */
FGColumnVector3 FindElementTripletConvertTo( const std::string& target_units);
- double DisperseValue(Element *e, double val, const std::string supplied_units="", const std::string target_units="");
+ double DisperseValue(Element *e, double val, const std::string& supplied_units="",
+ const std::string& target_units="");
/** This function sets the value of the parent class attribute to the supplied
Element pointer.
diff --git a/src/FDM/JSBSim/input_output/string_utilities.h b/src/FDM/JSBSim/input_output/string_utilities.h
index 3b263b4c8..f21b14db0 100644
--- a/src/FDM/JSBSim/input_output/string_utilities.h
+++ b/src/FDM/JSBSim/input_output/string_utilities.h
@@ -49,7 +49,7 @@ INCLUDES
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_STRINGUTILS "$Id: string_utilities.h,v 1.22 2015/03/28 14:49:01 bcoconni Exp $"
+#define ID_STRINGUTILS "$Id: string_utilities.h,v 1.24 2015/08/16 16:06:28 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
@@ -88,32 +88,30 @@ CLASS DECLARATION
#else
#include
- using namespace std;
-
- string& trim_left(string& str)
+ std::string& trim_left(std::string& str)
{
- while (str.size() && isspace((unsigned char)str[0])) {
+ while (!str.empty() && isspace((unsigned char)str[0])) {
str = str.erase(0,1);
}
return str;
}
- string& trim_right(string& str)
+ std::string& trim_right(std::string& str)
{
- while (str.size() && isspace((unsigned char)str[str.size()-1])) {
+ while (!str.empty() && isspace((unsigned char)str[str.size()-1])) {
str = str.erase(str.size()-1,1);
}
return str;
}
- string& trim(string& str)
+ std::string& trim(std::string& str)
{
- if (str.size() == 0) return str;
- string temp_str = trim_right(str);
+ if (str.empty()) return str;
+ std::string temp_str = trim_right(str);
return str = trim_left(temp_str);
}
- string& trim_all_space(string& str)
+ std::string& trim_all_space(std::string& str)
{
for (size_t i=0; i split(string str, char d)
+ std::vector split(std::string str, char d)
{
- vector str_array;
+ std::vector str_array;
size_t index=0;
- string temp = "";
+ std::string temp = "";
trim(str);
index = str.find(d);
- while (index != string::npos) {
+ while (index != std::string::npos) {
temp = str.substr(0,index);
trim(temp);
- if (temp.size() > 0) str_array.push_back(temp);
+ if (!temp.empty()) str_array.push_back(temp);
str = str.erase(0,index+1);
index = str.find(d);
}
- if (str.size() > 0) {
+ if (!str.empty()) {
temp = trim(str);
- if (temp.size() > 0) str_array.push_back(temp);
+ if (!temp.empty()) str_array.push_back(temp);
}
return str_array;
@@ -172,33 +170,33 @@ CLASS DECLARATION
// * libc++ for all C++ language versions
// * Visual Studio for versions greater than 2010 (1700 -> MSVC++ 11.0 and VS 2012)
#if !defined(_LIBCPP_VERSION) && _MSC_VER < 1700 && __cplusplus < 201103L
- string to_string(int i)
+ std::string to_string(int i)
{
char buffer[32];
sprintf(buffer, "%d", i);
- return string(buffer);
+ return std::string(buffer);
}
- string to_string(float x)
+ std::string to_string(float x)
{
std::ostringstream o;
- if (!(o << x)) cerr << "Bad float to string conversion" << endl;
+ if (!(o << x)) std::cerr << "Bad float to string conversion" << std::endl;
return o.str();
}
- string to_string(double x)
+ std::string to_string(double x)
{
std::ostringstream o;
- if (!(o << x)) cerr << "Bad double to string conversion" << endl;
+ if (!(o << x)) std::cerr << "Bad double to string conversion" << std::endl;
return o.str();
}
#endif
- string replace(string str, const string& oldstr, const string& newstr)
+ std::string replace(std::string str, const std::string& oldstr, const std::string& newstr)
{
- string temp;
+ std::string temp = str;
size_t old_idx = str.find(oldstr);
- if (old_idx != string::npos) {
+ if (old_idx != std::string::npos) {
temp = str.replace(old_idx, 1, newstr);
}
return temp;
diff --git a/src/FDM/JSBSim/math/FGFunction.cpp b/src/FDM/JSBSim/math/FGFunction.cpp
old mode 100644
new mode 100755
index 0b09b31f1..853b81425
--- a/src/FDM/JSBSim/math/FGFunction.cpp
+++ b/src/FDM/JSBSim/math/FGFunction.cpp
@@ -32,18 +32,18 @@ INCLUDES
#include
#include
#include
+
#include "FGFunction.h"
#include "FGTable.h"
#include "FGPropertyValue.h"
#include "FGRealValue.h"
#include "input_output/FGXMLElement.h"
-#include "input_output/FGPropertyManager.h"
using namespace std;
namespace JSBSim {
-IDENT(IdSrc,"$Id: FGFunction.cpp,v 1.57 2015/03/28 14:49:01 bcoconni Exp $");
+IDENT(IdSrc,"$Id: FGFunction.cpp,v 1.58 2015/07/12 19:34:08 bcoconni Exp $");
IDENT(IdHdr,ID_FUNCTION);
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -254,9 +254,8 @@ FGFunction::FGFunction(FGPropertyManager* propMan, Element* el, const string& pr
property_name = replace(property_name,"#",Prefix);
}
}
- FGPropertyNode* newNode = 0L;
if (PropertyManager->HasNode(property_name)) {
- newNode = PropertyManager->GetNode(property_name);
+ FGPropertyNode* newNode = PropertyManager->GetNode(property_name);
Parameters.push_back(new FGPropertyValue( newNode ));
} else {
// cerr << fgcyan << "Warning: The property " + property_name + " is initially undefined."
diff --git a/src/FDM/JSBSim/math/FGFunction.h b/src/FDM/JSBSim/math/FGFunction.h
old mode 100644
new mode 100755
index 49d3e1516..25fa9b4c9
--- a/src/FDM/JSBSim/math/FGFunction.h
+++ b/src/FDM/JSBSim/math/FGFunction.h
@@ -43,7 +43,7 @@ INCLUDES
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_FUNCTION "$Id: FGFunction.h,v 1.31 2013/06/20 04:37:27 jberndt Exp $"
+#define ID_FUNCTION "$Id: FGFunction.h,v 1.32 2015/07/12 13:03:23 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
@@ -76,7 +76,7 @@ A function definition consists of an operation, a value, a table, or a property
- log2 (takes 1 arg)
- ln (takes 1 arg)
- log10 (takes 1 arg)
-- abs (takes n args)
+- abs (takes 1 arg)
- sin (takes 1 arg)
- cos (takes 1 arg)
- tan (takes 1 arg)
diff --git a/src/FDM/JSBSim/math/FGLocation.cpp b/src/FDM/JSBSim/math/FGLocation.cpp
index 2094ecd60..49903ac0e 100644
--- a/src/FDM/JSBSim/math/FGLocation.cpp
+++ b/src/FDM/JSBSim/math/FGLocation.cpp
@@ -47,7 +47,7 @@ INCLUDES
namespace JSBSim {
-IDENT(IdSrc,"$Id: FGLocation.cpp,v 1.33 2014/08/28 11:46:11 bcoconni Exp $");
+IDENT(IdSrc,"$Id: FGLocation.cpp,v 1.34 2015/09/20 20:53:13 bcoconni Exp $");
IDENT(IdHdr,ID_LOCATION);
// Set up the default ground callback object.
@@ -397,6 +397,68 @@ void FGLocation::ComputeDerivedUnconditional(void) const
mCacheValid = true;
}
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+// The calculations, below, implement the Haversine formulas to calculate
+// heading and distance to a set of lat/long coordinates from the current
+// position.
+//
+// The basic equations are (lat1, long1 are source positions; lat2
+// long2 are target positions):
+//
+// R = earthâs radius
+// Îlat = lat2 â lat1
+// Îlong = long2 â long1
+//
+// For the waypoint distance calculation:
+//
+// a = sin²(Îlat/2) + cos(lat1)âcos(lat2)âsin²(Îlong/2)
+// c = 2âatan2(âa, â(1âa))
+// d = Râc
+
+double FGLocation::GetDistanceTo(double target_longitude,
+ double target_latitude) const
+{
+ double delta_lat_rad = target_latitude - GetLatitude();
+ double delta_lon_rad = target_longitude - GetLongitude();
+
+ double distance_a = pow(sin(0.5*delta_lat_rad), 2.0)
+ + (GetCosLatitude() * cos(target_latitude)
+ * (pow(sin(0.5*delta_lon_rad), 2.0)));
+
+ return 2.0 * GetRadius() * atan2(sqrt(distance_a), sqrt(1.0 - distance_a));
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+// The calculations, below, implement the Haversine formulas to calculate
+// heading and distance to a set of lat/long coordinates from the current
+// position.
+//
+// The basic equations are (lat1, long1 are source positions; lat2
+// long2 are target positions):
+//
+// R = earthâs radius
+// Îlat = lat2 â lat1
+// Îlong = long2 â long1
+//
+// For the heading angle calculation:
+//
+// θ = atan2(sin(Îlong)âcos(lat2), cos(lat1)âsin(lat2) â sin(lat1)âcos(lat2)âcos(Îlong))
+
+double FGLocation::GetHeadingTo(double target_longitude,
+ double target_latitude) const
+{
+ double delta_lon_rad = target_longitude - GetLongitude();
+
+ double Y = sin(delta_lon_rad) * cos(target_latitude);
+ double X = GetCosLatitude() * sin(target_latitude)
+ - GetSinLatitude() * cos(target_latitude) * cos(delta_lon_rad);
+
+ double heading_to_waypoint_rad = atan2(Y, X);
+ if (heading_to_waypoint_rad < 0) heading_to_waypoint_rad += 2.0*M_PI;
+
+ return heading_to_waypoint_rad;
+}
+
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
} // namespace JSBSim
diff --git a/src/FDM/JSBSim/math/FGLocation.h b/src/FDM/JSBSim/math/FGLocation.h
index 9f086f6b8..0ce83f453 100644
--- a/src/FDM/JSBSim/math/FGLocation.h
+++ b/src/FDM/JSBSim/math/FGLocation.h
@@ -51,7 +51,7 @@ INCLUDES
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_LOCATION "$Id: FGLocation.h,v 1.34 2014/11/30 12:35:32 bcoconni Exp $"
+#define ID_LOCATION "$Id: FGLocation.h,v 1.35 2015/09/20 20:53:13 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
@@ -150,7 +150,7 @@ CLASS DOCUMENTATION
@see W. C. Durham "Aircraft Dynamics & Control", section 2.2
@author Mathias Froehlich
- @version $Id: FGLocation.h,v 1.34 2014/11/30 12:35:32 bcoconni Exp $
+ @version $Id: FGLocation.h,v 1.35 2015/09/20 20:53:13 bcoconni Exp $
*/
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -441,6 +441,23 @@ public:
@see IncrementEarthPositionAngle */
const FGMatrix33& GetTl2i(void) const {ComputeDerived(); return mTl2i;}
+ /** Get the geodetic distance between the current location and a given
+ location. This corresponds to the shortest distance between the two
+ locations. Earth curvature is taken into account.
+ @param target_longitude the target longitude
+ @param target_latitude the target latitude
+ @return The geodetic distance between the two locations */
+ double GetDistanceTo(double target_longitude, double target_latitude) const;
+
+ /** Get the heading that should be followed from the current location to
+ a given location along the shortest path. Earth curvature is
+ taken into account.
+ @param target_longitude the target longitude
+ @param target_latitude the target latitude
+ @return The heading that should be followed to reach the targeted
+ location along the shortest path */
+ double GetHeadingTo(double target_longitude, double target_latitude) const;
+
/** Conversion from Local frame coordinates to a location in the
earth centered and fixed frame.
This function calculates the FGLocation of an object which position
diff --git a/src/FDM/JSBSim/math/FGStateSpace.h b/src/FDM/JSBSim/math/FGStateSpace.h
old mode 100644
new mode 100755
index 58dfd0328..5434e1b64
--- a/src/FDM/JSBSim/math/FGStateSpace.h
+++ b/src/FDM/JSBSim/math/FGStateSpace.h
@@ -221,7 +221,7 @@ public:
void run() {
// initialize
- m_fdm->Initialize(m_fdm->GetIC());
+ m_fdm->Initialize(m_fdm->GetIC());
for (unsigned int i=0; iGetPropulsion()->GetNumEngines(); i++) {
m_fdm->GetPropulsion()->GetEngine(i)->InitRunning();
}
diff --git a/src/FDM/JSBSim/models/FGAircraft.h b/src/FDM/JSBSim/models/FGAircraft.h
index 3d77b0454..0726166ec 100644
--- a/src/FDM/JSBSim/models/FGAircraft.h
+++ b/src/FDM/JSBSim/models/FGAircraft.h
@@ -39,17 +39,15 @@ INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#include
-#include
#include "FGModel.h"
-#include "math/FGColumnVector3.h"
#include "math/FGMatrix33.h"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_AIRCRAFT "$Id: FGAircraft.h,v 1.24 2015/01/31 14:56:21 bcoconni Exp $"
+#define ID_AIRCRAFT "$Id: FGAircraft.h,v 1.25 2015/07/12 19:34:08 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
@@ -91,7 +89,7 @@ CLASS DOCUMENTATION
@endcode
@author Jon S. Berndt
- @version $Id: FGAircraft.h,v 1.24 2015/01/31 14:56:21 bcoconni Exp $
+ @version $Id: FGAircraft.h,v 1.25 2015/07/12 19:34:08 bcoconni Exp $
@see Cooke, Zyda, Pratt, and McGhee, "NPSNET: Flight Simulation Dynamic Modeling
Using Quaternions", Presence, Vol. 1, No. 4, pp. 404-420 Naval Postgraduate
School, January 1994
diff --git a/src/FDM/JSBSim/models/FGAuxiliary.cpp b/src/FDM/JSBSim/models/FGAuxiliary.cpp
old mode 100644
new mode 100755
index d710d8fcb..3492deac4
--- a/src/FDM/JSBSim/models/FGAuxiliary.cpp
+++ b/src/FDM/JSBSim/models/FGAuxiliary.cpp
@@ -51,7 +51,7 @@ using namespace std;
namespace JSBSim {
-IDENT(IdSrc,"$Id: FGAuxiliary.cpp,v 1.68 2014/12/27 05:41:11 dpculp Exp $");
+IDENT(IdSrc,"$Id: FGAuxiliary.cpp,v 1.70 2015/09/20 20:53:13 bcoconni Exp $");
IDENT(IdHdr,ID_AUXILIARY);
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -78,7 +78,6 @@ FGAuxiliary::FGAuxiliary(FGFDMExec* fdmex) : FGModel(fdmex)
hoverbmac = hoverbcg = 0.0;
Re = 0.0;
Nz = Ny = 0.0;
- lon_relative_position = lat_relative_position = relative_position = 0.0;
vPilotAccel.InitMatrix();
vPilotAccelN.InitMatrix();
@@ -117,7 +116,6 @@ bool FGAuxiliary::InitModel(void)
hoverbmac = hoverbcg = 0.0;
Re = 0.0;
Nz = Ny = 0.0;
- lon_relative_position = lat_relative_position = relative_position = 0.0;
vPilotAccel.InitMatrix();
vPilotAccelN.InitMatrix();
@@ -259,9 +257,6 @@ bool FGAuxiliary::Run(bool Holding)
FGColumnVector3 vMac = in.Tb2l * in.RPBody;
hoverbmac = (in.DistanceAGL + vMac(3)) / in.Wingspan;
- // When all models are executed calculate the distance from the initial point.
- CalculateRelativePosition();
-
return false;
}
@@ -344,13 +339,6 @@ double FGAuxiliary::GetCrossWind(void) const
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-double FGAuxiliary::GethVRP(void) const
-{
- return vLocationVRP.GetRadius() - in.ReferenceRadius;
-}
-
-//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
double FGAuxiliary::GetNlf(void) const
{
if (in.Mass != 0)
@@ -361,13 +349,36 @@ double FGAuxiliary::GetNlf(void) const
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-void FGAuxiliary::CalculateRelativePosition(void) //ToDo: This belongs elsewhere - perhaps in FGPropagate or Exec
+double FGAuxiliary::GetLongitudeRelativePosition(void) const
{
- const double earth_radius_mt = in.ReferenceRadius*fttom;
- lat_relative_position=(in.vLocation.GetLatitude() - FDMExec->GetIC()->GetLatitudeDegIC() *degtorad)*earth_radius_mt;
- lon_relative_position=(in.vLocation.GetLongitude() - FDMExec->GetIC()->GetLongitudeDegIC()*degtorad)*earth_radius_mt;
- relative_position = sqrt(lat_relative_position*lat_relative_position + lon_relative_position*lon_relative_position);
-};
+ FGLocation source(FDMExec->GetIC()->GetLongitudeRadIC(),
+ FDMExec->GetIC()->GetLatitudeRadIC(),
+ in.vLocation.GetSeaLevelRadius());
+ return source.GetDistanceTo(in.vLocation.GetLongitude(),
+ FDMExec->GetIC()->GetLatitudeRadIC()) * fttom;
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+double FGAuxiliary::GetLatitudeRelativePosition(void) const
+{
+ FGLocation source(FDMExec->GetIC()->GetLongitudeRadIC(),
+ FDMExec->GetIC()->GetLatitudeRadIC(),
+ in.vLocation.GetSeaLevelRadius());
+ return source.GetDistanceTo(FDMExec->GetIC()->GetLongitudeRadIC(),
+ in.vLocation.GetLatitude()) * fttom;
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+double FGAuxiliary::GetDistanceRelativePosition(void) const
+{
+ FGLocation source(FDMExec->GetIC()->GetLongitudeRadIC(),
+ FDMExec->GetIC()->GetLatitudeRadIC(),
+ in.vLocation.GetSeaLevelRadius());
+ return source.GetDistanceTo(in.vLocation.GetLongitude(),
+ in.vLocation.GetLatitude()) * fttom;
+}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
diff --git a/src/FDM/JSBSim/models/FGAuxiliary.h b/src/FDM/JSBSim/models/FGAuxiliary.h
index 462dbf676..bb8c9f23f 100644
--- a/src/FDM/JSBSim/models/FGAuxiliary.h
+++ b/src/FDM/JSBSim/models/FGAuxiliary.h
@@ -48,7 +48,7 @@ INCLUDES
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_AUXILIARY "$Id: FGAuxiliary.h,v 1.29 2014/12/27 05:41:11 dpculp Exp $"
+#define ID_AUXILIARY "$Id: FGAuxiliary.h,v 1.31 2015/09/20 20:53:13 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
@@ -99,7 +99,7 @@ CLASS DOCUMENTATION
to the JSBSim vPQRdot vector, and the w parameter is equivalent to vPQR.
@author Tony Peden, Jon Berndt
- @version $Id: FGAuxiliary.h,v 1.29 2014/12/27 05:41:11 dpculp Exp $
+ @version $Id: FGAuxiliary.h,v 1.31 2015/09/20 20:53:13 bcoconni Exp $
*/
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -173,7 +173,7 @@ public:
const FGColumnVector3& GetAeroUVW (void) const { return vAeroUVW; }
const FGLocation& GetLocationVRP(void) const { return vLocationVRP; }
- double GethVRP(void) const;
+ double GethVRP(void) const { return vLocationVRP.GetAltitudeASL(); }
double GetAeroUVW (int idx) const { return vAeroUVW(idx); }
double Getalpha (void) const { return alpha; }
double Getbeta (void) const { return beta; }
@@ -247,9 +247,9 @@ public:
int GetDayOfYear (void) const { return day_of_year; }
double GetSecondsInDay (void) const { return seconds_in_day; }
- double GetLongitudeRelativePosition (void) const { return lon_relative_position; }
- double GetLatitudeRelativePosition (void) const { return lat_relative_position; }
- double GetDistanceRelativePosition (void) const { return relative_position; }
+ double GetLongitudeRelativePosition (void) const;
+ double GetLatitudeRelativePosition (void) const;
+ double GetDistanceRelativePosition (void) const;
void SetAeroPQR(const FGColumnVector3& tt) { vAeroPQR = tt; }
@@ -280,7 +280,6 @@ public:
FGColumnVector3 VRPBody;
FGColumnVector3 vFw;
FGLocation vLocation;
- double ReferenceRadius;
double CosTht;
double SinTht;
double CosPhi;
@@ -327,12 +326,6 @@ private:
double hoverbcg, hoverbmac;
- // helper data, calculation of distance from initial position
-
- double lon_relative_position;
- double lat_relative_position;
- double relative_position;
-
void UpdateWindMatrices(void);
void CalculateRelativePosition(void);
diff --git a/src/FDM/JSBSim/models/FGFCS.cpp b/src/FDM/JSBSim/models/FGFCS.cpp
index 486f03e87..8e10abb97 100644
--- a/src/FDM/JSBSim/models/FGFCS.cpp
+++ b/src/FDM/JSBSim/models/FGFCS.cpp
@@ -44,7 +44,6 @@ INCLUDES
#include "FGFCS.h"
#include "FGFDMExec.h"
#include "FGGroundReactions.h"
-#include "input_output/FGPropertyManager.h"
#include "input_output/FGXMLElement.h"
#include "input_output/FGModelLoader.h"
@@ -71,7 +70,7 @@ using namespace std;
namespace JSBSim {
-IDENT(IdSrc,"$Id: FGFCS.cpp,v 1.90 2014/06/09 11:52:07 bcoconni Exp $");
+IDENT(IdSrc,"$Id: FGFCS.cpp,v 1.92 2015/07/12 19:34:08 bcoconni Exp $");
IDENT(IdHdr,ID_FCS);
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -82,6 +81,7 @@ FGFCS::FGFCS(FGFDMExec* fdmex) : FGModel(fdmex)
{
int i;
Name = "FGFCS";
+ systype = stFCS;
DaCmd = DeCmd = DrCmd = DsCmd = DfCmd = DsbCmd = DspCmd = 0;
PTrimCmd = YTrimCmd = RTrimCmd = 0.0;
@@ -326,11 +326,10 @@ void FGFCS::SetDspPos( int form , double pos )
void FGFCS::SetThrottleCmd(int engineNum, double setting)
{
- unsigned int ctr;
-
if (engineNum < (int)ThrottlePos.size()) {
if (engineNum < 0) {
- for (ctr=0;ctrGetName() == "autopilot") {
+ Name = "Autopilot: ";
+ systype = stAutoPilot;
+ } else if (document->GetName() == "flight_control") {
+ Name = "FCS: ";
+ systype = stFCS;
+ } else if (document->GetName() == "system") {
+ Name = "System: ";
+ systype = stSystem;
+ }
// Load interface properties from document
if (!FGModel::Load(document))
return false;
- name = document->GetAttributeValue("name");
-
- Name = "Flight Control Systems Model: " + document->GetAttributeValue("name");
+ Name += document->GetAttributeValue("name");
- if (document->GetName() == "autopilot") {
- Name = "Autopilot: " + document->GetAttributeValue("name");
- } else if (document->GetName() == "flight_control") {
- Name = "FCS: " + document->GetAttributeValue("name");
- } else if (document->GetName() == "system") {
- Name = "System: " + document->GetAttributeValue("name");
- }
Debug(2);
- if (document->GetName() == "flight_control") bindModel();
+ if (systype == stFCS) bindModel();
- channel_element = document->FindElement("channel");
+ Element* channel_element = document->FindElement("channel");
while (channel_element) {
@@ -523,9 +511,8 @@ bool FGFCS::Load(Element* document, SystemType type)
string sOnOffProperty = channel_element->GetAttributeValue("execute");
string sChannelName = channel_element->GetAttributeValue("name");
- FGPropertyNode* OnOffPropertyNode = 0;
if (sOnOffProperty.length() > 0) {
- OnOffPropertyNode = PropertyManager->GetNode(sOnOffProperty);
+ FGPropertyNode* OnOffPropertyNode = PropertyManager->GetNode(sOnOffProperty);
if (OnOffPropertyNode == 0) {
cerr << highint << fgred
<< "The On/Off property, " << sOnOffProperty << " specified for channel "
@@ -545,7 +532,7 @@ bool FGFCS::Load(Element* document, SystemType type)
cout << endl << highint << fgblue << " Channel "
<< normint << channel_element->GetAttributeValue("name") << reset << endl;
- component_element = channel_element->GetElement();
+ Element* component_element = channel_element->GetElement();
while (component_element) {
try {
if ((component_element->GetName() == string("lag_filter")) ||
@@ -593,7 +580,7 @@ bool FGFCS::Load(Element* document, SystemType type)
} else {
cerr << "Unknown FCS component: " << component_element->GetName() << endl;
}
- } catch(string s) {
+ } catch(string& s) {
cerr << highint << fgred << endl << " " << s << endl;
cerr << reset << endl;
return false;
diff --git a/src/FDM/JSBSim/models/FGFCS.h b/src/FDM/JSBSim/models/FGFCS.h
index f86c1d1b2..9f6543f99 100644
--- a/src/FDM/JSBSim/models/FGFCS.h
+++ b/src/FDM/JSBSim/models/FGFCS.h
@@ -40,9 +40,8 @@ INCLUDES
#include
#include
-
#include
-#include "models/flight_control/FGFCSComponent.h"
+
#include "models/FGModel.h"
#include "models/FGLGear.h"
@@ -50,7 +49,7 @@ INCLUDES
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_FCS "$Id: FGFCS.h,v 1.47 2015/02/27 20:36:47 bcoconni Exp $"
+#define ID_FCS "$Id: FGFCS.h,v 1.49 2015/07/12 19:34:08 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
@@ -168,7 +167,7 @@ CLASS DOCUMENTATION
@property gear/tailhook-pos-norm
@author Jon S. Berndt
- @version $Revision: 1.47 $
+ @version $Revision: 1.49 $
@see FGActuator
@see FGDeadBand
@see FGFCSFunction
@@ -551,9 +550,8 @@ public:
/** Loads the Flight Control System.
Load() is called from FGFDMExec.
@param el pointer to the Element instance
- @param systype type of system (FCS, Autopilot, System)
@return true if succesful */
- bool Load(Element* el, SystemType systype);
+ bool Load(Element* el);
std::string FindFullPathName(const std::string& system_filename) const;
@@ -565,10 +563,6 @@ public:
bool GetTrimStatus(void) const { return FDMExec->GetTrimStatus(); }
- struct Inputs {
- unsigned int NumGear;
- } in;
-
private:
double DaCmd, DeCmd, DrCmd, DsCmd, DfCmd, DsbCmd, DspCmd;
double DePos[NForms], DaLPos[NForms], DaRPos[NForms], DrPos[NForms];
diff --git a/src/FDM/JSBSim/models/FGFCSChannel.h b/src/FDM/JSBSim/models/FGFCSChannel.h
old mode 100644
new mode 100755
index e4695934f..0eda6711b
--- a/src/FDM/JSBSim/models/FGFCSChannel.h
+++ b/src/FDM/JSBSim/models/FGFCSChannel.h
@@ -70,7 +70,7 @@ typedef std::vector FCSCompVec;
class FGFCSChannel {
public:
/// Constructor
- FGFCSChannel(string name, FGPropertyNode* node=0) :
+ FGFCSChannel(std::string name, FGPropertyNode* node=0) :
OnOffNode(node), Name(name)
{
}
@@ -80,7 +80,7 @@ public:
FCSComponents.clear();
}
/// Retrieves the name of the channel
- string GetName() {return Name;}
+ std::string GetName() {return Name;}
/// Adds a component to a channel
void Add(FGFCSComponent* comp) {FCSComponents.push_back(comp);}
@@ -114,7 +114,7 @@ public:
private:
FCSCompVec FCSComponents;
FGConstPropertyNode_ptr OnOffNode;
- string Name;
+ std::string Name;
};
}
diff --git a/src/FDM/JSBSim/models/FGInput.cpp b/src/FDM/JSBSim/models/FGInput.cpp
old mode 100644
new mode 100755
index be6284200..5bf66a4f2
--- a/src/FDM/JSBSim/models/FGInput.cpp
+++ b/src/FDM/JSBSim/models/FGInput.cpp
@@ -50,7 +50,7 @@ using namespace std;
namespace JSBSim {
-IDENT(IdSrc,"$Id: FGInput.cpp,v 1.33 2015/04/08 19:35:00 bcoconni Exp $");
+IDENT(IdSrc,"$Id: FGInput.cpp,v 1.34 2015/08/23 09:43:31 bcoconni Exp $");
IDENT(IdHdr,ID_INPUT);
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -60,6 +60,7 @@ CLASS IMPLEMENTATION
FGInput::FGInput(FGFDMExec* fdmex) : FGModel(fdmex)
{
Name = "FGInput";
+ enabled = true;
Debug(0);
}
@@ -139,7 +140,9 @@ bool FGInput::InitModel(void)
bool FGInput::Run(bool Holding)
{
+ if (FDMExec->GetTrimStatus()) return true;
if (FGModel::Run(Holding)) return true;
+ if (!enabled) return true;
vector::iterator it;
for (it = InputTypes.begin(); it != InputTypes.end(); ++it)
@@ -164,24 +167,6 @@ bool FGInput::SetDirectivesFile(const std::string& fname)
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-void FGInput::Enable(void)
-{
- vector::iterator it;
- for (it = InputTypes.begin(); it != InputTypes.end(); ++it)
- (*it)->Enable();
-}
-
-//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-void FGInput::Disable(void)
-{
- vector::iterator it;
- for (it = InputTypes.begin(); it != InputTypes.end(); ++it)
- (*it)->Disable();
-}
-
-//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
bool FGInput::Toggle(int idx)
{
if (idx >= (int)0 && idx < (int)InputTypes.size())
diff --git a/src/FDM/JSBSim/models/FGInput.h b/src/FDM/JSBSim/models/FGInput.h
old mode 100644
new mode 100755
index e127bbe91..e2b606d7c
--- a/src/FDM/JSBSim/models/FGInput.h
+++ b/src/FDM/JSBSim/models/FGInput.h
@@ -46,7 +46,7 @@ INCLUDES
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_INPUT "$Id: FGInput.h,v 1.11 2015/02/15 12:03:21 bcoconni Exp $"
+#define ID_INPUT "$Id: FGInput.h,v 1.13 2015/08/23 09:43:31 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
@@ -81,7 +81,7 @@ CLASS DOCUMENTATION
The class FGInput is the manager of the inputs requested by the user. It
manages a list of instances derived from the abstract class FGInputType.
- @version $Id: FGInput.h,v 1.11 2015/02/15 12:03:21 bcoconni Exp $
+ @version $Id: FGInput.h,v 1.13 2015/08/23 09:43:31 bcoconni Exp $
*/
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -125,10 +125,10 @@ public:
bool SetDirectivesFile(const std::string& fname);
/// Enables the input generation for all input instances.
- void Enable(void);
+ void Enable(void) { enabled = true; }
/// Disables the input generation for all input instances.
- void Disable(void);
- /** Toggles the input generation for an ouput instances.
+ void Disable(void) { enabled = false; }
+ /** Toggles the input generation of each input instance.
@param idx ID of the input instance which input generation will be
toggled.
@result false if the instance does not exist otherwise returns the status
@@ -152,6 +152,7 @@ public:
private:
std::vector InputTypes;
+ bool enabled;
void Debug(int from);
};
diff --git a/src/FDM/JSBSim/models/FGLGear.cpp b/src/FDM/JSBSim/models/FGLGear.cpp
index 7ac687ee5..d26ddbcbe 100644
--- a/src/FDM/JSBSim/models/FGLGear.cpp
+++ b/src/FDM/JSBSim/models/FGLGear.cpp
@@ -42,11 +42,9 @@ INCLUDES
#include
#include
-#include
#include "math/FGFunction.h"
#include "FGLGear.h"
-#include "input_output/FGPropertyManager.h"
#include "models/FGGroundReactions.h"
#include "math/FGTable.h"
#include "input_output/FGXMLElement.h"
@@ -63,7 +61,7 @@ DEFINITIONS
GLOBAL DATA
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-IDENT(IdSrc,"$Id: FGLGear.cpp,v 1.118 2014/11/30 12:35:32 bcoconni Exp $");
+IDENT(IdSrc,"$Id: FGLGear.cpp,v 1.120 2015/08/16 16:13:31 bcoconni Exp $");
IDENT(IdHdr,ID_LGEAR);
// Body To Structural (body frame is rotated 180 deg about Y and lengths are given in
@@ -166,6 +164,23 @@ FGLGear::FGLGear(Element* el, FGFDMExec* fdmex, int number, const struct Inputs&
else
eSteerType = stSteer;
+ Element* castering = el->FindElement("castered");
+ if (castering) {
+ if (castering->GetDataAsNumber() != 0.0) {
+ eSteerType = stCaster;
+ Castered = true;
+ }
+ else {
+ if (maxSteerAngle == 0.0) {
+ eSteerType = stFixed;
+ }
+ else {
+ eSteerType = stSteer;
+ }
+ Castered = false;
+ }
+ }
+
GroundReactions = fdmex->GetGroundReactions();
ForceY_Table = 0;
@@ -262,7 +277,13 @@ void FGLGear::ResetToIC(void)
WheelSlip = 0.0;
// Initialize Lagrange multipliers
- memset(LMultiplier, 0, sizeof(LMultiplier));
+ for (int i=0; i < 3; i++) {
+ LMultiplier[i].ForceJacobian.InitMatrix();
+ LMultiplier[i].MomentJacobian.InitMatrix();
+ LMultiplier[i].Min = 0.0;
+ LMultiplier[i].Max = 0.0;
+ LMultiplier[i].value = 0.0;
+ }
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
diff --git a/src/FDM/JSBSim/models/FGMassBalance.h b/src/FDM/JSBSim/models/FGMassBalance.h
index ca8f3b16c..56b1f6849 100644
--- a/src/FDM/JSBSim/models/FGMassBalance.h
+++ b/src/FDM/JSBSim/models/FGMassBalance.h
@@ -48,14 +48,12 @@ INCLUDES
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_MASSBALANCE "$Id: FGMassBalance.h,v 1.35 2015/03/28 14:49:02 bcoconni Exp $"
+#define ID_MASSBALANCE "$Id: FGMassBalance.h,v 1.36 2015/08/22 18:09:00 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONSS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-using std::string;
-
namespace JSBSim {
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -248,7 +246,7 @@ private:
double Weight; /// Weight in pounds.
double Radius; /// Radius in feet.
double Length; /// Length in feet.
- string Name;
+ std::string Name;
FGMatrix33 mPMInertia;
double GetPointMassLocation(int axis) const {return Location(axis);}
@@ -256,7 +254,7 @@ private:
esShape GetShapeType(void) {return eShapeType;}
const FGColumnVector3& GetLocation(void) {return Location;}
const FGMatrix33& GetPointMassInertia(void) {return mPMInertia;}
- const string& GetName(void) {return Name;}
+ const std::string& GetName(void) {return Name;}
void SetPointMassLocation(int axis, double value) {Location(axis) = value;}
void SetPointMassWeight(double wt) {
@@ -266,7 +264,7 @@ private:
void SetPointMassShapeType(esShape st) {eShapeType = st;}
void SetRadius(double r) {Radius = r;}
void SetLength(double l) {Length = l;}
- void SetName(string name) {Name = name;}
+ void SetName(const std::string& name) {Name = name;}
void SetPointMassMoI(const FGMatrix33& MoI) { mPMInertia = MoI; }
double GetPointMassMoI(int r, int c) {return mPMInertia(r,c);}
diff --git a/src/FDM/JSBSim/models/FGModel.cpp b/src/FDM/JSBSim/models/FGModel.cpp
index ba05a71e1..943444ac3 100644
--- a/src/FDM/JSBSim/models/FGModel.cpp
+++ b/src/FDM/JSBSim/models/FGModel.cpp
@@ -46,7 +46,7 @@ using namespace std;
namespace JSBSim {
-IDENT(IdSrc,"$Id: FGModel.cpp,v 1.25 2014/06/09 11:52:07 bcoconni Exp $");
+IDENT(IdSrc,"$Id: FGModel.cpp,v 1.26 2015/07/12 19:34:08 bcoconni Exp $");
IDENT(IdHdr,ID_MODEL);
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -142,8 +142,6 @@ bool FGModel::Load(Element* el)
element->SetParent(el);
element = document->FindNextElement();
}
-
- document = el;
}
return result;
diff --git a/src/FDM/JSBSim/models/FGModel.h b/src/FDM/JSBSim/models/FGModel.h
index 86b576b46..b7ad17bca 100644
--- a/src/FDM/JSBSim/models/FGModel.h
+++ b/src/FDM/JSBSim/models/FGModel.h
@@ -46,7 +46,7 @@ INCLUDES
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_MODEL "$Id: FGModel.h,v 1.22 2014/06/09 11:52:07 bcoconni Exp $"
+#define ID_MODEL "$Id: FGModel.h,v 1.25 2015/08/16 13:19:52 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
@@ -93,16 +93,18 @@ public:
virtual bool Run(bool Holding);
virtual bool InitModel(void);
- virtual void SetRate(int tt) {rate = tt;}
- virtual int GetRate(void) {return rate;}
+ /// Set the ouput rate for the model in frames
+ void SetRate(unsigned int tt) {rate = tt;}
+ /// Get the output rate for the model in frames
+ unsigned int GetRate(void) {return rate;}
FGFDMExec* GetExec(void) {return FDMExec;}
void SetPropertyManager(FGPropertyManager *fgpm) { PropertyManager=fgpm;}
virtual std::string FindFullPathName(const std::string& filename) const;
protected:
- int exe_ctr;
- int rate;
+ unsigned int exe_ctr;
+ unsigned int rate;
/** Loads this model.
@param el a pointer to the element
diff --git a/src/FDM/JSBSim/models/FGOutput.cpp b/src/FDM/JSBSim/models/FGOutput.cpp
index d5221ca9e..6d682bac9 100644
--- a/src/FDM/JSBSim/models/FGOutput.cpp
+++ b/src/FDM/JSBSim/models/FGOutput.cpp
@@ -53,7 +53,7 @@ using namespace std;
namespace JSBSim {
-IDENT(IdSrc,"$Id: FGOutput.cpp,v 1.82 2015/04/02 02:20:50 dpculp Exp $");
+IDENT(IdSrc,"$Id: FGOutput.cpp,v 1.86 2015/08/23 09:43:31 bcoconni Exp $");
IDENT(IdHdr,ID_OUTPUT);
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -65,6 +65,7 @@ FGOutput::FGOutput(FGFDMExec* fdmex) : FGModel(fdmex)
typedef int (FGOutput::*iOPV)(void) const;
Name = "FGOutput";
+ enabled = true;
PropertyManager->Tie("simulation/force-output", this, (iOPV)0, &FGOutput::ForceOutput, false);
@@ -101,11 +102,14 @@ bool FGOutput::InitModel(void)
bool FGOutput::Run(bool Holding)
{
+ if (FDMExec->GetTrimStatus()) return true;
if (FGModel::Run(Holding)) return true;
+ if (Holding) return false;
+ if (!enabled) return true;
vector::iterator it;
for (it = OutputTypes.begin(); it != OutputTypes.end(); ++it)
- (*it)->Run(Holding);
+ (*it)->Run();
return false;
}
@@ -130,24 +134,6 @@ void FGOutput::SetStartNewOutput(void)
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-void FGOutput::Enable(void)
-{
- vector::iterator it;
- for (it = OutputTypes.begin(); it != OutputTypes.end(); ++it)
- (*it)->Enable();
-}
-
-//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-void FGOutput::Disable(void)
-{
- vector::iterator it;
- for (it = OutputTypes.begin(); it != OutputTypes.end(); ++it)
- (*it)->Disable();
-}
-
-//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
bool FGOutput::Toggle(int idx)
{
if (idx >= (int)0 && idx < (int)OutputTypes.size())
@@ -158,11 +144,11 @@ bool FGOutput::Toggle(int idx)
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-void FGOutput::SetRate(double rate)
+void FGOutput::SetRateHz(double rate)
{
vector::iterator it;
for (it = OutputTypes.begin(); it != OutputTypes.end(); ++it)
- (*it)->SetRate(rate);
+ (*it)->SetRateHz(rate);
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -248,7 +234,7 @@ bool FGOutput::Load(int subSystems, std::string protocol, std::string type,
Output->SetIdx(idx);
Output->SetOutputName(name);
- Output->SetRate(outRate);
+ Output->SetRateHz(outRate);
Output->SetSubSystems(subSystems);
Output->SetOutputProperties(outputProperties);
diff --git a/src/FDM/JSBSim/models/FGOutput.h b/src/FDM/JSBSim/models/FGOutput.h
index 86e14c1ff..7a68a8440 100644
--- a/src/FDM/JSBSim/models/FGOutput.h
+++ b/src/FDM/JSBSim/models/FGOutput.h
@@ -47,7 +47,7 @@ INCLUDES
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_OUTPUT "$Id: FGOutput.h,v 1.29 2013/11/24 11:40:56 bcoconni Exp $"
+#define ID_OUTPUT "$Id: FGOutput.h,v 1.33 2015/08/23 09:43:31 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
@@ -121,7 +121,7 @@ CLASS DOCUMENTATION
The class FGOutput is the manager of the outputs requested by the user. It
manages a list of instances derived from the abstract class FGOutputType.
- @version $Id: FGOutput.h,v 1.29 2013/11/24 11:40:56 bcoconni Exp $
+ @version $Id: FGOutput.h,v 1.33 2015/08/23 09:43:31 bcoconni Exp $
*/
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -183,10 +183,10 @@ public:
@return true if the execution succeeded. */
bool SetDirectivesFile(const std::string& fname);
/// Enables the output generation for all output instances.
- void Enable(void);
+ void Enable(void) { enabled = true; }
/// Disables the output generation for all output instances.
- void Disable(void);
- /** Toggles the output generation for an ouput instances.
+ void Disable(void) { enabled = false; }
+ /** Toggles the output generation of each ouput instance.
@param idx ID of the output instance which output generation will be
toggled.
@result false if the instance does not exist otherwise returns the status
@@ -195,7 +195,7 @@ public:
bool Toggle(int idx);
/** Modifies the output rate for all output instances.
@param rate new output rate in Hz */
- void SetRate(double rate);
+ void SetRateHz(double rate);
/** Load the output directives and adds a new output instance to the Output
Manager list.
@param el XMLElement that is pointing to the output directives
@@ -224,6 +224,7 @@ public:
private:
std::vector OutputTypes;
+ bool enabled;
void Debug(int from);
};
diff --git a/src/FDM/JSBSim/models/FGPropagate.cpp b/src/FDM/JSBSim/models/FGPropagate.cpp
index c0d20fdb6..a2aebf58c 100644
--- a/src/FDM/JSBSim/models/FGPropagate.cpp
+++ b/src/FDM/JSBSim/models/FGPropagate.cpp
@@ -79,7 +79,7 @@ using namespace std;
namespace JSBSim {
-IDENT(IdSrc,"$Id: FGPropagate.cpp,v 1.126 2014/11/30 12:35:32 bcoconni Exp $");
+IDENT(IdSrc,"$Id: FGPropagate.cpp,v 1.127 2015/08/22 18:09:00 bcoconni Exp $");
IDENT(IdHdr,ID_PROPAGATE);
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -188,12 +188,10 @@ void FGPropagate::SetInitialState(const FGInitialCondition *FGIC)
void FGPropagate::InitializeDerivatives()
{
- for (int i=0; i<5; i++) {
- VState.dqPQRidot[i] = in.vPQRidot;
- VState.dqUVWidot[i] = in.vUVWidot;
- VState.dqInertialVelocity[i] = VState.vInertialVelocity;
- VState.dqQtrndot[i] = in.vQtrndot;
- }
+ VState.dqPQRidot.assign(5, in.vPQRidot);
+ VState.dqUVWidot.assign(5, in.vUVWidot);
+ VState.dqInertialVelocity.assign(5, VState.vInertialVelocity);
+ VState.dqQtrndot.assign(5, in.vQtrndot);
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -636,7 +634,6 @@ void FGPropagate::WriteStateFile(int num)
string filename = FDMExec->GetFullAircraftPath();
- string sim_time = to_string((double)FDMExec->GetSimTime());
if (filename.empty()) filename = "initfile.";
else filename.append("/initfile.");
diff --git a/src/FDM/JSBSim/models/FGPropagate.h b/src/FDM/JSBSim/models/FGPropagate.h
index a3c3a2702..682c555b5 100644
--- a/src/FDM/JSBSim/models/FGPropagate.h
+++ b/src/FDM/JSBSim/models/FGPropagate.h
@@ -49,7 +49,7 @@ INCLUDES
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_PROPAGATE "$Id: FGPropagate.h,v 1.81 2014/05/17 15:15:53 jberndt Exp $"
+#define ID_PROPAGATE "$Id: FGPropagate.h,v 1.82 2015/08/22 18:09:00 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
@@ -57,7 +57,6 @@ FORWARD DECLARATIONS
namespace JSBSim {
-using std::deque;
class FGInitialCondition;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -93,7 +92,7 @@ CLASS DOCUMENTATION
@endcode
@author Jon S. Berndt, Mathias Froehlich, Bertrand Coconnier
- @version $Id: FGPropagate.h,v 1.81 2014/05/17 15:15:53 jberndt Exp $
+ @version $Id: FGPropagate.h,v 1.82 2015/08/22 18:09:00 bcoconni Exp $
*/
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -138,10 +137,10 @@ public:
FGColumnVector3 vInertialPosition;
- deque dqPQRidot;
- deque dqUVWidot;
- deque dqInertialVelocity;
- deque dqQtrndot;
+ std::deque dqPQRidot;
+ std::deque dqUVWidot;
+ std::deque dqInertialVelocity;
+ std::deque dqQtrndot;
};
/** Constructor.
@@ -567,7 +566,7 @@ public:
void SetDistanceAGL(double tt);
void SetDistanceAGLKm(double tt);
- void SetInitialState(const FGInitialCondition *);
+ void SetInitialState(const FGInitialCondition*);
void SetLocation(const FGLocation& l);
void SetLocation(const FGColumnVector3& lv)
{
@@ -632,13 +631,13 @@ private:
void Integrate( FGColumnVector3& Integrand,
FGColumnVector3& Val,
- deque & ValDot,
+ std::deque & ValDot,
double dt,
eIntegrateType integration_type);
void Integrate( FGQuaternion& Integrand,
FGQuaternion& Val,
- deque & ValDot,
+ std::deque & ValDot,
double dt,
eIntegrateType integration_type);
diff --git a/src/FDM/JSBSim/models/flight_control/FGAccelerometer.cpp b/src/FDM/JSBSim/models/flight_control/FGAccelerometer.cpp
old mode 100644
new mode 100755
index 2b9b4c5b4..eceac67a9
--- a/src/FDM/JSBSim/models/flight_control/FGAccelerometer.cpp
+++ b/src/FDM/JSBSim/models/flight_control/FGAccelerometer.cpp
@@ -44,14 +44,14 @@ INCLUDES
#include "models/FGPropagate.h"
#include "models/FGAccelerations.h"
#include "models/FGMassBalance.h"
-#include "models/FGInertial.h"
#include "input_output/FGXMLElement.h"
+#include "models/FGFCS.h"
using namespace std;
namespace JSBSim {
-IDENT(IdSrc,"$Id: FGAccelerometer.cpp,v 1.15 2014/01/13 10:46:07 ehofman Exp $");
+IDENT(IdSrc,"$Id: FGAccelerometer.cpp,v 1.17 2015/08/09 17:29:48 bcoconni Exp $");
IDENT(IdHdr,ID_ACCELEROMETER);
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -92,8 +92,8 @@ bool FGAccelerometer::Run(void )
//aircraft forces
vAccel = (Accelerations->GetBodyAccel()
- + Accelerations->GetPQRidot() * vRadius
- + Propagate->GetPQRi() * (Propagate->GetPQRi() * vRadius));
+ + Accelerations->GetPQRidot() * vRadius
+ + Propagate->GetPQRi() * (Propagate->GetPQRi() * vRadius));
// transform to the specified orientation
vAccel = mT * vAccel;
diff --git a/src/FDM/JSBSim/models/flight_control/FGActuator.cpp b/src/FDM/JSBSim/models/flight_control/FGActuator.cpp
index dd492c4af..453752775 100644
--- a/src/FDM/JSBSim/models/flight_control/FGActuator.cpp
+++ b/src/FDM/JSBSim/models/flight_control/FGActuator.cpp
@@ -42,12 +42,13 @@ INCLUDES
#include "FGActuator.h"
#include "input_output/FGXMLElement.h"
#include "math/FGRealValue.h"
+#include "models/FGFCS.h"
using namespace std;
namespace JSBSim {
-IDENT(IdSrc,"$Id: FGActuator.cpp,v 1.37 2014/08/28 13:44:28 bcoconni Exp $");
+IDENT(IdSrc,"$Id: FGActuator.cpp,v 1.38 2015/07/12 19:34:08 bcoconni Exp $");
IDENT(IdHdr,ID_ACTUATOR);
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -57,8 +58,6 @@ CLASS IMPLEMENTATION
FGActuator::FGActuator(FGFCS* fcs, Element* element) : FGFCSComponent(fcs, element)
{
- double denom;
-
// inputs are read from the base class constructor
PreviousOutput = 0.0;
@@ -119,7 +118,7 @@ FGActuator::FGActuator(FGFCS* fcs, Element* element) : FGFCSComponent(fcs, eleme
}
if ( element->FindElement("lag") ) {
lag = element->FindElementValueAsNumber("lag");
- denom = 2.00 + dt*lag;
+ double denom = 2.00 + dt*lag;
ca = dt*lag / denom;
cb = (2.00 - dt*lag) / denom;
}
diff --git a/src/FDM/JSBSim/models/flight_control/FGFCSComponent.cpp b/src/FDM/JSBSim/models/flight_control/FGFCSComponent.cpp
index 39d586972..5152a558b 100644
--- a/src/FDM/JSBSim/models/flight_control/FGFCSComponent.cpp
+++ b/src/FDM/JSBSim/models/flight_control/FGFCSComponent.cpp
@@ -37,18 +37,19 @@ COMMENTS, REFERENCES, and NOTES
INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+#include
+#include
+
#include "FGFCSComponent.h"
-#include "input_output/FGPropertyManager.h"
#include "input_output/FGXMLElement.h"
#include "math/FGPropertyValue.h"
-#include
-#include
+#include "models/FGFCS.h"
using namespace std;
namespace JSBSim {
-IDENT(IdSrc,"$Id: FGFCSComponent.cpp,v 1.40 2014/01/13 10:46:08 ehofman Exp $");
+IDENT(IdSrc,"$Id: FGFCSComponent.cpp,v 1.41 2015/07/12 19:34:08 bcoconni Exp $");
IDENT(IdHdr,ID_FCSCOMPONENT);
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -129,9 +130,9 @@ FGFCSComponent::FGFCSComponent(FGFCS* _fcs, Element* element) : fcs(_fcs)
} else {
InitSigns.push_back( 1.0);
}
- FGPropertyNode* node = 0L;
+
if (PropertyManager->HasNode(init)) {
- node = PropertyManager->GetNode(init);
+ FGPropertyNode* node = PropertyManager->GetNode(init);
InitNodes.push_back(new FGPropertyValue( node ));
} else {
InitNodes.push_back(new FGPropertyValue( init,
@@ -151,9 +152,9 @@ FGFCSComponent::FGFCSComponent(FGFCS* _fcs, Element* element) : fcs(_fcs)
} else {
InputSigns.push_back( 1.0);
}
- FGPropertyNode* node = 0L;
+
if (PropertyManager->HasNode(input)) {
- node = PropertyManager->GetNode(input);
+ FGPropertyNode* node = PropertyManager->GetNode(input);
InputNodes.push_back(new FGPropertyValue( node ));
} else {
InputNodes.push_back(new FGPropertyValue( input,
@@ -319,8 +320,6 @@ void FGFCSComponent::bind(void)
void FGFCSComponent::Debug(int from)
{
- string propsign="";
-
if (debug_lvl <= 0) return;
if (debug_lvl & 1) { // Standard console startup message output
@@ -329,17 +328,20 @@ void FGFCSComponent::Debug(int from)
<< "\" of type: " << Type << endl;
if (clip) {
+ string propsign;
+
if (ClipMinPropertyNode != 0L) {
if (clipMinSign < 0.0) propsign="-";
cout << " Minimum limit: " << propsign << ClipMinPropertyNode->GetName() << endl;
- propsign="";
} else {
cout << " Minimum limit: " << clipmin << endl;
}
+
+ propsign="";
+
if (ClipMaxPropertyNode != 0L) {
if (clipMaxSign < 0.0) propsign="-";
cout << " Maximum limit: " << propsign << ClipMaxPropertyNode->GetName() << endl;
- propsign="";
} else {
cout << " Maximum limit: " << clipmax << endl;
}
diff --git a/src/FDM/JSBSim/models/flight_control/FGFCSComponent.h b/src/FDM/JSBSim/models/flight_control/FGFCSComponent.h
index 4e1680a95..70ae0b6e6 100644
--- a/src/FDM/JSBSim/models/flight_control/FGFCSComponent.h
+++ b/src/FDM/JSBSim/models/flight_control/FGFCSComponent.h
@@ -37,16 +37,17 @@ SENTRY
INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#include "FGJSBBase.h"
-#include "math/FGPropertyValue.h"
#include
#include
+#include "FGJSBBase.h"
+#include "math/FGPropertyValue.h"
+
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_FCSCOMPONENT "$Id: FGFCSComponent.h,v 1.26 2014/02/17 05:33:25 jberndt Exp $"
+#define ID_FCSCOMPONENT "$Id: FGFCSComponent.h,v 1.27 2015/07/12 19:34:08 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
@@ -82,7 +83,7 @@ CLASS DOCUMENTATION
- FGAngle
@author Jon S. Berndt
- @version $Id: FGFCSComponent.h,v 1.26 2014/02/17 05:33:25 jberndt Exp $
+ @version $Id: FGFCSComponent.h,v 1.27 2015/07/12 19:34:08 bcoconni Exp $
@see Documentation for the FGFCS class, and for the configuration file class
*/
@@ -141,7 +142,4 @@ protected:
} //namespace JSBSim
-#include "../FGFCS.h"
-
#endif
-
diff --git a/src/FDM/JSBSim/models/flight_control/FGFilter.cpp b/src/FDM/JSBSim/models/flight_control/FGFilter.cpp
index 906068896..2d7902287 100644
--- a/src/FDM/JSBSim/models/flight_control/FGFilter.cpp
+++ b/src/FDM/JSBSim/models/flight_control/FGFilter.cpp
@@ -48,7 +48,7 @@ using namespace std;
namespace JSBSim {
-IDENT(IdSrc,"$Id: FGFilter.cpp,v 1.20 2014/01/13 10:46:09 ehofman Exp $");
+IDENT(IdSrc,"$Id: FGFilter.cpp,v 1.21 2015/09/27 20:26:23 bcoconni Exp $");
IDENT(IdHdr,ID_FILTER);
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -188,11 +188,9 @@ void FGFilter::CalculateDynamicFilters(void)
bool FGFilter::Run(void)
{
- double test = 0.0;
-
if (Initialize) {
- PreviousOutput1 = PreviousInput1 = Output = Input;
+ PreviousOutput2 = PreviousInput2 = PreviousOutput1 = PreviousInput1 = Output = Input;
Initialize = false;
} else {
@@ -217,7 +215,7 @@ bool FGFilter::Run(void)
break;
case eIntegrator:
if (Trigger != 0) {
- test = Trigger->getDoubleValue();
+ double test = Trigger->getDoubleValue();
if (fabs(test) > 0.000001) {
Input = PreviousInput1 = PreviousInput2 = 0.0;
}
diff --git a/src/FDM/JSBSim/models/flight_control/FGGyro.cpp b/src/FDM/JSBSim/models/flight_control/FGGyro.cpp
old mode 100644
new mode 100755
index ceaafef32..d1849465d
--- a/src/FDM/JSBSim/models/flight_control/FGGyro.cpp
+++ b/src/FDM/JSBSim/models/flight_control/FGGyro.cpp
@@ -42,12 +42,13 @@ INCLUDES
#include "FGGyro.h"
#include "models/FGAccelerations.h"
#include "input_output/FGXMLElement.h"
+#include "models/FGFCS.h"
using namespace std;
namespace JSBSim {
-IDENT(IdSrc,"$Id: FGGyro.cpp,v 1.10 2014/01/13 10:46:09 ehofman Exp $");
+IDENT(IdSrc,"$Id: FGGyro.cpp,v 1.11 2015/07/12 19:34:08 bcoconni Exp $");
IDENT(IdHdr,ID_GYRO);
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
diff --git a/src/FDM/JSBSim/models/flight_control/FGMagnetometer.cpp b/src/FDM/JSBSim/models/flight_control/FGMagnetometer.cpp
old mode 100644
new mode 100755
index eeb2b1c1c..b7203e5b7
--- a/src/FDM/JSBSim/models/flight_control/FGMagnetometer.cpp
+++ b/src/FDM/JSBSim/models/flight_control/FGMagnetometer.cpp
@@ -44,12 +44,13 @@ INCLUDES
#include "FGMagnetometer.h"
#include "simgear/magvar/coremag.hxx"
#include "input_output/FGXMLElement.h"
+#include "models/FGFCS.h"
using namespace std;
namespace JSBSim {
-IDENT(IdSrc,"$Id: FGMagnetometer.cpp,v 1.9 2014/01/13 10:46:09 ehofman Exp $");
+IDENT(IdSrc,"$Id: FGMagnetometer.cpp,v 1.10 2015/07/12 19:34:08 bcoconni Exp $");
IDENT(IdHdr,ID_MAGNETOMETER);
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
diff --git a/src/FDM/JSBSim/models/flight_control/FGSensor.cpp b/src/FDM/JSBSim/models/flight_control/FGSensor.cpp
old mode 100644
new mode 100755
index 93187953a..969219903
--- a/src/FDM/JSBSim/models/flight_control/FGSensor.cpp
+++ b/src/FDM/JSBSim/models/flight_control/FGSensor.cpp
@@ -37,16 +37,17 @@ COMMENTS, REFERENCES, and NOTES
INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#include "FGSensor.h"
-#include "input_output/FGXMLElement.h"
#include
#include
+#include "FGSensor.h"
+#include "input_output/FGXMLElement.h"
+
using namespace std;
namespace JSBSim {
-IDENT(IdSrc,"$Id: FGSensor.cpp,v 1.27 2014/01/13 10:46:10 ehofman Exp $");
+IDENT(IdSrc,"$Id: FGSensor.cpp,v 1.28 2015/07/12 19:34:08 bcoconni Exp $");
IDENT(IdHdr,ID_SENSOR);
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -56,8 +57,6 @@ CLASS IMPLEMENTATION
FGSensor::FGSensor(FGFCS* fcs, Element* element) : FGFCSComponent(fcs, element)
{
- double denom;
-
// inputs are read from the base class constructor
bits = quantized = divisions = 0;
@@ -94,7 +93,7 @@ FGSensor::FGSensor(FGFCS* fcs, Element* element) : FGFCSComponent(fcs, element)
}
if ( element->FindElement("lag") ) {
lag = element->FindElementValueAsNumber("lag");
- denom = 2.00 + dt*lag;
+ double denom = 2.00 + dt*lag;
ca = dt*lag / denom;
cb = (2.00 - dt*lag) / denom;
}
diff --git a/src/FDM/JSBSim/models/flight_control/FGWaypoint.cpp b/src/FDM/JSBSim/models/flight_control/FGWaypoint.cpp
old mode 100644
new mode 100755
index 5f4d62397..0173ade54
--- a/src/FDM/JSBSim/models/flight_control/FGWaypoint.cpp
+++ b/src/FDM/JSBSim/models/flight_control/FGWaypoint.cpp
@@ -40,12 +40,13 @@ INCLUDES
#include "FGWaypoint.h"
#include "input_output/FGXMLElement.h"
#include "input_output/FGPropertyManager.h"
+#include "math/FGLocation.h"
using namespace std;
namespace JSBSim {
-IDENT(IdSrc,"$Id: FGWaypoint.cpp,v 1.5 2014/01/13 10:46:10 ehofman Exp $");
+IDENT(IdSrc,"$Id: FGWaypoint.cpp,v 1.6 2015/09/20 20:53:13 bcoconni Exp $");
IDENT(IdHdr,ID_WAYPOINT);
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -71,9 +72,8 @@ FGWaypoint::FGWaypoint(FGFCS* fcs, Element* element) : FGFCSComponent(fcs, eleme
target_latitude_unit = 0.017453293;
}
}
- } else {
+ } else
throw("Target latitude is required for waypoint component: "+Name);
- }
if (element->FindElement("target_longitude") ) {
target_longitude_pNode = PropertyManager->GetNode(element->FindElementValue("target_longitude"));
@@ -82,9 +82,8 @@ FGWaypoint::FGWaypoint(FGFCS* fcs, Element* element) : FGFCSComponent(fcs, eleme
target_longitude_unit = 0.017453293;
}
}
- } else {
+ } else
throw("Target longitude is required for waypoint component: "+Name);
- }
if (element->FindElement("source_latitude") ) {
source_latitude_pNode = PropertyManager->GetNode(element->FindElementValue("source_latitude"));
@@ -93,9 +92,8 @@ FGWaypoint::FGWaypoint(FGFCS* fcs, Element* element) : FGFCSComponent(fcs, eleme
source_latitude_unit = 0.017453293;
}
}
- } else {
+ } else
throw("Source latitude is required for waypoint component: "+Name);
- }
if (element->FindElement("source_longitude") ) {
source_longitude_pNode = PropertyManager->GetNode(element->FindElementValue("source_longitude"));
@@ -104,30 +102,28 @@ FGWaypoint::FGWaypoint(FGFCS* fcs, Element* element) : FGFCSComponent(fcs, eleme
source_longitude_unit = 0.017453293;
}
}
- } else {
+ } else
throw("Source longitude is required for waypoint component: "+Name);
- }
- if (element->FindElement("radius")) {
+ if (element->FindElement("radius"))
radius = element->FindElementValueAsNumberConvertTo("radius", "FT");
- } else {
+ else
radius = 21144000; // Radius of Earth in feet.
- }
unit = element->GetAttributeValue("unit");
if (WaypointType == eHeading) {
if (!unit.empty()) {
- if (unit == "DEG") eUnit = eDeg;
- else if (unit == "RAD") eUnit = eRad;
- else throw("Unknown unit "+unit+" in HEADING waypoint component, "+Name);
- } else {
+ if (unit == "DEG") eUnit = eDeg;
+ else if (unit == "RAD") eUnit = eRad;
+ else throw("Unknown unit "+unit+" in HEADING waypoint component, "+Name);
+ } else {
eUnit = eRad; // Default is radians if unspecified
}
} else {
if (!unit.empty()) {
- if (unit == "FT") eUnit = eFeet;
- else if (unit == "M") eUnit = eMeters;
- else throw("Unknown unit "+unit+" in DISTANCE waypoint component, "+Name);
+ if (unit == "FT") eUnit = eFeet;
+ else if (unit == "M") eUnit = eMeters;
+ else throw("Unknown unit "+unit+" in DISTANCE waypoint component, "+Name);
} else {
eUnit = eFeet; // Default is feet if unspecified
}
@@ -145,47 +141,18 @@ FGWaypoint::~FGWaypoint()
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-// The calculations, below, implement the Haversine formulas to calculate
-// heading and distance to a set of lat/long coordinates from the current
-// position. The latitude and longitude are expected to be in radian units
-// and are measured from the 0 meridian and the equator, with positive
-// longitude being east from there, and positive latitude being north.
-//
-// The basic equations are (lat1, long1 are source positions; lat2
-// long2 are target positions):
-//
-// R = earthâs radius
-// Îlat = lat2 â lat1
-// Îlong = long2 â long1
-//
-// For the heading angle calculation:
-//
-// θ = atan2(sin(Îlong)âcos(lat2), cos(lat1)âsin(lat2) â sin(lat1) âcos(lat2)âcos(Îlong) )
-//
-// For the waypoint distance calculation:
-//
-// a = sin²(Îlat/2) + cos(lat1)âcos(lat2)âsin²(Îlong/2)
-// c = 2âatan2(âa, â(1âa))
-// d = Râc
bool FGWaypoint::Run(void )
{
- target_latitude = target_latitude_pNode->getDoubleValue() * target_latitude_unit;
- target_longitude = target_longitude_pNode->getDoubleValue() * target_longitude_unit;
- source_latitude = source_latitude_pNode->getDoubleValue() * source_latitude_unit;
- source_longitude = source_longitude_pNode->getDoubleValue() * source_longitude_unit;
-
- double delta_lat_rad = target_latitude - source_latitude;
- double delta_lon_rad = target_longitude - source_longitude;
+ double target_latitude = target_latitude_pNode->getDoubleValue() * target_latitude_unit;
+ double target_longitude = target_longitude_pNode->getDoubleValue() * target_longitude_unit;
+ double source_latitude = source_latitude_pNode->getDoubleValue() * source_latitude_unit;
+ double source_longitude = source_longitude_pNode->getDoubleValue() * source_longitude_unit;
+ FGLocation source(source_longitude, source_latitude, radius);
if (WaypointType == eHeading) { // Calculate Heading
-
- double Y = sin(delta_lon_rad) * cos(target_latitude);
- double X = (cos(source_latitude) * sin(target_latitude))
- - (sin(source_latitude) * cos(target_latitude) * cos(delta_lon_rad));
-
- double heading_to_waypoint_rad = atan2(Y, X);
- if (heading_to_waypoint_rad < 0) heading_to_waypoint_rad += 2.0*M_PI;
+ double heading_to_waypoint_rad = source.GetHeadingTo(target_longitude,
+ target_latitude);
double heading_to_waypoint = 0;
if (eUnit == eDeg) heading_to_waypoint = heading_to_waypoint_rad * radtodeg;
@@ -194,12 +161,7 @@ bool FGWaypoint::Run(void )
Output = heading_to_waypoint;
} else { // Calculate Distance
-
- double distance_a = pow(sin(delta_lat_rad/2.0), 2.0)
- + (cos(source_latitude) * cos(target_latitude)
- * (pow(sin(delta_lon_rad/2.0), 2.0)));
-
- double wp_distance = 2.0 * radius * atan2(pow(distance_a, 0.5), pow((1.0 - distance_a), 0.5));
+ double wp_distance = source.GetDistanceTo(target_longitude, target_latitude);
if (eUnit == eMeters) {
Output = FeetToMeters(wp_distance);
diff --git a/src/FDM/JSBSim/models/flight_control/FGWaypoint.h b/src/FDM/JSBSim/models/flight_control/FGWaypoint.h
old mode 100644
new mode 100755
index bf7ba6626..999e9739a
--- a/src/FDM/JSBSim/models/flight_control/FGWaypoint.h
+++ b/src/FDM/JSBSim/models/flight_control/FGWaypoint.h
@@ -44,7 +44,7 @@ INCLUDES
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_WAYPOINT "$Id: FGWaypoint.h,v 1.1 2013/06/20 04:37:28 jberndt Exp $"
+#define ID_WAYPOINT "$Id: FGWaypoint.h,v 1.3 2015/09/20 20:53:13 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
@@ -92,7 +92,7 @@ CLASS DOCUMENTATION
@endcode
@author Jon S. Berndt
- @version $Id: FGWaypoint.h,v 1.1 2013/06/20 04:37:28 jberndt Exp $
+ @version $Id: FGWaypoint.h,v 1.3 2015/09/20 20:53:13 bcoconni Exp $
*/
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -112,10 +112,6 @@ private:
FGPropertyNode_ptr target_longitude_pNode;
FGPropertyNode_ptr source_latitude_pNode;
FGPropertyNode_ptr source_longitude_pNode;
- double target_latitude;
- double target_longitude;
- double source_latitude;
- double source_longitude;
double target_latitude_unit;
double target_longitude_unit;
double source_latitude_unit;
diff --git a/src/FDM/JSBSim/models/propulsion/FGElectric.cpp b/src/FDM/JSBSim/models/propulsion/FGElectric.cpp
index 41fba7d7f..9273a97bc 100644
--- a/src/FDM/JSBSim/models/propulsion/FGElectric.cpp
+++ b/src/FDM/JSBSim/models/propulsion/FGElectric.cpp
@@ -50,7 +50,7 @@ using namespace std;
namespace JSBSim {
-IDENT(IdSrc,"$Id: FGElectric.cpp,v 1.18 2014/06/08 12:00:35 bcoconni Exp $");
+IDENT(IdSrc,"$Id: FGElectric.cpp,v 1.20 2015/09/27 09:54:21 bcoconni Exp $");
IDENT(IdHdr,ID_ELECTRIC);
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -58,10 +58,8 @@ CLASS IMPLEMENTATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
FGElectric::FGElectric(FGFDMExec* exec, Element *el, int engine_number, struct FGEngine::Inputs& input)
- : FGEngine(exec, engine_number, input)
+ : FGEngine(engine_number, input)
{
- string token;
-
Load(exec,el);
Type = etElectric;
@@ -71,10 +69,9 @@ FGElectric::FGElectric(FGFDMExec* exec, Element *el, int engine_number, struct F
if (el->FindElement("power"))
PowerWatts = el->FindElementValueAsNumberConvertTo("power","WATTS");
- string property_name, base_property_name;
- base_property_name = CreateIndexedPropertyName("propulsion/engine", EngineNumber);
- property_name = base_property_name + "/power-hp";
- PropertyManager->Tie(property_name, &HP);
+ string base_property_name = CreateIndexedPropertyName("propulsion/engine",
+ EngineNumber);
+ exec->GetPropertyManager()->Tie(base_property_name + "/power-hp", &HP);
Debug(0); // Call Debug() routine from constructor if needed
}
diff --git a/src/FDM/JSBSim/models/propulsion/FGEngine.cpp b/src/FDM/JSBSim/models/propulsion/FGEngine.cpp
index b3257d148..61834f2ad 100644
--- a/src/FDM/JSBSim/models/propulsion/FGEngine.cpp
+++ b/src/FDM/JSBSim/models/propulsion/FGEngine.cpp
@@ -53,17 +53,16 @@ using namespace std;
namespace JSBSim {
-IDENT(IdSrc,"$Id: FGEngine.cpp,v 1.62 2015/02/27 20:42:55 bcoconni Exp $");
+IDENT(IdSrc,"$Id: FGEngine.cpp,v 1.67 2015/09/27 09:54:21 bcoconni Exp $");
IDENT(IdHdr,ID_ENGINE);
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CLASS IMPLEMENTATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-FGEngine::FGEngine(FGFDMExec* exec, int engine_number, struct Inputs& input)
+FGEngine::FGEngine(int engine_number, struct Inputs& input)
: in(input), EngineNumber(engine_number)
{
- Name = "";
Type = etUnknown;
X = Y = Z = 0.0;
EnginePitch = EngineYaw = 0.0;
@@ -172,27 +171,25 @@ void FGEngine::LoadThrusterInputs()
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-void FGEngine::LoadThruster(Element *thruster_element)
+void FGEngine::LoadThruster(FGFDMExec* exec, Element *thruster_element)
{
if (thruster_element->FindElement("propeller")) {
Element *document = thruster_element->FindElement("propeller");
- Thruster = new FGPropeller(FDMExec, document, EngineNumber);
+ Thruster = new FGPropeller(exec, document, EngineNumber);
} else if (thruster_element->FindElement("nozzle")) {
Element *document = thruster_element->FindElement("nozzle");
- Thruster = new FGNozzle(FDMExec, document, EngineNumber);
+ Thruster = new FGNozzle(exec, document, EngineNumber);
} else if (thruster_element->FindElement("rotor")) {
Element *document = thruster_element->FindElement("rotor");
- Thruster = new FGRotor(FDMExec, document, EngineNumber);
+ Thruster = new FGRotor(exec, document, EngineNumber);
} else if (thruster_element->FindElement("direct")) {
Element *document = thruster_element->FindElement("direct");
- Thruster = new FGThruster( FDMExec, document, EngineNumber);
+ Thruster = new FGThruster(exec, document, EngineNumber);
} else {
cerr << thruster_element->ReadFrom() << " Unknown thruster type" << endl;
throw("Failed to load the thruster");
}
- Thruster->SetdeltaT(in.TotalDeltaT);
-
Debug(2);
}
@@ -204,9 +201,7 @@ bool FGEngine::Load(FGFDMExec *exec, Element *engine_element)
Element* local_element;
FGColumnVector3 location, orientation;
- FDMExec = exec;
-
- PropertyManager = FDMExec->GetPropertyManager();
+ FGPropertyManager* PropertyManager = exec->GetPropertyManager();
Name = engine_element->GetAttributeValue("name");
@@ -230,8 +225,8 @@ bool FGEngine::Load(FGFDMExec *exec, Element *engine_element)
local_element = parent_element->FindElement("thruster");
if (local_element) {
try {
- LoadThruster(local_element);
- } catch (std::string str) {
+ LoadThruster(exec, local_element);
+ } catch (std::string& str) {
throw("Error loading engine " + Name + ". " + str);
}
} else {
diff --git a/src/FDM/JSBSim/models/propulsion/FGEngine.h b/src/FDM/JSBSim/models/propulsion/FGEngine.h
index 472798a25..511f322b3 100644
--- a/src/FDM/JSBSim/models/propulsion/FGEngine.h
+++ b/src/FDM/JSBSim/models/propulsion/FGEngine.h
@@ -53,7 +53,7 @@ INCLUDES
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_ENGINE "$Id: FGEngine.h,v 1.44 2015/03/28 14:49:02 bcoconni Exp $"
+#define ID_ENGINE "$Id: FGEngine.h,v 1.47 2015/09/27 10:16:57 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
@@ -111,7 +111,7 @@ CLASS DOCUMENTATION
documentation for engine and thruster classes.
@author Jon S. Berndt
- @version $Id: FGEngine.h,v 1.44 2015/03/28 14:49:02 bcoconni Exp $
+ @version $Id: FGEngine.h,v 1.47 2015/09/27 10:16:57 bcoconni Exp $
*/
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -122,7 +122,6 @@ class FGEngine : public FGModelFunctions
{
public:
struct Inputs {
- double SLPressure;
double Pressure;
double PressureRatio;
double Temperature;
@@ -130,7 +129,6 @@ public:
double DensityRatio;
double Soundspeed;
double TotalPressure;
- double TotalTempearture;
double TAT_c;
double Vt;
double Vc;
@@ -150,7 +148,7 @@ public:
double TotalDeltaT;
};
- FGEngine(FGFDMExec* exec, int engine_number, struct Inputs& input);
+ FGEngine(int engine_number, struct Inputs& input);
virtual ~FGEngine();
enum EngineType {etUnknown, etRocket, etPiston, etTurbine, etTurboprop, etElectric};
@@ -208,7 +206,7 @@ public:
virtual const FGColumnVector3& GetBodyForces(void);
virtual const FGColumnVector3& GetMoments(void);
- void LoadThruster(Element *el);
+ void LoadThruster(FGFDMExec* exec, Element *el);
FGThruster* GetThruster(void) const {return Thruster;}
unsigned int GetSourceTank(unsigned int i) const;
@@ -221,14 +219,7 @@ public:
void LoadThrusterInputs();
protected:
- /** Reduces the fuel in the active tanks by the amount required.
- This function should be called from within the
- derived class' Calculate() function before any other calculations are
- done. This base class method removes fuel from the fuel tanks as
- appropriate, and sets the starved flag if necessary. * /
- virtual void ConsumeFuel(void); */
-
- FGPropertyManager* PropertyManager;
+
std::string Name;
const int EngineNumber;
EngineType Type;
@@ -253,8 +244,7 @@ protected:
double FuelUsedLbs;
double FuelDensity;
- FGFDMExec* FDMExec;
- FGThruster* Thruster;
+ FGThruster* Thruster;
std::vector SourceTanks;
diff --git a/src/FDM/JSBSim/models/propulsion/FGPiston.cpp b/src/FDM/JSBSim/models/propulsion/FGPiston.cpp
index f6de73419..5880881e7 100644
--- a/src/FDM/JSBSim/models/propulsion/FGPiston.cpp
+++ b/src/FDM/JSBSim/models/propulsion/FGPiston.cpp
@@ -51,7 +51,7 @@ using namespace std;
namespace JSBSim {
-IDENT(IdSrc,"$Id: FGPiston.cpp,v 1.79 2015/02/27 20:36:47 bcoconni Exp $");
+IDENT(IdSrc,"$Id: FGPiston.cpp,v 1.81 2015/09/27 09:54:21 bcoconni Exp $");
IDENT(IdHdr,ID_PISTON);
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -59,7 +59,7 @@ CLASS IMPLEMENTATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
FGPiston::FGPiston(FGFDMExec* exec, Element* el, int engine_number, struct Inputs& input)
- : FGEngine(exec, engine_number, input),
+ : FGEngine(engine_number, input),
R_air(287.3), // Gas constant for air J/Kg/K
calorific_value_fuel(47.3e6), // J/Kg
Cp_air(1005), // Specific heat (constant pressure) J/Kg/K
@@ -69,8 +69,7 @@ FGPiston::FGPiston(FGFDMExec* exec, Element* el, int engine_number, struct Input
Load(exec, el);
Element *table_element;
- string token;
- string name="";
+ FGPropertyManager* PropertyManager = exec->GetPropertyManager();
// Defaults and initializations
@@ -236,7 +235,7 @@ FGPiston::FGPiston(FGFDMExec* exec, Element* el, int engine_number, struct Input
}
while((table_element = el->FindNextElement("table")) != 0) {
- name = table_element->GetAttributeValue("name");
+ string name = table_element->GetAttributeValue("name");
try {
if (name == "COMBUSTION") {
Lookup_Combustion_Efficiency = new FGTable(PropertyManager, table_element);
@@ -245,7 +244,7 @@ FGPiston::FGPiston(FGFDMExec* exec, Element* el, int engine_number, struct Input
} else {
cerr << "Unknown table type: " << name << " in piston engine definition." << endl;
}
- } catch (std::string str) {
+ } catch (std::string& str) {
// Make sure allocated resources are freed before rethrowing.
// (C++ standard guarantees that a null pointer deletion is no-op).
delete Lookup_Combustion_Efficiency;
diff --git a/src/FDM/JSBSim/models/propulsion/FGPropeller.cpp b/src/FDM/JSBSim/models/propulsion/FGPropeller.cpp
index 6b36d5dec..510d67f0f 100644
--- a/src/FDM/JSBSim/models/propulsion/FGPropeller.cpp
+++ b/src/FDM/JSBSim/models/propulsion/FGPropeller.cpp
@@ -45,7 +45,7 @@ using namespace std;
namespace JSBSim {
-IDENT(IdSrc,"$Id: FGPropeller.cpp,v 1.51 2015/04/20 12:12:49 ehofman Exp $");
+IDENT(IdSrc,"$Id: FGPropeller.cpp,v 1.54 2015/09/27 09:29:41 bcoconni Exp $");
IDENT(IdHdr,ID_PROPELLER);
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -60,7 +60,6 @@ CLASS IMPLEMENTATION
FGPropeller::FGPropeller(FGFDMExec* exec, Element* prop_element, int num)
: FGThruster(exec, prop_element, num)
{
- string token;
Element *table_element, *local_element;
string name="";
FGPropertyManager* PropertyManager = exec->GetPropertyManager();
@@ -78,7 +77,7 @@ FGPropeller::FGPropeller(FGFDMExec* exec, Element* prop_element, int num)
Vinduced = 0.0;
if (prop_element->FindElement("ixx"))
- Ixx = prop_element->FindElementValueAsNumberConvertTo("ixx", "SLUG*FT2");
+ Ixx = max(prop_element->FindElementValueAsNumberConvertTo("ixx", "SLUG*FT2"), 0.001);
Sense_multiplier = 1.0;
if (prop_element->HasAttribute("version"))
@@ -86,11 +85,11 @@ FGPropeller::FGPropeller(FGFDMExec* exec, Element* prop_element, int num)
Sense_multiplier = -1.0;
if (prop_element->FindElement("diameter"))
- Diameter = prop_element->FindElementValueAsNumberConvertTo("diameter", "FT");
+ Diameter = max(prop_element->FindElementValueAsNumberConvertTo("diameter", "FT"), 0.001);
if (prop_element->FindElement("numblades"))
numBlades = (int)prop_element->FindElementValueAsNumber("numblades");
if (prop_element->FindElement("gearratio"))
- GearRatio = prop_element->FindElementValueAsNumber("gearratio");
+ GearRatio = max(prop_element->FindElementValueAsNumber("gearratio"), 0.001);
if (prop_element->FindElement("minpitch"))
MinPitch = prop_element->FindElementValueAsNumber("minpitch");
if (prop_element->FindElement("maxpitch"))
@@ -119,7 +118,7 @@ FGPropeller::FGPropeller(FGFDMExec* exec, Element* prop_element, int num)
} else {
cerr << "Unknown table type: " << name << " in propeller definition." << endl;
}
- } catch (std::string str) {
+ } catch (std::string& str) {
throw("Error loading propeller table:" + name + ". " + str);
}
}
@@ -203,7 +202,7 @@ double FGPropeller::Calculate(double EnginePower)
FGColumnVector3 localAeroVel = Transform().Transposed() * in.AeroUVW;
double omega, PowerAvailable;
- double Vel = localAeroVel(eU);
+ double Vel = localAeroVel(eU) + Vinduced;
double rho = in.Density;
double RPS = RPM/60.0;
@@ -286,7 +285,7 @@ double FGPropeller::Calculate(double EnginePower)
if (omega > 0.0) ExcessTorque = PowerAvailable / omega;
else ExcessTorque = PowerAvailable / 1.0;
- RPM = (RPS + ((ExcessTorque / Ixx) / (2.0 * M_PI)) * deltaT) * 60.0;
+ RPM = (RPS + ((ExcessTorque / Ixx) / (2.0 * M_PI)) * in.TotalDeltaT) * 60.0;
if (RPM < 0.0) RPM = 0.0; // Engine won't turn backwards
@@ -303,7 +302,7 @@ double FGPropeller::GetPowerRequired(void)
{
double cPReq, J;
double rho = in.Density;
- double Vel = in.AeroUVW(eU);
+ double Vel = in.AeroUVW(eU) + Vinduced;
double RPS = RPM / 60.0;
if (RPS != 0.0) J = Vel / (Diameter * RPS);
@@ -327,7 +326,7 @@ double FGPropeller::GetPowerRequired(void)
double dRPM = rpmReq - RPM;
// The pitch of a variable propeller cannot be changed when the RPMs are
// too low - the oil pump does not work.
- if (RPM > 200) Pitch -= dRPM * deltaT;
+ if (RPM > 200) Pitch -= dRPM * in.TotalDeltaT;
if (Pitch < MinPitch) Pitch = MinPitch;
else if (Pitch > MaxPitch) Pitch = MaxPitch;
diff --git a/src/FDM/JSBSim/models/propulsion/FGRocket.cpp b/src/FDM/JSBSim/models/propulsion/FGRocket.cpp
index 220d1bbd4..69f72d776 100644
--- a/src/FDM/JSBSim/models/propulsion/FGRocket.cpp
+++ b/src/FDM/JSBSim/models/propulsion/FGRocket.cpp
@@ -49,7 +49,7 @@ using namespace std;
namespace JSBSim {
-IDENT(IdSrc,"$Id: FGRocket.cpp,v 1.37 2014/06/08 12:00:35 bcoconni Exp $");
+IDENT(IdSrc,"$Id: FGRocket.cpp,v 1.39 2015/09/27 09:54:21 bcoconni Exp $");
IDENT(IdHdr,ID_ROCKET);
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -57,7 +57,7 @@ CLASS IMPLEMENTATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
FGRocket::FGRocket(FGFDMExec* exec, Element *el, int engine_number, struct Inputs& input)
- : FGEngine(exec, engine_number, input), isp_function(0L)
+ : FGEngine(engine_number, input), isp_function(0L), FDMExec(exec)
{
Load(exec, el);
@@ -84,19 +84,17 @@ FGRocket::FGRocket(FGFDMExec* exec, Element *el, int engine_number, struct Input
MinThrottle = 0.0;
MaxThrottle = 1.0;
- string base_property_name = CreateIndexedPropertyName("propulsion/engine", EngineNumber);
-
std::stringstream strEngineNumber;
strEngineNumber << EngineNumber;
- Element* isp_el = el->FindElement("isp");
- Element* isp_func_el=0;
+ FGPropertyManager* PropertyManager = exec->GetPropertyManager();
+ bindmodel(PropertyManager); // Bind model properties first, since they might be needed in functions.
- bindmodel(); // Bind model properties first, since they might be needed in functions.
+ Element* isp_el = el->FindElement("isp");
// Specific impulse may be specified as a constant value or as a function - perhaps as a function of mixture ratio.
if (isp_el) {
- isp_func_el = isp_el->FindElement("function");
+ Element* isp_func_el = isp_el->FindElement("function");
if (isp_func_el) {
isp_function = new FGFunction(exec->GetPropertyManager(),isp_func_el, strEngineNumber.str());
} else {
@@ -286,7 +284,7 @@ string FGRocket::GetEngineValues(const string& delimiter)
// This function should tie properties to rocket engine specific properties
// that are not bound in the base class (FGEngine) code.
//
-void FGRocket::bindmodel()
+void FGRocket::bindmodel(FGPropertyManager* PropertyManager)
{
string property_name, base_property_name;
base_property_name = CreateIndexedPropertyName("propulsion/engine", EngineNumber);
diff --git a/src/FDM/JSBSim/models/propulsion/FGRocket.h b/src/FDM/JSBSim/models/propulsion/FGRocket.h
index b93f15193..d258c660a 100644
--- a/src/FDM/JSBSim/models/propulsion/FGRocket.h
+++ b/src/FDM/JSBSim/models/propulsion/FGRocket.h
@@ -46,7 +46,7 @@ INCLUDES
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_ROCKET "$Id: FGRocket.h,v 1.20 2013/11/24 11:40:57 bcoconni Exp $"
+#define ID_ROCKET "$Id: FGRocket.h,v 1.22 2015/09/27 09:54:21 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
@@ -118,7 +118,7 @@ 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: FGRocket.h,v 1.20 2013/11/24 11:40:57 bcoconni Exp $
+ $Id: FGRocket.h,v 1.22 2015/09/27 09:54:21 bcoconni Exp $
@see FGNozzle,
FGThruster,
FGForce,
@@ -214,7 +214,7 @@ private:
@return The vacuum thrust in lbs. */
double GetVacThrust(void) const {return VacThrust;}
- void bindmodel(void);
+ void bindmodel(FGPropertyManager* pm);
double Isp; // Vacuum Isp
double It; // Total actual Isp
@@ -236,6 +236,7 @@ private:
double BuildupTime;
FGTable* ThrustTable;
FGFunction* isp_function;
+ FGFDMExec* FDMExec;
void Debug(int from);
};
diff --git a/src/FDM/JSBSim/models/propulsion/FGRotor.cpp b/src/FDM/JSBSim/models/propulsion/FGRotor.cpp
index 2c6141330..29eae1770 100644
--- a/src/FDM/JSBSim/models/propulsion/FGRotor.cpp
+++ b/src/FDM/JSBSim/models/propulsion/FGRotor.cpp
@@ -43,6 +43,7 @@ HISTORY
INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+#include
#include
#include "FGRotor.h"
@@ -53,11 +54,12 @@ INCLUDES
using std::cerr;
using std::cout;
using std::endl;
+using std::string;
using std::ostringstream;
namespace JSBSim {
-IDENT(IdSrc,"$Id: FGRotor.cpp,v 1.23 2014/01/13 10:46:10 ehofman Exp $");
+IDENT(IdSrc,"$Id: FGRotor.cpp,v 1.24 2015/09/27 10:03:53 bcoconni Exp $");
IDENT(IdHdr,ID_ROTOR);
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -101,7 +103,6 @@ FGRotor::FGRotor(FGFDMExec *exec, Element* rotor_element, int num)
// initialise/set remaining variables
SetTransformType(FGForce::tCustom);
- PropertyManager = exec->GetPropertyManager();
Type = ttRotor;
GearRatio = 1.0;
@@ -211,7 +212,7 @@ FGRotor::FGRotor(FGFDMExec *exec, Element* rotor_element, int num)
damp_hagl = Filter(1.0, dt);
// enable import-export
- BindModel();
+ bindmodel(exec->GetPropertyManager());
Debug(0);
@@ -693,7 +694,7 @@ double FGRotor::Calculate(double EnginePower)
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-bool FGRotor::BindModel(void)
+bool FGRotor::bindmodel(FGPropertyManager* PropertyManager)
{
string property_name, base_property_name;
base_property_name = CreateIndexedPropertyName("propulsion/engine", EngineNum);
diff --git a/src/FDM/JSBSim/models/propulsion/FGRotor.h b/src/FDM/JSBSim/models/propulsion/FGRotor.h
index 50c9072ff..fc2cf107d 100644
--- a/src/FDM/JSBSim/models/propulsion/FGRotor.h
+++ b/src/FDM/JSBSim/models/propulsion/FGRotor.h
@@ -48,7 +48,7 @@ INCLUDES
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_ROTOR "$Id: FGRotor.h,v 1.15 2013/01/26 17:06:50 bcoconni Exp $"
+#define ID_ROTOR "$Id: FGRotor.h,v 1.17 2015/09/27 10:03:53 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
@@ -230,7 +230,7 @@ CLASS DOCUMENTATION
@author Thomas Kreitler
- @version $Id: FGRotor.h,v 1.15 2013/01/26 17:06:50 bcoconni Exp $
+ @version $Id: FGRotor.h,v 1.17 2015/09/27 10:03:53 bcoconni Exp $
*/
@@ -350,7 +350,7 @@ private:
FGColumnVector3 body_moments(double a_ic = 0.0 , double b_ic = 0.0 );
// interface
- bool BindModel(void);
+ bool bindmodel(FGPropertyManager* pm);
void Debug(int from);
// environment
diff --git a/src/FDM/JSBSim/models/propulsion/FGThruster.cpp b/src/FDM/JSBSim/models/propulsion/FGThruster.cpp
index 516f1b4e0..b01cd6eec 100644
--- a/src/FDM/JSBSim/models/propulsion/FGThruster.cpp
+++ b/src/FDM/JSBSim/models/propulsion/FGThruster.cpp
@@ -45,7 +45,7 @@ using namespace std;
namespace JSBSim {
-IDENT(IdSrc,"$Id: FGThruster.cpp,v 1.21 2014/01/13 10:46:10 ehofman Exp $");
+IDENT(IdSrc,"$Id: FGThruster.cpp,v 1.22 2015/09/27 10:03:53 bcoconni Exp $");
IDENT(IdHdr,ID_THRUSTER);
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -66,7 +66,7 @@ FGThruster::FGThruster(FGFDMExec *FDMExec, Element *el, int num ): FGForce(FDMEx
GearRatio = 1.0;
EngineNum = num;
- PropertyManager = FDMExec->GetPropertyManager();
+ FGPropertyManager* PropertyManager = FDMExec->GetPropertyManager();
// Determine the initial location and orientation of this thruster and load the
// thruster with this information.
diff --git a/src/FDM/JSBSim/models/propulsion/FGThruster.h b/src/FDM/JSBSim/models/propulsion/FGThruster.h
index 0ac1dafe6..27a157fd5 100644
--- a/src/FDM/JSBSim/models/propulsion/FGThruster.h
+++ b/src/FDM/JSBSim/models/propulsion/FGThruster.h
@@ -46,7 +46,7 @@ INCLUDES
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_THRUSTER "$Id: FGThruster.h,v 1.22 2013/12/22 17:14:37 bcoconni Exp $"
+#define ID_THRUSTER "$Id: FGThruster.h,v 1.26 2015/09/27 10:03:53 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
@@ -74,7 +74,7 @@ CLASS DOCUMENTATION
1.57 (pi/2) results in no thrust at all.
@author Jon Berndt
- @version $Id: FGThruster.h,v 1.22 2013/12/22 17:14:37 bcoconni Exp $
+ @version $Id: FGThruster.h,v 1.26 2015/09/27 10:03:53 bcoconni Exp $
*/
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -100,7 +100,6 @@ public:
virtual void SetRPM(double rpm) {};
virtual void SetEngineRPM(double rpm) {};
virtual double GetPowerRequired(void) {return 0.0;}
- virtual void SetdeltaT(double dt) {deltaT = dt;}
double GetThrust(void) const {return Thrust;}
eType GetType(void) {return Type;}
std::string GetName(void) {return Name;}
@@ -133,12 +132,10 @@ protected:
std::string Name;
double Thrust;
double PowerRequired;
- double deltaT;
double GearRatio;
double ThrustCoeff;
double ReverserAngle;
int EngineNum;
- FGPropertyManager* PropertyManager;
virtual void Debug(int from);
};
}
diff --git a/src/FDM/JSBSim/models/propulsion/FGTurbine.cpp b/src/FDM/JSBSim/models/propulsion/FGTurbine.cpp
index 2fce543aa..0b3171b07 100644
--- a/src/FDM/JSBSim/models/propulsion/FGTurbine.cpp
+++ b/src/FDM/JSBSim/models/propulsion/FGTurbine.cpp
@@ -51,7 +51,7 @@ using namespace std;
namespace JSBSim {
-IDENT(IdSrc,"$Id: FGTurbine.cpp,v 1.44 2014/12/12 01:21:17 dpculp Exp $");
+IDENT(IdSrc,"$Id: FGTurbine.cpp,v 1.47 2015/09/27 10:07:53 bcoconni Exp $");
IDENT(IdHdr,ID_TURBINE);
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -60,7 +60,7 @@ CLASS IMPLEMENTATION
FGTurbine::FGTurbine(FGFDMExec* exec, Element *el, int engine_number, struct Inputs& input)
- : FGEngine(exec, engine_number, input)
+ : FGEngine(engine_number, input), FDMExec(exec)
{
Type = etTurbine;
@@ -104,9 +104,8 @@ void FGTurbine::ResetToIC(void)
Stalled = Seized = Overtemp = Fire = Augmentation = Injection = Reversed = false;
Cutoff = true;
phase = tpOff;
- TAT = (in.TotalTempearture - 491.69) * 0.5555556;
- EGT_degC = TAT;
- OilTemp_degK = TAT + 273.0;
+ EGT_degC = in.TAT_c;
+ OilTemp_degK = in.TAT_c + 273.0;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -121,7 +120,6 @@ void FGTurbine::Calculate(void)
ThrottlePos = in.ThrottlePos[EngineNumber];
- TAT = (in.TotalTempearture - 491.69) * 0.5555556;
if (ThrottlePos > 1.0) {
AugmentCmd = ThrottlePos - 1.0;
ThrottlePos -= AugmentCmd;
@@ -142,7 +140,7 @@ void FGTurbine::Calculate(void)
} else {
phase = tpOff;
Cutoff = true;
- EGT_degC = TAT;
+ EGT_degC = in.TAT_c;
}
}
@@ -185,8 +183,8 @@ double FGTurbine::Off(void)
FuelFlow_pph = Seek(&FuelFlow_pph, 0, 1000.0, 10000.0);
N1 = Seek(&N1, in.qbar/10.0, N1/2.0, N1/2.0);
N2 = Seek(&N2, in.qbar/15.0, N2/2.0, N2/2.0);
- EGT_degC = Seek(&EGT_degC, TAT, 11.7, 7.3);
- OilTemp_degK = Seek(&OilTemp_degK, TAT + 273.0, 0.2, 0.2);
+ EGT_degC = Seek(&EGT_degC, in.TAT_c, 11.7, 7.3);
+ OilTemp_degK = Seek(&OilTemp_degK, in.TAT_c + 273.0, 0.2, 0.2);
OilPressure_psi = N2 * 0.62;
NozzlePosition = Seek(&NozzlePosition, 1.0, 0.8, 0.8);
EPR = Seek(&EPR, 1.0, 0.2, 0.2);
@@ -223,7 +221,7 @@ double FGTurbine::Run()
N1 = Seek(&N1, IdleN1 + ThrottlePos * N1_factor, spoolup, spoolup * 2.4);
N2norm = (N2 - IdleN2) / N2_factor;
thrust = idlethrust + (milthrust * N2norm * N2norm);
- EGT_degC = TAT + 363.1 + ThrottlePos * 357.1;
+ EGT_degC = in.TAT_c + 363.1 + ThrottlePos * 357.1;
OilPressure_psi = N2 * 0.62;
OilTemp_degK = Seek(&OilTemp_degK, 366.0, 1.2, 0.1);
@@ -284,9 +282,9 @@ double FGTurbine::SpinUp(void)
FuelFlow_pph = 0.0;
N2 = Seek(&N2, 25.18, N2_spinup, N2/2.0);
N1 = Seek(&N1, 5.21, N1_spinup, N1/2.0);
- EGT_degC = Seek(&EGT_degC, TAT, 11.7, 7.3);
+ EGT_degC = Seek(&EGT_degC, in.TAT_c, 11.7, 7.3);
OilPressure_psi = N2 * 0.62;
- OilTemp_degK = Seek(&OilTemp_degK, TAT + 273.0, 0.2, 0.2);
+ OilTemp_degK = Seek(&OilTemp_degK, in.TAT_c + 273.0, 0.2, 0.2);
EPR = 1.0;
NozzlePosition = 1.0;
if (Starter == false) phase = tpOff;
@@ -302,7 +300,7 @@ double FGTurbine::Start(void)
if (N2 < IdleN2) {
N2 = Seek(&N2, IdleN2, 2.0, N2/2.0);
N1 = Seek(&N1, IdleN1, 1.4, N1/2.0);
- EGT_degC = Seek(&EGT_degC, TAT + 363.1, 21.3, 7.3);
+ EGT_degC = Seek(&EGT_degC, in.TAT_c + 363.1, 21.3, 7.3);
FuelFlow_pph = IdleFF * N2 / IdleN2;
OilPressure_psi = N2 * 0.62;
if ((Starter == false) && (in.qbar < 30.0)) phase = tpOff; // aborted start
@@ -326,7 +324,7 @@ double FGTurbine::Start(void)
double FGTurbine::Stall(void)
{
- EGT_degC = TAT + 903.14;
+ EGT_degC = in.TAT_c + 903.14;
FuelFlow_pph = IdleFF;
N1 = Seek(&N1, in.qbar/10.0, 0, N1/10.0);
N2 = Seek(&N2, in.qbar/15.0, 0, N2/10.0);
@@ -345,7 +343,7 @@ double FGTurbine::Seize(void)
N1 = Seek(&N1, in.qbar/20.0, 0, N1/15.0);
FuelFlow_pph = Cutoff ? 0.0 : IdleFF;
OilPressure_psi = 0.0;
- OilTemp_degK = Seek(&OilTemp_degK, TAT + 273.0, 0, 0.2);
+ OilTemp_degK = Seek(&OilTemp_degK, in.TAT_c + 273.0, 0, 0.2);
Running = false;
return 0.0;
}
@@ -354,12 +352,11 @@ double FGTurbine::Seize(void)
double FGTurbine::Trim()
{
- double idlethrust, milthrust, thrust, tdiff, N2, N2norm;
- idlethrust = MilThrust * IdleThrustLookup->GetValue();
- milthrust = (MilThrust - idlethrust) * MilThrustLookup->GetValue();
- N2 = IdleN2 + ThrottlePos * N2_factor;
- N2norm = (N2 - IdleN2) / N2_factor;
- thrust = (idlethrust + (milthrust * N2norm * N2norm))
+ double idlethrust = MilThrust * IdleThrustLookup->GetValue();
+ double milthrust = (MilThrust - idlethrust) * MilThrustLookup->GetValue();
+ double N2 = IdleN2 + ThrottlePos * N2_factor;
+ double N2norm = (N2 - IdleN2) / N2_factor;
+ double thrust = (idlethrust + (milthrust * N2norm * N2norm))
* (1.0 - BleedDemand);
if (AugMethod == 1) {
@@ -373,7 +370,7 @@ double FGTurbine::Trim()
if (AugMethod == 2) {
if (AugmentCmd > 0.0) {
- tdiff = (MaxThrust * MaxThrustLookup->GetValue()) - thrust;
+ double tdiff = (MaxThrust * MaxThrustLookup->GetValue()) - thrust;
thrust += (tdiff * AugmentCmd);
}
}
@@ -487,10 +484,10 @@ bool FGTurbine::Load(FGFDMExec* exec, Element *el)
delay = 90.0 / (BypassRatio + 3.0);
N1_factor = MaxN1 - IdleN1;
N2_factor = MaxN2 - IdleN2;
- OilTemp_degK = (in.TotalTempearture - 491.69) * 0.5555556 + 273.0;
+ OilTemp_degK = in.TAT_c + 273.0;
IdleFF = pow(MilThrust, 0.2) * 107.0; // just an estimate
- bindmodel();
+ bindmodel(exec->GetPropertyManager());
return true;
}
@@ -522,7 +519,7 @@ string FGTurbine::GetEngineValues(const string& delimiter)
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-void FGTurbine::bindmodel()
+void FGTurbine::bindmodel(FGPropertyManager* PropertyManager)
{
string property_name, base_property_name;
base_property_name = CreateIndexedPropertyName("propulsion/engine", EngineNumber);
diff --git a/src/FDM/JSBSim/models/propulsion/FGTurbine.h b/src/FDM/JSBSim/models/propulsion/FGTurbine.h
index d7f03434e..1aab10dee 100644
--- a/src/FDM/JSBSim/models/propulsion/FGTurbine.h
+++ b/src/FDM/JSBSim/models/propulsion/FGTurbine.h
@@ -42,7 +42,7 @@ INCLUDES
#include "FGEngine.h"
-#define ID_TURBINE "$Id: FGTurbine.h,v 1.23 2014/12/12 01:21:17 dpculp Exp $"
+#define ID_TURBINE "$Id: FGTurbine.h,v 1.26 2015/09/27 10:07:53 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
@@ -152,7 +152,7 @@ CLASS DOCUMENTATION
/engine/direct.xml
@author David P. Culp
- @version "$Id: FGTurbine.h,v 1.23 2014/12/12 01:21:17 dpculp Exp $"
+ @version "$Id: FGTurbine.h,v 1.26 2015/09/27 10:07:53 bcoconni Exp $"
*/
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -252,7 +252,6 @@ private:
double N2_factor; ///< factor to tie N2 and throttle
double ThrottlePos; ///< FCS-supplied throttle position - modified for local use!
double AugmentCmd; ///< modulated afterburner command (0.0 to 1.0)
- double TAT; ///< total air temperature (deg C)
double N1_spinup; ///< N1 spin up rate from starter (per second)
double N2_spinup; ///< N2 spin up rate from starter (per second)
bool Stalled; ///< true if engine is compressor-stalled
@@ -295,9 +294,10 @@ private:
FGFunction *MilThrustLookup;
FGFunction *MaxThrustLookup;
FGFunction *InjectionLookup;
+ FGFDMExec* FDMExec;
bool Load(FGFDMExec *exec, Element *el);
- void bindmodel(void);
+ void bindmodel(FGPropertyManager* pm);
void Debug(int from);
};
diff --git a/src/FDM/JSBSim/models/propulsion/FGTurboProp.cpp b/src/FDM/JSBSim/models/propulsion/FGTurboProp.cpp
old mode 100644
new mode 100755
index 8216a5ca7..10e0a9475
--- a/src/FDM/JSBSim/models/propulsion/FGTurboProp.cpp
+++ b/src/FDM/JSBSim/models/propulsion/FGTurboProp.cpp
@@ -54,7 +54,7 @@ using namespace std;
namespace JSBSim {
-IDENT(IdSrc,"$Id: FGTurboProp.cpp,v 1.30 2014/06/08 12:00:35 bcoconni Exp $");
+IDENT(IdSrc,"$Id: FGTurboProp.cpp,v 1.32 2015/09/27 09:54:21 bcoconni Exp $");
IDENT(IdHdr,ID_TURBOPROP);
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -62,15 +62,16 @@ CLASS IMPLEMENTATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
FGTurboProp::FGTurboProp(FGFDMExec* exec, Element *el, int engine_number, struct Inputs& input)
- : FGEngine(exec, engine_number, input),
- ITT_N1(NULL), EnginePowerRPM_N1(NULL), EnginePowerVC(NULL), CombustionEfficiency_N1(NULL)
+ : FGEngine(engine_number, input),
+ ITT_N1(NULL), EnginePowerRPM_N1(NULL), EnginePowerVC(NULL), CombustionEfficiency_N1(NULL),
+ FDMExec(exec)
{
FGEngine::Load(exec, el);
SetDefaults();
thrusterType = Thruster->GetType();
Load(exec, el);
- bindmodel();
+ bindmodel(exec->GetPropertyManager());
Debug(0);
}
@@ -541,7 +542,7 @@ int FGTurboProp::InitRunning(void)
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-void FGTurboProp::bindmodel()
+void FGTurboProp::bindmodel(FGPropertyManager* PropertyManager)
{
string property_name, base_property_name;
base_property_name = CreateIndexedPropertyName("propulsion/engine", EngineNumber);
diff --git a/src/FDM/JSBSim/models/propulsion/FGTurboProp.h b/src/FDM/JSBSim/models/propulsion/FGTurboProp.h
old mode 100644
new mode 100755
index b41a35fd7..97b69c1a5
--- a/src/FDM/JSBSim/models/propulsion/FGTurboProp.h
+++ b/src/FDM/JSBSim/models/propulsion/FGTurboProp.h
@@ -46,7 +46,7 @@ INCLUDES
#include "FGEngine.h"
#include "math/FGTable.h"
-#define ID_TURBOPROP "$Id: FGTurboProp.h,v 1.19 2015/02/27 20:36:48 bcoconni Exp $"
+#define ID_TURBOPROP "$Id: FGTurboProp.h,v 1.21 2015/09/27 09:54:21 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
@@ -215,13 +215,14 @@ private:
void SetDefaults(void);
bool Load(FGFDMExec *exec, Element *el);
- void bindmodel(void);
+ void bindmodel(FGPropertyManager* pm);
void Debug(int from);
FGTable* ITT_N1; // ITT temperature depending on throttle command
FGTable* EnginePowerRPM_N1;
FGTable* EnginePowerVC;
FGTable* CombustionEfficiency_N1;
+ FGFDMExec* FDMExec;
};
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%