]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/JSBSim/FGPropulsion.h
Updated to match changes in radiostack.[ch]xx
[flightgear.git] / src / FDM / JSBSim / FGPropulsion.h
index 3cad5a1334a3d9289a3893e8b7e13c28229b50b9..c0a9cf636f2f6e53463e7d5886ad1183b958b71b 100644 (file)
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
  Header:       FGPropulsion.h
  Author:       Jon S. Berndt
@@ -27,54 +27,193 @@ HISTORY
 --------------------------------------------------------------------------------
 08/20/00   JSB   Created
  
-********************************************************************************
-COMMENTS, REFERENCES,  and NOTES
-********************************************************************************
-********************************************************************************
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 SENTRY
-*******************************************************************************/
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
 #ifndef FGPROPULSION_H
 #define FGPROPULSION_H
 
-/*******************************************************************************
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 INCLUDES
-*******************************************************************************/
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
 #ifdef FGFS
 #  include <simgear/compiler.h>
-#  ifdef FG_HAVE_STD_INCLUDES
+#  ifdef SG_HAVE_STD_INCLUDES
 #    include <vector>
+#    include <iterator>
 #  else
 #    include <vector.h>
+#    include <iterator.h>
 #  endif
 #else
 #  include <vector>
+#  include <iterator>
 #endif
 
 #include "FGModel.h"
 
-#include "FGEngine.h"
+#include "FGRocket.h"
+#include "FGPiston.h"
+#include "FGTurboShaft.h"
+#include "FGTurboJet.h"
+#include "FGTurboProp.h"
 #include "FGTank.h"
