]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/FGState.h
Ron JENSEN: turn cout into SG_LOG/SG_WARN (merge from JSBSim/cvs)
[flightgear.git] / src / FDM / JSBSim / FGState.h
1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2
3  Header:       FGState.h
4  Author:       Jon S. Berndt
5  Date started: 11/17/98
6
7  ------------- Copyright (C) 1999  Jon S. Berndt (jsb@hal-pc.org) -------------
8
9  This program is free software; you can redistribute it and/or modify it under
10  the terms of the GNU Lesser General Public License as published by the Free Software
11  Foundation; either version 2 of the License, or (at your option) any later
12  version.
13
14  This program is distributed in the hope that it will be useful, but WITHOUT
15  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16  FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
17  details.
18
19  You should have received a copy of the GNU Lesser General Public License along with
20  this program; if not, write to the Free Software Foundation, Inc., 59 Temple
21  Place - Suite 330, Boston, MA  02111-1307, USA.
22
23  Further information about the GNU Lesser General Public License can also be found on
24  the world wide web at http://www.gnu.org.
25
26 FUNCTIONAL DESCRIPTION
27 --------------------------------------------------------------------------------
28
29 HISTORY
30 --------------------------------------------------------------------------------
31 11/17/98   JSB   Created
32
33 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
34 SENTRY
35 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
36
37 #ifndef FGSTATE_H
38 #define FGSTATE_H
39
40 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
41 INCLUDES
42 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
43
44 #ifdef FGFS
45 #  include <simgear/compiler.h>
46 #  ifdef SG_HAVE_STD_INCLUDES
47 #    include <fstream>
48 #  else
49 #    include <fstream.h>
50 #  endif
51 #else
52 #  if defined(sgi) && !defined(__GNUC__) && (_COMPILER_VERSION < 740)
53 #    include <fstream.h>
54 #  else
55 #    include <fstream>
56 #  endif
57 #endif
58
59 #include <string>
60 #include <map>
61 #include "FGJSBBase.h"
62 #include <initialization/FGInitialCondition.h>
63 #include <math/FGMatrix33.h>
64 #include <math/FGColumnVector3.h>
65 #include <math/FGQuaternion.h>
66 #include "FGFDMExec.h"
67 #include <models/FGAtmosphere.h>
68 #include <models/FGFCS.h>
69 #include <models/FGPropagate.h>
70 #include <models/FGAuxiliary.h>
71 #include <models/FGAerodynamics.h>
72 #include <models/FGAircraft.h>
73 #include <models/FGGroundReactions.h>
74 #include <models/FGPropulsion.h>
75
76 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
77 DEFINITIONS
78 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
79
80 #define ID_STATE "$Id$"
81
82 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
83 FORWARD DECLARATIONS
84 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
85
86 namespace JSBSim {
87
88 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
89 CLASS DOCUMENTATION
90 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
91
92 /** Encapsulates the calculation of aircraft state.
93     <h3>Properties</h3>
94     @property sim-time-sec (read only) cumulative simulation in seconds.
95     @author Jon S. Berndt
96     @version $Revision$
97 */
98
99 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
100 CLASS DECLARATION
101 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
102
103 class FGState : public FGJSBBase
104 {
105 public:
106   /** Constructor
107       @param Executive a pointer to the parent executive object */
108   FGState(FGFDMExec*);
109   /// Destructor
110   ~FGState();
111
112   /** Initializes the simulation state based on parameters from an Initial Conditions object.
113       @param FGIC pointer to an initial conditions object.
114       @see FGInitialConditions.    */
115   void Initialize(FGInitialCondition *FGIC);
116
117   /// Returns the cumulative simulation time in seconds.
118   inline double Getsim_time(void) const { return sim_time; }
119
120   /// Returns the simulation delta T.
121   inline double Getdt(void) {return dt;}
122
123   /// Suspends the simulation and sets the delta T to zero.
124   inline void SuspendIntegration(void) {saved_dt = dt; dt = 0.0;}
125
126   /// Resumes the simulation by resetting delta T to the correct value.
127   inline void ResumeIntegration(void)  {dt = saved_dt;}
128
129   /** Returns the simulation suspension state.
130       @return true if suspended, false if executing  */
131   bool IntegrationSuspended(void) {return dt == 0.0;}
132
133   /** Sets the current sim time.
134       @param cur_time the current time
135       @return the current simulation time.      */
136   inline double Setsim_time(double cur_time) {
137     sim_time = cur_time;
138     return sim_time;
139   }
140
141   /** Sets the integration time step for the simulation executive.
142       @param delta_t the time step in seconds.     */
143   inline void  Setdt(double delta_t) { dt = delta_t; }
144
145   /** Increments the simulation time.
146       @return the new simulation time.     */
147   inline double IncrTime(void) {
148     sim_time+=dt;
149     return sim_time;
150   }
151
152   /** Calculates and returns the stability-to-body axis transformation matrix.
153       @return a reference to the stability-to-body transformation matrix.
154       */
155   FGMatrix33& GetTs2b(void);
156
157   /** Calculates and returns the body-to-stability axis transformation matrix.
158       @return a reference to the stability-to-body transformation matrix.
159       */
160   FGMatrix33& GetTb2s(void);
161
162   /** Prints a summary of simulator state (speed, altitude,
163       configuration, etc.)  */
164   void ReportState(void);
165
166 private:
167   double sim_time, dt;
168   double saved_dt;
169
170   FGFDMExec* FDMExec;
171   FGMatrix33 mTs2b;
172   FGMatrix33 mTb2s;
173
174   FGAircraft* Aircraft;
175   FGPropagate* Propagate;
176   FGAtmosphere* Atmosphere;
177   FGFCS* FCS;
178   FGAerodynamics* Aerodynamics;
179   FGGroundReactions* GroundReactions;
180   FGPropulsion* Propulsion;
181   FGAuxiliary* Auxiliary;
182   FGPropertyManager* PropertyManager;
183
184   void bind();
185   void unbind();
186
187   void Debug(int from);
188 };
189 }
190 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
191
192
193 #endif
194