]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/JSBSim/FGPiston.cpp
JSBSim tweaks.
[flightgear.git] / src / FDM / JSBSim / FGPiston.cpp
index 9acbf502ae4b0a682afc0900bd5d686bf88c3d47..e60a65fa39f3e8fc63631b2fca3fc4364998ee2c 100644 (file)
@@ -40,17 +40,81 @@ INCLUDES
 
 #include "FGPiston.h"
 
-static const char *IdSrc = "$Header$";
+static const char *IdSrc = "$Id$";
 static const char *IdHdr = ID_PISTON;
 
+extern short debug_lvl;
+
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 CLASS IMPLEMENTATION
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
+FGPiston::FGPiston(FGFDMExec* exec, FGConfigFile* Eng_cfg) : FGEngine(exec)
+{
+  string token;
+
+  Name = Eng_cfg->GetValue("NAME");
+  Eng_cfg->GetNextConfigLine();
+  while (Eng_cfg->GetValue() != "/FG_PISTON") {
+    *Eng_cfg >> token;
+    if      (token == "BRAKEHORSEPOWER") *Eng_cfg >> BrakeHorsePower;
+    else if (token == "MAXTHROTTLE")     *Eng_cfg >> MaxThrottle;
+    else if (token == "MINTHROTTLE")     *Eng_cfg >> MinThrottle;
+    else if (token == "SLFUELFLOWMAX")   *Eng_cfg >> SLFuelFlowMax;
+    else if (token == "SPEEDSLOPE")      *Eng_cfg >> SpeedSlope;
+    else if (token == "SPEEDINTERCEPT")  *Eng_cfg >> SpeedIntercept;
+    else if (token == "ALTITUDESLOPE")   *Eng_cfg >> AltitudeSlope;
+    else cerr << "Unhandled token in Engine config file: " << token << endl;
+  }
+
+  if (debug_lvl > 0) {
+    cout << "\n    Engine Name: " << Name << endl;
+    cout << "      BrakeHorsePower = " << BrakeHorsePower << endl;
+    cout << "      MaxThrottle = " << MaxThrottle << endl;
+    cout << "      MinThrottle = " << MinThrottle << endl;
+    cout << "      SLFuelFlowMax = " << SLFuelFlowMax << endl;
+    cout << "      SpeedSlope = " << SpeedSlope << endl;
+    cout << "      SpeedIntercept = " << SpeedIntercept << endl;
+    cout << "      AltitudeSlope = " << AltitudeSlope << endl;
+  }
+
+  Type = etPiston;
+  EngineNumber = 0;
+
+  if (debug_lvl & 2) cout << "Instantiated: FGPiston" << endl;
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+FGPiston::~FGPiston()
+{
+  if (debug_lvl & 2) cout << "Destroyed:    FGPiston" << endl;
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+float FGPiston::Calculate(float PowerRequired)
+{
+  float h,EngineMaxPower;
+
+  ConsumeFuel();
+
+  Throttle = FCS->GetThrottlePos(EngineNumber);
+
+  h = Position->Geth();
+
+  if (h < 0) h = 0;
+
+  EngineMaxPower = (1 + AltitudeSlope*h)*BrakeHorsePower;
+  PowerAvailable = Throttle*EngineMaxPower*HPTOFTLBSSEC - PowerRequired;
+  
+  return PowerAvailable;
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-FGPiston::FGPiston(FGFDMExec* fdex, string enginePath, string engineName, int num) :
-                                 FGEngine(fdex, enginePath, engineName, num)
+void FGPiston::Debug(void)
 {
-  //
+    //TODO: Add your source code here
 }