]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/JSBSim/FGPiston.cpp
JSBSim tweaks.
[flightgear.git] / src / FDM / JSBSim / FGPiston.cpp
index 0982ca2b75920682c92ee5931b291ec33cbb2937..e60a65fa39f3e8fc63631b2fca3fc4364998ee2c 100644 (file)
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
  Module:       FGPiston.cpp
  Author:       Jon S. Berndt
@@ -34,20 +34,87 @@ HISTORY
 --------------------------------------------------------------------------------
 09/12/2000  JSB  Created
 
-********************************************************************************
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 INCLUDES
-*******************************************************************************/
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
 #include "FGPiston.h"
 
-/*******************************************************************************
-************************************ CODE **************************************
-*******************************************************************************/
+static const char *IdSrc = "$Id$";
+static const char *IdHdr = ID_PISTON;
 
+extern short debug_lvl;
 
-FGPiston::FGPiston(FGFDMExec* fdex, string enginePath, string engineName, int num) :
-                                 FGEngine(fdex, enginePath, engineName, num)
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+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;
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+void FGPiston::Debug(void)
 {
-  //
+    //TODO: Add your source code here
 }