}
//correct signs of drag and lift to wind axes convention
//positive forward, right, down
- if( Translation->Getqbar() > 0) {
+ if ( Translation->Getqbar() > 0) {
clsq = vFs(eLift) / (Aircraft->GetWingArea()*Translation->Getqbar());
clsq *= clsq;
}
axis = AC_cfg->GetValue("NAME");
AC_cfg->GetNextConfigLine();
while ((token = AC_cfg->GetValue()) != string("/AXIS")) {
- if( token == "COEFFICIENT" ) {
+ if ( token == "COEFFICIENT" ) {
ca.push_back( new FGCoefficient(FDMExec) );
ca.back()->Load(AC_cfg);
} else if ( token == "GROUP" ) {
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-void FGAerodynamics::bind(void){
-
+void FGAerodynamics::bind(void)
+{
PropertyManager->Tie("forces/fbx-aero-lbs", this,1,
&FGAerodynamics::GetForces);
PropertyManager->Tie("forces/fby-aero-lbs", this,2,
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-void FGAerodynamics::bindModel(void) {
-
+void FGAerodynamics::bindModel(void)
+{
unsigned i,j;
FGPropertyManager* node;
string axis_node_name;
node = PropertyManager->GetNode("aero/buildup",true);
- for(i=0;i<NAxes;i++) {
- node=node->GetNode( string(AxisNames[i]),true );
+ for (i=0;i<NAxes;i++) {
+ node = node->GetNode( string(AxisNames[i]),true );
for (j=0; j < Coeff[i].size(); j++) {
Coeff[i][j]->bind(node);
}
- node=(FGPropertyManager*)node->getParent();
+ node = (FGPropertyManager*)node->getParent();
}
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-void FGAerodynamics::unbind(void){
+void FGAerodynamics::unbind(void)
+{
unsigned i,j;
PropertyManager->Untie("forces/fbx-aero-lbs");
PropertyManager->Untie("forces/lod-norm");
PropertyManager->Untie("aero/cl-squared-norm");
- for( i=0; i<NAxes; i++ ) {
+ for ( i=0; i<NAxes; i++ ) {
for ( j=0; j < Coeff[i].size(); j++ ) {
Coeff[i][j]->unbind();
/** Gets the total aerodynamic force vector.
@return a force vector reference. */
FGColumnVector3& GetForces(void) {return vForces;}
- double GetForces(int n) const {return vForces(n);}
+ inline double GetForces(int n) const {return vForces(n);}
/** Gets the total aerodynamic moment vector.
@return a moment vector reference. */
FGColumnVector3& GetMoments(void) {return vMoments;}
- double GetMoments(int n) const {return vMoments(n);}
+ inline double GetMoments(int n) const {return vMoments(n);}
- FGColumnVector3& GetvLastFs(void) { return vLastFs; }
- double GetvLastFs(int axis) const { return vLastFs(axis); }
- FGColumnVector3& GetvFs(void) { return vFs; }
- double GetvFs(int axis) const { return vFs(axis); }
+ inline FGColumnVector3& GetvLastFs(void) { return vLastFs; }
+ inline double GetvLastFs(int axis) const { return vLastFs(axis); }
+ inline FGColumnVector3& GetvFs(void) { return vFs; }
+ inline double GetvFs(int axis) const { return vFs(axis); }
inline double GetLoD(void) const { return lod; }
inline double GetClSquared(void) const { return clsq; }
i = lastIndex-1;
while (htab[i] > altitude) i--;
}
- } else if (altitude > htab[lastIndex+1]){
- if (altitude >= htab[7]){
+ } else if (altitude > htab[lastIndex+1]) {
+ if (altitude >= htab[7]) {
i = 7;
altitude = htab[7];
} else {
i = lastIndex+1;
- while(htab[i+1] < altitude) i++;
+ while (htab[i+1] < altitude) i++;
}
}
// The radius R is calculated below in the vector vToEyePt.
vPilotAccel.InitMatrix();
- if( Translation->GetVt() > 1 ) {
+ if ( Translation->GetVt() > 1 ) {
vToEyePt = Aircraft->GetXYZep() - MassBalance->GetXYZcg();
vToEyePt *= inchtoft;
vPilotAccel = Aerodynamics->GetForces()
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+void FGAuxiliary::bind(void)
+{
+ PropertyManager->Tie("velocities/vc-fps", this,
+ &FGAuxiliary::GetVcalibratedFPS);
+ PropertyManager->Tie("velocities/vc-kts", this,
+ &FGAuxiliary::GetVcalibratedKTS);
+ PropertyManager->Tie("velocities/ve-fps", this,
+ &FGAuxiliary::GetVequivalentFPS);
+ PropertyManager->Tie("velocities/ve-kts", this,
+ &FGAuxiliary::GetVequivalentKTS);
+ PropertyManager->Tie("accelerations/a-pilot-x-ft_sec2", this,1,
+ &FGAuxiliary::GetPilotAccel);
+ PropertyManager->Tie("accelerations/a-pilot-y-ft_sec2", this,2,
+ &FGAuxiliary::GetPilotAccel);
+ PropertyManager->Tie("accelerations/a-pilot-z-ft_sec2", this,3,
+ &FGAuxiliary::GetPilotAccel);
+ PropertyManager->Tie("accelerations/n-pilot-x-norm", this,1,
+ &FGAuxiliary::GetNpilot);
+ PropertyManager->Tie("accelerations/n-pilot-y-norm", this,2,
+ &FGAuxiliary::GetNpilot);
+ PropertyManager->Tie("accelerations/n-pilot-z-norm", this,3,
+ &FGAuxiliary::GetNpilot);
+ PropertyManager->Tie("position/epa-rad", this,
+ &FGAuxiliary::GetEarthPositionAngle);
+ /* PropertyManager->Tie("atmosphere/headwind-fps", this,
+ &FGAuxiliary::GetHeadWind,
+ true);
+ PropertyManager->Tie("atmosphere/crosswind-fps", this,
+ &FGAuxiliary::GetCrossWind,
+ true); */
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+void FGAuxiliary::unbind(void)
+{
+ PropertyManager->Untie("velocities/vc-fps");
+ PropertyManager->Untie("velocities/vc-kts");
+ PropertyManager->Untie("velocities/ve-fps");
+ PropertyManager->Untie("velocities/ve-kts");
+ PropertyManager->Untie("accelerations/a-pilot-x-ft_sec2");
+ PropertyManager->Untie("accelerations/a-pilot-y-ft_sec2");
+ PropertyManager->Untie("accelerations/a-pilot-z-ft_sec2");
+ PropertyManager->Untie("accelerations/n-pilot-x-norm");
+ PropertyManager->Untie("accelerations/n-pilot-y-norm");
+ PropertyManager->Untie("accelerations/n-pilot-z-norm");
+ PropertyManager->Untie("position/epa-rad");
+ /* PropertyManager->Untie("atmosphere/headwind-fps");
+ PropertyManager->Untie("atmosphere/crosswind-fps"); */
+
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
void FGAuxiliary::GetState(void)
{
qbar = Translation->Getqbar();
}
}
-void FGAuxiliary::bind(void){
- PropertyManager->Tie("velocities/vc-fps", this,
- &FGAuxiliary::GetVcalibratedFPS);
- PropertyManager->Tie("velocities/vc-kts", this,
- &FGAuxiliary::GetVcalibratedKTS);
- PropertyManager->Tie("velocities/ve-fps", this,
- &FGAuxiliary::GetVequivalentFPS);
- PropertyManager->Tie("velocities/ve-kts", this,
- &FGAuxiliary::GetVequivalentKTS);
- PropertyManager->Tie("accelerations/a-pilot-x-ft_sec2", this,1,
- &FGAuxiliary::GetPilotAccel);
- PropertyManager->Tie("accelerations/a-pilot-y-ft_sec2", this,2,
- &FGAuxiliary::GetPilotAccel);
- PropertyManager->Tie("accelerations/a-pilot-z-ft_sec2", this,3,
- &FGAuxiliary::GetPilotAccel);
- PropertyManager->Tie("accelerations/n-pilot-x-norm", this,1,
- &FGAuxiliary::GetNpilot);
- PropertyManager->Tie("accelerations/n-pilot-y-norm", this,2,
- &FGAuxiliary::GetNpilot);
- PropertyManager->Tie("accelerations/n-pilot-z-norm", this,3,
- &FGAuxiliary::GetNpilot);
- PropertyManager->Tie("position/epa-rad", this,
- &FGAuxiliary::GetEarthPositionAngle);
- /* PropertyManager->Tie("atmosphere/headwind-fps", this,
- &FGAuxiliary::GetHeadWind,
- true);
- PropertyManager->Tie("atmosphere/crosswind-fps", this,
- &FGAuxiliary::GetCrossWind,
- true); */
-
-}
-
-void FGAuxiliary::unbind(void){
- PropertyManager->Untie("velocities/vc-fps");
- PropertyManager->Untie("velocities/vc-kts");
- PropertyManager->Untie("velocities/ve-fps");
- PropertyManager->Untie("velocities/ve-kts");
- PropertyManager->Untie("accelerations/a-pilot-x-ft_sec2");
- PropertyManager->Untie("accelerations/a-pilot-y-ft_sec2");
- PropertyManager->Untie("accelerations/a-pilot-z-ft_sec2");
- PropertyManager->Untie("accelerations/n-pilot-x-norm");
- PropertyManager->Untie("accelerations/n-pilot-y-norm");
- PropertyManager->Untie("accelerations/n-pilot-z-norm");
- PropertyManager->Untie("position/epa-rad");
- /* PropertyManager->Untie("atmosphere/headwind-fps");
- PropertyManager->Untie("atmosphere/crosswind-fps"); */
-
-}
FGCoefficient::FGCoefficient( FGFDMExec* fdex )
{
-
FDMExec = fdex;
State = FDMExec->GetState();
Table = 0;
PropertyManager = FDMExec->GetPropertyManager();
- bias=0;
- gain=1;
-
+ Table = (FGTable*)0L;
LookupR = LookupC = 0;
-
- totalValue = 0;
-
- if (debug_lvl & 2) cout << "Instantiated: FGCoefficient" << endl;
+ numInstances = 0;
+ rows = columns = 0;
+
+ StaticValue = 0.0;
+ totalValue = 0.0;
+ bias = 0.0;
+ gain = 1.0;
+
+ filename.erase();
+ description.erase();
+ name.erase();
+ method.erase();
+ multparms.erase();
+ multparmsRow.erase();
+ multparmsCol.erase();
+
+ Debug(0);
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FGCoefficient::~FGCoefficient()
{
if (Table) delete Table;
- if (debug_lvl & 2) cout << "Destroyed: FGCoefficient" << endl;
+ Debug(1);
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-void FGCoefficient::bind(FGPropertyManager *parent) {
+void FGCoefficient::bind(FGPropertyManager *parent)
+{
string mult;
unsigned i;
node=parent->GetNode(name,true);
node->SetString("description",description);
- if(LookupR) node->SetString("row-parm",LookupR->getName() );
- if(LookupC) node->SetString("column-parm",LookupC->getName() );
+ if (LookupR) node->SetString("row-parm",LookupR->getName() );
+ if (LookupC) node->SetString("column-parm",LookupC->getName() );
mult="";
- if(multipliers.size() == 0)
+ if (multipliers.size() == 0)
mult="none";
for (i=0; i<multipliers.size(); i++) {
mult += multipliers[i]->getName();
- if( i < multipliers.size()-1 ) mult += " ";
+ if ( i < multipliers.size()-1 ) mult += " ";
}
node->SetString("multipliers",mult);
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-void FGCoefficient::unbind(void) {
+void FGCoefficient::unbind(void)
+{
node->Untie("SD-norm");
node->Untie("value-lbs");
node->Untie("bias");
node->Untie("gain");
-}
+}
+
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// The bitmasked value choices are as follows:
// unset: In this case (the default) JSBSim would only print
virtual void bind(FGPropertyManager *parent);
virtual void unbind(void);
+protected:
+ FGFDMExec* FDMExec;
+ string description;
+ string name;
+ FGPropertyManager *node;
+
private:
enum Type {UNKNOWN, VALUE, VECTOR, TABLE, EQUATION};
int numInstances;
string filename;
- string description;
- string name;
string method;
string multparms;
string multparmsRow;
double totalValue;
double bias,gain;
FGPropertyManager *LookupR, *LookupC;
- FGPropertyManager *node;
MultVec multipliers;
int rows, columns;
double SD; // Actual stability derivative (or other coefficient) value
FGTable *Table;
- FGFDMExec* FDMExec;
FGState* State;
FGAtmosphere* Atmosphere;
FGFCS* FCS;
string LineComment;
bool CommentsOn;
bool Opened;
- unsigned int CurrentIndex;
+ unsigned int CurrentIndex;
void Debug(int from);
};
DoNormalize=true;
bind();
- for(i=0;i<=NForms;i++) {
+ for (i=0;i<=NForms;i++) {
DePos[i] = DaLPos[i] = DaRPos[i] = DrPos[i] = 0.0;
DfPos[i] = DsbPos[i] = DspPos[i] = 0.0;
}
- for(i=0;i<NNorm;i++) { ToNormalize[i]=-1;}
+ for (i=0;i<NNorm;i++) { ToNormalize[i]=-1;}
Debug(0);
}
for (i=0; i<MixturePos.size(); i++) MixturePos[i] = MixtureCmd[i];
for (i=0; i<PropAdvance.size(); i++) PropAdvance[i] = PropAdvanceCmd[i];
for (i=0; i<Components.size(); i++) Components[i]->Run();
- if(DoNormalize) Normalize();
+ if (DoNormalize) Normalize();
} else {
}
Name = Name + ":" + AC_cfg->GetValue("NAME");
if (debug_lvl > 0) cout << " Control System Name: " << Name << endl;
- if( AC_cfg->GetValue("NORMALIZE") == "FALSE") {
+ if ( AC_cfg->GetValue("NORMALIZE") == "FALSE") {
DoNormalize=false;
cout << " Automatic Control Surface Normalization Disabled" << endl;
}
}
//collect information for normalizing control surfaces
string nodeName;
- for(i=0;i<Components.size();i++) {
+ for (i=0;i<Components.size();i++) {
- if( (Components[i]->GetType() == "AEROSURFACE_SCALE"
+ if ( (Components[i]->GetType() == "AEROSURFACE_SCALE"
|| Components[i]->GetType() == "KINEMAT")
&& Components[i]->GetOutputNode() ) {
nodeName= Components[i]->GetOutputNode()->GetName();
- if( nodeName == "elevator-pos-rad" ) {
+ if ( nodeName == "elevator-pos-rad" ) {
ToNormalize[iDe]=i;
} else if ( nodeName == "left-aileron-pos-rad"
|| nodeName == "aileron-pos-rad" ) {
//those that are have an index >=0 in the ToNormalize array
//ToNormalize is filled in Load()
- if( ToNormalize[iDe] > -1 ) {
+ if ( ToNormalize[iDe] > -1 ) {
DePos[ofNorm] = Components[ToNormalize[iDe]]->GetOutputPct();
}
- if( ToNormalize[iDaL] > -1 ) {
+ if ( ToNormalize[iDaL] > -1 ) {
DaLPos[ofNorm] = Components[ToNormalize[iDaL]]->GetOutputPct();
}
- if( ToNormalize[iDaR] > -1 ) {
+ if ( ToNormalize[iDaR] > -1 ) {
DaRPos[ofNorm] = Components[ToNormalize[iDaR]]->GetOutputPct();
}
- if( ToNormalize[iDr] > -1 ) {
+ if ( ToNormalize[iDr] > -1 ) {
DrPos[ofNorm] = Components[ToNormalize[iDr]]->GetOutputPct();
}
- if( ToNormalize[iDsb] > -1 ) {
+ if ( ToNormalize[iDsb] > -1 ) {
DsbPos[ofNorm] = Components[ToNormalize[iDsb]]->GetOutputPct();
}
- if( ToNormalize[iDsp] > -1 ) {
+ if ( ToNormalize[iDsp] > -1 ) {
DspPos[ofNorm] = Components[ToNormalize[iDsp]]->GetOutputPct();
}
- if( ToNormalize[iDf] > -1 ) {
+ if ( ToNormalize[iDf] > -1 ) {
DfPos[ofNorm] = Components[ToNormalize[iDf]]->GetOutputPct();
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-void FGFCS::bind(void){
+void FGFCS::bind(void)
+{
PropertyManager->Tie("fcs/aileron-cmd-norm", this,
&FGFCS::GetDaCmd,
&FGFCS::SetDaCmd,
&FGFCS::SetGearPos,
true);
}
+
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-void FGFCS::bindModel(void){
+void FGFCS::bindModel(void)
+{
unsigned i;
- for(i=0;i<ThrottleCmd.size();i++) {
+
+ for (i=0; i<ThrottleCmd.size(); i++) {
PropertyManager->Tie("fcs/throttle-cmd-norm",this,i,
&FGFCS::GetThrottleCmd,
&FGFCS::SetThrottleCmd,
&FGFCS::GetThrottlePos,
&FGFCS::SetThrottlePos,
true );
- if( MixtureCmd.size() > i ) {
+ if ( MixtureCmd.size() > i ) {
PropertyManager->Tie("fcs/mixture-cmd-norm",this,i,
&FGFCS::GetMixtureCmd,
&FGFCS::SetMixtureCmd,
&FGFCS::SetMixturePos,
true );
}
- if( PropAdvanceCmd.size() > i ) {
+ if ( PropAdvanceCmd.size() > i ) {
PropertyManager->Tie("fcs/advance-cmd-norm",this,i,
&FGFCS::GetPropAdvanceCmd,
&FGFCS::SetPropAdvanceCmd,
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-void FGFCS::unbind(void){
+void FGFCS::unbind(void)
+{
PropertyManager->Untie("fcs/aileron-cmd-norm");
PropertyManager->Untie("fcs/elevator-cmd-norm");
PropertyManager->Untie("fcs/rudder-cmd-norm");
PropertyManager->Untie("gear/gear-pos-norm");
}
-
-
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// The bitmasked value choices are as follows:
// unset: In this case (the default) JSBSim would only print
if (!Aircraft->InitModel()) {
cerr << fgred << "Aircraft model init failed" << fgdef << endl;
Error+=128;}
- if (!Translation->InitModel()){
+ if (!Translation->InitModel()) {
cerr << fgred << "Translation model init failed" << fgdef << endl;
Error+=256;}
if (!Rotation->InitModel()) {
/** Encapsulates the JSBSim simulation executive.
@author Jon S. Berndt
@version $Id$
+ @see <a href="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/jsbsim/JSBSim/FGFDMExec.h?rev=HEAD&content-type=text/vnd.viewcvs-markup">
+ Header File </a>
+ @see <a href="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/jsbsim/JSBSim/FGFDMExec.cpp?rev=HEAD&content-type=text/vnd.viewcvs-markup">
+ Source File </a>
@doc This class is the interface class through which all other simulation classes
are instantiated, initialized, and run. When integrated with FlightGear (or
totalValue += sum[i]->TotalValue();
SDtotal += sum[i]->GetSD();
}
- //cout << totalValue << " " << FGCoefficient::TotalValue() << endl;
totalValue *= FGCoefficient::TotalValue();
SDtotal *= FGCoefficient::GetSD();
Debug(2);
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-void FGFactorGroup::bind(FGPropertyManager* parent) {
-
- cout << "In FGFactorGroup::bind" << endl;
- cout << parent->getName() << endl;
+void FGFactorGroup::bind(FGPropertyManager* parent)
+{
unsigned i;
node=parent->GetNode(name,true);
- cout << node->getName() << endl;
node->SetString("description",description);
FGCoefficient::bind(node);
for (i=0; i < sum.size(); i++) {
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-void FGFactorGroup::unbind(void) {
+void FGFactorGroup::unbind(void)
+{
unsigned i;
FGCoefficient::unbind();
CLASS DECLARATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-class FGFactorGroup: public FGCoefficient {
- public:
- FGFactorGroup(FGFDMExec* fdmex);
- ~FGFactorGroup();
-
- bool Load(FGConfigFile *AC_cfg);
- double TotalValue(void);
- inline double GetValue(void) const { return totalValue; }
- //string GetCoefficientStrings(void);
- //string GetCoefficientValues(void);
- inline double GetSD(void) { return SDtotal; }
- inline double GetFactorSD(void) { return FGCoefficient::GetSD(); }
-
- void bind(FGPropertyManager* parent);
- void unbind(void);
- private:
- FGFDMExec *FDMExec;
- string name;
- string description;
- typedef vector<FGCoefficient*> CoeffArray;
- CoeffArray sum;
- double SDtotal;
- double totalValue;
- FGPropertyManager* node;
- void Debug(int from);
+class FGFactorGroup: public FGCoefficient
+{
+public:
+ FGFactorGroup(FGFDMExec* fdmex);
+ ~FGFactorGroup();
+
+ bool Load(FGConfigFile *AC_cfg);
+ double TotalValue(void);
+ inline double GetValue(void) const { return totalValue; }
+ //string GetCoefficientStrings(void);
+ //string GetCoefficientValues(void);
+ inline double GetSD(void) { return SDtotal; }
+ inline double GetFactorSD(void) { return FGCoefficient::GetSD(); }
+
+ void bind(FGPropertyManager* parent);
+ void unbind(void);
+
+private:
+ typedef vector<FGCoefficient*> CoeffArray;
+ CoeffArray sum;
+ double SDtotal;
+ double totalValue;
+ void Debug(int from);
};
#endif
return GroundReactionValues;
}
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+void FGGroundReactions::bind(void)
+{
+ PropertyManager->Tie("gear/num-units", this,
+ &FGGroundReactions::GetNumGearUnits);
+ PropertyManager->Tie("moments/l-gear-lbsft", this,1,
+ &FGGroundReactions::GetMoments);
+ PropertyManager->Tie("moments/m-gear-lbsft", this,2,
+ &FGGroundReactions::GetMoments);
+ PropertyManager->Tie("moments/n-gear-lbsft", this,3,
+ &FGGroundReactions::GetMoments);
+ PropertyManager->Tie("forces/fbx-gear-lbs", this,1,
+ &FGGroundReactions::GetForces);
+ PropertyManager->Tie("forces/fby-gear-lbs", this,2,
+ &FGGroundReactions::GetForces);
+ PropertyManager->Tie("forces/fbz-gear-lbs", this,3,
+ &FGGroundReactions::GetForces);
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+void FGGroundReactions::unbind(void)
+{
+ PropertyManager->Untie("gear/num-units");
+ PropertyManager->Untie("moments/l-gear-lbsft");
+ PropertyManager->Untie("moments/m-gear-lbsft");
+ PropertyManager->Untie("moments/n-gear-lbsft");
+ PropertyManager->Untie("forces/fbx-gear-lbs");
+ PropertyManager->Untie("forces/fby-gear-lbs");
+ PropertyManager->Untie("forces/fbz-gear-lbs");
+}
+
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// The bitmasked value choices are as follows:
// unset: In this case (the default) JSBSim would only print
}
}
-void FGGroundReactions::bind(void){
-
- PropertyManager->Tie("gear/num-units", this,
- &FGGroundReactions::GetNumGearUnits);
- PropertyManager->Tie("moments/l-gear-lbsft", this,1,
- &FGGroundReactions::GetMoments);
- PropertyManager->Tie("moments/m-gear-lbsft", this,2,
- &FGGroundReactions::GetMoments);
- PropertyManager->Tie("moments/n-gear-lbsft", this,3,
- &FGGroundReactions::GetMoments);
- PropertyManager->Tie("forces/fbx-gear-lbs", this,1,
- &FGGroundReactions::GetForces);
- PropertyManager->Tie("forces/fby-gear-lbs", this,2,
- &FGGroundReactions::GetForces);
- PropertyManager->Tie("forces/fbz-gear-lbs", this,3,
- &FGGroundReactions::GetForces);
-}
-
-void FGGroundReactions::unbind(void){
- PropertyManager->Untie("gear/num-units");
- PropertyManager->Untie("moments/l-gear-lbsft");
- PropertyManager->Untie("moments/m-gear-lbsft");
- PropertyManager->Untie("moments/n-gear-lbsft");
- PropertyManager->Untie("forces/fbx-gear-lbs");
- PropertyManager->Untie("forces/fby-gear-lbs");
- PropertyManager->Untie("forces/fbz-gear-lbs");
-}
return true;
}
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+void FGInertial::bind(void)
+{
+ PropertyManager->Tie("forces/fbx-inertial-lbs", this,1,
+ &FGInertial::GetForces);
+ PropertyManager->Tie("forces/fby-inertial-lbs", this,2,
+ &FGInertial::GetForces);
+ PropertyManager->Tie("forces/fbz-inertial-lbs", this,3,
+ &FGInertial::GetForces);
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+void FGInertial::unbind(void)
+{
+ PropertyManager->Untie("forces/fbx-inertial-lbs");
+ PropertyManager->Untie("forces/fby-inertial-lbs");
+ PropertyManager->Untie("forces/fbz-inertial-lbs");
+}
+
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// The bitmasked value choices are as follows:
// unset: In this case (the default) JSBSim would only print
}
}
-void FGInertial::bind(void){
- PropertyManager->Tie("forces/fbx-inertial-lbs", this,1,
- &FGInertial::GetForces);
- PropertyManager->Tie("forces/fby-inertial-lbs", this,2,
- &FGInertial::GetForces);
- PropertyManager->Tie("forces/fbz-inertial-lbs", this,3,
- &FGInertial::GetForces);
-}
-
-void FGInertial::unbind(void){
- PropertyManager->Untie("forces/fbx-inertial-lbs");
- PropertyManager->Untie("forces/fby-inertial-lbs");
- PropertyManager->Untie("forces/fbz-inertial-lbs");
-}
return I;
}
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+void FGMassBalance::bind(void)
+{
+ PropertyManager->Tie("inertia/mass-slugs", this,
+ &FGMassBalance::GetMass);
+ PropertyManager->Tie("inertia/weight-lbs", this,
+ &FGMassBalance::GetWeight);
+ PropertyManager->Tie("inertia/ixx-lbsft2", this,
+ &FGMassBalance::GetIxx);
+ PropertyManager->Tie("inertia/iyy-lbsft2", this,
+ &FGMassBalance::GetIyy);
+ PropertyManager->Tie("inertia/izz-lbsft2", this,
+ &FGMassBalance::GetIzz);
+ PropertyManager->Tie("inertia/ixy-lbsft2", this,
+ &FGMassBalance::GetIxy);
+ PropertyManager->Tie("inertia/ixz-lbsft2", this,
+ &FGMassBalance::GetIxz);
+ PropertyManager->Tie("inertia/cg-x-ft", this,1,
+ &FGMassBalance::GetXYZcg);
+ PropertyManager->Tie("inertia/cg-y-ft", this,2,
+ &FGMassBalance::GetXYZcg);
+ PropertyManager->Tie("inertia/cg-z-ft", this,3,
+ &FGMassBalance::GetXYZcg);
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+void FGMassBalance::unbind(void)
+{
+ PropertyManager->Untie("inertia/mass-slugs");
+ PropertyManager->Untie("inertia/weight-lbs");
+ PropertyManager->Untie("inertia/ixx-lbsft2");
+ PropertyManager->Untie("inertia/iyy-lbsft2");
+ PropertyManager->Untie("inertia/izz-lbsft2");
+ PropertyManager->Untie("inertia/ixy-lbsft2");
+ PropertyManager->Untie("inertia/ixz-lbsft2");
+ PropertyManager->Untie("inertia/cg-x-ft");
+ PropertyManager->Untie("inertia/cg-y-ft");
+ PropertyManager->Untie("inertia/cg-z-ft");
+}
+
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// The bitmasked value choices are as follows:
// unset: In this case (the default) JSBSim would only print
}
}
-void FGMassBalance::bind(void){
- PropertyManager->Tie("inertia/mass-slugs", this,
- &FGMassBalance::GetMass);
- PropertyManager->Tie("inertia/weight-lbs", this,
- &FGMassBalance::GetWeight);
- PropertyManager->Tie("inertia/ixx-lbsft2", this,
- &FGMassBalance::GetIxx);
- PropertyManager->Tie("inertia/iyy-lbsft2", this,
- &FGMassBalance::GetIyy);
- PropertyManager->Tie("inertia/izz-lbsft2", this,
- &FGMassBalance::GetIzz);
- PropertyManager->Tie("inertia/ixy-lbsft2", this,
- &FGMassBalance::GetIxy);
- PropertyManager->Tie("inertia/ixz-lbsft2", this,
- &FGMassBalance::GetIxz);
- PropertyManager->Tie("inertia/cg-x-ft", this,1,
- &FGMassBalance::GetXYZcg);
- PropertyManager->Tie("inertia/cg-y-ft", this,2,
- &FGMassBalance::GetXYZcg);
- PropertyManager->Tie("inertia/cg-z-ft", this,3,
- &FGMassBalance::GetXYZcg);
-}
-
-void FGMassBalance::unbind(void){
- PropertyManager->Untie("inertia/mass-slugs");
- PropertyManager->Untie("inertia/weight-lbs");
- PropertyManager->Untie("inertia/ixx-lbsft2");
- PropertyManager->Untie("inertia/iyy-lbsft2");
- PropertyManager->Untie("inertia/izz-lbsft2");
- PropertyManager->Untie("inertia/ixy-lbsft2");
- PropertyManager->Untie("inertia/ixz-lbsft2");
- PropertyManager->Untie("inertia/cg-x-ft");
- PropertyManager->Untie("inertia/cg-y-ft");
- PropertyManager->Untie("inertia/cg-z-ft");
-}
{
FGMatrix33 Quot;
- if( scalar != 0 ) {
+ if ( scalar != 0 ) {
double tmp = 1.0/scalar;
Quot(1,1) = data[1][1] * tmp;
Quot(1,2) = data[1][2] * tmp;
void FGMatrix33::operator/=(const double scalar)
{
- if( scalar != 0 ) {
+ if ( scalar != 0 ) {
double tmp = 1.0/scalar;
data[1][1] *= tmp;
data[1][2] *= tmp;
//must be brought up now.
PropertyManager = FDMExec->GetPropertyManager();
-
exe_ctr = 1;
if (debug_lvl & 2) cout << " FGModel Base Class" << endl;
/** Base class for all scheduled JSBSim models
@author Jon S. Berndt
+ @see <a href="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/jsbsim/JSBSim/FGModel.h?rev=HEAD&content-type=text/vnd.viewcvs-markup">
+ Header File </a>
+ @see <a href="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/jsbsim/JSBSim/FGModel.cpp?rev=HEAD&content-type=text/vnd.viewcvs-markup">
+ Source File </a>
*/
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Type = otSocket;
} else if (type == "TERMINAL") {
Type = otTerminal;
- } else if (type != string("NONE")){
+ } else if (type != string("NONE")) {
Type = otUnknown;
cerr << "Unknown type of output specified in config file" << endl;
}
//Assume lean limit at 22 AFR for now - thats a thi of 0.668
//This might be a bit generous, but since there's currently no audiable warning of impending
//cutout in the form of misfiring and/or rough running its probably reasonable for now.
- if(equivalence_ratio < 0.668)
+ if (equivalence_ratio < 0.668)
Running = false;
doEnginePower();
if ((!Running) && (spark) && (fuel)) {
// start the engine if revs high enough
- if(Cranking) {
+ if (Cranking) {
if ((RPM > 450) && (crank_counter > 175)) {
//Add a little delay to startup on the starter
Running = true;
void FGPiston::doEnginePower(void)
{
ManifoldPressure_inHg *= p_amb / p_amb_sea_level;
- if(Running) {
+ if (Running) {
double ManXRPM = ManifoldPressure_inHg * RPM;
// FIXME: this needs to be generalized
Percentage_Power = (6e-9 * ManXRPM * ManXRPM) + (8e-4 * ManXRPM) - 1.0;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-// The bitmasked value choices are as follows:
-// unset: In this case (the default) JSBSim would only print
-// out the normally expected messages, essentially echoing
-// the config files as they are read. If the environment
-// variable is not set, debug_lvl is set to 1 internally
-// 0: This requests JSBSim not to output any messages
-// whatsoever.
-// 1: This value explicity requests the normal JSBSim
-// startup messages
-// 2: This value asks for a message to be printed out when
-// a class is instantiated
-// 4: When this value is set, a message is displayed when a
-// FGModel object executes its Run() method
-// 8: When this value is set, various runtime state variables
-// are printed out periodically
-// 16: When set various parameters are sanity checked and
-// a message is printed out when they go out of bounds
-void FGPosition::Debug(int from)
+void FGPosition::bind(void)
{
- if (debug_lvl <= 0) return;
-
- if (debug_lvl & 1) { // Standard console startup message output
- if (from == 0) { // Constructor
-
- }
- }
- if (debug_lvl & 2 ) { // Instantiation/Destruction notification
- if (from == 0) cout << "Instantiated: FGPosition" << endl;
- if (from == 1) cout << "Destroyed: FGPosition" << endl;
- }
- if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
- }
- if (debug_lvl & 8 ) { // Runtime state variables
- }
- if (debug_lvl & 16) { // Sanity checking
- }
- if (debug_lvl & 64) {
- if (from == 0) { // Constructor
- cout << IdSrc << endl;
- cout << IdHdr << endl;
- }
- }
-}
-
-void FGPosition::bind(void){
PropertyManager->Tie("velocities/v-north-fps", this,
&FGPosition::GetVn);
PropertyManager->Tie("velocities/v-east-fps", this,
&FGPosition::GetHOverBMAC);
}
-void FGPosition::unbind(void){
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+void FGPosition::unbind(void)
+{
PropertyManager->Untie("velocities/v-north-fps");
PropertyManager->Untie("velocities/v-east-fps");
PropertyManager->Untie("velocities/v-down-fps");
PropertyManager->Untie("aero/h_b-cg-ft");
PropertyManager->Untie("aero/h_b-mac-ft");
}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+// The bitmasked value choices are as follows:
+// unset: In this case (the default) JSBSim would only print
+// out the normally expected messages, essentially echoing
+// the config files as they are read. If the environment
+// variable is not set, debug_lvl is set to 1 internally
+// 0: This requests JSBSim not to output any messages
+// whatsoever.
+// 1: This value explicity requests the normal JSBSim
+// startup messages
+// 2: This value asks for a message to be printed out when
+// a class is instantiated
+// 4: When this value is set, a message is displayed when a
+// FGModel object executes its Run() method
+// 8: When this value is set, various runtime state variables
+// are printed out periodically
+// 16: When set various parameters are sanity checked and
+// a message is printed out when they go out of bounds
+
+void FGPosition::Debug(int from)
+{
+ if (debug_lvl <= 0) return;
+
+ if (debug_lvl & 1) { // Standard console startup message output
+ if (from == 0) { // Constructor
+
+ }
+ }
+ if (debug_lvl & 2 ) { // Instantiation/Destruction notification
+ if (from == 0) cout << "Instantiated: FGPosition" << endl;
+ if (from == 1) cout << "Destroyed: FGPosition" << endl;
+ }
+ if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
+ }
+ if (debug_lvl & 8 ) { // Runtime state variables
+ }
+ if (debug_lvl & 16) { // Sanity checking
+ }
+ if (debug_lvl & 64) {
+ if (from == 0) { // Constructor
+ cout << IdSrc << endl;
+ cout << IdHdr << endl;
+ }
+ }
+}
+
PowerAvailable = Engines[i]->Calculate(Thrusters[i]->GetPowerRequired());
lastThrust = currentThrust;
currentThrust = Thrusters[i]->Calculate(PowerAvailable);
- if(fabs(lastThrust-currentThrust) < 0.0001) {
+ if (fabs(lastThrust-currentThrust) < 0.0001) {
steady_count++;
- if(steady_count > 120) { steady=true; }
+ if (steady_count > 120) { steady=true; }
} else {
steady_count=0;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-void FGPropulsion::bind(void){
+void FGPropulsion::bind(void)
+{
/* PropertyManager->Tie("propulsion/num-engines", this,
&FGPropulsion::GetNumEngines);
PropertyManager->Tie("propulsion/num-tanks", this,
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-void FGPropulsion::unbind(void){
+void FGPropulsion::unbind(void)
+{
/* PropertyManager->Untie("propulsion/num-engines");
PropertyManager->Untie("propulsion/num-tanks"); */
PropertyManager->Untie("propulsion/num-sel-fuel-tanks");
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-// The bitmasked value choices are as follows:
-// unset: In this case (the default) JSBSim would only print
-// out the normally expected messages, essentially echoing
-// the config files as they are read. If the environment
-// variable is not set, debug_lvl is set to 1 internally
-// 0: This requests JSBSim not to output any messages
-// whatsoever.
-// 1: This value explicity requests the normal JSBSim
-// startup messages
-// 2: This value asks for a message to be printed out when
-// a class is instantiated
-// 4: When this value is set, a message is displayed when a
-// FGModel object executes its Run() method
-// 8: When this value is set, various runtime state variables
-// are printed out periodically
-// 16: When set various parameters are sanity checked and
-// a message is printed out when they go out of bounds
-void FGRotation::Debug(int from)
+void FGRotation::bind(void)
{
- if (debug_lvl <= 0) return;
-
- if (debug_lvl & 1) { // Standard console startup message output
- if (from == 0) { // Constructor
-
- }
- }
- if (debug_lvl & 2 ) { // Instantiation/Destruction notification
- if (from == 0) cout << "Instantiated: FGRotation" << endl;
- if (from == 1) cout << "Destroyed: FGRotation" << endl;
- }
- if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
- }
- if (debug_lvl & 8 ) { // Runtime state variables
- }
- if (debug_lvl & 16) { // Sanity check variables
- if (from == 2) {
- if (fabs(vPQR(eP)) > 100)
- cout << "FGRotation::P (Roll Rate) out of bounds: " << vPQR(eP) << endl;
- if (fabs(vPQR(eQ)) > 100)
- cout << "FGRotation::Q (Pitch Rate) out of bounds: " << vPQR(eQ) << endl;
- if (fabs(vPQR(eR)) > 100)
- cout << "FGRotation::R (Yaw Rate) out of bounds: " << vPQR(eR) << endl;
- }
- }
- if (debug_lvl & 64) {
- if (from == 0) { // Constructor
- cout << IdSrc << endl;
- cout << IdHdr << endl;
- }
- }
-}
-
-void FGRotation::bind(void){
PropertyManager->Tie("velocities/p-rad_sec", this,1,
&FGRotation::GetPQR);
PropertyManager->Tie("velocities/q-rad_sec", this,2,
&FGRotation::Getpsi);
}
-void FGRotation::unbind(void){
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+void FGRotation::unbind(void)
+{
PropertyManager->Untie("velocities/p-rad_sec");
PropertyManager->Untie("velocities/q-rad_sec");
PropertyManager->Untie("velocities/r-rad_sec");
PropertyManager->Untie("attitude/theta-rad");
PropertyManager->Untie("attitude/psi-true-rad");
}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+// The bitmasked value choices are as follows:
+// unset: In this case (the default) JSBSim would only print
+// out the normally expected messages, essentially echoing
+// the config files as they are read. If the environment
+// variable is not set, debug_lvl is set to 1 internally
+// 0: This requests JSBSim not to output any messages
+// whatsoever.
+// 1: This value explicity requests the normal JSBSim
+// startup messages
+// 2: This value asks for a message to be printed out when
+// a class is instantiated
+// 4: When this value is set, a message is displayed when a
+// FGModel object executes its Run() method
+// 8: When this value is set, various runtime state variables
+// are printed out periodically
+// 16: When set various parameters are sanity checked and
+// a message is printed out when they go out of bounds
+
+void FGRotation::Debug(int from)
+{
+ if (debug_lvl <= 0) return;
+
+ if (debug_lvl & 1) { // Standard console startup message output
+ if (from == 0) { // Constructor
+
+ }
+ }
+ if (debug_lvl & 2 ) { // Instantiation/Destruction notification
+ if (from == 0) cout << "Instantiated: FGRotation" << endl;
+ if (from == 1) cout << "Destroyed: FGRotation" << endl;
+ }
+ if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
+ }
+ if (debug_lvl & 8 ) { // Runtime state variables
+ }
+ if (debug_lvl & 16) { // Sanity check variables
+ if (from == 2) {
+ if (fabs(vPQR(eP)) > 100)
+ cout << "FGRotation::P (Roll Rate) out of bounds: " << vPQR(eP) << endl;
+ if (fabs(vPQR(eQ)) > 100)
+ cout << "FGRotation::Q (Pitch Rate) out of bounds: " << vPQR(eQ) << endl;
+ if (fabs(vPQR(eR)) > 100)
+ cout << "FGRotation::R (Yaw Rate) out of bounds: " << vPQR(eR) << endl;
+ }
+ }
+ if (debug_lvl & 64) {
+ if (from == 0) { // Constructor
+ cout << IdSrc << endl;
+ cout << IdHdr << endl;
+ }
+ }
+}
+
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-void FGState::Initialize(FGInitialCondition *FGIC) {
-
+void FGState::Initialize(FGInitialCondition *FGIC)
+{
double tht,psi,phi;
double U, V, W, h;
double latitude, longitude;
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-void FGState::InitMatrices(double phi, double tht, double psi) {
+void FGState::InitMatrices(double phi, double tht, double psi)
+{
double thtd2, psid2, phid2;
double Sthtd2, Spsid2, Sphid2;
double Cthtd2, Cpsid2, Cphid2;
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-void FGState::CalcMatrices(void) {
+void FGState::CalcMatrices(void)
+{
double Q0Q0, Q1Q1, Q2Q2, Q3Q3;
double Q0Q1, Q0Q2, Q0Q3, Q1Q2;
double Q1Q3, Q2Q3;
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-void FGState::IntegrateQuat(FGColumnVector3 vPQR, int rate) {
+void FGState::IntegrateQuat(FGColumnVector3 vPQR, int rate)
+{
vQdot(1) = -0.5*(vQtrn(2)*vPQR(eP) + vQtrn(3)*vPQR(eQ) + vQtrn(4)*vPQR(eR));
vQdot(2) = 0.5*(vQtrn(1)*vPQR(eP) + vQtrn(3)*vPQR(eR) - vQtrn(4)*vPQR(eQ));
vQdot(3) = 0.5*(vQtrn(1)*vPQR(eQ) + vQtrn(4)*vPQR(eP) - vQtrn(2)*vPQR(eR));
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-FGColumnVector3& FGState::CalcEuler(void) {
+FGColumnVector3& FGState::CalcEuler(void)
+{
if (mTl2b(3,3) == 0.0) mTl2b(3,3) = 0.0000001;
if (mTl2b(1,1) == 0.0) mTl2b(1,1) = 0.0000001;
FDMExec->GetMassBalance()->GetXYZcg(2),
FDMExec->GetMassBalance()->GetXYZcg(3));
cout << out;
- if( FCS->GetDfPos() <= 0.01)
+ if ( FCS->GetDfPos() <= 0.01)
snprintf(flap,10,"Up");
else
snprintf(flap,10,"%2.0f",FCS->GetDfPos());
- if(FCS->GetGearPos() < 0.01)
+
+ if (FCS->GetGearPos() < 0.01)
snprintf(gear,12,"Up");
- else if(FCS->GetGearPos() > 0.99)
+ else if (FCS->GetGearPos() > 0.99)
snprintf(gear,12,"Down");
else
- snprintf(gear,12,"In Transit");
+ snprintf(gear,12,"In Transit");
+
snprintf(out,80, " Flaps: %3s Gear: %12s\n",flap,gear);
cout << out;
snprintf(out,80, " Speed: %4.0f KCAS Mach: %5.2f\n",
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-void FGState::InitPropertyMaps(void) {
+void FGState::InitPropertyMaps(void)
+{
ParamNameToProp[ "FG_TIME" ]="sim-time-sec";
ParamNameToProp[ "FG_QBAR" ]="aero/qbar-psf";
ParamNameToProp[ "FG_WINGAREA" ]="metrics/Sw-sqft";
ParamNameToProp[ "FG_VBARV" ]="metrics/vbarv-norm";
ParamNameToProp[ "FG_GEAR_CMD" ]="gear/gear-cmd-norm";
ParamNameToProp[ "FG_GEAR_POS" ]="gear/gear-pos-norm";
-
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-void FGState::bind(void) {
+void FGState::bind(void)
+{
PropertyManager->Tie("sim-time-sec",this,
&FGState::Getsim_time);
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-void FGState::unbind(void) {
+void FGState::unbind(void)
+{
PropertyManager->Untie("sim-time-sec");
}
-
-
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// The bitmasked value choices are as follows:
// unset: In this case (the default) JSBSim would only print
}
}
-
int r;
for (r=1; r<=nRows; r++) if (Data[r][0] >= key) break;
- r = r < 2 ? 2 : (r > nRows ? nRows : r);
+ r = Clamp(2, r, nRows);
+ key = Clamp(Data[1][0], key, Data[nRows][0]);
// make sure denominator below does not go to zero.
int r, c;
for (r=1;r<=nRows;r++) if (Data[r][0] >= rowKey) break;
- for (c=1;c<=nCols;c++) if (Data[0][c] >= colKey) break;
+ r = Clamp(2, r, nRows);
+ rowKey = Clamp(Data[1][0], rowKey, Data[nRows][0]);
- c = c < 2 ? 2 : (c > nCols ? nCols : c);
- r = r < 2 ? 2 : (r > nRows ? nRows : r);
+ for (c=1;c<=nCols;c++) if (Data[0][c] >= colKey) break;
+ c = Clamp(2, c, nCols);
+ colKey = Clamp(Data[0][1], colKey, Data[0][nCols]);
rFactor = (rowKey - Data[r-1][0]) / (Data[r][0] - Data[r-1][0]);
cFactor = (colKey - Data[0][c-1]) / (Data[0][c] - Data[0][c-1]);
void operator<<(FGConfigFile&);
FGTable& operator<<(const double n);
FGTable& operator<<(const int n);
-// FGTable& operator<<(const double n);
inline double GetElement(int r, int c) {return Data[r][c];}
void Print(void);
-
+ template <class T> T Clamp(T lower, T value, T upper)
+ {return value < lower ? lower : (value > upper ? upper : value);}
+
private:
enum type {tt1D, tt2D} Type;
double** Data;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-// The bitmasked value choices are as follows:
-// unset: In this case (the default) JSBSim would only print
-// out the normally expected messages, essentially echoing
-// the config files as they are read. If the environment
-// variable is not set, debug_lvl is set to 1 internally
-// 0: This requests JSBSim not to output any messages
-// whatsoever.
-// 1: This value explicity requests the normal JSBSim
-// startup messages
-// 2: This value asks for a message to be printed out when
-// a class is instantiated
-// 4: When this value is set, a message is displayed when a
-// FGModel object executes its Run() method
-// 8: When this value is set, various runtime state variables
-// are printed out periodically
-// 16: When set various parameters are sanity checked and
-// a message is printed out when they go out of bounds
-void FGTranslation::Debug(int from)
+void FGTranslation::bind(void)
{
- if (debug_lvl <= 0) return;
-
- if (debug_lvl & 1) { // Standard console startup message output
- if (from == 0) { // Constructor
-
- }
- }
- if (debug_lvl & 2 ) { // Instantiation/Destruction notification
- if (from == 0) cout << "Instantiated: FGTranslation" << endl;
- if (from == 1) cout << "Destroyed: FGTranslation" << endl;
- }
- if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
- }
- if (debug_lvl & 8 ) { // Runtime state variables
- }
- if (debug_lvl & 16) { // Sanity checking
- if (fabs(vUVW(eU)) > 1e6)
- cout << "FGTranslation::U velocity out of bounds: " << vUVW(eU) << endl;
- if (fabs(vUVW(eV)) > 1e6)
- cout << "FGTranslation::V velocity out of bounds: " << vUVW(eV) << endl;
- if (fabs(vUVW(eW)) > 1e6)
- cout << "FGTranslation::W velocity out of bounds: " << vUVW(eW) << endl;
- if (fabs(vUVWdot(eU)) > 1e4)
- cout << "FGTranslation::U acceleration out of bounds: " << vUVWdot(eU) << endl;
- if (fabs(vUVWdot(eV)) > 1e4)
- cout << "FGTranslation::V acceleration out of bounds: " << vUVWdot(eV) << endl;
- if (fabs(vUVWdot(eW)) > 1e4)
- cout << "FGTranslation::W acceleration out of bounds: " << vUVWdot(eW) << endl;
- if (Mach > 100 || Mach < 0.00)
- cout << "FGTranslation::Mach is out of bounds: " << Mach << endl;
- if (qbar > 1e6 || qbar < 0.00)
- cout << "FGTranslation::qbar is out of bounds: " << qbar << endl;
- }
- if (debug_lvl & 64) {
- if (from == 0) { // Constructor
- cout << IdSrc << endl;
- cout << IdHdr << endl;
- }
- }
-}
-
-//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-void FGTranslation::bind(void){
PropertyManager->Tie("velocities/u-fps", this,1,
&FGTranslation::GetUVW /*,
&FGTranslation::SetUVW,
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-void FGTranslation::unbind(void){
+void FGTranslation::unbind(void)
+{
PropertyManager->Untie("velocities/u-fps");
PropertyManager->Untie("velocities/v-fps");
PropertyManager->Untie("velocities/w-fps");
PropertyManager->Untie("aero/alphadot-rad_sec");
PropertyManager->Untie("aero/betadot-rad_sec");
}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+// The bitmasked value choices are as follows:
+// unset: In this case (the default) JSBSim would only print
+// out the normally expected messages, essentially echoing
+// the config files as they are read. If the environment
+// variable is not set, debug_lvl is set to 1 internally
+// 0: This requests JSBSim not to output any messages
+// whatsoever.
+// 1: This value explicity requests the normal JSBSim
+// startup messages
+// 2: This value asks for a message to be printed out when
+// a class is instantiated
+// 4: When this value is set, a message is displayed when a
+// FGModel object executes its Run() method
+// 8: When this value is set, various runtime state variables
+// are printed out periodically
+// 16: When set various parameters are sanity checked and
+// a message is printed out when they go out of bounds
+
+void FGTranslation::Debug(int from)
+{
+ if (debug_lvl <= 0) return;
+
+ if (debug_lvl & 1) { // Standard console startup message output
+ if (from == 0) { // Constructor
+
+ }
+ }
+ if (debug_lvl & 2 ) { // Instantiation/Destruction notification
+ if (from == 0) cout << "Instantiated: FGTranslation" << endl;
+ if (from == 1) cout << "Destroyed: FGTranslation" << endl;
+ }
+ if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
+ }
+ if (debug_lvl & 8 ) { // Runtime state variables
+ }
+ if (debug_lvl & 16) { // Sanity checking
+ if (fabs(vUVW(eU)) > 1e6)
+ cout << "FGTranslation::U velocity out of bounds: " << vUVW(eU) << endl;
+ if (fabs(vUVW(eV)) > 1e6)
+ cout << "FGTranslation::V velocity out of bounds: " << vUVW(eV) << endl;
+ if (fabs(vUVW(eW)) > 1e6)
+ cout << "FGTranslation::W velocity out of bounds: " << vUVW(eW) << endl;
+ if (fabs(vUVWdot(eU)) > 1e4)
+ cout << "FGTranslation::U acceleration out of bounds: " << vUVWdot(eU) << endl;
+ if (fabs(vUVWdot(eV)) > 1e4)
+ cout << "FGTranslation::V acceleration out of bounds: " << vUVWdot(eV) << endl;
+ if (fabs(vUVWdot(eW)) > 1e4)
+ cout << "FGTranslation::W acceleration out of bounds: " << vUVWdot(eW) << endl;
+ if (Mach > 100 || Mach < 0.00)
+ cout << "FGTranslation::Mach is out of bounds: " << Mach << endl;
+ if (qbar > 1e6 || qbar < 0.00)
+ cout << "FGTranslation::qbar is out of bounds: " << qbar << endl;
+ }
+ if (debug_lvl & 64) {
+ if (from == 0) { // Constructor
+ cout << IdSrc << endl;
+ cout << IdHdr << endl;
+ }
+ }
+}
+
@author Tony Peden (Maintained and refined)
@version $Id$
@see main in file JSBSim.cpp (use main() wrapper for standalone usage)
+ @see <a href="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/jsbsim/JSBSim/JSBSim.hxx?rev=HEAD&content-type=text/vnd.viewcvs-markup">
+ Header File </a>
+ @see <a href="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/jsbsim/JSBSim/JSBSim.cxx?rev=HEAD&content-type=text/vnd.viewcvs-markup">
+ Source File </a>
*/
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FGEngine.cpp FGEngine.h \
FGTank.cpp FGTank.h \
FGfdmSocket.cpp FGfdmSocket.h \
- FGPropertyManager.h \
+ FGPropertyManager.h \
JSBSim.cxx JSBSim.hxx
}
} else if ( token == "DETENTS" ) {
*AC_cfg >> NumDetents;
- for(int i=0;i<NumDetents;i++) {
+ for (int i=0;i<NumDetents;i++) {
*AC_cfg >> tmpDetent;
*AC_cfg >> tmpTime;
Detents.push_back(tmpDetent);
InputCmd = Input*Detents[NumDetents-1];
OutputPos = OutputNode->getDoubleValue();
- if(InputCmd < Detents[0]) {
+ if (InputCmd < Detents[0]) {
fi=0;
InputCmd=Detents[0];
lastInputCmd=InputCmd;
OutputPos=Detents[0];
Output=OutputPos;
- } else if(InputCmd > Detents[NumDetents-1]) {
+ } else if (InputCmd > Detents[NumDetents-1]) {
fi=NumDetents-1;
InputCmd=Detents[fi];
lastInputCmd=InputCmd;
Output=OutputPos;
} else {
//cout << "FGKinemat::Run Handle: " << InputCmd << " Position: " << OutputPos << endl;
- if(dt <= 0)
+ if (dt <= 0)
OutputPos=InputCmd;
else {
- if(InputCmd != lastInputCmd) {
+ if (InputCmd != lastInputCmd) {
InTransit=1;
}
//cout << "FGKinemat::Run, InTransit: " << InTransit << endl;
- if(InTransit) {
+ if (InTransit) {
//fprintf(stderr,"InputCmd: %g, OutputPos: %g\n",InputCmd,OutputPos);
fi=0;
- while(Detents[fi] < InputCmd) {
+ while (Detents[fi] < InputCmd) {
fi++;
}
- if(OutputPos < InputCmd) {
- if(TransitionTimes[fi] > 0)
+ if (OutputPos < InputCmd) {
+ if (TransitionTimes[fi] > 0)
output_transit_rate=(Detents[fi] - Detents[fi-1])/TransitionTimes[fi];
else
output_transit_rate=(Detents[fi] - Detents[fi-1])/5;
//cout << "FGKinemat::Run, output_transit_rate: " << output_transit_rate << endl;
} else {
- if(TransitionTimes[fi+1] > 0)
+ if (TransitionTimes[fi+1] > 0)
output_transit_rate=(Detents[fi] - Detents[fi+1])/TransitionTimes[fi+1];
else
output_transit_rate=(Detents[fi] - Detents[fi+1])/5;
}
- if(fabs(OutputPos - InputCmd) > fabs(dt*output_transit_rate) ) {
+ if (fabs(OutputPos - InputCmd) > fabs(dt*output_transit_rate) ) {
OutputPos+=output_transit_rate*dt;
//cout << "FGKinemat::Run, OutputPos: " << OutputPos
// << " dt: " << dt << endl;
Output = OutputPos;
}
- if( Detents[NumDetents-1] > 0 ) {
+ if ( Detents[NumDetents-1] > 0 ) {
OutputPct = Output / Detents[NumDetents-1];
}
cout << " ID: " << ID << endl;
cout << " INPUT: " << InputNode->getName() << endl;
cout << " DETENTS: " << NumDetents << endl;
- for(int i=0;i<NumDetents;i++) {
+ for (int i=0;i<NumDetents;i++) {
cout << " " << Detents[i] << " " << TransitionTimes[i] << endl;
}
if (IsOutput) cout << " OUTPUT: " << OutputNode->getName() << endl;
FGSummer::~FGSummer()
{
unsigned i;
- for(i=0;i<Inputs.size();i++) {
+ for (i=0;i<Inputs.size();i++) {
delete Inputs[i];
}
Debug(1);