1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7 ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
9 This program is free software; you can redistribute it and/or modify it under
10 the terms of the GNU General Public License as published by the Free Software
11 Foundation; either version 2 of the License, or (at your option) any later
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 General Public License for more
19 You should have received a copy of the GNU 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.
23 Further information about the GNU General Public License can also be found on
24 the world wide web at http://www.gnu.org.
26 FUNCTIONAL DESCRIPTION
27 --------------------------------------------------------------------------------
30 --------------------------------------------------------------------------------
33 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
35 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
40 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
42 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
45 # include <simgear/compiler.h>
46 # ifdef SG_HAVE_STD_INCLUDES
52 # if defined(sgi) && !defined(__GNUC__) && (_COMPILER_VERSION < 740)
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>
76 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
78 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
80 #define ID_STATE "$Id$"
82 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
84 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
88 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
90 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
92 /** Encapsulates the calculation of aircraft state.
97 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
99 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
101 class FGState : public FGJSBBase
105 @param Executive a pointer to the parent executive object */
110 /** Initializes the simulation state based on parameters from an Initial Conditions object.
111 @param FGIC pointer to an initial conditions object.
112 @see FGInitialConditions.
114 void Initialize(FGInitialCondition *FGIC);
116 /// Returns the simulation time in seconds.
117 inline double Getsim_time(void) const { return sim_time; }
118 /// Returns the simulation delta T.
119 inline double Getdt(void) {
123 /// Suspends the simulation and sets the delta T to zero.
124 inline void SuspendIntegration(void) {saved_dt = dt; dt = 0.0;}
125 /// Resumes the simulation by resetting delta T to the correct value.
126 inline void ResumeIntegration(void) {dt = saved_dt;}
128 bool IntegrationSuspended(void) {return dt == 0.0;}
130 /** Sets the current sim time.
131 @param cur_time the current time
132 @return the current time.
134 inline double Setsim_time(double cur_time) {
139 /** Sets the integration time step for the simulation executive.
140 @param delta_t the time step in seconds.
142 inline void Setdt(double delta_t) {
146 /** Increments the simulation time.
147 @return the new simulation time.
149 inline double IncrTime(void) {
154 /** Calculates and returns the stability-to-body axis transformation matrix.
155 @return a reference to the stability-to-body transformation matrix.
157 FGMatrix33& GetTs2b(void);
159 /** Calculates and returns the body-to-stability axis transformation matrix.
160 @return a reference to the stability-to-body transformation matrix.
162 FGMatrix33& GetTb2s(void);
164 /** Prints a summary of simulator state (speed, altitude,
167 void ReportState(void);
180 FGAircraft* Aircraft;
181 FGPropagate* Propagate;
182 FGAtmosphere* Atmosphere;
184 FGAerodynamics* Aerodynamics;
185 FGGroundReactions* GroundReactions;
186 FGPropulsion* Propulsion;
187 FGAuxiliary* Auxiliary;
188 FGPropertyManager* PropertyManager;
190 void Debug(int from);
193 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%