namespace JSBSim {
-static const char *IdSrc = "$Id: FGFDMExec.cpp,v 1.82 2010/10/07 03:17:29 jberndt Exp $";
+static const char *IdSrc = "$Id: FGFDMExec.cpp,v 1.83 2010/11/07 13:30:54 jberndt Exp $";
static const char *IdHdr = ID_FDMEXEC;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-// Constructors
-FGFDMExec::FGFDMExec(FGPropertyManager* root) : Root(root), delete_root(false)
-{
- FDMctr = new unsigned int;
- *FDMctr = 0;
- Initialize();
- root_overload = (root != NULL);
-}
+// Constructor
-FGFDMExec::FGFDMExec(FGPropertyManager* root, unsigned int* fdmctr) : Root(root), delete_root(false), FDMctr(fdmctr)
+FGFDMExec::FGFDMExec(FGPropertyManager* root, unsigned int* fdmctr) : Root(root), FDMctr(fdmctr)
{
- Initialize();
- root_overload = (root != NULL);
-}
-void FGFDMExec::Initialize()
-{
Frame = 0;
Error = 0;
GroundCallback = 0;
IsChild = false;
holding = false;
Terminate = false;
+ StandAlone = false;
sim_time = 0.0;
dT = 1.0/120.0; // a default timestep size. This is needed for when JSBSim is
if (Root == 0) { // Then this is the root FDM
Root = new FGPropertyManager; // Create the property manager
- delete_root = true;
-
+ StandAlone = true;
+ }
+
+ if (FDMctr == 0) {
FDMctr = new unsigned int; // Create and initialize the child FDM counter
(*FDMctr) = 0;
}
checkTied( instance );
DeAllocate();
- if(FDMctr != 0 && !root_overload) {
+ if (IdFDM == 0) { // Meaning this is no child FDM
if(Root != 0) {
- if (delete_root)
+ if(StandAlone)
delete Root;
Root = 0;
}
- if (IdFDM == 0) { // Meaning this is no child FDM
+ if(FDMctr != 0) {
delete FDMctr;
FDMctr = 0;
}
INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#include "models/FGModel.h"
+#include <vector>
+#include <string>
+
+//#include "models/FGModel.h"
#include "models/FGOutput.h"
#include "models/FGInput.h"
#include "initialization/FGTrim.h"
#include "models/FGPropagate.h"
#include "math/FGColumnVector3.h"
-#include <vector>
-#include <string>
-
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_FDMEXEC "$Id: FGFDMExec.h,v 1.54 2010/10/07 03:17:29 jberndt Exp $"
+#define ID_FDMEXEC "$Id: FGFDMExec.h,v 1.56 2010/11/18 20:37:10 jberndt Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
class FGScript;
class FGTrim;
+class FGAerodynamics;
+class FGAircraft;
+class FGAtmosphere;
+class FGAuxiliary;
+class FGBuoyantForces;
+class FGExternalReactions;
+class FGGroundReactions;
+class FGFCS;
+class FGInertial;
+class FGInput;
+class FGOutput;
+class FGPropagate;
+class FGPropulsion;
+class FGMassBalance;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CLASS DOCUMENTATION
property actually maps toa function call of DoTrim().
@author Jon S. Berndt
- @version $Revision: 1.54 $
+ @version $Revision: 1.56 $
*/
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
public:
- /// Default constructors
- FGFDMExec(FGPropertyManager* root = 0);
- FGFDMExec(FGPropertyManager* root, unsigned int* fdmctr);
+ /// Default constructor
+ FGFDMExec(FGPropertyManager* root = 0, unsigned int* fdmctr = 0);
/// Default destructor
~FGFDMExec();
/// @name Top-level executive State and Model retrieval mechanism
//@{
/// Returns the FGAtmosphere pointer.
- inline FGAtmosphere* GetAtmosphere(void) {return Atmosphere;}
+ FGAtmosphere* GetAtmosphere(void) {return Atmosphere;}
/// Returns the FGFCS pointer.
- inline FGFCS* GetFCS(void) {return FCS;}
+ FGFCS* GetFCS(void) {return FCS;}
/// Returns the FGPropulsion pointer.
- inline FGPropulsion* GetPropulsion(void) {return Propulsion;}
+ FGPropulsion* GetPropulsion(void) {return Propulsion;}
/// Returns the FGAircraft pointer.
- inline FGMassBalance* GetMassBalance(void) {return MassBalance;}
+ FGMassBalance* GetMassBalance(void) {return MassBalance;}
/// Returns the FGAerodynamics pointer
- inline FGAerodynamics* GetAerodynamics(void){return Aerodynamics;}
+ FGAerodynamics* GetAerodynamics(void){return Aerodynamics;}
/// Returns the FGInertial pointer.
- inline FGInertial* GetInertial(void) {return Inertial;}
+ FGInertial* GetInertial(void) {return Inertial;}
/// Returns the FGGroundReactions pointer.
- inline FGGroundReactions* GetGroundReactions(void) {return GroundReactions;}
+ FGGroundReactions* GetGroundReactions(void) {return GroundReactions;}
/// Returns the FGExternalReactions pointer.
- inline FGExternalReactions* GetExternalReactions(void) {return ExternalReactions;}
+ FGExternalReactions* GetExternalReactions(void) {return ExternalReactions;}
/// Returns the FGBuoyantForces pointer.
- inline FGBuoyantForces* GetBuoyantForces(void) {return BuoyantForces;}
+ FGBuoyantForces* GetBuoyantForces(void) {return BuoyantForces;}
/// Returns the FGAircraft pointer.
- inline FGAircraft* GetAircraft(void) {return Aircraft;}
+ FGAircraft* GetAircraft(void) {return Aircraft;}
/// Returns the FGPropagate pointer.
- inline FGPropagate* GetPropagate(void) {return Propagate;}
+ FGPropagate* GetPropagate(void) {return Propagate;}
/// Returns the FGAuxiliary pointer.
- inline FGAuxiliary* GetAuxiliary(void) {return Auxiliary;}
+ FGAuxiliary* GetAuxiliary(void) {return Auxiliary;}
/// Returns the FGInput pointer.
- inline FGInput* GetInput(void) {return Input;}
+ FGInput* GetInput(void) {return Input;}
/// Returns the FGGroundCallback pointer.
- inline FGGroundCallback* GetGroundCallback(void) {return GroundCallback;}
+ FGGroundCallback* GetGroundCallback(void) {return GroundCallback;}
/// Retrieves the script object
- inline FGScript* GetScript(void) {return Script;}
+ FGScript* GetScript(void) {return Script;}
// Returns a pointer to the FGInitialCondition object
- inline FGInitialCondition* GetIC(void) {return IC;}
+ FGInitialCondition* GetIC(void) {return IC;}
// Returns a pointer to the FGTrim object
FGTrim* GetTrim(void);
//@}
/// Retrieves the engine path.
- inline const string& GetEnginePath(void) {return EnginePath;}
+ const string& GetEnginePath(void) {return EnginePath;}
/// Retrieves the aircraft path.
- inline const string& GetAircraftPath(void) {return AircraftPath;}
+ const string& GetAircraftPath(void) {return AircraftPath;}
/// Retrieves the systems path.
- inline const string& GetSystemsPath(void) {return SystemsPath;}
+ const string& GetSystemsPath(void) {return SystemsPath;}
/// Retrieves the full aircraft path name.
- inline const string& GetFullAircraftPath(void) {return FullAircraftPath;}
+ const string& GetFullAircraftPath(void) {return FullAircraftPath;}
/** Retrieves the value of a property.
@param property the name of the property
bool Constructing;
bool modelLoaded;
bool IsChild;
- bool root_overload;
string modelName;
string AircraftPath;
string FullAircraftPath;
FGTrim* Trim;
FGPropertyManager* Root;
- bool delete_root;
+ bool StandAlone;
FGPropertyManager* instance;
// The FDM counter is used to give each child FDM an unique ID. The root FDM has the ID 0
vector <childData*> ChildFDMList;
vector <FGModel*> Models;
- void Initialize();
bool ReadFileHeader(Element*);
bool ReadChild(Element*);
bool ReadPrologue(Element*);
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
-// $Id: JSBSim.cxx,v 1.63 2010/10/07 03:45:40 jberndt Exp $
+// $Id: JSBSim.cxx,v 1.64 2010/10/31 04:49:25 jberndt Exp $
#ifdef HAVE_CONFIG_H
// ground in this area.
double groundCacheRadius = acrad + 2*dt*Propagate->GetUVW().Magnitude();
double alt, slr, lat, lon;
- FGColumnVector3 cart = Auxiliary->GetLocationVRP();
+ FGLocation cart = Auxiliary->GetLocationVRP();
if ( needTrim && startup_trim->getBoolValue() ) {
alt = fgic->GetAltitudeASLFtIC();
slr = fgic->GetSeaLevelRadiusFtIC();
if ( needTrim ) {
if ( startup_trim->getBoolValue() ) {
- double contact[3], d[3], agl;
+ double contact[3], d[3], vel[3], agl;
get_agl_ft(fdmex->GetSimTime(), cart_pos, SG_METER_TO_FEET*2, contact,
- d, d, d, &agl);
+ d, vel, d, &agl);
double terrain_alt = sqrt(contact[0]*contact[0] + contact[1]*contact[1]
+ contact[2]*contact[2]) - fgic->GetSeaLevelRadiusFtIC();
"Ready to trim, terrain elevation is: "
<< terrain_alt * SG_METER_TO_FEET );
+ if (fgGetBool("/sim/presets/onground")) {
+ FGColumnVector3 gndVelNED = cart.GetTec2l()
+ * FGColumnVector3(vel[0], vel[1], vel[2]);
+ fgic->SetVNorthFpsIC(gndVelNED(1));
+ fgic->SetVEastFpsIC(gndVelNED(2));
+ fgic->SetVDownFpsIC(gndVelNED(3));
+ }
fgic->SetTerrainElevationFtIC( terrain_alt );
do_trim();
} else {
namespace JSBSim {
-static const char *IdSrc = "$Id: FGInitialCondition.cpp,v 1.46 2010/09/29 02:19:05 jberndt Exp $";
+static const char *IdSrc = "$Id: FGInitialCondition.cpp,v 1.50 2010/11/20 16:38:43 bcoconni Exp $";
static const char *IdHdr = ID_INITIALCONDITION;
//******************************************************************************
outfile << " <psi unit=\"DEG\"> " << Propagate->GetEuler(ePsi) << " </psi>" << endl;
outfile << " <longitude unit=\"DEG\"> " << Propagate->GetLongitudeDeg() << " </longitude>" << endl;
outfile << " <latitude unit=\"DEG\"> " << Propagate->GetLatitudeDeg() << " </latitude>" << endl;
- outfile << " <altitude unit=\"FT\"> " << Propagate->GetAltitudeASL() << " </altitude>" << endl;
+ outfile << " <altitude unit=\"FT\"> " << Propagate->GetDistanceAGL() << " </altitude>" << endl;
outfile << "</initialize>" << endl;
outfile.close();
} else {
//******************************************************************************
-void FGInitialCondition::SetVgroundFpsIC(double tt) {
- double ua,va,wa;
- double vxz;
+void FGInitialCondition::calcAeroEuler(void)
+{
+ double ua = u + uw;
+ double va = v + vw;
+ double wa = w + ww;
+ vt = sqrt( ua*ua + va*va + wa*wa );
+ alpha = beta = 0.0;
+ calpha = cbeta = 1.0;
+ salpha = sbeta = 0.0;
+ double vxz = sqrt( u*u + w*w );
+ if( w != 0 ) alpha = atan2( w, u );
+ if( vxz != 0 ) {
+ beta = atan2( v, vxz );
+ calpha = u / vxz;
+ salpha = w / vxz;
+ }
+ double vn = sqrt(vxz*vxz + v*v);
+ if (vn != 0) {
+ cbeta = vxz / vn;
+ sbeta = v / vn;
+ }
+}
+
+//******************************************************************************
+void FGInitialCondition::SetVgroundFpsIC(double tt) {
vg=tt;
lastSpeedSet=setvg;
vnorth = vg*cos(psi); veast = vg*sin(psi); vdown = 0;
calcUVWfromNED();
- ua = u + uw; va = v + vw; wa = w + ww;
- vt = sqrt( ua*ua + va*va + wa*wa );
- alpha = beta = 0;
- vxz = sqrt( u*u + w*w );
- if( w != 0 ) alpha = atan2( w, u );
- if( vxz != 0 ) beta = atan2( v, vxz );
+ calcAeroEuler();
mach=vt/fdmex->GetAtmosphere()->GetSoundSpeed();
vc=calcVcas(mach);
ve=vt*sqrt(fdmex->GetAtmosphere()->GetDensityRatio());
void FGInitialCondition::SetUBodyFpsIC(double tt) {
u=tt;
- vt=sqrt(u*u + v*v + w*w);
+ calcAeroEuler();
lastSpeedSet=setuvw;
}
void FGInitialCondition::SetVBodyFpsIC(double tt) {
v=tt;
- vt=sqrt(u*u + v*v + w*w);
+ calcAeroEuler();
lastSpeedSet=setuvw;
}
void FGInitialCondition::SetWBodyFpsIC(double tt) {
w=tt;
- vt=sqrt( u*u + v*v + w*w );
+ calcAeroEuler();
lastSpeedSet=setuvw;
}
//******************************************************************************
void FGInitialCondition::SetVNorthFpsIC(double tt) {
- double ua,va,wa;
- double vxz;
vnorth = tt;
calcUVWfromNED();
- ua = u + uw; va = v + vw; wa = w + ww;
- vt = sqrt( ua*ua + va*va + wa*wa );
- alpha = beta = 0;
- vxz = sqrt( u*u + w*w );
- if( w != 0 ) alpha = atan2( w, u );
- if( vxz != 0 ) beta = atan2( v, vxz );
+ calcAeroEuler();
mach=vt/fdmex->GetAtmosphere()->GetSoundSpeed();
vc=calcVcas(mach);
ve=vt*sqrt(fdmex->GetAtmosphere()->GetDensityRatio());
//******************************************************************************
void FGInitialCondition::SetVEastFpsIC(double tt) {
- double ua,va,wa;
- double vxz;
veast = tt;
calcUVWfromNED();
- ua = u + uw; va = v + vw; wa = w + ww;
- vt = sqrt( ua*ua + va*va + wa*wa );
- alpha = beta = 0;
- vxz = sqrt( u*u + w*w );
- if( w != 0 ) alpha = atan2( w, u );
- if( vxz != 0 ) beta = atan2( v, vxz );
+ calcAeroEuler();
mach=vt/fdmex->GetAtmosphere()->GetSoundSpeed();
vc=calcVcas(mach);
ve=vt*sqrt(fdmex->GetAtmosphere()->GetDensityRatio());
//******************************************************************************
void FGInitialCondition::SetVDownFpsIC(double tt) {
- double ua,va,wa;
- double vxz;
vdown = tt;
calcUVWfromNED();
- ua = u + uw; va = v + vw; wa = w + ww;
- vt = sqrt( ua*ua + va*va + wa*wa );
- alpha = beta = 0;
- vxz = sqrt( u*u + w*w );
- if( w != 0 ) alpha = atan2( w, u );
- if( vxz != 0 ) beta = atan2( v, vxz );
+ calcAeroEuler();
mach=vt/fdmex->GetAtmosphere()->GetSoundSpeed();
vc=calcVcas(mach);
ve=vt*sqrt(fdmex->GetAtmosphere()->GetDensityRatio());
bool FGInitialCondition::Load_v1(void)
{
+ bool result = true;
int n;
if (document->FindElement("latitude"))
Element* running_elements = document->FindElement("running");
while (running_elements) {
n = int(running_elements->GetDataAsNumber());
- propulsion->InitRunning(n);
+ try {
+ propulsion->InitRunning(n);
+ } catch (string str) {
+ cerr << str << endl;
+ result = false;
+ }
running_elements = document->FindNextElement("running");
}
fdmex->RunIC();
- return true;
+ return result;
}
//******************************************************************************
Element* running_elements = document->FindElement("running");
while (running_elements) {
n = int(running_elements->GetDataAsNumber());
- propulsion->InitRunning(n);
+ try {
+ propulsion->InitRunning(n);
+ } catch (string str) {
+ cerr << str << endl;
+ result = false;
+ }
running_elements = document->FindNextElement("running");
}
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_INITIALCONDITION "$Id: FGInitialCondition.h,v 1.20 2010/02/15 03:22:57 jberndt Exp $"
+#define ID_INITIALCONDITION "$Id: FGInitialCondition.h,v 1.22 2010/11/20 16:38:43 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
- vc (calibrated airspeed, ft/sec)
- mach (mach)
- vground (ground speed, ft/sec)
- - running (0 or 1)
+ - running (-1 for all engines, 0 for no engines, 1 ... n for specific engines)
<h3>Properties</h3>
@property ic/vc-kts (read/write) Calibrated airspeed initial condition in knots
@property ic/r-rad_sec (read/write) Yaw rate initial condition in radians/second
@author Tony Peden
- @version "$Id: FGInitialCondition.h,v 1.20 2010/02/15 03:22:57 jberndt Exp $"
+ @version "$Id: FGInitialCondition.h,v 1.22 2010/11/20 16:38:43 bcoconni Exp $"
*/
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
double calcVcas(double Mach);
void calcUVWfromNED(void);
void calcWindUVW(void);
+ void calcAeroEuler(void);
bool findInterval(double x,double guess);
bool solve(double *y, double x);
namespace JSBSim {
-static const char *IdSrc = "$Id: FGScript.cpp,v 1.41 2010/07/08 11:36:28 jberndt Exp $";
+static const char *IdSrc = "$Id: FGScript.cpp,v 1.42 2010/11/24 12:58:39 jberndt Exp $";
static const char *IdHdr = ID_FGSCRIPT;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Events[ev_ctr].Triggered = true;
} else if (Events[ev_ctr].Persistent) { // If the event is persistent, reset the trigger.
-
+ Events[ev_ctr].Triggered = false; // Reset the trigger for persistent events
+ Events[ev_ctr].Notified = false; // Also reset the notification flag
+ } else if (Events[ev_ctr].Continuous) { // If the event is continuous, reset the trigger.
Events[ev_ctr].Triggered = false; // Reset the trigger for persistent events
Events[ev_ctr].Notified = false; // Also reset the notification flag
}
cout << ":" << endl;
if (Events[i].Persistent)
- cout << " " << "Always executes";
+ cout << " " << "Whenever triggered, executes once";
+ else if (Events[i].Continuous)
+ cout << " " << "While true, always executes";
else
- cout << " " << "Executes once";
+ cout << " " << "When first triggered, executes once";
Events[i].Condition->PrintCondition();
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_MODELFUNCTIONS "$Id: FGModelFunctions.h,v 1.2 2010/08/24 10:30:14 jberndt Exp $"
+#define ID_MODELFUNCTIONS "$Id: FGModelFunctions.h,v 1.3 2010/11/17 03:18:37 jberndt Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
CLASS DOCUMENTATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-/**
-@author Jon Berndt
+/** The model functions class provides the capability for loading, storing, and
+ executing arbitrary functions.
+ For certain classes, such as the engine, aerodynamics, ground reactions,
+ mass balance, etc., it can be useful to incorporate special functions that
+ can operate on the local model parameters before and/or after the model
+ executes. For example, there is no inherent chamber pressure calculation
+ done in the rocket engine model. However, an arbitrary function can be added
+ to a specific rocket engine XML configuration file. It would be tagged with
+ a "pre" or "post" type attribute to denote whether the function is to be
+ executed before or after the standard model algorithm.
+ @author Jon Berndt
*/
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DECLARATION: FGModelFunctions
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
- class FGModelFunctions : public FGJSBBase
+class FGModelFunctions : public FGJSBBase
{
public:
~FGModelFunctions();
namespace JSBSim {
-static const char *IdSrc = "$Id: FGAerodynamics.cpp,v 1.34 2010/10/15 11:32:41 jberndt Exp $";
+static const char *IdSrc = "$Id: FGAerodynamics.cpp,v 1.35 2010/11/18 12:38:06 jberndt Exp $";
static const char *IdHdr = ID_AERODYNAMICS;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
bool FGAerodynamics::Run(void)
{
- unsigned int axis_ctr, ctr;
- double alpha, twovel;
if (FGModel::Run()) return true;
if (FDMExec->Holding()) return false; // if paused don't execute
+ unsigned int axis_ctr, ctr;
+ const double alpha=FDMExec->GetAuxiliary()->Getalpha();
+ const double twovel=2*FDMExec->GetAuxiliary()->GetVt();
+ const double qbar = FDMExec->GetAuxiliary()->Getqbar();
+ const double wingarea = FDMExec->GetAircraft()->GetWingArea();
+ const double wingspan = FDMExec->GetAircraft()->GetWingSpan();
+ const double wingchord = FDMExec->GetAircraft()->Getcbar();
+ const double wingincidence = FDMExec->GetAircraft()->GetWingIncidence();
RunPreFunctions();
// calculate some oft-used quantities for speed
- twovel = 2*Auxiliary->GetVt();
if (twovel != 0) {
- bi2vel = Aircraft->GetWingSpan() / twovel;
- ci2vel = Aircraft->Getcbar() / twovel;
+ bi2vel = wingspan / twovel;
+ ci2vel = wingchord / twovel;
}
- alphaw = Auxiliary->Getalpha() + Aircraft->GetWingIncidence();
- alpha = Auxiliary->Getalpha();
- qbar_area = Aircraft->GetWingArea() * Auxiliary->Getqbar();
+ alphaw = alpha + wingincidence;
+ qbar_area = wingarea * qbar;
if (alphaclmax != 0) {
if (alpha > 0.85*alphaclmax) {
}
// Calculate aerodynamic reference point shift, if any
- if (AeroRPShift) vDeltaRP(eX) = AeroRPShift->GetValue()*Aircraft->Getcbar()*12.0;
+ if (AeroRPShift) vDeltaRP(eX) = AeroRPShift->GetValue()*wingchord*12.0;
// Calculate lift coefficient squared
- if ( Auxiliary->Getqbar() > 0) {
- clsq = vFw(eLift) / (Aircraft->GetWingArea()*Auxiliary->Getqbar());
+ if ( qbar > 0) {
+ clsq = vFw(eLift) / (wingarea*qbar);
clsq *= clsq;
}
// Calculate lift Lift over Drag
if ( fabs(vFw(eDrag)) > 0.0) lod = fabs( vFw(eLift) / vFw(eDrag) );
- vDXYZcg = MassBalance->StructuralToBody(Aircraft->GetXYZrp() + vDeltaRP);
+ vDXYZcg = FDMExec->GetMassBalance()->StructuralToBody(FDMExec->GetAircraft()->GetXYZrp() + vDeltaRP);
vMoments = vDXYZcg*vForces; // M = r X F
{
double ca, cb, sa, sb;
- double alpha = Auxiliary->Getalpha();
- double beta = Auxiliary->Getbeta();
+ double alpha = FDMExec->GetAuxiliary()->Getalpha();
+ double beta = FDMExec->GetAuxiliary()->Getbeta();
ca = cos(alpha);
sa = sin(alpha);
double alpha,beta;
double ca, cb, sa, sb;
- alpha = Auxiliary->Getalpha();
- beta = Auxiliary->Getbeta();
+ alpha = FDMExec->GetAuxiliary()->Getalpha();
+ beta = FDMExec->GetAuxiliary()->Getbeta();
ca = cos(alpha);
sa = sin(alpha);
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_AERODYNAMICS "$Id: FGAerodynamics.h,v 1.20 2009/11/12 13:08:11 jberndt Exp $"
+#define ID_AERODYNAMICS "$Id: FGAerodynamics.h,v 1.21 2010/11/18 12:38:06 jberndt Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
Systems may NOT be combined, or a load error will occur.
@author Jon S. Berndt, Tony Peden
- @version $Revision: 1.20 $
+ @version $Revision: 1.21 $
*/
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
/** Gets the total aerodynamic force vector.
@return a force vector reference. */
- FGColumnVector3& GetForces(void) {return vForces;}
+ const FGColumnVector3& GetForces(void) const {return vForces;}
/** Gets the aerodynamic force for an axis.
@param n Axis index. This could be 0, 1, or 2, or one of the
/** Gets the total aerodynamic moment vector.
@return a moment vector reference. */
- FGColumnVector3& GetMoments(void) {return vMoments;}
+ const FGColumnVector3& GetMoments(void) const {return vMoments;}
/** Gets the aerodynamic moment for an axis.
@return the moment about a single axis (as described also in the
/** Retrieves the aerodynamic forces in the wind axes.
@return a reference to a column vector containing the wind axis forces. */
- FGColumnVector3& GetvFw(void) { return vFw; }
+ const FGColumnVector3& GetvFw(void) const { return vFw; }
/** Retrieves the aerodynamic forces in the wind axes, given an axis.
@param axis the axis to return the force for (eX, eY, eZ).
double GetvFw(int axis) const { return vFw(axis); }
/** Retrieves the lift over drag ratio */
- inline double GetLoD(void) const { return lod; }
+ double GetLoD(void) const { return lod; }
/** Retrieves the square of the lift coefficient. */
- inline double GetClSquared(void) const { return clsq; }
- inline double GetAlphaCLMax(void) const { return alphaclmax; }
- inline double GetAlphaCLMin(void) const { return alphaclmin; }
+ double GetClSquared(void) const { return clsq; }
+ double GetAlphaCLMax(void) const { return alphaclmax; }
+ double GetAlphaCLMin(void) const { return alphaclmin; }
- inline double GetHysteresisParm(void) const { return stall_hyst; }
- inline double GetStallWarn(void) const { return impending_stall; }
+ double GetHysteresisParm(void) const { return stall_hyst; }
+ double GetStallWarn(void) const { return impending_stall; }
double GetAlphaW(void) const { return alphaw; }
double GetBI2Vel(void) const { return bi2vel; }
double GetCI2Vel(void) const { return ci2vel; }
- inline void SetAlphaCLMax(double tt) { alphaclmax=tt; }
- inline void SetAlphaCLMin(double tt) { alphaclmin=tt; }
+ void SetAlphaCLMax(double tt) { alphaclmax=tt; }
+ void SetAlphaCLMin(double tt) { alphaclmin=tt; }
/** Gets the strings for the current set of coefficients.
@param delimeter either a tab or comma string depending on output type
#include <sys/stat.h>
#include <sys/types.h>
-
+#include <iostream>
#include <cmath>
#include "FGAircraft.h"
#include "FGPropagate.h"
#include "FGPropulsion.h"
#include "input_output/FGPropertyManager.h"
-#include <iostream>
using namespace std;
GLOBAL DATA
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-static const char *IdSrc = "$Id: FGAircraft.cpp,v 1.28 2010/09/07 00:40:03 jberndt Exp $";
+static const char *IdSrc = "$Id: FGAircraft.cpp,v 1.29 2010/11/18 12:38:06 jberndt Exp $";
static const char *IdHdr = ID_AIRCRAFT;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
vForces.InitMatrix();
if (!HoldDown) {
- vForces += Aerodynamics->GetForces();
- vForces += Propulsion->GetForces();
- vForces += GroundReactions->GetForces();
- vForces += ExternalReactions->GetForces();
- vForces += BuoyantForces->GetForces();
+ vForces += FDMExec->GetAerodynamics()->GetForces();
+ vForces += FDMExec->GetPropulsion()->GetForces();
+ vForces += FDMExec->GetGroundReactions()->GetForces();
+ vForces += FDMExec->GetExternalReactions()->GetForces();
+ vForces += FDMExec->GetBuoyantForces()->GetForces();
} else {
- const FGMatrix33& mTl2b = Propagate->GetTl2b();
- vForces = mTl2b * FGColumnVector3(0,0,-MassBalance->GetWeight());
+ const FGMatrix33& mTl2b = FDMExec->GetPropagate()->GetTl2b();
+ vForces = mTl2b * FGColumnVector3(0,0,-FDMExec->GetMassBalance()->GetWeight());
}
vMoments.InitMatrix();
if (!HoldDown) {
- vMoments += Aerodynamics->GetMoments();
- vMoments += Propulsion->GetMoments();
- vMoments += GroundReactions->GetMoments();
- vMoments += ExternalReactions->GetMoments();
- vMoments += BuoyantForces->GetMoments();
+ vMoments += FDMExec->GetAerodynamics()->GetMoments();
+ vMoments += FDMExec->GetPropulsion()->GetMoments();
+ vMoments += FDMExec->GetGroundReactions()->GetMoments();
+ vMoments += FDMExec->GetExternalReactions()->GetMoments();
+ vMoments += FDMExec->GetBuoyantForces()->GetMoments();
}
- vBodyAccel = vForces/MassBalance->GetMass();
+ vBodyAccel = vForces/FDMExec->GetMassBalance()->GetMass();
- vNcg = vBodyAccel/Inertial->SLgravity();
+ vNcg = vBodyAccel/FDMExec->GetInertial()->SLgravity();
- vNwcg = Aerodynamics->GetTb2w() * vNcg;
+ vNwcg = FDMExec->GetAerodynamics()->GetTb2w() * vNcg;
vNwcg(3) = 1.0 - vNwcg(3);
RunPostFunctions();
double FGAircraft::GetNlf(void) const
{
- return -1*Aerodynamics->GetvFw(3)/MassBalance->GetWeight();
+ return (-FDMExec->GetAerodynamics()->GetvFw(3))/FDMExec->GetMassBalance()->GetWeight();
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_AIRCRAFT "$Id: FGAircraft.h,v 1.15 2009/10/24 22:59:30 jberndt Exp $"
+#define ID_AIRCRAFT "$Id: FGAircraft.h,v 1.16 2010/11/18 12:38:06 jberndt Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
@endcode
@author Jon S. Berndt
- @version $Id: FGAircraft.h,v 1.15 2009/10/24 22:59:30 jberndt Exp $
+ @version $Id: FGAircraft.h,v 1.16 2010/11/18 12:38:06 jberndt Exp $
@see Cooke, Zyda, Pratt, and McGhee, "NPSNET: Flight Simulation Dynamic Modeling
Using Quaternions", Presence, Vol. 1, No. 4, pp. 404-420 Naval Postgraduate
School, January 1994
double GetWingSpan(void) const { return WingSpan; }
/// Gets the average wing chord
double Getcbar(void) const { return cbar; }
- inline double GetWingIncidence(void) const { return WingIncidence; }
- inline double GetWingIncidenceDeg(void) const { return WingIncidence*radtodeg; }
- inline double GetHTailArea(void) const { return HTailArea; }
- inline double GetHTailArm(void) const { return HTailArm; }
- inline double GetVTailArea(void) const { return VTailArea; }
- inline double GetVTailArm(void) const { return VTailArm; }
- inline double Getlbarh(void) const { return lbarh; } // HTailArm / cbar
- inline double Getlbarv(void) const { return lbarv; } // VTailArm / cbar
- inline double Getvbarh(void) const { return vbarh; } // H. Tail Volume
- inline double Getvbarv(void) const { return vbarv; } // V. Tail Volume
- inline FGColumnVector3& GetMoments(void) { return vMoments; }
- inline double GetMoments(int idx) const { return vMoments(idx); }
- inline FGColumnVector3& GetForces(void) { return vForces; }
- inline double GetForces(int idx) const { return vForces(idx); }
- inline FGColumnVector3& GetBodyAccel(void) { return vBodyAccel; }
- inline double GetBodyAccel(int idx) { return vBodyAccel(idx); }
- inline FGColumnVector3& GetNcg (void) { return vNcg; }
- inline double GetNcg(int idx) { return vNcg(idx); }
- inline FGColumnVector3& GetXYZrp(void) { return vXYZrp; }
- inline FGColumnVector3& GetXYZvrp(void) { return vXYZvrp; }
- inline FGColumnVector3& GetXYZep(void) { return vXYZep; }
- inline double GetXYZrp(int idx) const { return vXYZrp(idx); }
- inline double GetXYZvrp(int idx) const { return vXYZvrp(idx); }
- inline double GetXYZep(int idx) const { return vXYZep(idx); }
- inline void SetAircraftName(const std::string& name) {AircraftName = name;}
- inline void SetHoldDown(int hd) {HoldDown = hd;}
- inline int GetHoldDown(void) const {return HoldDown;}
+ double GetWingIncidence(void) const { return WingIncidence; }
+ double GetWingIncidenceDeg(void) const { return WingIncidence*radtodeg; }
+ double GetHTailArea(void) const { return HTailArea; }
+ double GetHTailArm(void) const { return HTailArm; }
+ double GetVTailArea(void) const { return VTailArea; }
+ double GetVTailArm(void) const { return VTailArm; }
+ double Getlbarh(void) const { return lbarh; } // HTailArm / cbar
+ double Getlbarv(void) const { return lbarv; } // VTailArm / cbar
+ double Getvbarh(void) const { return vbarh; } // H. Tail Volume
+ double Getvbarv(void) const { return vbarv; } // V. Tail Volume
+ const FGColumnVector3& GetMoments(void) const { return vMoments; }
+ double GetMoments(int idx) const { return vMoments(idx); }
+ const FGColumnVector3& GetForces(void) const { return vForces; }
+ double GetForces(int idx) const { return vForces(idx); }
+ FGColumnVector3& GetBodyAccel(void) { return vBodyAccel; }
+ double GetBodyAccel(int idx) const { return vBodyAccel(idx); }
+ const FGColumnVector3& GetNcg(void) const { return vNcg; }
+ double GetNcg(int idx) const { return vNcg(idx); }
+ const FGColumnVector3& GetXYZrp(void) const { return vXYZrp; }
+ const FGColumnVector3& GetXYZvrp(void) const { return vXYZvrp; }
+ const FGColumnVector3& GetXYZep(void) const { return vXYZep; }
+ double GetXYZrp(int idx) const { return vXYZrp(idx); }
+ double GetXYZvrp(int idx) const { return vXYZvrp(idx); }
+ double GetXYZep(int idx) const { return vXYZep(idx); }
+ void SetAircraftName(const std::string& name) {AircraftName = name;}
+ void SetHoldDown(int hd) {HoldDown = hd;}
+ int GetHoldDown(void) const {return HoldDown;}
void SetXYZrp(int idx, double value) {vXYZrp(idx) = value;}
double GetNlf(void) const;
- inline FGColumnVector3& GetNwcg(void) { return vNwcg; }
+ FGColumnVector3& GetNwcg(void) { return vNwcg; }
void bind(void);
void unbind(void);
namespace JSBSim {
-static const char *IdSrc = "$Id: FGAtmosphere.cpp,v 1.38 2010/09/16 11:01:24 jberndt Exp $";
+static const char *IdSrc = "$Id: FGAtmosphere.cpp,v 1.40 2010/11/18 12:38:06 jberndt Exp $";
static const char *IdHdr = ID_ATMOSPHERE;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
RunPreFunctions();
T_dev = 0.0;
- h = Propagate->GetAltitudeASL();
+ h = FDMExec->GetPropagate()->GetAltitudeASL();
if (!useExternal) {
Calculate(h);
if (slope == 0) {
intTemperature = reftemp;
- intPressure = refpress*exp(-Inertial->SLgravity()/(reftemp*Reng)*(altitude-htab[i]));
+ intPressure = refpress*exp(-FDMExec->GetInertial()->SLgravity()/(reftemp*Reng)*(altitude-htab[i]));
intDensity = intPressure/(Reng*intTemperature);
} else {
intTemperature = reftemp+slope*(altitude-htab[i]);
- intPressure = refpress*pow(intTemperature/reftemp,-Inertial->SLgravity()/(slope*Reng));
+ intPressure = refpress*pow(intTemperature/reftemp,-FDMExec->GetInertial()->SLgravity()/(slope*Reng));
intDensity = intPressure/(Reng*intTemperature);
}
void FGAtmosphere::Turbulence(void)
{
- double DeltaT = rate*FDMExec->GetDeltaT();
+ const double DeltaT = rate*FDMExec->GetDeltaT();
+ const double wingspan = FDMExec->GetAircraft()->GetWingSpan();
+ const double HOverBMAC = FDMExec->GetAuxiliary()->GetHOverBMAC();
+ const FGMatrix33& Tl2b = FDMExec->GetPropagate()->GetTl2b();
+ const double HTailArm = FDMExec->GetAircraft()->GetHTailArm();
+ const double VTailArm = FDMExec->GetAircraft()->GetVTailArm();
switch (turbType) {
case ttStandard: {
// Diminish turbulence within three wingspans
// of the ground
vTurbulenceNED = TurbGain * Magnitude * vDirection;
- double HOverBMAC = Auxiliary->GetHOverBMAC();
if (HOverBMAC < 3.0)
vTurbulenceNED *= (HOverBMAC / 3.0) * (HOverBMAC / 3.0);
// Need to determine the turbulence change in body axes between two time points.
vTurbulenceGrad = TurbGain*MagnitudeAccel * vDirection;
- vBodyTurbGrad = Propagate->GetTl2b()*vTurbulenceGrad;
+ vBodyTurbGrad = Tl2b*vTurbulenceGrad;
- if (Aircraft->GetWingSpan() > 0) {
- vTurbPQR(eP) = vBodyTurbGrad(eY)/Aircraft->GetWingSpan();
+ if (wingspan > 0) {
+ vTurbPQR(eP) = vBodyTurbGrad(eY)/wingspan;
} else {
vTurbPQR(eP) = vBodyTurbGrad(eY)/30.0;
}
-// if (Aircraft->GetHTailArm() != 0.0)
-// vTurbPQR(eQ) = vBodyTurbGrad(eZ)/Aircraft->GetHTailArm();
+// if (HTailArm != 0.0)
+// vTurbPQR(eQ) = vBodyTurbGrad(eZ)/HTailArm;
// else
// vTurbPQR(eQ) = vBodyTurbGrad(eZ)/10.0;
- if (Aircraft->GetVTailArm() > 0)
- vTurbPQR(eR) = vBodyTurbGrad(eX)/Aircraft->GetVTailArm();
+ if (VTailArm > 0)
+ vTurbPQR(eR) = vBodyTurbGrad(eX)/VTailArm;
else
vTurbPQR(eR) = vBodyTurbGrad(eX)/10.0;
vDirection += vDirectionAccel*DeltaT;
// Diminish z-vector within two wingspans of the ground
- double HOverBMAC = Auxiliary->GetHOverBMAC();
if (HOverBMAC < 2.0) vDirection(eZ) *= HOverBMAC / 2.0;
vDirection.Normalize();
vTurbulenceNED = TurbGain*Magnitude * vDirection;
vTurbulenceGrad = TurbGain*MagnitudeAccel * vDirection;
- vBodyTurbGrad = Propagate->GetTl2b() * vTurbulenceGrad;
- vTurbPQR(eP) = vBodyTurbGrad(eY) / Aircraft->GetWingSpan();
- if (Aircraft->GetHTailArm() > 0)
- vTurbPQR(eQ) = vBodyTurbGrad(eZ) / Aircraft->GetHTailArm();
+ vBodyTurbGrad = Tl2b * vTurbulenceGrad;
+ vTurbPQR(eP) = vBodyTurbGrad(eY) / wingspan;
+ if (HTailArm > 0)
+ vTurbPQR(eQ) = vBodyTurbGrad(eZ) / HTailArm;
else
vTurbPQR(eQ) = vBodyTurbGrad(eZ) / 10.0;
- if (Aircraft->GetVTailArm() > 0)
- vTurbPQR(eR) = vBodyTurbGrad(eX) / Aircraft->GetVTailArm();
+ if (VTailArm > 0)
+ vTurbPQR(eR) = vBodyTurbGrad(eX) / VTailArm;
else
vTurbPQR(eR) = vBodyTurbGrad(eX)/10.0;
// Vertical component of turbulence.
vTurbulenceNED(3) = sinewave * max_vs * TurbGain * Rhythmicity;
vTurbulenceNED(3)+= delta;
- double HOverBMAC = Auxiliary->GetHOverBMAC();
if (HOverBMAC < 3.0)
vTurbulenceNED(3) *= HOverBMAC * 0.3333;
// Turbulence model according to MIL-F-8785C (Flying Qualities of Piloted Aircraft)
double
- h = Propagate->GetDistanceAGL(),
- V = Auxiliary->GetVt(), // true airspeed in ft/s
- b_w = Aircraft->GetWingSpan(),
+ h = FDMExec->GetPropagate()->GetDistanceAGL(),
+ V = FDMExec->GetAuxiliary()->GetVt(), // true airspeed in ft/s
+ b_w = wingspan,
L_u, L_w, sig_u, sig_w;
// clip height functions at 10 ft
nu_v = GaussianRandomNumber(),
nu_w = GaussianRandomNumber(),
nu_p = GaussianRandomNumber(),
- xi_u, xi_v, xi_w, xi_p, xi_q, xi_r;
+ xi_u=0, xi_v=0, xi_w=0, xi_p=0, xi_q=0, xi_r=0;
// values of turbulence NED velocities
vTurbPQR(3) = xi_r;
// vTurbPQR is in the body fixed frame, not NED
- vTurbPQR = Propagate->GetTl2b()*vTurbPQR;
+ vTurbPQR = Tl2b*vTurbPQR;
// hand on the values for the next timestep
xi_u_km1 = xi_u; nu_u_km1 = nu_u;
SENTRY
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#ifndef FGAtmosphere_H
-#define FGAtmosphere_H
+#ifndef FGATMOSPHERE_H
+#define FGATMOSPHERE_H
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
INCLUDES
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_ATMOSPHERE "$Id: FGAtmosphere.h,v 1.23 2010/09/16 11:01:24 jberndt Exp $"
+#define ID_ATMOSPHERE "$Id: FGAtmosphere.h,v 1.24 2010/11/18 12:38:06 jberndt Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
/** Models the 1976 Standard Atmosphere.
@author Tony Peden, Jon Berndt
- @version $Id: FGAtmosphere.h,v 1.23 2010/09/16 11:01:24 jberndt Exp $
+ @version $Id: FGAtmosphere.h,v 1.24 2010/11/18 12:38:06 jberndt Exp $
@see Anderson, John D. "Introduction to Flight, Third Edition", McGraw-Hill,
1989, ISBN 0-07-001641-0
// TOTAL WIND access functions (wind + gust + turbulence)
/// Retrieves the total wind components in NED frame.
- FGColumnVector3& GetTotalWindNED(void) { return vTotalWindNED; }
+ const FGColumnVector3& GetTotalWindNED(void) const { return vTotalWindNED; }
/// Retrieves a total wind component in NED frame.
double GetTotalWindNED(int idx) const {return vTotalWindNED(idx);}
double GetTurbPQR(int idx) const {return vTurbPQR(idx);}
double GetTurbMagnitude(void) const {return Magnitude;}
- FGColumnVector3& GetTurbDirection(void) {return vDirection;}
- FGColumnVector3& GetTurbPQR(void) {return vTurbPQR;}
+ const FGColumnVector3& GetTurbDirection(void) const {return vDirection;}
+ const FGColumnVector3& GetTurbPQR(void) const {return vTurbPQR;}
void SetWindspeed20ft(double ws) { windspeed_at_20ft = ws;}
double GetWindspeed20ft() const { return windspeed_at_20ft;}
namespace JSBSim {
-static const char *IdSrc = "$Id: FGAuxiliary.cpp,v 1.44 2010/10/10 15:10:15 jberndt Exp $";
+static const char *IdSrc = "$Id: FGAuxiliary.cpp,v 1.45 2010/11/18 12:38:06 jberndt Exp $";
static const char *IdHdr = ID_AUXILIARY;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
RunPreFunctions();
- const FGColumnVector3& vPQR = Propagate->GetPQR();
- const FGColumnVector3& vUVW = Propagate->GetUVW();
- const FGColumnVector3& vUVWdot = Propagate->GetUVWdot();
- const FGColumnVector3& vVel = Propagate->GetVel();
+ const double density = FDMExec->GetAtmosphere()->GetDensity();
+ const double soundspeed = FDMExec->GetAtmosphere()->GetSoundSpeed();
+ const double DistanceAGL = FDMExec->GetPropagate()->GetDistanceAGL();
+ const double wingspan = FDMExec->GetAircraft()->GetWingSpan();
+ const FGMatrix33& Tl2b = FDMExec->GetPropagate()->GetTl2b();
+ const FGMatrix33& Tb2l = FDMExec->GetPropagate()->GetTb2l();
- p = Atmosphere->GetPressure();
- rhosl = Atmosphere->GetDensitySL();
- psl = Atmosphere->GetPressureSL();
- sat = Atmosphere->GetTemperature();
+ const FGColumnVector3& vPQR = FDMExec->GetPropagate()->GetPQR();
+ const FGColumnVector3& vUVW = FDMExec->GetPropagate()->GetUVW();
+ const FGColumnVector3& vUVWdot = FDMExec->GetPropagate()->GetUVWdot();
+ const FGColumnVector3& vVel = FDMExec->GetPropagate()->GetVel();
+
+ p = FDMExec->GetAtmosphere()->GetPressure();
+ rhosl = FDMExec->GetAtmosphere()->GetDensitySL();
+ psl = FDMExec->GetAtmosphere()->GetPressureSL();
+ sat = FDMExec->GetAtmosphere()->GetTemperature();
// Rotation
- double cTht = Propagate->GetCosEuler(eTht);
- double sTht = Propagate->GetSinEuler(eTht);
- double cPhi = Propagate->GetCosEuler(ePhi);
- double sPhi = Propagate->GetSinEuler(ePhi);
+ double cTht = FDMExec->GetPropagate()->GetCosEuler(eTht);
+ double sTht = FDMExec->GetPropagate()->GetSinEuler(eTht);
+ double cPhi = FDMExec->GetPropagate()->GetCosEuler(ePhi);
+ double sPhi = FDMExec->GetPropagate()->GetSinEuler(ePhi);
vEulerRates(eTht) = vPQR(eQ)*cPhi - vPQR(eR)*sPhi;
if (cTht != 0.0) {
}
// Combine the wind speed with aircraft speed to obtain wind relative speed
- FGColumnVector3 wind = Propagate->GetTl2b()*Atmosphere->GetTotalWindNED();
- vAeroPQR = vPQR - Atmosphere->GetTurbPQR();
+ FGColumnVector3 wind = Tl2b*FDMExec->GetAtmosphere()->GetTotalWindNED();
+ vAeroPQR = vPQR - FDMExec->GetAtmosphere()->GetTurbPQR();
vAeroUVW = vUVW - wind;
Vt = vAeroUVW.Magnitude();
alpha = beta = adot = bdot = 0;
}
- Re = Vt * Aircraft->Getcbar() / Atmosphere->GetKinematicViscosity();
+ Re = Vt * FDMExec->GetAircraft()->Getcbar() / FDMExec->GetAtmosphere()->GetKinematicViscosity();
- qbar = 0.5*Atmosphere->GetDensity()*Vt*Vt;
- qbarUW = 0.5*Atmosphere->GetDensity()*(vAeroUVW(eU)*vAeroUVW(eU) + vAeroUVW(eW)*vAeroUVW(eW));
- qbarUV = 0.5*Atmosphere->GetDensity()*(vAeroUVW(eU)*vAeroUVW(eU) + vAeroUVW(eV)*vAeroUVW(eV));
- Mach = Vt / Atmosphere->GetSoundSpeed();
- MachU = vMachUVW(eU) = vAeroUVW(eU) / Atmosphere->GetSoundSpeed();
- vMachUVW(eV) = vAeroUVW(eV) / Atmosphere->GetSoundSpeed();
- vMachUVW(eW) = vAeroUVW(eW) / Atmosphere->GetSoundSpeed();
+ qbar = 0.5*density*Vt*Vt;
+ qbarUW = 0.5*density*(vAeroUVW(eU)*vAeroUVW(eU) + vAeroUVW(eW)*vAeroUVW(eW));
+ qbarUV = 0.5*density*(vAeroUVW(eU)*vAeroUVW(eU) + vAeroUVW(eV)*vAeroUVW(eV));
+ Mach = Vt / soundspeed;
+ MachU = vMachUVW(eU) = vAeroUVW(eU) / soundspeed;
+ vMachUVW(eV) = vAeroUVW(eV) / soundspeed;
+ vMachUVW(eW) = vAeroUVW(eW) / soundspeed;
// Position
vcas = veas = 0.0;
}
+ const double SLgravity = FDMExec->GetInertial()->SLgravity();
+
vPilotAccel.InitMatrix();
if ( Vt > 1.0 ) {
- // Use the "+=" operator to avoid the creation of temporary objects.
- vAircraftAccel = Aerodynamics->GetForces();
- vAircraftAccel += Propulsion->GetForces();
- vAircraftAccel += GroundReactions->GetForces();
- vAircraftAccel += ExternalReactions->GetForces();
- vAircraftAccel += BuoyantForces->GetForces();
-
- vAircraftAccel /= MassBalance->GetMass();
+ vAircraftAccel = FDMExec->GetAircraft()->GetBodyAccel();
// Nz is Acceleration in "g's", along normal axis (-Z body axis)
- Nz = -vAircraftAccel(eZ)/Inertial->SLgravity();
- vToEyePt = MassBalance->StructuralToBody(Aircraft->GetXYZep());
- vPilotAccel = vAircraftAccel + Propagate->GetPQRdot() * vToEyePt;
+ Nz = -vAircraftAccel(eZ)/SLgravity;
+ vToEyePt = FDMExec->GetMassBalance()->StructuralToBody(FDMExec->GetAircraft()->GetXYZep());
+ vPilotAccel = vAircraftAccel + FDMExec->GetPropagate()->GetPQRdot() * vToEyePt;
vPilotAccel += vPQR * (vPQR * vToEyePt);
} else {
// The line below handles low velocity (and on-ground) cases, basically
// any jitter that could be introduced by the landing gear. Theoretically,
// this branch could be eliminated, with a penalty of having a short
// transient at startup (lasting only a fraction of a second).
- vPilotAccel = Propagate->GetTl2b() * FGColumnVector3( 0.0, 0.0, -Inertial->SLgravity() );
- Nz = -vPilotAccel(eZ)/Inertial->SLgravity();
+ vPilotAccel = Tl2b * FGColumnVector3( 0.0, 0.0, -SLgravity );
+ Nz = -vPilotAccel(eZ)/SLgravity;
}
- vPilotAccelN = vPilotAccel/Inertial->SLgravity();
+ vPilotAccelN = vPilotAccel/SLgravity;
// VRP computation
- const FGLocation& vLocation = Propagate->GetLocation();
- FGColumnVector3& vrpStructural = Aircraft->GetXYZvrp();
- FGColumnVector3 vrpBody = MassBalance->StructuralToBody( vrpStructural );
- FGColumnVector3 vrpLocal = Propagate->GetTb2l() * vrpBody;
+ const FGLocation& vLocation = FDMExec->GetPropagate()->GetLocation();
+ const FGColumnVector3& vrpStructural = FDMExec->GetAircraft()->GetXYZvrp();
+ const FGColumnVector3 vrpBody = FDMExec->GetMassBalance()->StructuralToBody( vrpStructural );
+ const FGColumnVector3 vrpLocal = Tb2l * vrpBody;
vLocationVRP = vLocation.LocalToLocation( vrpLocal );
// Recompute some derived values now that we know the dependent parameters values ...
- hoverbcg = Propagate->GetDistanceAGL() / Aircraft->GetWingSpan();
+ hoverbcg = DistanceAGL / wingspan;
- FGColumnVector3 vMac = Propagate->GetTb2l()*MassBalance->StructuralToBody(Aircraft->GetXYZrp());
- hoverbmac = (Propagate->GetDistanceAGL() + vMac(3)) / Aircraft->GetWingSpan();
+ FGColumnVector3 vMac = Tb2l*FDMExec->GetMassBalance()->StructuralToBody(FDMExec->GetAircraft()->GetXYZrp());
+ hoverbmac = (DistanceAGL + vMac(3)) / wingspan;
// when all model are executed,
// please calculate the distance from the initial point
{
double psiw,vw;
- psiw = Atmosphere->GetWindPsi();
- vw = Atmosphere->GetTotalWindNED().Magnitude();
+ psiw = FDMExec->GetAtmosphere()->GetWindPsi();
+ vw = FDMExec->GetAtmosphere()->GetTotalWindNED().Magnitude();
- return vw*cos(psiw - Propagate->GetEuler(ePsi));
+ return vw*cos(psiw - FDMExec->GetPropagate()->GetEuler(ePsi));
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
{
double psiw,vw;
- psiw = Atmosphere->GetWindPsi();
- vw = Atmosphere->GetTotalWindNED().Magnitude();
+ psiw = FDMExec->GetAtmosphere()->GetWindPsi();
+ vw = FDMExec->GetAtmosphere()->GetTotalWindNED().Magnitude();
+
+ return vw*sin(psiw - FDMExec->GetPropagate()->GetEuler(ePsi));
+}
- return vw*sin(psiw - Propagate->GetEuler(ePsi));
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+double FGAuxiliary::GethVRP(void) const
+{
+ return vLocationVRP.GetRadius() - FDMExec->GetPropagate()->GetSeaLevelRadius();
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void FGAuxiliary::CalculateRelativePosition(void)
{
- const double earth_radius_mt = Inertial->GetRefRadius()*fttom;
+ const double earth_radius_mt = FDMExec->GetInertial()->GetRefRadius()*fttom;
lat_relative_position=(FDMExec->GetPropagate()->GetLatitude() - FDMExec->GetIC()->GetLatitudeDegIC() *degtorad)*earth_radius_mt;
lon_relative_position=(FDMExec->GetPropagate()->GetLongitude() - FDMExec->GetIC()->GetLongitudeDegIC()*degtorad)*earth_radius_mt;
relative_position = sqrt(lat_relative_position*lat_relative_position + lon_relative_position*lon_relative_position);
#include "FGModel.h"
#include "math/FGColumnVector3.h"
#include "math/FGLocation.h"
-#include "FGPropagate.h"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_AUXILIARY "$Id: FGAuxiliary.h,v 1.17 2009/10/24 22:59:30 jberndt Exp $"
+#define ID_AUXILIARY "$Id: FGAuxiliary.h,v 1.19 2010/11/18 12:38:06 jberndt Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
The radius R is calculated below in the vector vToEyePt.
@author Tony Peden, Jon Berndt
- @version $Id: FGAuxiliary.h,v 1.17 2009/10/24 22:59:30 jberndt Exp $
+ @version $Id: FGAuxiliary.h,v 1.19 2010/11/18 12:38:06 jberndt Exp $
*/
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
const FGColumnVector3& GetAeroUVW (void) const { return vAeroUVW; }
const FGLocation& GetLocationVRP(void) const { return vLocationVRP; }
- double GethVRP(void) const { return vLocationVRP.GetRadius() - Propagate->GetSeaLevelRadius(); }
+ double GethVRP(void) const;
double GetAeroUVW (int idx) const { return vAeroUVW(idx); }
double Getalpha (void) const { return alpha; }
double Getbeta (void) const { return beta; }
namespace JSBSim {
-static const char *IdSrc = "$Id: FGBuoyantForces.cpp,v 1.13 2010/09/07 00:40:03 jberndt Exp $";
+static const char *IdSrc = "$Id: FGBuoyantForces.cpp,v 1.14 2010/11/18 12:38:06 jberndt Exp $";
static const char *IdHdr = ID_BUOYANTFORCES;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
gasCellJ = FGMatrix33();
for (unsigned int i=0; i < size; i++) {
- FGColumnVector3 v = MassBalance->StructuralToBody( Cells[i]->GetXYZ() );
+ FGColumnVector3 v = FDMExec->GetMassBalance()->StructuralToBody( Cells[i]->GetXYZ() );
// Body basis is in FT.
const double mass = Cells[i]->GetMass();
INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+#include <string>
#include "FGFDMExec.h"
#include "FGJSBBase.h"
#include "models/propulsion/FGForce.h"
-#include <string>
#include "input_output/FGPropertyManager.h"
#include "math/FGColumnVector3.h"
#include "math/FGFunction.h"
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_EXTERNALFORCE "$Id: FGExternalForce.h,v 1.8 2009/10/02 10:30:09 jberndt Exp $"
+#define ID_EXTERNALFORCE "$Id: FGExternalForce.h,v 1.9 2010/11/18 12:38:06 jberndt Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+#include <vector>
#include "FGModel.h"
#include "FGExternalForce.h"
-#include <vector>
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_EXTERNALREACTIONS "$Id: FGExternalReactions.h,v 1.9 2009/10/24 22:59:30 jberndt Exp $"
+#define ID_EXTERNALREACTIONS "$Id: FGExternalReactions.h,v 1.10 2010/11/18 12:38:06 jberndt Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
/** Retrieves the total forces defined in the external reactions.
@return the total force in pounds.
*/
- FGColumnVector3 GetForces(void) {return vTotalForces;}
+ FGColumnVector3 GetForces(void) const {return vTotalForces;}
/** Retrieves the total moment resulting from the forces defined in the external reactions.
@return the total moment in foot-pounds.
*/
- FGColumnVector3 GetMoments(void) {return vTotalMoments;}
+ FGColumnVector3 GetMoments(void) const {return vTotalMoments;}
private:
namespace JSBSim {
-static const char *IdSrc = "$Id: FGFCS.cpp,v 1.71 2010/09/28 02:54:03 jberndt Exp $";
+static const char *IdSrc = "$Id: FGFCS.cpp,v 1.72 2010/11/18 12:38:06 jberndt Exp $";
static const char *IdHdr = ID_FCS;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// Set the default steering angle
for (i=0; i<SteerPosDeg.size(); i++) {
- FGLGear* gear = GroundReactions->GetGearUnit(i);
+ FGLGear* gear = FDMExec->GetGroundReactions()->GetGearUnit(i);
SteerPosDeg[i] = gear->GetDefaultSteerAngle( GetDsCmd() );
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-string FGFCS::GetComponentStrings(const string& delimiter)
+string FGFCS::GetComponentStrings(const string& delimiter) const
{
unsigned int comp;
string CompStrings = "";
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-string FGFCS::GetComponentValues(const string& delimiter)
+string FGFCS::GetComponentValues(const string& delimiter) const
{
std::ostringstream buf;
string tmp;
for (i=0; i<SteerPosDeg.size(); i++) {
- if (GroundReactions->GetGearUnit(i)->GetSteerable()) {
+ if (FDMExec->GetGroundReactions()->GetGearUnit(i)->GetSteerable()) {
tmp = CreateIndexedPropertyName("fcs/steer-pos-deg", i);
PropertyManager->Tie( tmp.c_str(), this, i, &FGFCS::GetSteerPosDeg, &FGFCS::SetSteerPosDeg);
}
/** Retrieves all component names for inclusion in output stream
@param delimiter either a tab or comma string depending on output type
@return a string containing the descriptive names for all components */
- std::string GetComponentStrings(const std::string& delimiter);
+ std::string GetComponentStrings(const std::string& delimiter) const;
/** Retrieves all component outputs for inclusion in output stream
@param delimiter either a tab or comma string depending on output type
@return a string containing the numeric values for the current set of
component outputs */
- std::string GetComponentValues(const std::string& delimiter);
+ std::string GetComponentValues(const std::string& delimiter) const;
/// @name Pilot input command setting
//@{
namespace JSBSim {
-static const char *IdSrc = "$Id: FGGroundReactions.cpp,v 1.30 2010/09/07 00:40:03 jberndt Exp $";
+static const char *IdSrc = "$Id: FGGroundReactions.cpp,v 1.31 2010/11/18 12:38:06 jberndt Exp $";
static const char *IdHdr = ID_GROUNDREACTIONS;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Element* contact_element = el->FindElement("contact");
while (contact_element) {
lGear.push_back(new FGLGear(contact_element, FDMExec, num++));
- FCS->AddGear(); // make the FCS aware of the landing gear
+ FDMExec->GetFCS()->AddGear(); // make the FCS aware of the landing gear
contact_element = el->FindNextElement("contact");
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-string FGGroundReactions::GetGroundReactionStrings(string delimeter)
+string FGGroundReactions::GetGroundReactionStrings(string delimeter) const
{
std::ostringstream buf;
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-string FGGroundReactions::GetGroundReactionValues(string delimeter)
+string FGGroundReactions::GetGroundReactionValues(string delimeter) const
{
std::ostringstream buf;
#include "math/FGColumnVector3.h"
#include "input_output/FGXMLElement.h"
-#define ID_GROUNDREACTIONS "$Id: FGGroundReactions.h,v 1.18 2010/09/07 00:40:03 jberndt Exp $"
+#define ID_GROUNDREACTIONS "$Id: FGGroundReactions.h,v 1.19 2010/11/18 12:38:06 jberndt Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
bool InitModel(void);
bool Run(void);
bool Load(Element* el);
- FGColumnVector3& GetForces(void) {return vForces;}
+ const FGColumnVector3& GetForces(void) const {return vForces;}
double GetForces(int idx) const {return vForces(idx);}
- FGColumnVector3& GetMoments(void) {return vMoments;}
+ const FGColumnVector3& GetMoments(void) const {return vMoments;}
double GetMoments(int idx) const {return vMoments(idx);}
- string GetGroundReactionStrings(string delimeter);
- string GetGroundReactionValues(string delimeter);
+ string GetGroundReactionStrings(string delimeter) const;
+ string GetGroundReactionValues(string delimeter) const;
bool GetWOW(void) const;
void UpdateForcesAndMoments(void);
/** Gets a gear instance
@param gear index of gear instance
@return a pointer to the FGLGear instance of the gear unit requested */
- inline FGLGear* GetGearUnit(int gear) { return lGear[gear]; }
+ FGLGear* GetGearUnit(int gear) const { return lGear[gear]; }
private:
vector <FGLGear*> lGear;
namespace JSBSim {
-static const char *IdSrc = "$Id: FGInertial.cpp,v 1.19 2010/10/10 15:06:38 jberndt Exp $";
+static const char *IdSrc = "$Id: FGInertial.cpp,v 1.20 2010/11/18 12:38:06 jberndt Exp $";
static const char *IdHdr = ID_INERTIAL;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
RunPreFunctions();
// Gravitation accel
- double r = Propagate->GetRadius();
+ double r = FDMExec->GetPropagate()->GetRadius();
gAccel = GetGAccel(r);
earthPosAngle += FDMExec->GetDeltaT()*RotationRate;
// Gravitation accel
double r = position.Magnitude();
- double lat = Propagate->GetLatitude();
+ double lat = FDMExec->GetPropagate()->GetLatitude();
double sinLat = sin(lat);
double adivr = a/r;
ostringstream info;
info << "JSBSim version: " << JSBSim_version << endl;
info << "Config File version: " << needed_cfg_version << endl;
- info << "Aircraft simulated: " << Aircraft->GetAircraftName() << endl;
+// info << "Aircraft simulated: " << Aircraft->GetAircraftName() << endl;
info << "Simulation time: " << setw(8) << setprecision(3) << FDMExec->GetSimTime() << endl;
socket->Reply(info.str());
namespace JSBSim {
-static const char *IdSrc = "$Id: FGMassBalance.cpp,v 1.33 2010/09/07 00:40:03 jberndt Exp $";
+static const char *IdSrc = "$Id: FGMassBalance.cpp,v 1.34 2010/11/18 12:38:06 jberndt Exp $";
static const char *IdHdr = ID_MASSBALANCE;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if (FDMExec->GetChildFDM(fdm)->mated) ChildFDMWeight += FDMExec->GetChildFDM(fdm)->exec->GetMassBalance()->GetWeight();
}
- Weight = EmptyWeight + Propulsion->GetTanksWeight() + GetTotalPointMassWeight()
- + BuoyantForces->GetGasMass()*slugtolb + ChildFDMWeight;
+ Weight = EmptyWeight + FDMExec->GetPropulsion()->GetTanksWeight() + GetTotalPointMassWeight()
+ + FDMExec->GetBuoyantForces()->GetGasMass()*slugtolb + ChildFDMWeight;
Mass = lbtoslug*Weight;
if (FDMExec->GetChildFDM(fdm)->mated) ChildFDMWeight += FDMExec->GetChildFDM(fdm)->exec->GetMassBalance()->GetWeight();
}
- Weight = EmptyWeight + Propulsion->GetTanksWeight() + GetTotalPointMassWeight()
- + BuoyantForces->GetGasMass()*slugtolb + ChildFDMWeight;
+ Weight = EmptyWeight + FDMExec->GetPropulsion()->GetTanksWeight() + GetTotalPointMassWeight()
+ + FDMExec->GetBuoyantForces()->GetGasMass()*slugtolb + ChildFDMWeight;
Mass = lbtoslug*Weight;
// Calculate new CG
- vXYZcg = (Propulsion->GetTanksMoment() + EmptyWeight*vbaseXYZcg
+ vXYZcg = (FDMExec->GetPropulsion()->GetTanksMoment() + EmptyWeight*vbaseXYZcg
+ GetPointMassMoment()
- + BuoyantForces->GetGasMassMoment()) / Weight;
+ + FDMExec->GetBuoyantForces()->GetGasMassMoment()) / Weight;
// Track frame-by-frame delta CG, and move the EOM-tracked location
// by this amount.
vDeltaXYZcg = vXYZcg - vLastXYZcg;
vDeltaXYZcgBody = StructuralToBody(vLastXYZcg) - StructuralToBody(vXYZcg);
vLastXYZcg = vXYZcg;
- Propagate->NudgeBodyLocation(vDeltaXYZcgBody);
+ FDMExec->GetPropagate()->NudgeBodyLocation(vDeltaXYZcgBody);
// Calculate new total moments of inertia
mJ += GetPointmassInertia( lbtoslug * EmptyWeight, vbaseXYZcg );
// Then add the contributions from the additional pointmasses.
mJ += CalculatePMInertias();
- mJ += Propulsion->CalculateTankInertias();
- mJ += BuoyantForces->GetGasMassInertia();
+ mJ += FDMExec->GetPropulsion()->CalculateTankInertias();
+ mJ += FDMExec->GetBuoyantForces()->GetGasMassInertia();
Ixx = mJ(1,1);
Iyy = mJ(2,2);
<< setw(12) << pm->GetPointMassMoI(3,3) << endl;
}
- for (unsigned int i=0;i<Propulsion->GetNumTanks() ;i++) {
- FGTank* tank = Propulsion->GetTank(i);
+ for (unsigned int i=0;i<FDMExec->GetPropulsion()->GetNumTanks() ;i++) {
+ FGTank* tank = FDMExec->GetPropulsion()->GetTank(i);
string tankname="";
if (tank->GetType() == FGTank::ttFUEL && tank->GetGrainType() != FGTank::gtUNKNOWN) {
tankname = "Solid Fuel";
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_MASSBALANCE "$Id: FGMassBalance.h,v 1.21 2010/08/12 04:07:11 jberndt Exp $"
+#define ID_MASSBALANCE "$Id: FGMassBalance.h,v 1.22 2010/11/18 12:38:06 jberndt Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONSS
*/
FGColumnVector3 StructuralToBody(const FGColumnVector3& r) const;
- inline void SetEmptyWeight(double EW) { EmptyWeight = EW;}
- inline void SetBaseCG(const FGColumnVector3& CG) {vbaseXYZcg = vXYZcg = CG;}
+ void SetEmptyWeight(double EW) { EmptyWeight = EW;}
+ void SetBaseCG(const FGColumnVector3& CG) {vbaseXYZcg = vXYZcg = CG;}
void AddPointMass(Element* el);
double GetTotalPointMassWeight(void);
FGColumnVector3& GetPointMassMoment(void);
- FGMatrix33& GetJ(void) {return mJ;}
- FGMatrix33& GetJinv(void) {return mJinv;}
+ const FGMatrix33& GetJ(void) const {return mJ;}
+ const FGMatrix33& GetJinv(void) const {return mJinv;}
void SetAircraftBaseInertias(FGMatrix33 BaseJ) {baseJ = BaseJ;}
void GetMassPropertiesReport(void) const;
namespace JSBSim {
-static const char *IdSrc = "$Id: FGModel.cpp,v 1.15 2010/09/07 00:19:38 jberndt Exp $";
+static const char *IdSrc = "$Id: FGModel.cpp,v 1.16 2010/11/18 12:38:06 jberndt Exp $";
static const char *IdHdr = ID_MODEL;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
{
FDMExec = fdmex;
- Atmosphere = 0;
- FCS = 0;
- Propulsion = 0;
- MassBalance = 0;
- Aerodynamics = 0;
- Inertial = 0;
- GroundReactions = 0;
- ExternalReactions = 0;
- Aircraft = 0;
- Propagate = 0;
- Auxiliary = 0;
-
//in order for FGModel derived classes to self-bind (that is, call
//their bind function in the constructor, the PropertyManager pointer
//must be brought up now.
bool FGModel::InitModel(void)
{
- Atmosphere = FDMExec->GetAtmosphere();
- FCS = FDMExec->GetFCS();
- Propulsion = FDMExec->GetPropulsion();
- MassBalance = FDMExec->GetMassBalance();
- Aerodynamics = FDMExec->GetAerodynamics();
- Inertial = FDMExec->GetInertial();
- GroundReactions = FDMExec->GetGroundReactions();
- ExternalReactions = FDMExec->GetExternalReactions();
- BuoyantForces = FDMExec->GetBuoyantForces();
- Aircraft = FDMExec->GetAircraft();
- Propagate = FDMExec->GetPropagate();
- Auxiliary = FDMExec->GetAuxiliary();
-
- if (!Atmosphere ||
- !FCS ||
- !Propulsion ||
- !MassBalance ||
- !Aerodynamics ||
- !Inertial ||
- !GroundReactions ||
- !ExternalReactions ||
- !Aircraft ||
- !Propagate ||
- !Auxiliary) return(false);
- else return(true);
+ return true;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_MODEL "$Id: FGModel.h,v 1.16 2010/09/22 11:33:40 jberndt Exp $"
+#define ID_MODEL "$Id: FGModel.h,v 1.18 2010/11/18 12:38:06 jberndt Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
namespace JSBSim {
class FGFDMExec;
-class FGAtmosphere;
-class FGFCS;
-class FGPropulsion;
-class FGMassBalance;
-class FGAerodynamics;
-class FGInertial;
-class FGGroundReactions;
-class FGExternalReactions;
-class FGBuoyantForces;
-class FGAircraft;
-class FGPropagate;
-class FGAuxiliary;
class Element;
class FGPropertyManager;
virtual void Debug(int from);
FGFDMExec* FDMExec;
- FGAtmosphere* Atmosphere;
- FGFCS* FCS;
- FGPropulsion* Propulsion;
- FGMassBalance* MassBalance;
- FGAerodynamics* Aerodynamics;
- FGInertial* Inertial;
- FGGroundReactions* GroundReactions;
- FGExternalReactions* ExternalReactions;
- FGBuoyantForces* BuoyantForces;
- FGAircraft* Aircraft;
- FGPropagate* Propagate;
- FGAuxiliary* Auxiliary;
FGPropertyManager* PropertyManager;
};
}
namespace JSBSim {
-static const char *IdSrc = "$Id: FGOutput.cpp,v 1.49 2010/10/15 11:30:29 jberndt Exp $";
+static const char *IdSrc = "$Id: FGOutput.cpp,v 1.50 2010/11/18 12:38:06 jberndt Exp $";
static const char *IdHdr = ID_OUTPUT;
// (stolen from FGFS native_fdm.cxx)
void FGOutput::DelimitedOutput(const string& fname)
{
+ const FGAerodynamics* Aerodynamics = FDMExec->GetAerodynamics();
+ const FGAuxiliary* Auxiliary = FDMExec->GetAuxiliary();
+ const FGAircraft* Aircraft = FDMExec->GetAircraft();
+ const FGAtmosphere* Atmosphere = FDMExec->GetAtmosphere();
+ const FGPropulsion* Propulsion = FDMExec->GetPropulsion();
+ const FGMassBalance* MassBalance = FDMExec->GetMassBalance();
+ const FGPropagate* Propagate = FDMExec->GetPropagate();
+ const FGFCS* FCS = FDMExec->GetFCS();
+ const FGInertial* Inertial = FDMExec->GetInertial();
+ const FGGroundReactions* GroundReactions = FDMExec->GetGroundReactions();
+ const FGExternalReactions* ExternalReactions = FDMExec->GetExternalReactions();
+ const FGBuoyantForces* BuoyantForces = FDMExec->GetBuoyantForces();
+
streambuf* buffer;
string scratch = "";
void FGOutput::SocketDataFill(FGNetFDM* net)
{
+ const FGAerodynamics* Aerodynamics = FDMExec->GetAerodynamics();
+ const FGAuxiliary* Auxiliary = FDMExec->GetAuxiliary();
+ const FGPropulsion* Propulsion = FDMExec->GetPropulsion();
+ const FGMassBalance* MassBalance = FDMExec->GetMassBalance();
+ const FGPropagate* Propagate = FDMExec->GetPropagate();
+ const FGFCS* FCS = FDMExec->GetFCS();
+ const FGGroundReactions* GroundReactions = FDMExec->GetGroundReactions();
unsigned int i;
// Version
void FGOutput::SocketOutput(void)
{
+ const FGAerodynamics* Aerodynamics = FDMExec->GetAerodynamics();
+ const FGAuxiliary* Auxiliary = FDMExec->GetAuxiliary();
+ const FGPropulsion* Propulsion = FDMExec->GetPropulsion();
+ const FGMassBalance* MassBalance = FDMExec->GetMassBalance();
+ const FGPropagate* Propagate = FDMExec->GetPropagate();
+ const FGFCS* FCS = FDMExec->GetFCS();
+ const FGAtmosphere* Atmosphere = FDMExec->GetAtmosphere();
+ const FGAircraft* Aircraft = FDMExec->GetAircraft();
+ const FGGroundReactions* GroundReactions = FDMExec->GetGroundReactions();
+
string asciiData, scratch;
if (socket == NULL) return;
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_OUTPUT "$Id: FGOutput.h,v 1.18 2010/10/15 11:30:29 jberndt Exp $"
+#define ID_OUTPUT "$Id: FGOutput.h,v 1.19 2010/10/31 04:48:46 jberndt Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
propulsion ON|OFF
</pre>
NOTE that Time is always output with the data.
- @version $Id: FGOutput.h,v 1.18 2010/10/15 11:30:29 jberndt Exp $
+ @version $Id: FGOutput.h,v 1.19 2010/10/31 04:48:46 jberndt Exp $
*/
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
/** Subsystem: Propulsion (= 4096) */ ssPropulsion = 4096
} subsystems;
-
FGNetFDM fgSockBuf;
private:
namespace JSBSim {
-static const char *IdSrc = "$Id: FGPropagate.cpp,v 1.71 2010/10/15 11:34:09 jberndt Exp $";
+static const char *IdSrc = "$Id: FGPropagate.cpp,v 1.73 2010/11/18 12:38:06 jberndt Exp $";
static const char *IdHdr = ID_PROPAGATE;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
integrator_rotational_position = eAdamsBashforth2;
integrator_translational_position = eTrapezoidal;
- VState.dqPQRdot.resize(4, FGColumnVector3(0.0,0.0,0.0));
VState.dqPQRidot.resize(4, FGColumnVector3(0.0,0.0,0.0));
VState.dqUVWidot.resize(4, FGColumnVector3(0.0,0.0,0.0));
VState.dqInertialVelocity.resize(4, FGColumnVector3(0.0,0.0,0.0));
if (!FGModel::InitModel()) return false;
// For initialization ONLY:
- SeaLevelRadius = LocalTerrainRadius = Inertial->GetRefRadius();
+ SeaLevelRadius = LocalTerrainRadius = FDMExec->GetInertial()->GetRefRadius();
VState.vLocation.SetRadius( LocalTerrainRadius + 4.0 );
- VState.vLocation.SetEllipse(Inertial->GetSemimajor(), Inertial->GetSemiminor());
- vOmegaEarth = FGColumnVector3( 0.0, 0.0, Inertial->omega() ); // Earth rotation vector
+ VState.vLocation.SetEllipse(FDMExec->GetInertial()->GetSemimajor(), FDMExec->GetInertial()->GetSemiminor());
+ vOmegaEarth = FGColumnVector3( 0.0, 0.0, FDMExec->GetInertial()->omega() ); // Earth rotation vector
vPQRdot.InitMatrix();
vQtrndot = FGQuaternion(0,0,0);
vUVWdot.InitMatrix();
vInertialVelocity.InitMatrix();
- VState.dqPQRdot.resize(4, FGColumnVector3(0.0,0.0,0.0));
VState.dqPQRidot.resize(4, FGColumnVector3(0.0,0.0,0.0));
VState.dqUVWidot.resize(4, FGColumnVector3(0.0,0.0,0.0));
VState.dqInertialVelocity.resize(4, FGColumnVector3(0.0,0.0,0.0));
FGIC->GetLatitudeRadIC(),
FGIC->GetAltitudeASLFtIC() + FGIC->GetSeaLevelRadiusFtIC() );
- VState.vLocation.SetEarthPositionAngle(Inertial->GetEarthPositionAngle());
+ VState.vLocation.SetEarthPositionAngle(FDMExec->GetInertial()->GetEarthPositionAngle());
Ti2ec = GetTi2ec(); // ECI to ECEF transform
Tec2i = Ti2ec.Transposed(); // ECEF to ECI frame transform
// matrices that are consistent with the new state of the vehicle
// 1. Update the Earth position angle (EPA)
- VState.vLocation.SetEarthPositionAngle(Inertial->GetEarthPositionAngle());
+ VState.vLocation.SetEarthPositionAngle(FDMExec->GetInertial()->GetEarthPositionAngle());
// 2. Update the Ti2ec and Tec2i transforms from the updated EPA
Ti2ec = GetTi2ec(); // ECI to ECEF transform
void FGPropagate::CalculatePQRdot(void)
{
- const FGColumnVector3& vMoments = Aircraft->GetMoments(); // current moments
- const FGMatrix33& J = MassBalance->GetJ(); // inertia matrix
- const FGMatrix33& Jinv = MassBalance->GetJinv(); // inertia matrix inverse
+ const FGColumnVector3& vMoments = FDMExec->GetAircraft()->GetMoments(); // current moments
+ const FGMatrix33& J = FDMExec->GetMassBalance()->GetJ(); // inertia matrix
+ const FGMatrix33& Jinv = FDMExec->GetMassBalance()->GetJinv(); // inertia matrix inverse
// Compute body frame rotational accelerations based on the current body
// moments and the total inertial angular velocity expressed in the body
void FGPropagate::CalculateUVWdot(void)
{
- double mass = MassBalance->GetMass(); // mass
- const FGColumnVector3& vForces = Aircraft->GetForces(); // current forces
+ double mass = FDMExec->GetMassBalance()->GetMass(); // mass
+ const FGColumnVector3& vForces = FDMExec->GetAircraft()->GetForces(); // current forces
vUVWdot = vForces/mass - (VState.vPQR + 2.0*(Ti2b *vOmegaEarth)) * VState.vUVW;
// Include Gravitation accel
switch (gravType) {
case gtStandard:
- vGravAccel = Tl2b * FGColumnVector3( 0.0, 0.0, Inertial->GetGAccel(VehicleRadius) );
+ vGravAccel = Tl2b * FGColumnVector3( 0.0, 0.0, FDMExec->GetInertial()->GetGAccel(VehicleRadius) );
break;
case gtWGS84:
- vGravAccel = Tec2b * Inertial->GetGravityJ2(VState.vLocation);
+ vGravAccel = Tec2b * FDMExec->GetInertial()->GetGravityJ2(VState.vLocation);
break;
}
void FGPropagate::ResolveFrictionForces(double dt)
{
- const double invMass = 1.0 / MassBalance->GetMass();
- const FGMatrix33& Jinv = MassBalance->GetJinv();
+ const double invMass = 1.0 / FDMExec->GetMassBalance()->GetMass();
+ const FGMatrix33& Jinv = FDMExec->GetMassBalance()->GetJinv();
vector <FGColumnVector3> JacF, JacM;
FGColumnVector3 vdot, wdot;
FGColumnVector3 Fc, Mc;
int n = 0, i;
// Compiles data from the ground reactions to build up the jacobian matrix
- for (MultiplierIterator it=MultiplierIterator(GroundReactions); *it; ++it, n++) {
+ for (MultiplierIterator it=MultiplierIterator(FDMExec->GetGroundReactions()); *it; ++it, n++) {
JacF.push_back((*it)->ForceJacobian);
JacM.push_back((*it)->MomentJacobian);
}
// Initializes the Lagrange multipliers
i = 0;
- for (MultiplierIterator it=MultiplierIterator(GroundReactions); *it; ++it, i++) {
+ for (MultiplierIterator it=MultiplierIterator(FDMExec->GetGroundReactions()); *it; ++it, i++) {
lambda[i] = (*it)->value;
lambdaMax[i] = (*it)->Max;
lambdaMin[i] = (*it)->Min;
// Save the value of the Lagrange multipliers to accelerate the convergence
// of the Gauss-Seidel algorithm at next iteration.
i = 0;
- for (MultiplierIterator it=MultiplierIterator(GroundReactions); *it; ++it)
+ for (MultiplierIterator it=MultiplierIterator(FDMExec->GetGroundReactions()); *it; ++it)
(*it)->value = lambda[i++];
- GroundReactions->UpdateForcesAndMoments();
+ FDMExec->GetGroundReactions()->UpdateForcesAndMoments();
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CalculateInertialVelocity(); // Translational position derivative
// Initialize past values deques
- VState.dqPQRdot.clear();
VState.dqPQRidot.clear();
VState.dqUVWidot.clear();
VState.dqInertialVelocity.clear();
VState.dqQtrndot.clear();
for (int i=0; i<4; i++) {
- VState.dqPQRdot.push_front(vPQRdot);
VState.dqPQRidot.push_front(vPQRidot);
VState.dqUVWidot.push_front(vUVWdot);
VState.dqInertialVelocity.push_front(VState.vInertialVelocity);
<< reset << endl;
cout << endl;
cout << highint << " Earth Position Angle (deg): " << setw(8) << setprecision(3) << reset
- << Inertial->GetEarthPositionAngleDeg() << endl;
+ << FDMExec->GetInertial()->GetEarthPositionAngleDeg() << endl;
cout << endl;
cout << highint << " Body velocity (ft/sec): " << setw(8) << setprecision(3) << reset << VState.vUVW << endl;
cout << highint << " Local velocity (ft/sec): " << setw(8) << setprecision(3) << reset << vVel << endl;
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_PROPAGATE "$Id: FGPropagate.h,v 1.51 2010/10/07 03:45:40 jberndt Exp $"
+#define ID_PROPAGATE "$Id: FGPropagate.h,v 1.52 2010/10/31 04:48:46 jberndt Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
@endcode
@author Jon S. Berndt, Mathias Froehlich
- @version $Id: FGPropagate.h,v 1.51 2010/10/07 03:45:40 jberndt Exp $
+ @version $Id: FGPropagate.h,v 1.52 2010/10/31 04:48:46 jberndt Exp $
*/
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FGColumnVector3 vInertialPosition;
- deque <FGColumnVector3> dqPQRdot;
deque <FGColumnVector3> dqPQRidot;
deque <FGColumnVector3> dqUVWidot;
deque <FGColumnVector3> dqInertialVelocity;
namespace JSBSim {
-static const char *IdSrc = "$Id: FGPropulsion.cpp,v 1.41 2010/10/15 11:32:41 jberndt Exp $";
+static const char *IdSrc = "$Id: FGPropulsion.cpp,v 1.43 2010/11/18 12:38:06 jberndt Exp $";
static const char *IdHdr = ID_PROPULSION;
extern short debug_lvl;
bool FGPropulsion::InitModel(void)
{
+ bool result = true;
+
if (!FGModel::InitModel()) return false;
for (unsigned int i=0; i<numTanks; i++) Tanks[i]->ResetToIC();
switch (Engines[i]->GetType()) {
case FGEngine::etPiston:
((FGPiston*)Engines[i])->ResetToIC();
- if (HasInitializedEngines && (InitializedEngines & i)) InitRunning(i);
+ try {
+ if (HasInitializedEngines && (InitializedEngines & i)) InitRunning(i);
+ } catch (string str) {
+ cerr << str << endl;
+ result = false;
+ }
break;
case FGEngine::etTurbine:
((FGTurbine*)Engines[i])->ResetToIC();
- if (HasInitializedEngines && (InitializedEngines & i)) InitRunning(i);
+ try {
+ if (HasInitializedEngines && (InitializedEngines & i)) InitRunning(i);
+ } catch (string str) {
+ cerr << str << endl;
+ result = false;
+ }
break;
default:
break;
}
}
- return true;
+ return result;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void FGPropulsion::InitRunning(int n)
{
- if (n > 0) { // A specific engine is supposed to be initialized
+ if (n >= 0) { // A specific engine is supposed to be initialized
if (n >= (int)GetNumEngines() ) {
- cerr << "Tried to initialize a non-existent engine!" << endl;
- throw;
+ throw(string("Tried to initialize a non-existent engine!"));
}
- FCS->SetThrottleCmd(n,1);
- FCS->SetMixtureCmd(n,1);
+ FDMExec->GetFCS()->SetThrottleCmd(n,1);
+ FDMExec->GetFCS()->SetMixtureCmd(n,1);
GetEngine(n)->InitRunning();
GetSteadyState();
} else if (n < 0) { // -1 refers to "All Engines"
for (unsigned int i=0; i<GetNumEngines(); i++) {
- FCS->SetThrottleCmd(i,1);
- FCS->SetMixtureCmd(i,1);
+ FDMExec->GetFCS()->SetThrottleCmd(i,1);
+ FDMExec->GetFCS()->SetMixtureCmd(i,1);
GetEngine(i)->InitRunning();
}
GetSteadyState();
InitializedEngines = -1;
HasInitializedEngines = true;
- } else if (n == 0) { // No engines are to be initialized
- // Do nothing
}
}
return false;
}
- FCS->AddThrottle();
+ FDMExec->GetFCS()->AddThrottle();
ThrottleAdded = true;
numEngines++;
}
CalculateTankInertias();
- if (!ThrottleAdded) FCS->AddThrottle(); // need to have at least one throttle
+ if (!ThrottleAdded) FDMExec->GetFCS()->AddThrottle(); // need to have at least one throttle
// Process fuel dump rate
if (el->FindElement("dump-rate"))
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-string FGPropulsion::GetPropulsionStrings(const string& delimiter)
+string FGPropulsion::GetPropulsionStrings(const string& delimiter) const
{
unsigned int i;
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-string FGPropulsion::GetPropulsionValues(const string& delimiter)
+string FGPropulsion::GetPropulsionValues(const string& delimiter) const
{
unsigned int i;
tankJ = FGMatrix33();
for (unsigned int i=0; i<size; i++) {
- tankJ += MassBalance->GetPointmassInertia( lbtoslug * Tanks[i]->GetContents(),
+ tankJ += FDMExec->GetMassBalance()->GetPointmassInertia( lbtoslug * Tanks[i]->GetContents(),
Tanks[i]->GetXYZ() );
tankJ(1,1) += Tanks[i]->GetIxx();
tankJ(2,2) += Tanks[i]->GetIyy();
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_PROPULSION "$Id: FGPropulsion.h,v 1.25 2010/01/02 17:58:01 andgi Exp $"
+#define ID_PROPULSION "$Id: FGPropulsion.h,v 1.26 2010/11/18 12:38:06 jberndt Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
@endcode
@author Jon S. Berndt
- @version $Id: FGPropulsion.h,v 1.25 2010/01/02 17:58:01 andgi Exp $
+ @version $Id: FGPropulsion.h,v 1.26 2010/11/18 12:38:06 jberndt Exp $
@see
FGEngine
FGTank
bool Load(Element* el);
/// Retrieves the number of engines defined for the aircraft.
- inline unsigned int GetNumEngines(void) const {return (unsigned int)Engines.size();}
+ unsigned int GetNumEngines(void) const {return (unsigned int)Engines.size();}
/** Retrieves an engine object pointer from the list of engines.
@param index the engine index within the vector container
@return the address of the specific engine, or zero if no such engine is
available */
- inline FGEngine* GetEngine(unsigned int index) {
+ FGEngine* GetEngine(unsigned int index) const {
if (index < Engines.size()) return Engines[index];
else return 0L; }
/// Retrieves the number of tanks defined for the aircraft.
- inline unsigned int GetNumTanks(void) const {return (unsigned int)Tanks.size();}
+ unsigned int GetNumTanks(void) const {return (unsigned int)Tanks.size();}
/** Retrieves a tank object pointer from the list of tanks.
@param index the tank index within the vector container
@return the address of the specific tank, or zero if no such tank is
available */
- inline FGTank* GetTank(unsigned int index) {
+ FGTank* GetTank(unsigned int index) const {
if (index < Tanks.size()) return Tanks[index];
else return 0L; }
/** Returns the number of fuel tanks currently actively supplying fuel */
- inline int GetnumSelectedFuelTanks(void) const {return numSelectedFuelTanks;}
+ int GetnumSelectedFuelTanks(void) const {return numSelectedFuelTanks;}
/** Returns the number of oxidizer tanks currently actively supplying oxidizer */
- inline int GetnumSelectedOxiTanks(void) const {return numSelectedOxiTanks;}
+ int GetnumSelectedOxiTanks(void) const {return numSelectedOxiTanks;}
/** Loops the engines until thrust output steady (used for trimming) */
bool GetSteadyState(void);
/** Sets up the engines as running */
void InitRunning(int n);
- std::string GetPropulsionStrings(const std::string& delimiter);
- std::string GetPropulsionValues(const std::string& delimiter);
+ std::string GetPropulsionStrings(const std::string& delimiter) const;
+ std::string GetPropulsionValues(const std::string& delimiter) const;
- inline FGColumnVector3& GetForces(void) {return vForces; }
- inline double GetForces(int n) const { return vForces(n);}
- inline FGColumnVector3& GetMoments(void) {return vMoments;}
- inline double GetMoments(int n) const {return vMoments(n);}
+ const FGColumnVector3& GetForces(void) const {return vForces; }
+ double GetForces(int n) const { return vForces(n);}
+ const FGColumnVector3& GetMoments(void) const {return vMoments;}
+ double GetMoments(int n) const {return vMoments(n);}
- inline bool GetRefuel(void) const {return refuel;}
- inline void SetRefuel(bool setting) {refuel = setting;}
- inline bool GetFuelDump(void) const {return dump;}
- inline void SetFuelDump(bool setting) {dump = setting;}
+ bool GetRefuel(void) const {return refuel;}
+ void SetRefuel(bool setting) {refuel = setting;}
+ bool GetFuelDump(void) const {return dump;}
+ void SetFuelDump(bool setting) {dump = setting;}
double Transfer(int source, int target, double amount);
void DoRefuel(double time_slice);
void DumpFuel(double time_slice);
namespace JSBSim {
-static const char *IdSrc = "$Id: FGMSIS.cpp,v 1.13 2010/02/25 05:21:36 jberndt Exp $";
+static const char *IdSrc = "$Id: FGMSIS.cpp,v 1.14 2010/11/18 12:38:06 jberndt Exp $";
static const char *IdHdr = ID_MSIS;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
//do temp, pressure, and density first
if (!useExternal) {
// get sea-level values
- Calculate(Auxiliary->GetDayOfYear(),
- Auxiliary->GetSecondsInDay(),
+ Calculate(FDMExec->GetAuxiliary()->GetDayOfYear(),
+ FDMExec->GetAuxiliary()->GetSecondsInDay(),
0.0,
- Propagate->GetLocation().GetLatitudeDeg(),
- Propagate->GetLocation().GetLongitudeDeg());
+ FDMExec->GetPropagate()->GetLocation().GetLatitudeDeg(),
+ FDMExec->GetPropagate()->GetLocation().GetLongitudeDeg());
SLtemperature = output.t[1] * 1.8;
SLdensity = output.d[5] * 1.940321;
SLpressure = 1716.488 * SLdensity * SLtemperature;
rSLsoundspeed = 1.0/SLsoundspeed;
// get at-altitude values
- Calculate(Auxiliary->GetDayOfYear(),
- Auxiliary->GetSecondsInDay(),
- Propagate->GetAltitudeASL(),
- Propagate->GetLocation().GetLatitudeDeg(),
- Propagate->GetLocation().GetLongitudeDeg());
+ Calculate(FDMExec->GetAuxiliary()->GetDayOfYear(),
+ FDMExec->GetAuxiliary()->GetSecondsInDay(),
+ FDMExec->GetPropagate()->GetAltitudeASL(),
+ FDMExec->GetPropagate()->GetLocation().GetLatitudeDeg(),
+ FDMExec->GetPropagate()->GetLocation().GetLongitudeDeg());
intTemperature = output.t[1] * 1.8;
intDensity = output.d[5] * 1.940321;
intPressure = 1716.488 * intDensity * intTemperature;