]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/JSBSim/FGPropeller.cpp
Make yasim accept the launchbar and hook properties. They are not tied to anything...
[flightgear.git] / src / FDM / JSBSim / FGPropeller.cpp
index da3fbd41d5a80847342fb8950d0cbafcc78a2231..d205a3a621900d3f561de6c76624cf7c1bb6c813 100644 (file)
@@ -35,8 +35,12 @@ HISTORY
 INCLUDES
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
+#include <sstream>
+
 #include "FGPropeller.h"
-#include "FGFCS.h"
+#include "FGPropagate.h"
+#include "FGAtmosphere.h"
+#include "FGAuxiliary.h"
 
 namespace JSBSim {
 
@@ -47,17 +51,17 @@ static const char *IdHdr = ID_PROPELLER;
 CLASS IMPLEMENTATION
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-// This class currently makes certain assumptions when calculating torque and 
+// This class currently makes certain assumptions when calculating torque and
 // p-factor. That is, that the axis of rotation is the X axis of the aircraft -
-// not just the X-axis of the engine/propeller. This may or may not work for a 
+// not just the X-axis of the engine/propeller. This may or may not work for a
 // helicopter.
 
-FGPropeller::FGPropeller(FGFDMExec* exec, FGConfigFile* Prop_cfg) : FGThruster(exec)
+FGPropeller::FGPropeller(FGFDMExec* exec, FGConfigFile* Prop_cfg, int num) : FGThruster(exec)
 {
   string token;
   int rows, cols;
 
-  MaxPitch = MinPitch = P_Factor = Sense = Pitch = 0.0;
+  MaxPitch = MinPitch = P_Factor = Sense = Pitch = Advance = 0.0;
   GearRatio = 1.0;
 
   Name = Prop_cfg->GetValue("NAME");
@@ -103,6 +107,10 @@ FGPropeller::FGPropeller(FGFDMExec* exec, FGConfigFile* Prop_cfg) : FGThruster(e
   RPM = 0;
   vTorque.InitMatrix();
 
+  char property_name[80];
+  snprintf(property_name, 80, "propulsion/c-thrust[%u]", EngineNum);
+  PropertyManager->Tie( property_name, &ThrustCoeff );
+
   Debug(0);
 }
 
@@ -112,6 +120,11 @@ FGPropeller::~FGPropeller()
 {
   if (cThrust)    delete cThrust;
   if (cPower)     delete cPower;
+
+  char property_name[80];
+  snprintf(property_name, 80, "propulsion/c-thrust[%u]", EngineNum);
+  PropertyManager->Untie( property_name );
+
   Debug(1);
 }
 
@@ -131,8 +144,8 @@ FGPropeller::~FGPropeller()
 
 double FGPropeller::Calculate(double PowerAvailable)
 {
-  double J, C_Thrust, omega;
-  double Vel = fdmex->GetTranslation()->GetAeroUVW(eU);
+  double J, omega;
+  double Vel = fdmex->GetAuxiliary()->GetAeroUVW(eU);
   double rho = fdmex->GetAtmosphere()->GetDensity();
   double RPS = RPM/60.0;
   double alpha, beta;
@@ -144,29 +157,23 @@ double FGPropeller::Calculate(double PowerAvailable)
   }
 
   if (MaxPitch == MinPitch) { // Fixed pitch prop
-    C_Thrust = cThrust->GetValue(J);
+    ThrustCoeff = cThrust->GetValue(J);
   } else {                    // Variable pitch prop
-    C_Thrust = cThrust->GetValue(J, Pitch);
+    ThrustCoeff = cThrust->GetValue(J, Pitch);
   }
 
   if (P_Factor > 0.0001) {
-    alpha = fdmex->GetTranslation()->Getalpha();
-    beta  = fdmex->GetTranslation()->Getbeta();
+    alpha = fdmex->GetAuxiliary()->Getalpha();
+    beta  = fdmex->GetAuxiliary()->Getbeta();
     SetActingLocationY( GetLocationY() + P_Factor*alpha*Sense);
     SetActingLocationZ( GetLocationZ() + P_Factor*beta*Sense);
   } else if (P_Factor < 0.000) {
     cerr << "P-Factor value in config file must be greater than zero" << endl;
   }
 
-  Thrust = C_Thrust*RPS*RPS*Diameter*Diameter*Diameter*Diameter*rho;
+  Thrust = ThrustCoeff*RPS*RPS*Diameter*Diameter*Diameter*Diameter*rho;
   omega = RPS*2.0*M_PI;
 
-  // Check for windmilling.
-  double radius = Diameter * 0.375; // 75% of radius
-  double windmill_cutoff = tan(Pitch * 1.745329E-2) * omega * radius;
-  if (Vel > windmill_cutoff)
-    Thrust = -Thrust;
-
   vFn(1) = Thrust;
 
   // The Ixx value and rotation speed given below are for rotation about the
@@ -182,13 +189,13 @@ double FGPropeller::Calculate(double PowerAvailable)
   ExcessTorque = PowerAvailable / omega * GearRatio;
   RPM = (RPS + ((ExcessTorque / Ixx) / (2.0 * M_PI)) * deltaT) * 60.0;
 
-                               // The friction from the engine should
-                               // stop it somewhere; I chose an
-                               // arbitrary point.
+        // The friction from the engine should
+        // stop it somewhere; I chose an
+        // arbitrary point.
   if (RPM < 5.0)
     RPM = 0;
 
-  vMn = fdmex->GetRotation()->GetPQR()*vH + vTorque*Sense;
+  vMn = fdmex->GetPropagate()->GetPQR()*vH + vTorque*Sense;
 
   return Thrust; // return thrust in pounds
 }
@@ -201,17 +208,16 @@ double FGPropeller::GetPowerRequired(void)
 
   double cPReq, RPS = RPM / 60.0;
 
-  double J = fdmex->GetTranslation()->GetAeroUVW(eU) / (Diameter * RPS);
+  double J = fdmex->GetAuxiliary()->GetAeroUVW(eU) / (Diameter * RPS);
   double rho = fdmex->GetAtmosphere()->GetDensity();
 
   if (MaxPitch == MinPitch) { // Fixed pitch prop
     Pitch = MinPitch;
     cPReq = cPower->GetValue(J);
   } else {                    // Variable pitch prop
-    double advance = fdmex->GetFCS()->GetPropAdvance(ThrusterNumber);
 
     if (MaxRPM != MinRPM) {   // fixed-speed prop
-      double rpmReq = MinRPM + (MaxRPM - MinRPM) * advance;
+      double rpmReq = MinRPM + (MaxRPM - MinRPM) * Advance;
       double dRPM = rpmReq - RPM;
 
       Pitch -= dRPM / 10;
@@ -220,7 +226,7 @@ double FGPropeller::GetPowerRequired(void)
       else if (Pitch > MaxPitch)  Pitch = MaxPitch;
 
     } else {
-      Pitch = MinPitch + (MaxPitch - MinPitch) * advance;
+      Pitch = MinPitch + (MaxPitch - MinPitch) * Advance;
     }
     cPReq = cPower->GetValue(J, Pitch);
   }
@@ -244,6 +250,41 @@ FGColumnVector3 FGPropeller::GetPFactor()
   return FGColumnVector3(px, py, pz);
 }
 
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+string FGPropeller::GetThrusterLabels(int id, string delimeter)
+{
+  std::ostringstream buf;
+
+  buf << Name << "_Torque[" << id << "]" << delimeter
+      << Name << "_PFactor_Pitch[" << id << "]" << delimeter
+      << Name << "_PFactor_Yaw[" << id << "]" << delimeter
+      << Name << "_Thrust[" << id << "]" << delimeter;
+  if (IsVPitch())
+    buf << Name << "_Pitch[" << id << "]" << delimeter;
+  buf << Name << "_RPM[" << id << "]";
+
+  return buf.str();
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+string FGPropeller::GetThrusterValues(int id, string delimeter)
+{
+  std::ostringstream buf;
+
+  FGColumnVector3 vPFactor = GetPFactor();
+  buf << vTorque(eX) << delimeter
+      << vPFactor(ePitch) << delimeter
+      << vPFactor(eYaw) << delimeter
+      << Thrust << delimeter;
+  if (IsVPitch())
+    buf << Pitch << delimeter;
+  buf << RPM;
+
+  return buf.str();
+}
+
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 //    The bitmasked value choices are as follows:
 //    unset: In this case (the default) JSBSim would only print