]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/FGFactorGroup.cpp
Fix stall widths for the "auxilliary" (reverse flow) stalls so they
[flightgear.git] / src / FDM / JSBSim / FGFactorGroup.cpp
1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2
3  Module:       FGFactorGroup.cpp
4  Author:       Tony Peden
5  Date started: 7/21/01
6  Purpose:      Encapsulates coefficients in the mathematical construct:
7                factor*(coeff1 + coeff2 + coeff3 + ... + coeffn)
8  Called by:    FGAerodynamics
9
10  ------------- Copyright (C) 2001 Tony Peden (apeden@earthlink.net) -----------
11
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
15  version.
16
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
20  details.
21
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.
25
26  Further information about the GNU General Public License can also be found on
27  the world wide web at http://www.gnu.org.
28
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.
33
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.
37
38 See the header file FGFactorGroup.h for the values of the identifiers.
39
40 HISTORY
41 --------------------------------------------------------------------------------
42 7/21/01   TP  Created
43
44 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
45 INCLUDES
46 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
47
48 #include "FGCoefficient.h"
49 #include "FGFactorGroup.h"
50 #include "FGState.h"
51 #include "FGFDMExec.h"
52
53 #ifndef FGFS
54 #  if defined(sgi) && !defined(__GNUC__) && (_COMPILER_VERSION < 740)
55 #    include <iomanip.h>
56 #  else
57 #    include <iomanip>
58 #  endif
59 #else
60 #  include STL_IOMANIP
61 #endif
62
63 namespace JSBSim {
64
65 static const char *IdSrc = "$Id$";
66 static const char *IdHdr = ID_FACTORGROUP;
67
68 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
69 CLASS IMPLEMENTATION
70 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
71
72 FGFactorGroup::FGFactorGroup( FGFDMExec* fdmex ) : FGCoefficient( fdmex)
73 {
74   FDMExec = fdmex;
75   totalValue = 0;
76   IsFactor = true;
77   Debug(0);
78 }  
79
80 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
81                           
82 FGFactorGroup::~FGFactorGroup()
83 {
84   for (unsigned int i=0; i<sum.size(); i++) delete sum[i];
85
86   Debug(1);
87 }
88
89 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
90
91 bool FGFactorGroup::Load(FGConfigFile *AC_cfg)
92 {
93   string token;
94   
95   if (AC_cfg) {
96     name = AC_cfg->GetValue("NAME");
97     AC_cfg->GetNextConfigLine();
98     *AC_cfg >> description;
99     token = AC_cfg->GetValue();
100     if (token == "FACTOR") {
101       FGCoefficient::Load(AC_cfg);
102     } 
103     token = AC_cfg->GetValue();  
104     while (token != string("/GROUP") ) {
105       sum.push_back( new FGCoefficient(FDMExec) );
106       sum.back()->Load(AC_cfg);
107       token = AC_cfg->GetValue(); 
108     }
109     AC_cfg->GetNextConfigLine();
110     return true;
111   } else {
112     return false;
113   }  
114 }  
115
116 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
117
118 double FGFactorGroup::TotalValue(void)
119 {
120   unsigned int i;
121   SDtotal = 0.0;
122   totalValue = 0.0;
123   for (i=0; i<sum.size(); i++) {
124      totalValue += sum[i]->TotalValue();
125      SDtotal += sum[i]->GetSD();
126   }
127   totalValue *= FGCoefficient::TotalValue();
128   SDtotal *= FGCoefficient::GetSD();
129   Debug(2);
130   return totalValue;
131 }
132
133 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
134
135 void FGFactorGroup::bind(FGPropertyManager* parent)
136 {
137   unsigned i;
138   node=parent->GetNode(name,true);
139   node->SetString("description",description);
140   FGCoefficient::bind(node);
141   for (i=0; i < sum.size(); i++) { 
142     sum[i]->bind(node);
143   } 
144   node=(FGPropertyManager*)node->getParent();                                         
145
146 }
147
148 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
149   
150 void FGFactorGroup::unbind(void)
151 {
152   unsigned i;
153   FGCoefficient::unbind();
154   for (i=0; i < sum.size(); i++) { 
155     sum[i]->unbind();
156   } 
157 }
158
159 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
160 //    The bitmasked value choices are as follows:
161 //    unset: In this case (the default) JSBSim would only print
162 //       out the normally expected messages, essentially echoing
163 //       the config files as they are read. If the environment
164 //       variable is not set, debug_lvl is set to 1 internally
165 //    0: This requests JSBSim not to output any messages
166 //       whatsoever.
167 //    1: This value explicity requests the normal JSBSim
168 //       startup messages
169 //    2: This value asks for a message to be printed out when
170 //       a class is instantiated
171 //    4: When this value is set, a message is displayed when a
172 //       FGModel object executes its Run() method
173 //    8: When this value is set, various runtime state variables
174 //       are printed out periodically
175 //    16: When set various parameters are sanity checked and
176 //       a message is printed out when they go out of bounds
177
178 void FGFactorGroup::Debug(int from)
179 {
180   if (debug_lvl <= 0) return;
181
182   if (debug_lvl & 1) { // Standard console startup message output
183   }
184   if (debug_lvl & 2 ) { // Instantiation/Destruction notification
185     if (from == 0) cout << "Instantiated: FGFactorGroup" << endl;
186     if (from == 1) cout << "Destroyed:    FGFactorGroup" << endl;
187   }
188   if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
189   }
190   if (debug_lvl & 8 ) { // Runtime state variables
191     if (from == 2) {
192       cout << "FGCoefficient::GetSD(): " << FGCoefficient::GetSD() << endl;
193       cout << "FGFactorGroup::SDtotal: " << SDtotal << endl;
194     }
195   }
196   if (debug_lvl & 16) { // Sanity checking
197   }
198   if (debug_lvl & 64) {
199     if (from == 0) { // Constructor
200       cout << IdSrc << endl;
201       cout << IdHdr << endl;
202     }
203   }
204 }
205
206 }