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 Lesser 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 Lesser General Public License for more
21 You should have received a copy of the GNU Lesser 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 Lesser 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 FGAerodynamics, FGPropagate, 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 "FGPropagate.h"
53 #include "FGAuxiliary.h"
57 static const char *IdSrc = "$Id$";
58 static const char *IdHdr = ID_MODEL;
60 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
62 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
64 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
66 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
68 FGModel::FGModel(FGFDMExec* fdmex)
85 //in order for FGModel derived classes to self-bind (that is, call
86 //their bind function in the constructor, the PropertyManager pointer
87 //must be brought up now.
88 PropertyManager = FDMExec->GetPropertyManager();
93 if (debug_lvl & 2) cout << " FGModel Base Class" << endl;
96 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
100 if (debug_lvl & 2) cout << "Destroyed: FGModel" << endl;
103 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
105 bool FGModel::InitModel(void)
107 State = FDMExec->GetState();
108 Atmosphere = FDMExec->GetAtmosphere();
109 FCS = FDMExec->GetFCS();
110 Propulsion = FDMExec->GetPropulsion();
111 MassBalance = FDMExec->GetMassBalance();
112 Aerodynamics = FDMExec->GetAerodynamics();
113 Inertial = FDMExec->GetInertial();
114 GroundReactions = FDMExec->GetGroundReactions();
115 Aircraft = FDMExec->GetAircraft();
116 Propagate = FDMExec->GetPropagate();
117 Auxiliary = FDMExec->GetAuxiliary();
129 !Auxiliary) return(false);
133 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
137 if (debug_lvl & 4) cout << "Entering Run() for model " << Name << endl;
139 if (exe_ctr++ >= rate) exe_ctr = 1;
141 if (exe_ctr == 1) return false;
145 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
146 // The bitmasked value choices are as follows:
147 // unset: In this case (the default) JSBSim would only print
148 // out the normally expected messages, essentially echoing
149 // the config files as they are read. If the environment
150 // variable is not set, debug_lvl is set to 1 internally
151 // 0: This requests JSBSim not to output any messages
153 // 1: This value explicity requests the normal JSBSim
155 // 2: This value asks for a message to be printed out when
156 // a class is instantiated
157 // 4: When this value is set, a message is displayed when a
158 // FGModel object executes its Run() method
159 // 8: When this value is set, various runtime state variables
160 // are printed out periodically
161 // 16: When set various parameters are sanity checked and
162 // a message is printed out when they go out of bounds
164 void FGModel::Debug(int from)
166 if (debug_lvl <= 0) return;
168 if (debug_lvl & 1) { // Standard console startup message output
169 if (from == 0) { // Constructor
173 if (debug_lvl & 2 ) { // Instantiation/Destruction notification
174 if (from == 0) cout << "Instantiated: FGModel" << endl;
175 if (from == 1) cout << "Destroyed: FGModel" << endl;
177 if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
179 if (debug_lvl & 8 ) { // Runtime state variables
181 if (debug_lvl & 16) { // Sanity checking
183 if (debug_lvl & 64) {
184 if (from == 0) { // Constructor
185 cout << IdSrc << endl;
186 cout << IdHdr << endl;