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