1
0
Fork 0

Synchronized with JSBSim/CVS

This commit is contained in:
bcoconni 2013-11-24 20:12:17 +01:00
parent d3f6ab38c2
commit 69baf3a9d6
84 changed files with 1169 additions and 473 deletions

View file

@ -79,6 +79,7 @@ set(HEADERS
models/flight_control/FGSummer.h models/flight_control/FGSummer.h
models/flight_control/FGSwitch.h models/flight_control/FGSwitch.h
models/flight_control/FGWaypoint.h models/flight_control/FGWaypoint.h
models/flight_control/FGDistributor.h
models/propulsion/FGElectric.h models/propulsion/FGElectric.h
models/propulsion/FGEngine.h models/propulsion/FGEngine.h
models/propulsion/FGForce.h models/propulsion/FGForce.h
@ -168,6 +169,7 @@ set(SOURCES
models/flight_control/FGSummer.cpp models/flight_control/FGSummer.cpp
models/flight_control/FGSwitch.cpp models/flight_control/FGSwitch.cpp
models/flight_control/FGWaypoint.cpp models/flight_control/FGWaypoint.cpp
models/flight_control/FGDistributor.cpp
models/propulsion/FGElectric.cpp models/propulsion/FGElectric.cpp
models/propulsion/FGEngine.cpp models/propulsion/FGEngine.cpp
models/propulsion/FGForce.cpp models/propulsion/FGForce.cpp

View file

@ -68,12 +68,14 @@ INCLUDES
#include "initialization/FGLinearization.h" #include "initialization/FGLinearization.h"
#include "input_output/FGPropertyManager.h" #include "input_output/FGPropertyManager.h"
#include "input_output/FGScript.h" #include "input_output/FGScript.h"
#include "input_output/FGXMLFileRead.h"
#include "input_output/FGXMLElement.h"
using namespace std; using namespace std;
namespace JSBSim { namespace JSBSim {
static const char *IdSrc = "$Id: FGFDMExec.cpp,v 1.148 2013/06/10 01:46:27 jberndt Exp $"; static const char *IdSrc = "$Id: FGFDMExec.cpp,v 1.150 2013/11/24 11:40:55 bcoconni Exp $";
static const char *IdHdr = ID_FDMEXEC; static const char *IdHdr = ID_FDMEXEC;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -160,6 +162,7 @@ FGFDMExec::FGFDMExec(FGPropertyManager* root, unsigned int* fdmctr) : Root(root)
instance->Tie("simulation/randomseed", this, (iPMF)0, &FGFDMExec::SRand, false); instance->Tie("simulation/randomseed", this, (iPMF)0, &FGFDMExec::SRand, false);
instance->Tie("simulation/terminate", (int *)&Terminate); instance->Tie("simulation/terminate", (int *)&Terminate);
instance->Tie("simulation/sim-time-sec", this, &FGFDMExec::GetSimTime); instance->Tie("simulation/sim-time-sec", this, &FGFDMExec::GetSimTime);
instance->Tie("simulation/dt", this, &FGFDMExec::GetDeltaT);
instance->Tie("simulation/jsbsim-debug", this, &FGFDMExec::GetDebugLevel, &FGFDMExec::SetDebugLevel); instance->Tie("simulation/jsbsim-debug", this, &FGFDMExec::GetDebugLevel, &FGFDMExec::SetDebugLevel);
instance->Tie("simulation/frame", (int *)&Frame, false); instance->Tie("simulation/frame", (int *)&Frame, false);
@ -708,8 +711,9 @@ bool FGFDMExec::LoadModel(const string& model, bool addModelToPath)
} }
int saved_debug_lvl = debug_lvl; int saved_debug_lvl = debug_lvl;
FGXMLFileRead XMLFileRead;
Element *document = XMLFileRead.LoadXMLDocument(aircraftCfgFileName); // "document" is a class member
document = LoadXMLDocument(aircraftCfgFileName); // "document" is a class member
if (document) { if (document) {
if (IsChild) debug_lvl = 0; if (IsChild) debug_lvl = 0;

View file

@ -47,7 +47,6 @@ INCLUDES
#include "initialization/FGTrim.h" #include "initialization/FGTrim.h"
#include "FGJSBBase.h" #include "FGJSBBase.h"
#include "input_output/FGPropertyManager.h" #include "input_output/FGPropertyManager.h"
#include "input_output/FGXMLFileRead.h"
#include "models/FGPropagate.h" #include "models/FGPropagate.h"
#include "math/FGColumnVector3.h" #include "math/FGColumnVector3.h"
#include "models/FGOutput.h" #include "models/FGOutput.h"
@ -56,7 +55,7 @@ INCLUDES
DEFINITIONS DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#define ID_FDMEXEC "$Id: FGFDMExec.h,v 1.83 2013/06/10 01:46:27 jberndt Exp $" #define ID_FDMEXEC "$Id: FGFDMExec.h,v 1.85 2013/11/24 11:40:55 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS FORWARD DECLARATIONS
@ -179,14 +178,14 @@ CLASS DOCUMENTATION
property actually maps toa function call of DoTrim(). property actually maps toa function call of DoTrim().
@author Jon S. Berndt @author Jon S. Berndt
@version $Revision: 1.83 $ @version $Revision: 1.85 $
*/ */
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CLASS DECLARATION CLASS DECLARATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
class FGFDMExec : public FGJSBBase, public FGXMLFileRead class FGFDMExec : public FGJSBBase
{ {
struct childData { struct childData {
FGFDMExec* exec; FGFDMExec* exec;

View file

@ -1261,6 +1261,8 @@ void FGJSBsim::do_trim(void)
fgtrim = new FGTrim(fdmex,tFull); fgtrim = new FGTrim(fdmex,tFull);
} }
fdmex->RunIC();
if ( !fgtrim->DoTrim() ) { if ( !fgtrim->DoTrim() ) {
fgtrim->Report(); fgtrim->Report();
fgtrim->TrimStats(); fgtrim->TrimStats();

View file

@ -58,12 +58,14 @@ INCLUDES
#include "models/FGFCS.h" #include "models/FGFCS.h"
#include "input_output/FGPropertyManager.h" #include "input_output/FGPropertyManager.h"
#include "input_output/string_utilities.h" #include "input_output/string_utilities.h"
#include "input_output/FGXMLFileRead.h"
#include "input_output/FGXMLElement.h"
using namespace std; using namespace std;
namespace JSBSim { namespace JSBSim {
static const char *IdSrc = "$Id: FGInitialCondition.cpp,v 1.87 2013/01/19 14:19:43 bcoconni Exp $"; static const char *IdSrc = "$Id: FGInitialCondition.cpp,v 1.89 2013/11/24 11:40:55 bcoconni Exp $";
static const char *IdHdr = ID_INITIALCONDITION; static const char *IdHdr = ID_INITIALCONDITION;
//****************************************************************************** //******************************************************************************
@ -109,7 +111,7 @@ void FGInitialCondition::ResetIC(double u0, double v0, double w0,
position.SetLongitude(lonRad0); position.SetLongitude(lonRad0);
position.SetLatitude(latRad0); position.SetLatitude(latRad0);
position.SetAltitudeAGL(altAGLFt0, fdmex->GetSimTime()); position.SetAltitudeAGL(altAGLFt0, 0.0);
orientation = FGQuaternion(phi0, theta0, psi0); orientation = FGQuaternion(phi0, theta0, psi0);
const FGMatrix33& Tb2l = orientation.GetTInv(); const FGMatrix33& Tb2l = orientation.GetTInv();
@ -665,22 +667,22 @@ void FGInitialCondition::SetTerrainElevationFtIC(double elev)
double FGInitialCondition::GetAltitudeAGLFtIC(void) const double FGInitialCondition::GetAltitudeAGLFtIC(void) const
{ {
return position.GetAltitudeAGL(fdmex->GetSimTime()); return position.GetAltitudeAGL(0.0);
} }
//****************************************************************************** //******************************************************************************
double FGInitialCondition::GetTerrainElevationFtIC(void) const double FGInitialCondition::GetTerrainElevationFtIC(void) const
{ {
return position.GetTerrainRadius(fdmex->GetSimTime()) return position.GetTerrainRadius(0.0) - position.GetSeaLevelRadius();
- position.GetSeaLevelRadius();
} }
//****************************************************************************** //******************************************************************************
void FGInitialCondition::SetAltitudeAGLFtIC(double agl) void FGInitialCondition::SetAltitudeAGLFtIC(double agl)
{ {
double terrainElevation = position.GetTerrainRadius(fdmex->GetSimTime()) - position.GetSeaLevelRadius(); double terrainElevation = position.GetTerrainRadius(0.0)
- position.GetSeaLevelRadius();
SetAltitudeASLFtIC(agl + terrainElevation); SetAltitudeASLFtIC(agl + terrainElevation);
lastAltitudeSet = setagl; lastAltitudeSet = setagl;
} }
@ -870,7 +872,8 @@ bool FGInitialCondition::Load(string rstfile, bool useStoredPath)
init_file_name = rstfile; init_file_name = rstfile;
} }
document = LoadXMLDocument(init_file_name); FGXMLFileRead XMLFileRead;
Element* document = XMLFileRead.LoadXMLDocument(init_file_name);
// Make sure that the document is valid // Make sure that the document is valid
if (!document) { if (!document) {
@ -887,14 +890,14 @@ bool FGInitialCondition::Load(string rstfile, bool useStoredPath)
bool result = false; bool result = false;
if (version == HUGE_VAL) { if (version == HUGE_VAL) {
result = Load_v1(); // Default to the old version result = Load_v1(document); // Default to the old version
} else if (version >= 3.0) { } else if (version >= 3.0) {
cerr << "Only initialization file formats 1 and 2 are currently supported" << endl; cerr << "Only initialization file formats 1 and 2 are currently supported" << endl;
exit (-1); exit (-1);
} else if (version >= 2.0) { } else if (version >= 2.0) {
result = Load_v2(); result = Load_v2(document);
} else if (version >= 1.0) { } else if (version >= 1.0) {
result = Load_v1(); result = Load_v1(document);
} }
// Check to see if any engines are specified to be initialized in a running state // Check to see if any engines are specified to be initialized in a running state
@ -909,7 +912,7 @@ bool FGInitialCondition::Load(string rstfile, bool useStoredPath)
//****************************************************************************** //******************************************************************************
bool FGInitialCondition::Load_v1(void) bool FGInitialCondition::Load_v1(Element* document)
{ {
bool result = true; bool result = true;
@ -995,7 +998,7 @@ bool FGInitialCondition::Load_v1(void)
//****************************************************************************** //******************************************************************************
bool FGInitialCondition::Load_v2(void) bool FGInitialCondition::Load_v2(Element* document)
{ {
FGColumnVector3 vOrient; FGColumnVector3 vOrient;
bool result = true; bool result = true;
@ -1026,7 +1029,7 @@ bool FGInitialCondition::Load_v2(void)
position.SetRadius(position_el->FindElementValueAsNumberConvertTo("radius", "FT")); position.SetRadius(position_el->FindElementValueAsNumberConvertTo("radius", "FT"));
} else if (position_el->FindElement("altitudeAGL")) { } else if (position_el->FindElement("altitudeAGL")) {
position.SetAltitudeAGL(position_el->FindElementValueAsNumberConvertTo("altitudeAGL", "FT"), position.SetAltitudeAGL(position_el->FindElementValueAsNumberConvertTo("altitudeAGL", "FT"),
fdmex->GetSimTime()); 0.0);
} else if (position_el->FindElement("altitudeMSL")) { } else if (position_el->FindElement("altitudeMSL")) {
position.SetAltitudeASL(position_el->FindElementValueAsNumberConvertTo("altitudeMSL", "FT")); position.SetAltitudeASL(position_el->FindElementValueAsNumberConvertTo("altitudeMSL", "FT"));
} else { } else {
@ -1042,7 +1045,7 @@ bool FGInitialCondition::Load_v2(void)
double longitude = position.GetLongitude(); double longitude = position.GetLongitude();
double altitude = position.GetAltitudeASL(); // SetPositionGeodetic() assumes altitude double altitude = position.GetAltitudeASL(); // SetPositionGeodetic() assumes altitude
position.SetPositionGeodetic(longitude, latitude, altitude); // is geodetic, but it's close enough for now. position.SetPositionGeodetic(longitude, latitude, altitude); // is geodetic, but it's close enough for now.
position.SetAltitudeAGL(altitude, fdmex->GetSimTime()); position.SetAltitudeAGL(altitude, 0.0);
} else { } else {
position.SetLatitude(latitude); position.SetLatitude(latitude);
} }

View file

@ -47,7 +47,6 @@ SENTRY
INCLUDES INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#include "input_output/FGXMLFileRead.h"
#include "math/FGLocation.h" #include "math/FGLocation.h"
#include "math/FGQuaternion.h" #include "math/FGQuaternion.h"
@ -55,7 +54,7 @@ INCLUDES
DEFINITIONS DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#define ID_INITIALCONDITION "$Id: FGInitialCondition.h,v 1.36 2013/01/19 14:19:43 bcoconni Exp $" #define ID_INITIALCONDITION "$Id: FGInitialCondition.h,v 1.39 2013/11/24 11:40:55 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS FORWARD DECLARATIONS
@ -67,6 +66,8 @@ class FGFDMExec;
class FGMatrix33; class FGMatrix33;
class FGColumnVector3; class FGColumnVector3;
class FGAtmosphere; class FGAtmosphere;
class FGPropertyManager;
class Element;
typedef enum { setvt, setvc, setve, setmach, setuvw, setned, setvg } speedset; typedef enum { setvt, setvc, setve, setmach, setuvw, setned, setvg } speedset;
typedef enum { setasl, setagl} altitudeset; typedef enum { setasl, setagl} altitudeset;
@ -216,14 +217,14 @@ CLASS DOCUMENTATION
@property ic/r-rad_sec (read/write) Yaw rate initial condition in radians/second @property ic/r-rad_sec (read/write) Yaw rate initial condition in radians/second
@author Tony Peden @author Tony Peden
@version "$Id: FGInitialCondition.h,v 1.36 2013/01/19 14:19:43 bcoconni Exp $" @version "$Id: FGInitialCondition.h,v 1.39 2013/11/24 11:40:55 bcoconni Exp $"
*/ */
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CLASS DECLARATION CLASS DECLARATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
class FGInitialCondition : public FGJSBBase, public FGXMLFileRead class FGInitialCondition : public FGJSBBase
{ {
public: public:
/// Constructor /// Constructor
@ -682,8 +683,8 @@ private:
FGPropertyManager *PropertyManager; FGPropertyManager *PropertyManager;
FGAtmosphere* Atmosphere; FGAtmosphere* Atmosphere;
bool Load_v1(void); bool Load_v1(Element* document);
bool Load_v2(void); bool Load_v2(Element* document);
void InitializeIC(void); void InitializeIC(void);
void SetEulerAngleRadIC(int idx, double angle); void SetEulerAngleRadIC(int idx, double angle);

View file

@ -45,6 +45,9 @@ INCLUDES
#include "FGTrim.h" #include "FGTrim.h"
#include "models/FGGroundReactions.h" #include "models/FGGroundReactions.h"
#include "models/FGInertial.h" #include "models/FGInertial.h"
#include "models/FGAccelerations.h"
#include "models/FGMassBalance.h"
#include "models/FGFCS.h"
#if _MSC_VER #if _MSC_VER
#pragma warning (disable : 4786 4788) #pragma warning (disable : 4786 4788)
@ -54,7 +57,7 @@ using namespace std;
namespace JSBSim { namespace JSBSim {
static const char *IdSrc = "$Id: FGTrim.cpp,v 1.17 2012/09/05 21:49:19 bcoconni Exp $"; static const char *IdSrc = "$Id: FGTrim.cpp,v 1.18 2013/11/24 16:53:15 bcoconni Exp $";
static const char *IdHdr = ID_TRIM; static const char *IdHdr = ID_TRIM;
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -225,6 +228,13 @@ bool FGTrim::DoTrim(void) {
trim_failed=false; trim_failed=false;
int i; int i;
FGFCS *FCS = fdmex->GetFCS();
vector<double> throttle0 = FCS->GetThrottleCmd();
double elevator0 = FCS->GetDeCmd();
double aileron0 = FCS->GetDaCmd();
double rudder0 = FCS->GetDrCmd();
double PitchTrim0 = FCS->GetPitchTrimCmd();
FGInitialCondition fgic0 = *fgic;
for(i=0;i < fdmex->GetGroundReactions()->GetNumGearUnits();i++){ for(i=0;i < fdmex->GetGroundReactions()->GetNumGearUnits();i++){
fdmex->GetGroundReactions()->GetGearUnit(i)->SetReport(false); fdmex->GetGroundReactions()->GetGearUnit(i)->SetReport(false);
@ -239,15 +249,21 @@ bool FGTrim::DoTrim(void) {
fgic->SetQRadpsIC(0.0); fgic->SetQRadpsIC(0.0);
fgic->SetRRadpsIC(0.0); fgic->SetRRadpsIC(0.0);
if (mode == tGround) {
trimOnGround();
double theta = fgic->GetThetaRadIC();
double phi = fgic->GetPhiRadIC();
// Take opportunity of the first approx. found by trimOnGround() to
// refine the control limits.
TrimAxes[0]->SetControlLimits(0., fgic->GetAltitudeAGLFtIC());
TrimAxes[1]->SetControlLimits(theta - 5.0 * degtorad, theta + 5.0 * degtorad);
TrimAxes[2]->SetControlLimits(phi - 30.0 * degtorad, phi + 30.0 * degtorad);
}
//clear the sub iterations counts & zero out the controls //clear the sub iterations counts & zero out the controls
for(current_axis=0;current_axis<TrimAxes.size();current_axis++) { for(current_axis=0;current_axis<TrimAxes.size();current_axis++) {
//cout << current_axis << " " << TrimAxes[current_axis]->GetStateName() //cout << current_axis << " " << TrimAxes[current_axis]->GetStateName()
//<< " " << TrimAxes[current_axis]->GetControlName()<< endl; //<< " " << TrimAxes[current_axis]->GetControlName()<< endl;
if(TrimAxes[current_axis]->GetStateType() == tQdot) {
if(mode == tGround) {
TrimAxes[current_axis]->initTheta();
}
}
xlo=TrimAxes[current_axis]->GetControlMin(); xlo=TrimAxes[current_axis]->GetControlMin();
xhi=TrimAxes[current_axis]->GetControlMax(); xhi=TrimAxes[current_axis]->GetControlMax();
TrimAxes[current_axis]->SetControl((xlo+xhi)/2); TrimAxes[current_axis]->SetControl((xlo+xhi)/2);
@ -258,7 +274,6 @@ bool FGTrim::DoTrim(void) {
solution[current_axis]=false; solution[current_axis]=false;
} }
if(mode == tPullup ) { if(mode == tPullup ) {
cout << "Setting pitch rate and nlf... " << endl; cout << "Setting pitch rate and nlf... " << endl;
setupPullup(); setupPullup();
@ -297,7 +312,6 @@ bool FGTrim::DoTrim(void) {
} }
} }
if((axis_count == TrimAxes.size()-1) && (TrimAxes.size() > 1)) { if((axis_count == TrimAxes.size()-1) && (TrimAxes.size() > 1)) {
//cout << TrimAxes.size()-1 << " out of " << TrimAxes.size() << "!" << endl; //cout << TrimAxes.size()-1 << " out of " << TrimAxes.size() << "!" << endl;
//At this point we can check the input limits of the failed axis //At this point we can check the input limits of the failed axis
@ -338,24 +352,218 @@ bool FGTrim::DoTrim(void) {
if(N > max_iterations) if(N > max_iterations)
trim_failed=true; trim_failed=true;
} while((axis_count < TrimAxes.size()) && (!trim_failed)); } while((axis_count < TrimAxes.size()) && (!trim_failed));
if((!trim_failed) && (axis_count >= TrimAxes.size())) { if((!trim_failed) && (axis_count >= TrimAxes.size())) {
total_its=N; total_its=N;
if (debug_lvl > 0) if (debug_lvl > 0)
cout << endl << " Trim successful" << endl; cout << endl << " Trim successful" << endl;
} else { } else { // The trim has failed
total_its=N; total_its=N;
// Restore the aircraft parameters to their initial values
*fgic = fgic0;
FCS->SetDeCmd(elevator0);
FCS->SetDaCmd(aileron0);
FCS->SetDrCmd(rudder0);
FCS->SetPitchTrimCmd(PitchTrim0);
for (unsigned int i=0; i < throttle0.size(); i++)
FCS->SetThrottleCmd(i, throttle0[i]);
// If WOW is true we must make sure there are no gears into the ground.
if (fdmex->GetGroundReactions()->GetWOW()) {
fdmex->Initialize(fgic);
fdmex->Run();
trimOnGround();
}
if (debug_lvl > 0) if (debug_lvl > 0)
cout << endl << " Trim failed" << endl; cout << endl << " Trim failed" << endl;
} }
for(i=0;i < fdmex->GetGroundReactions()->GetNumGearUnits();i++){ for(i=0;i < fdmex->GetGroundReactions()->GetNumGearUnits();i++){
fdmex->GetGroundReactions()->GetGearUnit(i)->SetReport(true); fdmex->GetGroundReactions()->GetGearUnit(i)->SetReport(true);
} }
fdmex->SetTrimStatus(false); fdmex->SetTrimStatus(false);
fdmex->ResumeIntegration(); fdmex->ResumeIntegration();
fdmex->EnableOutput(); fdmex->EnableOutput();
return !trim_failed; return !trim_failed;
} }
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// Trim the aircraft on the ground. The algorithm is looking for a stable
// position of the aicraft. Assuming the aircaft is a rigid body and the ground
// a plane: we need to find the translations and rotations of the aircraft that
// will move 3 non-colinear points in contact with the ground.
// The algorithm proceeds in three stages (one for each point):
// 1. Look for the contact point closer to or deeper into the ground. Move the
// aircraft along the vertical direction so that only this contact point
// remains in contact with the ground.
// 2. The forces applied on the aircraft (most likely the gravity) will generate
// a moment on the aircraft around the point in contact. The rotation axis is
// therefore the moment axis. The 2nd stage thus consists in determining the
// minimum rotation angle around the first point in contact that will place a
// second contact point on the ground.
// 3. At this stage, 2 points are in contact with the ground: the rotation axis
// is therefore the vector generated by the 2 points. Like stage #2, the
// rotation direction will be driven by the moment around the axis formed by
// the 2 points in contact. The rotation angle is obtained similarly to stage
// #2: it is the minimum angle that will place a third contact point on the
// ground.
// The calculations below do not account for the compression of the landing
// gears meaning that the position found is close to the real position but not
// strictly equal to it.
void FGTrim::trimOnGround(void)
{
FGGroundReactions* GroundReactions = fdmex->GetGroundReactions();
FGPropagate* Propagate = fdmex->GetPropagate();
FGMassBalance* MassBalance = fdmex->GetMassBalance();
FGAccelerations* Accelerations = fdmex->GetAccelerations();
vector<ContactPoints> contacts;
FGLocation CGLocation = Propagate->GetLocation();
FGMatrix33 Tec2b = Propagate->GetTec2b();
FGMatrix33 Tl2b = Propagate->GetTl2b();
double hmin = 1E+10;
int contactRef = -1;
// Build the list of the aircraft contact points and take opportunity of the
// loop to find which one is closer to (or deeper into) the ground.
for (int i = 0; i < GroundReactions->GetNumGearUnits(); i++) {
ContactPoints c;
FGLGear* gear = GroundReactions->GetGearUnit(i);
c.location = gear->GetLocalGear();
FGLocation gearLoc = CGLocation.LocalToLocation(c.location);
c.location = Tl2b * c.location;
FGColumnVector3 normal, vDummy;
FGLocation lDummy;
double height = gearLoc.GetContactPoint(fdmex->GetSimTime(), lDummy,
normal, vDummy, vDummy);
c.normal = Tec2b * normal;
contacts.push_back(c);
if (height < hmin) {
hmin = height;
contactRef = i;
}
}
// Remove the contact point that is closest to the ground from the list:
// the rotation axis will be going thru this point so we need to remove it
// to avoid divisions by zero that could result from the computation of
// the rotations.
FGColumnVector3 contact0 = contacts[contactRef].location;
contacts.erase(contacts.begin() + contactRef);
// Update the initial conditions: this should remove the forces generated
// by overcompressed landing gears
fgic->SetAltitudeASLFtIC(fgic->GetAltitudeASLFtIC() - hmin);
fdmex->Initialize(fgic);
fdmex->Run();
// Compute the rotation axis: it is obtained from the direction of the
// moment measured at the contact point 'contact0'
FGColumnVector3 force = MassBalance->GetMass() * Accelerations->GetUVWdot();
FGColumnVector3 moment = MassBalance->GetJ() * Accelerations->GetPQRdot()
+ force * contact0;
FGColumnVector3 rotationAxis = moment.Normalize();
// Compute the rotation parameters: angle and the first point to come into
// contact with the ground when the rotation is applied.
RotationParameters rParam = calcRotation(contacts, rotationAxis, contact0);
FGQuaternion q0(rParam.angleMin, rotationAxis);
// Apply the computed rotation to all the contact points
FGMatrix33 rot = q0.GetTInv();
vector<ContactPoints>::iterator iter;
for (iter = contacts.begin(); iter != contacts.end(); iter++)
iter->location = contact0 + rot * (iter->location - contact0);
// Remove the second point to come in contact with the ground from the list.
// The reason is the same than above: avoid divisions by zero when the next
// rotation will be computed.
FGColumnVector3 contact1 = rParam.contactRef->location;
contacts.erase(rParam.contactRef);
// Compute the rotation axis: now there are 2 points in contact with the
// ground so the only option for the aircraft is to rotate around the axis
// generated by these 2 points.
rotationAxis = contact1 - contact0;
// Make sure that the rotation orientation is consistent with the moment.
if (DotProduct(rotationAxis, moment) < 0.0)
rotationAxis = contact0 - contact1;
rotationAxis.Normalize();
// Compute the rotation parameters
rParam = calcRotation(contacts, rotationAxis, contact0);
FGQuaternion q1(rParam.angleMin, rotationAxis);
// Update the aircraft orientation
FGColumnVector3 euler = (q0 * q1 * fgic->GetOrientation()).GetEuler();
fgic->SetPhiRadIC(euler(1));
fgic->SetThetaRadIC(euler(2));
fgic->SetPsiRadIC(euler(3));
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// Given a set of points and a rotation axis, this routine computes for each
// point the rotation angle that would drive the point in contact with the
// plane. It returns the minimum angle as well as the point with which this
// angle has been obtained.
// The rotation axis is defined by a vector 'u' and a point 'M0' on the axis.
// Since we are in the body frame, the position if 'M0' is measured from the CG
// hence the name 'GM0'.
FGTrim::RotationParameters FGTrim::calcRotation(vector<ContactPoints>& contacts,
const FGColumnVector3& u,
const FGColumnVector3& GM0)
{
RotationParameters rParam;
vector<ContactPoints>::iterator iter;
rParam.angleMin = 3.0 * M_PI;
for (iter = contacts.begin(); iter != contacts.end(); iter++) {
// Below the processed contact point is named 'M'
// Construct an orthonormal basis (u, v, t). The ground normal is obtained
// from iter->normal.
FGColumnVector3 t = u * iter->normal;
double length = t.Magnitude();
t /= length; // Normalize the tangent
FGColumnVector3 v = t * u;
FGColumnVector3 MM0 = GM0 - iter->location;
// d0 is the distance from the circle center 'C' to the reference point 'M0'
double d0 = DotProduct(MM0, u);
// Compute the square of the circle radius i.e. the square of the distance
// between 'C' and 'M'.
double sqrRadius = DotProduct(MM0, MM0) - d0 * d0;
// Compute the distance from the circle center 'C' to the line made by the
// intersection between the ground and the plane that contains the circle.
double DistPlane = d0 * DotProduct(u, iter->normal) / length;
// The coordinate of the point of intersection 'P' between the circle and
// the ground is (0, DistPlane, alpha) in the basis (u, v, t)
double alpha = sqrt(sqrRadius - DistPlane * DistPlane);
FGColumnVector3 CP = alpha * t + DistPlane * v;
// The transformation is now constructed: we can extract the angle using the
// classical formulas (cosine is obtained from the dot product and sine from
// the cross product).
double cosine = -DotProduct(MM0, CP) / sqrRadius;
double sine = DotProduct(MM0 * u, CP) / sqrRadius;
double angle = atan2(sine, cosine);
if (angle < 0.0) angle += 2.0 * M_PI;
if (angle < rParam.angleMin) {
rParam.angleMin = angle;
rParam.contactRef = iter;
}
}
return rParam;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
bool FGTrim::solve(void) { bool FGTrim::solve(void) {
@ -645,7 +853,7 @@ void FGTrim::SetMode(TrimMode tt) {
cout << " Ground Trim" << endl; cout << " Ground Trim" << endl;
TrimAxes.push_back(new FGTrimAxis(fdmex,fgic,tWdot,tAltAGL )); TrimAxes.push_back(new FGTrimAxis(fdmex,fgic,tWdot,tAltAGL ));
TrimAxes.push_back(new FGTrimAxis(fdmex,fgic,tQdot,tTheta )); TrimAxes.push_back(new FGTrimAxis(fdmex,fgic,tQdot,tTheta ));
//TrimAxes.push_back(new FGTrimAxis(fdmex,fgic,tPdot,tPhi )); TrimAxes.push_back(new FGTrimAxis(fdmex,fgic,tPdot,tPhi ));
break; break;
case tPullup: case tPullup:
TrimAxes.push_back(new FGTrimAxis(fdmex,fgic,tNlf,tAlpha )); TrimAxes.push_back(new FGTrimAxis(fdmex,fgic,tNlf,tAlpha ));

View file

@ -60,7 +60,7 @@ INCLUDES
DEFINITIONS DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#define ID_TRIM "$Id: FGTrim.h,v 1.8 2011/01/24 13:01:55 jberndt Exp $" #define ID_TRIM "$Id: FGTrim.h,v 1.10 2013/11/24 16:53:15 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS FORWARD DECLARATIONS
@ -120,7 +120,7 @@ CLASS DOCUMENTATION
@endcode @endcode
@author Tony Peden @author Tony Peden
@version "$Id: FGTrim.h,v 1.8 2011/01/24 13:01:55 jberndt Exp $" @version "$Id: FGTrim.h,v 1.10 2013/11/24 16:53:15 bcoconni Exp $"
*/ */
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -178,6 +178,21 @@ private:
void updateRates(void); void updateRates(void);
void setDebug(void); void setDebug(void);
struct ContactPoints {
FGColumnVector3 location;
FGColumnVector3 normal;
};
struct RotationParameters {
double angleMin;
std::vector<ContactPoints>::iterator contactRef;
};
void trimOnGround(void);
RotationParameters calcRotation(std::vector<ContactPoints>& contacts,
const FGColumnVector3& rotationAxis,
const FGColumnVector3& contact0);
public: public:
/** Initializes the trimming class /** Initializes the trimming class
@param FDMExec pointer to a JSBSim executive object. @param FDMExec pointer to a JSBSim executive object.

View file

@ -56,7 +56,7 @@ using namespace std;
namespace JSBSim { namespace JSBSim {
static const char *IdSrc = "$Id: FGTrimAxis.cpp,v 1.14 2012/09/05 21:49:19 bcoconni Exp $"; static const char *IdSrc = "$Id: FGTrimAxis.cpp,v 1.15 2013/11/24 16:53:15 bcoconni Exp $";
static const char *IdHdr = ID_TRIMAXIS; static const char *IdHdr = ID_TRIMAXIS;
/*****************************************************************************/ /*****************************************************************************/
@ -243,155 +243,6 @@ void FGTrimAxis::setControl(void) {
} }
} }
/*****************************************************************************/
// the aircraft center of rotation is no longer the cg once the gear
// contact the ground so the altitude needs to be changed when pitch
// and roll angle are adjusted. Instead of attempting to calculate the
// new center of rotation, pick a gear unit as a reference and use its
// location vector to calculate the new height change. i.e. new altitude =
// earth z component of that vector (which is in body axes )
void FGTrimAxis::SetThetaOnGround(double ff) {
int center,i,ref;
// favor an off-center unit so that the same one can be used for both
// pitch and roll. An on-center unit is used (for pitch)if that's all
// that's in contact with the ground.
i=0; ref=-1; center=-1;
while( (ref < 0) && (i < fdmex->GetGroundReactions()->GetNumGearUnits()) ) {
if(fdmex->GetGroundReactions()->GetGearUnit(i)->GetWOW()) {
if(fabs(fdmex->GetGroundReactions()->GetGearUnit(i)->GetBodyLocation(2)) > 0.01)
ref=i;
else
center=i;
}
i++;
}
if((ref < 0) && (center >= 0)) {
ref=center;
}
cout << "SetThetaOnGround ref gear: " << ref << endl;
if(ref >= 0) {
double sp = fdmex->GetPropagate()->GetSinEuler(ePhi);
double cp = fdmex->GetPropagate()->GetCosEuler(ePhi);
double lx = fdmex->GetGroundReactions()->GetGearUnit(ref)->GetBodyLocation(1);
double ly = fdmex->GetGroundReactions()->GetGearUnit(ref)->GetBodyLocation(2);
double lz = fdmex->GetGroundReactions()->GetGearUnit(ref)->GetBodyLocation(3);
double hagl = -1*lx*sin(ff) +
ly*sp*cos(ff) +
lz*cp*cos(ff);
fgic->SetAltitudeAGLFtIC(hagl);
cout << "SetThetaOnGround new alt: " << hagl << endl;
}
fgic->SetThetaRadIC(ff);
cout << "SetThetaOnGround new theta: " << ff << endl;
}
/*****************************************************************************/
bool FGTrimAxis::initTheta(void) {
int i,N;
int iForward = 0;
int iAft = 1;
double zAft,zForward,zDiff,theta;
double xAft,xForward,xDiff;
bool level;
double saveAlt;
saveAlt=fgic->GetAltitudeAGLFtIC();
fgic->SetAltitudeAGLFtIC(100);
N=fdmex->GetGroundReactions()->GetNumGearUnits();
//find the first wheel unit forward of the cg
//the list is short so a simple linear search is fine
for( i=0; i<N; i++ ) {
if(fdmex->GetGroundReactions()->GetGearUnit(i)->GetBodyLocation(1) > 0 ) {
iForward=i;
break;
}
}
//now find the first wheel unit aft of the cg
for( i=0; i<N; i++ ) {
if(fdmex->GetGroundReactions()->GetGearUnit(i)->GetBodyLocation(1) < 0 ) {
iAft=i;
break;
}
}
// now adjust theta till the wheels are the same distance from the ground
xAft=fdmex->GetGroundReactions()->GetGearUnit(iAft)->GetBodyLocation(1);
xForward=fdmex->GetGroundReactions()->GetGearUnit(iForward)->GetBodyLocation(1);
xDiff = xForward - xAft;
zAft=fdmex->GetGroundReactions()->GetGearUnit(iAft)->GetLocalGear(3);
zForward=fdmex->GetGroundReactions()->GetGearUnit(iForward)->GetLocalGear(3);
zDiff = zForward - zAft;
level=false;
theta=fgic->GetThetaDegIC();
while(!level && (i < 100)) {
theta+=radtodeg*atan(zDiff/xDiff);
fgic->SetThetaDegIC(theta);
fdmex->Initialize(fgic);
fdmex->Run();
zAft=fdmex->GetGroundReactions()->GetGearUnit(iAft)->GetLocalGear(3);
zForward=fdmex->GetGroundReactions()->GetGearUnit(iForward)->GetLocalGear(3);
zDiff = zForward - zAft;
//cout << endl << theta << " " << zDiff << endl;
//cout << "0: " << fdmex->GetGroundReactions()->GetGearUnit(0)->GetLocalGear() << endl;
//cout << "1: " << fdmex->GetGroundReactions()->GetGearUnit(1)->GetLocalGear() << endl;
if(fabs(zDiff ) < 0.1)
level=true;
i++;
}
//cout << i << endl;
if (debug_lvl > 0) {
cout << " Initial Theta: " << fdmex->GetPropagate()->GetEuler(eTht)*radtodeg << endl;
cout << " Used gear unit " << iAft << " as aft and " << iForward << " as forward" << endl;
}
control_min=(theta+5)*degtorad;
control_max=(theta-5)*degtorad;
fgic->SetAltitudeAGLFtIC(saveAlt);
if(i < 100)
return true;
else
return false;
}
/*****************************************************************************/
void FGTrimAxis::SetPhiOnGround(double ff) {
int i,ref;
i=0; ref=-1;
//must have an off-center unit here
while ( (ref < 0) && (i < fdmex->GetGroundReactions()->GetNumGearUnits()) ) {
if ( (fdmex->GetGroundReactions()->GetGearUnit(i)->GetWOW()) &&
(fabs(fdmex->GetGroundReactions()->GetGearUnit(i)->GetBodyLocation(2)) > 0.01))
ref=i;
i++;
}
if (ref >= 0) {
double st = fdmex->GetPropagate()->GetSinEuler(eTht);
double ct = fdmex->GetPropagate()->GetCosEuler(eTht);
double lx = fdmex->GetGroundReactions()->GetGearUnit(ref)->GetBodyLocation(1);
double ly = fdmex->GetGroundReactions()->GetGearUnit(ref)->GetBodyLocation(2);
double lz = fdmex->GetGroundReactions()->GetGearUnit(ref)->GetBodyLocation(3);
double hagl = -1*lx*st +
ly*sin(ff)*ct +
lz*cos(ff)*ct;
fgic->SetAltitudeAGLFtIC(hagl);
}
fgic->SetPhiRadIC(ff);
}
/*****************************************************************************/ /*****************************************************************************/
void FGTrimAxis::Run(void) { void FGTrimAxis::Run(void) {

View file

@ -48,7 +48,7 @@ INCLUDES
DEFINITIONS DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#define ID_TRIMAXIS "$Id: FGTrimAxis.h,v 1.5 2010/09/07 18:36:29 andgi Exp $" #define ID_TRIMAXIS "$Id: FGTrimAxis.h,v 1.7 2013/11/24 16:53:15 bcoconni Exp $"
#define DEFAULT_TOLERANCE 0.001 #define DEFAULT_TOLERANCE 0.001
@ -140,14 +140,9 @@ public:
inline int GetRunCount(void) { return total_stability_iterations; } inline int GetRunCount(void) { return total_stability_iterations; }
double GetAvgStability( void ); double GetAvgStability( void );
void SetThetaOnGround(double ff);
void SetPhiOnGround(double ff);
inline void SetStateTarget(double target) { state_target=target; } inline void SetStateTarget(double target) { state_target=target; }
inline double GetStateTarget(void) { return state_target; } inline double GetStateTarget(void) { return state_target; }
bool initTheta(void);
void AxisReport(void); void AxisReport(void);
bool InTolerance(void) { getState(); return (fabs(state_value) <= tolerance); } bool InTolerance(void) { getState(); return (fabs(state_value) <= tolerance); }

View file

@ -71,7 +71,7 @@ using namespace std;
namespace JSBSim { namespace JSBSim {
static const char *IdSrc = "$Id: FGOutputFG.cpp,v 1.5 2012/12/15 16:13:57 bcoconni Exp $"; static const char *IdSrc = "$Id: FGOutputFG.cpp,v 1.6 2013/11/09 14:06:36 bcoconni Exp $";
static const char *IdHdr = ID_OUTPUTFG; static const char *IdHdr = ID_OUTPUTFG;
// (stolen from FGFS native_fdm.cxx) // (stolen from FGFS native_fdm.cxx)
@ -159,9 +159,9 @@ void FGOutputFG::SocketDataFill(FGNetFDM* net)
net->v_east = (float)(Propagate->GetVel(eEast)); // east vel in NED frame, fps net->v_east = (float)(Propagate->GetVel(eEast)); // east vel in NED frame, fps
net->v_down = (float)(Propagate->GetVel(eDown)); // down vel in NED frame, fps net->v_down = (float)(Propagate->GetVel(eDown)); // down vel in NED frame, fps
//---ADD METHOD TO CALCULATE THESE TERMS--- //---ADD METHOD TO CALCULATE THESE TERMS---
net->v_wind_body_north = (float)(Propagate->GetVel(eNorth)); // north vel in NED relative to airmass, fps net->v_body_u = (float)(Propagate->GetUVW(1)); // ECEF speed in body axis
net->v_wind_body_east = (float)(Propagate->GetVel(eEast)); // east vel in NED relative to airmass, fps net->v_body_v = (float)(Propagate->GetUVW(2)); // ECEF speed in body axis
net->v_wind_body_down = (float)(Propagate->GetVel(eDown)); // down vel in NED relative to airmass, fps net->v_body_w = (float)(Propagate->GetUVW(3)); // ECEF speed in body axis
// Accelerations // Accelerations
net->A_X_pilot = (float)(Auxiliary->GetPilotAccel(1)); // X body accel, ft/s/s net->A_X_pilot = (float)(Auxiliary->GetPilotAccel(1)); // X body accel, ft/s/s
@ -282,9 +282,9 @@ void FGOutputFG::SocketDataFill(FGNetFDM* net)
htonf(net->v_north); htonf(net->v_north);
htonf(net->v_east); htonf(net->v_east);
htonf(net->v_down); htonf(net->v_down);
htonf(net->v_wind_body_north); htonf(net->v_body_u);
htonf(net->v_wind_body_east); htonf(net->v_body_v);
htonf(net->v_wind_body_down); htonf(net->v_body_w);
htonf(net->A_X_pilot); htonf(net->A_X_pilot);
htonf(net->A_Y_pilot); htonf(net->A_Y_pilot);

View file

@ -41,12 +41,13 @@ INCLUDES
#include <sstream> #include <sstream>
#include "FGOutputFile.h" #include "FGOutputFile.h"
#include "input_output/FGXMLElement.h"
using namespace std; using namespace std;
namespace JSBSim { namespace JSBSim {
static const char *IdSrc = "$Id: FGOutputFile.cpp,v 1.3 2012/12/15 16:13:57 bcoconni Exp $"; static const char *IdSrc = "$Id: FGOutputFile.cpp,v 1.4 2013/11/24 11:40:55 bcoconni Exp $";
static const char *IdHdr = ID_OUTPUTFILE; static const char *IdHdr = ID_OUTPUTFILE;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

View file

@ -54,12 +54,13 @@ INCLUDES
#include "models/FGGroundReactions.h" #include "models/FGGroundReactions.h"
#include "models/FGFCS.h" #include "models/FGFCS.h"
#include "models/atmosphere/FGWinds.h" #include "models/atmosphere/FGWinds.h"
#include "input_output/FGXMLElement.h"
using namespace std; using namespace std;
namespace JSBSim { namespace JSBSim {
static const char *IdSrc = "$Id: FGOutputSocket.cpp,v 1.5 2013/01/12 21:14:46 bcoconni Exp $"; static const char *IdSrc = "$Id: FGOutputSocket.cpp,v 1.6 2013/11/24 11:40:55 bcoconni Exp $";
static const char *IdHdr = ID_OUTPUTSOCKET; static const char *IdHdr = ID_OUTPUTSOCKET;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

View file

@ -58,12 +58,13 @@ INCLUDES
#include "models/FGBuoyantForces.h" #include "models/FGBuoyantForces.h"
#include "models/FGFCS.h" #include "models/FGFCS.h"
#include "models/atmosphere/FGWinds.h" #include "models/atmosphere/FGWinds.h"
#include "input_output/FGXMLElement.h"
using namespace std; using namespace std;
namespace JSBSim { namespace JSBSim {
static const char *IdSrc = "$Id: FGOutputTextFile.cpp,v 1.6 2013/09/11 12:51:13 jberndt Exp $"; static const char *IdSrc = "$Id: FGOutputTextFile.cpp,v 1.7 2013/11/24 11:40:55 bcoconni Exp $";
static const char *IdHdr = ID_OUTPUTTEXTFILE; static const char *IdHdr = ID_OUTPUTTEXTFILE;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

View file

@ -46,7 +46,7 @@ INCLUDES
namespace JSBSim { namespace JSBSim {
static const char *IdSrc = "$Id: FGOutputType.cpp,v 1.6 2013/01/26 17:06:49 bcoconni Exp $"; static const char *IdSrc = "$Id: FGOutputType.cpp,v 1.7 2013/09/27 19:45:40 jberndt Exp $";
static const char *IdHdr = ID_OUTPUTTYPE; static const char *IdHdr = ID_OUTPUTTYPE;
using namespace std; using namespace std;
@ -101,8 +101,7 @@ void FGOutputType::SetIdx(int idx)
bool FGOutputType::Load(Element* element) bool FGOutputType::Load(Element* element)
{ {
// Perform base class Load. // Perform base class Load.
if(!FGModel::Load(element)) // if(!FGModel::Load(element)) return false;
return false;
if (element->FindElementValue("simulation") == string("ON")) if (element->FindElementValue("simulation") == string("ON"))
SubSystems += ssSimulation; SubSystems += ssSimulation;

View file

@ -53,7 +53,7 @@ INCLUDES
DEFINITIONS DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#define ID_PROPERTYMANAGER "$Id: FGPropertyManager.h,v 1.26 2013/06/10 01:49:06 jberndt Exp $" #define ID_PROPERTYMANAGER "$Id: FGPropertyManager.h,v 1.28 2013/09/28 14:43:15 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS FORWARD DECLARATIONS
@ -393,7 +393,12 @@ class FGPropertyManager
{ return root->GetNode(path, create); } { return root->GetNode(path, create); }
FGPropertyNode* GetNode(const std::string &relpath, int index, bool create = false) FGPropertyNode* GetNode(const std::string &relpath, int index, bool create = false)
{ return root->GetNode(relpath, index, create); } { return root->GetNode(relpath, index, create); }
bool HasNode(const std::string& path) const { return root->HasNode(path); } bool HasNode(const std::string& path) const
{
std::string newPath = path;
if (newPath[0] == '-') newPath.erase(0,1);
return root->HasNode(newPath);
}
/** Property-ify a name /** Property-ify a name
* replaces spaces with '-' and, optionally, makes name all lower case * replaces spaces with '-' and, optionally, makes name all lower case

7
src/FDM/JSBSim/input_output/FGScript.cpp Normal file → Executable file
View file

@ -47,7 +47,7 @@ INCLUDES
#include "FGScript.h" #include "FGScript.h"
#include "input_output/FGXMLElement.h" #include "input_output/FGXMLElement.h"
#include "input_output/FGXMLParse.h" #include "input_output/FGXMLFileRead.h"
#include "initialization/FGTrim.h" #include "initialization/FGTrim.h"
#include "models/FGInput.h" #include "models/FGInput.h"
@ -55,7 +55,7 @@ using namespace std;
namespace JSBSim { namespace JSBSim {
static const char *IdSrc = "$Id: FGScript.cpp,v 1.52 2013/09/11 12:46:35 jberndt Exp $"; static const char *IdSrc = "$Id: FGScript.cpp,v 1.53 2013/11/24 11:40:55 bcoconni Exp $";
static const char *IdHdr = ID_FGSCRIPT; static const char *IdHdr = ID_FGSCRIPT;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -114,7 +114,8 @@ bool FGScript::LoadScript(string script, double deltaT, const string initfile)
struct event *newEvent; struct event *newEvent;
FGCondition *newCondition; FGCondition *newCondition;
document = LoadXMLDocument(script); FGXMLFileRead XMLFileRead;
Element* document = XMLFileRead.LoadXMLDocument(script);
if (!document) { if (!document) {
cerr << "File: " << script << " could not be loaded." << endl; cerr << "File: " << script << " could not be loaded." << endl;

View file

@ -43,13 +43,12 @@ INCLUDES
#include "FGJSBBase.h" #include "FGJSBBase.h"
#include "math/FGFunction.h" #include "math/FGFunction.h"
#include "math/FGCondition.h" #include "math/FGCondition.h"
#include "input_output/FGXMLFileRead.h"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DEFINITIONS DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#define ID_FGSCRIPT "$Id: FGScript.h,v 1.25 2013/09/11 12:46:35 jberndt Exp $" #define ID_FGSCRIPT "$Id: FGScript.h,v 1.27 2013/11/24 11:40:55 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS FORWARD DECLARATIONS
@ -158,14 +157,14 @@ CLASS DOCUMENTATION
comes the &quot;run&quot; section, where the conditions are comes the &quot;run&quot; section, where the conditions are
described in &quot;event&quot; clauses.</p> described in &quot;event&quot; clauses.</p>
@author Jon S. Berndt @author Jon S. Berndt
@version "$Id: FGScript.h,v 1.25 2013/09/11 12:46:35 jberndt Exp $" @version "$Id: FGScript.h,v 1.27 2013/11/24 11:40:55 bcoconni Exp $"
*/ */
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CLASS DECLARATION CLASS DECLARATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
class FGScript : public FGJSBBase, public FGXMLFileRead class FGScript : public FGJSBBase
{ {
public: public:
/// Default constructor /// Default constructor

98
src/FDM/JSBSim/input_output/FGXMLElement.cpp Normal file → Executable file
View file

@ -31,6 +31,7 @@ INCLUDES
#include <cmath> #include <cmath>
#include <cstdlib> #include <cstdlib>
#include <iostream> #include <iostream>
#include <sstream>
#include "FGXMLElement.h" #include "FGXMLElement.h"
#include "string_utilities.h" #include "string_utilities.h"
@ -43,7 +44,7 @@ FORWARD DECLARATIONS
namespace JSBSim { namespace JSBSim {
static const char *IdSrc = "$Id: FGXMLElement.cpp,v 1.39 2013/06/20 04:37:27 jberndt Exp $"; static const char *IdSrc = "$Id: FGXMLElement.cpp,v 1.41 2013/11/16 14:51:20 bcoconni Exp $";
static const char *IdHdr = ID_XMLELEMENT; static const char *IdHdr = ID_XMLELEMENT;
bool Element::converterIsInitialized = false; bool Element::converterIsInitialized = false;
@ -58,6 +59,7 @@ Element::Element(const string& nm)
name = nm; name = nm;
parent = 0L; parent = 0L;
element_index = 0; element_index = 0;
line_number = -1;
if (!converterIsInitialized) { if (!converterIsInitialized) {
converterIsInitialized = true; converterIsInitialized = true;
@ -279,8 +281,11 @@ double Element::GetAttributeValueAsNumber(const string& attr)
double number=0; double number=0;
if (is_number(trim(attribute))) if (is_number(trim(attribute)))
number = atof(attribute.c_str()); number = atof(attribute.c_str());
else else {
throw("Expecting numeric attribute value, but got: " + attribute); cerr << ReadFrom() << "Expecting numeric attribute value, but got: "
<< attribute << endl;
exit(-1);
}
return (number); return (number);
} }
@ -329,14 +334,18 @@ double Element::GetDataAsNumber(void)
double number=0; double number=0;
if (is_number(trim(data_lines[0]))) if (is_number(trim(data_lines[0])))
number = atof(data_lines[0].c_str()); number = atof(data_lines[0].c_str());
else else {
throw("Expected numeric value, but got: " + data_lines[0]); cerr << ReadFrom() << "Expected numeric value, but got: " << data_lines[0]
<< endl;
exit(-1);
}
return number; return number;
} else if (data_lines.size() == 0) { } else if (data_lines.size() == 0) {
return HUGE_VAL; return HUGE_VAL;
} else { } else {
cerr << "Attempting to get single data value from multiple lines in element " << name << endl; cerr << ReadFrom() << "Attempting to get single data value from multiple lines in element "
<< name << endl;
return HUGE_VAL; return HUGE_VAL;
} }
} }
@ -404,8 +413,9 @@ double Element::FindElementValueAsNumber(const string& el)
value = DisperseValue(element, value); value = DisperseValue(element, value);
return value; return value;
} else { } else {
cerr << "Attempting to get single data value from multiple lines" << endl; cerr << ReadFrom() << "Attempting to get non-existent element " << el
return 0; << endl;
exit(-1);
} }
} }
@ -428,27 +438,24 @@ double Element::FindElementValueAsNumberConvertTo(const string& el, const string
Element* element = FindElement(el); Element* element = FindElement(el);
if (!element) { if (!element) {
throw("Attempting to get the value of a non-existent element "+el); cerr << ReadFrom() << "Attempting to get non-existent element " << el
// cerr << "Attempting to get non-existent element " << el << endl; << endl;
// exit(0); exit(-1);
} }
string supplied_units = element->GetAttributeValue("unit"); string supplied_units = element->GetAttributeValue("unit");
if (!supplied_units.empty()) { if (!supplied_units.empty()) {
if (convert.find(supplied_units) == convert.end()) { if (convert.find(supplied_units) == convert.end()) {
throw("Supplied unit: \"" + supplied_units + "\" does not exist (typo?). Add new unit" cerr << element->ReadFrom() << "Supplied unit: \""
+ " conversion in FGXMLElement.cpp."); << supplied_units << "\" does not exist (typo?)." << endl;
// cerr << endl << "Supplied unit: \"" << supplied_units << "\" does not exist (typo?). Add new unit" exit(-1);
// << " conversion in FGXMLElement.cpp." << endl;
// exit(-1);
} }
if (convert[supplied_units].find(target_units) == convert[supplied_units].end()) { if (convert[supplied_units].find(target_units) == convert[supplied_units].end()) {
throw("Supplied unit: \"" + supplied_units + "\" cannot be converted to " cerr << element->ReadFrom() << "Supplied unit: \""
+ target_units + ". Add new unit conversion in FGXMLElement.cpp or fix typo"); << supplied_units << "\" cannot be converted to " << target_units
// cerr << endl << "Supplied unit: \"" << supplied_units << "\" cannot be converted to " << endl;
// << target_units << ". Add new unit conversion in FGXMLElement.cpp or fix typo" << endl; exit(-1);
// exit(-1);
} }
} }
@ -472,18 +479,19 @@ double Element::FindElementValueAsNumberConvertFromTo( const string& el,
if (!element) { if (!element) {
cerr << "Attempting to get non-existent element " << el << endl; cerr << "Attempting to get non-existent element " << el << endl;
exit(0); exit(-1);
} }
if (!supplied_units.empty()) { if (!supplied_units.empty()) {
if (convert.find(supplied_units) == convert.end()) { if (convert.find(supplied_units) == convert.end()) {
cerr << endl << "Supplied unit: \"" << supplied_units << "\" does not exist (typo?). Add new unit" cerr << element->ReadFrom() << "Supplied unit: \""
<< " conversion in FGXMLElement.cpp." << endl; << supplied_units << "\" does not exist (typo?)." << endl;
exit(-1); exit(-1);
} }
if (convert[supplied_units].find(target_units) == convert[supplied_units].end()) { if (convert[supplied_units].find(target_units) == convert[supplied_units].end()) {
cerr << endl << "Supplied unit: \"" << supplied_units << "\" cannot be converted to " cerr << element->ReadFrom() << "Supplied unit: \""
<< target_units << ". Add new unit conversion in FGXMLElement.cpp or fix typo" << endl; << supplied_units << "\" cannot be converted to " << target_units
<< endl;
exit(-1); exit(-1);
} }
} }
@ -509,13 +517,14 @@ FGColumnVector3 Element::FindElementTripletConvertTo( const string& target_units
if (!supplied_units.empty()) { if (!supplied_units.empty()) {
if (convert.find(supplied_units) == convert.end()) { if (convert.find(supplied_units) == convert.end()) {
cerr << endl << "Supplied unit: \"" << supplied_units << "\" does not exist (typo?). Add new unit" cerr << ReadFrom() << "Supplied unit: \""
<< " conversion in FGXMLElement.cpp." << endl; << supplied_units << "\" does not exist (typo?)." << endl;
exit(-1); exit(-1);
} }
if (convert[supplied_units].find(target_units) == convert[supplied_units].end()) { if (convert[supplied_units].find(target_units) == convert[supplied_units].end()) {
cerr << endl << "Supplied unit: \"" << supplied_units << "\" cannot be converted to " cerr << ReadFrom() << "Supplied unit: \""
<< target_units << ". Add new unit conversion in FGXMLElement.cpp or fix typo" << endl; << supplied_units << "\" cannot be converted to " << target_units
<< endl;
exit(-1); exit(-1);
} }
} }
@ -565,12 +574,22 @@ double Element::DisperseValue(Element *e, double val, const std::string supplied
if (!supplied_units.empty()) disp *= convert[supplied_units][target_units]; if (!supplied_units.empty()) disp *= convert[supplied_units][target_units];
string attType = e->GetAttributeValue("type"); string attType = e->GetAttributeValue("type");
if (attType == "gaussian") { if (attType == "gaussian") {
value = val + disp*GaussianRandomNumber(); double grn = GaussianRandomNumber();
value = val + disp*grn;
/* std::cout << "DISPERSION GAUSSIAN: Initial: " << val
<< " Dispersion: " << disp
<< " Gaussian Rand Num: " << grn
<< " Total Dispersed Value: " << value << endl; */
} else if (attType == "uniform") { } else if (attType == "uniform") {
value = val + disp * ((((double)rand()/RAND_MAX)-0.5)*2.0); double urn = ((((double)rand()/RAND_MAX)-0.5)*2.0);
value = val + disp * urn;
/* std::cout << "DISPERSION UNIFORM: Initial: " << val
<< " Dispersion: " << disp
<< " Uniform Rand Num: " << urn
<< " Total Dispersed Value: " << value << endl; */
} else { } else {
std::cerr << "Unknown dispersion type" << endl; cerr << ReadFrom() << "Unknown dispersion type" << attType << endl;
throw("Unknown dispersion type"); exit(-1);
} }
} }
@ -649,4 +668,15 @@ void Element::AddData(string d)
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
string Element::ReadFrom(void) const
{
ostringstream message;
message << endl
<< "In file " << GetFileName() << ": line " << GetLineNumber()
<< endl;
return message.str();
}
} // end namespace JSBSim } // end namespace JSBSim

33
src/FDM/JSBSim/input_output/FGXMLElement.h Normal file → Executable file
View file

@ -44,7 +44,7 @@ INCLUDES
DEFINITIONS DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#define ID_XMLELEMENT "$Id: FGXMLElement.h,v 1.17 2012/07/26 04:33:46 jberndt Exp $" #define ID_XMLELEMENT "$Id: FGXMLElement.h,v 1.18 2013/11/16 14:51:20 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS FORWARD DECLARATIONS
@ -136,7 +136,7 @@ CLASS DOCUMENTATION
- GAL = gallon (U.S. liquid) - GAL = gallon (U.S. liquid)
@author Jon S. Berndt @author Jon S. Berndt
@version $Id: FGXMLElement.h,v 1.17 2012/07/26 04:33:46 jberndt Exp $ @version $Id: FGXMLElement.h,v 1.18 2013/11/16 14:51:20 bcoconni Exp $
*/ */
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -218,6 +218,16 @@ public:
@return a pointer to the parent Element, or 0 if this is the top level Element. */ @return a pointer to the parent Element, or 0 if this is the top level Element. */
Element* GetParent(void) {return parent;} Element* GetParent(void) {return parent;}
/** Returns the line number at which the element has been defined.
@return the line number
*/
int GetLineNumber(void) const { return line_number; }
/** Returns the name of the file in which the element has been read.
@return the file name
*/
const std::string& GetFileName(void) const { return file_name; }
/** Searches for a specified element. /** Searches for a specified element.
Finds the first element that matches the supplied string, or simply the first Finds the first element that matches the supplied string, or simply the first
element if no search string is supplied. This function call resets the internal element if no search string is supplied. This function call resets the internal
@ -331,6 +341,23 @@ public:
* @param d The tab level. A level corresponds to a single space. */ * @param d The tab level. A level corresponds to a single space. */
void Print(unsigned int level=0); void Print(unsigned int level=0);
/** Set the line number at which the element has been read.
* @param line line number.
*/
void SetLineNumber(int line) { line_number = line; }
/** Set the name of the file in which the element has been read.
* @param name file name
*/
void SetFileName(const std::string& name) { file_name = name; }
/** Return a string that contains a description of the location where the
* current XML element was read from.
* @return a string describing the file name and line number where the
* element was read.
*/
std::string ReadFrom(void) const;
private: private:
std::string name; std::string name;
std::map <std::string, std::string> attributes; std::map <std::string, std::string> attributes;
@ -339,6 +366,8 @@ private:
std::vector <std::string> attribute_key; std::vector <std::string> attribute_key;
Element *parent; Element *parent;
unsigned int element_index; unsigned int element_index;
std::string file_name;
int line_number;
typedef std::map <std::string, std::map <std::string, double> > tMapConvert; typedef std::map <std::string, std::map <std::string, double> > tMapConvert;
static tMapConvert convert; static tMapConvert convert;
static bool converterIsInitialized; static bool converterIsInitialized;

12
src/FDM/JSBSim/input_output/FGXMLFileRead.h Normal file → Executable file
View file

@ -43,7 +43,7 @@ INCLUDES
DEFINITIONS DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#define ID_XMLFILEREAD "$Id: FGXMLFileRead.h,v 1.7 2012/12/12 06:19:57 jberndt Exp $" #define ID_XMLFILEREAD "$Id: FGXMLFileRead.h,v 1.8 2013/11/24 11:40:55 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS FORWARD DECLARATIONS
@ -56,13 +56,11 @@ public:
FGXMLFileRead(void) {} FGXMLFileRead(void) {}
~FGXMLFileRead(void) {} ~FGXMLFileRead(void) {}
protected:
Element* document;
Element* LoadXMLDocument(std::string XML_filename, bool verbose=true) Element* LoadXMLDocument(std::string XML_filename, bool verbose=true)
{ {
return LoadXMLDocument(XML_filename, file_parser, true); return LoadXMLDocument(XML_filename, file_parser, true);
} }
Element* LoadXMLDocument(std::string XML_filename, FGXMLParse& fparse, bool verbose=true) Element* LoadXMLDocument(std::string XML_filename, FGXMLParse& fparse, bool verbose=true)
{ {
std::ifstream infile; std::ifstream infile;
@ -80,12 +78,12 @@ protected:
} }
readXML(infile, fparse, XML_filename); readXML(infile, fparse, XML_filename);
document = fparse.GetDocument(); Element* document = fparse.GetDocument();
infile.close(); infile.close();
return document; return document;
} }
void ResetParser(void) {file_parser.reset();} void ResetParser(void) {file_parser.reset();}
private: private:

8
src/FDM/JSBSim/input_output/FGXMLParse.cpp Normal file → Executable file
View file

@ -40,7 +40,7 @@ using namespace std;
namespace JSBSim { namespace JSBSim {
static const char *IdSrc = "$Id: FGXMLParse.cpp,v 1.11 2010/09/28 02:54:03 jberndt Exp $"; static const char *IdSrc = "$Id: FGXMLParse.cpp,v 1.12 2013/11/16 14:51:20 bcoconni Exp $";
static const char *IdHdr = ID_XMLPARSE; static const char *IdHdr = ID_XMLPARSE;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -107,10 +107,14 @@ void FGXMLParse::startElement (const char * name, const XMLAttributes &atts)
} }
if (current_element == 0L) { if (current_element == 0L) {
cerr << "No current element read (no top-level element in XML file?)" << endl; cerr << "In file " << getPath() << ": line " << getLine() << endl
<< "No current element read (running out of memory?)" << endl;
exit (-1); exit (-1);
} }
current_element->SetLineNumber(getLine());
current_element->SetFileName(getPath());
for (int i=0; i<atts.size();i++) { for (int i=0; i<atts.size();i++) {
current_element->AddAttribute(atts.getName(i), atts.getValue(i)); current_element->AddAttribute(atts.getName(i), atts.getValue(i));
} }

View file

@ -6,7 +6,7 @@
// //
// This file is in the Public Domain, and comes with no warranty. // This file is in the Public Domain, and comes with no warranty.
// //
// $Id: net_fdm.hxx,v 1.5 2011/11/10 12:06:14 jberndt Exp $ // $Id: net_fdm.hxx,v 1.6 2013/11/09 14:06:36 bcoconni Exp $
#ifndef _NET_FDM_HXX #ifndef _NET_FDM_HXX
@ -61,12 +61,9 @@ public:
float v_north; // north velocity in local/body frame, fps float v_north; // north velocity in local/body frame, fps
float v_east; // east velocity in local/body frame, fps float v_east; // east velocity in local/body frame, fps
float v_down; // down/vertical velocity in local/body frame, fps float v_down; // down/vertical velocity in local/body frame, fps
float v_wind_body_north; // north velocity in local/body frame float v_body_u; // ECEF velocity in body axis
// relative to local airmass, fps float v_body_v; // ECEF velocity in body axis
float v_wind_body_east; // east velocity in local/body frame float v_body_w; // ECEF velocity in body axis
// relative to local airmass, fps
float v_wind_body_down; // down/vertical velocity in local/body
// frame relative to local airmass, fps
// Accelerations // Accelerations
float A_X_pilot; // X accel in body frame ft/sec^2 float A_X_pilot; // X accel in body frame ft/sec^2

View file

@ -39,6 +39,8 @@ INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#include <string> #include <string>
#include <sstream>
#include <iostream>
#include <vector> #include <vector>
#include <stdio.h> #include <stdio.h>
@ -46,7 +48,7 @@ INCLUDES
DEFINITIONS DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#define ID_STRINGUTILS "$Id: string_utilities.h,v 1.15 2012/11/17 19:31:26 bcoconni Exp $" #define ID_STRINGUTILS "$Id: string_utilities.h,v 1.16 2013/11/17 05:14:21 jberndt Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS FORWARD DECLARATIONS
@ -70,7 +72,10 @@ CLASS DECLARATION
extern std::string& to_lower(std::string& str); extern std::string& to_lower(std::string& str);
extern bool is_number(const std::string& str); extern bool is_number(const std::string& str);
std::vector <std::string> split(std::string str, char d); std::vector <std::string> split(std::string str, char d);
/* Comment out to_string functions when they are defined already - C++ 11 defines these */
extern std::string to_string(int); extern std::string to_string(int);
extern std::string to_string(double);
extern std::string to_string(float);
extern std::string replace(std::string str, const std::string& old, const std::string& newstr); extern std::string replace(std::string str, const std::string& old, const std::string& newstr);
#else #else
#include <cctype> #include <cctype>
@ -153,7 +158,7 @@ CLASS DECLARATION
return str_array; return str_array;
} }
/* Comment out to_string functions when they are defined already - C++ 11 defines these */
string to_string(int i) string to_string(int i)
{ {
char buffer[32]; char buffer[32];
@ -161,6 +166,20 @@ CLASS DECLARATION
return string(buffer); return string(buffer);
} }
string to_string(float x)
{
std::ostringstream o;
if (!(o << x)) cerr << "Bad float to string conversion" << endl;
return o.str();
}
string to_string(double x)
{
std::ostringstream o;
if (!(o << x)) cerr << "Bad double to string conversion" << endl;
return o.str();
}
string replace(string str, const string& oldstr, const string& newstr) string replace(string str, const string& oldstr, const string& newstr)
{ {
int old_idx; int old_idx;

9
src/FDM/JSBSim/math/FGFunction.cpp Normal file → Executable file
View file

@ -43,7 +43,7 @@ using namespace std;
namespace JSBSim { namespace JSBSim {
static const char *IdSrc = "$Id: FGFunction.cpp,v 1.51 2013/09/11 12:49:36 jberndt Exp $"; static const char *IdSrc = "$Id: FGFunction.cpp,v 1.53 2013/09/27 19:42:08 jberndt Exp $";
static const char *IdHdr = ID_FUNCTION; static const char *IdHdr = ID_FUNCTION;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -807,9 +807,10 @@ void FGFunction::bind(void)
} }
if (PropertyManager->HasNode(tmp)) { if (PropertyManager->HasNode(tmp)) {
FGPropertyNode* property = PropertyManager->GetNode(tmp); FGPropertyNode* _property = PropertyManager->GetNode(tmp);
if (property->isTied()) { if (_property->isTied()) {
cout << "Property " << tmp << " has already been successfully bound (late)." << endl; cout << "Property " << tmp << " has already been successfully bound (late)." << endl;
throw("Failed to bind the property to an existing already tied node.");
} }
} }
PropertyManager->Tie( tmp, this, &FGFunction::GetValue); PropertyManager->Tie( tmp, this, &FGFunction::GetValue);

View file

@ -44,11 +44,10 @@ INCLUDES
#include <cmath> #include <cmath>
#include "FGLocation.h" #include "FGLocation.h"
#include "input_output/FGPropertyManager.h"
namespace JSBSim { namespace JSBSim {
static const char *IdSrc = "$Id: FGLocation.cpp,v 1.29 2012/04/14 12:14:37 bcoconni Exp $"; static const char *IdSrc = "$Id: FGLocation.cpp,v 1.30 2013/10/19 17:59:51 bcoconni Exp $";
static const char *IdHdr = ID_LOCATION; static const char *IdHdr = ID_LOCATION;
using std::cerr; using std::cerr;
using std::endl; using std::endl;

View file

@ -42,8 +42,9 @@ SENTRY
INCLUDES INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#include <iostream>
#include "FGJSBBase.h" #include "FGJSBBase.h"
#include "input_output/FGPropertyManager.h"
#include "FGColumnVector3.h" #include "FGColumnVector3.h"
#include "FGMatrix33.h" #include "FGMatrix33.h"
#include "input_output/FGGroundCallback.h" #include "input_output/FGGroundCallback.h"
@ -52,7 +53,7 @@ INCLUDES
DEFINITIONS DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#define ID_LOCATION "$Id: FGLocation.h,v 1.31 2012/02/05 14:56:17 bcoconni Exp $" #define ID_LOCATION "$Id: FGLocation.h,v 1.32 2013/10/19 17:59:51 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS FORWARD DECLARATIONS
@ -151,7 +152,7 @@ CLASS DOCUMENTATION
@see W. C. Durham "Aircraft Dynamics & Control", section 2.2 @see W. C. Durham "Aircraft Dynamics & Control", section 2.2
@author Mathias Froehlich @author Mathias Froehlich
@version $Id: FGLocation.h,v 1.31 2012/02/05 14:56:17 bcoconni Exp $ @version $Id: FGLocation.h,v 1.32 2013/10/19 17:59:51 bcoconni Exp $
*/ */
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

3
src/FDM/JSBSim/math/FGModelFunctions.cpp Normal file → Executable file
View file

@ -41,12 +41,13 @@ INCLUDES
#include <sstream> #include <sstream>
#include <string> #include <string>
#include "FGModelFunctions.h" #include "FGModelFunctions.h"
#include "input_output/FGXMLElement.h"
using namespace std; using namespace std;
namespace JSBSim { namespace JSBSim {
static const char *IdSrc = "$Id: FGModelFunctions.cpp,v 1.6 2012/09/05 05:00:57 jberndt Exp $"; static const char *IdSrc = "$Id: FGModelFunctions.cpp,v 1.7 2013/11/24 11:40:55 bcoconni Exp $";
static const char *IdHdr = ID_MODELFUNCTIONS; static const char *IdHdr = ID_MODELFUNCTIONS;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

3
src/FDM/JSBSim/math/FGModelFunctions.h Normal file → Executable file
View file

@ -38,13 +38,12 @@ INCLUDES
#include <vector> #include <vector>
#include "math/FGFunction.h" #include "math/FGFunction.h"
#include "input_output/FGPropertyManager.h" #include "input_output/FGPropertyManager.h"
#include "input_output/FGXMLElement.h"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DEFINITIONS DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#define ID_MODELFUNCTIONS "$Id: FGModelFunctions.h,v 1.5 2012/04/13 13:25:52 jberndt Exp $" #define ID_MODELFUNCTIONS "$Id: FGModelFunctions.h,v 1.6 2013/11/24 11:40:55 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS FORWARD DECLARATIONS

13
src/FDM/JSBSim/math/FGPropertyValue.cpp Normal file → Executable file
View file

@ -34,7 +34,7 @@ INCLUDES
namespace JSBSim { namespace JSBSim {
static const char *IdSrc = "$Id: FGPropertyValue.cpp,v 1.8 2013/01/26 17:06:49 bcoconni Exp $"; static const char *IdSrc = "$Id: FGPropertyValue.cpp,v 1.9 2013/09/27 19:42:53 jberndt Exp $";
static const char *IdHdr = ID_PROPERTYVALUE; static const char *IdHdr = ID_PROPERTYVALUE;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -44,13 +44,20 @@ CLASS IMPLEMENTATION
FGPropertyValue::FGPropertyValue(FGPropertyNode* propNode) FGPropertyValue::FGPropertyValue(FGPropertyNode* propNode)
: PropertyManager(0L), PropertyNode(propNode) : PropertyManager(0L), PropertyNode(propNode)
{ {
Sign = 1;
} }
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FGPropertyValue::FGPropertyValue(std::string propName, FGPropertyManager* propertyManager) FGPropertyValue::FGPropertyValue(std::string propName, FGPropertyManager* propertyManager)
: PropertyManager(propertyManager), PropertyNode(0L), PropertyName(propName) : PropertyManager(propertyManager), PropertyNode(0L)
{ {
Sign = 1;
if (propName[0] == '-') {
propName.erase(0,1);
Sign = -1;
}
PropertyName = propName;
} }
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -69,7 +76,7 @@ double FGPropertyValue::GetValue(void) const
} }
} }
return node->getDoubleValue(); return node->getDoubleValue()*Sign;
} }
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

3
src/FDM/JSBSim/math/FGPropertyValue.h Normal file → Executable file
View file

@ -42,7 +42,7 @@ INCLUDES
DEFINITIONS DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#define ID_PROPERTYVALUE "$Id: FGPropertyValue.h,v 1.10 2013/01/26 17:06:49 bcoconni Exp $" #define ID_PROPERTYVALUE "$Id: FGPropertyValue.h,v 1.11 2013/09/27 19:43:01 jberndt Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS FORWARD DECLARATIONS
@ -79,6 +79,7 @@ private:
FGPropertyManager* PropertyManager; // Property root used to do late binding. FGPropertyManager* PropertyManager; // Property root used to do late binding.
FGPropertyNode_ptr PropertyNode; FGPropertyNode_ptr PropertyNode;
std::string PropertyName; std::string PropertyName;
int Sign;
}; };
} // namespace JSBSim } // namespace JSBSim

View file

@ -48,7 +48,7 @@ SENTRY
DEFINITIONS DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#define ID_QUATERNION "$Id: FGQuaternion.h,v 1.25 2012/09/05 05:00:57 jberndt Exp $" #define ID_QUATERNION "$Id: FGQuaternion.h,v 1.26 2013/11/24 16:53:15 bcoconni Exp $"
namespace JSBSim { namespace JSBSim {
@ -149,6 +149,27 @@ public:
} }
} }
/** Initializer by a rotation axis and an angle.
Initialize the quaternion to represent the rotation around a given
angle and an arbitrary axis.
@param angle The angle in radians
@param axis The rotation axis
*/
FGQuaternion(double angle, const FGColumnVector3& axis)
: mCacheValid(false) {
double angle2 = 0.5 * angle;
double length = axis.Magnitude();
double Sangle2 = sin(angle2) / length;
double Cangle2 = cos(angle2);
data[0] = Cangle2;
data[1] = Sangle2 * axis(1);
data[2] = Sangle2 * axis(2);
data[3] = Sangle2 * axis(3);
}
/** Initializer by matrix. /** Initializer by matrix.
Initialize the quaternion with the matrix representing a transform from one frame Initialize the quaternion with the matrix representing a transform from one frame
to another using the standard aerospace sequence, Yaw-Pitch-Roll (3-2-1). to another using the standard aerospace sequence, Yaw-Pitch-Roll (3-2-1).

View file

@ -43,12 +43,14 @@ INCLUDES
#include "FGFDMExec.h" #include "FGFDMExec.h"
#include "FGAerodynamics.h" #include "FGAerodynamics.h"
#include "input_output/FGPropertyManager.h" #include "input_output/FGPropertyManager.h"
#include "input_output/FGXMLFileRead.h"
#include "input_output/FGXMLElement.h"
using namespace std; using namespace std;
namespace JSBSim { namespace JSBSim {
static const char *IdSrc = "$Id: FGAerodynamics.cpp,v 1.48 2013/09/11 12:42:14 jberndt Exp $"; static const char *IdSrc = "$Id: FGAerodynamics.cpp,v 1.49 2013/11/24 11:40:55 bcoconni Exp $";
static const char *IdHdr = ID_AERODYNAMICS; static const char *IdHdr = ID_AERODYNAMICS;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -284,11 +286,13 @@ bool FGAerodynamics::Load(Element *element)
Element *temp_element, *axis_element, *function_element; Element *temp_element, *axis_element, *function_element;
string separator = "/"; string separator = "/";
FGXMLFileRead XMLFileRead;
Element* document;
fname = element->GetAttributeValue("file"); fname = element->GetAttributeValue("file");
if (!fname.empty()) { if (!fname.empty()) {
file = FDMExec->GetFullAircraftPath() + separator + fname; file = FDMExec->GetFullAircraftPath() + separator + fname;
document = LoadXMLDocument(file); document = XMLFileRead.LoadXMLDocument(file);
if (document == 0L) return false; if (document == 0L) return false;
} else { } else {
document = element; document = element;
@ -296,7 +300,7 @@ bool FGAerodynamics::Load(Element *element)
FGModel::Load(document); // Perform base class Pre-Load FGModel::Load(document); // Perform base class Pre-Load
DetermineAxisSystem(); // Detemine if Lift/Side/Drag, etc. is used. DetermineAxisSystem(document); // Detemine if Lift/Side/Drag, etc. is used.
Debug(2); Debug(2);
@ -370,7 +374,7 @@ bool FGAerodynamics::Load(Element *element)
// This is OK, and the warning is due to the SIDE specifier used for both // This is OK, and the warning is due to the SIDE specifier used for both
// the Lift/Drag and Axial/Normal axis systems. // the Lift/Drag and Axial/Normal axis systems.
void FGAerodynamics::DetermineAxisSystem() void FGAerodynamics::DetermineAxisSystem(Element* document)
{ {
Element* axis_element = document->FindElement("axis"); Element* axis_element = document->FindElement("axis");
string axis; string axis;

View file

@ -46,13 +46,12 @@ INCLUDES
#include "math/FGFunction.h" #include "math/FGFunction.h"
#include "math/FGColumnVector3.h" #include "math/FGColumnVector3.h"
#include "math/FGMatrix33.h" #include "math/FGMatrix33.h"
#include "input_output/FGXMLFileRead.h"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DEFINITIONS DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#define ID_AERODYNAMICS "$Id: FGAerodynamics.h,v 1.27 2013/09/11 12:42:14 jberndt Exp $" #define ID_AERODYNAMICS "$Id: FGAerodynamics.h,v 1.29 2013/11/24 11:40:55 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS FORWARD DECLARATIONS
@ -109,14 +108,14 @@ CLASS DOCUMENTATION
Systems may NOT be combined, or a load error will occur. Systems may NOT be combined, or a load error will occur.
@author Jon S. Berndt, Tony Peden @author Jon S. Berndt, Tony Peden
@version $Revision: 1.27 $ @version $Revision: 1.29 $
*/ */
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CLASS DECLARATION CLASS DECLARATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
class FGAerodynamics : public FGModel, public FGXMLFileRead class FGAerodynamics : public FGModel
{ {
public: public:
@ -252,7 +251,7 @@ private:
double clsq, lod, qbar_area; double clsq, lod, qbar_area;
typedef double (FGAerodynamics::*PMF)(int) const; typedef double (FGAerodynamics::*PMF)(int) const;
void DetermineAxisSystem(void); void DetermineAxisSystem(Element* document);
void bind(void); void bind(void);
void Debug(int from); void Debug(int from);

View file

@ -46,6 +46,7 @@ INCLUDES
#include "FGAircraft.h" #include "FGAircraft.h"
#include "FGFDMExec.h" #include "FGFDMExec.h"
#include "input_output/FGPropertyManager.h" #include "input_output/FGPropertyManager.h"
#include "input_output/FGXMLElement.h"
using namespace std; using namespace std;
@ -59,7 +60,7 @@ DEFINITIONS
GLOBAL DATA GLOBAL DATA
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
static const char *IdSrc = "$Id: FGAircraft.cpp,v 1.34 2012/09/15 17:00:56 bcoconni Exp $"; static const char *IdSrc = "$Id: FGAircraft.cpp,v 1.35 2013/11/24 11:40:55 bcoconni Exp $";
static const char *IdHdr = ID_AIRCRAFT; static const char *IdHdr = ID_AIRCRAFT;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

View file

@ -42,7 +42,6 @@ INCLUDES
#include <vector> #include <vector>
#include "FGModel.h" #include "FGModel.h"
#include "input_output/FGXMLElement.h"
#include "math/FGColumnVector3.h" #include "math/FGColumnVector3.h"
#include "math/FGMatrix33.h" #include "math/FGMatrix33.h"
@ -50,7 +49,7 @@ INCLUDES
DEFINITIONS DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#define ID_AIRCRAFT "$Id: FGAircraft.h,v 1.20 2012/09/15 17:00:56 bcoconni Exp $" #define ID_AIRCRAFT "$Id: FGAircraft.h,v 1.21 2013/11/24 11:40:55 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS FORWARD DECLARATIONS
@ -91,7 +90,7 @@ CLASS DOCUMENTATION
@endcode @endcode
@author Jon S. Berndt @author Jon S. Berndt
@version $Id: FGAircraft.h,v 1.20 2012/09/15 17:00:56 bcoconni Exp $ @version $Id: FGAircraft.h,v 1.21 2013/11/24 11:40:55 bcoconni Exp $
@see Cooke, Zyda, Pratt, and McGhee, "NPSNET: Flight Simulation Dynamic Modeling @see Cooke, Zyda, Pratt, and McGhee, "NPSNET: Flight Simulation Dynamic Modeling
Using Quaternions", Presence, Vol. 1, No. 4, pp. 404-420 Naval Postgraduate Using Quaternions", Presence, Vol. 1, No. 4, pp. 404-420 Naval Postgraduate
School, January 1994 School, January 1994

View file

@ -36,16 +36,19 @@ HISTORY
INCLUDES INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#include <iostream>
#include "FGBuoyantForces.h" #include "FGBuoyantForces.h"
#include "FGMassBalance.h" #include "FGMassBalance.h"
#include "input_output/FGPropertyManager.h" #include "input_output/FGPropertyManager.h"
#include <iostream> #include "input_output/FGXMLFileRead.h"
#include "input_output/FGXMLElement.h"
using namespace std; using namespace std;
namespace JSBSim { namespace JSBSim {
static const char *IdSrc = "$Id: FGBuoyantForces.cpp,v 1.21 2011/10/31 14:54:41 bcoconni Exp $"; static const char *IdSrc = "$Id: FGBuoyantForces.cpp,v 1.22 2013/11/24 11:40:55 bcoconni Exp $";
static const char *IdHdr = ID_BUOYANTFORCES; static const char *IdHdr = ID_BUOYANTFORCES;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -117,11 +120,13 @@ bool FGBuoyantForces::Load(Element *element)
Debug(2); Debug(2);
string separator = "/"; string separator = "/";
FGXMLFileRead XMLFileRead;
Element* document;
fname = element->GetAttributeValue("file"); fname = element->GetAttributeValue("file");
if (!fname.empty()) { if (!fname.empty()) {
file = FDMExec->GetFullAircraftPath() + separator + fname; file = FDMExec->GetFullAircraftPath() + separator + fname;
document = LoadXMLDocument(file); document = XMLFileRead.LoadXMLDocument(file);
} else { } else {
document = element; document = element;
} }

View file

@ -45,13 +45,12 @@ INCLUDES
#include "FGModel.h" #include "FGModel.h"
#include "FGGasCell.h" #include "FGGasCell.h"
#include "math/FGColumnVector3.h" #include "math/FGColumnVector3.h"
#include "input_output/FGXMLFileRead.h"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DEFINITIONS DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#define ID_BUOYANTFORCES "$Id: FGBuoyantForces.h,v 1.16 2011/10/31 14:54:41 bcoconni Exp $" #define ID_BUOYANTFORCES "$Id: FGBuoyantForces.h,v 1.18 2013/11/24 11:40:55 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS FORWARD DECLARATIONS
@ -96,14 +95,14 @@ CLASS DOCUMENTATION
See FGGasCell for the full configuration file format for gas cells. See FGGasCell for the full configuration file format for gas cells.
@author Anders Gidenstam, Jon S. Berndt @author Anders Gidenstam, Jon S. Berndt
@version $Id: FGBuoyantForces.h,v 1.16 2011/10/31 14:54:41 bcoconni Exp $ @version $Id: FGBuoyantForces.h,v 1.18 2013/11/24 11:40:55 bcoconni Exp $
*/ */
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CLASS DECLARATION CLASS DECLARATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
class FGBuoyantForces : public FGModel, public FGXMLFileRead class FGBuoyantForces : public FGModel
{ {
public: public:

12
src/FDM/JSBSim/models/FGExternalReactions.cpp Normal file → Executable file
View file

@ -36,11 +36,13 @@ HISTORY
INCLUDES INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#include "FGExternalReactions.h"
#include "input_output/FGXMLElement.h"
#include <iostream> #include <iostream>
#include <string> #include <string>
#include "FGExternalReactions.h"
#include "input_output/FGXMLFileRead.h"
#include "input_output/FGXMLElement.h"
using namespace std; using namespace std;
namespace JSBSim { namespace JSBSim {
@ -53,7 +55,7 @@ DEFINITIONS
GLOBAL DATA GLOBAL DATA
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
static const char *IdSrc = "$Id: FGExternalReactions.cpp,v 1.12 2011/07/20 12:16:34 jberndt Exp $"; static const char *IdSrc = "$Id: FGExternalReactions.cpp,v 1.13 2013/11/24 11:40:56 bcoconni Exp $";
static const char *IdHdr = ID_EXTERNALREACTIONS; static const char *IdHdr = ID_EXTERNALREACTIONS;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -73,9 +75,11 @@ bool FGExternalReactions::Load(Element* el)
{ {
// check if a file attribute was specified // check if a file attribute was specified
string fname = el->GetAttributeValue("file"); string fname = el->GetAttributeValue("file");
FGXMLFileRead XMLFileRead;
if (!fname.empty()) { if (!fname.empty()) {
string file = FDMExec->GetFullAircraftPath() + "/" + fname; string file = FDMExec->GetFullAircraftPath() + "/" + fname;
el = LoadXMLDocument(file); el = XMLFileRead.LoadXMLDocument(file);
if (el == 0L) return false; if (el == 0L) return false;
} }

6
src/FDM/JSBSim/models/FGExternalReactions.h Normal file → Executable file
View file

@ -41,14 +41,12 @@ INCLUDES
#include <vector> #include <vector>
#include "FGModel.h" #include "FGModel.h"
#include "FGExternalForce.h" #include "FGExternalForce.h"
#include "input_output/FGXMLFileRead.h"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DEFINITIONS DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#define ID_EXTERNALREACTIONS "$Id: FGExternalReactions.h,v 1.14 2011/10/31 14:54:41 bcoconni Exp $" #define ID_EXTERNALREACTIONS "$Id: FGExternalReactions.h,v 1.15 2013/11/24 11:40:56 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS FORWARD DECLARATIONS
@ -117,7 +115,7 @@ CLASS DOCUMENTATION
CLASS DECLARATION CLASS DECLARATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
class FGExternalReactions : public FGModel, public FGXMLFileRead class FGExternalReactions : public FGModel
{ {
public: public:
/** Constructor. /** Constructor.

View file

@ -45,6 +45,8 @@ INCLUDES
#include "FGFDMExec.h" #include "FGFDMExec.h"
#include "FGGroundReactions.h" #include "FGGroundReactions.h"
#include "input_output/FGPropertyManager.h" #include "input_output/FGPropertyManager.h"
#include "input_output/FGXMLFileRead.h"
#include "input_output/FGXMLElement.h"
#include "models/flight_control/FGFilter.h" #include "models/flight_control/FGFilter.h"
#include "models/flight_control/FGDeadBand.h" #include "models/flight_control/FGDeadBand.h"
@ -61,6 +63,7 @@ INCLUDES
#include "models/flight_control/FGGyro.h" #include "models/flight_control/FGGyro.h"
#include "models/flight_control/FGWaypoint.h" #include "models/flight_control/FGWaypoint.h"
#include "models/flight_control/FGAngles.h" #include "models/flight_control/FGAngles.h"
#include "models/flight_control/FGDistributor.h"
#include "FGFCSChannel.h" #include "FGFCSChannel.h"
@ -68,7 +71,7 @@ using namespace std;
namespace JSBSim { namespace JSBSim {
static const char *IdSrc = "$Id: FGFCS.cpp,v 1.81 2013/06/20 04:37:27 jberndt Exp $"; static const char *IdSrc = "$Id: FGFCS.cpp,v 1.83 2013/11/24 11:40:56 bcoconni Exp $";
static const char *IdHdr = ID_FCS; static const char *IdHdr = ID_FCS;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -174,7 +177,10 @@ bool FGFCS::Run(bool Holding)
} }
// Execute system channels in order // Execute system channels in order
for (i=0; i<SystemChannels.size(); i++) SystemChannels[i]->Execute(); for (i=0; i<SystemChannels.size(); i++) {
if (debug_lvl & 4) cout << " Executing System Channel: " << SystemChannels[i]->GetName() << endl;
SystemChannels[i]->Execute();
}
RunPostFunctions(); RunPostFunctions();
@ -485,6 +491,8 @@ bool FGFCS::Load(Element* el, SystemType systype)
string name, file, fname="", interface_property_string, parent_name; string name, file, fname="", interface_property_string, parent_name;
Element *component_element; Element *component_element;
Element *channel_element; Element *channel_element;
FGXMLFileRead XMLFileRead;
Element* document;
// ToDo: The handling of name and file attributes could be improved, here, // ToDo: The handling of name and file attributes could be improved, here,
// considering that a name can be in the external file, as well. // considering that a name can be in the external file, as well.
@ -502,7 +510,7 @@ bool FGFCS::Load(Element* el, SystemType systype)
cerr << "FCS, Autopilot, or system does not appear to be defined inline nor in a file" << endl; cerr << "FCS, Autopilot, or system does not appear to be defined inline nor in a file" << endl;
return false; return false;
} else { } else {
document = LoadXMLDocument(file); document = XMLFileRead.LoadXMLDocument(file);
if (!document) { if (!document) {
cerr << "Error loading file " << file << endl; cerr << "Error loading file " << file << endl;
return false; return false;
@ -566,6 +574,7 @@ bool FGFCS::Load(Element* el, SystemType systype)
FGFCSChannel* newChannel = 0; FGFCSChannel* newChannel = 0;
string sOnOffProperty = channel_element->GetAttributeValue("execute"); string sOnOffProperty = channel_element->GetAttributeValue("execute");
string sChannelName = channel_element->GetAttributeValue("name");
FGPropertyNode* OnOffPropertyNode = 0; FGPropertyNode* OnOffPropertyNode = 0;
if (sOnOffProperty.length() > 0) { if (sOnOffProperty.length() > 0) {
OnOffPropertyNode = PropertyManager->GetNode(sOnOffProperty); OnOffPropertyNode = PropertyManager->GetNode(sOnOffProperty);
@ -576,10 +585,10 @@ bool FGFCS::Load(Element* el, SystemType systype)
<< "understood. The simulation will abort" << reset << endl; << "understood. The simulation will abort" << reset << endl;
throw("Bad system definition"); throw("Bad system definition");
} else { } else {
newChannel = new FGFCSChannel(OnOffPropertyNode); newChannel = new FGFCSChannel(sChannelName, OnOffPropertyNode);
} }
} else { } else {
newChannel = new FGFCSChannel(); newChannel = new FGFCSChannel(sChannelName);
} }
SystemChannels.push_back(newChannel); SystemChannels.push_back(newChannel);
@ -631,6 +640,8 @@ bool FGFCS::Load(Element* el, SystemType systype)
newChannel->Add(new FGWaypoint(this, component_element)); newChannel->Add(new FGWaypoint(this, component_element));
} else if (component_element->GetName() == string("angle")) { } else if (component_element->GetName() == string("angle")) {
newChannel->Add(new FGAngles(this, component_element)); newChannel->Add(new FGAngles(this, component_element));
} else if (component_element->GetName() == string("distributor")) {
newChannel->Add(new FGDistributor(this, component_element));
} else { } else {
cerr << "Unknown FCS component: " << component_element->GetName() << endl; cerr << "Unknown FCS component: " << component_element->GetName() << endl;
} }
@ -646,8 +657,6 @@ bool FGFCS::Load(Element* el, SystemType systype)
PostLoad(document, PropertyManager); PostLoad(document, PropertyManager);
ResetParser();
return true; return true;
} }

View file

@ -45,13 +45,12 @@ INCLUDES
#include "models/flight_control/FGFCSComponent.h" #include "models/flight_control/FGFCSComponent.h"
#include "models/FGModel.h" #include "models/FGModel.h"
#include "models/FGLGear.h" #include "models/FGLGear.h"
#include "input_output/FGXMLFileRead.h"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DEFINITIONS DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#define ID_FCS "$Id: FGFCS.h,v 1.42 2013/06/20 04:37:27 jberndt Exp $" #define ID_FCS "$Id: FGFCS.h,v 1.45 2013/11/24 11:40:56 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS FORWARD DECLARATIONS
@ -169,7 +168,7 @@ CLASS DOCUMENTATION
@property gear/tailhook-pos-norm @property gear/tailhook-pos-norm
@author Jon S. Berndt @author Jon S. Berndt
@version $Revision: 1.42 $ @version $Revision: 1.45 $
@see FGActuator @see FGActuator
@see FGDeadBand @see FGDeadBand
@see FGFCSFunction @see FGFCSFunction
@ -184,13 +183,14 @@ CLASS DOCUMENTATION
@see FGAngles @see FGAngles
@see FGFCSComponent @see FGFCSComponent
@see Element @see Element
@see FGDistributor
*/ */
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CLASS DECLARATION CLASS DECLARATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
class FGFCS : public FGModel, public FGXMLFileRead class FGFCS : public FGModel
{ {
public: public:

10
src/FDM/JSBSim/models/FGFCSChannel.h Normal file → Executable file
View file

@ -44,7 +44,7 @@ INCLUDES
DEFINITIONS DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#define ID_FCSCHANNEL "$Id: FGFCSChannel.h,v 1.2 2013/01/26 17:06:50 bcoconni Exp $" #define ID_FCSCHANNEL "$Id: FGFCSChannel.h,v 1.3 2013/09/27 19:44:45 jberndt Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS FORWARD DECLARATIONS
@ -70,8 +70,8 @@ typedef std::vector <FGFCSComponent*> FCSCompVec;
class FGFCSChannel { class FGFCSChannel {
public: public:
/// Constructor /// Constructor
FGFCSChannel(FGPropertyNode* node=0) : FGFCSChannel(string name, FGPropertyNode* node=0) :
OnOffNode(node) OnOffNode(node), Name(name)
{ {
} }
/// Destructor /// Destructor
@ -79,6 +79,9 @@ public:
for (unsigned int i=0; i<FCSComponents.size(); i++) delete FCSComponents[i]; for (unsigned int i=0; i<FCSComponents.size(); i++) delete FCSComponents[i];
FCSComponents.clear(); FCSComponents.clear();
} }
/// Retrieves the name of the channel
string GetName() {return Name;}
/// Adds a component to a channel /// Adds a component to a channel
void Add(FGFCSComponent* comp) {FCSComponents.push_back(comp);} void Add(FGFCSComponent* comp) {FCSComponents.push_back(comp);}
/// Returns the number of components in the channel. /// Returns the number of components in the channel.
@ -121,6 +124,7 @@ public:
private: private:
FCSCompVec FCSComponents; FCSCompVec FCSComponents;
FGConstPropertyNode_ptr OnOffNode; FGConstPropertyNode_ptr OnOffNode;
string Name;
}; };
} }

View file

@ -42,12 +42,14 @@ INCLUDES
#include "FGLGear.h" #include "FGLGear.h"
#include "FGAccelerations.h" #include "FGAccelerations.h"
#include "input_output/FGPropertyManager.h" #include "input_output/FGPropertyManager.h"
#include "input_output/FGXMLFileRead.h"
#include "input_output/FGXMLElement.h"
using namespace std; using namespace std;
namespace JSBSim { namespace JSBSim {
static const char *IdSrc = "$Id: FGGroundReactions.cpp,v 1.42 2012/12/15 15:16:15 bcoconni Exp $"; static const char *IdSrc = "$Id: FGGroundReactions.cpp,v 1.43 2013/11/24 11:40:56 bcoconni Exp $";
static const char *IdHdr = ID_GROUNDREACTIONS; static const char *IdHdr = ID_GROUNDREACTIONS;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -130,11 +132,13 @@ bool FGGroundReactions::Load(Element* elem)
int num=0; int num=0;
string fname="", file=""; string fname="", file="";
string separator = "/"; string separator = "/";
FGXMLFileRead XMLFileRead;
Element* document;
fname = elem->GetAttributeValue("file"); fname = elem->GetAttributeValue("file");
if (!fname.empty()) { if (!fname.empty()) {
file = FDMExec->GetFullAircraftPath() + separator + fname; file = FDMExec->GetFullAircraftPath() + separator + fname;
document = LoadXMLDocument(file); document = XMLFileRead.LoadXMLDocument(file);
if (document == 0L) return false; if (document == 0L) return false;
} else { } else {
document = elem; document = elem;

View file

@ -43,10 +43,8 @@ INCLUDES
#include "FGModel.h" #include "FGModel.h"
#include "FGLGear.h" #include "FGLGear.h"
#include "math/FGColumnVector3.h" #include "math/FGColumnVector3.h"
#include "input_output/FGXMLElement.h"
#include "input_output/FGXMLFileRead.h"
#define ID_GROUNDREACTIONS "$Id: FGGroundReactions.h,v 1.25 2012/12/12 06:19:57 jberndt Exp $" #define ID_GROUNDREACTIONS "$Id: FGGroundReactions.h,v 1.27 2013/11/24 11:40:56 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS FORWARD DECLARATIONS
@ -79,7 +77,7 @@ CLASS DOCUMENTATION
CLASS DECLARATION CLASS DECLARATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
class FGGroundReactions : public FGModel, public FGXMLFileRead class FGGroundReactions : public FGModel
{ {
public: public:
FGGroundReactions(FGFDMExec*); FGGroundReactions(FGFDMExec*);

View file

@ -48,6 +48,7 @@ INCLUDES
#include "input_output/FGPropertyManager.h" #include "input_output/FGPropertyManager.h"
#include "models/FGGroundReactions.h" #include "models/FGGroundReactions.h"
#include "math/FGTable.h" #include "math/FGTable.h"
#include "input_output/FGXMLElement.h"
using namespace std; using namespace std;
@ -61,7 +62,7 @@ DEFINITIONS
GLOBAL DATA GLOBAL DATA
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
static const char *IdSrc = "$Id: FGLGear.cpp,v 1.104 2013/01/25 14:02:13 jberndt Exp $"; static const char *IdSrc = "$Id: FGLGear.cpp,v 1.106 2013/11/24 11:40:56 bcoconni Exp $";
static const char *IdHdr = ID_LGEAR; static const char *IdHdr = ID_LGEAR;
// Body To Structural (body frame is rotated 180 deg about Y and lengths are given in // Body To Structural (body frame is rotated 180 deg about Y and lengths are given in
@ -723,6 +724,14 @@ void FGLGear::UpdateForces(void)
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void FGLGear::SetstaticFCoeff(double coeff)
{
staticFCoeff = coeff;
Peak = coeff;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void FGLGear::bind(void) void FGLGear::bind(void)
{ {
string property_name; string property_name;
@ -749,7 +758,8 @@ void FGLGear::bind(void)
property_name = base_property_name + "/compression-velocity-fps"; property_name = base_property_name + "/compression-velocity-fps";
PropertyManager->Tie( property_name.c_str(), &compressSpeed ); PropertyManager->Tie( property_name.c_str(), &compressSpeed );
property_name = base_property_name + "/static_friction_coeff"; property_name = base_property_name + "/static_friction_coeff";
PropertyManager->Tie( property_name.c_str(), &staticFCoeff ); PropertyManager->Tie( property_name.c_str(), (FGLGear*)this,
&FGLGear::GetstaticFCoeff, &FGLGear::SetstaticFCoeff);
property_name = base_property_name + "/dynamic_friction_coeff"; property_name = base_property_name + "/dynamic_friction_coeff";
PropertyManager->Tie( property_name.c_str(), &dynamicFCoeff ); PropertyManager->Tie( property_name.c_str(), &dynamicFCoeff );

View file

@ -48,7 +48,7 @@ INCLUDES
DEFINITIONS DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#define ID_LGEAR "$Id: FGLGear.h,v 1.56 2012/12/15 15:16:16 bcoconni Exp $" #define ID_LGEAR "$Id: FGLGear.h,v 1.58 2013/11/15 22:43:01 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS FORWARD DECLARATIONS
@ -177,7 +177,7 @@ CLASS DOCUMENTATION
</contact> </contact>
@endcode @endcode
@author Jon S. Berndt @author Jon S. Berndt
@version $Id: FGLGear.h,v 1.56 2012/12/15 15:16:16 bcoconni Exp $ @version $Id: FGLGear.h,v 1.58 2013/11/15 22:43:01 bcoconni Exp $
@see Richard E. McFarland, "A Standard Kinematic Model for Flight Simulation at @see Richard E. McFarland, "A Standard Kinematic Model for Flight Simulation at
NASA-Ames", NASA CR-2497, January 1975 NASA-Ames", NASA CR-2497, January 1975
@see Barnes W. McCormick, "Aerodynamics, Aeronautics, and Flight Mechanics", @see Barnes W. McCormick, "Aerodynamics, Aeronautics, and Flight Mechanics",
@ -380,6 +380,7 @@ private:
void ComputeGroundFrame(void); void ComputeGroundFrame(void);
void ComputeJacobian(const FGColumnVector3& vWhlContactVec); void ComputeJacobian(const FGColumnVector3& vWhlContactVec);
void UpdateForces(void); void UpdateForces(void);
void SetstaticFCoeff(double coeff);
void CrashDetect(void); void CrashDetect(void);
void InitializeReporting(void); void InitializeReporting(void);
void ResetReporting(void); void ResetReporting(void);

View file

@ -44,12 +44,14 @@ INCLUDES
#include "FGMassBalance.h" #include "FGMassBalance.h"
#include "FGFDMExec.h" #include "FGFDMExec.h"
#include "input_output/FGPropertyManager.h" #include "input_output/FGPropertyManager.h"
#include "input_output/FGXMLFileRead.h"
#include "input_output/FGXMLElement.h"
using namespace std; using namespace std;
namespace JSBSim { namespace JSBSim {
static const char *IdSrc = "$Id: FGMassBalance.cpp,v 1.42 2012/12/12 06:19:57 jberndt Exp $"; static const char *IdSrc = "$Id: FGMassBalance.cpp,v 1.43 2013/11/24 11:40:56 bcoconni Exp $";
static const char *IdHdr = ID_MASSBALANCE; static const char *IdHdr = ID_MASSBALANCE;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -104,11 +106,13 @@ bool FGMassBalance::Load(Element* elem)
double bixx, biyy, bizz, bixy, bixz, biyz; double bixx, biyy, bizz, bixy, bixz, biyz;
string fname="", file=""; string fname="", file="";
string separator = "/"; string separator = "/";
FGXMLFileRead XMLFileRead;
Element* document;
fname = elem->GetAttributeValue("file"); fname = elem->GetAttributeValue("file");
if (!fname.empty()) { if (!fname.empty()) {
file = FDMExec->GetFullAircraftPath() + separator + fname; file = FDMExec->GetFullAircraftPath() + separator + fname;
document = LoadXMLDocument(file); document = XMLFileRead.LoadXMLDocument(file);
if (document == 0L) return false; if (document == 0L) return false;
} else { } else {
document = elem; document = elem;

View file

@ -43,14 +43,12 @@ INCLUDES
#include "FGModel.h" #include "FGModel.h"
#include "math/FGColumnVector3.h" #include "math/FGColumnVector3.h"
#include "math/FGMatrix33.h" #include "math/FGMatrix33.h"
#include "input_output/FGXMLElement.h"
#include "input_output/FGXMLFileRead.h"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DEFINITIONS DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#define ID_MASSBALANCE "$Id: FGMassBalance.h,v 1.28 2012/12/12 06:19:57 jberndt Exp $" #define ID_MASSBALANCE "$Id: FGMassBalance.h,v 1.29 2013/11/24 11:40:56 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONSS FORWARD DECLARATIONSS
@ -108,7 +106,7 @@ CLASS DOCUMENTATION
CLASS DECLARATION CLASS DECLARATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
class FGMassBalance : public FGModel, public FGXMLFileRead class FGMassBalance : public FGModel
{ {
public: public:

View file

@ -44,12 +44,14 @@ INCLUDES
#include "input_output/FGOutputSocket.h" #include "input_output/FGOutputSocket.h"
#include "input_output/FGOutputTextFile.h" #include "input_output/FGOutputTextFile.h"
#include "input_output/FGOutputFG.h" #include "input_output/FGOutputFG.h"
#include "input_output/FGXMLFileRead.h"
#include "input_output/FGXMLElement.h"
using namespace std; using namespace std;
namespace JSBSim { namespace JSBSim {
static const char *IdSrc = "$Id: FGOutput.cpp,v 1.73 2013/09/11 12:44:02 jberndt Exp $"; static const char *IdSrc = "$Id: FGOutput.cpp,v 1.74 2013/11/24 11:40:56 bcoconni Exp $";
static const char *IdHdr = ID_OUTPUT; static const char *IdHdr = ID_OUTPUT;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -192,11 +194,10 @@ string FGOutput::GetOutputName(unsigned int idx) const
bool FGOutput::SetDirectivesFile(const std::string& fname) bool FGOutput::SetDirectivesFile(const std::string& fname)
{ {
Element* document = LoadXMLDocument(fname); FGXMLFileRead XMLFile;
Element* document = XMLFile.LoadXMLDocument(fname);
bool result = Load(document); bool result = Load(document);
ResetParser();
if (!result) if (!result)
cerr << endl << "Aircraft output element has problems in file " << fname << endl; cerr << endl << "Aircraft output element has problems in file " << fname << endl;

View file

@ -42,13 +42,12 @@ INCLUDES
#include "FGModel.h" #include "FGModel.h"
#include "input_output/FGOutputType.h" #include "input_output/FGOutputType.h"
#include "input_output/FGXMLFileRead.h"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DEFINITIONS DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#define ID_OUTPUT "$Id: FGOutput.h,v 1.27 2013/01/26 17:06:50 bcoconni Exp $" #define ID_OUTPUT "$Id: FGOutput.h,v 1.29 2013/11/24 11:40:56 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS FORWARD DECLARATIONS
@ -122,14 +121,14 @@ CLASS DOCUMENTATION
The class FGOutput is the manager of the outputs requested by the user. It 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. manages a list of instances derived from the abstract class FGOutputType.
@version $Id: FGOutput.h,v 1.27 2013/01/26 17:06:50 bcoconni Exp $ @version $Id: FGOutput.h,v 1.29 2013/11/24 11:40:56 bcoconni Exp $
*/ */
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CLASS DECLARATION CLASS DECLARATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
class FGOutput : public FGModel, public FGXMLFileRead class FGOutput : public FGModel
{ {
public: public:
FGOutput(FGFDMExec*); FGOutput(FGFDMExec*);

View file

@ -67,6 +67,7 @@ INCLUDES
#include <cstdlib> #include <cstdlib>
#include <iostream> #include <iostream>
#include <iomanip> #include <iomanip>
#include <fstream>
#include "FGPropagate.h" #include "FGPropagate.h"
#include "FGGroundReactions.h" #include "FGGroundReactions.h"
@ -77,7 +78,7 @@ using namespace std;
namespace JSBSim { namespace JSBSim {
static const char *IdSrc = "$Id: FGPropagate.cpp,v 1.115 2013/09/14 11:26:02 bcoconni Exp $"; static const char *IdSrc = "$Id: FGPropagate.cpp,v 1.119 2013/11/24 11:40:56 bcoconni Exp $";
static const char *IdHdr = ID_PROPAGATE; static const char *IdHdr = ID_PROPAGATE;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -618,33 +619,43 @@ void FGPropagate::DumpState(void)
void FGPropagate::WriteStateFile(int num) void FGPropagate::WriteStateFile(int num)
{ {
ofstream outfile;
if (num == 0) return;
string filename = FDMExec->GetFullAircraftPath(); string filename = FDMExec->GetFullAircraftPath();
if (filename.empty()) string sim_time = to_string((double)FDMExec->GetSimTime());
filename = "initfile.xml"; if (filename.empty()) filename = "initfile.";
else else filename.append("/initfile.");
filename.append("/initfile.xml");
ofstream outfile(filename.c_str()); // Append sim time to the filename since there may be more than one created during a simulation run
filename += to_string((double)FDMExec->GetSimTime())+".xml";
if (outfile.is_open()) { switch(num) {
switch(num) { case 1:
case 1: outfile.open(filename.c_str());
outfile << "<?xml version=\"1.0\"?>" << endl; if (outfile.is_open()) {
outfile << "<initialize name=\"reset00\">" << endl; outfile << "<?xml version=\"1.0\"?>" << endl;
outfile << " <ubody unit=\"FT/SEC\"> " << VState.vUVW(eU) << " </ubody> " << endl; outfile << "<initialize name=\"reset00\">" << endl;
outfile << " <vbody unit=\"FT/SEC\"> " << VState.vUVW(eV) << " </vbody> " << endl; outfile << " <ubody unit=\"FT/SEC\"> " << VState.vUVW(eU) << " </ubody> " << endl;
outfile << " <wbody unit=\"FT/SEC\"> " << VState.vUVW(eW) << " </wbody> " << endl; outfile << " <vbody unit=\"FT/SEC\"> " << VState.vUVW(eV) << " </vbody> " << endl;
outfile << " <phi unit=\"DEG\"> " << VState.qAttitudeLocal.GetEuler(ePhi)*radtodeg << " </phi>" << endl; outfile << " <wbody unit=\"FT/SEC\"> " << VState.vUVW(eW) << " </wbody> " << endl;
outfile << " <theta unit=\"DEG\"> " << VState.qAttitudeLocal.GetEuler(eTht)*radtodeg << " </theta>" << endl; outfile << " <phi unit=\"DEG\"> " << VState.qAttitudeLocal.GetEuler(ePhi)*radtodeg << " </phi>" << endl;
outfile << " <psi unit=\"DEG\"> " << VState.qAttitudeLocal.GetEuler(ePsi)*radtodeg << " </psi>" << endl; outfile << " <theta unit=\"DEG\"> " << VState.qAttitudeLocal.GetEuler(eTht)*radtodeg << " </theta>" << endl;
outfile << " <longitude unit=\"DEG\"> " << VState.vLocation.GetLongitudeDeg() << " </longitude>" << endl; outfile << " <psi unit=\"DEG\"> " << VState.qAttitudeLocal.GetEuler(ePsi)*radtodeg << " </psi>" << endl;
outfile << " <latitude unit=\"DEG\"> " << VState.vLocation.GetLatitudeDeg() << " </latitude>" << endl; outfile << " <longitude unit=\"DEG\"> " << VState.vLocation.GetLongitudeDeg() << " </longitude>" << endl;
outfile << " <altitude unit=\"FT\"> " << GetDistanceAGL() << " </altitude>" << endl; outfile << " <latitude unit=\"DEG\"> " << VState.vLocation.GetLatitudeDeg() << " </latitude>" << endl;
outfile << "</initialize>" << endl; outfile << " <altitude unit=\"FT\"> " << GetDistanceAGL() << " </altitude>" << endl;
outfile.close(); outfile << "</initialize>" << endl;
outfile.close();
} else {
cerr << "Could not open and/or write the state to the initial conditions file: " << filename << endl;
}
break; break;
case 2: case 2:
outfile.open(filename.c_str());
if (outfile.is_open()) {
outfile << "<?xml version=\"1.0\"?>" << endl; outfile << "<?xml version=\"1.0\"?>" << endl;
outfile << "<initialize name=\"IC File\" version=\"2.0\">" << endl; outfile << "<initialize name=\"IC File\" version=\"2.0\">" << endl;
outfile << "" << endl; outfile << "" << endl;
@ -674,13 +685,12 @@ void FGPropagate::WriteStateFile(int num)
outfile << "" << endl; outfile << "" << endl;
outfile << "</initialize>" << endl; outfile << "</initialize>" << endl;
outfile.close(); outfile.close();
break; } else {
default: cerr << "Could not open and/or write the state to the initial conditions file: " << filename << endl;
return; // Ignore other writes to the property, e.g. on FlightGear reset.
throw("When writing a state file, the supplied value must be 1 or 2 for the version number of the resulting IC file");
} }
} else { break;
cerr << "Could not open and/or write the state to the initial conditions file: " << filename << endl; default:
cerr << "When writing a state file, the supplied value must be 1 or 2 for the version number of the resulting IC file" << endl;
} }
} }

View file

@ -59,14 +59,15 @@ INCLUDES
#include "models/propulsion/FGTurboProp.h" #include "models/propulsion/FGTurboProp.h"
#include "models/propulsion/FGTank.h" #include "models/propulsion/FGTank.h"
#include "input_output/FGPropertyManager.h" #include "input_output/FGPropertyManager.h"
#include "input_output/FGXMLParse.h" #include "input_output/FGXMLFileRead.h"
#include "input_output/FGXMLElement.h"
#include "math/FGColumnVector3.h" #include "math/FGColumnVector3.h"
using namespace std; using namespace std;
namespace JSBSim { namespace JSBSim {
static const char *IdSrc = "$Id: FGPropulsion.cpp,v 1.70 2013/09/11 23:24:49 jentron Exp $"; static const char *IdSrc = "$Id: FGPropulsion.cpp,v 1.71 2013/11/24 11:40:56 bcoconni Exp $";
static const char *IdHdr = ID_PROPULSION; static const char *IdHdr = ID_PROPULSION;
extern short debug_lvl; extern short debug_lvl;
@ -376,6 +377,7 @@ bool FGPropulsion::Load(Element* elem)
string type, engine_filename; string type, engine_filename;
string separator = "/"; string separator = "/";
Element *el=0; Element *el=0;
FGXMLFileRead XMLFileRead;
FGXMLParse main_file_parser; FGXMLParse main_file_parser;
Debug(2); Debug(2);
@ -384,7 +386,7 @@ bool FGPropulsion::Load(Element* elem)
fname = elem->GetAttributeValue("file"); fname = elem->GetAttributeValue("file");
if (!fname.empty()) { if (!fname.empty()) {
file = FDMExec->GetFullAircraftPath() + separator + fname; file = FDMExec->GetFullAircraftPath() + separator + fname;
el = LoadXMLDocument(file, main_file_parser); el = XMLFileRead.LoadXMLDocument(file, main_file_parser);
if (el == 0L) return false; if (el == 0L) return false;
} else { } else {
el = elem; el = elem;
@ -421,7 +423,7 @@ bool FGPropulsion::Load(Element* elem)
return false; return false;
} }
document = LoadXMLDocument(engine_filename); Element* document = XMLFileRead.LoadXMLDocument(engine_filename);
document->SetParent(engine_element); document->SetParent(engine_element);
type = document->GetName(); type = document->GetName();
@ -458,7 +460,7 @@ bool FGPropulsion::Load(Element* elem)
numEngines++; numEngines++;
engine_element = el->FindNextElement("engine"); engine_element = el->FindNextElement("engine");
ResetParser(); XMLFileRead.ResetParser();
} }
CalculateTankInertias(); CalculateTankInertias();

View file

@ -44,13 +44,12 @@ INCLUDES
#include "FGModel.h" #include "FGModel.h"
#include "propulsion/FGEngine.h" #include "propulsion/FGEngine.h"
#include "math/FGMatrix33.h" #include "math/FGMatrix33.h"
#include "input_output/FGXMLFileRead.h"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DEFINITIONS DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#define ID_PROPULSION "$Id: FGPropulsion.h,v 1.31 2011/10/31 14:54:41 bcoconni Exp $" #define ID_PROPULSION "$Id: FGPropulsion.h,v 1.32 2013/11/24 11:40:56 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS FORWARD DECLARATIONS
@ -92,7 +91,7 @@ CLASS DOCUMENTATION
@endcode @endcode
@author Jon S. Berndt @author Jon S. Berndt
@version $Id: FGPropulsion.h,v 1.31 2011/10/31 14:54:41 bcoconni Exp $ @version $Id: FGPropulsion.h,v 1.32 2013/11/24 11:40:56 bcoconni Exp $
@see @see
FGEngine FGEngine
FGTank FGTank
@ -102,7 +101,7 @@ CLASS DOCUMENTATION
CLASS DECLARATION CLASS DECLARATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
class FGPropulsion : public FGModel, public FGXMLFileRead class FGPropulsion : public FGModel
{ {
public: public:
/// Constructor /// Constructor

View file

@ -37,20 +37,21 @@ COMMENTS, REFERENCES, and NOTES
INCLUDES INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#include "FGAccelerometer.h"
#include <iostream> #include <iostream>
#include <cstdlib> #include <cstdlib>
#include "FGAccelerometer.h"
#include "models/FGPropagate.h" #include "models/FGPropagate.h"
#include "models/FGAccelerations.h" #include "models/FGAccelerations.h"
#include "models/FGMassBalance.h" #include "models/FGMassBalance.h"
#include "models/FGInertial.h" #include "models/FGInertial.h"
#include "input_output/FGXMLElement.h"
using namespace std; using namespace std;
namespace JSBSim { namespace JSBSim {
static const char *IdSrc = "$Id: FGAccelerometer.cpp,v 1.11 2012/11/17 18:03:19 jberndt Exp $"; static const char *IdSrc = "$Id: FGAccelerometer.cpp,v 1.12 2013/11/24 11:40:56 bcoconni Exp $";
static const char *IdHdr = ID_ACCELEROMETER; static const char *IdHdr = ID_ACCELEROMETER;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

5
src/FDM/JSBSim/models/flight_control/FGAccelerometer.h Normal file → Executable file
View file

@ -38,7 +38,6 @@ INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#include "FGSensor.h" #include "FGSensor.h"
#include "input_output/FGXMLElement.h"
#include "math/FGColumnVector3.h" #include "math/FGColumnVector3.h"
#include "math/FGMatrix33.h" #include "math/FGMatrix33.h"
#include "FGSensorOrientation.h" #include "FGSensorOrientation.h"
@ -47,7 +46,7 @@ INCLUDES
DEFINITIONS DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#define ID_ACCELEROMETER "$Id: FGAccelerometer.h,v 1.6 2012/01/08 12:39:14 bcoconni Exp $" #define ID_ACCELEROMETER "$Id: FGAccelerometer.h,v 1.7 2013/11/24 11:40:56 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS FORWARD DECLARATIONS
@ -127,7 +126,7 @@ even varying all the way from 0.95 to 1.05 in adjacent frames - whatever the del
time. time.
@author Jon S. Berndt @author Jon S. Berndt
@version $Revision: 1.6 $ @version $Revision: 1.7 $
*/ */
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

View file

@ -38,12 +38,13 @@ INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#include "FGActuator.h" #include "FGActuator.h"
#include "input_output/FGXMLElement.h"
using namespace std; using namespace std;
namespace JSBSim { namespace JSBSim {
static const char *IdSrc = "$Id: FGActuator.cpp,v 1.28 2013/06/10 02:04:50 jberndt Exp $"; static const char *IdSrc = "$Id: FGActuator.cpp,v 1.29 2013/11/24 11:40:56 bcoconni Exp $";
static const char *IdHdr = ID_ACTUATOR; static const char *IdHdr = ID_ACTUATOR;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

View file

@ -38,13 +38,12 @@ INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#include "FGFCSComponent.h" #include "FGFCSComponent.h"
#include "input_output/FGXMLElement.h"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DEFINITIONS DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#define ID_ACTUATOR "$Id: FGActuator.h,v 1.15 2013/01/26 17:06:50 bcoconni Exp $" #define ID_ACTUATOR "$Id: FGActuator.h,v 1.16 2013/11/24 11:40:56 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS FORWARD DECLARATIONS
@ -120,7 +119,7 @@ Example:
@endcode @endcode
@author Jon S. Berndt @author Jon S. Berndt
@version $Revision: 1.15 $ @version $Revision: 1.16 $
*/ */
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

View file

@ -1,4 +1,5 @@
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Module: FGAngles.cpp Module: FGAngles.cpp
Author: Jon S. Berndt Author: Jon S. Berndt
Date started: 6/2013 Date started: 6/2013
@ -73,7 +74,7 @@ using namespace std;
namespace JSBSim { namespace JSBSim {
static const char *IdSrc = "$Id: FGAngles.cpp,v 1.1 2013/06/20 04:37:28 jberndt Exp $"; static const char *IdSrc = "$Id: FGAngles.cpp,v 1.2 2013/09/27 19:36:28 jberndt Exp $";
static const char *IdHdr = ID_ANGLES; static const char *IdHdr = ID_ANGLES;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

View file

@ -0,0 +1,177 @@
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Module: FGDistributor.cpp
Author: Jon S. Berndt
Date started: 9/2013
------------- Copyright (C) 2013 -------------
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
You should have received a copy of the GNU Lesser General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place - Suite 330, Boston, MA 02111-1307, USA.
Further information about the GNU Lesser General Public License can also be found on
the world wide web at http://www.gnu.org.
FUNCTIONAL DESCRIPTION
--------------------------------------------------------------------------------
HISTORY
--------------------------------------------------------------------------------
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
COMMENTS, REFERENCES, and NOTES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Also, see the header file (FGDistributor.h) for further details.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#include <iostream>
#include "FGDistributor.h"
#include "input_output/FGXMLElement.h"
using namespace std;
namespace JSBSim {
static const char *IdSrc = "$Id: FGDistributor.cpp,v 1.3 2013/11/24 11:40:56 bcoconni Exp $";
static const char *IdHdr = ID_DISTRIBUTOR;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CLASS IMPLEMENTATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
FGDistributor::FGDistributor(FGFCS* fcs, Element* element) : FGFCSComponent(fcs, element)
{
Element *case_element=0;
Element* test_element=0;
Element* prop_val_element=0;
string type_string;
Case* current_case=0;
FGFCSComponent::bind(); // Bind() this component here in case it is used
// in its own definition for a sample-and-hold
type_string = element->GetAttributeValue("type");
if (type_string == "inclusive") Type = eInclusive;
else if (type_string == "exclusive") Type = eExclusive;
else {
throw("Not a known Distributor type, "+type_string);
}
case_element = element->FindElement("case");
while (case_element) {
current_case = new struct Case;
test_element = case_element->FindElement("test");
if (test_element) current_case->SetTest(new FGCondition(test_element, PropertyManager));
prop_val_element = case_element->FindElement("property");
while (prop_val_element) {
string value_string = prop_val_element->GetAttributeValue("value");
string property_string = prop_val_element->GetDataLine();
current_case->AddPropValPair(new PropValPair(property_string, value_string, PropertyManager));
prop_val_element = case_element->FindNextElement("property");
}
Cases.push_back(current_case);
case_element = element->FindNextElement("case");
}
Debug(0);
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FGDistributor::~FGDistributor()
{
Debug(1);
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
bool FGDistributor::Run(void )
{
bool completed = false;
for (unsigned int ctr=0; ctr<Cases.size(); ctr++) { // Loop through all Cases
if (Cases[ctr]->HasTest()) {
if (Cases[ctr]->GetTestResult() && !((Type == eExclusive) && completed)) {
Cases[ctr]->SetPropValPairs();
completed = true;
}
} else { // If no test present, execute always
Cases[ctr]->SetPropValPairs();
}
}
// if (delay != 0) Delay();
// Clip();
// if (IsOutput) SetOutput();
return true;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// The bitmasked value choices are as follows:
// unset: In this case (the default) JSBSim would only print
// out the normally expected messages, essentially echoing
// the config files as they are read. If the environment
// variable is not set, debug_lvl is set to 1 internally
// 0: This requests JSBSim not to output any messages
// whatsoever.
// 1: This value explicity requests the normal JSBSim
// startup messages
// 2: This value asks for a message to be printed out when
// a class is instantiated
// 4: When this value is set, a message is displayed when a
// FGModel object executes its Run() method
// 8: When this value is set, various runtime state variables
// are printed out periodically
// 16: When set various parameters are sanity checked and
// a message is printed out when they go out of bounds
void FGDistributor::Debug(int from)
{
string comp, scratch;
string indent = " ";
//bool first = false;
if (debug_lvl <= 0) return;
if (debug_lvl & 1) { // Standard console startup message output
if (from == 0) { // Constructor
}
}
if (debug_lvl & 2 ) { // Instantiation/Destruction notification
if (from == 0) cout << "Instantiated: FGDistributor" << endl;
if (from == 1) cout << "Destroyed: FGDistributor" << endl;
}
if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
}
if (debug_lvl & 8 ) { // Runtime state variables
}
if (debug_lvl & 16) { // Sanity checking
}
if (debug_lvl & 64) {
if (from == 0) { // Constructor
cout << IdSrc << endl;
cout << IdHdr << endl;
}
}
}
} //namespace JSBSim

View file

@ -0,0 +1,215 @@
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Header: FGDistributor.h
Author: Jon S. Berndt
Date started: 09/27/2013
------------- Copyright (C) 2013 jon@jsbsim.org -------------
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
You should have received a copy of the GNU Lesser General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place - Suite 330, Boston, MA 02111-1307, USA.
Further information about the GNU Lesser General Public License can also be found on
the world wide web at http://www.gnu.org.
HISTORY
--------------------------------------------------------------------------------
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SENTRY
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#ifndef FGDISTRIBUTOR_H
#define FGDISTRIBUTOR_H
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#include <iostream>
#include <cstdlib>
#include "FGFCSComponent.h"
#include "math/FGCondition.h"
#include "math/FGPropertyValue.h"
#include "math/FGRealValue.h"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#define ID_DISTRIBUTOR "$Id: FGDistributor.h,v 1.5 2013/11/24 11:40:57 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
namespace JSBSim {
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CLASS DOCUMENTATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
/** Encapsulates a distributor for the flight control system.
The distributor component models a distributor -
Within a test, additional tests can be specified, which allows for
complex groupings of logical comparisons. Each test contains
additional conditions, as well as possibly additional tests.
@code
<distributor name="name/is/irrelevant" type="exclusive|inclusive">
<case>
[<test logic="{AND|OR}" value="{property|value}">
{property} {conditional} {property|value}
<test logic="{AND|OR}">
{property} {conditional} {property|value}
...
</test>
...
</test>] <!-- Optional <test> one time. A <case> without a <test> is always executed -->
<property value="number|property"> property_name </property>
...
</case>
... <!-- Additional cases -->
</distributor>
@endcode
Here's an example:
@code
@endcode
Note: In the "logic" attribute, "AND" is the default logic, if none is supplied.
@author Jon S. Berndt
@version $Id: FGDistributor.h,v 1.5 2013/11/24 11:40:57 bcoconni Exp $
*/
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CLASS DECLARATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
class FGDistributor : public FGFCSComponent
{
public:
/** Constructor
@param fcs a pointer to the parent FGFCS class
@param element a pointer to the Element (from the config file XML tree)
that represents this distributor component */
FGDistributor(FGFCS* fcs, Element* element);
/// Destructor
~FGDistributor();
/** Executes the distributor logic.
@return true - always*/
bool Run(void);
private:
enum eType {eInclusive=0, eExclusive} Type;
class PropValPair {
public:
PropValPair(std::string prop, std::string val, FGPropertyManager* propMan) {
PropMan = propMan;
sign = 1;
Val = 0;
ValString = val;
FGPropertyNode *node = propMan->GetNode(prop, false);
if (node) PropNode = node;
else PropNode = 0;
PropName = prop;
if (is_number(ValString)) {
Val = new FGRealValue(atof(ValString.c_str()));
} else {
// "value" must be a property if execution passes to here.
if (ValString[0] == '-') {
sign = -1;
ValString.erase(0,1);
}
node = propMan->GetNode(ValString, false);
if (node) Val = new FGPropertyValue(node);
}
}
~PropValPair() {
delete PropNode;
delete PropMan;
}
void SetPropToValue() {
if (PropNode == 0) {
if (PropMan->HasNode(PropName)) {
PropNode = PropMan->GetNode(PropName);
} else {
throw(PropName+" in distributor component is not known");
}
}
if (Val == 0) {
if (PropMan->HasNode(ValString)) {
FGPropertyNode* node = PropMan->GetNode(ValString, false);
if (node) Val = new FGPropertyValue(node);
} else {
throw(ValString+" in distributor component is not known. Check spelling.");
}
}
PropNode->setDoubleValue(Val->GetValue()*sign);
}
private:
std::string PropName;
FGPropertyNode* PropNode;
FGPropertyManager* PropMan;
FGParameter* Val;
std::string ValString;
int sign;
};
class Case {
public:
Case() {
Test = 0;
}
~Case() {
for (unsigned int i=0; i<PropValPairs.size(); i++) delete PropValPairs[i];
PropValPairs.clear();
}
void SetTest(FGCondition* test) {Test = test;}
void AddPropValPair(PropValPair* pvPair) {PropValPairs.push_back(pvPair);}
void SetPropValPairs() {
for (unsigned int i=0; i<PropValPairs.size(); i++) PropValPairs[i]->SetPropToValue();
}
bool HasTest() {return (Test != 0);}
bool GetTestResult() { return Test->Evaluate(); }
private:
FGCondition* Test;
std::vector <PropValPair*> PropValPairs;
};
std::vector <Case*> Cases;
void Debug(int from);
};
}
#endif

View file

@ -48,7 +48,7 @@ using namespace std;
namespace JSBSim { namespace JSBSim {
static const char *IdSrc = "$Id: FGFCSComponent.cpp,v 1.36 2013/06/20 04:37:28 jberndt Exp $"; static const char *IdSrc = "$Id: FGFCSComponent.cpp,v 1.37 2013/09/27 19:38:36 jberndt Exp $";
static const char *IdHdr = ID_FCSCOMPONENT; static const char *IdHdr = ID_FCSCOMPONENT;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -57,14 +57,14 @@ CLASS IMPLEMENTATION
FGFCSComponent::FGFCSComponent(FGFCS* _fcs, Element* element) : fcs(_fcs) FGFCSComponent::FGFCSComponent(FGFCS* _fcs, Element* element) : fcs(_fcs)
{ {
Element *input_element, *clip_el; Element *input_element,*init_element, *clip_el;
Input = Output = clipmin = clipmax = delay_time = 0.0; Input = Output = clipmin = clipmax = delay_time = 0.0;
treenode = 0; treenode = 0;
delay = index = 0; delay = index = 0;
ClipMinPropertyNode = ClipMaxPropertyNode = 0; ClipMinPropertyNode = ClipMaxPropertyNode = 0;
clipMinSign = clipMaxSign = 1.0; clipMinSign = clipMaxSign = 1.0;
IsOutput = clip = false; IsOutput = clip = false;
string input, clip_string; string input,init, clip_string;
dt = fcs->GetDt(); dt = fcs->GetDt();
PropertyManager = fcs->GetPropertyManager(); PropertyManager = fcs->GetPropertyManager();
@ -112,12 +112,36 @@ FGFCSComponent::FGFCSComponent(FGFCS* _fcs, Element* element) : fcs(_fcs)
Type = "WAYPOINT_DISTANCE"; Type = "WAYPOINT_DISTANCE";
} else if (element->GetName() == string("angle")) { } else if (element->GetName() == string("angle")) {
Type = "ANGLE"; Type = "ANGLE";
} else if (element->GetName() == string("distributor")) {
Type = "DISTRIBUTOR";
} else { // illegal component in this channel } else { // illegal component in this channel
Type = "UNKNOWN"; Type = "UNKNOWN";
} }
Name = element->GetAttributeValue("name"); Name = element->GetAttributeValue("name");
init_element = element->FindElement("init");
while (init_element) {
init = init_element->GetDataLine();
if (init[0] == '-') {
InitSigns.push_back(-1.0);
init.erase(0,1);
} else {
InitSigns.push_back( 1.0);
}
FGPropertyNode* node = 0L;
if (PropertyManager->HasNode(init)) {
node = PropertyManager->GetNode(init);
InitNodes.push_back(new FGPropertyValue( node ));
} else {
InitNodes.push_back(new FGPropertyValue( init,
PropertyManager ));
}
InitNames.push_back( init );
init_element = element->FindNextElement("init");
}
input_element = element->FindElement("input"); input_element = element->FindElement("input");
while (input_element) { while (input_element) {
input = input_element->GetDataLine(); input = input_element->GetDataLine();

View file

@ -46,7 +46,7 @@ INCLUDES
DEFINITIONS DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#define ID_FCSCOMPONENT "$Id: FGFCSComponent.h,v 1.22 2013/06/20 04:37:28 jberndt Exp $" #define ID_FCSCOMPONENT "$Id: FGFCSComponent.h,v 1.23 2013/09/27 19:38:44 jberndt Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS FORWARD DECLARATIONS
@ -82,7 +82,7 @@ CLASS DOCUMENTATION
- FGAngle - FGAngle
@author Jon S. Berndt @author Jon S. Berndt
@version $Id: FGFCSComponent.h,v 1.22 2013/06/20 04:37:28 jberndt Exp $ @version $Id: FGFCSComponent.h,v 1.23 2013/09/27 19:38:44 jberndt Exp $
@see Documentation for the FGFCS class, and for the configuration file class @see Documentation for the FGFCS class, and for the configuration file class
*/ */
@ -112,6 +112,9 @@ protected:
std::vector <FGPropertyNode_ptr> OutputNodes; std::vector <FGPropertyNode_ptr> OutputNodes;
FGPropertyNode_ptr ClipMinPropertyNode; FGPropertyNode_ptr ClipMinPropertyNode;
FGPropertyNode_ptr ClipMaxPropertyNode; FGPropertyNode_ptr ClipMaxPropertyNode;
std::vector <FGPropertyValue*> InitNodes;
std::vector <std::string> InitNames;
std::vector <float> InitSigns;
std::vector <FGPropertyValue*> InputNodes; std::vector <FGPropertyValue*> InputNodes;
std::vector <std::string> InputNames; std::vector <std::string> InputNames;
std::vector <float> InputSigns; std::vector <float> InputSigns;

6
src/FDM/JSBSim/models/flight_control/FGFCSFunction.cpp Normal file → Executable file
View file

@ -37,15 +37,17 @@ COMMENTS, REFERENCES, and NOTES
INCLUDES INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#include "FGFCSFunction.h"
#include <cstdlib> #include <cstdlib>
#include <iostream> #include <iostream>
#include "FGFCSFunction.h"
#include "input_output/FGXMLElement.h"
using namespace std; using namespace std;
namespace JSBSim { namespace JSBSim {
static const char *IdSrc = "$Id: FGFCSFunction.cpp,v 1.12 2012/11/17 18:03:19 jberndt Exp $"; static const char *IdSrc = "$Id: FGFCSFunction.cpp,v 1.13 2013/11/24 11:40:57 bcoconni Exp $";
static const char *IdHdr = ID_FCSFUNCTION; static const char *IdHdr = ID_FCSFUNCTION;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

5
src/FDM/JSBSim/models/flight_control/FGFCSFunction.h Normal file → Executable file
View file

@ -38,14 +38,13 @@ INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#include "FGFCSComponent.h" #include "FGFCSComponent.h"
#include "input_output/FGXMLElement.h"
#include "math/FGFunction.h" #include "math/FGFunction.h"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DEFINITIONS DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#define ID_FCSFUNCTION "$Id: FGFCSFunction.h,v 1.8 2011/11/10 12:06:14 jberndt Exp $" #define ID_FCSFUNCTION "$Id: FGFCSFunction.h,v 1.9 2013/11/24 11:40:57 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS FORWARD DECLARATIONS
@ -105,7 +104,7 @@ a function (from an aero specification):
</function> </function>
@endcode @endcode
@version $Id: FGFCSFunction.h,v 1.8 2011/11/10 12:06:14 jberndt Exp $ @version $Id: FGFCSFunction.h,v 1.9 2013/11/24 11:40:57 bcoconni Exp $
*/ */
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

5
src/FDM/JSBSim/models/flight_control/FGGyro.cpp Normal file → Executable file
View file

@ -37,16 +37,17 @@ COMMENTS, REFERENCES, and NOTES
INCLUDES INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#include "FGGyro.h"
#include <iostream> #include <iostream>
#include "FGGyro.h"
#include "models/FGAccelerations.h" #include "models/FGAccelerations.h"
#include "input_output/FGXMLElement.h"
using namespace std; using namespace std;
namespace JSBSim { namespace JSBSim {
static const char *IdSrc = "$Id: FGGyro.cpp,v 1.7 2012/11/17 18:03:19 jberndt Exp $"; static const char *IdSrc = "$Id: FGGyro.cpp,v 1.8 2013/11/24 11:40:57 bcoconni Exp $";
static const char *IdHdr = ID_GYRO; static const char *IdHdr = ID_GYRO;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

5
src/FDM/JSBSim/models/flight_control/FGGyro.h Normal file → Executable file
View file

@ -38,7 +38,6 @@ INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#include "FGSensor.h" #include "FGSensor.h"
#include "input_output/FGXMLElement.h"
#include "math/FGColumnVector3.h" #include "math/FGColumnVector3.h"
#include "math/FGMatrix33.h" #include "math/FGMatrix33.h"
#include "FGSensorOrientation.h" #include "FGSensorOrientation.h"
@ -47,7 +46,7 @@ INCLUDES
DEFINITIONS DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#define ID_GYRO "$Id: FGGyro.h,v 1.6 2011/07/17 13:51:23 jberndt Exp $" #define ID_GYRO "$Id: FGGyro.h,v 1.7 2013/11/24 11:40:57 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS FORWARD DECLARATIONS
@ -104,7 +103,7 @@ even varying all the way from 0.95 to 1.05 in adjacent frames - whatever the del
time. time.
@author Jon S. Berndt @author Jon S. Berndt
@version $Revision: 1.6 $ @version $Revision: 1.7 $
*/ */
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

View file

@ -37,17 +37,19 @@ COMMENTS, REFERENCES, and NOTES
INCLUDES INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#include "FGMagnetometer.h"
#include "simgear/magvar/coremag.hxx"
#include <ctime> #include <ctime>
#include <cstdlib> #include <cstdlib>
#include <iostream> #include <iostream>
#include "FGMagnetometer.h"
#include "simgear/magvar/coremag.hxx"
#include "input_output/FGXMLElement.h"
using namespace std; using namespace std;
namespace JSBSim { namespace JSBSim {
static const char *IdSrc = "$Id: FGMagnetometer.cpp,v 1.6 2012/11/17 18:03:19 jberndt Exp $"; static const char *IdSrc = "$Id: FGMagnetometer.cpp,v 1.7 2013/11/24 11:40:57 bcoconni Exp $";
static const char *IdHdr = ID_MAGNETOMETER; static const char *IdHdr = ID_MAGNETOMETER;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

5
src/FDM/JSBSim/models/flight_control/FGMagnetometer.h Normal file → Executable file
View file

@ -38,7 +38,6 @@ INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#include "FGSensor.h" #include "FGSensor.h"
#include "input_output/FGXMLElement.h"
#include "models/FGPropagate.h" #include "models/FGPropagate.h"
#include "models/FGMassBalance.h" #include "models/FGMassBalance.h"
#include "models/FGInertial.h" #include "models/FGInertial.h"
@ -50,7 +49,7 @@ INCLUDES
DEFINITIONS DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#define ID_MAGNETOMETER "$Id: FGMagnetometer.h,v 1.4 2009/12/11 06:03:06 jberndt Exp $" #define ID_MAGNETOMETER "$Id: FGMagnetometer.h,v 1.5 2013/11/24 11:40:57 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS FORWARD DECLARATIONS
@ -118,7 +117,7 @@ even varying all the way from 0.95 to 1.05 in adjacent frames - whatever the del
time. time.
@author Jon S. Berndt @author Jon S. Berndt
@version $Revision: 1.4 $ @version $Revision: 1.5 $
*/ */
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

View file

@ -48,7 +48,7 @@ INCLUDES
DEFINITIONS DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#define ID_SensorOrientation "$Id: FGSensorOrientation.h,v 1.3 2009/10/24 22:59:30 jberndt Exp $" #define ID_SensorOrientation "$Id: FGSensorOrientation.h,v 1.5 2013/11/17 05:12:57 jberndt Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS FORWARD DECLARATIONS
@ -65,7 +65,7 @@ CLASS DOCUMENTATION
Syntax: Syntax:
@author Jon S. Berndt @author Jon S. Berndt
@version $Revision: 1.3 $ @version $Revision: 1.5 $
*/ */
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -79,7 +79,7 @@ public:
{ {
Element* orient_element = element->FindElement("orientation"); Element* orient_element = element->FindElement("orientation");
if (orient_element) vOrient = orient_element->FindElementTripletConvertTo("RAD"); if (orient_element) vOrient = orient_element->FindElementTripletConvertTo("RAD");
else { std::cerr << "No orientation given for this sensor. " << std::endl;}
Element* axis_element = element->FindElement("axis"); Element* axis_element = element->FindElement("axis");
if (axis_element) { if (axis_element) {

View file

@ -61,14 +61,16 @@ Also, see the header file (FGSwitch.h) for further details.
INCLUDES INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#include "FGSwitch.h"
#include <iostream> #include <iostream>
#include "FGSwitch.h"
#include "input_output/FGXMLElement.h"
using namespace std; using namespace std;
namespace JSBSim { namespace JSBSim {
static const char *IdSrc = "$Id: FGSwitch.cpp,v 1.25 2012/12/02 12:59:19 bcoconni Exp $"; static const char *IdSrc = "$Id: FGSwitch.cpp,v 1.27 2013/11/24 11:40:57 bcoconni Exp $";
static const char *IdHdr = ID_SWITCH; static const char *IdHdr = ID_SWITCH;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -95,6 +97,11 @@ FGSwitch::FGSwitch(FGFCS* fcs, Element* element) : FGFCSComponent(fcs, element)
value = test_element->GetAttributeValue("value"); value = test_element->GetAttributeValue("value");
current_test->setTestValue(value, Name, PropertyManager); current_test->setTestValue(value, Name, PropertyManager);
current_test->Default = true; current_test->Default = true;
if (delay > 0 && is_number(value)) { // If there is a delay, initialize the
for (unsigned int i=0; i<delay-1; i++) { // delay buffer to the default value
output_array[i] = atof(value.c_str()); // for the switch if that value is a number.
}
}
tests.push_back(current_test); tests.push_back(current_test);
} }

View file

@ -39,8 +39,8 @@ INCLUDES
#include <iostream> #include <iostream>
#include <cstdlib> #include <cstdlib>
#include "FGFCSComponent.h" #include "FGFCSComponent.h"
#include "input_output/FGXMLElement.h"
#include "math/FGCondition.h" #include "math/FGCondition.h"
#include "math/FGPropertyValue.h" #include "math/FGPropertyValue.h"
@ -48,7 +48,7 @@ INCLUDES
DEFINITIONS DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#define ID_SWITCH "$Id: FGSwitch.h,v 1.16 2013/01/26 17:06:50 bcoconni Exp $" #define ID_SWITCH "$Id: FGSwitch.h,v 1.18 2013/11/24 11:40:57 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS FORWARD DECLARATIONS
@ -127,7 +127,7 @@ ap/attitude_hold takes the value 1), the value of the switch component will be
whatever value fcs/roll-ap-error-summer is. whatever value fcs/roll-ap-error-summer is.
@author Jon S. Berndt @author Jon S. Berndt
@version $Id: FGSwitch.h,v 1.16 2013/01/26 17:06:50 bcoconni Exp $ @version $Id: FGSwitch.h,v 1.18 2013/11/24 11:40:57 bcoconni Exp $
*/ */
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -171,7 +171,9 @@ private:
sign = 1.0; sign = 1.0;
} }
void setTestValue(std::string value, std::string Name, FGPropertyManager* propMan) { void setTestValue(std::string value, std::string Name,
FGPropertyManager* propMan)
{
if (value.empty()) { if (value.empty()) {
std::cerr << "No VALUE supplied for switch component: " << Name << std::endl; std::cerr << "No VALUE supplied for switch component: " << Name << std::endl;
} else { } else {

View file

@ -44,12 +44,13 @@ INCLUDES
#include "FGElectric.h" #include "FGElectric.h"
#include "FGPropeller.h" #include "FGPropeller.h"
#include "input_output/FGXMLElement.h"
using namespace std; using namespace std;
namespace JSBSim { namespace JSBSim {
static const char *IdSrc = "$Id: FGElectric.cpp,v 1.13 2011/08/03 03:21:06 jberndt Exp $"; static const char *IdSrc = "$Id: FGElectric.cpp,v 1.14 2013/11/24 11:40:57 bcoconni Exp $";
static const char *IdHdr = ID_ELECTRIC; static const char *IdHdr = ID_ELECTRIC;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

View file

@ -39,13 +39,12 @@ INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#include "FGEngine.h" #include "FGEngine.h"
#include "input_output/FGXMLElement.h"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DEFINITIONS DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#define ID_ELECTRIC "$Id: FGElectric.h,v 1.11 2011/07/28 12:48:19 jberndt Exp $"; #define ID_ELECTRIC "$Id: FGElectric.h,v 1.12 2013/11/24 11:40:57 bcoconni Exp $";
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS FORWARD DECLARATIONS
@ -65,7 +64,7 @@ CLASS DOCUMENTATION
there is no battery model available, so this motor does not consume any there is no battery model available, so this motor does not consume any
energy. There is no internal friction. energy. There is no internal friction.
@author David Culp @author David Culp
@version "$Id: FGElectric.h,v 1.11 2011/07/28 12:48:19 jberndt Exp $" @version "$Id: FGElectric.h,v 1.12 2013/11/24 11:40:57 bcoconni Exp $"
*/ */
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

View file

@ -46,14 +46,15 @@ INCLUDES
#include "FGPropeller.h" #include "FGPropeller.h"
#include "FGNozzle.h" #include "FGNozzle.h"
#include "FGRotor.h" #include "FGRotor.h"
#include "input_output/FGXMLParse.h" #include "input_output/FGXMLFileRead.h"
#include "input_output/FGXMLElement.h"
#include "math/FGColumnVector3.h" #include "math/FGColumnVector3.h"
using namespace std; using namespace std;
namespace JSBSim { namespace JSBSim {
static const char *IdSrc = "$Id: FGEngine.cpp,v 1.52 2013/01/12 19:24:45 jberndt Exp $"; static const char *IdSrc = "$Id: FGEngine.cpp,v 1.54 2013/11/24 11:40:57 bcoconni Exp $";
static const char *IdHdr = ID_ENGINE; static const char *IdHdr = ID_ENGINE;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -83,7 +84,7 @@ FGEngine::FGEngine(FGFDMExec* exec, Element* engine_element, int engine_number,
Name = engine_element->GetAttributeValue("name"); Name = engine_element->GetAttributeValue("name");
Load(engine_element, PropertyManager, ::to_string(EngineNumber)); // Call ModelFunctions loader Load(engine_element, PropertyManager, to_string((int)EngineNumber)); // Call ModelFunctions loader
// Find and set engine location // Find and set engine location
@ -133,7 +134,7 @@ FGEngine::FGEngine(FGFDMExec* exec, Element* engine_element, int engine_number,
property_name = base_property_name + "/fuel-used-lbs"; property_name = base_property_name + "/fuel-used-lbs";
PropertyManager->Tie( property_name.c_str(), this, &FGEngine::GetFuelUsedLbs); PropertyManager->Tie( property_name.c_str(), this, &FGEngine::GetFuelUsedLbs);
PostLoad(engine_element, PropertyManager, ::to_string(EngineNumber)); PostLoad(engine_element, PropertyManager, to_string((int)EngineNumber));
Debug(0); Debug(0);
} }
@ -268,7 +269,8 @@ bool FGEngine::LoadThruster(Element *thruster_element)
return false; return false;
} }
document = LoadXMLDocument(thruster_fullpathname); FGXMLFileRead XMLFileRead;
Element *document = XMLFileRead.LoadXMLDocument(thruster_fullpathname);
document->SetParent(thruster_element); document->SetParent(thruster_element);
thrType = document->GetName(); thrType = document->GetName();

View file

@ -47,15 +47,13 @@ INCLUDES
#include <string> #include <string>
#include "math/FGModelFunctions.h" #include "math/FGModelFunctions.h"
#include "input_output/FGXMLFileRead.h"
#include "input_output/FGXMLElement.h"
#include "math/FGColumnVector3.h" #include "math/FGColumnVector3.h"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DEFINITIONS DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#define ID_ENGINE "$Id: FGEngine.h,v 1.36 2012/07/29 12:04:09 bcoconni Exp $" #define ID_ENGINE "$Id: FGEngine.h,v 1.38 2013/11/24 11:40:57 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS FORWARD DECLARATIONS
@ -113,14 +111,14 @@ CLASS DOCUMENTATION
documentation for engine and thruster classes. documentation for engine and thruster classes.
</pre> </pre>
@author Jon S. Berndt @author Jon S. Berndt
@version $Id: FGEngine.h,v 1.36 2012/07/29 12:04:09 bcoconni Exp $ @version $Id: FGEngine.h,v 1.38 2013/11/24 11:40:57 bcoconni Exp $
*/ */
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CLASS DECLARATION CLASS DECLARATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
class FGEngine : public FGModelFunctions, public FGXMLFileRead class FGEngine : public FGModelFunctions
{ {
public: public:
struct Inputs { struct Inputs {

View file

@ -45,12 +45,13 @@ INCLUDES
#include "FGPiston.h" #include "FGPiston.h"
#include "FGPropeller.h" #include "FGPropeller.h"
#include "input_output/FGXMLElement.h"
using namespace std; using namespace std;
namespace JSBSim { namespace JSBSim {
static const char *IdSrc = "$Id: FGPiston.cpp,v 1.71 2012/04/07 01:50:54 jentron Exp $"; static const char *IdSrc = "$Id: FGPiston.cpp,v 1.72 2013/11/24 11:40:57 bcoconni Exp $";
static const char *IdHdr = ID_PISTON; static const char *IdHdr = ID_PISTON;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

View file

@ -40,14 +40,16 @@ INCLUDES
#include <iostream> #include <iostream>
#include <sstream> #include <sstream>
#include "FGRocket.h" #include "FGRocket.h"
#include "FGThruster.h" #include "FGThruster.h"
#include "input_output/FGXMLElement.h"
using namespace std; using namespace std;
namespace JSBSim { namespace JSBSim {
static const char *IdSrc = "$Id: FGRocket.cpp,v 1.30 2013/06/10 02:00:11 jberndt Exp $"; static const char *IdSrc = "$Id: FGRocket.cpp,v 1.31 2013/11/24 11:40:57 bcoconni Exp $";
static const char *IdHdr = ID_ROCKET; static const char *IdHdr = ID_ROCKET;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

View file

@ -41,13 +41,12 @@ INCLUDES
#include "FGEngine.h" #include "FGEngine.h"
#include "math/FGTable.h" #include "math/FGTable.h"
#include "math/FGFunction.h" #include "math/FGFunction.h"
#include "input_output/FGXMLElement.h"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DEFINITIONS DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#define ID_ROCKET "$Id: FGRocket.h,v 1.19 2012/09/17 12:29:13 jberndt Exp $" #define ID_ROCKET "$Id: FGRocket.h,v 1.20 2013/11/24 11:40:57 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS FORWARD DECLARATIONS
@ -119,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. fuel begins burning and thrust is provided.
@author Jon S. Berndt @author Jon S. Berndt
$Id: FGRocket.h,v 1.19 2012/09/17 12:29:13 jberndt Exp $ $Id: FGRocket.h,v 1.20 2013/11/24 11:40:57 bcoconni Exp $
@see FGNozzle, @see FGNozzle,
FGThruster, FGThruster,
FGForce, FGForce,

View file

@ -48,6 +48,7 @@ INCLUDES
#include "FGRotor.h" #include "FGRotor.h"
#include "models/FGMassBalance.h" #include "models/FGMassBalance.h"
#include "models/FGPropulsion.h" // to get the GearRatio from a linked rotor #include "models/FGPropulsion.h" // to get the GearRatio from a linked rotor
#include "input_output/FGXMLElement.h"
using std::cerr; using std::cerr;
using std::cout; using std::cout;
@ -56,7 +57,7 @@ using std::ostringstream;
namespace JSBSim { namespace JSBSim {
static const char *IdSrc = "$Id: FGRotor.cpp,v 1.20 2012/03/18 15:48:36 jentron Exp $"; static const char *IdSrc = "$Id: FGRotor.cpp,v 1.21 2013/11/24 11:40:57 bcoconni Exp $";
static const char *IdHdr = ID_ROTOR; static const char *IdHdr = ID_ROTOR;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

View file

@ -42,13 +42,13 @@ INCLUDES
#include "FGTransmission.h" #include "FGTransmission.h"
using std::string;
using std::cout; using std::cout;
using std::endl; using std::endl;
using std::string;
namespace JSBSim { namespace JSBSim {
static const char *IdSrc = "$Id: FGTransmission.cpp,v 1.1 2012/02/25 14:37:02 jentron Exp $"; static const char *IdSrc = "$Id: FGTransmission.cpp,v 1.2 2013/11/15 22:43:03 bcoconni Exp $";
static const char *IdHdr = ID_TRANSMISSION; static const char *IdHdr = ID_TRANSMISSION;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

View file

@ -44,12 +44,13 @@ INCLUDES
#include "FGTurbine.h" #include "FGTurbine.h"
#include "FGThruster.h" #include "FGThruster.h"
#include "input_output/FGXMLElement.h"
using namespace std; using namespace std;
namespace JSBSim { namespace JSBSim {
static const char *IdSrc = "$Id: FGTurbine.cpp,v 1.37 2012/11/17 19:38:43 jberndt Exp $"; static const char *IdSrc = "$Id: FGTurbine.cpp,v 1.38 2013/11/24 11:40:57 bcoconni Exp $";
static const char *IdHdr = ID_TURBINE; static const char *IdHdr = ID_TURBINE;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

49
src/FDM/JSBSim/models/propulsion/FGTurboProp.cpp Normal file → Executable file
View file

@ -48,12 +48,13 @@ INCLUDES
#include "FGTurboProp.h" #include "FGTurboProp.h"
#include "FGPropeller.h" #include "FGPropeller.h"
#include "FGRotor.h" #include "FGRotor.h"
#include "input_output/FGXMLElement.h"
using namespace std; using namespace std;
namespace JSBSim { namespace JSBSim {
static const char *IdSrc = "$Id: FGTurboProp.cpp,v 1.24 2011/09/25 23:56:11 jentron Exp $"; static const char *IdSrc = "$Id: FGTurboProp.cpp,v 1.26 2013/11/24 14:22:22 bcoconni Exp $";
static const char *IdHdr = ID_TURBOPROP; static const char *IdHdr = ID_TURBOPROP;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -62,7 +63,7 @@ CLASS IMPLEMENTATION
FGTurboProp::FGTurboProp(FGFDMExec* exec, Element *el, int engine_number, struct Inputs& input) FGTurboProp::FGTurboProp(FGFDMExec* exec, Element *el, int engine_number, struct Inputs& input)
: FGEngine(exec, el, engine_number, input), : FGEngine(exec, el, engine_number, input),
ITT_N1(NULL), EnginePowerRPM_N1(NULL), EnginePowerVC(NULL) ITT_N1(NULL), EnginePowerRPM_N1(NULL), EnginePowerVC(NULL), CombustionEfficiency_N1(NULL)
{ {
SetDefaults(); SetDefaults();
thrusterType = Thruster->GetType(); thrusterType = Thruster->GetType();
@ -79,6 +80,7 @@ FGTurboProp::~FGTurboProp()
delete ITT_N1; delete ITT_N1;
delete EnginePowerRPM_N1; delete EnginePowerRPM_N1;
delete EnginePowerVC; delete EnginePowerVC;
delete CombustionEfficiency_N1;
Debug(1); Debug(1);
} }
@ -86,7 +88,6 @@ FGTurboProp::~FGTurboProp()
bool FGTurboProp::Load(FGFDMExec* exec, Element *el) bool FGTurboProp::Load(FGFDMExec* exec, Element *el)
{ {
IdleFF=-1;
MaxStartingTime = 999999; //very big timeout -> infinite MaxStartingTime = 999999; //very big timeout -> infinite
Ielu_max_torque=-1; Ielu_max_torque=-1;
@ -110,8 +111,10 @@ bool FGTurboProp::Load(FGFDMExec* exec, Element *el)
if (el->FindElement("maxpower")) if (el->FindElement("maxpower"))
MaxPower = el->FindElementValueAsNumber("maxpower"); MaxPower = el->FindElementValueAsNumber("maxpower");
if (el->FindElement("idlefuelflow")) if (el->FindElement("idlefuelflow")) {
IdleFF = el->FindElementValueAsNumber("idlefuelflow"); cerr << el->ReadFrom() << "Note: 'idlefuelflow' is obsolete, "
<< "use the 'CombustionEfficiency_N1' table instead." << endl;
}
if (el->FindElement("psfc")) if (el->FindElement("psfc"))
PSFC = el->FindElementValueAsNumber("psfc"); PSFC = el->FindElementValueAsNumber("psfc");
if (el->FindElement("n1idle_max_delay")) if (el->FindElement("n1idle_max_delay"))
@ -139,9 +142,11 @@ bool FGTurboProp::Load(FGFDMExec* exec, Element *el)
EnginePowerRPM_N1 = new FGTable(PropertyManager, table_element); EnginePowerRPM_N1 = new FGTable(PropertyManager, table_element);
} else if (name == "ITT_N1") { } else if (name == "ITT_N1") {
ITT_N1 = new FGTable(PropertyManager, table_element); ITT_N1 = new FGTable(PropertyManager, table_element);
} else if (name == "CombustionEfficiency_N1") {
CombustionEfficiency_N1 = new FGTable(PropertyManager, table_element);
} else { } else {
cerr << "Unknown table type: " << name << " in turbine definition." << cerr << el->ReadFrom() << "Unknown table type: " << name
endl; << " in turboprop definition." << endl;
} }
} }
@ -151,9 +156,19 @@ bool FGTurboProp::Load(FGFDMExec* exec, Element *el)
N1_factor = MaxN1 - IdleN1; N1_factor = MaxN1 - IdleN1;
N2_factor = MaxN2 - IdleN2; N2_factor = MaxN2 - IdleN2;
OilTemp_degK = in.TAT_c + 273.0; OilTemp_degK = in.TAT_c + 273.0;
if (IdleFF==-1) IdleFF = pow(MilThrust, 0.2) * 107.0; // just an estimate
// cout << "ENG POWER:" << EnginePowerRPM_N1->GetValue(1200,90) << endl; // default table based on '9.333 - (N1)/12.0' approximation
// gives 430%Fuel at 60%N1
if (! CombustionEfficiency_N1) {
CombustionEfficiency_N1 = new FGTable(6);
*CombustionEfficiency_N1 << 60.0 << 12.0/52.0;
*CombustionEfficiency_N1 << 82.0 << 12.0/30.0;
*CombustionEfficiency_N1 << 96.0 << 12.0/16.0;
*CombustionEfficiency_N1 << 100.0 << 1.0;
*CombustionEfficiency_N1 << 104.0 << 1.5;
*CombustionEfficiency_N1 << 110.0 << 6.0;
}
return true; return true;
} }
@ -294,7 +309,9 @@ double FGTurboProp::Off(void)
double FGTurboProp::Run(void) double FGTurboProp::Run(void)
{ {
double thrust = 0.0, EngPower_HP, eff_coef; double thrust = 0.0;
double EngPower_HP;
Running = true; Starter = false; EngStarting = false; Running = true; Starter = false; EngStarting = false;
//--- //---
@ -305,8 +322,8 @@ double FGTurboProp::Run(void)
EngPower_HP *= EnginePowerVC->GetValue(); EngPower_HP *= EnginePowerVC->GetValue();
if (EngPower_HP > MaxPower) EngPower_HP = MaxPower; if (EngPower_HP > MaxPower) EngPower_HP = MaxPower;
eff_coef = 9.333 - (N1)/12; // 430%Fuel at 60%N1 CombustionEfficiency = CombustionEfficiency_N1->GetValue(N1);
FuelFlow_pph = PSFC * EngPower_HP * eff_coef; FuelFlow_pph = PSFC / CombustionEfficiency * EngPower_HP;
Eng_Temperature = ExpSeek(&Eng_Temperature,Eng_ITT_degC,300,400); Eng_Temperature = ExpSeek(&Eng_Temperature,Eng_ITT_degC,300,400);
double ITT_goal = ITT_N1->GetValue((N1-old_N1)*300+N1,1); double ITT_goal = ITT_N1->GetValue((N1-old_N1)*300+N1,1);
@ -368,7 +385,6 @@ double FGTurboProp::SpinUp(void)
double FGTurboProp::Start(void) double FGTurboProp::Start(void)
{ {
double EngPower_HP = 0.0; double EngPower_HP = 0.0;
double eff_coef;
EngStarting = false; EngStarting = false;
if ((N1 > 15.0) && !Starved) { // minimum 15% N2 needed for start if ((N1 > 15.0) && !Starved) { // minimum 15% N2 needed for start
@ -379,8 +395,8 @@ double FGTurboProp::Start(void)
EngPower_HP *= EnginePowerVC->GetValue(); EngPower_HP *= EnginePowerVC->GetValue();
if (EngPower_HP > MaxPower) EngPower_HP = MaxPower; if (EngPower_HP > MaxPower) EngPower_HP = MaxPower;
N1 = ExpSeek(&N1, IdleN1*1.1, Idle_Max_Delay*4, Idle_Max_Delay * 2.4); N1 = ExpSeek(&N1, IdleN1*1.1, Idle_Max_Delay*4, Idle_Max_Delay * 2.4);
eff_coef = 9.333 - (N1)/12; // 430%Fuel at 60%N1 CombustionEfficiency = CombustionEfficiency_N1->GetValue(N1);
FuelFlow_pph = PSFC * EngPower_HP * eff_coef; FuelFlow_pph = PSFC / CombustionEfficiency * EngPower_HP;
Eng_Temperature = ExpSeek(&Eng_Temperature,Eng_ITT_degC,300,400); Eng_Temperature = ExpSeek(&Eng_Temperature,Eng_ITT_degC,300,400);
double ITT_goal = ITT_N1->GetValue((N1-old_N1)*300+N1,1); double ITT_goal = ITT_N1->GetValue((N1-old_N1)*300+N1,1);
Eng_ITT_degC = ExpSeek(&Eng_ITT_degC,ITT_goal,ITT_Delay,ITT_Delay*1.2); Eng_ITT_degC = ExpSeek(&Eng_ITT_degC,ITT_goal,ITT_Delay,ITT_Delay*1.2);
@ -477,6 +493,7 @@ void FGTurboProp::SetDefaults(void)
ITT_Delay = 0.05; ITT_Delay = 0.05;
ReverseMaxPower = 0.0; ReverseMaxPower = 0.0;
BetaRangeThrottleEnd = 0.0; BetaRangeThrottleEnd = 0.0;
CombustionEfficiency = 1.0;
} }
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -541,6 +558,8 @@ void FGTurboProp::bindmodel()
PropertyManager->Tie( property_name.c_str(), &Eng_Temperature); PropertyManager->Tie( property_name.c_str(), &Eng_Temperature);
property_name = base_property_name + "/ielu_intervent"; property_name = base_property_name + "/ielu_intervent";
PropertyManager->Tie( property_name.c_str(), &Ielu_intervent); PropertyManager->Tie( property_name.c_str(), &Ielu_intervent);
property_name = base_property_name + "/combustion_efficiency";
PropertyManager->Tie( property_name.c_str(), &CombustionEfficiency);
} }
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

6
src/FDM/JSBSim/models/propulsion/FGTurboProp.h Normal file → Executable file
View file

@ -44,10 +44,9 @@ INCLUDES
#include <vector> #include <vector>
#include "FGEngine.h" #include "FGEngine.h"
#include "input_output/FGXMLElement.h"
#include "math/FGTable.h" #include "math/FGTable.h"
#define ID_TURBOPROP "$Id: FGTurboProp.h,v 1.16 2011/08/04 13:45:42 jberndt Exp $" #define ID_TURBOPROP "$Id: FGTurboProp.h,v 1.18 2013/11/24 14:22:22 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS FORWARD DECLARATIONS
@ -160,7 +159,6 @@ private:
double N2; ///< N2 double N2; ///< N2
double MaxN1; ///< N1 at 100% throttle double MaxN1; ///< N1 at 100% throttle
double MaxN2; ///< N2 at 100% throttle double MaxN2; ///< N2 at 100% throttle
double IdleFF; ///< Idle Fuel Flow (lbm/hr)
double delay; ///< Inverse spool-up time from idle to 100% (seconds) double delay; ///< Inverse spool-up time from idle to 100% (seconds)
double N1_factor; ///< factor to tie N1 and throttle double N1_factor; ///< factor to tie N1 and throttle
double N2_factor; ///< factor to tie N2 and throttle double N2_factor; ///< factor to tie N2 and throttle
@ -195,6 +193,7 @@ private:
double Velocity; double Velocity;
double rho; double rho;
double PSFC; // Power specific fuel comsumption [lb/(HP*hr)] at best efficiency double PSFC; // Power specific fuel comsumption [lb/(HP*hr)] at best efficiency
double CombustionEfficiency;
double HP; // engine power output double HP; // engine power output
@ -222,6 +221,7 @@ private:
FGTable* ITT_N1; // ITT temperature depending on throttle command FGTable* ITT_N1; // ITT temperature depending on throttle command
FGTable* EnginePowerRPM_N1; FGTable* EnginePowerRPM_N1;
FGTable* EnginePowerVC; FGTable* EnginePowerVC;
FGTable* CombustionEfficiency_N1;
}; };
} }
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%