]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/JSBSim/FGThruster.cpp
Make yasim accept the launchbar and hook properties. They are not tied to anything...
[flightgear.git] / src / FDM / JSBSim / FGThruster.cpp
index ebe861803a9456697d87a0984edccf020be3e209..4d4a4edcb9331a7af68ac51d59ef09a57e5c09a6 100644 (file)
@@ -35,8 +35,12 @@ HISTORY
 INCLUDES
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
+#include <sstream>
+
 #include "FGThruster.h"
 
+namespace JSBSim {
+
 static const char *IdSrc = "$Id$";
 static const char *IdHdr = ID_THRUSTER;
 
@@ -45,11 +49,39 @@ CLASS IMPLEMENTATION
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
 
-FGThruster::FGThruster(FGFDMExec *FDMExec) : FGForce(FDMExec),
-                                             ThrusterNumber(0)
+FGThruster::FGThruster(FGFDMExec *FDMExec) : FGForce(FDMExec)
 {
+  Type = ttDirect;
   SetTransformType(FGForce::tCustom);
 
+  EngineNum = 0;
+  PropertyManager = FDMExec->GetPropertyManager();
+
+  Debug(0);
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+FGThruster::FGThruster(FGFDMExec *FDMExec,
+                       FGConfigFile *Eng_cfg, int num ): FGForce(FDMExec)
+{
+  Type = ttDirect;
+  SetTransformType(FGForce::tCustom);
+  Name = Eng_cfg->GetValue();
+  GearRatio = 1.0;
+
+  EngineNum = num;
+  ThrustCoeff = 0.0;
+  ReverserAngle = 0.0;
+  PropertyManager = FDMExec->GetPropertyManager();
+
+  char property_name[80];
+  snprintf(property_name, 80, "propulsion/c-thrust[%u]", EngineNum);
+  PropertyManager->Tie( property_name, &ThrustCoeff );
+  snprintf(property_name, 80, "propulsion/engine[%u]/reverser-angle", EngineNum);
+  PropertyManager->Tie( property_name, &ReverserAngle );
+
+
   Debug(0);
 }
 
@@ -57,9 +89,37 @@ FGThruster::FGThruster(FGFDMExec *FDMExec) : FGForce(FDMExec),
 
 FGThruster::~FGThruster()
 {
+  char property_name[80];
+  snprintf(property_name, 80, "propulsion/c-thrust[%u]", EngineNum);
+  PropertyManager->Untie( property_name );
+  snprintf(property_name, 80, "propulsion/engine[%u]/reverser-angle", EngineNum);
+  PropertyManager->Untie( property_name );
+
   Debug(1);
 }
 
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+string FGThruster::GetThrusterLabels(int id, string delimeter)
+{
+  std::ostringstream buf;
+
+  buf << Name << "_Thrust[" << id << "]";
+
+  return buf.str();
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+string FGThruster::GetThrusterValues(int id, string delimeter)
+{
+  std::ostringstream buf;
+
+  buf << Thrust;
+
+  return buf.str();
+}
+
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 //    The bitmasked value choices are as follows:
 //    unset: In this case (the default) JSBSim would only print
@@ -98,5 +158,11 @@ void FGThruster::Debug(int from)
   }
   if (debug_lvl & 16) { // Sanity checking
   }
+  if (debug_lvl & 64) {
+    if (from == 0) { // Constructor
+      cout << IdSrc << endl;
+      cout << IdHdr << endl;
+    }
+  }
+}
 }
-