1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6 Purpose: Base class for all models
7 Called by: FGSimExec, et. al.
9 ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
11 This program is free software; you can redistribute it and/or modify it under
12 the terms of the GNU General Public License as published by the Free Software
13 Foundation; either version 2 of the License, or (at your option) any later
16 This program is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
21 You should have received a copy of the GNU General Public License along with
22 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
23 Place - Suite 330, Boston, MA 02111-1307, USA.
25 Further information about the GNU General Public License can also be found on
26 the world wide web at http://www.gnu.org.
28 FUNCTIONAL DESCRIPTION
29 --------------------------------------------------------------------------------
30 This base class for the FGAero, FGRotational, etc. classes defines methods
34 --------------------------------------------------------------------------------
37 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
39 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
43 #include "FGFDMExec.h"
44 #include "FGAtmosphere.h"
46 #include "FGPropulsion.h"
47 #include "FGMassBalance.h"
48 #include "FGAerodynamics.h"
49 #include "FGInertial.h"
50 #include "FGGroundReactions.h"
51 #include "FGAircraft.h"
52 #include "FGTranslation.h"
53 #include "FGRotation.h"
54 #include "FGPosition.h"
55 #include "FGAuxiliary.h"
60 static const char *IdSrc = "$Id$";
61 static const char *IdHdr = ID_MODEL;
63 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
65 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
67 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
69 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
71 FGModel::FGModel(FGFDMExec* fdmex)
91 //in order for FGModel derived classes to self-bind (that is, call
92 //their bind function in the constructor, the PropertyManager pointer
93 //must be brought up now.
94 PropertyManager = FDMExec->GetPropertyManager();
98 if (debug_lvl & 2) cout << " FGModel Base Class" << endl;
101 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
105 if (debug_lvl & 2) cout << "Destroyed: FGModel" << endl;
108 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
110 bool FGModel::InitModel(void)
112 State = FDMExec->GetState();
113 Atmosphere = FDMExec->GetAtmosphere();
114 FCS = FDMExec->GetFCS();
115 Propulsion = FDMExec->GetPropulsion();
116 MassBalance = FDMExec->GetMassBalance();
117 Aerodynamics = FDMExec->GetAerodynamics();
118 Inertial = FDMExec->GetInertial();
119 GroundReactions = FDMExec->GetGroundReactions();
120 Aircraft = FDMExec->GetAircraft();
121 Translation = FDMExec->GetTranslation();
122 Rotation = FDMExec->GetRotation();
123 Position = FDMExec->GetPosition();
124 Auxiliary = FDMExec->GetAuxiliary();
125 Output = FDMExec->GetOutput();
140 !Output) return(false);
144 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
148 if (debug_lvl & 4) cout << "Entering Run() for model " << Name << endl;
151 if (exe_ctr++ >= rate) exe_ctr = 1;
154 if (exe_ctr++ >= rate) exe_ctr = 1;
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
167 // 1: This value explicity requests the normal JSBSim
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
178 void FGModel::Debug(int from)
180 if (debug_lvl <= 0) return;
182 if (debug_lvl & 1) { // Standard console startup message output
183 if (from == 0) { // Constructor
187 if (debug_lvl & 2 ) { // Instantiation/Destruction notification
188 if (from == 0) cout << "Instantiated: FGModel" << endl;
189 if (from == 1) cout << "Destroyed: FGModel" << endl;
191 if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
193 if (debug_lvl & 8 ) { // Runtime state variables
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;