| 1 | #ifndef _PROPENGINE_HPP |
| 2 | #define _PROPENGINE_HPP |
| 3 | |
| 4 | #include "Thruster.hpp" |
| 5 | #include "Engine.hpp" |
| 6 | |
| 7 | namespace yasim { |
| 8 | |
| 9 | class Propeller; |
| 10 | |
| 11 | class PropEngine : public Thruster { |
| 12 | public: |
| 13 | PropEngine(Propeller* prop, Engine* eng, float moment); |
| 14 | virtual ~PropEngine(); |
| 15 | |
| 16 | void setEngine(Engine* eng) { delete _eng; _eng = eng; } |
| 17 | |
| 18 | void setMagnetos(int magnetos); |
| 19 | void setAdvance(float advance); |
| 20 | void setPropPitch(float proppitch); |
| 21 | void setVariableProp(float min, float max); |
| 22 | void setPropFeather(int state); |
| 23 | void setGearRatio(float ratio) { _gearRatio = ratio; } |
| 24 | void setContraPair(bool contra) { _contra = contra; } |
| 25 | |
| 26 | virtual PropEngine* getPropEngine() { return this; } |
| 27 | virtual Engine* getEngine() { return _eng; } |
| 28 | virtual Propeller* getPropeller() { return _prop; } |
| 29 | |
| 30 | // Dynamic output |
| 31 | virtual bool isRunning(); |
| 32 | virtual bool isCranking(); |
| 33 | virtual void getThrust(float* out); |
| 34 | virtual void getTorque(float* out); |
| 35 | virtual void getGyro(float* out); |
| 36 | virtual float getFuelFlow(); |
| 37 | |
| 38 | // Runtime instructions |
| 39 | virtual void init(); |
| 40 | virtual void integrate(float dt); |
| 41 | virtual void stabilize(); |
| 42 | |
| 43 | float getOmega(); |
| 44 | void setOmega (float omega); |
| 45 | |
| 46 | private: |
| 47 | float _moment; |
| 48 | Propeller* _prop; |
| 49 | Engine* _eng; |
| 50 | |
| 51 | bool _variable; |
| 52 | bool _contra; // contra-rotating propeller pair |
| 53 | int _magnetos; // 0=off, 1=right, 2=left, 3=both |
| 54 | float _gearRatio; |
| 55 | float _advance; // control input, 0-1 |
| 56 | float _maxOmega; |
| 57 | float _minOmega; |
| 58 | |
| 59 | float _omega; // RPM, in radians/sec |
| 60 | float _thrust[3]; |
| 61 | float _torque[3]; |
| 62 | float _gyro[3]; |
| 63 | float _fuelFlow; |
| 64 | }; |
| 65 | |
| 66 | }; // namespace yasim |
| 67 | #endif // _PROPENGINE_HPP |