X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FFDM%2FJSBSim%2FFGJSBBase.h;h=c4d0542460c2b4637dd6b7fcd255fe2ebe75b550;hb=9cd26d8b341fa32b617bb9ab851e0d557b7e0344;hp=8ec8e828bee9eb744f1b9892c47e41d1d7588ae3;hpb=f7f17a4744aaa1dbcd9e64b1a4bc97de888ed892;p=flightgear.git diff --git a/src/FDM/JSBSim/FGJSBBase.h b/src/FDM/JSBSim/FGJSBBase.h index 8ec8e828b..c4d054246 100644 --- a/src/FDM/JSBSim/FGJSBBase.h +++ b/src/FDM/JSBSim/FGJSBBase.h @@ -41,6 +41,7 @@ INCLUDES #include #include #include +#include #include using std::fabs; @@ -102,6 +103,27 @@ public: double dVal; }; + /// First order, (low pass / lag) filter + class Filter { + double prev_in; + double prev_out; + double ca; + double cb; + public: Filter(void) {} + public: Filter(double coeff, double dt) { + prev_in = prev_out = 0.0; + double denom = 2.0 + coeff*dt; + ca = coeff*dt/denom; + cb = (2.0 - coeff*dt)/denom; + } + public: double execute(double in) { + double out = (in + prev_in)*ca + prev_out*cb; + prev_in = in; + prev_out = out; + return out; + } + }; + ///@name JSBSim console output highlighting terms. //@{ /// highlights text @@ -303,6 +325,15 @@ protected: static const string needed_cfg_version; static const string JSBSim_version; + static string CreateIndexedPropertyName(string Property, int index) + { + std::stringstream str; + str << index; + string tmp; + str >> tmp; + return Property + "[" + tmp + "]"; + } + public: /// Moments L, M, N enum {eL = 1, eM, eN };