]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/FGState.h
Update to the latest version of JSBSim which supports Lighter Than Air craft
[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/FGColumnVector3.h>
64 #include <math/FGQuaternion.h>
65 #include "FGFDMExec.h"
66 #include <models/FGAtmosphere.h>
67 #include <models/FGFCS.h>
68 #include <models/FGPropagate.h>
69 #include <models/FGAuxiliary.h>
70 #include <models/FGAerodynamics.h>
71 #include <models/FGAircraft.h>
72 #include <models/FGGroundReactions.h>
73 #include <models/FGPropulsion.h>
74
75 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
76 DEFINITIONS
77 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
78
79 #define ID_STATE "$Id$"
80
81 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
82 FORWARD DECLARATIONS
83 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
84
85 namespace JSBSim {
86
87 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
88 CLASS DOCUMENTATION
89 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
90
91 /** Encapsulates the calculation of aircraft state.
92     <h3>Properties</h3>
93     @property sim-time-sec (read only) cumulative simulation in seconds.
94     @author Jon S. Berndt
95     @version $Revision$
96 */
97
98 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
99 CLASS DECLARATION
100 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
101
102 class FGState : public FGJSBBase
103 {
104 public:
105   /** Constructor
106       @param Executive a pointer to the parent executive object */
107   FGState(FGFDMExec*);
108   /// Destructor
109   ~FGState();
110
111   /** Initializes the simulation state based on parameters from an Initial Conditions object.
112       @param FGIC pointer to an initial conditions object.
113       @see FGInitialConditions.    */
114   void Initialize(FGInitialCondition *FGIC);
115
116   /// Returns the cumulative simulation time in seconds.
117   inline double Getsim_time(void) const { return sim_time; }
118
119   /// Returns the simulation delta T.
120   inline double Getdt(void) {return dt;}
121
122   /// Suspends the simulation and sets the delta T to zero.
123   inline void SuspendIntegration(void) {saved_dt = dt; dt = 0.0;}
124
125   /// Resumes the simulation by resetting delta T to the correct value.
126   inline void ResumeIntegration(void)  {dt = saved_dt;}
127
128   /** Returns the simulation suspension state.
129       @return true if suspended, false if executing  */
130   bool IntegrationSuspended(void) {return dt == 0.0;}
131
132   /** Sets the current sim time.
133       @param cur_time the current time
134       @return the current simulation time.      */
135   inline double Setsim_time(double cur_time) {
136     sim_time = cur_time;
137     return sim_time;
138   }
139
140   /** Sets the integration time step for the simulation executive.
141       @param delta_t the time step in seconds.     */
142   inline void  Setdt(double delta_t) { dt = delta_t; }
143
144   /** Increments the simulation time.
145       @return the new simulation time.     */
146   inline double IncrTime(void) {
147     sim_time+=dt;
148     return sim_time;
149   }
150
151   /** Prints a summary of simulator state (speed, altitude,
152       configuration, etc.)  */
153 //  void ReportState(void);
154
155 private:
156   double sim_time, dt;
157   double saved_dt;
158
159   FGFDMExec* FDMExec;
160
161   FGAircraft* Aircraft;
162   FGPropagate* Propagate;
163   FGAtmosphere* Atmosphere;
164   FGFCS* FCS;
165   FGAerodynamics* Aerodynamics;
166   FGGroundReactions* GroundReactions;
167   FGPropulsion* Propulsion;
168   FGAuxiliary* Auxiliary;
169   FGPropertyManager* PropertyManager;
170
171   void bind();
172
173   void Debug(int from);
174 };
175 }
176 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
177
178
179 #endif
180