1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7 ------------- Copyright (C) -------------
9 This program is free software; you can redistribute it and/or modify it under
10 the terms of the GNU General Public License as published by the Free Software
11 Foundation; either version 2 of the License, or (at your option) any later
14 This program is distributed in the hope that it will be useful, but WITHOUT
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
19 You should have received a copy of the GNU General Public License along with
20 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
21 Place - Suite 330, Boston, MA 02111-1307, USA.
23 Further information about the GNU General Public License can also be found on
24 the world wide web at http://www.gnu.org.
27 --------------------------------------------------------------------------------
29 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
31 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
36 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
38 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
40 #include "FGFCSComponent.h"
41 #include "../FGConfigFile.h"
43 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
45 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
47 #define ID_FILTER "$Id$"
49 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
51 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
55 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
57 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
59 /** Encapsulates a filter for the flight control system.
60 The filter component can simulate any filter up to second order. The
61 Tustin substitution is used to take filter definitions from LaPlace space to the
62 time domain. The general format for a filter specification is:
65 \<COMPONENT NAME="name" TYPE="type">
77 For a lag filter of the form,
83 the corresponding filter definition is:
85 \<COMPONENT NAME="name" TYPE="LAG_FILTER">
91 As an example, for the specific filter:
97 the corresponding filter definition could be:
99 \<COMPONENT NAME="LAG_1" TYPE="LAG_FILTER">
104 For a lead-lag filter of the form:
110 The corresponding filter definition is:
112 \<COMPONENT NAME="name" TYPE="LEAD_LAG_FILTER">
121 For a washout filter of the form:
127 The corresponding filter definition is:
129 \<COMPONENT NAME="name" TYPE="WASHOUT_FILTER">
135 For a second order filter of the form:
141 The corresponding filter definition is:
143 \<COMPONENT NAME="name" TYPE="SECOND_ORDER_FILTER">
154 For an integrator of the form:
160 The corresponding filter definition is:
162 \<COMPONENT NAME="name" TYPE="INTEGRATOR">
166 [TRIGGER \<property>]
169 For the integrator, the TRIGGER features the following behavior, if the TRIGGER
171 - -1 (or simply less than zero), all previous inputs and outputs are set to 0.0
172 - 0, no action is taken - the output is calculated normally
173 - +1 (or simply greater than zero), all previous outputs (only) will be set to 0.0
175 In all the filter specifications above, an [OUTPUT] keyword is also seen. This
176 is so that the last component in a "string" can copy its value to the appropriate
177 output, such as the elevator, or speedbrake, etc.
179 @author Jon S. Berndt
183 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
185 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
187 class FGFilter : public FGFCSComponent
190 FGFilter(FGFCS* fcs, FGConfigFile* AC_cfg);
195 /** When true, causes previous values to be set to current values. This
196 is particularly useful for first pass. */
199 enum {eLag, eLeadLag, eOrder2, eWashout, eIntegrator, eUnknown} FilterType;
214 double PreviousInput1;
215 double PreviousInput2;
216 double PreviousOutput1;
217 double PreviousOutput2;
218 FGConfigFile* AC_cfg;
219 FGPropertyManager* Trigger;
220 void Debug(int from);