diff --git a/src/FDM/YASim/ControlMap.cpp b/src/FDM/YASim/ControlMap.cpp index 51f527594..87bf3b80d 100644 --- a/src/FDM/YASim/ControlMap.cpp +++ b/src/FDM/YASim/ControlMap.cpp @@ -2,6 +2,7 @@ #include "Thruster.hpp" #include "PropEngine.hpp" #include "PistonEngine.hpp" +#include "TurbineEngine.hpp" #include "Gear.hpp" #include "Wing.hpp" #include "Rotor.hpp" @@ -186,10 +187,12 @@ void ControlMap::applyControls(float dt) switch(o->type) { case THROTTLE: ((Thruster*)obj)->setThrottle(lval); break; case MIXTURE: ((Thruster*)obj)->setMixture(lval); break; + case CONDLEVER: ((TurbineEngine*)((PropEngine*)obj)->getEngine())->setCondLever(lval); break; case STARTER: ((Thruster*)obj)->setStarter(lval != 0.0); break; case MAGNETOS: ((PropEngine*)obj)->setMagnetos((int)lval); break; case ADVANCE: ((PropEngine*)obj)->setAdvance(lval); break; - case PROPPITCH: ((PropEngine*)obj)->setPropPitch(lval); break; + case PROPPITCH: ((PropEngine*)obj)->setPropPitch(lval); break; + case PROPFEATHER: ((PropEngine*)obj)->setPropFeather((int)lval); break; case REHEAT: ((Jet*)obj)->setReheat(lval); break; case VECTOR: ((Jet*)obj)->setRotation(lval); break; case BRAKE: ((Gear*)obj)->setBrake(lval); break; diff --git a/src/FDM/YASim/ControlMap.hpp b/src/FDM/YASim/ControlMap.hpp index 07d15f301..415f80532 100644 --- a/src/FDM/YASim/ControlMap.hpp +++ b/src/FDM/YASim/ControlMap.hpp @@ -9,11 +9,11 @@ class ControlMap { public: ~ControlMap(); - enum OutputType { THROTTLE, MIXTURE, STARTER, MAGNETOS, + enum OutputType { THROTTLE, MIXTURE, CONDLEVER, STARTER, MAGNETOS, ADVANCE, REHEAT, PROP, BRAKE, STEER, EXTEND, INCIDENCE, FLAP0, FLAP1, SLAT, SPOILER, VECTOR, - BOOST, CASTERING, PROPPITCH, + BOOST, CASTERING, PROPPITCH, PROPFEATHER, COLLECTIVE, CYCLICAIL, CYCLICELE, ROTORENGINEON, REVERSE_THRUST }; diff --git a/src/FDM/YASim/FGFDM.cpp b/src/FDM/YASim/FGFDM.cpp index 577a8c28f..258a3424b 100644 --- a/src/FDM/YASim/FGFDM.cpp +++ b/src/FDM/YASim/FGFDM.cpp @@ -393,7 +393,7 @@ void FGFDM::getExternalInput(float dt) void FGFDM::setOutputProperties() { - char buf[256]; + // char buf[256]; int i; float grossWgt = _airplane.getModel()->getBody()->getTotalMass() * KG2LBS; @@ -726,6 +726,7 @@ int FGFDM::parseAxis(const char* name) // Not there, make a new one. AxisRec* a = new AxisRec(); a->name = dup(name); + fgGetNode( a->name, true ); // make sure the property name exists a->handle = _airplane.getControlMap()->newInput(); _axes.add(a); return a->handle; @@ -735,6 +736,7 @@ int FGFDM::parseOutput(const char* name) { if(eq(name, "THROTTLE")) return ControlMap::THROTTLE; if(eq(name, "MIXTURE")) return ControlMap::MIXTURE; + if(eq(name, "CONDLEVER")) return ControlMap::CONDLEVER; if(eq(name, "STARTER")) return ControlMap::STARTER; if(eq(name, "MAGNETOS")) return ControlMap::MAGNETOS; if(eq(name, "ADVANCE")) return ControlMap::ADVANCE; @@ -752,6 +754,7 @@ int FGFDM::parseOutput(const char* name) if(eq(name, "SPOILER")) return ControlMap::SPOILER; if(eq(name, "CASTERING")) return ControlMap::CASTERING; if(eq(name, "PROPPITCH")) return ControlMap::PROPPITCH; + if(eq(name, "PROPFEATHER")) return ControlMap::PROPFEATHER; if(eq(name, "COLLECTIVE")) return ControlMap::COLLECTIVE; if(eq(name, "CYCLICAIL")) return ControlMap::CYCLICAIL; if(eq(name, "CYCLICELE")) return ControlMap::CYCLICELE; diff --git a/src/FDM/YASim/PropEngine.cpp b/src/FDM/YASim/PropEngine.cpp index 0213358fc..74c29f317 100644 --- a/src/FDM/YASim/PropEngine.cpp +++ b/src/FDM/YASim/PropEngine.cpp @@ -41,6 +41,12 @@ void PropEngine::setPropPitch(float proppitch) _prop->setPropPitch(proppitch); } +void PropEngine::setPropFeather(int state) +{ + // toggle prop feathering on/off + _prop->setPropFeather(state); +} + void PropEngine::setVariableProp(float min, float max) { _variable = true; @@ -99,6 +105,8 @@ void PropEngine::stabilize() _eng->setStarter(false); _eng->setMagnetos(3); + + bool running_state = _eng->isRunning(); _eng->setRunning(true); if(_variable) { @@ -141,7 +149,7 @@ void PropEngine::stabilize() } // ...and back off - _eng->setRunning(false); + _eng->setRunning(running_state); } void PropEngine::init() diff --git a/src/FDM/YASim/PropEngine.hpp b/src/FDM/YASim/PropEngine.hpp index 4094b2d2c..2e9e7c3c6 100644 --- a/src/FDM/YASim/PropEngine.hpp +++ b/src/FDM/YASim/PropEngine.hpp @@ -19,6 +19,7 @@ public: void setAdvance(float advance); void setPropPitch(float proppitch); void setVariableProp(float min, float max); + void setPropFeather(int state); void setGearRatio(float ratio) { _gearRatio = ratio; } virtual PropEngine* getPropEngine() { return this; } diff --git a/src/FDM/YASim/Propeller.cpp b/src/FDM/YASim/Propeller.cpp index 661a3842e..a49f0dad8 100644 --- a/src/FDM/YASim/Propeller.cpp +++ b/src/FDM/YASim/Propeller.cpp @@ -24,6 +24,7 @@ Propeller::Propeller(float radius, float v, float omega, _matchTakeoff = false; _manual = false; _proppitch = 0; + _propfeather = 0; } void Propeller::setTakeoff(float omega0, float power0) @@ -55,6 +56,12 @@ void Propeller::setPropPitch(float proppitch) _proppitch = Math::clamp(proppitch, 0, 1); } +void Propeller::setPropFeather(int state) +{ + // 0 = normal, 1 = feathered + _propfeather = (state != 0); +} + void Propeller::calc(float density, float v, float omega, float* thrustOut, float* torqueOut) { diff --git a/src/FDM/YASim/Propeller.hpp b/src/FDM/YASim/Propeller.hpp index cd6ee547d..5a5905e2f 100644 --- a/src/FDM/YASim/Propeller.hpp +++ b/src/FDM/YASim/Propeller.hpp @@ -22,6 +22,8 @@ public: void setPropPitch(float proppitch); + void setPropFeather(int state); + void setManualPitch(); void calc(float density, float v, float omega, @@ -37,8 +39,9 @@ private: float _beta; // constant, ~1.48058; float _tc0; // thrust "coefficient" at takeoff bool _matchTakeoff; // Does _tc0 mean anything? - bool _manual; // manual pitch mode - float _proppitch; // prop pitch control setting (0 ~ 1.0) + bool _manual; // manual pitch mode + float _proppitch; // prop pitch control setting (0 ~ 1.0) + float _propfeather; // prop feather control setting (0 = norm, 1 = feather) }; }; // namespace yasim diff --git a/src/FDM/YASim/Thruster.cpp b/src/FDM/YASim/Thruster.cpp index 20b4a6c7b..cd57745a6 100644 --- a/src/FDM/YASim/Thruster.cpp +++ b/src/FDM/YASim/Thruster.cpp @@ -50,6 +50,7 @@ void Thruster::setMixture(float mixture) _mixture = Math::clamp(mixture, 0, 1); } + void Thruster::setStarter(bool starter) { _starter = starter; diff --git a/src/FDM/YASim/TurbineEngine.cpp b/src/FDM/YASim/TurbineEngine.cpp index 81580c62d..ee79fcdb1 100644 --- a/src/FDM/YASim/TurbineEngine.cpp +++ b/src/FDM/YASim/TurbineEngine.cpp @@ -7,6 +7,8 @@ namespace yasim { TurbineEngine::TurbineEngine(float power, float omega, float alt, float flatRating) { + // _cond_lever = 1.0; + _rho0 = Atmosphere::getStdDensity(0); _maxTorque = (power/omega) * _rho0 / Atmosphere::getStdDensity(alt); _flatRating = flatRating; @@ -19,6 +21,8 @@ TurbineEngine::TurbineEngine(float power, float omega, float alt, _n2 = _n2Target = _n2Min; _torque = 0; _fuelFlow = 0; + + _running = true; } void TurbineEngine::setOutputFromN2() @@ -46,7 +50,12 @@ void TurbineEngine::integrate(float dt) void TurbineEngine::calc(float pressure, float temp, float omega) { - _running = true; + if ( _cond_lever < 0.001 ) { + _running = false; + } else { + _running = true; + } + _omega = omega; _rho = Atmosphere::calcStdDensity(pressure, temp); @@ -56,7 +65,12 @@ void TurbineEngine::calc(float pressure, float temp, float omega) torque = _flatRating / omega; float frac = torque / (_maxTorque * (_rho / _rho0)); - _n2Target = _n2Min + (_n2Max - _n2Min) * frac; + + if ( _running ) { + _n2Target = _n2Min + (_n2Max - _n2Min) * frac; + } else { + _n2Target = 0; + } } }; // namespace yasim diff --git a/src/FDM/YASim/TurbineEngine.hpp b/src/FDM/YASim/TurbineEngine.hpp index 09c0233d2..3f14edb21 100644 --- a/src/FDM/YASim/TurbineEngine.hpp +++ b/src/FDM/YASim/TurbineEngine.hpp @@ -17,6 +17,9 @@ public: virtual void stabilize(); virtual void integrate(float dt); + void setCondLever( float lever ) { + _cond_lever = lever; + } virtual float getTorque() { return _torque; } virtual float getFuelFlow() { return _fuelFlow; } float getN2() { return _n2; } @@ -24,6 +27,8 @@ public: private: void setOutputFromN2(); + float _cond_lever; + float _maxTorque; float _flatRating; float _rho0;