]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/FGState.h
10896b4f50c8195cfa13841661e5329923b362ee
[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 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 General Public License for more
17  details.
18  
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.
22  
23  Further information about the GNU 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 Based on Flightgear code, which is based on LaRCSim. This class wraps all
30 global state variables (such as velocity, position, orientation, etc.).
31  
32 HISTORY
33 --------------------------------------------------------------------------------
34 11/17/98   JSB   Created
35  
36 ********************************************************************************
37 SENTRY
38 *******************************************************************************/
39
40 #ifndef FGSTATE_H
41 #define FGSTATE_H
42
43 /*******************************************************************************
44 INCLUDES
45 *******************************************************************************/
46
47 #ifdef FGFS
48 #  include <simgear/compiler.h>
49 #  ifdef FG_HAVE_STD_INCLUDES
50 #    include <fstream>
51 #  else
52 #    include <fstream.h>
53 #  endif
54 #else
55 #  include <fstream>
56 #endif
57
58 #include <string>
59 #include <map>
60 #include "FGDefs.h"
61 #include "FGInitialCondition.h"
62 #include "FGMatrix.h"
63
64 /*******************************************************************************
65 DEFINES
66 *******************************************************************************/
67
68 /*******************************************************************************
69 CLASS DECLARATION
70 *******************************************************************************/
71
72 class FGFDMExec;
73
74 class FGState {
75 public:
76   FGState(FGFDMExec*);
77   ~FGState(void);
78
79   bool Reset(string, string, string);
80   void Initialize(float, float, float, float, float, float, float, float, float);
81   void Initialize(FGInitialCondition *FGIC);
82   bool StoreData(string);
83
84   inline float Geta(void) { return a; }
85
86   inline float Getsim_time(void) { return sim_time; }
87   inline float Getdt(void) { return dt; }
88
89   inline void Suspend(void) {saved_dt = dt; dt = 0.0;}
90   inline void Resume(void)  {dt = saved_dt;}
91
92   float GetParameter(eParam val_idx);
93   float GetParameter(string val_string);
94   eParam GetParameterIndex(string val_string);
95
96
97   inline void Seta(float tt) { a = tt; }
98
99   inline float Setsim_time(float tt) {
100     sim_time = tt;
101     return sim_time;
102   }
103   inline void  Setdt(float tt) { dt = tt; }
104
105   void SetParameter(eParam, float);
106
107   inline float IncrTime(void) {
108     sim_time+=dt;
109     return sim_time;
110   }
111   void InitMatrices(float phi, float tht, float psi);
112   void CalcMatrices(void);
113   void IntegrateQuat(FGColumnVector vPQR, int rate);
114   FGColumnVector CalcEuler(void);
115   FGMatrix GetTs2b(float alpha, float beta);
116   FGMatrix GetTl2b(void) { return mTl2b; }
117   FGMatrix GetTb2l(void) { return mTb2l; }
118   typedef map<eParam, string> ParamMap;
119   ParamMap paramdef;
120
121 private:
122
123   float a;                          // speed of sound
124   float sim_time, dt;
125   float saved_dt;
126
127   FGFDMExec* FDMExec;
128   FGMatrix mTb2l;
129   FGMatrix mTl2b;
130   FGMatrix mTs2b;
131   FGColumnVector vQtrn;
132
133   typedef map<string, eParam> CoeffMap;
134   CoeffMap coeffdef;
135
136 protected:
137   enum {ePhi=1, eTht, ePsi};
138   enum {eP=1, eQ, eR};
139 };
140
141 /******************************************************************************/
142 #endif