1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6 Purpose: Base class for all models
7 Called by: FGSimExec, et. al.
9 ------------- Copyright (C) 1999 Jon S. Berndt (jon@jsbsim.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 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
42 #include "FGFDMExec.h"
43 #include "FGAtmosphere.h"
45 #include "FGPropulsion.h"
46 #include "FGMassBalance.h"
47 #include "FGAerodynamics.h"
48 #include "FGInertial.h"
49 #include "FGGroundReactions.h"
50 #include "FGExternalReactions.h"
51 #include "FGAircraft.h"
52 #include "FGPropagate.h"
53 #include "FGAuxiliary.h"
60 static const char *IdSrc = "$Id: FGModel.cpp,v 1.16 2010/11/18 12:38:06 jberndt Exp $";
61 static const char *IdHdr = ID_MODEL;
63 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
65 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
67 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
69 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
71 FGModel::FGModel(FGFDMExec* fdmex)
75 //in order for FGModel derived classes to self-bind (that is, call
76 //their bind function in the constructor, the PropertyManager pointer
77 //must be brought up now.
78 PropertyManager = FDMExec->GetPropertyManager();
83 if (debug_lvl & 2) cout << " FGModel Base Class" << endl;
86 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
90 if (debug_lvl & 2) cout << "Destroyed: FGModel" << endl;
93 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
95 bool FGModel::InitModel(void)
100 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
104 if (debug_lvl & 4) cout << "Entering Run() for model " << Name << endl;
106 if (rate == 1) return false; // Fast exit if nothing to do
108 if (exe_ctr >= rate) exe_ctr = 1;
110 if (exe_ctr++ == 1) return false;
114 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
115 // The bitmasked value choices are as follows:
116 // unset: In this case (the default) JSBSim would only print
117 // out the normally expected messages, essentially echoing
118 // the config files as they are read. If the environment
119 // variable is not set, debug_lvl is set to 1 internally
120 // 0: This requests JSBSim not to output any messages
122 // 1: This value explicity requests the normal JSBSim
124 // 2: This value asks for a message to be printed out when
125 // a class is instantiated
126 // 4: When this value is set, a message is displayed when a
127 // FGModel object executes its Run() method
128 // 8: When this value is set, various runtime state variables
129 // are printed out periodically
130 // 16: When set various parameters are sanity checked and
131 // a message is printed out when they go out of bounds
133 void FGModel::Debug(int from)
135 if (debug_lvl <= 0) return;
137 if (debug_lvl & 1) { // Standard console startup message output
138 if (from == 0) { // Constructor
142 if (debug_lvl & 2 ) { // Instantiation/Destruction notification
143 if (from == 0) cout << "Instantiated: FGModel" << endl;
144 if (from == 1) cout << "Destroyed: FGModel" << endl;
146 if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
148 if (debug_lvl & 8 ) { // Runtime state variables
150 if (debug_lvl & 16) { // Sanity checking
152 if (debug_lvl & 64) {
153 if (from == 0) { // Constructor
154 cout << IdSrc << endl;
155 cout << IdHdr << endl;