]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/FGState.h
0429 updates from Jon.
[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 #  include STL_STRING
50 #  ifdef FG_HAVE_STD_INCLUDES
51 #    include <fstream>
52 #  else
53 #    include <fstream.h>
54 #  endif
55    FG_USING_STD(string);
56 #else
57 #  include <string>
58 #  include <fstream>
59 #endif
60
61 #include <map>
62 #include "FGDefs.h"
63 #include "FGInitialCondition.h"
64 #include "FGMatrix.h"
65
66 /*******************************************************************************
67 DEFINES
68 *******************************************************************************/
69
70 using namespace std;
71
72 /*******************************************************************************
73 CLASS DECLARATION
74 *******************************************************************************/
75
76 class FGFDMExec;
77
78 class FGState
79 {
80 public:
81    FGState(FGFDMExec*);
82   ~FGState(void);
83
84   bool Reset(string, string, string);
85   void Initialize(float, float, float, float, float, float, float, float, float);
86   void Initialize(FGInitialCondition *FGIC);
87   bool StoreData(string);
88
89   inline float Getadot(void) {return adot;}
90   inline float Getbdot(void) {return bdot;}
91
92   inline float GetLocalAltitudeOverRunway(void) {return LocalAltitudeOverRunway;}
93   inline float Geta(void) {return a;}
94
95   inline float Getsim_time(void) {return sim_time;}
96   inline float Getdt(void) {return dt;}
97
98   float GetParameter(int val_idx);
99   float GetParameter(string val_string);
100   int GetParameterIndex(string val_string);
101
102   inline void Setadot(float tt) {adot = tt;}
103   inline void Setbdot(float tt) {bdot = tt;}
104
105   inline void SetLocalAltitudeOverRunway(float tt) {LocalAltitudeOverRunway = tt;}
106   inline void Seta(float tt) {a = tt;}
107
108   inline float Setsim_time(float tt) {sim_time = tt; return sim_time;}
109   inline void  Setdt(float tt) {dt = tt;}
110
111   void SetParameter(int, float);
112
113   inline float IncrTime(void) {sim_time+=dt;return sim_time;}
114   void InitMatrices(float phi, float tht, float psi);
115   void CalcMatrices(void);
116   void IntegrateQuat(FGColumnVector vPQR, int rate);
117   FGColumnVector CalcEuler(void);
118   FGMatrix GetTs2b(float alpha, float beta);
119   FGMatrix GetTl2b(void) {return mTl2b;}
120   FGMatrix GetTb2l(void) {return mTb2l;}
121
122 private:
123
124   float adot, bdot;                 // alpha dot and beta dot
125   float a;                          // speed of sound
126   float sim_time, dt;
127
128   FGFDMExec* FDMExec;
129   float LocalAltitudeOverRunway;
130   FGMatrix mTb2l;
131   FGMatrix mTl2b;
132   FGMatrix mTs2b;
133   FGColumnVector vQtrn;
134
135   typedef map<string, long> CoeffMap;
136   CoeffMap coeffdef;
137
138 protected:
139   enum {ePhi=1, eTht, ePsi};
140   enum {eP=1, eQ, eR};
141 };
142
143 /******************************************************************************/
144 #endif