From 7f5a91ea4750d2c58fd5b00db30a2d49779bb675 Mon Sep 17 00:00:00 2001 From: Henning Stahlke Date: Fri, 7 Apr 2017 22:36:07 +0200 Subject: [PATCH] YASim: refactoring loadControls() --- src/FDM/YASim/Airplane.cpp | 21 +++++---------------- src/FDM/YASim/Airplane.hpp | 5 +++-- 2 files changed, 8 insertions(+), 18 deletions(-) diff --git a/src/FDM/YASim/Airplane.cpp b/src/FDM/YASim/Airplane.cpp index 2c7e898af..cdc9ef8cc 100644 --- a/src/FDM/YASim/Airplane.cpp +++ b/src/FDM/YASim/Airplane.cpp @@ -770,11 +770,11 @@ void Airplane::setupWeights(bool isApproach) } /// load values for controls as defined in cruise configuration -void Airplane::loadCruiseControls() +void Airplane::loadControls(Vector& controls) { _controls.reset(); - for(int i=0; i<_cruiseControls.size(); i++) { - Control* c = (Control*)_cruiseControls.get(i); + for(int i=0; i < controls.size(); i++) { + Control* c = (Control*)controls.get(i); _controls.setInput(c->control, c->val); } _controls.applyControls(); @@ -789,7 +789,7 @@ void Airplane::runCruise() Atmosphere::calcStdDensity(_cruiseP, _cruiseT)); // The control configuration - loadCruiseControls(); + loadControls(_cruiseControls); // The local wind float wind[3]; @@ -818,17 +818,6 @@ void Airplane::runCruise() _model.calcForces(&_cruiseState); } -/// load values for controls as defined in approach configuration -void Airplane::loadApproachControls() -{ - _controls.reset(); - for(int i=0; i<_approachControls.size(); i++) { - Control* c = (Control*)_approachControls.get(i); - _controls.setInput(c->control, c->val); - } - _controls.applyControls(); -} - /// Helper for solve() void Airplane::runApproach() { @@ -838,7 +827,7 @@ void Airplane::runApproach() Atmosphere::calcStdDensity(_approachP, _approachT)); // The control configuration - loadApproachControls(); + loadControls(_approachControls); // The local wind float wind[3]; diff --git a/src/FDM/YASim/Airplane.hpp b/src/FDM/YASim/Airplane.hpp index 43e570778..13dcdc836 100644 --- a/src/FDM/YASim/Airplane.hpp +++ b/src/FDM/YASim/Airplane.hpp @@ -100,8 +100,8 @@ public: const char* getFailureMsg() { return _failureMsg; } static void setupState(const float aoa, const float speed, const float gla, yasim::State* s); // utility - void loadApproachControls(); - void loadCruiseControls(); + void loadApproachControls() { loadControls(_approachControls); } + void loadCruiseControls() { loadControls(_cruiseControls); } float getCGMinX() { return _cgMinX; } float getCGMaxX() { return _cgMaxX; } @@ -119,6 +119,7 @@ private: struct SolveWeight { bool approach; int idx; float wgt; }; struct ContactRec { Gear* gear; float p[3]; }; + void loadControls(Vector &controls); void runCruise(); void runApproach(); void solveGear();