fdmex->Run();
}
+ struct FGJSBBase::Message* msg;
+ while (fdmex->ReadMessage()) {
+ msg = fdmex->ProcessMessage();
+ switch (msg->type) {
+ case FGJSBBase::Message::eText:
+ cout << msg->messageId << ": " << msg->text << endl;
+ break;
+ case FGJSBBase::Message::eBool:
+ cout << msg->messageId << ": " << msg->text << " " << msg->bVal << endl;
+ break;
+ case FGJSBBase::Message::eInteger:
+ cout << msg->messageId << ": " << msg->text << " " << msg->iVal << endl;
+ break;
+ case FGJSBBase::Message::eDouble:
+ cout << msg->messageId << ": " << msg->text << " " << msg->dVal << endl;
+ break;
+ default:
+ cerr << "Unrecognized message type." << endl;
+ break;
+ }
+ }
+
for( i=0; i<get_num_engines(); i++ ) {
FGEngInterface * e = get_engine(i);
FGEngine * eng = Propulsion->GetEngine(i);
bool FGAerodynamics::Run(void)
{
- float alpha, beta;
unsigned int axis_ctr,ctr;
if (!FGModel::Run()) {
- alpha = Translation->Getalpha();
- beta = Translation->Getbeta();
-
vLastFs = vFs;
vFs.InitMatrix();
}
}
- vForces = State->GetTs2b(alpha, beta)*vFs;
+ vForces = State->GetTs2b()*vFs;
vDXYZcg(eX) = -(Aircraft->GetXYZrp(eX)
- MassBalance->GetXYZcg(eX))*inchtoft;
AC_cfg->GetNextConfigLine();
- while ((token = AC_cfg->GetValue()) != "/AERODYNAMICS") {
+ while ((token = AC_cfg->GetValue()) != string("/AERODYNAMICS")) {
if (token == "AXIS") {
CoeffArray ca;
axis = AC_cfg->GetValue("NAME");
AC_cfg->GetNextConfigLine();
- while ((token = AC_cfg->GetValue()) != "/AXIS") {
+ while ((token = AC_cfg->GetValue()) != string("/AXIS")) {
if( token == "COEFFICIENT" ) {
ca.push_back( new FGCoefficient(FDMExec) );
ca.back()->Load(AC_cfg);
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-float FGAerodynamics::GetNlf(void)
+double FGAerodynamics::GetNlf(void)
{
if (fabs(Position->GetGamma()) < 1.57) {
return (vFs(eZ)/(MassBalance->GetWeight()*cos(Position->GetGamma())));
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-float FGAerodynamics::GetLoD(void)
+double FGAerodynamics::GetLoD(void)
{
- float LoD;
+ double LoD;
if (vFs(1) != 0.00) return vFs(3)/vFs(1);
else return 0.00;
/** Gets the total aerodynamic force vector.
@return a force vector reference. */
FGColumnVector3& GetForces(void) {return vForces;}
- inline float GetForces(int n) {return vForces(n);}
+ inline double GetForces(int n) {return vForces(n);}
/** Gets the total aerodynamic moment vector.
@return a moment vector reference. */
FGColumnVector3& GetMoments(void) {return vMoments;}
- inline float GetMoments(int n) {return vMoments(n);}
+ inline double GetMoments(int n) {return vMoments(n);}
inline FGColumnVector3& GetvLastFs(void) { return vLastFs; }
- inline float GetvLastFs(int axis) { return vLastFs(axis); }
+ inline double GetvLastFs(int axis) { return vLastFs(axis); }
inline FGColumnVector3& GetvFs(void) { return vFs; }
- inline float GetvFs(int axis) { return vFs(axis); }
- float GetLoD(void);
+ inline double GetvFs(int axis) { return vFs(axis); }
+ double GetLoD(void);
/** Gets the strings for the current set of coefficients.
@return a string containing the descriptive names for all coefficients */
string GetCoefficientValues(void);
/// Gets the Normal Load Factor
- float GetNlf(void);
+ double GetNlf(void);
private:
typedef map<string,int> AxisIndex;
ReadPrologue(AC_cfg);
- while ((AC_cfg->GetNextConfigLine() != "EOF") &&
- (token = AC_cfg->GetValue()) != "/FDM_CONFIG") {
+ while ((AC_cfg->GetNextConfigLine() != string("EOF")) &&
+ (token = AC_cfg->GetValue()) != string("/FDM_CONFIG")) {
if (token == "METRICS") {
if (debug_lvl > 0) cout << fgcyan << "\n Reading Metrics" << fgdef << endl;
ReadMetrics(AC_cfg);
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+void FGAircraft::ReadPrologue(FGConfigFile* AC_cfg)
+{
+ string token = AC_cfg->GetValue();
+ string scratch;
+ AircraftName = AC_cfg->GetValue("NAME");
+ if (debug_lvl > 0) cout << underon << "Reading Aircraft Configuration File"
+ << underoff << ": " << highint << AircraftName << normint << endl;
+ scratch = AC_cfg->GetValue("VERSION").c_str();
+
+ CFGVersion = AC_cfg->GetValue("VERSION");
+
+ if (debug_lvl > 0)
+ cout << " Version: " << highint << CFGVersion
+ << normint << endl;
+ if (CFGVersion != needed_cfg_version) {
+ cerr << endl << fgred << "YOU HAVE AN INCOMPATIBLE CFG FILE FOR THIS AIRCRAFT."
+ " RESULTS WILL BE UNPREDICTABLE !!" << endl;
+ cerr << "Current version needed is: " << needed_cfg_version << endl;
+ cerr << " You have version: " << CFGVersion << endl << fgdef << endl;
+ }
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
void FGAircraft::ReadMetrics(FGConfigFile* AC_cfg)
{
string token = "";
string parameter;
- float EW, bixx, biyy, bizz, bixz, biyz;
+ double EW, bixx, biyy, bizz, bixz, biyz;
FGColumnVector3 vbaseXYZcg(3);
AC_cfg->GetNextConfigLine();
- while ((token = AC_cfg->GetValue()) != "/METRICS") {
+ while ((token = AC_cfg->GetValue()) != string("/METRICS")) {
*AC_cfg >> parameter;
if (parameter == "AC_WINGAREA") {
*AC_cfg >> WingArea;
void FGAircraft::ReadOutput(FGConfigFile* AC_cfg)
{
- string token, parameter;
- int OutRate = 0;
- int subsystems = 0;
-
- token = AC_cfg->GetValue("NAME");
- Output->SetFilename(token);
- token = AC_cfg->GetValue("TYPE");
- Output->SetType(token);
- AC_cfg->GetNextConfigLine();
-
- while ((token = AC_cfg->GetValue()) != "/OUTPUT") {
- *AC_cfg >> parameter;
- if (parameter == "RATE_IN_HZ") *AC_cfg >> OutRate;
- if (parameter == "SIMULATION") {
- *AC_cfg >> parameter;
- if (parameter == "ON") subsystems += ssSimulation;
- }
- if (parameter == "AEROSURFACES") {
- *AC_cfg >> parameter;
- if (parameter == "ON") subsystems += ssAerosurfaces;
- }
- if (parameter == "RATES") {
- *AC_cfg >> parameter;
- if (parameter == "ON") subsystems += ssRates;
- }
- if (parameter == "VELOCITIES") {
- *AC_cfg >> parameter;
- if (parameter == "ON") subsystems += ssVelocities;
- }
- if (parameter == "FORCES") {
- *AC_cfg >> parameter;
- if (parameter == "ON") subsystems += ssForces;
- }
- if (parameter == "MOMENTS") {
- *AC_cfg >> parameter;
- if (parameter == "ON") subsystems += ssMoments;
- }
- if (parameter == "ATMOSPHERE") {
- *AC_cfg >> parameter;
- if (parameter == "ON") subsystems += ssAtmosphere;
- }
- if (parameter == "MASSPROPS") {
- *AC_cfg >> parameter;
- if (parameter == "ON") subsystems += ssMassProps;
- }
- if (parameter == "POSITION") {
- *AC_cfg >> parameter;
- if (parameter == "ON") subsystems += ssPosition;
- }
- if (parameter == "COEFFICIENTS") {
- *AC_cfg >> parameter;
- if (parameter == "ON") subsystems += ssCoefficients;
- }
- if (parameter == "GROUND_REACTIONS") {
- *AC_cfg >> parameter;
- if (parameter == "ON") subsystems += ssGroundReactions;
- }
- if (parameter == "FCS") {
- *AC_cfg >> parameter;
- if (parameter == "ON") subsystems += ssFCS;
- }
- if (parameter == "PROPULSION") {
- *AC_cfg >> parameter;
- if (parameter == "ON") subsystems += ssPropulsion;
- }
- }
-
- Output->SetSubsystems(subsystems);
-
- OutRate = OutRate>120?120:(OutRate<0?0:OutRate);
- Output->SetRate( (int)(0.5 + 1.0/(State->Getdt()*OutRate)) );
-}
-
-//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-void FGAircraft::ReadPrologue(FGConfigFile* AC_cfg)
-{
- string token = AC_cfg->GetValue();
- string scratch;
- AircraftName = AC_cfg->GetValue("NAME");
- if (debug_lvl > 0) cout << underon << "Reading Aircraft Configuration File"
- << underoff << ": " << highint << AircraftName << normint << endl;
- scratch = AC_cfg->GetValue("VERSION").c_str();
-
- CFGVersion = AC_cfg->GetValue("VERSION");
-
- if (debug_lvl > 0)
- cout << " Version: " << highint << CFGVersion
- << normint << endl;
- if (CFGVersion != needed_cfg_version) {
- cerr << endl << fgred << "YOU HAVE AN INCOMPATIBLE CFG FILE FOR THIS AIRCRAFT."
- " RESULTS WILL BE UNPREDICTABLE !!" << endl;
- cerr << "Current version needed is: " << needed_cfg_version << endl;
- cerr << " You have version: " << CFGVersion << endl << fgdef << endl;
+ if (!Output->Load(AC_cfg)) {
+ cerr << "Output not successfully loaded" << endl;
}
}
inline string GetAircraftName(void) { return AircraftName; }
/// Gets the wing area
- inline float GetWingArea(void) { return WingArea; }
+ inline double GetWingArea(void) { return WingArea; }
/// Gets the wing span
- inline float GetWingSpan(void) { return WingSpan; }
+ inline double GetWingSpan(void) { return WingSpan; }
/// Gets the average wing chord
- inline float Getcbar(void) { return cbar; }
- inline float GetWingIncidence(void) { return WingIncidence; }
- inline float GetHTailArea(void) { return HTailArea; }
- inline float GetHTailArm(void) { return HTailArm; }
- inline float GetVTailArea(void) { return VTailArea; }
- inline float GetVTailArm(void) { return VTailArm; }
- inline float Getlbarh(void) { return lbarh; } // HTailArm / cbar
- inline float Getlbarv(void) { return lbarv; } // VTailArm / cbar
- inline float Getvbarh(void) { return vbarh; } // H. Tail Volume
- inline float Getvbarv(void) { return vbarv; } // V. Tail Volume
+ inline double Getcbar(void) { return cbar; }
+ inline double GetWingIncidence(void) { return WingIncidence; }
+ inline double GetHTailArea(void) { return HTailArea; }
+ inline double GetHTailArm(void) { return HTailArm; }
+ inline double GetVTailArea(void) { return VTailArea; }
+ inline double GetVTailArm(void) { return VTailArm; }
+ inline double Getlbarh(void) { return lbarh; } // HTailArm / cbar
+ inline double Getlbarv(void) { return lbarv; } // VTailArm / cbar
+ inline double Getvbarh(void) { return vbarh; } // H. Tail Volume
+ inline double Getvbarv(void) { return vbarv; } // V. Tail Volume
inline FGColumnVector3& GetMoments(void) { return vMoments; }
inline FGColumnVector3& GetForces(void) { return vForces; }
inline FGColumnVector3& GetBodyAccel(void) { return vBodyAccel; }
inline FGColumnVector3& GetNcg (void) { return vNcg; }
inline FGColumnVector3& GetXYZrp(void) { return vXYZrp; }
inline FGColumnVector3& GetXYZep(void) { return vXYZep; }
- inline float GetXYZrp(int idx) { return vXYZrp(idx); }
- inline float GetXYZep(int idx) { return vXYZep(idx); }
- inline float GetAlphaCLMax(void) { return alphaclmax; }
- inline float GetAlphaCLMin(void) { return alphaclmin; }
+ inline double GetXYZrp(int idx) { return vXYZrp(idx); }
+ inline double GetXYZep(int idx) { return vXYZep(idx); }
+ inline double GetAlphaCLMax(void) { return alphaclmax; }
+ inline double GetAlphaCLMin(void) { return alphaclmin; }
- inline void SetAlphaCLMax(float tt) { alphaclmax=tt; }
- inline void SetAlphaCLMin(float tt) { alphaclmin=tt; }
+ inline void SetAlphaCLMax(double tt) { alphaclmax=tt; }
+ inline void SetAlphaCLMin(double tt) { alphaclmin=tt; }
inline bool GetStallWarn(void) { return impending_stall; }
- /// Subsystem types for specifying which will be output in the FDM data logging
- enum SubSystems {
- /** Subsystem: Simulation (= 1) */ ssSimulation = 1,
- /** Subsystem: Aerosurfaces (= 2) */ ssAerosurfaces = 2,
- /** Subsystem: Body rates (= 4) */ ssRates = 4,
- /** Subsystem: Velocities (= 8) */ ssVelocities = 8,
- /** Subsystem: Forces (= 16) */ ssForces = 16,
- /** Subsystem: Moments (= 32) */ ssMoments = 32,
- /** Subsystem: Atmosphere (= 64) */ ssAtmosphere = 64,
- /** Subsystem: Mass Properties (= 128) */ ssMassProps = 128,
- /** Subsystem: Coefficients (= 256) */ ssCoefficients = 256,
- /** Subsystem: Position (= 512) */ ssPosition = 512,
- /** Subsystem: Ground Reactions (= 1024) */ ssGroundReactions = 1024,
- /** Subsystem: FCS (= 2048) */ ssFCS = 2048,
- /** Subsystem: Propulsion (= 4096) */ ssPropulsion = 4096
- } subsystems;
-
private:
FGColumnVector3 vMoments;
FGColumnVector3 vForces;
FGColumnVector3 vBodyAccel;
FGColumnVector3 vNcg;
- float WingArea, WingSpan, cbar, WingIncidence;
- float HTailArea, VTailArea, HTailArm, VTailArm;
- float lbarh,lbarv,vbarh,vbarv;
- float alphaclmax,alphaclmin;
- float impending_stall;
+ double WingArea, WingSpan, cbar, WingIncidence;
+ double HTailArea, VTailArea, HTailArm, VTailArm;
+ double lbarh,lbarv,vbarh,vbarv;
+ double alphaclmax,alphaclmin;
+ double impending_stall;
string CFGVersion;
string AircraftName;
soundspeed = sqrt(SHRatio*Reng*temperature);
State->Seta(soundspeed);
-
} else { // skip Run() execution this time
}
+
return false;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-void FGAtmosphere::Calculate(float altitude)
+void FGAtmosphere::Calculate(double altitude)
{
//see reference [1]
- float slope,reftemp,refpress;
+ double slope,reftemp,refpress;
int i=0; bool lookup = false;
// cout << "Atmosphere: h=" << altitude << " rho= " << density << endl;
i=lastIndex;
bool InitModel(void);
/// Returns the temperature in degrees Rankine.
- inline float GetTemperature(void) {return temperature;}
+ inline double GetTemperature(void) {return temperature;}
/** Returns the density in slugs/ft^3.
<i>This function may <b>only</b> be used if Run() is called first.</i> */
- inline float GetDensity(void) {return density;}
+ inline double GetDensity(void) {return density;}
/// Returns the pressure in psf.
- inline float GetPressure(void) {return pressure;}
+ inline double GetPressure(void) {return pressure;}
/// Returns the speed of sound in ft/sec.
- inline float GetSoundSpeed(void) {return soundspeed;}
+ inline double GetSoundSpeed(void) {return soundspeed;}
/// Returns the sea level temperature in degrees Rankine.
- inline float GetTemperatureSL(void) { return SLtemperature; }
+ inline double GetTemperatureSL(void) { return SLtemperature; }
/// Returns the sea level density in slugs/ft^3
- inline float GetDensitySL(void) { return SLdensity; }
+ inline double GetDensitySL(void) { return SLdensity; }
/// Returns the sea level pressure in psf.
- inline float GetPressureSL(void) { return SLpressure; }
+ inline double GetPressureSL(void) { return SLpressure; }
/// Returns the sea level speed of sound in ft/sec.
- inline float GetSoundSpeedSL(void) { return SLsoundspeed; }
+ inline double GetSoundSpeedSL(void) { return SLsoundspeed; }
/// Returns the ratio of at-altitude temperature over the sea level value.
- inline float GetTemperatureRatio(void) { return temperature*rSLtemperature; }
+ inline double GetTemperatureRatio(void) { return temperature*rSLtemperature; }
/// Returns the ratio of at-altitude density over the sea level value.
- inline float GetDensityRatio(void) { return density*rSLdensity; }
+ inline double GetDensityRatio(void) { return density*rSLdensity; }
/// Returns the ratio of at-altitude pressure over the sea level value.
- inline float GetPressureRatio(void) { return pressure*rSLpressure; }
+ inline double GetPressureRatio(void) { return pressure*rSLpressure; }
/// Returns the ratio of at-altitude sound speed over the sea level value.
- inline float GetSoundSpeedRatio(void) { return soundspeed*rSLsoundspeed; }
+ inline double GetSoundSpeedRatio(void) { return soundspeed*rSLsoundspeed; }
/// Tells the simulator to use an externally calculated atmosphere model.
inline void UseExternal(void) { useExternal=true; }
bool External(void) { return useExternal; }
/// Provides the external atmosphere model with an interface to set the temperature.
- inline void SetExTemperature(float t) { exTemperature=t; }
+ inline void SetExTemperature(double t) { exTemperature=t; }
/// Provides the external atmosphere model with an interface to set the density.
- inline void SetExDensity(float d) { exDensity=d; }
+ inline void SetExDensity(double d) { exDensity=d; }
/// Provides the external atmosphere model with an interface to set the pressure.
- inline void SetExPressure(float p) { exPressure=p; }
+ inline void SetExPressure(double p) { exPressure=p; }
/// Sets the wind components in NED frame.
- inline void SetWindNED(float wN, float wE, float wD) { vWindNED(1)=wN; vWindNED(2)=wE; vWindNED(3)=wD;}
+ inline void SetWindNED(double wN, double wE, double wD) { vWindNED(1)=wN; vWindNED(2)=wE; vWindNED(3)=wD;}
/// Retrieves the wind components in NED frame.
inline FGColumnVector3& GetWindNED(void) { return vWindNED; }
/** Retrieves the wind direction. The direction is defined as north=0 and
increases counterclockwise. The wind heading is returned in radians.*/
- inline float GetWindPsi(void) { return psiw; }
+ inline double GetWindPsi(void) { return psiw; }
private:
double rho;
FGColumnVector3 vWindNED;
double psiw;
- void Calculate(float altitude);
+ void Calculate(double altitude);
void Debug(void);
};
bool FGAuxiliary::Run()
{
- float A,B,D;
+ double A,B,D;
if (!FGModel::Run()) {
GetState();
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-float FGAuxiliary::GetHeadWind(void)
+double FGAuxiliary::GetHeadWind(void)
{
- float psiw,vw,psi;
+ double psiw,vw,psi;
psiw = Atmosphere->GetWindPsi();
psi = Rotation->Getpsi();
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-float FGAuxiliary::GetCrossWind(void)
+double FGAuxiliary::GetCrossWind(void)
{
- float psiw,vw,psi;
+ double psiw,vw,psi;
psiw = Atmosphere->GetWindPsi();
psi = Rotation->Getpsi();
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-float FGAuxiliary::GetNpilot(int idx)
+double FGAuxiliary::GetNpilot(int idx)
{
return (vPilotAccel/Inertial->gravity())(idx);
}
bool Run(void);
// Use FGInitialCondition to set these speeds
- inline float GetVcalibratedFPS(void) { return vcas; }
- inline float GetVcalibratedKTS(void) { return vcas*fpstokts; }
- inline float GetVequivalentFPS(void) { return veas; }
- inline float GetVequivalentKTS(void) { return veas*fpstokts; }
+ inline double GetVcalibratedFPS(void) { return vcas; }
+ inline double GetVcalibratedKTS(void) { return vcas*fpstokts; }
+ inline double GetVequivalentFPS(void) { return veas; }
+ inline double GetVequivalentKTS(void) { return veas*fpstokts; }
inline FGColumnVector3& GetPilotAccel(void) { return vPilotAccel; }
- inline float GetPilotAccel(int idx) { return vPilotAccel(idx); }
+ inline double GetPilotAccel(int idx) { return vPilotAccel(idx); }
FGColumnVector3 GetNpilot(void);
- float GetNpilot(int idx);
+ double GetNpilot(int idx);
- inline float GetEarthPositionAngle(void) { return earthPosAngle; }
+ inline double GetEarthPositionAngle(void) { return earthPosAngle; }
- float GetHeadWind(void);
- float GetCrossWind(void);
+ double GetHeadWind(void);
+ double GetCrossWind(void);
private:
- float vcas;
- float veas;
- float mach;
- float qbar,rhosl,rho,p,psl,pt;
+ double vcas;
+ double veas;
+ double mach;
+ double qbar,rhosl,rho,p,psl,pt;
// Don't add a getter for pt!
// pt above is freestream total pressure for subsonic only
FGColumnVector3 vPilotAccel;
FGColumnVector3 vToEyePt;
- float earthPosAngle;
+ double earthPosAngle;
void GetState(void);
void Debug(void);
n = multparms.find("|");
start = 0;
- if(multparms != "FG_NONE") {
+ if (multparms != string("FG_NONE")) {
while (n < end && n >= 0) {
n -= start;
mult = multparms.substr(start,n);
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-float FGCoefficient::Value(float rVal, float cVal)
+double FGCoefficient::Value(double rVal, double cVal)
{
- float Value;
+ double Value;
unsigned int midx;
SD = Value = Table->GetValue(rVal, cVal);
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-float FGCoefficient::Value(float Val)
+double FGCoefficient::Value(double Val)
{
- float Value;
+ double Value;
SD = Value = Table->GetValue(Val);
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-float FGCoefficient::Value(void)
+double FGCoefficient::Value(void)
{
- float Value;
+ double Value;
SD = Value = StaticValue;
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-float FGCoefficient::TotalValue()
+double FGCoefficient::TotalValue()
{
switch(type) {
virtual bool Load(FGConfigFile* AC_cfg);
typedef vector <eParam> MultVec;
- virtual float TotalValue(void);
+ virtual double TotalValue(void);
virtual inline string Getname(void) {return name;}
- virtual inline float GetSD(void) { return SD;}
+ virtual inline double GetSD(void) { return SD;}
inline MultVec Getmultipliers(void) {return multipliers;}
void DumpSD(void);
string description;
string name;
string method;
- float Value(float, float);
- float Value(float);
- float Value(void);
- float StaticValue;
+ double Value(double, double);
+ double Value(double);
+ double Value(void);
+ double StaticValue;
eParam LookupR, LookupC;
MultVec multipliers;
int rows, columns;
Type type;
- float SD; // Actual stability derivative (or other coefficient) value
+ double SD; // Actual stability derivative (or other coefficient) value
FGTable *Table;
FGFDMExec* FDMExec;
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-float FGColumnVector3::Magnitude(void)
+double FGColumnVector3::Magnitude(void)
{
double num;
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-FGColumnVector3& FGColumnVector3::operator<<(const float ff)
+FGColumnVector3& FGColumnVector3::operator<<(const double ff)
{
data[rowCtr] = ff;
if (++rowCtr > 3 )
void operator*=(const double scalar);
void operator/=(const double scalar);
- FGColumnVector3& operator<<(const float ff);
+ FGColumnVector3& operator<<(const double ff);
inline void InitMatrix(void) { data[1]=0; data[2]=0; data[3]=0; }
- inline void InitMatrix(float ff) { data[1]=ff; data[2]=ff; data[3]=ff; }
+ inline void InitMatrix(double ff) { data[1]=ff; data[2]=ff; data[3]=ff; }
- float Magnitude(void);
+ double Magnitude(void);
FGColumnVector3 Normalize(void);
friend FGColumnVector3 operator*(const double scalar, const FGColumnVector3& A);
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-float FGColumnVector4::Magnitude(void)
+double FGColumnVector4::Magnitude(void)
{
double num;
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-FGColumnVector4& FGColumnVector4::operator<<(const float ff)
+FGColumnVector4& FGColumnVector4::operator<<(const double ff)
{
data[rowCtr] = ff;
if (++rowCtr > 4 )
inline double operator()(int m) const { return data[m]; }
inline double& operator()(int m) { return data[m]; }
- FGColumnVector4& operator<<(const float ff);
+ FGColumnVector4& operator<<(const double ff);
inline void InitMatrix(void) { data[1]=0; data[2]=0; data[3]=0; }
- inline void InitMatrix(float ff) { data[1]=ff; data[2]=ff; data[3]=ff; }
+ inline void InitMatrix(double ff) { data[1]=ff; data[2]=ff; data[3]=ff; }
- float Magnitude(void);
+ double Magnitude(void);
FGColumnVector4 Normalize(void);
friend FGColumnVector4 operator*(const double scalar, const FGColumnVector4& A);
-/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
- Header: FGConfigFile.h
- Author: Jon Berndt
- Date started: 03/29/00
- Purpose: Config file read-in class
- Called by: FGAircraft
-
-FUNCTIONAL DESCRIPTION
---------------------------------------------------------------------------------
-
-HISTORY
---------------------------------------------------------------------------------
-03/16/2000 JSB Created
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-INCLUDES
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-
-#include "FGConfigFile.h"
-#include <stdlib.h>
-#include <math.h>
-
-static const char *IdSrc = "$Id$";
-static const char *IdHdr = ID_CONFIGFILE;
-
-/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-CLASS IMPLEMENTATION
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-
-FGConfigFile::FGConfigFile(string cfgFileName)
-{
-#if defined ( sgi ) && !defined( __GNUC__ )
- cfgfile.open(cfgFileName.c_str(), ios::in );
-#else
- cfgfile.open(cfgFileName.c_str(), ios::in | ios::binary );
-#endif
- CommentsOn = false;
- CurrentIndex = 0;
- Opened = true;
-#if defined ( sgi ) && !defined( __GNUC__ )
- if (!cfgfile.fail() && !cfgfile.eof()) GetNextConfigLine();
-#else
- if (cfgfile.is_open()) GetNextConfigLine();
-#endif
- else Opened = false;
-
- if (debug_lvl & 2) cout << "Instantiated: FGConfigFile" << endl;
-}
-
-//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-FGConfigFile::~FGConfigFile()
-{
- cfgfile.close();
- if (debug_lvl & 2) cout << "Destroyed: FGConfigFile" << endl;
-}
-
-//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-string FGConfigFile::GetNextConfigLine(void)
-{
- int deblank;
-
- do {
- CurrentLine = GetLine();
- if (CurrentLine.find("<!--") != CurrentLine.npos) {
- CommentsOn = true;
- CommentString = "";
- if (CurrentLine.find("<!--") != CurrentLine.npos)
- CurrentLine.erase(CurrentLine.find("<!--"),4);
- while((deblank = CurrentLine.find(" ")) != CurrentLine.npos) CurrentLine.erase(deblank,1);
- if (CurrentLine.size() <= 2) CurrentLine = "";
- }
-
- if (CurrentLine.find("-->") != CurrentLine.npos) {
- CommentsOn = false;
-
- if (CurrentLine.find("-->") != CurrentLine.npos)
- CurrentLine.erase(CurrentLine.find("-->"),4);
-
- while((deblank = CurrentLine.find(" ")) != CurrentLine.npos) CurrentLine.erase(deblank,1);
- if (CurrentLine.size() <= 2) CurrentLine = "";
-
- CommentString += CurrentLine;
- GetNextConfigLine();
- }
-
- if (CommentsOn) CommentString += CurrentLine + "\r\n";
-
- } while (CommentsOn);
-
- if (CurrentLine.length() == 0) GetNextConfigLine();
- CurrentIndex = 0;
- return CurrentLine;
-}
-
-//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-string FGConfigFile::GetCommentString(void)
-{
- return CommentString;
-}
-
-//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-string FGConfigFile::GetValue(string val)
-{
- unsigned int pos, p1, p2, ptest;
-
- if (val == "") { // this call is to return the tag value
- pos = CurrentLine.find("<");
- if (pos != CurrentLine.npos) { // beginning brace found "<"
- p1 = CurrentLine.find_first_not_of(" ",pos+1);
- if (p1 != CurrentLine.npos) { // found first character of tag
- p2 = CurrentLine.find_first_of(" >",p1+1);
- if (p2 == CurrentLine.npos) p2 = p1+1;
- return CurrentLine.substr(p1,p2-p1);
- }
- } else { // beginning brace "<" not found; this is a regular data line
- pos = CurrentLine.find_first_not_of(" ");
- if (pos != CurrentLine.npos) { // first character in line found
- p2 = CurrentLine.find_first_of(" ",pos+1);
- if (p2 != CurrentLine.npos) {
- return CurrentLine.substr(pos,p2-pos);
- } else {
- return CurrentLine.substr(pos,CurrentLine.length()-pos);
- }
- }
- }
- } else { // return a value for a specific tag
- pos = CurrentLine.find(val);
- if (pos != CurrentLine.npos) {
- pos = CurrentLine.find("=",pos);
- if (pos != CurrentLine.npos) {
- ptest = CurrentLine.find_first_not_of(" ",pos+1);
- if (ptest != CurrentLine.npos) {
- p1 = ptest + 1;
- if (CurrentLine[ptest] == '"') { // quoted
- p2 = CurrentLine.find_first_of("\"",p1);
- } else { // not quoted
- p2 = CurrentLine.find_first_of(" ",p1);
- }
- if (p2 != CurrentLine.npos) {
- return CurrentLine.substr(p1,p2-p1);
- }
- }
- } else { // "=" not found
- pos = CurrentLine.find(val);
- pos = CurrentLine.find_first_of(" ",pos+1);
- ptest = CurrentLine.find_first_not_of(" ",pos+1);
- if (ptest != CurrentLine.npos) {
- if (CurrentLine[ptest] == '"') { // quoted
- p1 = ptest + 1;
- p2 = CurrentLine.find_first_of("\"",p1);
- } else { // not quoted
- p1 = ptest;
- p2 = CurrentLine.find_first_of(" ",p1);
- }
- if (p2 != CurrentLine.npos) {
- return CurrentLine.substr(p1,p2-p1);
- } else {
- p2 = CurrentLine.length();
- return CurrentLine.substr(p1,p2-p1);
- }
- }
- }
- }
- }
-
- return string("");
-}
-
-//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-string FGConfigFile::GetValue(void)
-{
- return GetValue("");
-}
-
-//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-string FGConfigFile::GetLine(void)
-{
- string scratch = "";
- int test;
-
- while ((test = cfgfile.get()) != EOF) {
- if (test >= 0x20) {
- scratch += (char)test;
- } else {
- if ((test = cfgfile.get()) != EOF) {
-#if defined ( sgi ) && !defined( __GNUC__ )
- if (test >= 0x20) cfgfile.putback(test);
-#else
- if (test >= 0x20) cfgfile.unget();
-#endif
- break;
- }
- }
- }
- if (cfgfile.eof()) return string("EOF");
- return scratch;
-}
-
-//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-FGConfigFile& FGConfigFile::operator>>(double& val)
-{
- unsigned int pos, end;
-
- pos = CurrentLine.find_first_not_of(", ",CurrentIndex);
- if (pos == CurrentLine.npos) pos = CurrentLine.length();
- end = CurrentLine.find_first_of(", ",pos+1);
- if (end == CurrentLine.npos) end = CurrentLine.length();
- string str = CurrentLine.substr(pos, end - pos);
- val = strtod(str.c_str(),NULL);
- CurrentIndex = end+1;
- if (CurrentIndex >= CurrentLine.length()) GetNextConfigLine();
- return *this;
-}
-
-//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-FGConfigFile& FGConfigFile::operator>>(float& val)
-{
- unsigned int pos, end;
-
- pos = CurrentLine.find_first_not_of(", ",CurrentIndex);
- if (pos == CurrentLine.npos) pos = CurrentLine.length();
- end = CurrentLine.find_first_of(", ",pos+1);
- if (end == CurrentLine.npos) end = CurrentLine.length();
- string str = CurrentLine.substr(pos, end - pos);
- val = strtod(str.c_str(),NULL);
- CurrentIndex = end+1;
- if (CurrentIndex >= CurrentLine.length()) GetNextConfigLine();
- return *this;
-}
-
-//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-FGConfigFile& FGConfigFile::operator>>(int& val)
-{
- unsigned int pos, end;
-
- pos = CurrentLine.find_first_not_of(", ",CurrentIndex);
- if (pos == CurrentLine.npos) pos = CurrentLine.length();
- end = CurrentLine.find_first_of(", ",pos+1);
- if (end == CurrentLine.npos) end = CurrentLine.length();
- string str = CurrentLine.substr(pos, end - pos);
- val = atoi(str.c_str());
- CurrentIndex = end+1;
- if (CurrentIndex >= CurrentLine.length()) GetNextConfigLine();
- return *this;
-}
-
-//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-FGConfigFile& FGConfigFile::operator>>(eParam& val)
-{
- unsigned int pos, end;
-
- pos = CurrentLine.find_first_not_of(", ",CurrentIndex);
- if (pos == CurrentLine.npos) pos = CurrentLine.length();
- end = CurrentLine.find_first_of(", ",pos+1);
- if (end == CurrentLine.npos) end = CurrentLine.length();
- string str = CurrentLine.substr(pos, end - pos);
- val = (eParam)atoi(str.c_str());
- CurrentIndex = end+1;
- if (CurrentIndex >= CurrentLine.length()) GetNextConfigLine();
- return *this;
-}
-
-//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-FGConfigFile& FGConfigFile::operator>>(string& str)
-{
- unsigned int pos, end;
-
- pos = CurrentLine.find_first_not_of(", ",CurrentIndex);
- if (pos == CurrentLine.npos) pos = CurrentLine.length();
- end = CurrentLine.find_first_of(", ",pos+1);
- if (end == CurrentLine.npos) end = CurrentLine.length();
- str = CurrentLine.substr(pos, end - pos);
- CurrentIndex = end+1;
- if (CurrentIndex >= CurrentLine.length()) GetNextConfigLine();
- return *this;
-}
-
-//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-void FGConfigFile::ResetLineIndexToZero(void)
-{
- CurrentIndex = 0;
-}
-
-//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-void FGConfigFile::Debug(void)
-{
- //TODO: Add your source code here
-}
-
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r
+\r
+ Header: FGConfigFile.h\r
+ Author: Jon Berndt\r
+ Date started: 03/29/00\r
+ Purpose: Config file read-in class\r
+ Called by: FGAircraft\r
+\r
+FUNCTIONAL DESCRIPTION\r
+--------------------------------------------------------------------------------\r
+\r
+HISTORY\r
+--------------------------------------------------------------------------------\r
+03/16/2000 JSB Created\r
+\r
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r
+INCLUDES\r
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/\r
+\r
+#include "FGConfigFile.h"\r
+#include <stdlib.h>\r
+#include <math.h>\r
+\r
+static const char *IdSrc = "$Id$";\r
+static const char *IdHdr = ID_CONFIGFILE;\r
+\r
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r
+CLASS IMPLEMENTATION\r
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/\r
+\r
+FGConfigFile::FGConfigFile(string cfgFileName)\r
+{\r
+#if defined ( sgi ) && !defined( __GNUC__ )\r
+ cfgfile.open(cfgFileName.c_str(), ios::in );\r
+#else\r
+ cfgfile.open(cfgFileName.c_str(), ios::in | ios::binary );\r
+#endif\r
+ CommentsOn = false;\r
+ CurrentIndex = 0;\r
+ Opened = true;\r
+#if defined ( sgi ) && !defined( __GNUC__ )\r
+ if (!cfgfile.fail() && !cfgfile.eof()) GetNextConfigLine();\r
+#else\r
+ if (cfgfile.is_open()) GetNextConfigLine();\r
+#endif\r
+ else Opened = false;\r
+\r
+ if (debug_lvl & 2) cout << "Instantiated: FGConfigFile" << endl;\r
+}\r
+\r
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r
+\r
+FGConfigFile::~FGConfigFile()\r
+{\r
+ cfgfile.close();\r
+ if (debug_lvl & 2) cout << "Destroyed: FGConfigFile" << endl;\r
+}\r
+\r
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r
+\r
+string FGConfigFile::GetNextConfigLine(void)\r
+{\r
+ int deblank, not_found = string::npos;\r
+ int comment_starts_at;\r
+ int comment_ends_at;\r
+ int comment_length;\r
+ int line_length;\r
+ bool start_comment, end_comment;\r
+ string CommentStringTemp;\r
+\r
+ do {\r
+ CurrentLine = GetLine();\r
+ line_length = CurrentLine.length();\r
+ comment_starts_at = CurrentLine.find("<!--");\r
+ \r
+ if (comment_starts_at >= 0) start_comment = true;\r
+ else start_comment = false;\r
+ \r
+ comment_ends_at = CurrentLine.find("-->");\r
+ \r
+ if (comment_ends_at >= 0) end_comment = true;\r
+ else end_comment = false;\r
+\r
+ if (!start_comment && !end_comment) { // command comment\r
+ if (CommentsOn) CommentStringTemp = CurrentLine;\r
+ CommentString += CommentStringTemp + "\r\n";\r
+ } else if (start_comment && comment_ends_at > comment_starts_at) { // <!-- ... -->\r
+ CommentsOn = false;\r
+ comment_length = comment_ends_at + 2 - comment_starts_at + 1;\r
+ LineComment = CurrentLine.substr(comment_starts_at+4, comment_length-4-3);\r
+ CurrentLine.erase(comment_starts_at, comment_length);\r
+ } else if ( start_comment && !end_comment) { // <!-- ...\r
+ CommentsOn = true;\r
+ comment_length = line_length - comment_starts_at;\r
+ CommentStringTemp = CurrentLine.substr(comment_starts_at+4, comment_length-4);\r
+ CommentString = CommentStringTemp + "\r\n";\r
+ CurrentLine.erase(comment_starts_at, comment_length);\r
+ } else if (!start_comment && end_comment) { // ... -->\r
+ CommentsOn = false;\r
+ comment_length = comment_ends_at + 2 + 1;\r
+ CommentStringTemp = CurrentLine.substr(0, comment_length-4);\r
+ CommentString += CommentStringTemp + "\r\n";\r
+ CurrentLine.erase(0, comment_length);\r
+ } else if (start_comment && comment_ends_at < comment_starts_at) { // --> command <!--\r
+ cerr << "Old comment ends and new one starts - bad JSBSim config file form." << endl;\r
+ CommentsOn = false;\r
+ comment_length = comment_ends_at + 2 + 1;\r
+ CommentStringTemp = CurrentLine.substr(0, comment_length-4);\r
+ CommentString += CommentStringTemp + "\r\n";\r
+ CurrentLine.erase(0, comment_length);\r
+ }\r
+ \r
+ } while (CommentsOn);\r
+\r
+ if (CurrentLine.length() == 0) GetNextConfigLine();\r
+ CurrentIndex = 0;\r
+ return CurrentLine;\r
+}\r
+\r
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r
+\r
+string FGConfigFile::GetValue(string val)\r
+{\r
+ unsigned int pos, p1, p2, ptest;\r
+\r
+ if (val == "") { // this call is to return the tag value\r
+ pos = CurrentLine.find("<");\r
+ if (pos != CurrentLine.npos) { // beginning brace found "<"\r
+ p1 = CurrentLine.find_first_not_of(" ",pos+1);\r
+ if (p1 != CurrentLine.npos) { // found first character of tag\r
+ p2 = CurrentLine.find_first_of(" >",p1+1);\r
+ if (p2 == CurrentLine.npos) p2 = p1+1;\r
+ return CurrentLine.substr(p1,p2-p1);\r
+ }\r
+ } else { // beginning brace "<" not found; this is a regular data line\r
+ pos = CurrentLine.find_first_not_of(" ");\r
+ if (pos != CurrentLine.npos) { // first character in line found\r
+ p2 = CurrentLine.find_first_of(" ",pos+1);\r
+ if (p2 != CurrentLine.npos) {\r
+ return CurrentLine.substr(pos,p2-pos);\r
+ } else {\r
+ return CurrentLine.substr(pos,CurrentLine.length()-pos);\r
+ }\r
+ }\r
+ }\r
+ } else { // return a value for a specific tag\r
+ pos = CurrentLine.find(val);\r
+ if (pos != CurrentLine.npos) {\r
+ pos = CurrentLine.find("=",pos);\r
+ if (pos != CurrentLine.npos) {\r
+ ptest = CurrentLine.find_first_not_of(" ",pos+1);\r
+ if (ptest != CurrentLine.npos) {\r
+ p1 = ptest + 1;\r
+ if (CurrentLine[ptest] == '"') { // quoted\r
+ p2 = CurrentLine.find_first_of("\"",p1);\r
+ } else { // not quoted\r
+ p2 = CurrentLine.find_first_of(" ",p1);\r
+ }\r
+ if (p2 != CurrentLine.npos) {\r
+ return CurrentLine.substr(p1,p2-p1);\r
+ }\r
+ }\r
+ } else { // "=" not found\r
+ pos = CurrentLine.find(val);\r
+ pos = CurrentLine.find_first_of(" ",pos+1);\r
+ ptest = CurrentLine.find_first_not_of(" ",pos+1);\r
+ if (ptest != CurrentLine.npos) {\r
+ if (CurrentLine[ptest] == '"') { // quoted\r
+ p1 = ptest + 1;\r
+ p2 = CurrentLine.find_first_of("\"",p1);\r
+ } else { // not quoted\r
+ p1 = ptest;\r
+ p2 = CurrentLine.find_first_of(" ",p1);\r
+ }\r
+ if (p2 != CurrentLine.npos) {\r
+ return CurrentLine.substr(p1,p2-p1);\r
+ } else {\r
+ p2 = CurrentLine.length();\r
+ return CurrentLine.substr(p1,p2-p1);\r
+ }\r
+ }\r
+ }\r
+ }\r
+ }\r
+\r
+ return string("");\r
+}\r
+\r
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r
+\r
+string FGConfigFile::GetValue(void)\r
+{\r
+ return GetValue("");\r
+}\r
+\r
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r
+\r
+string FGConfigFile::GetLine(void)\r
+{\r
+ string scratch = "";\r
+ int test;\r
+\r
+ while ((test = cfgfile.get()) != EOF) {\r
+ if (test >= 0x20 || test == 0x09) {\r
+ if (test == 0x09) {\r
+ scratch += (char)0x20;\r
+ } else {\r
+ scratch += (char)test;\r
+ }\r
+ } else {\r
+ if ((test = cfgfile.get()) != EOF) { // get *next* character\r
+#if defined ( sgi ) && !defined( __GNUC__ )\r
+ if (test >= 0x20 || test == 0x09) cfgfile.putback(test);\r
+#else\r
+ if (test >= 0x20 || test == 0x09) cfgfile.unget();\r
+#endif\r
+ break;\r
+ }\r
+ }\r
+ }\r
+ if (cfgfile.eof()) return string("EOF");\r
+ return scratch;\r
+}\r
+\r
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r
+/*\r
+FGConfigFile& FGConfigFile::operator>>(double& val)\r
+{\r
+ unsigned int pos, end;\r
+\r
+ pos = CurrentLine.find_first_not_of(", ",CurrentIndex);\r
+ if (pos == CurrentLine.npos) pos = CurrentLine.length();\r
+ end = CurrentLine.find_first_of(", ",pos+1);\r
+ if (end == CurrentLine.npos) end = CurrentLine.length();\r
+ string str = CurrentLine.substr(pos, end - pos);\r
+ val = strtod(str.c_str(),NULL);\r
+ CurrentIndex = end+1;\r
+ if (CurrentIndex >= CurrentLine.length()) GetNextConfigLine();\r
+ return *this;\r
+}\r
+*/\r
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r
+\r
+FGConfigFile& FGConfigFile::operator>>(double& val)\r
+{\r
+ unsigned int pos, end;\r
+\r
+ pos = CurrentLine.find_first_not_of(", ",CurrentIndex);\r
+ if (pos == CurrentLine.npos) pos = CurrentLine.length();\r
+ end = CurrentLine.find_first_of(", ",pos+1);\r
+ if (end == CurrentLine.npos) end = CurrentLine.length();\r
+ string str = CurrentLine.substr(pos, end - pos);\r
+ val = strtod(str.c_str(),NULL);\r
+ CurrentIndex = end+1;\r
+ if (CurrentIndex >= CurrentLine.length()) GetNextConfigLine();\r
+ return *this;\r
+}\r
+\r
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r
+\r
+FGConfigFile& FGConfigFile::operator>>(int& val)\r
+{\r
+ unsigned int pos, end;\r
+\r
+ pos = CurrentLine.find_first_not_of(", ",CurrentIndex);\r
+ if (pos == CurrentLine.npos) pos = CurrentLine.length();\r
+ end = CurrentLine.find_first_of(", ",pos+1);\r
+ if (end == CurrentLine.npos) end = CurrentLine.length();\r
+ string str = CurrentLine.substr(pos, end - pos);\r
+ val = atoi(str.c_str());\r
+ CurrentIndex = end+1;\r
+ if (CurrentIndex >= CurrentLine.length()) GetNextConfigLine();\r
+ return *this;\r
+}\r
+\r
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r
+\r
+FGConfigFile& FGConfigFile::operator>>(eParam& val)\r
+{\r
+ unsigned int pos, end;\r
+\r
+ pos = CurrentLine.find_first_not_of(", ",CurrentIndex);\r
+ if (pos == CurrentLine.npos) pos = CurrentLine.length();\r
+ end = CurrentLine.find_first_of(", ",pos+1);\r
+ if (end == CurrentLine.npos) end = CurrentLine.length();\r
+ string str = CurrentLine.substr(pos, end - pos);\r
+ val = (eParam)atoi(str.c_str());\r
+ CurrentIndex = end+1;\r
+ if (CurrentIndex >= CurrentLine.length()) GetNextConfigLine();\r
+ return *this;\r
+}\r
+\r
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r
+\r
+FGConfigFile& FGConfigFile::operator>>(string& str)\r
+{\r
+ unsigned int pos, end;\r
+\r
+ pos = CurrentLine.find_first_not_of(", ",CurrentIndex);\r
+ if (pos == CurrentLine.npos) pos = CurrentLine.length();\r
+ end = CurrentLine.find_first_of(", ",pos+1);\r
+ if (end == CurrentLine.npos) end = CurrentLine.length();\r
+ str = CurrentLine.substr(pos, end - pos);\r
+ CurrentIndex = end+1;\r
+ if (CurrentIndex >= CurrentLine.length()) GetNextConfigLine();\r
+ return *this;\r
+}\r
+\r
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r
+\r
+void FGConfigFile::ResetLineIndexToZero(void)\r
+{\r
+ CurrentIndex = 0;\r
+}\r
+\r
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r
+\r
+void FGConfigFile::Debug(void)\r
+{\r
+ //TODO: Add your source code here\r
+}\r
+\r
string GetNextConfigLine(void);
string GetValue(string);
string GetValue(void);
- string GetCommentString(void);
+ string GetCommentString(void) {return CommentString;}
+ string GetLineComment(void) {return LineComment;}
bool IsOpen(void) {return Opened;}
+// FGConfigFile& operator>>(double&);
FGConfigFile& operator>>(double&);
- FGConfigFile& operator>>(float&);
FGConfigFile& operator>>(int&);
FGConfigFile& operator>>(string&);
FGConfigFile& operator>>(eParam&);
ifstream cfgfile;
string CurrentLine;
string CommentString;
+ string LineComment;
bool CommentsOn;
bool Opened;
unsigned int CurrentIndex;
// and sets the starved flag if necessary.
void FGEngine::ConsumeFuel(void) {
- float Fshortage, Oshortage;
+ double Fshortage, Oshortage;
FGTank* Tank;
if (TrimMode) return;
-
Fshortage = Oshortage = 0.0;
for (unsigned int i=0; i<SourceTanks.size(); i++) {
Tank = Propulsion->GetTank(i);
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-float FGEngine::CalcFuelNeed(void) {
+double FGEngine::CalcFuelNeed(void) {
FuelNeed = SLFuelFlowMax*PctPower*State->Getdt()*Propulsion->GetRate();
return FuelNeed;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-float FGEngine::CalcOxidizerNeed(void) {
+double FGEngine::CalcOxidizerNeed(void) {
OxidizerNeed = SLOxiFlowMax*PctPower*State->Getdt()*Propulsion->GetRate();
return OxidizerNeed;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-void FGEngine::SetPlacement(float x, float y, float z, float pitch, float yaw) {
+void FGEngine::SetPlacement(double x, double y, double z, double pitch, double yaw) {
X = x;
Y = y;
Z = z;
enum EngineType {etUnknown, etRocket, etPiston, etTurboProp, etTurboJet, etTurboShaft};
- virtual float GetThrottleMin(void) { return MinThrottle; }
- virtual float GetThrottleMax(void) { return MaxThrottle; }
- float GetThrottle(void) { return Throttle; }
- float GetMixture(void) { return Mixture; }
+ virtual double GetThrottleMin(void) { return MinThrottle; }
+ virtual double GetThrottleMax(void) { return MaxThrottle; }
+ double GetThrottle(void) { return Throttle; }
+ double GetMixture(void) { return Mixture; }
int GetMagnetos(void) { return Magnetos; }
bool GetStarter(void) { return Starter; }
- float GetThrust(void) { return Thrust; }
+ double GetThrust(void) { return Thrust; }
bool GetStarved(void) { return Starved; }
bool GetFlameout(void) { return Flameout; }
bool GetRunning(void) { return Running; }
int GetType(void) { return Type; }
string GetName(void) { return Name; }
- virtual float getManifoldPressure_inHg () const {
+ virtual double getManifoldPressure_inHg () const {
return ManifoldPressure_inHg;
}
- virtual float getExhaustGasTemp_degF () const {
+ virtual double getExhaustGasTemp_degF () const {
return (ExhaustGasTemp_degK - 273) * (9.0 / 5.0) + 32.0;
}
- virtual float getCylinderHeadTemp_degF () const {
+ virtual double getCylinderHeadTemp_degF () const {
return (CylinderHeadTemp_degK - 273) * (9.0 / 5.0) + 32.0;
}
- virtual float getOilPressure_psi () const {
+ virtual double getOilPressure_psi () const {
return OilPressure_psi;
}
- virtual float getOilTemp_degF () const {
+ virtual double getOilTemp_degF () const {
return (OilTemp_degK - 273.0) * (9.0 / 5.0) + 32.0;
}
such as a propeller. This resisting effect must be provided to the
engine model.
@return Thrust in pounds */
- virtual float Calculate(float PowerRequired) {return 0.0;};
+ virtual double Calculate(double PowerRequired) {return 0.0;};
/** Reduces the fuel in the active tanks by the amount required.
This function should be called from within the
power level. It is also turned from a rate into an actual amount (pounds)
by multiplying it by the delta T and the rate.
@return Total fuel requirement for this engine in pounds. */
- float CalcFuelNeed(void);
+ double CalcFuelNeed(void);
/** The oxidizer need is calculated based on power levels and flow rate for that
power level. It is also turned from a rate into an actual amount (pounds)
by multiplying it by the delta T and the rate.
@return Total oxidizer requirement for this engine in pounds. */
- float CalcOxidizerNeed(void);
+ double CalcOxidizerNeed(void);
/// Sets engine placement information
- void SetPlacement(float x, float y, float z, float pitch, float yaw);
+ void SetPlacement(double x, double y, double z, double pitch, double yaw);
- virtual float GetPowerAvailable(void) {return 0.0;};
+ virtual double GetPowerAvailable(void) {return 0.0;};
bool GetTrimMode(void) {return TrimMode;}
void SetTrimMode(bool state) {TrimMode = state;}
protected:
string Name;
EngineType Type;
- float X, Y, Z;
- float EnginePitch;
- float EngineYaw;
- float SLFuelFlowMax;
- float SLOxiFlowMax;
- float MaxThrottle;
- float MinThrottle;
-
- float Thrust;
- float Throttle;
- float Mixture;
+ double X, Y, Z;
+ double EnginePitch;
+ double EngineYaw;
+ double SLFuelFlowMax;
+ double SLOxiFlowMax;
+ double MaxThrottle;
+ double MinThrottle;
+
+ double Thrust;
+ double Throttle;
+ double Mixture;
int Magnetos;
bool Starter;
- float FuelNeed, OxidizerNeed;
+ double FuelNeed, OxidizerNeed;
bool Starved;
bool Flameout;
bool Running;
bool Cranking;
- float PctPower;
+ double PctPower;
int EngineNumber;
bool TrimMode;
- float ManifoldPressure_inHg;
- float ExhaustGasTemp_degK;
- float CylinderHeadTemp_degK;
- float OilPressure_psi;
- float OilTemp_degK;
+ double ManifoldPressure_inHg;
+ double ExhaustGasTemp_degK;
+ double CylinderHeadTemp_degK;
+ double OilPressure_psi;
+ double OilTemp_degK;
FGFDMExec* FDMExec;
FGState* State;
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-void FGFCS::SetThrottleCmd(int engineNum, float setting)
+void FGFCS::SetThrottleCmd(int engineNum, double setting)
{
unsigned int ctr;
- if ((int)ThrottleCmd.size() > engineNum) {
+ if (engineNum < (int)ThrottlePos.size()) {
if (engineNum < 0) {
- for (ctr=0;ctr<=ThrottleCmd.size();ctr++) ThrottleCmd[ctr] = setting;
+ for (ctr=0;ctr<ThrottleCmd.size();ctr++) ThrottleCmd[ctr] = setting;
} else {
ThrottleCmd[engineNum] = setting;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-void FGFCS::SetThrottlePos(int engineNum, float setting)
+void FGFCS::SetThrottlePos(int engineNum, double setting)
{
unsigned int ctr;
- if ((int)ThrottlePos.size() > engineNum) {
+ if (engineNum < (int)ThrottlePos.size()) {
if (engineNum < 0) {
- for (ctr=0;ctr<=ThrottlePos.size();ctr++) ThrottlePos[ctr] = setting;
+ for (ctr=0;ctr<ThrottlePos.size();ctr++) ThrottlePos[ctr] = setting;
} else {
ThrottlePos[engineNum] = setting;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-float FGFCS::GetThrottleCmd(int engineNum)
+double FGFCS::GetThrottleCmd(int engineNum)
{
- if ((int)ThrottleCmd.size() > engineNum) {
+ if (engineNum < (int)ThrottlePos.size()) {
if (engineNum < 0) {
cerr << "Cannot get throttle value for ALL engines" << endl;
} else {
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-float FGFCS::GetThrottlePos(int engineNum)
+double FGFCS::GetThrottlePos(int engineNum)
{
- if ((int)ThrottlePos.size() > engineNum) {
+ if (engineNum < (int)ThrottlePos.size()) {
if (engineNum < 0) {
cerr << "Cannot get throttle value for ALL engines" << endl;
} else {
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-void FGFCS::SetMixtureCmd(int engineNum, float setting)
+void FGFCS::SetMixtureCmd(int engineNum, double setting)
{
unsigned int ctr;
- if (engineNum < 0) {
- for (ctr=0;ctr<MixtureCmd.size();ctr++) MixtureCmd[ctr] = setting;
- } else {
- MixtureCmd[engineNum] = setting;
+ if (engineNum < (int)ThrottlePos.size()) {
+ if (engineNum < 0) {
+ for (ctr=0;ctr<MixtureCmd.size();ctr++) MixtureCmd[ctr] = setting;
+ } else {
+ MixtureCmd[engineNum] = setting;
+ }
}
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-void FGFCS::SetMixturePos(int engineNum, float setting)
+void FGFCS::SetMixturePos(int engineNum, double setting)
{
unsigned int ctr;
- if (engineNum < 0) {
- for (ctr=0;ctr<=MixtureCmd.size();ctr++) MixturePos[ctr] = MixtureCmd[ctr];
- } else {
- MixturePos[engineNum] = setting;
+ if (engineNum < (int)ThrottlePos.size()) {
+ if (engineNum < 0) {
+ for (ctr=0;ctr<=MixtureCmd.size();ctr++) MixturePos[ctr] = MixtureCmd[ctr];
+ } else {
+ MixturePos[engineNum] = setting;
+ }
}
}
Name = Name + ":" + AC_cfg->GetValue("NAME");
if (debug_lvl > 0) cout << " Control System Name: " << Name << endl;
AC_cfg->GetNextConfigLine();
- while ((token = AC_cfg->GetValue()) != "/FLIGHT_CONTROL") {
+ while ((token = AC_cfg->GetValue()) != string("/FLIGHT_CONTROL")) {
if (token == "COMPONENT") {
token = AC_cfg->GetValue("TYPE");
if (debug_lvl > 0) cout << " Loading Component \""
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-float FGFCS::GetComponentOutput(eParam idx) {
+double FGFCS::GetComponentOutput(eParam idx) {
return Components[idx]->GetOutput();
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-float FGFCS::GetBrake(FGLGear::BrakeGroup bg) {
+double FGFCS::GetBrake(FGLGear::BrakeGroup bg) {
switch (bg) {
case FGLGear::bgLeft:
return LeftBrake;
//@{
/** Gets the aileron command.
@return aileron command in radians */
- inline float GetDaCmd(void) { return DaCmd; }
+ inline double GetDaCmd(void) { return DaCmd; }
/** Gets the elevator command.
@return elevator command in radians */
- inline float GetDeCmd(void) { return DeCmd; }
+ inline double GetDeCmd(void) { return DeCmd; }
/** Gets the rudder command.
@return rudder command in radians */
- inline float GetDrCmd(void) { return DrCmd; }
+ inline double GetDrCmd(void) { return DrCmd; }
/** Gets the flaps command.
@return flaps command in radians */
- inline float GetDfCmd(void) { return DfCmd; }
+ inline double GetDfCmd(void) { return DfCmd; }
/** Gets the speedbrake command.
@return speedbrake command in radians */
- inline float GetDsbCmd(void) { return DsbCmd; }
+ inline double GetDsbCmd(void) { return DsbCmd; }
/** Gets the spoiler command.
@return spoiler command in radians */
- inline float GetDspCmd(void) { return DspCmd; }
+ inline double GetDspCmd(void) { return DspCmd; }
/** Gets the throttle command.
@param engine engine ID number
@return throttle command in percent ( 0 - 100) for the given engine */
- float GetThrottleCmd(int engine);
+ double GetThrottleCmd(int engine);
/** Gets the mixture command.
@param engine engine ID number
@return mixture command in percent ( 0 - 100) for the given engine */
- inline float GetMixtureCmd(int engine) { return MixtureCmd[engine]; }
+ inline double GetMixtureCmd(int engine) { return MixtureCmd[engine]; }
/** Gets the pitch trim command.
@return pitch trim command in radians */
- inline float GetPitchTrimCmd(void) { return PTrimCmd; }
+ inline double GetPitchTrimCmd(void) { return PTrimCmd; }
//@}
/// @name Aerosurface position retrieval
//@{
/** Gets the aileron position.
@return aileron position in radians */
- inline float GetDaPos(void) { return DaPos; }
+ inline double GetDaPos(void) { return DaPos; }
/** Gets the elevator position.
@return elevator position in radians */
- inline float GetDePos(void) { return DePos; }
+ inline double GetDePos(void) { return DePos; }
/** Gets the rudder position.
@return rudder position in radians */
- inline float GetDrPos(void) { return DrPos; }
+ inline double GetDrPos(void) { return DrPos; }
/** Gets the flaps position.
@return flaps position in radians */
- inline float GetDfPos(void) { return DfPos; }
+ inline double GetDfPos(void) { return DfPos; }
/** Gets the speedbrake position.
@return speedbrake position in radians */
- inline float GetDsbPos(void) { return DsbPos; }
+ inline double GetDsbPos(void) { return DsbPos; }
/** Gets the spoiler position.
@return spoiler position in radians */
- inline float GetDspPos(void) { return DspPos; }
+ inline double GetDspPos(void) { return DspPos; }
/** Gets the throttle position.
@param engine engine ID number
@return throttle position for the given engine in percent ( 0 - 100)*/
- float GetThrottlePos(int engine);
+ double GetThrottlePos(int engine);
/** Gets the mixture position.
@param engine engine ID number
@return mixture position for the given engine in percent ( 0 - 100)*/
- inline float GetMixturePos(int engine) { return MixturePos[engine]; }
+ inline double GetMixturePos(int engine) { return MixturePos[engine]; }
//@}
/** Retrieves the State object pointer.
/** Retrieves a components output value
@param idx the index of the component (the component ID)
@return output value from the component */
- float GetComponentOutput(eParam idx);
+ double GetComponentOutput(eParam idx);
/** Retrieves the component name
@param idx the index of the component (the component ID)
//@{
/** Sets the aileron command
@param cmd aileron command in radians*/
- inline void SetDaCmd(float cmd) { DaCmd = cmd; }
+ inline void SetDaCmd(double cmd) { DaCmd = cmd; }
/** Sets the elevator command
@param cmd elevator command in radians*/
- inline void SetDeCmd(float cmd) { DeCmd = cmd; }
+ inline void SetDeCmd(double cmd) { DeCmd = cmd; }
/** Sets the rudder command
@param cmd rudder command in radians*/
- inline void SetDrCmd(float cmd) { DrCmd = cmd; }
+ inline void SetDrCmd(double cmd) { DrCmd = cmd; }
/** Sets the flaps command
@param cmd flaps command in radians*/
- inline void SetDfCmd(float cmd) { DfCmd = cmd; }
+ inline void SetDfCmd(double cmd) { DfCmd = cmd; }
/** Sets the speedbrake command
@param cmd speedbrake command in radians*/
- inline void SetDsbCmd(float cmd) { DsbCmd = cmd; }
+ inline void SetDsbCmd(double cmd) { DsbCmd = cmd; }
/** Sets the spoilers command
@param cmd spoilers command in radians*/
- inline void SetDspCmd(float cmd) { DspCmd = cmd; }
+ inline void SetDspCmd(double cmd) { DspCmd = cmd; }
/** Sets the pitch trim command
@param cmd pitch trim command in radians*/
- inline void SetPitchTrimCmd(float cmd) { PTrimCmd = cmd; }
+ inline void SetPitchTrimCmd(double cmd) { PTrimCmd = cmd; }
/** Sets the throttle command for the specified engine
@param engine engine ID number
@param cmd throttle command in percent (0 - 100)*/
- void SetThrottleCmd(int engine, float cmd);
+ void SetThrottleCmd(int engine, double cmd);
/** Sets the mixture command for the specified engine
@param engine engine ID number
@param cmd mixture command in percent (0 - 100)*/
- void SetMixtureCmd(int engine, float cmd);
+ void SetMixtureCmd(int engine, double cmd);
//@}
/// @name Aerosurface position setting
//@{
/** Sets the aileron position
@param cmd aileron position in radians*/
- inline void SetDaPos(float cmd) { DaPos = cmd; }
+ inline void SetDaPos(double cmd) { DaPos = cmd; }
/** Sets the elevator position
@param cmd elevator position in radians*/
- inline void SetDePos(float cmd) { DePos = cmd; }
+ inline void SetDePos(double cmd) { DePos = cmd; }
/** Sets the rudder position
@param cmd rudder position in radians*/
- inline void SetDrPos(float cmd) { DrPos = cmd; }
+ inline void SetDrPos(double cmd) { DrPos = cmd; }
/** Sets the flaps position
@param cmd flaps position in radians*/
- inline void SetDfPos(float cmd) { DfPos = cmd; }
+ inline void SetDfPos(double cmd) { DfPos = cmd; }
/** Sets the speedbrake position
@param cmd speedbrake position in radians*/
- inline void SetDsbPos(float cmd) { DsbPos = cmd; }
+ inline void SetDsbPos(double cmd) { DsbPos = cmd; }
/** Sets the spoiler position
@param cmd spoiler position in radians*/
- inline void SetDspPos(float cmd) { DspPos = cmd; }
+ inline void SetDspPos(double cmd) { DspPos = cmd; }
/** Sets the actual throttle setting for the specified engine
@param engine engine ID number
@param cmd throttle setting in percent (0 - 100)*/
- void SetThrottlePos(int engine, float cmd);
+ void SetThrottlePos(int engine, double cmd);
/** Sets the actual mixture setting for the specified engine
@param engine engine ID number
@param cmd mixture setting in percent (0 - 100)*/
- void SetMixturePos(int engine, float cmd);
+ void SetMixturePos(int engine, double cmd);
//@}
/// @name Landing Gear brakes
//@{
/** Sets the left brake group
@param cmd brake setting in percent (0.0 - 1.0) */
- void SetLBrake(float cmd) {LeftBrake = cmd;}
+ void SetLBrake(double cmd) {LeftBrake = cmd;}
/** Sets the right brake group
@param cmd brake setting in percent (0.0 - 1.0) */
- void SetRBrake(float cmd) {RightBrake = cmd;}
+ void SetRBrake(double cmd) {RightBrake = cmd;}
/** Sets the center brake group
@param cmd brake setting in percent (0.0 - 1.0) */
- void SetCBrake(float cmd) {CenterBrake = cmd;}
+ void SetCBrake(double cmd) {CenterBrake = cmd;}
/** Gets the brake for a specified group.
@param bg which brakegroup to retrieve the command for
@return the brake setting for the supplied brake group argument */
- float GetBrake(FGLGear::BrakeGroup bg);
+ double GetBrake(FGLGear::BrakeGroup bg);
//@}
/** Loads the Flight Control System.
void AddThrottle(void);
private:
- float DaCmd, DeCmd, DrCmd, DfCmd, DsbCmd, DspCmd;
- float DaPos, DePos, DrPos, DfPos, DsbPos, DspPos;
- float PTrimCmd;
- vector <float> ThrottleCmd;
- vector <float> ThrottlePos;
- vector <float> MixtureCmd;
- vector <float> MixturePos;
- float LeftBrake, RightBrake, CenterBrake; // Brake settings
+ double DaCmd, DeCmd, DrCmd, DfCmd, DsbCmd, DspCmd;
+ double DaPos, DePos, DrPos, DfPos, DsbPos, DspPos;
+ double PTrimCmd;
+ vector <double> ThrottleCmd;
+ vector <double> ThrottlePos;
+ vector <double> MixtureCmd;
+ vector <double> MixturePos;
+ double LeftBrake, RightBrake, CenterBrake; // Brake settings
vector <FGFCSComponent*> Components;
void Debug(void);
model_iterator->NextModel->SetRate(rate);
}
+
return 0;
}
string aircraft="";
string initialize="";
bool result=false;
- float dt=0.0;
+ double dt=0.0;
int i;
struct condition *newCondition;
Scripted = true;
if (debug_lvl > 0) cout << "Reading Script File " << ScriptName << endl;
- while (Script.GetNextConfigLine() != "EOF" && Script.GetValue() != "/runscript") {
+ while (Script.GetNextConfigLine() != string("EOF") && Script.GetValue() != string("/runscript")) {
token = Script.GetValue();
if (token == "use") {
- if ((token = Script.GetValue("aircraft")) != "") {
+ if ((token = Script.GetValue("aircraft")) != string("")) {
aircraft = token;
if (debug_lvl > 0) cout << " Use aircraft: " << token << endl;
- } else if ((token = Script.GetValue("initialize")) != "") {
+ } else if ((token = Script.GetValue("initialize")) != string("")) {
initialize = token;
if (debug_lvl > 0) cout << " Use reset file: " << token << endl;
} else {
State->Setdt(dt);
Script.GetNextConfigLine();
token = Script.GetValue();
- while (token != "/run") {
+ while (token != string("/run")) {
if (token == "when") {
Script.GetNextConfigLine();
token = Script.GetValue();
newCondition = new struct condition();
- while (token != "/when") {
+ while (token != string("/when")) {
if (token == "parameter") {
newCondition->TestParam.push_back(State->GetParameterIndex(Script.GetValue("name")));
newCondition->TestValue.push_back(strtod(Script.GetValue("value").c_str(), NULL));
int count=0;
- float currentTime = State->Getsim_time();
- float newSetValue;
+ double currentTime = State->Getsim_time();
+ double newSetValue;
while (iC < Conditions.end()) {
// determine whether the set of conditional tests for this condition equate
break;
}
State->SetParameter(iC->SetParam[i], newSetValue);
+ if ((unsigned long int)Propulsion->GetTank(0) == 0) {
+ cout << "Param # getting set: " << iC->SetParam[i] << " Value: " << newSetValue << endl;
+ }
}
}
iC++;
struct condition {
vector <eParam> TestParam;
vector <eParam> SetParam;
- vector <float> TestValue;
- vector <float> SetValue;
+ vector <double> TestValue;
+ vector <double> SetValue;
vector <string> Comparison;
- vector <float> TC;
+ vector <double> TC;
vector <bool> Persistent;
vector <eAction> Action;
vector <eType> Type;
vector <bool> Triggered;
- vector <float> newValue;
- vector <float> OriginalValue;
- vector <float> StartTime;
- vector <float> EndTime;
+ vector <double> newValue;
+ vector <double> OriginalValue;
+ vector <double> StartTime;
+ vector <double> EndTime;
condition() {
}
string EnginePath;
string ScriptPath;
string ScriptName;
- float StartTime;
- float EndTime;
+ double StartTime;
+ double EndTime;
vector <struct condition> Conditions;
FGState* State;
//if (debug_lvl > 0) DisplayCoeffFactors(ca.back()->Getmultipliers());
}
token = AC_cfg->GetValue();
- while ( token != "/GROUP" ) {
+ while ( token != string("/GROUP") ) {
sum.push_back( new FGCoefficient(FDMExec) );
sum.back()->Load(AC_cfg);
//if (debug_lvl > 0) DisplayCoeffFactors(ca.back()->Getmultipliers());
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-float FGFactorGroup::TotalValue(void) {
+double FGFactorGroup::TotalValue(void) {
int i;
- float totalsum=0;
+ double totalsum=0;
SDtotal=0.0;
for(i=0;i<sum.size();i++) {
totalsum+=sum[i]->TotalValue();
~FGFactorGroup();
bool Load(FGConfigFile *AC_cfg);
- float TotalValue(void);
+ double TotalValue(void);
//string GetCoefficientStrings(void);
//string GetCoefficientValues(void);
- inline float GetSD(void) { return SDtotal; }
- inline float GetFactorSD(void) { return FGCoefficient::GetSD(); }
+ inline double GetSD(void) { return SDtotal; }
+ inline double GetFactorSD(void) { return FGCoefficient::GetSD(); }
private:
FGFDMExec *FDMExec;
string description;
typedef vector<FGCoefficient*> CoeffArray;
CoeffArray sum;
- float SDtotal;
+ double SDtotal;
void Debug(void);
};
FGMatrix33 FGForce::Transform(void) {
switch(ttype) {
case tWindBody:
- return fdmex->GetState()->GetTs2b(fdmex->GetTranslation()->Getalpha(),fdmex->GetTranslation()->Getbeta());
+ return fdmex->GetState()->GetTs2b();
case tLocalBody:
return fdmex->GetState()->GetTl2b();
case tCustom:
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-void FGForce::SetAnglesToBody(float broll, float bpitch, float byaw) {
+void FGForce::SetAnglesToBody(double broll, double bpitch, double byaw) {
if(ttype == tCustom) {
- float cp,sp,cr,sr,cy,sy;
+ double cp,sp,cr,sr,cy,sy;
cp=cos(bpitch); sp=sin(bpitch);
cr=cos(broll); sr=sin(broll);
<p>Note that storing the native forces and moments outside of this class is not
strictly necessary, overloaded SetNativeForces() and SetNativeMoments() methods
-which each accept three floats (rather than a vector) are provided and can be
+which each accept three doubles (rather than a vector) are provided and can be
repeatedly called without incurring undue overhead. The body axes force vector
can now be retrieved by calling:</p>
enum TransformType { tNone, tWindBody, tLocalBody, tCustom } ttype;
- inline void SetNativeForces(float Fnx, float Fny, float Fnz) {
+ inline void SetNativeForces(double Fnx, double Fny, double Fnz) {
vFn(1)=Fnx;
vFn(2)=Fny;
vFn(3)=Fnz;
}
inline void SetNativeForces(FGColumnVector3 vv) { vFn = vv; };
- inline void SetNativeMoments(float Ln,float Mn, float Nn) {
+ inline void SetNativeMoments(double Ln,double Mn, double Nn) {
vMn(1)=Ln;
vMn(2)=Mn;
vMn(3)=Nn;
//point of application, JSBsim structural coords
//(inches, x +back, y +right, z +up)
- inline void SetLocation(float x, float y, float z) {
+ inline void SetLocation(double x, double y, double z) {
vXYZn(1) = x;
vXYZn(2) = y;
vXYZn(3) = z;
}
- inline void SetLocationX(float x) {vXYZn(1) = x;}
- inline void SetLocationY(float y) {vXYZn(2) = y;}
- inline void SetLocationZ(float z) {vXYZn(3) = z;}
+ inline void SetLocationX(double x) {vXYZn(1) = x;}
+ inline void SetLocationY(double y) {vXYZn(2) = y;}
+ inline void SetLocationZ(double z) {vXYZn(3) = z;}
inline void SetLocation(FGColumnVector3 vv) { vXYZn = vv; }
FGColumnVector3& GetLocation(void) { return vXYZn; }
//are going to get confused.
//They are in radians.
- void SetAnglesToBody(float broll, float bpitch, float byaw);
+ void SetAnglesToBody(double broll, double bpitch, double byaw);
inline void SetAnglesToBody(FGColumnVector3 vv) { SetAnglesToBody(vv(1), vv(2), vv(3));}
- inline void SetSense(float x, float y, float z) { vSense(1)=x, vSense(2)=y, vSense(3)=z; }
+ inline void SetSense(double x, double y, double z) { vSense(1)=x, vSense(2)=y, vSense(3)=z; }
inline void SetSense(FGColumnVector3 vv) { vSense=vv; }
inline FGColumnVector3& GetSense(void) { return vSense; }
bool FGGroundReactions::Run(void)
{
- float steerAngle = 0.0;
- float xForces = 0.0, yForces = 0.0;
+ double steerAngle = 0.0;
+ double xForces = 0.0, yForces = 0.0;
if (!FGModel::Run()) {
vForces.InitMatrix();
AC_cfg->GetNextConfigLine();
- while ((token = AC_cfg->GetValue()) != "/UNDERCARRIAGE") {
+ while ((token = AC_cfg->GetValue()) != string("/UNDERCARRIAGE")) {
lGear.push_back(FGLGear(AC_cfg, FDMExec));
}
bool FGInertial::Run(void)
{
- float stht, ctht, sphi, cphi;
+ double stht, ctht, sphi, cphi;
if (!FGModel::Run()) {
bool Run(void);
FGColumnVector3& GetForces(void) {return vForces;}
FGColumnVector3& GetGravity(void) {return vGravity;}
- float GetForces(int n) {return vForces(n);}
+ double GetForces(int n) {return vForces(n);}
bool LoadInertial(FGConfigFile* AC_cfg);
double SLgravity(void) {return gAccelReference;}
double gravity(void) {return gAccel;}
//******************************************************************************
-void FGInitialCondition::SetVcalibratedKtsIC(float tt) {
+void FGInitialCondition::SetVcalibratedKtsIC(double tt) {
if(getMachFromVcas(&mach,tt*ktstofps)) {
//cout << "Mach: " << mach << endl;
//******************************************************************************
-void FGInitialCondition::SetVequivalentKtsIC(float tt) {
+void FGInitialCondition::SetVequivalentKtsIC(double tt) {
ve=tt*ktstofps;
lastSpeedSet=setve;
vt=ve*1/sqrt(fdmex->GetAtmosphere()->GetDensityRatio());
//******************************************************************************
-void FGInitialCondition::SetVgroundFpsIC(float tt) {
- float ua,va,wa;
- float vxz;
+void FGInitialCondition::SetVgroundFpsIC(double tt) {
+ double ua,va,wa;
+ double vxz;
vg=tt;
lastSpeedSet=setvg;
//******************************************************************************
-void FGInitialCondition::SetVtrueFpsIC(float tt) {
+void FGInitialCondition::SetVtrueFpsIC(double tt) {
vt=tt;
lastSpeedSet=setvt;
mach=vt/fdmex->GetAtmosphere()->GetSoundSpeed();
//******************************************************************************
-void FGInitialCondition::SetMachIC(float tt) {
+void FGInitialCondition::SetMachIC(double tt) {
mach=tt;
lastSpeedSet=setmach;
vt=mach*fdmex->GetAtmosphere()->GetSoundSpeed();
//******************************************************************************
-void FGInitialCondition::SetClimbRateFpmIC(float tt) {
+void FGInitialCondition::SetClimbRateFpmIC(double tt) {
SetClimbRateFpsIC(tt/60.0);
}
//******************************************************************************
-void FGInitialCondition::SetClimbRateFpsIC(float tt) {
+void FGInitialCondition::SetClimbRateFpsIC(double tt) {
if(vt > 0.1) {
hdot=tt;
//******************************************************************************
-void FGInitialCondition::SetFlightPathAngleRadIC(float tt) {
+void FGInitialCondition::SetFlightPathAngleRadIC(double tt) {
gamma=tt;
sgamma=sin(gamma); cgamma=cos(gamma);
getTheta();
//******************************************************************************
-void FGInitialCondition::SetAlphaRadIC(float tt) {
+void FGInitialCondition::SetAlphaRadIC(double tt) {
alpha=tt;
salpha=sin(alpha); calpha=cos(alpha);
getTheta();
//******************************************************************************
-void FGInitialCondition::SetPitchAngleRadIC(float tt) {
+void FGInitialCondition::SetPitchAngleRadIC(double tt) {
theta=tt;
stheta=sin(theta); ctheta=cos(theta);
getAlpha();
//******************************************************************************
-void FGInitialCondition::SetBetaRadIC(float tt) {
+void FGInitialCondition::SetBetaRadIC(double tt) {
beta=tt;
sbeta=sin(beta); cbeta=cos(beta);
getTheta();
//******************************************************************************
-void FGInitialCondition::SetRollAngleRadIC(float tt) {
+void FGInitialCondition::SetRollAngleRadIC(double tt) {
phi=tt;
sphi=sin(phi); cphi=cos(phi);
getTheta();
//******************************************************************************
-void FGInitialCondition::SetTrueHeadingRadIC(float tt) {
+void FGInitialCondition::SetTrueHeadingRadIC(double tt) {
psi=tt;
spsi=sin(psi); cpsi=cos(psi);
calcWindUVW();
//******************************************************************************
-void FGInitialCondition::SetUBodyFpsIC(float tt) {
+void FGInitialCondition::SetUBodyFpsIC(double tt) {
u=tt;
vt=sqrt(u*u + v*v + w*w);
lastSpeedSet=setuvw;
//******************************************************************************
-void FGInitialCondition::SetVBodyFpsIC(float tt) {
+void FGInitialCondition::SetVBodyFpsIC(double tt) {
v=tt;
vt=sqrt(u*u + v*v + w*w);
lastSpeedSet=setuvw;
//******************************************************************************
-void FGInitialCondition::SetWBodyFpsIC(float tt) {
+void FGInitialCondition::SetWBodyFpsIC(double tt) {
w=tt;
vt=sqrt( u*u + v*v + w*w );
lastSpeedSet=setuvw;
//******************************************************************************
-float FGInitialCondition::GetUBodyFpsIC(void) {
+double FGInitialCondition::GetUBodyFpsIC(void) {
if(lastSpeedSet == setvg )
return u;
else
//******************************************************************************
-float FGInitialCondition::GetVBodyFpsIC(void) {
+double FGInitialCondition::GetVBodyFpsIC(void) {
if( lastSpeedSet == setvg )
return v;
else {
//******************************************************************************
-float FGInitialCondition::GetWBodyFpsIC(void) {
+double FGInitialCondition::GetWBodyFpsIC(void) {
if( lastSpeedSet == setvg )
return w;
else
//******************************************************************************
-void FGInitialCondition::SetWindNEDFpsIC(float wN, float wE, float wD ) {
+void FGInitialCondition::SetWindNEDFpsIC(double wN, double wE, double wD ) {
wnorth = wN; weast = wE; wdown = wD;
lastWindSet = setwned;
calcWindUVW();
//******************************************************************************
// positive from left
-void FGInitialCondition::SetHeadWindKtsIC(float head){
+void FGInitialCondition::SetHeadWindKtsIC(double head){
whead=head*ktstofps;
lastWindSet=setwhc;
calcWindUVW();
//******************************************************************************
-void FGInitialCondition::SetCrossWindKtsIC(float cross){
+void FGInitialCondition::SetCrossWindKtsIC(double cross){
wcross=cross*ktstofps;
lastWindSet=setwhc;
calcWindUVW();
//******************************************************************************
-void FGInitialCondition::SetWindDownKtsIC(float wD) {
+void FGInitialCondition::SetWindDownKtsIC(double wD) {
wdown=wD;
calcWindUVW();
if(lastSpeedSet == setvg)
//******************************************************************************
-void FGInitialCondition::SetWindMagKtsIC(float mag) {
+void FGInitialCondition::SetWindMagKtsIC(double mag) {
wmag=mag*ktstofps;
lastWindSet=setwmd;
calcWindUVW();
//******************************************************************************
-void FGInitialCondition::SetWindDirDegIC(float dir) {
+void FGInitialCondition::SetWindDirDegIC(double dir) {
wdir=dir*degtorad;
lastWindSet=setwmd;
calcWindUVW();
//******************************************************************************
-void FGInitialCondition::SetAltitudeFtIC(float tt) {
+void FGInitialCondition::SetAltitudeFtIC(double tt) {
altitude=tt;
fdmex->GetPosition()->Seth(altitude);
fdmex->GetAtmosphere()->Run();
//******************************************************************************
-void FGInitialCondition::SetAltitudeAGLFtIC(float tt) {
+void FGInitialCondition::SetAltitudeAGLFtIC(double tt) {
fdmex->GetPosition()->SetDistanceAGL(tt);
altitude=fdmex->GetPosition()->Geth();
SetAltitudeFtIC(altitude);
//******************************************************************************
-void FGInitialCondition::SetVnorthFpsIC(float tt) {
+void FGInitialCondition::SetVnorthFpsIC(double tt) {
vnorth=tt;
calcUVWfromNED();
vt=sqrt(u*u + v*v + w*w);
//******************************************************************************
-void FGInitialCondition::SetVeastFpsIC(float tt) {
+void FGInitialCondition::SetVeastFpsIC(double tt) {
veast=tt;
calcUVWfromNED();
vt=sqrt(u*u + v*v + w*w);
//******************************************************************************
-void FGInitialCondition::SetVdownFpsIC(float tt) {
+void FGInitialCondition::SetVdownFpsIC(double tt) {
vdown=tt;
calcUVWfromNED();
vt=sqrt(u*u + v*v + w*w);
//******************************************************************************
-bool FGInitialCondition::getMachFromVcas(float *Mach,float vcas) {
+bool FGInitialCondition::getMachFromVcas(double *Mach,double vcas) {
bool result=false;
- float guess=1.5;
+ double guess=1.5;
xlo=xhi=0;
xmin=0;xmax=50;
sfunc=&FGInitialCondition::calcVcas;
bool FGInitialCondition::getAlpha(void) {
bool result=false;
- float guess=theta-gamma;
+ double guess=theta-gamma;
xlo=xhi=0;
xmin=fdmex->GetAircraft()->GetAlphaCLMin();
xmax=fdmex->GetAircraft()->GetAlphaCLMax();
bool FGInitialCondition::getTheta(void) {
bool result=false;
- float guess=alpha+gamma;
+ double guess=alpha+gamma;
xlo=xhi=0;
xmin=-89;xmax=89;
sfunc=&FGInitialCondition::GammaEqOfTheta;
//******************************************************************************
-float FGInitialCondition::GammaEqOfTheta(float Theta) {
- float a,b,c,d;
- float sTheta,cTheta;
+double FGInitialCondition::GammaEqOfTheta(double Theta) {
+ double a,b,c,d;
+ double sTheta,cTheta;
//theta=Theta; stheta=sin(theta); ctheta=cos(theta);
sTheta=sin(Theta); cTheta=cos(Theta);
//******************************************************************************
-float FGInitialCondition::GammaEqOfAlpha(float Alpha) {
- float a,b,c,d;
- float sAlpha,cAlpha;
+double FGInitialCondition::GammaEqOfAlpha(double Alpha) {
+ double a,b,c,d;
+ double sAlpha,cAlpha;
sAlpha=sin(Alpha); cAlpha=cos(Alpha);
a=wdown + vt*cAlpha*cbeta + uw;
//******************************************************************************
-float FGInitialCondition::calcVcas(float Mach) {
+double FGInitialCondition::calcVcas(double Mach) {
- float p=fdmex->GetAtmosphere()->GetPressure();
- float psl=fdmex->GetAtmosphere()->GetPressureSL();
- float rhosl=fdmex->GetAtmosphere()->GetDensitySL();
- float pt,A,B,D,vcas;
+ double p=fdmex->GetAtmosphere()->GetPressure();
+ double psl=fdmex->GetAtmosphere()->GetPressureSL();
+ double rhosl=fdmex->GetAtmosphere()->GetDensitySL();
+ double pt,A,B,D,vcas;
if(Mach < 0) Mach=0;
if(Mach < 1) //calculate total pressure assuming isentropic flow
pt=p*pow((1 + 0.2*Mach*Mach),3.5);
//******************************************************************************
-bool FGInitialCondition::findInterval(float x,float guess) {
- //void find_interval(inter_params &ip,eqfunc f,float y,float constant, int &flag){
+bool FGInitialCondition::findInterval(double x,double guess) {
+ //void find_interval(inter_params &ip,eqfunc f,double y,double constant, int &flag){
int i=0;
bool found=false;
- float flo,fhi,fguess;
- float lo,hi,step;
+ double flo,fhi,fguess;
+ double lo,hi,step;
step=0.1;
fguess=(this->*sfunc)(guess)-x;
lo=hi=guess;
//******************************************************************************
-bool FGInitialCondition::solve(float *y,float x)
+bool FGInitialCondition::solve(double *y,double x)
{
- float x1,x2,x3,f1,f2,f3,d,d0;
- float eps=1E-5;
- float const relax =0.9;
+ double x1,x2,x3,f1,f2,f3,d,d0;
+ double eps=1E-5;
+ double const relax =0.9;
int i;
bool success=false;
//******************************************************************************
-float FGInitialCondition::GetWindDirDegIC(void) {
+double FGInitialCondition::GetWindDirDegIC(void) {
if(weast != 0.0)
return atan2(weast,wnorth)*radtodeg;
else if(wnorth > 0)
//******************************************************************************
-bool FGInitialCondition::Load(string path, string acname, string fname)
+bool FGInitialCondition::Load(string acpath, string acname, string rstfile)
{
string resetDef;
string token="";
- float temp;
+ double temp;
# ifndef macintosh
- resetDef = path + "/" + acname + "/" + fname + ".xml";
+ resetDef = acpath + "/" + acname + "/" + rstfile + ".xml";
# else
- resetDef = path + ";" + acname + ";" + fname + ".xml";
+ resetDef = acpath + ";" + acname + ";" + rstfile + ".xml";
# endif
- cout << resetDef << endl;
FGConfigFile resetfile(resetDef);
if (!resetfile.IsOpen()) return false;
resetfile.GetNextConfigLine();
token = resetfile.GetValue();
- if (token != "initialize") {
+ if (token != string("initialize")) {
cerr << "The reset file " << resetDef
<< " does not appear to be a reset file" << endl;
return false;
resetfile.GetNextConfigLine();
resetfile >> token;
- while (token != "/initialize" && token != "EOF") {
+ while (token != string("/initialize") && token != string("EOF")) {
if (token == "UBODY" ) { resetfile >> temp; SetUBodyFpsIC(temp); }
if (token == "VBODY" ) { resetfile >> temp; SetVBodyFpsIC(temp); }
if (token == "WBODY" ) { resetfile >> temp; SetWBodyFpsIC(temp); }
/// Destructor
~FGInitialCondition();
- void SetVcalibratedKtsIC(float tt);
- void SetVequivalentKtsIC(float tt);
- inline void SetVtrueKtsIC(float tt) { SetVtrueFpsIC(tt*ktstofps); }
- inline void SetVgroundKtsIC(float tt) { SetVgroundFpsIC(tt*ktstofps); }
- void SetMachIC(float tt);
+ void SetVcalibratedKtsIC(double tt);
+ void SetVequivalentKtsIC(double tt);
+ inline void SetVtrueKtsIC(double tt) { SetVtrueFpsIC(tt*ktstofps); }
+ inline void SetVgroundKtsIC(double tt) { SetVgroundFpsIC(tt*ktstofps); }
+ void SetMachIC(double tt);
- inline void SetAlphaDegIC(float tt) { SetAlphaRadIC(tt*degtorad); }
- inline void SetBetaDegIC(float tt) { SetBetaRadIC(tt*degtorad);}
+ inline void SetAlphaDegIC(double tt) { SetAlphaRadIC(tt*degtorad); }
+ inline void SetBetaDegIC(double tt) { SetBetaRadIC(tt*degtorad);}
- inline void SetPitchAngleDegIC(float tt) { SetPitchAngleRadIC(tt*degtorad); }
- inline void SetRollAngleDegIC(float tt) { SetRollAngleRadIC(tt*degtorad);}
- inline void SetTrueHeadingDegIC(float tt){ SetTrueHeadingRadIC(tt*degtorad); }
+ inline void SetPitchAngleDegIC(double tt) { SetPitchAngleRadIC(tt*degtorad); }
+ inline void SetRollAngleDegIC(double tt) { SetRollAngleRadIC(tt*degtorad);}
+ inline void SetTrueHeadingDegIC(double tt){ SetTrueHeadingRadIC(tt*degtorad); }
- void SetClimbRateFpmIC(float tt);
- inline void SetFlightPathAngleDegIC(float tt) { SetFlightPathAngleRadIC(tt*degtorad); }
+ void SetClimbRateFpmIC(double tt);
+ inline void SetFlightPathAngleDegIC(double tt) { SetFlightPathAngleRadIC(tt*degtorad); }
- void SetAltitudeFtIC(float tt);
- void SetAltitudeAGLFtIC(float tt);
+ void SetAltitudeFtIC(double tt);
+ void SetAltitudeAGLFtIC(double tt);
void SetSeaLevelRadiusFtIC(double tt);
void SetTerrainAltitudeFtIC(double tt);
- inline void SetLatitudeDegIC(float tt) { latitude=tt*degtorad; }
- inline void SetLongitudeDegIC(float tt) { longitude=tt*degtorad; }
+ inline void SetLatitudeDegIC(double tt) { latitude=tt*degtorad; }
+ inline void SetLongitudeDegIC(double tt) { longitude=tt*degtorad; }
- inline float GetVcalibratedKtsIC(void) { return vc*fpstokts; }
- inline float GetVequivalentKtsIC(void) { return ve*fpstokts; }
- inline float GetVgroundKtsIC(void) { return vg*fpstokts; }
- inline float GetVtrueKtsIC(void) { return vt*fpstokts; }
- inline float GetMachIC(void) { return mach; }
+ inline double GetVcalibratedKtsIC(void) { return vc*fpstokts; }
+ inline double GetVequivalentKtsIC(void) { return ve*fpstokts; }
+ inline double GetVgroundKtsIC(void) { return vg*fpstokts; }
+ inline double GetVtrueKtsIC(void) { return vt*fpstokts; }
+ inline double GetMachIC(void) { return mach; }
- inline float GetClimbRateFpmIC(void) { return hdot*60; }
- inline float GetFlightPathAngleDegIC(void) { return gamma*radtodeg; }
+ inline double GetClimbRateFpmIC(void) { return hdot*60; }
+ inline double GetFlightPathAngleDegIC(void) { return gamma*radtodeg; }
- inline float GetAlphaDegIC(void) { return alpha*radtodeg; }
- inline float GetBetaDegIC(void) { return beta*radtodeg; }
+ inline double GetAlphaDegIC(void) { return alpha*radtodeg; }
+ inline double GetBetaDegIC(void) { return beta*radtodeg; }
- inline float GetPitchAngleDegIC(void) { return theta*radtodeg; }
- inline float GetRollAngleDegIC(void) { return phi*radtodeg; }
- inline float GetHeadingDegIC(void) { return psi*radtodeg; }
+ inline double GetPitchAngleDegIC(void) { return theta*radtodeg; }
+ inline double GetRollAngleDegIC(void) { return phi*radtodeg; }
+ inline double GetHeadingDegIC(void) { return psi*radtodeg; }
- inline float GetLatitudeDegIC(void) { return latitude*radtodeg; }
- inline float GetLongitudeDegIC(void) { return longitude*radtodeg; }
+ inline double GetLatitudeDegIC(void) { return latitude*radtodeg; }
+ inline double GetLongitudeDegIC(void) { return longitude*radtodeg; }
- inline float GetAltitudeFtIC(void) { return altitude; }
- inline float GetAltitudeAGLFtIC(void) { return altitude - terrain_altitude; }
+ inline double GetAltitudeFtIC(void) { return altitude; }
+ inline double GetAltitudeAGLFtIC(void) { return altitude - terrain_altitude; }
- inline float GetSeaLevelRadiusFtIC(void) { return sea_level_radius; }
- inline float GetTerrainAltitudeFtIC(void) { return terrain_altitude; }
-
- void SetVgroundFpsIC(float tt);
- void SetVtrueFpsIC(float tt);
- void SetUBodyFpsIC(float tt);
- void SetVBodyFpsIC(float tt);
- void SetWBodyFpsIC(float tt);
- void SetVnorthFpsIC(float tt);
- void SetVeastFpsIC(float tt);
- void SetVdownFpsIC(float tt);
+ inline double GetSeaLevelRadiusFtIC(void) { return sea_level_radius; }
+ inline double GetTerrainAltitudeFtIC(void) { return terrain_altitude; }
+
+ void SetVgroundFpsIC(double tt);
+ void SetVtrueFpsIC(double tt);
+ void SetUBodyFpsIC(double tt);
+ void SetVBodyFpsIC(double tt);
+ void SetWBodyFpsIC(double tt);
+ void SetVnorthFpsIC(double tt);
+ void SetVeastFpsIC(double tt);
+ void SetVdownFpsIC(double tt);
- void SetWindNEDFpsIC(float wN, float wE, float wD);
+ void SetWindNEDFpsIC(double wN, double wE, double wD);
- void SetWindMagKtsIC(float mag);
- void SetWindDirDegIC(float dir);
+ void SetWindMagKtsIC(double mag);
+ void SetWindDirDegIC(double dir);
- void SetHeadWindKtsIC(float head);
- void SetCrossWindKtsIC(float cross);// positive from left
+ void SetHeadWindKtsIC(double head);
+ void SetCrossWindKtsIC(double cross);// positive from left
- void SetWindDownKtsIC(float wD);
+ void SetWindDownKtsIC(double wD);
- void SetClimbRateFpsIC(float tt);
- inline float GetVgroundFpsIC(void) { return vg; }
- inline float GetVtrueFpsIC(void) { return vt; }
- inline float GetWindUFpsIC(void) { return uw; }
- inline float GetWindVFpsIC(void) { return vw; }
- inline float GetWindWFpsIC(void) { return ww; }
- inline float GetWindNFpsIC(void) { return wnorth; }
- inline float GetWindEFpsIC(void) { return weast; }
- inline float GetWindDFpsIC(void) { return wdown; }
- inline float GetWindFpsIC(void) { return sqrt(wnorth*wnorth + weast*weast); }
- float GetWindDirDegIC(void);
- inline float GetClimbRateFpsIC(void) { return hdot; }
- float GetUBodyFpsIC(void);
- float GetVBodyFpsIC(void);
- float GetWBodyFpsIC(void);
- void SetFlightPathAngleRadIC(float tt);
- void SetAlphaRadIC(float tt);
- void SetPitchAngleRadIC(float tt);
- void SetBetaRadIC(float tt);
- void SetRollAngleRadIC(float tt);
- void SetTrueHeadingRadIC(float tt);
- inline void SetLatitudeRadIC(float tt) { latitude=tt; }
- inline void SetLongitudeRadIC(float tt) { longitude=tt; }
- inline float GetFlightPathAngleRadIC(void) { return gamma; }
- inline float GetAlphaRadIC(void) { return alpha; }
- inline float GetPitchAngleRadIC(void) { return theta; }
- inline float GetBetaRadIC(void) { return beta; }
- inline float GetRollAngleRadIC(void) { return phi; }
- inline float GetHeadingRadIC(void) { return psi; }
- inline float GetLatitudeRadIC(void) { return latitude; }
- inline float GetLongitudeRadIC(void) { return longitude; }
- inline float GetThetaRadIC(void) { return theta; }
- inline float GetPhiRadIC(void) { return phi; }
- inline float GetPsiRadIC(void) { return psi; }
+ void SetClimbRateFpsIC(double tt);
+ inline double GetVgroundFpsIC(void) { return vg; }
+ inline double GetVtrueFpsIC(void) { return vt; }
+ inline double GetWindUFpsIC(void) { return uw; }
+ inline double GetWindVFpsIC(void) { return vw; }
+ inline double GetWindWFpsIC(void) { return ww; }
+ inline double GetWindNFpsIC(void) { return wnorth; }
+ inline double GetWindEFpsIC(void) { return weast; }
+ inline double GetWindDFpsIC(void) { return wdown; }
+ inline double GetWindFpsIC(void) { return sqrt(wnorth*wnorth + weast*weast); }
+ double GetWindDirDegIC(void);
+ inline double GetClimbRateFpsIC(void) { return hdot; }
+ double GetUBodyFpsIC(void);
+ double GetVBodyFpsIC(void);
+ double GetWBodyFpsIC(void);
+ void SetFlightPathAngleRadIC(double tt);
+ void SetAlphaRadIC(double tt);
+ void SetPitchAngleRadIC(double tt);
+ void SetBetaRadIC(double tt);
+ void SetRollAngleRadIC(double tt);
+ void SetTrueHeadingRadIC(double tt);
+ inline void SetLatitudeRadIC(double tt) { latitude=tt; }
+ inline void SetLongitudeRadIC(double tt) { longitude=tt; }
+ inline double GetFlightPathAngleRadIC(void) { return gamma; }
+ inline double GetAlphaRadIC(void) { return alpha; }
+ inline double GetPitchAngleRadIC(void) { return theta; }
+ inline double GetBetaRadIC(void) { return beta; }
+ inline double GetRollAngleRadIC(void) { return phi; }
+ inline double GetHeadingRadIC(void) { return psi; }
+ inline double GetLatitudeRadIC(void) { return latitude; }
+ inline double GetLongitudeRadIC(void) { return longitude; }
+ inline double GetThetaRadIC(void) { return theta; }
+ inline double GetPhiRadIC(void) { return phi; }
+ inline double GetPsiRadIC(void) { return psi; }
inline speedset GetSpeedSet(void) { return lastSpeedSet; }
inline windset GetWindSet(void) { return lastWindSet; }
- bool Load(string path, string acname, string fname);
+ bool Load(string acpath, string acname, string rstname);
private:
- float vt,vc,ve,vg;
- float mach;
- float altitude,hdot;
- float latitude,longitude;
- float u,v,w;
- float uw,vw,ww;
- float vnorth,veast,vdown;
- float wnorth,weast,wdown;
- float whead, wcross, wdir, wmag;
+ double vt,vc,ve,vg;
+ double mach;
+ double altitude,hdot;
+ double latitude,longitude;
+ double u,v,w;
+ double uw,vw,ww;
+ double vnorth,veast,vdown;
+ double wnorth,weast,wdown;
+ double whead, wcross, wdir, wmag;
double sea_level_radius;
double terrain_altitude;
double radius_to_vehicle;
- float alpha, beta, theta, phi, psi, gamma;
- float salpha,sbeta,stheta,sphi,spsi,sgamma;
- float calpha,cbeta,ctheta,cphi,cpsi,cgamma;
+ double alpha, beta, theta, phi, psi, gamma;
+ double salpha,sbeta,stheta,sphi,spsi,sgamma;
+ double calpha,cbeta,ctheta,cphi,cpsi,cgamma;
- float xlo, xhi,xmin,xmax;
+ double xlo, xhi,xmin,xmax;
- typedef float (FGInitialCondition::*fp)(float x);
+ typedef double (FGInitialCondition::*fp)(double x);
fp sfunc;
speedset lastSpeedSet;
bool getAlpha(void);
bool getTheta(void);
- bool getMachFromVcas(float *Mach,float vcas);
+ bool getMachFromVcas(double *Mach,double vcas);
- float GammaEqOfTheta(float Theta);
- float GammaEqOfAlpha(float Alpha);
- float calcVcas(float Mach);
+ double GammaEqOfTheta(double Theta);
+ double GammaEqOfAlpha(double Alpha);
+ double calcVcas(double Mach);
void calcUVWfromNED(void);
void calcWindUVW(void);
- bool findInterval(float x,float guess);
- bool solve(float *y, float x);
+ bool findInterval(double x,double guess);
+ bool solve(double *y, double x);
};
#endif
# include <math.h>
# include <queue>
# include STL_STRING
- SG_USING_STD(queue);
+
+SG_USING_STD(string);
+SG_USING_STD(queue);
+
#else
+
+# include <queue>
+# include <string>
# if defined(sgi) && !defined(__GNUC__)
# include <math.h>
-# include <queue.h>
-# include <string.h>
# else
# include <cmath>
-# include <queue>
-# include <string>
# endif
+
+using std::string;
+using std::queue;
#endif
#ifndef M_PI
FCS = Exec->GetFCS();
MassBalance = Exec->GetMassBalance();
- WOW = false;
+ WOW = lastWOW = false;
ReportEnable = true;
FirstContact = false;
Reported = false;
vLocalGear = lgear.vLocalGear;
WOW = lgear.WOW;
+ lastWOW = lgear.lastWOW;
ReportEnable = lgear.ReportEnable;
FirstContact = lgear.FirstContact;
DistanceTraveled = lgear.DistanceTraveled;
FGColumnVector3& FGLGear::Force(void)
{
- float SteerGain;
- float SinWheel, CosWheel, SideWhlVel, RollingWhlVel;
- float RudderPedal, RollingForce, SideForce, FCoeff;
- float WheelSlip;
+ double SteerGain;
+ double SinWheel, CosWheel, SideWhlVel, RollingWhlVel;
+ double RudderPedal, RollingForce, SideForce, FCoeff;
+ double WheelSlip;
vWhlBodyVec = (vXYZ - MassBalance->GetXYZcg()) / 12.0;
vWhlBodyVec(eX) = -vWhlBodyVec(eX);
// case. NOTE: SQUARE LAW DAMPING NO GOOD!
vLocalForce(eZ) = min(-compressLength * kSpring
- - compressSpeed * bDamp, (float)0.0);
+ - compressSpeed * bDamp, (double)0.0);
MaximumStrutForce = max(MaximumStrutForce, fabs(vLocalForce(eZ)));
MaximumStrutTravel = max(MaximumStrutTravel, fabs(compressLength));
if (debug_lvl > 0) Report();
}
+ if (lastWOW != WOW) {
+ PutMessage("GEAR_CONTACT", WOW);
+ }
+
+ lastWOW = WOW;
+
+ // Crash detection logic (really out-of-bounds detection)
+
+ if (compressLength > 500.0 ||
+ vForce.Magnitude() > 100000000.0 ||
+ vMoment.Magnitude() > 5000000000.0 ||
+ SinkRate > 1.4666*30)
+ {
+ PutMessage("Crash Detected");
+ Exec->Freeze();
+ }
+
return vForce;
}
/// Gets the location of the gear in Body axes
FGColumnVector3& GetBodyLocation(void) { return vWhlBodyVec; }
- float GetBodyLocation(int idx) { return vWhlBodyVec(idx); }
+ double GetBodyLocation(int idx) { return vWhlBodyVec(idx); }
FGColumnVector3& GetLocalGear(void) { return vLocalGear; }
- float GetLocalGear(int idx) { return vLocalGear(idx); }
+ double GetLocalGear(int idx) { return vLocalGear(idx); }
/// Gets the name of the gear
inline string GetName(void) {return name; }
/// Gets the Weight On Wheels flag value
inline bool GetWOW(void) {return WOW; }
/// Gets the current compressed length of the gear in feet
- inline float GetCompLen(void) {return compressLength;}
+ inline double GetCompLen(void) {return compressLength;}
/// Gets the current gear compression velocity in ft/sec
- inline float GetCompVel(void) {return compressSpeed; }
+ inline double GetCompVel(void) {return compressSpeed; }
/// Gets the gear compression force in pounds
- inline float GetCompForce(void) {return Force()(3); }
- inline float GetBrakeFCoeff(void) {return BrakeFCoeff;}
+ inline double GetCompForce(void) {return Force()(3); }
+ inline double GetBrakeFCoeff(void) {return BrakeFCoeff;}
/// Sets the brake value in percent (0 - 100)
inline void SetBrake(double bp) {brakePct = bp;}
/** Get the console touchdown reporting feature
@return true if reporting is turned on */
inline bool GetReport(void) { return ReportEnable; }
- inline float GetSteerAngle(void) { return SteerAngle;}
- inline float GetstaticFCoeff(void) { return staticFCoeff;}
+ inline double GetSteerAngle(void) { return SteerAngle;}
+ inline double GetstaticFCoeff(void) { return staticFCoeff;}
inline int GetBrakeGroup(void) { return (int)eBrakeGrp; }
inline int GetSteerType(void) { return (int)eSteerType; }
FGColumnVector3 vForce;
FGColumnVector3 vLocalForce;
FGColumnVector3 vWhlVelVec; // Velocity of this wheel (Local)
- float SteerAngle;
- float kSpring;
- float bDamp;
- float compressLength;
- float compressSpeed;
- float staticFCoeff, dynamicFCoeff, rollingFCoeff;
- float brakePct;
- float BrakeFCoeff;
- float maxCompLen;
+ double SteerAngle;
+ double kSpring;
+ double bDamp;
+ double compressLength;
+ double compressSpeed;
+ double staticFCoeff, dynamicFCoeff, rollingFCoeff;
+ double brakePct;
+ double BrakeFCoeff;
+ double maxCompLen;
double SinkRate;
double GroundSpeed;
double DistanceTraveled;
double MaximumStrutForce;
double MaximumStrutTravel;
bool WOW;
+ bool lastWOW;
bool FirstContact;
bool Reported;
bool ReportEnable;
string sBrakeGroup;
BrakeGroup eBrakeGrp;
SteerType eSteerType;
- float maxSteerAngle;
+ double maxSteerAngle;
FGFDMExec* Exec;
FGState* State;
bool Run(void);
- inline float GetMass(void) {return Mass;}
- inline float GetWeight(void) {return Weight;}
- inline float GetIxx(void) {return Ixx;}
- inline float GetIyy(void) {return Iyy;}
- inline float GetIzz(void) {return Izz;}
- inline float GetIxz(void) {return Ixz;}
- inline float GetIyz(void) {return Iyz;}
+ inline double GetMass(void) {return Mass;}
+ inline double GetWeight(void) {return Weight;}
+ inline double GetIxx(void) {return Ixx;}
+ inline double GetIyy(void) {return Iyy;}
+ inline double GetIzz(void) {return Izz;}
+ inline double GetIxz(void) {return Ixz;}
+ inline double GetIyz(void) {return Iyz;}
inline FGColumnVector3& GetXYZcg(void) {return vXYZcg;}
- inline float GetXYZcg(int axis) {return vXYZcg(axis);}
-
- inline void SetEmptyWeight(float EW) { EmptyWeight = EW;}
- inline void SetBaseIxx(float bixx) { baseIxx = bixx;}
- inline void SetBaseIyy(float biyy) { baseIyy = biyy;}
- inline void SetBaseIzz(float bizz) { baseIzz = bizz;}
- inline void SetBaseIxz(float bixz) { baseIxz = bixz;}
- inline void SetBaseIyz(float biyz) { baseIyz = biyz;}
+ inline double GetXYZcg(int axis) {return vXYZcg(axis);}
+
+ inline void SetEmptyWeight(double EW) { EmptyWeight = EW;}
+ inline void SetBaseIxx(double bixx) { baseIxx = bixx;}
+ inline void SetBaseIyy(double biyy) { baseIyy = biyy;}
+ inline void SetBaseIzz(double bizz) { baseIzz = bizz;}
+ inline void SetBaseIxz(double bixz) { baseIxz = bixz;}
+ inline void SetBaseIyz(double biyz) { baseIyz = biyz;}
inline void SetBaseCG(const FGColumnVector3& CG) {vbaseXYZcg = CG;}
private:
- float Weight;
- float EmptyWeight;
- float Mass;
- float Ixx;
- float Iyy;
- float Izz;
- float Ixz;
- float Iyz;
- float baseIxx;
- float baseIyy;
- float baseIzz;
- float baseIxz;
- float baseIyz;
+ double Weight;
+ double EmptyWeight;
+ double Mass;
+ double Ixx;
+ double Iyy;
+ double Izz;
+ double Ixz;
+ double Iyz;
+ double baseIxx;
+ double baseIyy;
+ double baseIzz;
+ double baseIxz;
+ double baseIyz;
FGColumnVector3 vXYZcg;
FGColumnVector3 vXYZtank;
FGColumnVector3 vbaseXYZcg;
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-FGMatrix33& FGMatrix33::operator<<(const float ff)
+FGMatrix33& FGMatrix33::operator<<(const double ff)
{
data[rowCtr][colCtr] = ff;
if (++colCtr > Cols()) {
void FGMatrix33::operator*=(const FGMatrix33& M)
{
- float a,b,c;
+ double a,b,c;
a = data[1][1]; b=data[1][2]; c=data[1][3];
data[1][1] = a*M(1,1) + b*M(2,1) + c*M(3,1);
FGMatrix33 operator*(const FGMatrix33& B);
FGMatrix33 operator*(const double scalar);
FGMatrix33 operator/(const double scalar);
- FGMatrix33& operator<<(const float ff);
+ FGMatrix33& operator<<(const double ff);
friend ostream& operator<<(ostream& os, const FGMatrix33& M);
friend istream& operator>>(istream& is, FGMatrix33& M);
Name = Nzl_cfg->GetValue("NAME");
Nzl_cfg->GetNextConfigLine();
- while (Nzl_cfg->GetValue() != "/FG_NOZZLE") {
+ while (Nzl_cfg->GetValue() != string("/FG_NOZZLE")) {
*Nzl_cfg >> token;
if (token == "PE") *Nzl_cfg >> PE;
else if (token == "EXPR") *Nzl_cfg >> ExpR;
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-float FGNozzle::Calculate(float CfPc)
+double FGNozzle::Calculate(double CfPc)
{
- float pAtm = fdmex->GetAtmosphere()->GetPressure();
- Thrust = max((float)0.0, (CfPc * AreaT + (PE - pAtm)*Area2) * nzlEff);
+ double pAtm = fdmex->GetAtmosphere()->GetPressure();
+ Thrust = max((double)0.0, (CfPc * AreaT + (PE - pAtm)*Area2) * nzlEff);
vFn(1) = Thrust;
return Thrust;
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-float FGNozzle::GetPowerRequired(void)
+double FGNozzle::GetPowerRequired(void)
{
return PE;
}
/// Destructor
~FGNozzle();
- float Calculate(float CfPc);
- float GetPowerRequired(void);
+ double Calculate(double CfPc);
+ double GetPowerRequired(void);
private:
- float PE;
- float ExpR;
- float nzlEff;
- float Diameter;
- float AreaT;
- float Area2;
+ double PE;
+ double ExpR;
+ double nzlEff;
+ double Diameter;
+ double AreaT;
+ double Area2;
void Debug(void);
};
Type = otSocket;
} else if (type == "TERMINAL") {
Type = otTerminal;
- } else if (type != "NONE"){
+ } else if (type != string("NONE")){
Type = otUnknown;
cerr << "Unknown type of output specified in config file" << endl;
}
void FGOutput::DelimitedOutput(string fname)
{
-# if defined(sgi) && !defined(__GNUC__)
- ostream_withassign outstream;
-# else
- _IO_ostream_withassign outstream;
-# endif
+ streambuf* buffer;
if (fname == "COUT" || fname == "cout") {
- outstream = cout;
+ buffer = cout.rdbuf();
} else {
datafile.open(fname.c_str());
- outstream = datafile;
+ buffer = datafile.rdbuf();
}
+ ostream outstream(buffer);
+
if (dFirstPass) {
outstream << "Time";
- if (SubSystems & FGAircraft::ssSimulation) {
+ if (SubSystems & ssSimulation) {
// Nothing here, yet
}
- if (SubSystems & FGAircraft::ssAerosurfaces) {
+ if (SubSystems & ssAerosurfaces) {
outstream << ", ";
outstream << "Throttle, ";
outstream << "Mixture, ";
outstream << "Elevator Pos, ";
outstream << "Rudder Pos";
}
- if (SubSystems & FGAircraft::ssRates) {
+ if (SubSystems & ssRates) {
outstream << ", ";
outstream << "P, Q, R";
}
- if (SubSystems & FGAircraft::ssVelocities) {
+ if (SubSystems & ssVelocities) {
outstream << ", ";
outstream << "QBar, ";
outstream << "Vtotal, ";
outstream << "UAero, VAero, WAero, ";
outstream << "Vn, Ve, Vd";
}
- if (SubSystems & FGAircraft::ssForces) {
+ if (SubSystems & ssForces) {
outstream << ", ";
outstream << "Drag, Side, Lift, ";
outstream << "L/D, ";
outstream << "Xforce, Yforce, Zforce";
}
- if (SubSystems & FGAircraft::ssMoments) {
+ if (SubSystems & ssMoments) {
outstream << ", ";
outstream << "L, M, N";
}
- if (SubSystems & FGAircraft::ssAtmosphere) {
+ if (SubSystems & ssAtmosphere) {
outstream << ", ";
outstream << "Rho";
}
- if (SubSystems & FGAircraft::ssMassProps) {
+ if (SubSystems & ssMassProps) {
outstream << ", ";
outstream << "Ixx, ";
outstream << "Iyy, ";
outstream << "Mass, ";
outstream << "Xcg, Ycg, Zcg";
}
- if (SubSystems & FGAircraft::ssPosition) {
+ if (SubSystems & ssPosition) {
outstream << ", ";
outstream << "Altitude, ";
outstream << "Phi, Tht, Psi, ";
outstream << "Distance AGL, ";
outstream << "Runway Radius";
}
- if (SubSystems & FGAircraft::ssCoefficients) {
+ if (SubSystems & ssCoefficients) {
outstream << ", ";
outstream << Aerodynamics->GetCoefficientStrings();
}
- if (SubSystems & FGAircraft::ssGroundReactions) {
+ if (SubSystems & ssGroundReactions) {
outstream << ", ";
outstream << GroundReactions->GetGroundReactionStrings();
}
- if (SubSystems & FGAircraft::ssPropulsion) {
+ if (SubSystems & ssPropulsion) {
outstream << ", ";
outstream << Propulsion->GetPropulsionStrings();
}
}
outstream << State->Getsim_time();
- if (SubSystems & FGAircraft::ssSimulation) {
+ if (SubSystems & ssSimulation) {
}
- if (SubSystems & FGAircraft::ssAerosurfaces) {
+ if (SubSystems & ssAerosurfaces) {
outstream << ", ";
outstream << FCS->GetThrottlePos(0) << ", ";
outstream << FCS->GetMixturePos(0) << ", ";
outstream << FCS->GetDePos() << ", ";
outstream << FCS->GetDrPos();
}
- if (SubSystems & FGAircraft::ssRates) {
+ if (SubSystems & ssRates) {
outstream << ", ";
outstream << Rotation->GetPQR();
}
- if (SubSystems & FGAircraft::ssVelocities) {
+ if (SubSystems & ssVelocities) {
outstream << ", ";
outstream << Translation->Getqbar() << ", ";
outstream << Translation->GetVt() << ", ";
outstream << Translation->GetvAero() << ", ";
outstream << Position->GetVel();
}
- if (SubSystems & FGAircraft::ssForces) {
+ if (SubSystems & ssForces) {
outstream << ", ";
outstream << Aerodynamics->GetvFs() << ", ";
outstream << Aerodynamics->GetLoD() << ", ";
outstream << Aircraft->GetForces();
}
- if (SubSystems & FGAircraft::ssMoments) {
+ if (SubSystems & ssMoments) {
outstream << ", ";
outstream << Aircraft->GetMoments();
}
- if (SubSystems & FGAircraft::ssAtmosphere) {
+ if (SubSystems & ssAtmosphere) {
outstream << ", ";
outstream << Atmosphere->GetDensity();
}
- if (SubSystems & FGAircraft::ssMassProps) {
+ if (SubSystems & ssMassProps) {
outstream << ", ";
outstream << MassBalance->GetIxx() << ", ";
outstream << MassBalance->GetIyy() << ", ";
outstream << MassBalance->GetMass() << ", ";
outstream << MassBalance->GetXYZcg();
}
- if (SubSystems & FGAircraft::ssPosition) {
+ if (SubSystems & ssPosition) {
outstream << ", ";
outstream << Position->Geth() << ", ";
outstream << Rotation->GetEuler() << ", ";
outstream << Position->GetDistanceAGL() << ", ";
outstream << Position->GetRunwayRadius();
}
- if (SubSystems & FGAircraft::ssCoefficients) {
+ if (SubSystems & ssCoefficients) {
outstream << ", ";
outstream << Aerodynamics->GetCoefficientValues();
}
- if (SubSystems & FGAircraft::ssGroundReactions) {
+ if (SubSystems & ssGroundReactions) {
outstream << ", ";
outstream << GroundReactions->GetGroundReactionValues();
}
- if (SubSystems & FGAircraft::ssPropulsion) {
+ if (SubSystems & ssPropulsion) {
outstream << ", ";
outstream << Propulsion->GetPropulsionValues();
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+bool FGOutput::Load(FGConfigFile* AC_cfg)
+{
+ string token, parameter;
+ int OutRate = 0;
+
+ token = AC_cfg->GetValue("NAME");
+ Output->SetFilename(token);
+ token = AC_cfg->GetValue("TYPE");
+ Output->SetType(token);
+ AC_cfg->GetNextConfigLine();
+
+ while ((token = AC_cfg->GetValue()) != string("/OUTPUT")) {
+ *AC_cfg >> parameter;
+ if (parameter == "RATE_IN_HZ") *AC_cfg >> OutRate;
+ if (parameter == "SIMULATION") {
+ *AC_cfg >> parameter;
+ if (parameter == "ON") SubSystems += ssSimulation;
+ }
+ if (parameter == "AEROSURFACES") {
+ *AC_cfg >> parameter;
+ if (parameter == "ON") SubSystems += ssAerosurfaces;
+ }
+ if (parameter == "RATES") {
+ *AC_cfg >> parameter;
+ if (parameter == "ON") SubSystems += ssRates;
+ }
+ if (parameter == "VELOCITIES") {
+ *AC_cfg >> parameter;
+ if (parameter == "ON") SubSystems += ssVelocities;
+ }
+ if (parameter == "FORCES") {
+ *AC_cfg >> parameter;
+ if (parameter == "ON") SubSystems += ssForces;
+ }
+ if (parameter == "MOMENTS") {
+ *AC_cfg >> parameter;
+ if (parameter == "ON") SubSystems += ssMoments;
+ }
+ if (parameter == "ATMOSPHERE") {
+ *AC_cfg >> parameter;
+ if (parameter == "ON") SubSystems += ssAtmosphere;
+ }
+ if (parameter == "MASSPROPS") {
+ *AC_cfg >> parameter;
+ if (parameter == "ON") SubSystems += ssMassProps;
+ }
+ if (parameter == "POSITION") {
+ *AC_cfg >> parameter;
+ if (parameter == "ON") SubSystems += ssPosition;
+ }
+ if (parameter == "COEFFICIENTS") {
+ *AC_cfg >> parameter;
+ if (parameter == "ON") SubSystems += ssCoefficients;
+ }
+ if (parameter == "GROUND_REACTIONS") {
+ *AC_cfg >> parameter;
+ if (parameter == "ON") SubSystems += ssGroundReactions;
+ }
+ if (parameter == "FCS") {
+ *AC_cfg >> parameter;
+ if (parameter == "ON") SubSystems += ssFCS;
+ }
+ if (parameter == "PROPULSION") {
+ *AC_cfg >> parameter;
+ if (parameter == "ON") SubSystems += ssPropulsion;
+ }
+ }
+
+ OutRate = OutRate>120?120:(OutRate<0?0:OutRate);
+ rate = (int)(0.5 + 1.0/(State->Getdt()*OutRate));
+
+ return true;
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
void FGOutput::Debug(void)
{
//TODO: Add your source code here
inline void Enable(void) { enabled = true; }
inline void Disable(void) { enabled = false; }
inline bool Toggle(void) {enabled = !enabled; return enabled;}
+ bool Load(FGConfigFile* AC_cfg);
+
+ /// Subsystem types for specifying which will be output in the FDM data logging
+ enum SubSystems {
+ /** Subsystem: Simulation (= 1) */ ssSimulation = 1,
+ /** Subsystem: Aerosurfaces (= 2) */ ssAerosurfaces = 2,
+ /** Subsystem: Body rates (= 4) */ ssRates = 4,
+ /** Subsystem: Velocities (= 8) */ ssVelocities = 8,
+ /** Subsystem: Forces (= 16) */ ssForces = 16,
+ /** Subsystem: Moments (= 32) */ ssMoments = 32,
+ /** Subsystem: Atmosphere (= 64) */ ssAtmosphere = 64,
+ /** Subsystem: Mass Properties (= 128) */ ssMassProps = 128,
+ /** Subsystem: Coefficients (= 256) */ ssCoefficients = 256,
+ /** Subsystem: Position (= 512) */ ssPosition = 512,
+ /** Subsystem: Ground Reactions (= 1024) */ ssGroundReactions = 1024,
+ /** Subsystem: FCS (= 2048) */ ssFCS = 2048,
+ /** Subsystem: Propulsion (= 4096) */ ssPropulsion = 4096
+ } subsystems;
private:
bool sFirstPass, dFirstPass, enabled;
Name = Eng_cfg->GetValue("NAME");
Eng_cfg->GetNextConfigLine();
- while (Eng_cfg->GetValue() != "/FG_PISTON") {
+ while (Eng_cfg->GetValue() != string("/FG_PISTON")) {
*Eng_cfg >> token;
if (token == "MINMP") *Eng_cfg >> MinManifoldPressure_inHg;
else if (token == "MAXMP") *Eng_cfg >> MaxManifoldPressure_inHg;
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-float FGPiston::Calculate(float PowerRequired)
+double FGPiston::Calculate(double PowerRequired)
{
- float h,EngineMaxPower;
+ double h,EngineMaxPower;
// FIXME: calculate from actual fuel flow
ConsumeFuel();
void FGPiston::doAirFlow(void)
{
rho_air = p_amb / (R_air * T_amb);
- float rho_air_manifold = rho_air * ManifoldPressure_inHg / 29.6;
- float displacement_SI = Displacement * CONVERT_CUBIC_INCHES_TO_METERS_CUBED;
- float swept_volume = (displacement_SI * (RPM/60)) / 2;
- float v_dot_air = swept_volume * volumetric_efficiency;
+ double rho_air_manifold = rho_air * ManifoldPressure_inHg / 29.6;
+ double displacement_SI = Displacement * CONVERT_CUBIC_INCHES_TO_METERS_CUBED;
+ double swept_volume = (displacement_SI * (RPM/60)) / 2;
+ double v_dot_air = swept_volume * volumetric_efficiency;
m_dot_air = v_dot_air * rho_air_manifold;
}
void FGPiston::doFuelFlow(void)
{
- float thi_sea_level = 1.3 * Mixture;
+ double thi_sea_level = 1.3 * Mixture;
equivalence_ratio = thi_sea_level * p_amb_sea_level / p_amb;
m_dot_fuel = m_dot_air / 14.7 * equivalence_ratio;
}
void FGPiston::doEnginePower(void)
{
- float True_ManifoldPressure_inHg = ManifoldPressure_inHg * p_amb / p_amb_sea_level;
- float ManXRPM = True_ManifoldPressure_inHg * RPM;
+ double True_ManifoldPressure_inHg = ManifoldPressure_inHg * p_amb / p_amb_sea_level;
+ double ManXRPM = True_ManifoldPressure_inHg * RPM;
// FIXME: this needs to be generalized
Percentage_Power = (6e-9 * ManXRPM * ManXRPM) + (8e-4 * ManXRPM) - 1.0;
- float T_amb_degF = (T_amb * 1.8) - 459.67;
- float T_amb_sea_lev_degF = (288 * 1.8) - 459.67;
+ double T_amb_degF = (T_amb * 1.8) - 459.67;
+ double T_amb_sea_lev_degF = (288 * 1.8) - 459.67;
Percentage_Power =
Percentage_Power + ((T_amb_sea_lev_degF - T_amb_degF) * 7 /120);
- float Percentage_of_best_power_mixture_power =
+ double Percentage_of_best_power_mixture_power =
Power_Mixture_Correlation->GetValue(14.7 / equivalence_ratio);
Percentage_Power =
Percentage_Power * Percentage_of_best_power_mixture_power / 100.0;
void FGPiston::doEGT(void)
{
combustion_efficiency = Lookup_Combustion_Efficiency->GetValue(equivalence_ratio);
- float enthalpy_exhaust = m_dot_fuel * calorific_value_fuel *
+ double enthalpy_exhaust = m_dot_fuel * calorific_value_fuel *
combustion_efficiency * 0.33;
- float heat_capacity_exhaust = (Cp_air * m_dot_air) + (Cp_fuel * m_dot_fuel);
- float delta_T_exhaust = enthalpy_exhaust / heat_capacity_exhaust;
+ double heat_capacity_exhaust = (Cp_air * m_dot_air) + (Cp_fuel * m_dot_fuel);
+ double delta_T_exhaust = enthalpy_exhaust / heat_capacity_exhaust;
ExhaustGasTemp_degK = T_amb + delta_T_exhaust;
ExhaustGasTemp_degK *= 0.444 + ((0.544 - 0.444) * Percentage_Power / 100.0);
}
void FGPiston::doCHT(void)
{
- float h1 = -95.0;
- float h2 = -3.95;
- float h3 = -0.05;
-
- float arbitary_area = 1.0;
- float CpCylinderHead = 800.0;
- float MassCylinderHead = 8.0;
-
- float temperature_difference = CylinderHeadTemp_degK - T_amb;
- float v_apparent = IAS * 0.5144444;
- float v_dot_cooling_air = arbitary_area * v_apparent;
- float m_dot_cooling_air = v_dot_cooling_air * rho_air;
- float dqdt_from_combustion =
+ double h1 = -95.0;
+ double h2 = -3.95;
+ double h3 = -0.05;
+
+ double arbitary_area = 1.0;
+ double CpCylinderHead = 800.0;
+ double MassCylinderHead = 8.0;
+
+ double temperature_difference = CylinderHeadTemp_degK - T_amb;
+ double v_apparent = IAS * 0.5144444;
+ double v_dot_cooling_air = arbitary_area * v_apparent;
+ double m_dot_cooling_air = v_dot_cooling_air * rho_air;
+ double dqdt_from_combustion =
m_dot_fuel * calorific_value_fuel * combustion_efficiency * 0.33;
- float dqdt_forced = (h2 * m_dot_cooling_air * temperature_difference) +
+ double dqdt_forced = (h2 * m_dot_cooling_air * temperature_difference) +
(h3 * RPM * temperature_difference);
- float dqdt_free = h1 * temperature_difference;
- float dqdt_cylinder_head = dqdt_from_combustion + dqdt_forced + dqdt_free;
+ double dqdt_free = h1 * temperature_difference;
+ double dqdt_cylinder_head = dqdt_from_combustion + dqdt_forced + dqdt_free;
- float HeatCapacityCylinderHead = CpCylinderHead * MassCylinderHead;
+ double HeatCapacityCylinderHead = CpCylinderHead * MassCylinderHead;
CylinderHeadTemp_degK = dqdt_cylinder_head / HeatCapacityCylinderHead;
}
void FGPiston::doOilTemperature(void)
{
- float idle_percentage_power = 2.3; // approximately
- float target_oil_temp; // Steady state oil temp at the current engine conditions
- float time_constant; // The time constant for the differential equation
+ double idle_percentage_power = 2.3; // approximately
+ double target_oil_temp; // Steady state oil temp at the current engine conditions
+ double time_constant; // The time constant for the differential equation
if (Running) {
target_oil_temp = 363;
// that oil is no longer getting circulated
}
- float dOilTempdt = (target_oil_temp - OilTemp_degK) / time_constant;
+ double dOilTempdt = (target_oil_temp - OilTemp_degK) / time_constant;
OilTemp_degK += (dOilTempdt * dt);
}
void FGPiston::doOilPressure(void)
{
- float Oil_Press_Relief_Valve = 60; // FIXME: may vary by engine
- float Oil_Press_RPM_Max = 1800; // FIXME: may vary by engine
- float Design_Oil_Temp = 85; // FIXME: may vary by engine
+ double Oil_Press_Relief_Valve = 60; // FIXME: may vary by engine
+ double Oil_Press_RPM_Max = 1800; // FIXME: may vary by engine
+ double Design_Oil_Temp = 85; // FIXME: may vary by engine
// FIXME: WRONG!!! (85 degK???)
- float Oil_Viscosity_Index = 0.25;
+ double Oil_Viscosity_Index = 0.25;
OilPressure_psi = (Oil_Press_Relief_Valve / Oil_Press_RPM_Max) * RPM;
/// Destructor
~FGPiston();
- float Calculate(float PowerRequired);
- float GetPowerAvailable(void) {return PowerAvailable;}
+ double Calculate(double PowerRequired);
+ double GetPowerAvailable(void) {return PowerAvailable;}
private:
- float BrakeHorsePower;
- float SpeedSlope;
- float SpeedIntercept;
- float AltitudeSlope;
- float PowerAvailable;
+ double BrakeHorsePower;
+ double SpeedSlope;
+ double SpeedIntercept;
+ double AltitudeSlope;
+ double PowerAvailable;
// timestep
- float dt;
+ double dt;
void doEngineStartup(void);
void doManifoldPressure(void);
//
// constants
//
- const float CONVERT_CUBIC_INCHES_TO_METERS_CUBED;
+ const double CONVERT_CUBIC_INCHES_TO_METERS_CUBED;
- const float R_air;
- const float rho_fuel; // kg/m^3
- const float calorific_value_fuel; // W/Kg (approximate)
- const float Cp_air; // J/KgK
- const float Cp_fuel; // J/KgK
+ const double R_air;
+ const double rho_fuel; // kg/m^3
+ const double calorific_value_fuel; // W/Kg (approximate)
+ const double Cp_air; // J/KgK
+ const double Cp_fuel; // J/KgK
FGTable *Lookup_Combustion_Efficiency;
FGTable *Power_Mixture_Correlation;
//
// Configuration
//
- float MinManifoldPressure_inHg; // Inches Hg
- float MaxManifoldPressure_inHg; // Inches Hg
- float Displacement; // cubic inches
- float MaxHP; // horsepower
- float Cycles; // cycles/power stroke
- float IdleRPM; // revolutions per minute
+ double MinManifoldPressure_inHg; // Inches Hg
+ double MaxManifoldPressure_inHg; // Inches Hg
+ double Displacement; // cubic inches
+ double MaxHP; // horsepower
+ double Cycles; // cycles/power stroke
+ double IdleRPM; // revolutions per minute
//
// Inputs (in addition to those in FGEngine).
//
- float p_amb; // Pascals
- float p_amb_sea_level; // Pascals
- float T_amb; // degrees Kelvin
- float RPM; // revolutions per minute
- float IAS; // knots
+ double p_amb; // Pascals
+ double p_amb_sea_level; // Pascals
+ double T_amb; // degrees Kelvin
+ double RPM; // revolutions per minute
+ double IAS; // knots
//
// Outputs (in addition to those in FGEngine).
//
bool Magneto_Left;
bool Magneto_Right;
- float rho_air;
- float volumetric_efficiency;
- float m_dot_air;
- float equivalence_ratio;
- float m_dot_fuel;
- float Percentage_Power;
- float HP;
- float combustion_efficiency;
+ double rho_air;
+ double volumetric_efficiency;
+ double m_dot_air;
+ double equivalence_ratio;
+ double m_dot_fuel;
+ double Percentage_Power;
+ double HP;
+ double combustion_efficiency;
void Debug(void);
};
CLASS IMPLEMENTATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-extern float globalTriNormal[3];
+extern double globalTriNormal[3];
extern double globalSceneryAltitude;
extern double globalSeaLevelRadius;
inline FGColumnVector3& GetRunwayNormal(void) { return vRunwayNormal; }
inline double GetGamma(void) { return gamma; }
- inline void SetGamma(float tt) { gamma = tt; }
+ inline void SetGamma(double tt) { gamma = tt; }
inline double GetHOverB(void) { return hoverb; }
void SetvVel(const FGColumnVector3& v) { vVel = v; }
- void SetLatitude(float tt) { Latitude = tt; }
+ void SetLatitude(double tt) { Latitude = tt; }
void SetLongitude(double tt) { Longitude = tt; }
void Seth(double tt);
void SetRunwayRadius(double tt) { RunwayRadius = tt; }
double LatitudeDot, LongitudeDot, RadiusDot;
double lastLatitudeDot, lastLongitudeDot, lastRadiusDot;
double Longitude, Latitude;
- float dt;
+ double dt;
double RunwayRadius;
double DistanceAGL;
double SeaLevelRadius;
double gamma;
double Vt, Vground;
- float hoverb,b;
+ double hoverb,b;
double psigt;
Name = Prop_cfg->GetValue("NAME");
Prop_cfg->GetNextConfigLine();
- while (Prop_cfg->GetValue() != "/FG_PROPELLER") {
+ while (Prop_cfg->GetValue() != string("/FG_PROPELLER")) {
*Prop_cfg >> token;
if (token == "IXX") {
*Prop_cfg >> Ixx;
//
// Because RPM could be zero, we need to be creative about what RPM is stated as.
-float FGPropeller::Calculate(float PowerAvailable)
+double FGPropeller::Calculate(double PowerAvailable)
{
- float J, C_Thrust, omega;
- float Vel = (fdmex->GetTranslation()->GetvAero())(1);
- float rho = fdmex->GetAtmosphere()->GetDensity();
- float RPS = RPM/60.0;
- float alpha, beta;
+ double J, C_Thrust, omega;
+ double Vel = (fdmex->GetTranslation()->GetvAero())(1);
+ double rho = fdmex->GetAtmosphere()->GetDensity();
+ double RPS = RPM/60.0;
+ double alpha, beta;
if (RPM > 0.10) {
J = Vel / (Diameter * RPM / 60.0);
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-float FGPropeller::GetPowerRequired(void)
+double FGPropeller::GetPowerRequired(void)
{
if (RPM <= 0.10) return 0.0; // If the prop ain't turnin', the fuel ain't burnin'.
- float cPReq, RPS = RPM / 60.0;
+ double cPReq, RPS = RPM / 60.0;
- float J = (fdmex->GetTranslation()->GetvAero())(1) / (Diameter * RPS);
- float rho = fdmex->GetAtmosphere()->GetDensity();
+ double J = (fdmex->GetTranslation()->GetvAero())(1) / (Diameter * RPS);
+ double rho = fdmex->GetAtmosphere()->GetDensity();
if (MaxPitch == MinPitch) { // Fixed pitch prop
cPReq = cPower->GetValue(J);
equation for rotational acceleration "a": a = Q/I , where Q is Torque and
I is moment of inertia for the propeller.
@param rpm the rotational velocity of the propeller */
- void SetRPM(float rpm) {RPM = rpm;}
+ void SetRPM(double rpm) {RPM = rpm;}
/** This commands the pitch of the blade to change to the value supplied.
This call is meant to be issued either from the cockpit or by the flight
indices to the power, thrust, and efficiency tables for variable-pitch
propellers.
@param pitch the pitch of the blade in degrees. */
- void SetPitch(float pitch) {Pitch = pitch;}
+ void SetPitch(double pitch) {Pitch = pitch;}
void SetPFactor(double pf) {P_Factor = pf;}
void SetSense(double s) { Sense = s;}
/// Retrieves the pitch of the propeller in degrees.
- float GetPitch(void) { return Pitch; }
+ double GetPitch(void) { return Pitch; }
/// Retrieves the RPMs of the propeller
- float GetRPM(void) { return RPM; }
+ double GetRPM(void) { return RPM; }
/// Retrieves the propeller moment of inertia
- float GetIxx(void) { return Ixx; }
+ double GetIxx(void) { return Ixx; }
/// Retrieves the Torque in foot-pounds (Don't you love the English system?)
- float GetTorque(void) { return Torque; }
+ double GetTorque(void) { return Torque; }
/** Retrieves the power required (or "absorbed") by the propeller -
i.e. the power required to keep spinning the propeller at the current
velocity, air density, and rotational rate. */
- float GetPowerRequired(void);
+ double GetPowerRequired(void);
/** Calculates and returns the thrust produced by this propeller.
Given the excess power available from the engine (in foot-pounds), the thrust is
accelerate the prop. It could be negative, dictating that the propeller
would be slowed.
@return the thrust in pounds */
- float Calculate(float PowerAvailable);
+ double Calculate(double PowerAvailable);
private:
int numBlades;
- float RPM;
- float Ixx;
- float Diameter;
- float MaxPitch;
- float MinPitch;
- float P_Factor;
- float Sense;
- float Pitch;
- float Torque;
+ double RPM;
+ double Ixx;
+ double Diameter;
+ double MaxPitch;
+ double MinPitch;
+ double P_Factor;
+ double Sense;
+ double Pitch;
+ double Torque;
FGTable *Efficiency;
FGTable *cThrust;
FGTable *cPower;
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-bool FGPropulsion::Run(void) {
- float PowerAvailable;
+bool FGPropulsion::Run(void)
+{
+ double PowerAvailable;
dt = State->Getdt();
Forces->InitMatrix();
*Forces += Thrusters[i]->GetBodyForces(); // sum body frame forces
*Moments += Thrusters[i]->GetMoments(); // sum body frame moments
}
-
return false;
} else {
return true;
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
bool FGPropulsion::GetSteadyState(void) {
- float PowerAvailable;
- float currentThrust = 0, lastThrust=-1;
+ double PowerAvailable;
+ double currentThrust = 0, lastThrust=-1;
dt = State->Getdt();
int steady_count,j=0;
bool steady=false;
bool FGPropulsion::ICEngineStart(void) {
- float PowerAvailable;
+ double PowerAvailable;
int j;
dt = State->Getdt();
AC_cfg->GetNextConfigLine();
- while ((token = AC_cfg->GetValue()) != "/PROPULSION") {
+ while ((token = AC_cfg->GetValue()) != string("/PROPULSION")) {
if (token == "AC_ENGINE") { // ============ READING ENGINES
}
AC_cfg->GetNextConfigLine();
- while ((token = AC_cfg->GetValue()) != "/AC_ENGINE") {
+ while ((token = AC_cfg->GetValue()) != string("/AC_ENGINE")) {
*AC_cfg >> token;
if (token == "XLOC") { *AC_cfg >> xLoc; }
else if (token == "YLOC") { *AC_cfg >> yLoc; }
}
AC_cfg->GetNextConfigLine();
- while ((token = AC_cfg->GetValue()) != "/AC_THRUSTER") {
+ while ((token = AC_cfg->GetValue()) != string("/AC_THRUSTER")) {
*AC_cfg >> token;
if (token == "XLOC") *AC_cfg >> xLoc;
else if (token == "YLOC") *AC_cfg >> yLoc;
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-float FGPropulsion::GetTanksWeight(void)
+double FGPropulsion::GetTanksWeight(void)
{
- float Tw = 0.0;
+ double Tw = 0.0;
iTank = Tanks.begin();
while (iTank < Tanks.end()) {
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-float FGPropulsion::GetTanksIxx(const FGColumnVector3& vXYZcg)
+double FGPropulsion::GetTanksIxx(const FGColumnVector3& vXYZcg)
{
- float I = 0.0;
+ double I = 0.0;
iTank = Tanks.begin();
while (iTank < Tanks.end()) {
I += ((*iTank)->GetX() - vXYZcg(eX))*((*iTank)->GetX() - vXYZcg(eX)) * (*iTank)->GetContents()/(144.0*Inertial->gravity());
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-float FGPropulsion::GetTanksIyy(const FGColumnVector3& vXYZcg)
+double FGPropulsion::GetTanksIyy(const FGColumnVector3& vXYZcg)
{
- float I = 0.0;
+ double I = 0.0;
iTank = Tanks.begin();
while (iTank < Tanks.end()) {
I += ((*iTank)->GetY() - vXYZcg(eY))*((*iTank)->GetY() - vXYZcg(eY)) * (*iTank)->GetContents()/(144.0*Inertial->gravity());
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-float FGPropulsion::GetTanksIzz(const FGColumnVector3& vXYZcg)
+double FGPropulsion::GetTanksIzz(const FGColumnVector3& vXYZcg)
{
- float I = 0.0;
+ double I = 0.0;
iTank = Tanks.begin();
while (iTank < Tanks.end()) {
I += ((*iTank)->GetZ() - vXYZcg(eZ))*((*iTank)->GetZ() - vXYZcg(eZ)) * (*iTank)->GetContents()/(144.0*Inertial->gravity());
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-float FGPropulsion::GetTanksIxz(const FGColumnVector3& vXYZcg)
+double FGPropulsion::GetTanksIxz(const FGColumnVector3& vXYZcg)
{
- float I = 0.0;
+ double I = 0.0;
iTank = Tanks.begin();
while (iTank < Tanks.end()) {
I += ((*iTank)->GetX() - vXYZcg(eX))*((*iTank)->GetZ() - vXYZcg(eZ)) * (*iTank)->GetContents()/(144.0*Inertial->gravity());
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-float FGPropulsion::GetTanksIxy(const FGColumnVector3& vXYZcg)
+double FGPropulsion::GetTanksIxy(const FGColumnVector3& vXYZcg)
{
- float I = 0.0;
+ double I = 0.0;
iTank = Tanks.begin();
while (iTank != Tanks.end()) {
I += ((*iTank)->GetX() - vXYZcg(eX))*((*iTank)->GetY() - vXYZcg(eY)) * (*iTank)->GetContents()/(144.0*Inertial->gravity());
string GetPropulsionValues(void);
inline FGColumnVector3& GetForces(void) {return *Forces; }
- inline float GetForces(int n) { return (*Forces)(n);}
+ inline double GetForces(int n) { return (*Forces)(n);}
inline FGColumnVector3& GetMoments(void) {return *Moments;}
- inline float GetMoments(int n) {return (*Moments)(n);}
+ inline double GetMoments(int n) {return (*Moments)(n);}
FGColumnVector3& GetTanksCG(void);
- float GetTanksWeight(void);
+ double GetTanksWeight(void);
- float GetTanksIxx(const FGColumnVector3& vXYZcg);
- float GetTanksIyy(const FGColumnVector3& vXYZcg);
- float GetTanksIzz(const FGColumnVector3& vXYZcg);
- float GetTanksIxz(const FGColumnVector3& vXYZcg);
- float GetTanksIxy(const FGColumnVector3& vXYZcg);
+ double GetTanksIxx(const FGColumnVector3& vXYZcg);
+ double GetTanksIyy(const FGColumnVector3& vXYZcg);
+ double GetTanksIzz(const FGColumnVector3& vXYZcg);
+ double GetTanksIxz(const FGColumnVector3& vXYZcg);
+ double GetTanksIxy(const FGColumnVector3& vXYZcg);
private:
vector <FGEngine*> Engines;
unsigned int numEngines;
unsigned int numTanks;
unsigned int numThrusters;
- float dt;
+ double dt;
FGColumnVector3 *Forces;
FGColumnVector3 *Moments;
FGColumnVector3 vXYZtank;
Name = Eng_cfg->GetValue("NAME");
Eng_cfg->GetNextConfigLine();
- while (Eng_cfg->GetValue() != "/FG_ROCKET") {
+ while (Eng_cfg->GetValue() != string("/FG_ROCKET")) {
*Eng_cfg >> token;
if (token == "SHR") *Eng_cfg >> SHR;
else if (token == "MAX_PC") *Eng_cfg >> maxPC;
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-float FGRocket::Calculate(float pe)
+double FGRocket::Calculate(double pe)
{
- float Cf;
+ double Cf;
ConsumeFuel();
PC = 0.0;
} else {
PctPower = Throttle / MaxThrottle;
- PC = maxPC*PctPower * (1.0 + Variance * ((float)rand()/(float)RAND_MAX - 0.5));
+ PC = maxPC*PctPower * (1.0 + Variance * ((double)rand()/(double)RAND_MAX - 0.5));
Cf = sqrt(kFactor*(1 - pow(pe/(PC), (SHR-1)/SHR)));
Flameout = false;
}
coefficient times the chamber pressure.
@param pe nozzle exit pressure
@return thrust coefficient times chamber pressure */
- float Calculate(float pe);
+ double Calculate(double pe);
/** Gets the chamber pressure.
@return chamber pressure in psf. */
- float GetChamberPressure(void) {return PC;}
+ double GetChamberPressure(void) {return PC;}
private:
- float SHR;
- float maxPC;
- float propEff;
- float kFactor;
- float Variance;
- float PC;
+ double SHR;
+ double maxPC;
+ double propEff;
+ double kFactor;
+ double Variance;
+ double PC;
void Debug(void);
};
bool FGRotation::Run(void)
{
- float L2, N1;
- float tTheta;
+ double L2, N1;
+ double tTheta;
if (!FGModel::Run()) {
GetState();
bool Run(void);
inline FGColumnVector3& GetPQR(void) {return vPQR;}
- inline float GetPQR(int axis) {return vPQR(axis);}
+ inline double GetPQR(int axis) {return vPQR(axis);}
inline FGColumnVector3& GetPQRdot(void) {return vPQRdot;}
- inline float GetPQRdot(int idx) {return vPQRdot(idx);}
+ inline double GetPQRdot(int idx) {return vPQRdot(idx);}
inline FGColumnVector3& GetEuler(void) {return vEuler;}
- inline float GetEuler(int axis) {return vEuler(axis);}
+ inline double GetEuler(int axis) {return vEuler(axis);}
inline FGColumnVector3& GetEulerRates(void) { return vEulerRates; }
- inline float GetEulerRates(int axis) { return vEulerRates(axis); }
+ inline double GetEulerRates(int axis) { return vEulerRates(axis); }
inline void SetPQR(FGColumnVector3 tt) {vPQR = tt;}
inline void SetEuler(FGColumnVector3 tt) {vEuler = tt;}
- inline float Getphi(void) {return vEuler(1);}
- inline float Gettht(void) {return vEuler(2);}
- inline float Getpsi(void) {return vEuler(3);}
+ inline double Getphi(void) {return vEuler(1);}
+ inline double Gettht(void) {return vEuler(2);}
+ inline double Getpsi(void) {return vEuler(3);}
- inline float GetCosphi(void) {return cPhi;}
- inline float GetCostht(void) {return cTht;}
- inline float GetCospsi(void) {return cPsi;}
+ inline double GetCosphi(void) {return cPhi;}
+ inline double GetCostht(void) {return cTht;}
+ inline double GetCospsi(void) {return cPsi;}
- inline float GetSinphi(void) {return sPhi;}
- inline float GetSintht(void) {return sTht;}
- inline float GetSinpsi(void) {return sPsi;}
+ inline double GetSinphi(void) {return sPhi;}
+ inline double GetSintht(void) {return sTht;}
+ inline double GetSinpsi(void) {return sPsi;}
private:
FGColumnVector3 vPQR;
FGColumnVector3 vEulerRates;
FGColumnVector3 vlastPQRdot;
- float cTht,sTht;
- float cPhi,sPhi;
- float cPsi,sPsi;
+ double cTht,sTht;
+ double cPhi,sPhi;
+ double cPsi,sPsi;
- float Ixx, Iyy, Izz, Ixz;
- float dt;
+ double Ixx, Iyy, Izz, Ixz;
+ double dt;
void GetState(void);
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-float FGRotor::Calculate(float PowerAvailable)
+double FGRotor::Calculate(double PowerAvailable)
{
return 0.0;
}
FGRotor(FGFDMExec *FDMExec);
~FGRotor();
- float Calculate(float);
+ double Calculate(double);
private:
void Debug(void);
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-float FGState::GetParameter(eParam val_idx) {
- float scratch;
+double FGState::GetParameter(eParam val_idx) {
+ double scratch;
switch(val_idx) {
case FG_TIME:
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-float FGState::GetParameter(string val_string) {
+double FGState::GetParameter(string val_string) {
return GetParameter(coeffdef[val_string]);
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-void FGState::SetParameter(eParam val_idx, float val) {
+void FGState::SetParameter(eParam val_idx, double val) {
switch(val_idx) {
case FG_ELEVATOR_POS:
FCS->SetDePos(val);
string resetDef;
string token="";
- float U, V, W;
- float phi, tht, psi;
- float latitude, longitude, h;
- float wdir, wmag, wnorth, weast;
+ double U, V, W;
+ double phi, tht, psi;
+ double latitude, longitude, h;
+ double wdir, wmag, wnorth, weast;
# ifndef macintosh
resetDef = path + "/" + acname + "/" + fname + ".xml";
// Initialize: Assume all angles GIVEN IN RADIANS !!
//
-void FGState::Initialize(float U, float V, float W,
- float phi, float tht, float psi,
- float Latitude, float Longitude, float H,
- float wnorth, float weast, float wdown)
+void FGState::Initialize(double U, double V, double W,
+ double phi, double tht, double psi,
+ double Latitude, double Longitude, double H,
+ double wnorth, double weast, double wdown)
{
- float alpha, beta;
- float qbar, Vt;
+ double alpha, beta;
+ double qbar, Vt;
FGColumnVector3 vAero;
Position->SetLatitude(Latitude);
void FGState::Initialize(FGInitialCondition *FGIC) {
- float tht,psi,phi;
- float U, V, W, h;
- float latitude, longitude;
- float wnorth,weast, wdown;
+ double tht,psi,phi;
+ double U, V, W, h;
+ double latitude, longitude;
+ double wnorth,weast, wdown;
latitude = FGIC->GetLatitudeRadIC();
longitude = FGIC->GetLongitudeRadIC();
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-void FGState::InitMatrices(float phi, float tht, float psi) {
- float thtd2, psid2, phid2;
- float Sthtd2, Spsid2, Sphid2;
- float Cthtd2, Cpsid2, Cphid2;
- float Cphid2Cthtd2;
- float Cphid2Sthtd2;
- float Sphid2Sthtd2;
- float Sphid2Cthtd2;
+void FGState::InitMatrices(double phi, double tht, double psi) {
+ double thtd2, psid2, phid2;
+ double Sthtd2, Spsid2, Sphid2;
+ double Cthtd2, Cpsid2, Cphid2;
+ double Cphid2Cthtd2;
+ double Cphid2Sthtd2;
+ double Sphid2Sthtd2;
+ double Sphid2Cthtd2;
thtd2 = tht/2.0;
psid2 = psi/2.0;
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void FGState::CalcMatrices(void) {
- float Q0Q0, Q1Q1, Q2Q2, Q3Q3;
- float Q0Q1, Q0Q2, Q0Q3, Q1Q2;
- float Q1Q3, Q2Q3;
+ double Q0Q0, Q1Q1, Q2Q2, Q3Q3;
+ double Q0Q1, Q0Q2, Q0Q3, Q1Q2;
+ double Q1Q3, Q2Q3;
Q0Q0 = vQtrn(1)*vQtrn(1);
Q1Q1 = vQtrn(2)*vQtrn(2);
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-FGMatrix33& FGState::GetTs2b(float alpha, float beta)
+FGMatrix33& FGState::GetTs2b(void)
{
- float ca, cb, sa, sb;
+ double ca, cb, sa, sb;
+
+ double alpha = Translation->Getalpha();
+ double beta = Translation->Getbeta();
ca = cos(alpha);
sa = sin(alpha);
@param weast eastward velocity in feet per second
@param wdown downward velocity in feet per second
*/
- void Initialize(float U,
- float V,
- float W,
- float lat,
- float lon,
- float phi,
- float tht,
- float psi,
- float h,
- float wnorth,
- float weast,
- float wdown);
+ void Initialize(double U,
+ double V,
+ double W,
+ double lat,
+ double lon,
+ double phi,
+ double tht,
+ double psi,
+ double h,
+ double wnorth,
+ double weast,
+ double wdown);
/** Initializes the simulation state based on parameters from an Initial Conditions object.
@param FGIC pointer to an initial conditions object.
bool StoreData(string filename);
/// returns the speed of sound in feet per second.
- inline float Geta(void) { return a; }
+ inline double Geta(void) { return a; }
/// Returns the simulation time in seconds.
- inline float Getsim_time(void) { return sim_time; }
+ inline double Getsim_time(void) { return sim_time; }
/// Returns the simulation delta T.
- inline float Getdt(void) { return dt; }
+ inline double Getdt(void) { return dt; }
/// Suspends the simulation and sets the delta T to zero.
inline void Suspend(void) {saved_dt = dt; dt = 0.0;}
@param val_idx one of the enumerated JSBSim parameters.
@return the value of the parameter.
*/
- float GetParameter(eParam val_idx);
+ double GetParameter(eParam val_idx);
/** Retrieves a parameter.
The parameters that can be retrieved are enumerated in FGJSBBase.h.
i.e. "FG_QBAR".
@return the value of the parameter.
*/
- float GetParameter(string val_string);
+ double GetParameter(string val_string);
/** Retrieves the JSBSim parameter enumerated item given the text string.
@param val_string the parameter string, i.e. "FG_QBAR".
/** Sets the speed of sound.
@param speed the speed of sound in feet per second.
*/
- inline void Seta(float speed) { a = speed; }
+ inline void Seta(double speed) { a = speed; }
/** Sets the current sim time.
@param cur_time the current time
@return the current time.
*/
- inline float Setsim_time(float cur_time) {
+ inline double Setsim_time(double cur_time) {
sim_time = cur_time;
return sim_time;
}
/** Sets the integration time step for the simulation executive.
@param delta_t the time step in seconds.
*/
- inline void Setdt(float delta_t) { dt = delta_t; }
+ inline void Setdt(double delta_t) { dt = delta_t; }
/** Sets the JSBSim parameter to the supplied value.
@param prm the JSBSim parameter to set, i.e. FG_RUDDER_POS.
@param val the value to give the parameter.
*/
- void SetParameter(eParam prm, float val);
+ void SetParameter(eParam prm, double val);
/** Increments the simulation time.
@return the new simulation time.
*/
- inline float IncrTime(void) {
+ inline double IncrTime(void) {
sim_time+=dt;
return sim_time;
}
@param tht the pitch angle in radians.
@param psi the heading angle in radians
*/
- void InitMatrices(float phi, float tht, float psi);
+ void InitMatrices(double phi, double tht, double psi);
/** Calculates the local-to-body and body-to-local conversion matrices.
*/
FGColumnVector3& CalcEuler(void);
/** Calculates and returns the stability-to-body axis transformation matrix.
- @param alpha angle of attack in radians.
- @param beta angle of sideslip in radians.
@return a reference to the stability-to-body transformation matrix.
*/
- FGMatrix33& GetTs2b(float alpha, float beta);
+ FGMatrix33& GetTs2b(void);
/** Retrieves the local-to-body transformation matrix.
@return a reference to the local-to-body transformation matrix.
@param c matrix column index.
@return the matrix element described by the row and column supplied.
*/
- float GetTl2b(int r, int c) { return mTl2b(r,c);}
+ double GetTl2b(int r, int c) { return mTl2b(r,c);}
/** Retrieves the body-to-local transformation matrix.
@return a reference to the body-to-local matrix.
@param c matrix column index.
@return the matrix element described by the row and column supplied.
*/
- float GetTb2l(int i, int j) { return mTb2l(i,j);}
+ double GetTb2l(int i, int j) { return mTb2l(i,j);}
/** Prints a summary of simulator state (speed, altitude,
configuration, etc.)
ParamMap paramdef;
private:
- float a; // speed of sound
- float sim_time, dt;
- float saved_dt;
+ double a; // speed of sound
+ double sim_time, dt;
+ double saved_dt;
FGFDMExec* FDMExec;
FGMatrix33 mTb2l;
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-float** FGTable::Allocate(void)
+double** FGTable::Allocate(void)
{
- Data = new float*[nRows+1];
+ Data = new double*[nRows+1];
for (int r=0; r<=nRows; r++) {
- Data[r] = new float[nCols+1];
+ Data[r] = new double[nCols+1];
for (int c=0; c<=nCols; c++) {
Data[r][c] = 0.0;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-float FGTable::GetValue(float key)
+double FGTable::GetValue(double key)
{
- float Factor, Value, Span;
+ double Factor, Value, Span;
int r;
for (r=1; r<=nRows; r++) if (Data[r][0] >= key) break;
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-float FGTable::GetValue(float rowKey, float colKey)
+double FGTable::GetValue(double rowKey, double colKey)
{
- float rFactor, cFactor, col1temp, col2temp, Value;
+ double rFactor, cFactor, col1temp, col2temp, Value;
int r, c;
for (r=1;r<=nRows;r++) if (Data[r][0] >= rowKey) break;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-FGTable& FGTable::operator<<(const float n)
+/*
+FGTable& FGTable::operator<<(const double n)
{
*this << (double)n;
return *this;
}
-
+*/
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void FGTable::Print(void)
~FGTable();
FGTable(int nRows);
FGTable(int nRows, int nCols);
- float GetValue(float key);
- float GetValue(float rowKey, float colKey);
+ double GetValue(double key);
+ double GetValue(double rowKey, double colKey);
/** Read the table in.
Data in the config file should be in matrix format with the row
independents as the first column and the column independents in
</pre>
*/
void operator<<(FGConfigFile&);
- FGTable& operator<<(const float n);
- FGTable& operator<<(const int n);
FGTable& operator<<(const double n);
- inline float GetElement(int r, int c) {return Data[r][c];}
+ FGTable& operator<<(const int n);
+// FGTable& operator<<(const double n);
+ inline double GetElement(int r, int c) {return Data[r][c];}
void Print(void);
private:
enum type {tt1D, tt2D} Type;
- float** Data;
+ double** Data;
int nRows, nCols;
unsigned int colCounter;
unsigned int rowCounter;
- float** Allocate(void);
+ double** Allocate(void);
void Debug(void);
};
else Type = ttUNKNOWN;
AC_cfg->GetNextConfigLine();
- while ((token = AC_cfg->GetValue()) != "/AC_TANK") {
+ while ((token = AC_cfg->GetValue()) != string("/AC_TANK")) {
if (token == "XLOC") *AC_cfg >> X;
else if (token == "YLOC") *AC_cfg >> Y;
else if (token == "ZLOC") *AC_cfg >> Z;
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-float FGTank::Reduce(float used)
+double FGTank::Reduce(double used)
{
- float shortage;
+ double shortage;
if (used < Contents) {
Contents -= used;
FGTank(FGConfigFile*);
~FGTank();
- float Reduce(float);
+ double Reduce(double);
int GetType(void) {return Type;}
bool GetSelected(void) {return Selected;}
- float GetPctFull(void) {return PctFull;}
- float GetContents(void) {return Contents;}
- float inline GetX(void) {return X;}
- float inline GetY(void) {return Y;}
- float inline GetZ(void) {return Z;}
+ double GetPctFull(void) {return PctFull;}
+ double GetContents(void) {return Contents;}
+ double inline GetX(void) {return X;}
+ double inline GetY(void) {return Y;}
+ double inline GetZ(void) {return Z;}
enum TankType {ttUNKNOWN, ttFUEL, ttOXIDIZER};
private:
TankType Type;
- float X, Y, Z;
- float Capacity;
- float Radius;
- float PctFull;
- float Contents;
+ double X, Y, Z;
+ double Capacity;
+ double Radius;
+ double PctFull;
+ double Contents;
bool Selected;
void Debug(void);
};
enum eType {ttNozzle, ttRotor, ttPropeller};
- virtual float Calculate(float) {return 0.0;}
+ virtual double Calculate(double) {return 0.0;}
void SetName(string name) {Name = name;}
- virtual float GetPowerRequired(void) {return 0.0;}
- virtual void SetdeltaT(float dt) {deltaT = dt;}
- float GetThrust(void) {return Thrust;}
+ virtual double GetPowerRequired(void) {return 0.0;}
+ virtual void SetdeltaT(double dt) {deltaT = dt;}
+ double GetThrust(void) {return Thrust;}
eType GetType(void) {return Type;}
string GetName(void) {return Name;}
- virtual float GetRPM(void) { return 0.0; };
+ virtual double GetRPM(void) { return 0.0; };
protected:
eType Type;
string Name;
- float Thrust;
- float PowerRequired;
- float deltaT;
+ double Thrust;
+ double PowerRequired;
+ double deltaT;
virtual void Debug(void);
};
bool FGTranslation::Run(void)
{
- float Tc = 0.5*State->Getdt()*rate;
+ double Tc = 0.5*State->Getdt()*rate;
if (!FGModel::Run()) {
sqrt(vAero(eU)*vAero(eU) + vAero(eW)*vAero(eW))) : 0.0;
// stolen, quite shamelessly, from LaRCsim
- float mUW = (vAero(eU)*vAero(eU) + vAero(eW)*vAero(eW));
- float signU=1;
+ double mUW = (vAero(eU)*vAero(eU) + vAero(eW)*vAero(eW));
+ double signU=1;
if (vAero(eU) != 0.0)
signU = vAero(eU)/fabs(vAero(eU));
~FGTranslation();
inline FGColumnVector3& GetUVW (void) { return vUVW; }
- inline float GetUVW (int idx) { return vUVW(idx); }
+ inline double GetUVW (int idx) { return vUVW(idx); }
inline FGColumnVector3& GetUVWdot(void) { return vUVWdot; }
- inline float GetUVWdot(int idx) { return vUVWdot(idx); }
+ inline double GetUVWdot(int idx) { return vUVWdot(idx); }
inline FGColumnVector3& GetvAero (void) { return vAero; }
- inline float GetvAero (int idx) { return vAero(idx); }
+ inline double GetvAero (int idx) { return vAero(idx); }
- inline float Getalpha(void) { return alpha; }
- inline float Getbeta (void) { return beta; }
- inline float Getqbar (void) { return qbar; }
- inline float GetVt (void) { return Vt; }
- inline float GetMach (void) { return Mach; }
- inline float Getadot (void) { return adot; }
- inline float Getbdot (void) { return bdot; }
+ inline double Getalpha(void) { return alpha; }
+ inline double Getbeta (void) { return beta; }
+ inline double Getqbar (void) { return qbar; }
+ inline double GetVt (void) { return Vt; }
+ inline double GetMach (void) { return Mach; }
+ inline double Getadot (void) { return adot; }
+ inline double Getbdot (void) { return bdot; }
void SetUVW(FGColumnVector3 tt) { vUVW = tt; }
- inline void Setalpha(float tt) { alpha = tt; }
- inline void Setbeta (float tt) { beta = tt; }
- inline void Setqbar (float tt) { qbar = tt; }
- inline void SetVt (float tt) { Vt = tt; }
- inline void SetMach (float tt) { Mach=tt; }
- inline void Setadot (float tt) { adot = tt; }
- inline void Setbdot (float tt) { bdot = tt; }
+ inline void Setalpha(double tt) { alpha = tt; }
+ inline void Setbeta (double tt) { beta = tt; }
+ inline void Setqbar (double tt) { qbar = tt; }
+ inline void SetVt (double tt) { Vt = tt; }
+ inline void SetMach (double tt) { Mach=tt; }
+ inline void Setadot (double tt) { adot = tt; }
+ inline void Setbdot (double tt) { bdot = tt; }
- inline void SetAB(float t1, float t2) { alpha=t1; beta=t2; }
+ inline void SetAB(double t1, double t2) { alpha=t1; beta=t2; }
bool Run(void);
FGMatrix33 mVel;
FGColumnVector3 vAero;
- float Vt, qbar, Mach;
- float dt;
- float alpha, beta;
- float adot,bdot;
+ double Vt, qbar, Mach;
+ double dt;
+ double alpha, beta;
+ double adot,bdot;
void Debug(void);
};
break;
}
//cout << "TrimAxes.size(): " << TrimAxes.size() << endl;
- sub_iterations=new float[TrimAxes.size()];
- successful=new float[TrimAxes.size()];
+ sub_iterations=new double[TrimAxes.size()];
+ successful=new double[TrimAxes.size()];
solution=new bool[TrimAxes.size()];
current_axis=0;
snprintf(out,80," %5s: %3.0f average: %5.2f successful: %3.0f stability: %5.2f\n",
TrimAxes[current_axis]->GetStateName().c_str(),
sub_iterations[current_axis],
- sub_iterations[current_axis]/float(total_its),
+ sub_iterations[current_axis]/double(total_its),
successful[current_axis],
TrimAxes[current_axis]->GetAvgStability() );
cout << out;
delete[] sub_iterations;
delete[] successful;
delete[] solution;
- sub_iterations=new float[TrimAxes.size()];
- successful=new float[TrimAxes.size()];
+ sub_iterations=new double[TrimAxes.size()];
+ successful=new double[TrimAxes.size()];
solution=new bool[TrimAxes.size()];
}
return result;
delete[] sub_iterations;
delete[] successful;
delete[] solution;
- sub_iterations=new float[TrimAxes.size()];
- successful=new float[TrimAxes.size()];
+ sub_iterations=new double[TrimAxes.size()];
+ successful=new double[TrimAxes.size()];
solution=new bool[TrimAxes.size()];
}
return result;
bool FGTrim::solve(void) {
- float x1,x2,x3,f1,f2,f3,d,d0;
- const float relax =0.9;
- float eps=TrimAxes[current_axis]->GetSolverEps();
+ double x1,x2,x3,f1,f2,f3,d,d0;
+ const double relax =0.9;
+ double eps=TrimAxes[current_axis]->GetSolverEps();
x1=x2=x3=0;
d=1;
*/
bool FGTrim::findInterval(void) {
bool found=false;
- float step;
- float current_control=TrimAxes[current_axis]->GetControl();
- float current_accel=TrimAxes[current_axis]->GetState();;
- float xmin=TrimAxes[current_axis]->GetControlMin();
- float xmax=TrimAxes[current_axis]->GetControlMax();
- float lastxlo,lastxhi,lastalo,lastahi;
+ double step;
+ double current_control=TrimAxes[current_axis]->GetControl();
+ double current_accel=TrimAxes[current_axis]->GetState();;
+ double xmin=TrimAxes[current_axis]->GetControlMin();
+ double xmax=TrimAxes[current_axis]->GetControlMax();
+ double lastxlo,lastxhi,lastalo,lastahi;
step=0.025*fabs(xmax);
xlo=xhi=current_control;
bool FGTrim::checkLimits(void) {
bool solutionExists;
- float current_control=TrimAxes[current_axis]->GetControl();
- float current_accel=TrimAxes[current_axis]->GetState();
+ double current_control=TrimAxes[current_axis]->GetControl();
+ double current_accel=TrimAxes[current_axis]->GetState();
xlo=TrimAxes[current_axis]->GetControlMin();
xhi=TrimAxes[current_axis]->GetControlMax();
int N, Nsub;
TrimMode mode;
int Debug;
- float Tolerance, A_Tolerance;
- float wdot,udot,qdot;
- float dth;
- float *sub_iterations;
- float *successful;
+ double Tolerance, A_Tolerance;
+ double wdot,udot,qdot;
+ double dth;
+ double *sub_iterations;
+ double *successful;
bool *solution;
int max_sub_iterations;
int max_iterations;
bool trim_failed;
int axis_count;
int solutionDomain;
- float xlo,xhi,alo,ahi;
+ double xlo,xhi,alo,ahi;
FGFDMExec* fdmex;
FGInitialCondition* fgic;
held to a tolerance of 1/10th of the given. The default is
0.001 for the recti-linear accelerations and 0.0001 for the angular.
*/
- inline void SetTolerance(float tt) {
+ inline void SetTolerance(double tt) {
Tolerance = tt;
A_Tolerance = tt / 10;
}
/*****************************************************************************/
-float FGTrimAxis::computeHmgt(void) {
- float diff;
+double FGTrimAxis::computeHmgt(void) {
+ double diff;
diff = fdmex->GetRotation()->Getpsi() -
fdmex->GetPosition()->GetGroundTrack();
// 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(float ff) {
+void FGTrimAxis::SetThetaOnGround(double ff) {
int center,i,ref;
// favor an off-center unit so that the same one can be used for both
}
cout << "SetThetaOnGround ref gear: " << ref << endl;
if(ref >= 0) {
- float sp=fdmex->GetRotation()->GetSinphi();
- float cp=fdmex->GetRotation()->GetCosphi();
- float lx=fdmex->GetGroundReactions()->GetGearUnit(ref)->GetBodyLocation(1);
- float ly=fdmex->GetGroundReactions()->GetGearUnit(ref)->GetBodyLocation(2);
- float lz=fdmex->GetGroundReactions()->GetGearUnit(ref)->GetBodyLocation(3);
- float hagl = -1*lx*sin(ff) +
+ double sp=fdmex->GetRotation()->GetSinphi();
+ double cp=fdmex->GetRotation()->GetCosphi();
+ 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);
bool FGTrimAxis::initTheta(void) {
int i,N,iAft, iForward;
- float zAft,zForward,zDiff,theta;
+ double zAft,zForward,zDiff,theta;
bool level;
- float saveAlt;
+ double saveAlt;
saveAlt=fgic->GetAltitudeAGLFtIC();
fgic->SetAltitudeAGLFtIC(100);
/*****************************************************************************/
-void FGTrimAxis::SetPhiOnGround(float ff) {
+void FGTrimAxis::SetPhiOnGround(double ff) {
int i,ref;
i=0; ref=-1;
i++;
}
if(ref >= 0) {
- float st=fdmex->GetRotation()->GetSintht();
- float ct=fdmex->GetRotation()->GetCostht();
- float lx=fdmex->GetGroundReactions()->GetGearUnit(ref)->GetBodyLocation(1);
- float ly=fdmex->GetGroundReactions()->GetGearUnit(ref)->GetBodyLocation(2);
- float lz=fdmex->GetGroundReactions()->GetGearUnit(ref)->GetBodyLocation(3);
- float hagl = -1*lx*st +
+ double st=fdmex->GetRotation()->GetSintht();
+ double ct=fdmex->GetRotation()->GetCostht();
+ 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;
void FGTrimAxis::Run(void) {
- float last_state_value;
+ double last_state_value;
int i;
setControl();
//cout << "FGTrimAxis::Run: " << control_value << endl;
/*****************************************************************************/
void FGTrimAxis::setThrottlesPct(void) {
- float tMin,tMax;
+ double tMin,tMax;
for(unsigned i=0;i<fdmex->GetPropulsion()->GetNumEngines();i++) {
tMin=fdmex->GetPropulsion()->GetEngine(i)->GetThrottleMin();
tMax=fdmex->GetPropulsion()->GetEngine(i)->GetThrottleMax();
/*****************************************************************************/
-float FGTrimAxis::GetAvgStability( void ) {
+double FGTrimAxis::GetAvgStability( void ) {
if(total_iterations > 0) {
- return float(total_stability_iterations)/float(total_iterations);
+ return double(total_stability_iterations)/double(total_iterations);
}
return 0;
}
void Run(void);
- float GetState(void) { getState(); return state_value; }
+ double GetState(void) { getState(); return state_value; }
//Accels are not settable
- inline void SetControl(float value ) { control_value=value; }
- inline float GetControl(void) { return control_value; }
+ inline void SetControl(double value ) { control_value=value; }
+ inline double GetControl(void) { return control_value; }
inline State GetStateType(void) { return state; }
inline Control GetControlType(void) { return control; }
inline string GetStateName(void) { return StateNames[state]; }
inline string GetControlName(void) { return ControlNames[control]; }
- inline float GetControlMin(void) { return control_min; }
- inline float GetControlMax(void) { return control_max; }
+ inline double GetControlMin(void) { return control_min; }
+ inline double GetControlMax(void) { return control_max; }
inline void SetControlToMin(void) { control_value=control_min; }
inline void SetControlToMax(void) { control_value=control_max; }
- inline void SetControlLimits(float min, float max) {
+ inline void SetControlLimits(double min, double max) {
control_min=min;
control_max=max;
}
- inline void SetTolerance(float ff) { tolerance=ff;}
- inline float GetTolerance(void) { return tolerance; }
+ inline void SetTolerance(double ff) { tolerance=ff;}
+ inline double GetTolerance(void) { return tolerance; }
- inline float GetSolverEps(void) { return solver_eps; }
- inline void SetSolverEps(float ff) { solver_eps=ff; }
+ inline double GetSolverEps(void) { return solver_eps; }
+ inline void SetSolverEps(double ff) { solver_eps=ff; }
inline int GetIterationLimit(void) { return max_iterations; }
inline void SetIterationLimit(int ii) { max_iterations=ii; }
inline int GetStability(void) { return its_to_stable_value; }
inline int GetRunCount(void) { return total_stability_iterations; }
- float GetAvgStability( void );
+ double GetAvgStability( void );
- void SetThetaOnGround(float ff);
- void SetPhiOnGround(float ff);
+ void SetThetaOnGround(double ff);
+ void SetPhiOnGround(double ff);
bool initTheta(void);
State state;
Control control;
- float state_value;
- float control_value;
+ double state_value;
+ double control_value;
- float control_min;
- float control_max;
+ double control_min;
+ double control_max;
- float tolerance;
+ double tolerance;
- float solver_eps;
+ double solver_eps;
- float state_convert;
- float control_convert;
+ double state_convert;
+ double control_convert;
int max_iterations;
void getControl(void);
void setControl(void);
- float computeHmgt(void);
+ double computeHmgt(void);
void Debug(void);
};
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-float FGTurboJet::Calculate(float dummy)
+double FGTurboJet::Calculate(double dummy)
{
ConsumeFuel();
return 0.0;
FGTurboJet(FGFDMExec* exec, FGConfigFile* Eng_cfg);
~FGTurboJet();
- float Calculate(float);
+ double Calculate(double);
private:
void Debug(void);
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-float FGTurboProp::Calculate(float dummy)
+double FGTurboProp::Calculate(double dummy)
{
ConsumeFuel();
return 0.0;
FGTurboProp(FGFDMExec* exec, FGConfigFile* Eng_cfg);
~FGTurboProp();
- float Calculate(float);
+ double Calculate(double);
private:
void Debug(void);
};
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-float FGTurboShaft::Calculate(float dummy) {
+double FGTurboShaft::Calculate(double dummy) {
ConsumeFuel();
return 0.0;
}
FGTurboShaft(FGFDMExec* exec, FGConfigFile* Eng_cfg);
~FGTurboShaft();
- float Calculate(float);
+ double Calculate(double);
private:
void Debug(void);
};
size++;
}
-void FGfdmSocket::Append(float item)
+void FGfdmSocket::Append(double item)
{
char s[25];
~FGfdmSocket();
void Send(void);
void Append(const char*);
- void Append(float);
+ void Append(double);
void Append(long);
void Clear(void);
FDMExec = new FGFDMExec();
- if (scripted) {
+ if (scripted) { // form jsbsim <scriptfile>
result = FDMExec->LoadScript(argv[1]);
if (!result) {
cerr << "Script file " << argv[1] << " was not successfully loaded" << endl;
exit(-1);
}
- } else {
- // result = FDMExec->LoadModel("aircraft", "engine", string(argv[1]));
- FGInitialCondition IC(FDMExec);
- result = IC.Load("aircraft","engine",string(argv[1]));
-
- if (!result) {
- cerr << "Aircraft file " << argv[1] << " was not found" << endl;
- exit(-1);
- }
- if ( ! FDMExec->GetState()->Reset("aircraft", string(argv[1]), string(argv[2]))) {
+ } else { // form jsbsim <acname> <resetfile>
+ if ( ! FDMExec->LoadModel("aircraft", "engine", string(argv[1]))) {
cerr << "JSBSim could not be started" << endl;
- exit(-1);
+ exit(-1);
}
+
+ FGInitialCondition IC(FDMExec);
+ if ( ! IC.Load("aircraft",string(argv[1]),string(argv[2]))) {
+ cerr << "Initialization unsuccessful" << endl;
+ exit(-1);
+ }
}
struct FGJSBBase::Message* msg;
virtual bool Run(void);
virtual void SetOutput(void);
- inline float GetOutput (void) {return Output;}
+ inline double GetOutput (void) {return Output;}
inline string GetName(void) {return Name;}
protected:
string Name;
int ID;
eParam InputIdx;
- float Input;
+ double Input;
string sOutputIdx;
eParam OutputIdx;
- float Output;
+ double Output;
bool IsOutput;
virtual void Debug(void);
};
AC_cfg(AC_cfg)
{
string token;
- float denom;
+ double denom;
Type = AC_cfg->GetValue("TYPE");
Name = AC_cfg->GetValue("NAME");
enum {eLag, eLeadLag, eOrder2, eWashout, eIntegrator, eUnknown} FilterType;
private:
- float dt;
- float ca;
- float cb;
- float cc;
- float cd;
- float ce;
- float C1;
- float C2;
- float C3;
- float C4;
- float C5;
- float C6;
- float PreviousInput1;
- float PreviousInput2;
- float PreviousOutput1;
- float PreviousOutput2;
+ double dt;
+ double ca;
+ double cb;
+ double cc;
+ double cd;
+ double ce;
+ double C1;
+ double C2;
+ double C3;
+ double C4;
+ double C5;
+ double C6;
+ double PreviousInput1;
+ double PreviousInput2;
+ double PreviousOutput1;
+ double PreviousOutput2;
FGConfigFile* AC_cfg;
void Debug(void);
};
FGFlaps::FGFlaps(FGFCS* fcs, FGConfigFile* AC_cfg) : FGFCSComponent(fcs),
AC_cfg(AC_cfg) {
string token;
- float tmpDetent;
- float tmpTime;
+ double tmpDetent;
+ double tmpTime;
Detents.clear();
TransitionTimes.clear();
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
bool FGFlaps::Run(void ) {
- float dt=fcs->GetState()->Getdt();
- float flap_transit_rate=0;
+ double dt=fcs->GetState()->Getdt();
+ double flap_transit_rate=0;
FGFCSComponent::Run(); // call the base class for initialization of Input
Flap_Handle = Input*Detents[NumDetents-1];
private:
FGConfigFile* AC_cfg;
- vector<float> Detents;
- vector<float> TransitionTimes;
+ vector<double> Detents;
+ vector<double> TransitionTimes;
int NumDetents,fi;
- float lastFlapHandle;
- float Flap_Handle;
- float Flap_Position;
+ double lastFlapHandle;
+ double Flap_Handle;
+ double Flap_Position;
bool Flaps_In_Transit;
void Debug(void);
bool FGGain::Run(void )
{
- float SchedGain = 1.0;
- float LookupVal = 0;
+ double SchedGain = 1.0;
+ double LookupVal = 0;
FGFCSComponent::Run(); // call the base class for initialization of Input
FGConfigFile* AC_cfg;
FGTable* Table;
FGState* State;
- float Gain;
- float Min, Max;
+ double Gain;
+ double Min, Max;
int Rows;
eParam ScheduledBy;
vector <eParam> InputIndices;
vector <int> InputTypes;
bool clip;
- float clipmin,clipmax;
+ double clipmin,clipmax;
void Debug(void);
};