]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/JSBSim/FGEngine.cpp
Encapsulate the interpolstion version of FGEnvironment and fix some bugs
[flightgear.git] / src / FDM / JSBSim / FGEngine.cpp
index 7f7c2956c1d9fffc7dd632dc658a4853e73e56fd..06bb5b63476b4e20060a2e584a881519265053af 100644 (file)
@@ -46,7 +46,7 @@ INCLUDES
 #    include <fstream.h>
 #  endif
 #else
-#  if defined(sgi) && !defined(__GNUC__)
+#  if defined(sgi) && !defined(__GNUC__) && (_COMPILER_VERSION < 740)
 #    include <fstream.h>
 #  else
 #    include <fstream>
@@ -56,6 +56,8 @@ INCLUDES
 #include "FGEngine.h"
 #include "FGTank.h"
 
+namespace JSBSim {
+
 static const char *IdSrc = "$Id$";
 static const char *IdHdr = ID_ENGINE;
 
@@ -66,27 +68,40 @@ CLASS IMPLEMENTATION
 
 FGEngine::FGEngine(FGFDMExec* exec)
 {
-  FDMExec     = exec;
-  State       = FDMExec->GetState();
-  Atmosphere  = FDMExec->GetAtmosphere();
-  FCS         = FDMExec->GetFCS();
-  Propulsion  = FDMExec->GetPropulsion();
-  Aircraft    = FDMExec->GetAircraft();
+  Name.clear();
+  Type = etUnknown;
+  X = Y = Z = 0.0;
+  EnginePitch = EngineYaw = 0.0;
+  SLFuelFlowMax = SLOxiFlowMax = 0.0;
+  MaxThrottle = 1.0;
+  MinThrottle = 0.0;
+  Thrust = 0.0;
+  Throttle = 0.0;
+  Mixture = 1.0;
+  Starter = false;
+  FuelNeed = OxidizerNeed = 0.0;
+  Starved = Running = Cranking = false;
+  PctPower = 0.0;
+  EngineNumber = -1;
+  TrimMode = false;
+  FuelFlow_gph = 0.0;
+  FuelFlow_pph = 0.0;
+
+  FDMExec = exec;
+  State = FDMExec->GetState();
+  Atmosphere = FDMExec->GetAtmosphere();
+  FCS = FDMExec->GetFCS();
+  Propulsion = FDMExec->GetPropulsion();
+  Aircraft = FDMExec->GetAircraft();
   Translation = FDMExec->GetTranslation();
-  Rotation    = FDMExec->GetRotation();
-  Position    = FDMExec->GetPosition();
-  Auxiliary   = FDMExec->GetAuxiliary();
-  Output      = FDMExec->GetOutput();
-
-  Mixture = 1.0;               // FIXME: get actual value
-
-  Thrust = PctPower = 0.0;
-  Starved = Flameout = false;
-  Running = false;
-  Cranking = Starter = false;
+  Rotation = FDMExec->GetRotation();
+  Position = FDMExec->GetPosition();
+  Auxiliary = FDMExec->GetAuxiliary();
+  Output = FDMExec->GetOutput();
+  
+  PropertyManager = FDMExec->GetPropertyManager();
 
   Debug(0);
-  TrimMode = false;
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -110,7 +125,7 @@ void FGEngine::ConsumeFuel(void)
   if (TrimMode) return;
   Fshortage = Oshortage = 0.0;
   for (unsigned int i=0; i<SourceTanks.size(); i++) {
-    Tank = Propulsion->GetTank(i);
+    Tank = Propulsion->GetTank(SourceTanks[i]);
     if (Tank->GetType() == FGTank::ttFUEL) {
       Fshortage += Tank->Reduce(CalcFuelNeed()/Propulsion->GetnumSelectedFuelTanks());
     } else {
@@ -124,21 +139,24 @@ void FGEngine::ConsumeFuel(void)
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-double FGEngine::CalcFuelNeed(void) {
+double FGEngine::CalcFuelNeed(void)
+{
   FuelNeed = SLFuelFlowMax*PctPower*State->Getdt()*Propulsion->GetRate();
   return FuelNeed;
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-double FGEngine::CalcOxidizerNeed(void) {
+double FGEngine::CalcOxidizerNeed(void)
+{
   OxidizerNeed = SLOxiFlowMax*PctPower*State->Getdt()*Propulsion->GetRate();
   return OxidizerNeed;
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-void FGEngine::SetPlacement(double x, double y, double z, double pitch, double yaw) {
+void FGEngine::SetPlacement(double x, double y, double z, double pitch, double yaw)
+{
   X = x;
   Y = y;
   Z = z;
@@ -191,4 +209,11 @@ void FGEngine::Debug(int from)
   }
   if (debug_lvl & 16) { // Sanity checking
   }
+  if (debug_lvl & 64) {
+    if (from == 0) { // Constructor
+      cout << IdSrc << endl;
+      cout << IdHdr << endl;
+    }
+  }
+}
 }