-#include "FGThruster.h"
-#include "FGConfigFile.h"
+#include "FGPropeller.h"
+#include "FGNozzle.h"
+
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+DEFINITIONS
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
+#define ID_PROPULSION "$Id$"
+
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+FORWARD DECLARATIONS
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+COMMENTS, REFERENCES, and NOTES [use "class documentation" below for API docs]
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-/*******************************************************************************
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+CLASS DOCUMENTATION
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
+/** Propulsion management class.
+    FGPropulsion manages all aspects of propulsive force generation, including
+    containment of engines, tanks, and thruster class instances in STL vectors,
+    and the interaction and communication between them.
+    @author Jon S. Berndt
+    @version $Id$
+    @see FGEngine
+    @see FGTank
+    @see FGThruster
+    @see <a href="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/jsbsim/JSBSim/FGPropulsion.h?rev=HEAD&content-type=text/vnd.viewcvs-markup">
+         Header File </a>
+    @see <a href="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/jsbsim/JSBSim/FGPropulsion.cpp?rev=HEAD&content-type=text/vnd.viewcvs-markup">
+         Source File </a>
+*/
+
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 CLASS DECLARATION
-*******************************************************************************/
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-class FGPropulsion : public FGModel {
-  vector <FGEngine>   Engines;
-  vector <FGTank>     Tanks;
-  vector <FGThruster> Thrusters;
+class FGPropulsion : public FGModel
+{
 public:
+  /// Constructor
   FGPropulsion(FGFDMExec*);
+  /// Destructor
+  ~FGPropulsion();
+
+  /** Executes the propulsion model.
+      The initial plan for the FGPropulsion class calls for Run() to be executed,
+      performing the following tasks:
+      <ol>
+  <li>Determine the drag - or power required - for the attached thrust effector
+      for this engine so that any feedback to the engine can be performed. This
+      is done by calling FGThruster::CalculatePReq()</li>
+  <li>Given 1, above, calculate the power available from the engine. This is
+      done by calling FGEngine::CalculatePAvail()</li>
+  <li>Next, calculate the thrust output from the thruster model given the power
+      available and the power required. This may also result in new performance
+      numbers for the thruster in the case of the propeller, at least. This
+      result is returned from a call to Calculate().</li></ol>
 
+      [Note: Should we be checking the Starved flag here?] */
   bool Run(void);
-  bool LoadPropulsion(FGConfigFile* AC_cfg);
+
+  /** Loads the propulsion system (engine[s], tank[s], thruster[s]).
+      Characteristics of the propulsion system are read in from the config file.
+      @param AC_cfg pointer to the config file instance that describes the
+             aircraft being modeled.
+      @return true if successfully loaded, otherwise false */
+  bool Load(FGConfigFile* AC_cfg);
+
+  /// Retrieves the number of engines defined for the aircraft.
+  inline unsigned int GetNumEngines(void) const {return Engines.size();}
+
+  /** Retrieves an engine object pointer from the list of engines.
+      @param index the engine index within the vector container
+      @return the address of the specific engine, or zero if no such engine is
+              available */
+  inline FGEngine* GetEngine(unsigned int index) {
+                      if (index <= Engines.size()-1) return Engines[index];
+                      else                           return 0L;      }
+
+  // Retrieves the number of tanks defined for the aircraft.
+  inline unsigned int GetNumTanks(void) const {return Tanks.size();}
+
+  /** Retrieves a tank object pointer from the list of tanks.
+      @param index the tank index within the vector container
+      @return the address of the specific tank, or zero if no such tank is
+              available */
+  inline FGTank* GetTank(unsigned int index) {
+                      if (index <= Tanks.size()-1) return Tanks[index];
+                      else                         return 0L;        }
+
+  /** Retrieves a thruster object pointer from the list of thrusters.
+      @param index the thruster index within the vector container
+      @return the address of the specific thruster, or zero if no such thruster is
+              available */
+  inline FGThruster* GetThruster(unsigned int index) {
+                      if (index <= Thrusters.size()-1) return Thrusters[index];
+                      else                             return 0L;    }
+
+  /** Returns the number of fuel tanks currently actively supplying fuel */
+  inline int GetnumSelectedFuelTanks(void) const {return numSelectedFuelTanks;}
+
+  /** Returns the number of oxidizer tanks currently actively supplying oxidizer */
+  inline int GetnumSelectedOxiTanks(void) const {return numSelectedOxiTanks;}
+
+  /** Loops the engines/thrusters until thrust output steady (used for trimming) */
+  bool GetSteadyState(void);
+  
+  /** starts the engines in IC mode (dt=0).  All engine-specific setup must
+      be done before calling this (i.e. magnetos, starter engage, etc.) */
+  bool ICEngineStart(void);
+  
+  string GetPropulsionStrings(void);
+  string GetPropulsionValues(void);
+
+  inline FGColumnVector3& GetForces(void)  {return vForces; }
+  inline double GetForces(int n) const { return vForces(n);}
+  inline FGColumnVector3& GetMoments(void) {return vMoments;}
+  inline double GetMoments(int n) const {return vMoments(n);}
+  
+  FGColumnVector3& GetTanksMoment(void);
+  double GetTanksWeight(void);
+
+  double GetTanksIxx(const FGColumnVector3& vXYZcg);
+  double GetTanksIyy(const FGColumnVector3& vXYZcg);
+  double GetTanksIzz(const FGColumnVector3& vXYZcg);
+  double GetTanksIxz(const FGColumnVector3& vXYZcg);
+  double GetTanksIxy(const FGColumnVector3& vXYZcg);
+  
+  void bind();
+  void unbind();
+   
+private:
+  vector <FGEngine*>   Engines;
+  vector <FGTank*>     Tanks;
+  vector <FGTank*>::iterator iTank;
+  vector <FGThruster*> Thrusters;
+  unsigned int numSelectedFuelTanks;
+  unsigned int numSelectedOxiTanks;
+  unsigned int numFuelTanks;
+  unsigned int numOxiTanks;
+  unsigned int numEngines;
+  unsigned int numTanks;
+  unsigned int numThrusters;
+  double dt;
+  FGColumnVector3 vForces;
+  FGColumnVector3 vMoments;
+  FGColumnVector3 vXYZtank;
+  void Debug(int from);
 };
 
-/******************************************************************************/
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 #endif