1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 Module: FGFactorGroup.cpp
6 Purpose: Encapsulates coefficients in the mathematical construct:
7 factor*(coeff1 + coeff2 + coeff3 + ... + coeffn)
8 Called by: FGAerodynamics
10 ------------- Copyright (C) 2001 Tony Peden (apeden@earthlink.net) -----------
12 This program is free software; you can redistribute it and/or modify it under
13 the terms of the GNU General Public License as published by the Free Software
14 Foundation; either version 2 of the License, or (at your option) any later
17 This program is distributed in the hope that it will be useful, but WITHOUT
18 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
19 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
22 You should have received a copy of the GNU General Public License along with
23 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
24 Place - Suite 330, Boston, MA 02111-1307, USA.
26 Further information about the GNU General Public License can also be found on
27 the world wide web at http://www.gnu.org.
29 FUNCTIONAL DESCRIPTION
30 --------------------------------------------------------------------------------
31 This class models the stability derivative coefficient lookup tables or
32 equations. Note that the coefficients need not be calculated each delta-t.
34 Note that the values in a row which index into the table must be the same value
35 for each column of data, so the first column of numbers for each altitude are
36 seen to be equal, and there are the same number of values for each altitude.
38 See the header file FGFactorGroup.h for the values of the identifiers.
41 --------------------------------------------------------------------------------
44 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
46 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
48 #include "FGCoefficient.h"
49 #include "FGFactorGroup.h"
51 #include "FGFDMExec.h"
54 # if defined(sgi) && !defined(__GNUC__) && (_COMPILER_VERSION < 740)
65 static const char *IdSrc = "$Id$";
66 static const char *IdHdr = ID_FACTORGROUP;
68 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
70 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
72 FGFactorGroup::FGFactorGroup( FGFDMExec* fdmex ) : FGCoefficient( fdmex)
79 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
81 FGFactorGroup::~FGFactorGroup()
83 for (unsigned int i=0; i<sum.size(); i++) delete sum[i];
88 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
90 bool FGFactorGroup::Load(FGConfigFile *AC_cfg)
95 name = AC_cfg->GetValue("NAME");
96 AC_cfg->GetNextConfigLine();
97 *AC_cfg >> description;
98 token = AC_cfg->GetValue();
99 if (token == "FACTOR") {
100 FGCoefficient::Load(AC_cfg);
102 token = AC_cfg->GetValue();
103 while (token != string("/GROUP") ) {
104 sum.push_back( new FGCoefficient(FDMExec) );
105 sum.back()->Load(AC_cfg);
106 token = AC_cfg->GetValue();
108 AC_cfg->GetNextConfigLine();
115 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
117 double FGFactorGroup::TotalValue(void)
122 for (i=0; i<sum.size(); i++) {
123 totalValue += sum[i]->TotalValue();
124 SDtotal += sum[i]->GetSD();
126 totalValue *= FGCoefficient::TotalValue();
127 SDtotal *= FGCoefficient::GetSD();
132 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
134 void FGFactorGroup::bind(FGPropertyManager* parent)
137 node=parent->GetNode(name,true);
138 node->SetString("description",description);
139 FGCoefficient::bind(node);
140 for (i=0; i < sum.size(); i++) {
143 node=(FGPropertyManager*)node->getParent();
147 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
149 void FGFactorGroup::unbind(void)
152 FGCoefficient::unbind();
153 for (i=0; i < sum.size(); i++) {
158 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
159 // The bitmasked value choices are as follows:
160 // unset: In this case (the default) JSBSim would only print
161 // out the normally expected messages, essentially echoing
162 // the config files as they are read. If the environment
163 // variable is not set, debug_lvl is set to 1 internally
164 // 0: This requests JSBSim not to output any messages
166 // 1: This value explicity requests the normal JSBSim
168 // 2: This value asks for a message to be printed out when
169 // a class is instantiated
170 // 4: When this value is set, a message is displayed when a
171 // FGModel object executes its Run() method
172 // 8: When this value is set, various runtime state variables
173 // are printed out periodically
174 // 16: When set various parameters are sanity checked and
175 // a message is printed out when they go out of bounds
177 void FGFactorGroup::Debug(int from)
179 if (debug_lvl <= 0) return;
181 if (debug_lvl & 1) { // Standard console startup message output
183 if (debug_lvl & 2 ) { // Instantiation/Destruction notification
184 if (from == 0) cout << "Instantiated: FGFactorGroup" << endl;
185 if (from == 1) cout << "Destroyed: FGFactorGroup" << endl;
187 if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
189 if (debug_lvl & 8 ) { // Runtime state variables
191 cout << "FGCoefficient::GetSD(): " << FGCoefficient::GetSD() << endl;
192 cout << "FGFactorGroup::SDtotal: " << SDtotal << endl;
195 if (debug_lvl & 16) { // Sanity checking
197 if (debug_lvl & 64) {
198 if (from == 0) { // Constructor
199 cout << IdSrc << endl;
200 cout << IdHdr << endl;