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 /*******************************************************************************
43 ************************************ CODE **************************************
44 *******************************************************************************/
46 // *****************************************************************************
47 // Function: constructor
52 FGFilter::FGFilter(FGFCS* fcs, FGConfigFile* AC_cfg) : FGFCSComponent(fcs),
57 Type = AC_cfg->GetValue("TYPE");
58 Name = AC_cfg->GetValue("NAME");
59 AC_cfg->GetNextConfigLine();
61 C1 = C2 = C3 = C4 = C5 = C6 = 0.0;
63 if (Type == "LAG_FILTER") FilterType = eLag ;
64 else if (Type == "RECT_LAG_FILTER") FilterType = eRectLag ;
65 else if (Type == "LEAD_LAG_FILTER") FilterType = eLeadLag ;
66 else if (Type == "SECOND_ORDER_FILTER") FilterType = eOrder2 ;
67 else if (Type == "WASHOUT_FILTER") FilterType = eWashout ;
68 else if (Type == "INTEGRATOR") FilterType = eIntegrator ;
69 else FilterType = eUnknown ;
71 while ((token = AC_cfg->GetValue()) != "/COMPONENT") {
75 } else if (token == "INPUT") {
76 token = AC_cfg->GetValue("INPUT");
77 if (token.find("FG_") != token.npos) {
79 InputIdx = fcs->GetState()->GetParameterIndex(token);
80 InputType = itPilotAC;
85 } else if (token == "C1") {
87 } else if (token == "C2") {
89 } else if (token == "C3") {
91 } else if (token == "C4") {
93 } else if (token == "C5") {
95 } else if (token == "C6") {
100 switch (FilterType) {
102 ca = dt*C1 / (2.00 + dt*C1);
103 cb = (2.00 - dt*C1) / (2.00 + dt*C1);
119 // *****************************************************************************
125 bool FGFilter::Run(void)
127 FGFCSComponent::Run(); // call the base class for initialization of Input
129 switch (FilterType) {
144 PreviousOutput2 = PreviousOutput1;
145 PreviousOutput1 = Output;
146 PreviousInput2 = PreviousInput1;
147 PreviousInput1 = Input;