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_SUMMER;
45 /*******************************************************************************
46 ************************************ CODE **************************************
47 *******************************************************************************/
49 FGSummer::FGSummer(FGFCS* fcs, FGConfigFile* AC_cfg) : FGFCSComponent(fcs),
59 Type = AC_cfg->GetValue("TYPE");
60 Name = AC_cfg->GetValue("NAME");
61 AC_cfg->GetNextConfigLine();
63 while ((token = AC_cfg->GetValue()) != "/COMPONENT") {
69 cout << " ID: " << ID << endl;
71 } else if (token == "INPUT") {
73 token = AC_cfg->GetValue("INPUT");
74 cout << " INPUT: " << token << endl;
75 if (token.find("FG_") != token.npos) {
77 tmpInputIndex = fcs->GetState()->GetParameterIndex(token);
78 InputIndices.push_back(tmpInputIndex);
79 InputTypes.push_back(itPilotAC);
81 *AC_cfg >> tmpInputIndex;
82 InputIndices.push_back(tmpInputIndex);
83 InputTypes.push_back(itFCS);
86 } else if (token == "CLIPTO") {
88 *AC_cfg >> clipmin >> clipmax;
89 if (clipmax > clipmin) {
91 cout << " CLIPTO: " << clipmin << ", " << clipmax << endl;
94 } else if (token == "OUTPUT") {
97 *AC_cfg >> sOutputIdx;
98 cout << " OUTPUT: " <<sOutputIdx << endl;
99 OutputIdx = fcs->GetState()->GetParameterIndex(sOutputIdx);
104 // *****************************************************************************
110 bool FGSummer::Run(void )
114 // The Summer takes several inputs, so do not call the base class Run()
115 // FGFCSComponent::Run();
119 for (idx=0; idx<InputIndices.size(); idx++) {
120 switch (InputTypes[idx]) {
122 Output += fcs->GetState()->GetParameter(InputIndices[idx]);
125 Output += fcs->GetComponentOutput(InputIndices[idx]);
131 if (Output > clipmax) Output = clipmax;
132 else if (Output < clipmin) Output = clipmin;
135 if (IsOutput) SetOutput();