INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#include "FGJSBBase.h"
-#include "input_output/FGXMLFileRead.h"
-#include "math/FGColumnVector3.h"
#include <vector>
#include <string>
+#include "math/FGModelFunctions.h"
+#include "input_output/FGXMLFileRead.h"
+#include "input_output/FGXMLElement.h"
+#include "math/FGColumnVector3.h"
+
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_ENGINE "$Id$"
+#define ID_ENGINE "$Id: FGEngine.h,v 1.35 2012/04/14 18:10:44 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
namespace JSBSim {
class FGFDMExec;
-class FGState;
-class FGAtmosphere;
-class FGFCS;
-class FGAircraft;
-class FGPropagate;
-class FGPropulsion;
-class FGAuxiliary;
class FGThruster;
class Element;
class FGPropertyManager;
@endcode
<pre>
NOTES:
- Engines feed from all tanks equally.
- Not all thruster types can be matched with a given engine type. See the class
- documentation for engine and thruster classes.
+ Not all thruster types can be matched with a given engine type. See the class
+ documentation for engine and thruster classes.
</pre>
@author Jon S. Berndt
- @version $Id$
+ @version $Id: FGEngine.h,v 1.35 2012/04/14 18:10:44 bcoconni Exp $
*/
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CLASS DECLARATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-class FGEngine : public FGJSBBase, public FGXMLFileRead
+class FGEngine : public FGModelFunctions, public FGXMLFileRead
{
public:
- FGEngine(FGFDMExec* exec, Element* el, int engine_number);
+ struct Inputs {
+ double SLPressure;
+ double Pressure;
+ double PressureRatio;
+ double Temperature;
+ double Density;
+ double DensityRatio;
+ double Soundspeed;
+ double TotalPressure;
+ double TotalTempearture;
+ double TAT_c;
+ double Vt;
+ double Vc;
+ double qbar;
+ double alpha;
+ double beta;
+ double H_agl;
+ FGColumnVector3 AeroUVW;
+ FGColumnVector3 AeroPQR;
+ FGColumnVector3 PQR;
+ vector <double> ThrottleCmd;
+ vector <double> MixtureCmd;
+ vector <double> ThrottlePos;
+ vector <double> MixturePos;
+ vector <double> PropAdvance;
+ vector <bool> PropFeather;
+ FGColumnVector3 vXYZcg; // CG coordinates expressed in the structural frame
+ double TotalDeltaT;
+ };
+
+ FGEngine(FGFDMExec* exec, Element* el, int engine_number, struct Inputs& input);
virtual ~FGEngine();
enum EngineType {etUnknown, etRocket, etPiston, etTurbine, etTurboprop, etElectric};
- EngineType GetType(void) { return Type; }
- virtual string GetName(void) { return Name; }
+ EngineType GetType(void) const { return Type; }
+ virtual const string& GetName(void) const { return Name; }
// Engine controls
- virtual double GetThrottleMin(void) { return MinThrottle; }
- virtual double GetThrottleMax(void) { return MaxThrottle; }
- virtual double GetThrottle(void) { return Throttle; }
- virtual double GetMixture(void) { return Mixture; }
- virtual bool GetStarter(void) { return Starter; }
+ virtual double GetThrottleMin(void) const { return MinThrottle; }
+ virtual double GetThrottleMax(void) const { return MaxThrottle; }
+ virtual bool GetStarter(void) const { return Starter; }
virtual double getFuelFlow_gph () const {return FuelFlow_gph;}
virtual double getFuelFlow_pph () const {return FuelFlow_pph;}
virtual double GetFuelFlowRate(void) const {return FuelFlowRate;}
- virtual bool GetStarved(void) { return Starved; }
+ virtual double GetFuelFlowRateGPH(void) const {return FuelFlowRate*3600/6.02;}
+ virtual double GetFuelUsedLbs(void) const {return FuelUsedLbs;}
+ virtual bool GetStarved(void) const { return Starved; }
virtual bool GetRunning(void) const { return Running; }
- virtual bool GetCranking(void) { return Cranking; }
+ virtual bool GetCranking(void) const { return Cranking; }
virtual void SetStarved(bool tt) { Starved = tt; }
virtual void SetStarved(void) { Starved = true; }
virtual void SetRunning(bool bb) { Running=bb; }
- virtual void SetName(string name) { Name = name; }
- virtual void AddFeedTank(int tkID, int priority);
+ virtual void SetName(const string& name) { Name = name; }
virtual void SetFuelFreeze(bool f) { FuelFreeze = f; }
virtual void SetStarter(bool s) { Starter = s; }
/** Resets the Engine parameters to the initial conditions */
void ResetToIC(void);
- /** Calculates the thrust of the engine, and other engine functions.
- @return Thrust in pounds */
- virtual double Calculate(void) {return 0.0;}
+ /** Calculates the thrust of the engine, and other engine functions. */
+ virtual void Calculate(void) = 0;
+ virtual double GetThrust(void) const;
+
/// Sets engine placement information
- virtual void SetPlacement(FGColumnVector3& location, FGColumnVector3& orientation);
+ virtual void SetPlacement(const FGColumnVector3& location, const FGColumnVector3& orientation);
- virtual double GetPowerAvailable(void) {return 0.0;};
+ /** The fuel need is calculated based on power levels and flow rate for that
+ power level. It is also turned from a rate into an actual amount (pounds)
+ by multiplying it by the delta T and the rate.
+ @return Total fuel requirement for this engine in pounds. */
+ virtual double CalcFuelNeed(void);
- virtual bool GetTrimMode(void) {return TrimMode;}
- virtual void SetTrimMode(bool state) {TrimMode = state;}
+ virtual double CalcOxidizerNeed(void) {return 0.0;}
- virtual FGColumnVector3& GetBodyForces(void);
- virtual FGColumnVector3& GetMoments(void);
+ virtual double GetPowerAvailable(void) {return 0.0;};
+
+ virtual const FGColumnVector3& GetBodyForces(void);
+ virtual const FGColumnVector3& GetMoments(void);
bool LoadThruster(Element *el);
- FGThruster* GetThruster(void) {return Thruster;}
+ FGThruster* GetThruster(void) const {return Thruster;}
+
+ unsigned int GetSourceTank(unsigned int i) const;
+ unsigned int GetNumSourceTanks() const {return SourceTanks.size();}
virtual std::string GetEngineLabels(const std::string& delimiter) = 0;
virtual std::string GetEngineValues(const std::string& delimiter) = 0;
+ struct Inputs& in;
+ void LoadThrusterInputs();
+
protected:
/** Reduces the fuel in the active tanks by the amount required.
This function should be called from within the
derived class' Calculate() function before any other calculations are
done. This base class method removes fuel from the fuel tanks as
- appropriate, and sets the starved flag if necessary. */
- virtual void ConsumeFuel(void);
-
- /** The fuel need is calculated based on power levels and flow rate for that
- power level. It is also turned from a rate into an actual amount (pounds)
- by multiplying it by the delta T and the rate.
- @return Total fuel requirement for this engine in pounds. */
- virtual double CalcFuelNeed(void);
+ appropriate, and sets the starved flag if necessary. * /
+ virtual void ConsumeFuel(void); */
FGPropertyManager* PropertyManager;
std::string Name;
double MaxThrottle;
double MinThrottle;
- double Throttle;
- double Mixture;
double FuelExpended;
double FuelFlowRate;
double PctPower;
bool Starved;
bool Running;
bool Cranking;
- bool TrimMode;
bool FuelFreeze;
double FuelFlow_gph;
double FuelFlow_pph;
+ double FuelUsedLbs;
FGFDMExec* FDMExec;
- FGState* State;
- FGAtmosphere* Atmosphere;
- FGFCS* FCS;
- FGPropulsion* Propulsion;
- FGAircraft* Aircraft;
- FGPropagate* Propagate;
- FGAuxiliary* Auxiliary;
FGThruster* Thruster;
std::vector <int> SourceTanks;
+
void Debug(int from);
};
}