]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/JSBSim/models/FGPropulsion.h
Sync. with JSBSim CVS
[flightgear.git] / src / FDM / JSBSim / models / FGPropulsion.h
index 6ae3324ac011fdbc4feb9215ce021878b55b1709..50dd860cde4809db61d5ba19cd89fe546f79a568 100644 (file)
@@ -4,23 +4,23 @@
  Author:       Jon S. Berndt
  Date started: 08/20/00
 
- ------------- Copyright (C) 1999  Jon S. Berndt (jsb@hal-pc.org) -------------
+ ------------- Copyright (C) 1999  Jon S. Berndt (jon@jsbsim.org) -------------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ the terms of the GNU Lesser General Public License as published by the Free Software
  Foundation; either version 2 of the License, or (at your option) any later
  version.
 
  This program is distributed in the hope that it will be useful, but WITHOUT
  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ You should have received a copy of the GNU Lesser General Public License along with
  this program; if not, write to the Free Software Foundation, Inc., 59 Temple
  Place - Suite 330, Boston, MA  02111-1307, USA.
 
- Further information about the GNU General Public License can also be found on
+ Further information about the GNU Lesser General Public License can also be found on
  the world wide web at http://www.gnu.org.
 
 HISTORY
@@ -38,34 +38,18 @@ SENTRY
 INCLUDES
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-#ifdef FGFS
-#  include <simgear/compiler.h>
-#  ifdef SG_HAVE_STD_INCLUDES
-#    include <vector>
-#    include <iterator>
-#    include <fstream>
-#  else
-#    include <vector.h>
-#    include <iterator.h>
-#    include <fstream.h>
-#  endif
-#else
-#  include <vector>
-#  include <iterator>
-#  include <fstream>
-#endif
+#include <vector>
+#include <iosfwd>
 
 #include "FGModel.h"
-#include <models/propulsion/FGEngine.h>
-#include <models/propulsion/FGTank.h>
-#include <math/FGMatrix33.h>
-#include <input_output/FGXMLElement.h>
+#include "math/FGMatrix33.h"
+#include "input_output/FGXMLFileRead.h"
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 DEFINITIONS
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-#define ID_PROPULSION "$Id$"
+#define ID_PROPULSION "$Id: FGPropulsion.h,v 1.26 2010/11/18 12:38:06 jberndt Exp $"
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 FORWARD DECLARATIONS
@@ -73,6 +57,9 @@ FORWARD DECLARATIONS
 
 namespace JSBSim {
 
+class FGTank;
+class FGEngine;
+
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 CLASS DOCUMENTATION
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
@@ -80,14 +67,31 @@ CLASS DOCUMENTATION
 /** Propulsion management class.
     The Propulsion class is the container for the entire propulsion system, which is
     comprised of engines, and tanks. Once the Propulsion class gets the config file,
-    it reads in information which is specific to a type of engine. Then:
+    it reads in the \<propulsion> section. Then:
 
     -# The appropriate engine type instance is created
     -# At least one tank object is created, and is linked to an engine.
 
-    At Run time each engines Calculate() method is called.
+    At Run time each engine's Calculate() method is called.
+
+    <h3>Configuration File Format:</h3>
+
+  @code
+    <propulsion>
+        <engine file="{string}">
+          ... see FGEngine, FGThruster, and class for engine type ...
+        </engine>
+        ... more engines ...
+        <tank type="{FUEL | OXIDIZER}"> 
+          ... see FGTank ...
+        </tank>
+        ... more tanks ...
+        <dump-rate unit="{LBS/MIN | KG/MIN}"> {number} </dump-rate>
+    </propulsion>
+  @endcode
+
     @author Jon S. Berndt
-    @version $Id$
+    @version $Id: FGPropulsion.h,v 1.26 2010/11/18 12:38:06 jberndt Exp $
     @see
     FGEngine
     FGTank
@@ -97,7 +101,7 @@ CLASS DOCUMENTATION
 CLASS DECLARATION
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-class FGPropulsion : public FGModel
+class FGPropulsion : public FGModel, public FGXMLFileRead
 {
 public:
   /// Constructor
@@ -112,6 +116,8 @@ public:
       [Note: Should we be checking the Starved flag here?] */
   bool Run(void);
 
+  bool InitModel(void);
+
   /** Loads the propulsion system (engine[s] and tank[s]).
       Characteristics of the propulsion system are read in from the config file.
       @param el pointer to an XML element that contains the engine information.
@@ -119,58 +125,60 @@ public:
   bool Load(Element* el);
 
   /// Retrieves the number of engines defined for the aircraft.
-  inline unsigned int GetNumEngines(void) const {return Engines.size();}
+  unsigned int GetNumEngines(void) const {return (unsigned int)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;      }
+  FGEngine* GetEngine(unsigned int index) const {
+                      if (index < Engines.size()) return Engines[index];
+                      else                        return 0L;      }
 
   /// Retrieves the number of tanks defined for the aircraft.
-  inline unsigned int GetNumTanks(void) const {return Tanks.size();}
+  unsigned int GetNumTanks(void) const {return (unsigned int)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;        }
+  FGTank* GetTank(unsigned int index) const {
+                      if (index < Tanks.size()) return Tanks[index];
+                      else                      return 0L;        }
 
   /** Returns the number of fuel tanks currently actively supplying fuel */
-  inline int GetnumSelectedFuelTanks(void) const {return numSelectedFuelTanks;}
+  int GetnumSelectedFuelTanks(void) const {return numSelectedFuelTanks;}
 
   /** Returns the number of oxidizer tanks currently actively supplying oxidizer */
-  inline int GetnumSelectedOxiTanks(void) const {return numSelectedOxiTanks;}
+  int GetnumSelectedOxiTanks(void) const {return numSelectedOxiTanks;}
 
   /** Loops the engines 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);
+  /** Sets up the engines as running */
+  void InitRunning(int n);
 
-  string GetPropulsionStrings(string delimeter);
-  string GetPropulsionValues(string delimeter);
+  std::string GetPropulsionStrings(const std::string& delimiter) const;
+  std::string GetPropulsionValues(const std::string& delimiter) const;
 
-  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);}
+  const FGColumnVector3& GetForces(void) const {return vForces; }
+  double GetForces(int n) const { return vForces(n);}
+  const FGColumnVector3& GetMoments(void) const {return vMoments;}
+  double GetMoments(int n) const {return vMoments(n);}
 
