INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+#include <sstream>
+#include <iomanip>
+
#include "FGGroundReactions.h"
+#include "FGPropertyManager.h"
+
+namespace JSBSim {
static const char *IdSrc = "$Id$";
static const char *IdHdr = ID_GROUNDREACTIONS;
{
Name = "FGGroundReactions";
+ bind();
+
Debug(0);
}
FGGroundReactions::~FGGroundReactions(void)
{
+ unbind();
+
Debug(1);
}
vMoments.InitMatrix();
// Only execute gear force code below 300 feet
- if ( Position->GetDistanceAGL() < 300.0 ) {
+ if ( Propagate->GetDistanceAGL() < 300.0 ) {
vector <FGLGear>::iterator iGear = lGear.begin();
// Sum forces and moments for all gear, here.
// Some optimizations may be made here - or rather in the gear code itself.
AC_cfg->GetNextConfigLine();
while ((token = AC_cfg->GetValue()) != string("/UNDERCARRIAGE")) {
- lGear.push_back(FGLGear(AC_cfg, FDMExec));
+ int num = lGear.size();
+ lGear.push_back(FGLGear(AC_cfg, FDMExec, num));
+ FCS->AddGear();
}
return true;
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-string FGGroundReactions::GetGroundReactionStrings(void)
+string FGGroundReactions::GetGroundReactionStrings(string delimeter)
{
- string GroundReactionStrings = "";
- bool firstime = true;
+ std::ostringstream buf;
for (unsigned int i=0;i<lGear.size();i++) {
- if (!firstime) GroundReactionStrings += ", ";
- GroundReactionStrings += (lGear[i].GetName() + "_WOW, ");
- GroundReactionStrings += (lGear[i].GetName() + "_stroke, ");
- GroundReactionStrings += (lGear[i].GetName() + "_strokeVel, ");
- GroundReactionStrings += (lGear[i].GetName() + "_CompressForce, ");
- GroundReactionStrings += (lGear[i].GetName() + "_WhlSideForce, ");
- GroundReactionStrings += (lGear[i].GetName() + "_WhlRollForce, ");
- GroundReactionStrings += (lGear[i].GetName() + "_BodyXForce, ");
- GroundReactionStrings += (lGear[i].GetName() + "_BodyYForce, ");
- GroundReactionStrings += (lGear[i].GetName() + "_WhlSlipDegrees");
-
- firstime = false;
+ string name = lGear[i].GetName();
+ buf << name << "_WOW" << delimeter
+ << name << "_stroke" << delimeter
+ << name << "_strokeVel" << delimeter
+ << name << "_CompressForce" << delimeter
+ << name << "_WhlSideForce" << delimeter
+ << name << "_WhlVelVecX" << delimeter
+ << name << "_WhlVelVecY" << delimeter
+ << name << "_WhlRollForce" << delimeter
+ << name << "_BodyXForce" << delimeter
+ << name << "_BodyYForce" << delimeter
+ << name << "_WhlSlipDegrees" << delimeter;
}
- return GroundReactionStrings;
+ buf << "TotalGearForce_X" << delimeter
+ << "TotalGearForce_Y" << delimeter
+ << "TotalGearForce_Z" << delimeter
+ << "TotalGearMoment_L" << delimeter
+ << "TotalGearMoment_M" << delimeter
+ << "TotalGearMoment_N";
+
+ return buf.str();
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-string FGGroundReactions::GetGroundReactionValues(void)
+string FGGroundReactions::GetGroundReactionValues(string delimeter)
{
- char buff[20];
- string GroundReactionValues = "";
-
- bool firstime = true;
+ std::ostringstream buf;
for (unsigned int i=0;i<lGear.size();i++) {
- if (!firstime) GroundReactionValues += ", ";
- GroundReactionValues += string( lGear[i].GetWOW()?"1":"0" ) + ", ";
- GroundReactionValues += (string(gcvt(lGear[i].GetCompLen(), 5, buff)) + ", ");
- GroundReactionValues += (string(gcvt(lGear[i].GetCompVel(), 6, buff)) + ", ");
- GroundReactionValues += (string(gcvt(lGear[i].GetCompForce(), 10, buff)) + ", ");
- GroundReactionValues += (string(gcvt(lGear[i].GetWheelSideForce(), 6, buff)) + ", ");
- GroundReactionValues += (string(gcvt(lGear[i].GetWheelRollForce(), 6, buff)) + ", ");
- GroundReactionValues += (string(gcvt(lGear[i].GetBodyXForce(), 6, buff)) + ", ");
- GroundReactionValues += (string(gcvt(lGear[i].GetBodyYForce(), 6, buff)) + ", ");
- GroundReactionValues += (string(gcvt(lGear[i].GetWheelSlipAngle(), 6, buff)));
-
- firstime = false;
+ FGLGear& gear = lGear[i];
+ buf << (gear.GetWOW() ? "1, " : "0, ")
+ << setprecision(5) << gear.GetCompLen() << delimeter
+ << setprecision(6) << gear.GetCompVel() << delimeter
+ << setprecision(10) << gear.GetCompForce() << delimeter
+ << setprecision(6) << gear.GetWheelVel(eX) << delimeter
+ << gear.GetWheelVel(eY) << delimeter
+ << gear.GetWheelSideForce() << delimeter
+ << gear.GetWheelRollForce() << delimeter
+ << gear.GetBodyXForce() << delimeter
+ << gear.GetBodyYForce() << delimeter
+ << gear.GetWheelSlipAngle() << delimeter;
}
- return GroundReactionValues;
+ buf << vForces(eX) << delimeter
+ << vForces(eY) << delimeter
+ << vForces(eZ) << delimeter
+ << vMoments(eX) << delimeter
+ << vMoments(eY) << delimeter
+ << vMoments(eZ);
+
+ return buf.str();
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+void FGGroundReactions::bind(void)
+{
+ typedef double (FGGroundReactions::*PMF)(int) const;
+ PropertyManager->Tie("gear/num-units", this,
+ &FGGroundReactions::GetNumGearUnits);
+ PropertyManager->Tie("moments/l-gear-lbsft", this,1,
+ (PMF)&FGGroundReactions::GetMoments);
+ PropertyManager->Tie("moments/m-gear-lbsft", this,2,
+ (PMF)&FGGroundReactions::GetMoments);
+ PropertyManager->Tie("moments/n-gear-lbsft", this,3,
+ (PMF)&FGGroundReactions::GetMoments);
+ PropertyManager->Tie("forces/fbx-gear-lbs", this,1,
+ (PMF)&FGGroundReactions::GetForces);
+ PropertyManager->Tie("forces/fby-gear-lbs", this,2,
+ (PMF)&FGGroundReactions::GetForces);
+ PropertyManager->Tie("forces/fbz-gear-lbs", this,3,
+ (PMF)&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");
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
}
}
}
-
+}