]> git.mxchange.org Git - flightgear.git/blob - src/FDM/YASim/Engine.hpp
FGPUIDialog: fix reading from already free'd memory.
[flightgear.git] / src / FDM / YASim / Engine.hpp
1 #ifndef _ENGINE_HPP
2 #define _ENGINE_HPP
3
4 namespace yasim {
5
6 class PistonEngine;
7 class TurbineEngine;
8
9 //
10 // Interface for the "Engine" part of a PropEngine object.  This is a
11 // virtual class, intended to be implemented by stuff like
12 // PistonEngine and TurbineEngine, and maybe exotics like
13 // SolarElectricEngine, etc...
14 //
15
16 class Engine {
17 public:
18     virtual PistonEngine* isPistonEngine() { return 0; }
19     virtual TurbineEngine* isTurbineEngine() { return 0; }
20
21     void setThrottle(float throttle) { _throttle = throttle; }
22     void setStarter(bool starter) { _starter = starter; }
23     void setMagnetos(int magnetos) { _magnetos = magnetos; }
24     void setMixture(float mixture) { _mixture = mixture; }
25     void setBoost(float boost) { _boost = boost; }
26     void setFuelState(bool hasFuel) { _fuel = hasFuel; }
27     void setRunning(bool r) { _running = r; }
28
29     bool isRunning() { return _running; }
30     virtual bool isCranking() { return false; }
31
32     virtual void calc(float pressure, float temp, float speed) = 0;
33     virtual void stabilize() {}
34     virtual void integrate(float dt) {}
35     virtual float getTorque() = 0;
36     virtual float getFuelFlow() = 0;
37
38     virtual ~Engine() {}
39 protected:
40     float _throttle;
41     bool _starter; // true=engaged, false=disengaged
42     int _magnetos; // 0=off, 1=right, 2=left, 3=both
43     float _mixture;
44     float _boost;
45     bool _fuel;
46     bool _running;
47 };
48
49 }; // namespace yasim
50 #endif // _ENGINE_HPP