-  inline bool GetRefuel(void) {return refuel;}
-  inline void SetRefuel(bool setting) {refuel = setting;}
+  bool GetRefuel(void) const {return refuel;}
+  void SetRefuel(bool setting) {refuel = setting;}
+  bool GetFuelDump(void) const {return dump;}
+  void SetFuelDump(bool setting) {dump = setting;}
   double Transfer(int source, int target, double amount);
   void DoRefuel(double time_slice);
+  void DumpFuel(double time_slice);
 
   FGColumnVector3& GetTanksMoment(void);
   double GetTanksWeight(void);
 
-  ifstream* FindEngineFile(string filename);
-  string FindEngineFullPathname(string engine_filename);
+  std::ifstream* FindEngineFile(const std::string& filename);
+  std::string FindEngineFullPathname(const std::string& engine_filename);
   inline int GetActiveEngine(void) const {return ActiveEngine;}
   inline bool GetFuelFreeze(void) {return fuel_freeze;}
   double GetTotalFuelQuantity(void) const {return TotalFuelQuantity;}
@@ -182,13 +190,9 @@ public:
   void SetFuelFreeze(bool f);
   FGMatrix33& CalculateTankInertias(void);
 
-  void bind();
-  void unbind();
-
 private:
-  vector <FGEngine*>   Engines;
-  vector <FGTank*>     Tanks;
-  vector <FGTank*>::iterator iTank;
+  std::vector <FGEngine*>   Engines;
+  std::vector <FGTank*>     Tanks;
   unsigned int numSelectedFuelTanks;
   unsigned int numSelectedOxiTanks;
   unsigned int numFuelTanks;
@@ -202,8 +206,10 @@ private:
   FGColumnVector3 vXYZtank_arm;
   FGMatrix33 tankJ;
   bool refuel;
+  bool dump;
   bool fuel_freeze;
   double TotalFuelQuantity;
+  double DumpRate;
   bool IsBound;
   bool HavePistonEngine;
   bool HaveTurbineEngine;
@@ -211,6 +217,10 @@ private:
   bool HaveRocketEngine;
   bool HaveElectricEngine;
 
+  int InitializedEngines;
+  bool HasInitializedEngines;
+
+  void bind();
   void Debug(int from);
 };
 }