1 /*******************************************************************************
7 ------------- Copyright (C) 2000 -------------
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.
26 FUNCTIONAL DESCRIPTION
27 --------------------------------------------------------------------------------
30 --------------------------------------------------------------------------------
32 ********************************************************************************
33 COMMENTS, REFERENCES, and NOTES
34 ********************************************************************************
36 ********************************************************************************
38 *******************************************************************************/
42 static const char *IdSrc = "$Header$";
43 static const char *IdHdr = ID_FILTER;
45 /*******************************************************************************
46 ************************************ CODE **************************************
47 *******************************************************************************/
49 FGFilter::FGFilter(FGFCS* fcs, FGConfigFile* AC_cfg) : FGFCSComponent(fcs),
54 Type = AC_cfg->GetValue("TYPE");
55 Name = AC_cfg->GetValue("NAME");
56 AC_cfg->GetNextConfigLine();
58 C1 = C2 = C3 = C4 = C5 = C6 = 0.0;
60 if (Type == "LAG_FILTER") FilterType = eLag ;
61 else if (Type == "RECT_LAG_FILTER") FilterType = eRectLag ;
62 else if (Type == "LEAD_LAG_FILTER") FilterType = eLeadLag ;
63 else if (Type == "SECOND_ORDER_FILTER") FilterType = eOrder2 ;
64 else if (Type == "WASHOUT_FILTER") FilterType = eWashout ;
65 else if (Type == "INTEGRATOR") FilterType = eIntegrator ;
66 else FilterType = eUnknown ;
68 while ((token = AC_cfg->GetValue()) != "/COMPONENT") {
72 } else if (token == "INPUT") {
73 token = AC_cfg->GetValue("INPUT");
74 if (token.find("FG_") != token.npos) {
76 InputIdx = fcs->GetState()->GetParameterIndex(token);
77 InputType = itPilotAC;
82 } else if (token == "C1") {
84 } else if (token == "C2") {
86 } else if (token == "C3") {
88 } else if (token == "C4") {
90 } else if (token == "C5") {
92 } else if (token == "C6") {
99 ca = dt*C1 / (2.00 + dt*C1);
100 cb = (2.00 - dt*C1) / (2.00 + dt*C1);
116 // *****************************************************************************
122 bool FGFilter::Run(void)
124 FGFCSComponent::Run(); // call the base class for initialization of Input
126 switch (FilterType) {
141 PreviousOutput2 = PreviousOutput1;
142 PreviousOutput1 = Output;
143 PreviousInput2 = PreviousInput1;
144 PreviousInput1 = Input;