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 FGSummer::FGSummer(FGFCS* fcs, FGConfigFile* AC_cfg) : FGFCSComponent(fcs),
62 Type = AC_cfg->GetValue("TYPE");
63 Name = AC_cfg->GetValue("NAME");
64 AC_cfg->GetNextConfigLine();
66 while ((token = AC_cfg->GetValue()) != "/COMPONENT") {
72 cout << " ID: " << ID << endl;
74 } else if (token == "INPUT") {
76 token = AC_cfg->GetValue("INPUT");
77 cout << " INPUT: " << token << endl;
78 if (token.find("FG_") != token.npos) {
80 tmpInputIndex = fcs->GetState()->GetParameterIndex(token);
81 InputIndices.push_back(tmpInputIndex);
82 InputTypes.push_back(itPilotAC);
84 *AC_cfg >> tmpInputIndex;
85 InputIndices.push_back(tmpInputIndex);
86 InputTypes.push_back(itFCS);
89 } else if (token == "CLIPTO") {
91 *AC_cfg >> clipmin >> clipmax;
92 if (clipmax > clipmin) {
94 cout << " CLIPTO: " << clipmin << ", " << clipmax << endl;
97 } else if (token == "OUTPUT") {
100 *AC_cfg >> sOutputIdx;
101 cout << " OUTPUT: " <<sOutputIdx << endl;
102 OutputIdx = fcs->GetState()->GetParameterIndex(sOutputIdx);
107 // *****************************************************************************
113 bool FGSummer::Run(void )
117 // The Summer takes several inputs, so do not call the base class Run()
118 // FGFCSComponent::Run();
122 for (idx=0; idx<InputIndices.size(); idx++) {
123 switch (InputTypes[idx]) {
125 Output += fcs->GetState()->GetParameter(InputIndices[idx]);
128 Output += fcs->GetComponentOutput(InputIndices[idx]);
134 if (Output > clipmax) Output = clipmax;
135 else if (Output < clipmin) Output = clipmin;
138 if (IsOutput) SetOutput();