]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/FGState.cpp
Updated to match changes in radiostack.[ch]xx
[flightgear.git] / src / FDM / JSBSim / FGState.cpp
1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2                                                                        
3  Module:       FGState.cpp
4  Author:       Jon Berndt
5  Date started: 11/17/98
6  Called by:    FGFDMExec and accessed by all models.
7  
8  ------------- Copyright (C) 1999  Jon S. Berndt (jsb@hal-pc.org) -------------
9  
10  This program is free software; you can redistribute it and/or modify it under
11  the terms of the GNU General Public License as published by the Free Software
12  Foundation; either version 2 of the License, or (at your option) any later
13  version.
14  
15  This program is distributed in the hope that it will be useful, but WITHOUT
16  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
18  details.
19  
20  You should have received a copy of the GNU General Public License along with
21  this program; if not, write to the Free Software Foundation, Inc., 59 Temple
22  Place - Suite 330, Boston, MA  02111-1307, USA.
23  
24  Further information about the GNU General Public License can also be found on
25  the world wide web at http://www.gnu.org.
26  
27 FUNCTIONAL DESCRIPTION
28 --------------------------------------------------------------------------------
29 See header file.
30  
31 HISTORY
32 --------------------------------------------------------------------------------
33 11/17/98   JSB   Created
34  
35 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
36 INCLUDES
37 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
38
39 #ifdef FGFS
40 #  include <simgear/compiler.h>
41 #  include <math.h>
42 #else
43 #  if defined(sgi) && !defined(__GNUC__)
44 #    include <math.h>
45 #  else
46 #    include <cmath>
47 #  endif
48 #endif
49
50 #ifdef _WIN32
51 #define snprintf _snprintf
52 #endif
53
54 #include "FGState.h"
55
56 static const char *IdSrc = "$Id$";
57 static const char *IdHdr = ID_STATE;
58
59 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
60 MACROS
61 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
62
63 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
64 CLASS IMPLEMENTATION
65 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
66
67 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
68 //
69 // For every term registered here there must be a corresponding handler in
70 // GetParameter() below that retrieves that parameter. Also, there must be an
71 // entry in the enum eParam definition in FGJSBBase.h. The ID is what must be used
72 // in any config file entry which references that item.
73
74 FGState::FGState(FGFDMExec* fdex)
75 {
76   FDMExec = fdex;
77
78   a = 1000.0;
79   sim_time = 0.0;
80   dt = 1.0/120.0;
81   ActiveEngine = -1;
82
83   Aircraft     = FDMExec->GetAircraft();
84   Translation  = FDMExec->GetTranslation();
85   Rotation     = FDMExec->GetRotation();
86   Position     = FDMExec->GetPosition();
87   FCS          = FDMExec->GetFCS();
88   Output       = FDMExec->GetOutput();
89   Atmosphere   = FDMExec->GetAtmosphere();
90   Aerodynamics = FDMExec->GetAerodynamics();
91   GroundReactions = FDMExec->GetGroundReactions();
92   Propulsion      = FDMExec->GetPropulsion();
93   PropertyManager = FDMExec->GetPropertyManager();
94
95   InitPropertyMaps();
96
97   bind();
98   
99   Debug(0);
100 }
101
102 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
103
104 FGState::~FGState()
105 {
106   unbind();
107   Debug(1);
108 }
109
110 //***************************************************************************
111 //
112 // Reset: Assume all angles READ FROM FILE IN DEGREES !!
113 //
114
115 bool FGState::Reset(string path, string acname, string fname)
116 {
117   string resetDef;
118   string token="";
119
120   double U, V, W;
121   double phi, tht, psi;
122   double latitude, longitude, h;
123   double wdir, wmag, wnorth, weast;
124
125 # ifndef macintosh
126   resetDef = path + "/" + acname + "/" + fname + ".xml";
127 # else
128   resetDef = path + ";" + acname + ";" + fname + ".xml";
129 # endif
130
131   FGConfigFile resetfile(resetDef);
132   if (!resetfile.IsOpen()) return false;
133
134   resetfile.GetNextConfigLine();
135   token = resetfile.GetValue();
136   if (token != string("initialize")) {
137     cerr << "The reset file " << resetDef
138          << " does not appear to be a reset file" << endl;
139     return false;
140   } else {
141     resetfile.GetNextConfigLine();
142     resetfile >> token;
143     cout << "Resetting using: " << token << endl << endl;
144   }
145   
146   while (token != string("/initialize") && token != string("EOF")) {
147     if (token == "UBODY") resetfile >> U;
148     if (token == "VBODY") resetfile >> V;
149     if (token == "WBODY") resetfile >> W;
150     if (token == "LATITUDE") resetfile >> latitude;
151     if (token == "LONGITUDE") resetfile >> longitude;
152     if (token == "PHI") resetfile >> phi;
153     if (token == "THETA") resetfile >> tht;
154     if (token == "PSI") resetfile >> psi;
155     if (token == "ALTITUDE") resetfile >> h;
156     if (token == "WINDDIR") resetfile >> wdir;
157     if (token == "VWIND") resetfile >> wmag;
158
159     resetfile >> token;
160   }
161   
162   
163   Position->SetLatitude(latitude*degtorad);
164   Position->SetLongitude(longitude*degtorad);
165   Position->Seth(h);
166
167   wnorth = wmag*ktstofps*cos(wdir*degtorad);
168   weast = wmag*ktstofps*sin(wdir*degtorad);
169   
170   Initialize(U, V, W, phi*degtorad, tht*degtorad, psi*degtorad,
171                latitude*degtorad, longitude*degtorad, h, wnorth, weast, 0.0);
172
173   return true;
174 }
175
176 //***************************************************************************
177 //
178 // Initialize: Assume all angles GIVEN IN RADIANS !!
179 //
180
181 void FGState::Initialize(double U, double V, double W,
182                          double phi, double tht, double psi,
183                          double Latitude, double Longitude, double H,
184                          double wnorth, double weast, double wdown)
185 {
186   double alpha, beta;
187   double qbar, Vt;
188   FGColumnVector3 vAeroUVW;
189
190   Position->SetLatitude(Latitude);
191   Position->SetLongitude(Longitude);
192   Position->Seth(H);
193
194   Atmosphere->Run();
195   
196   vLocalEuler << phi << tht << psi;
197   Rotation->SetEuler(vLocalEuler);
198
199   InitMatrices(phi, tht, psi);
200   
201   vUVW << U << V << W;
202   Translation->SetUVW(vUVW);
203   
204   Atmosphere->SetWindNED(wnorth, weast, wdown);
205   
206   vAeroUVW = vUVW + mTl2b*Atmosphere->GetWindNED();
207   
208   if (vAeroUVW(eW) != 0.0)
209     alpha = vAeroUVW(eU)*vAeroUVW(eU) > 0.0 ? atan2(vAeroUVW(eW), vAeroUVW(eU)) : 0.0;
210   else
211     alpha = 0.0;
212   if (vAeroUVW(eV) != 0.0)
213     beta = vAeroUVW(eU)*vAeroUVW(eU)+vAeroUVW(eW)*vAeroUVW(eW) > 0.0 ? atan2(vAeroUVW(eV), (fabs(vAeroUVW(eU))/vAeroUVW(eU))*sqrt(vAeroUVW(eU)*vAeroUVW(eU) + vAeroUVW(eW)*vAeroUVW(eW))) : 0.0;
214   else
215     beta = 0.0;
216
217   Translation->SetAB(alpha, beta);
218
219   Vt = sqrt(U*U + V*V + W*W);
220   Translation->SetVt(Vt);
221
222   Translation->SetMach(Vt/Atmosphere->GetSoundSpeed());
223
224   qbar = 0.5*(U*U + V*V + W*W)*Atmosphere->GetDensity();
225   Translation->Setqbar(qbar);
226
227   vLocalVelNED = mTb2l*vUVW;
228   Position->SetvVel(vLocalVelNED);
229 }
230
231 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
232
233 void FGState::Initialize(FGInitialCondition *FGIC)
234 {
235   double tht,psi,phi;
236   double U, V, W, h;
237   double latitude, longitude;
238   double wnorth,weast, wdown;
239   
240   latitude = FGIC->GetLatitudeRadIC();
241   longitude = FGIC->GetLongitudeRadIC();
242   h = FGIC->GetAltitudeFtIC();
243   U = FGIC->GetUBodyFpsIC();
244   V = FGIC->GetVBodyFpsIC();
245   W = FGIC->GetWBodyFpsIC();
246   tht = FGIC->GetThetaRadIC();
247   phi = FGIC->GetPhiRadIC();
248   psi = FGIC->GetPsiRadIC();
249   wnorth = FGIC->GetWindNFpsIC();
250   weast = FGIC->GetWindEFpsIC();
251   wdown = FGIC->GetWindDFpsIC();
252   
253   Position->SetSeaLevelRadius( FGIC->GetSeaLevelRadiusFtIC() );
254   Position->SetRunwayRadius( FGIC->GetSeaLevelRadiusFtIC() + 
255                                              FGIC->GetTerrainAltitudeFtIC() );
256
257   // need to fix the wind speed args, here.  
258   Initialize(U, V, W, phi, tht, psi, latitude, longitude, h, wnorth, weast, wdown);
259 }
260
261 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
262
263 void FGState::InitMatrices(double phi, double tht, double psi)
264 {
265   double thtd2, psid2, phid2;
266   double Sthtd2, Spsid2, Sphid2;
267   double Cthtd2, Cpsid2, Cphid2;
268   double Cphid2Cthtd2;
269   double Cphid2Sthtd2;
270   double Sphid2Sthtd2;
271   double Sphid2Cthtd2;
272
273   thtd2 = tht/2.0;
274   psid2 = psi/2.0;
275   phid2 = phi/2.0;
276
277   Sthtd2 = sin(thtd2);
278   Spsid2 = sin(psid2);
279   Sphid2 = sin(phid2);
280
281   Cthtd2 = cos(thtd2);
282   Cpsid2 = cos(psid2);
283   Cphid2 = cos(phid2);
284
285   Cphid2Cthtd2 = Cphid2*Cthtd2;
286   Cphid2Sthtd2 = Cphid2*Sthtd2;
287   Sphid2Sthtd2 = Sphid2*Sthtd2;
288   Sphid2Cthtd2 = Sphid2*Cthtd2;
289
290   vQtrn(1) = Cphid2Cthtd2*Cpsid2 + Sphid2Sthtd2*Spsid2;
291   vQtrn(2) = Sphid2Cthtd2*Cpsid2 - Cphid2Sthtd2*Spsid2;
292   vQtrn(3) = Cphid2Sthtd2*Cpsid2 + Sphid2Cthtd2*Spsid2;
293   vQtrn(4) = Cphid2Cthtd2*Spsid2 - Sphid2Sthtd2*Cpsid2;
294
295   CalcMatrices();
296 }
297
298 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
299
300 void FGState::CalcMatrices(void)
301 {
302   double Q0Q0, Q1Q1, Q2Q2, Q3Q3;
303   double Q0Q1, Q0Q2, Q0Q3, Q1Q2;
304   double Q1Q3, Q2Q3;
305
306   Q0Q0 = vQtrn(1)*vQtrn(1);
307   Q1Q1 = vQtrn(2)*vQtrn(2);
308   Q2Q2 = vQtrn(3)*vQtrn(3);
309   Q3Q3 = vQtrn(4)*vQtrn(4);
310   Q0Q1 = vQtrn(1)*vQtrn(2);
311   Q0Q2 = vQtrn(1)*vQtrn(3);
312   Q0Q3 = vQtrn(1)*vQtrn(4);
313   Q1Q2 = vQtrn(2)*vQtrn(3);
314   Q1Q3 = vQtrn(2)*vQtrn(4);
315   Q2Q3 = vQtrn(3)*vQtrn(4);
316
317   mTl2b(1,1) = Q0Q0 + Q1Q1 - Q2Q2 - Q3Q3;
318   mTl2b(1,2) = 2*(Q1Q2 + Q0Q3);
319   mTl2b(1,3) = 2*(Q1Q3 - Q0Q2);
320   mTl2b(2,1) = 2*(Q1Q2 - Q0Q3);
321   mTl2b(2,2) = Q0Q0 - Q1Q1 + Q2Q2 - Q3Q3;
322   mTl2b(2,3) = 2*(Q2Q3 + Q0Q1);
323   mTl2b(3,1) = 2*(Q1Q3 + Q0Q2);
324   mTl2b(3,2) = 2*(Q2Q3 - Q0Q1);
325   mTl2b(3,3) = Q0Q0 - Q1Q1 - Q2Q2 + Q3Q3;
326
327   mTb2l = mTl2b;
328   mTb2l.T();
329 }
330
331 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
332
333 void FGState::IntegrateQuat(FGColumnVector3 vPQR, int rate)
334 {
335   vQdot(1) = -0.5*(vQtrn(2)*vPQR(eP) + vQtrn(3)*vPQR(eQ) + vQtrn(4)*vPQR(eR));
336   vQdot(2) =  0.5*(vQtrn(1)*vPQR(eP) + vQtrn(3)*vPQR(eR) - vQtrn(4)*vPQR(eQ));
337   vQdot(3) =  0.5*(vQtrn(1)*vPQR(eQ) + vQtrn(4)*vPQR(eP) - vQtrn(2)*vPQR(eR));
338   vQdot(4) =  0.5*(vQtrn(1)*vPQR(eR) + vQtrn(2)*vPQR(eQ) - vQtrn(3)*vPQR(eP));
339   vQtrn += 0.5*dt*rate*(vlastQdot + vQdot);
340
341   vQtrn.Normalize();
342
343   vlastQdot = vQdot;
344 }
345
346 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
347
348 FGColumnVector3& FGState::CalcEuler(void)
349 {
350   if (mTl2b(3,3) == 0.0) mTl2b(3,3) = 0.0000001;
351   if (mTl2b(1,1) == 0.0) mTl2b(1,1) = 0.0000001;
352
353   vEuler(ePhi) = atan2(mTl2b(2,3), mTl2b(3,3));
354   vEuler(eTht) = asin(-mTl2b(1,3));
355   vEuler(ePsi) = atan2(mTl2b(1,2), mTl2b(1,1));
356
357   if (vEuler(ePsi) < 0.0) vEuler(ePsi) += 2*M_PI;
358
359   return vEuler;
360 }
361
362 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
363
364 FGMatrix33& FGState::GetTs2b(void)
365 {
366   double ca, cb, sa, sb;
367
368   double alpha = Translation->Getalpha();
369   double beta  = Translation->Getbeta();
370
371   ca = cos(alpha);
372   sa = sin(alpha);
373   cb = cos(beta);
374   sb = sin(beta);
375
376   mTs2b(1,1) = ca*cb;
377   mTs2b(1,2) = -ca*sb;
378   mTs2b(1,3) = -sa;
379   mTs2b(2,1) = sb;
380   mTs2b(2,2) = cb;
381   mTs2b(2,3) = 0.0;
382   mTs2b(3,1) = sa*cb;
383   mTs2b(3,2) = -sa*sb;
384   mTs2b(3,3) = ca;
385
386   return mTs2b;
387 }
388
389 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
390
391 FGMatrix33& FGState::GetTb2s(void)
392 {
393   float alpha,beta;
394   float ca, cb, sa, sb;
395   
396   alpha = Translation->Getalpha();
397   beta  = Translation->Getbeta();
398   
399   ca = cos(alpha);
400   sa = sin(alpha);
401   cb = cos(beta);
402   sb = sin(beta);
403
404   mTb2s(1,1) = ca*cb;
405   mTb2s(1,2) = sb;
406   mTb2s(1,3) = sa*cb;
407   mTb2s(2,1) = -ca*sb;
408   mTb2s(2,2) = cb;
409   mTb2s(2,3) = -sa*sb;
410   mTb2s(3,1) = -sa;
411   mTb2s(3,2) = 0.0;
412   mTb2s(3,3) = ca;
413
414   return mTb2s;
415 }
416
417 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
418
419 void FGState::ReportState(void)
420 {
421 #if !defined(__BORLANDCPP__)
422   char out[80], flap[10], gear[12];
423   
424   cout << endl << "  JSBSim State" << endl;
425   snprintf(out,80,"    Weight: %7.0f lbs.  CG: %5.1f, %5.1f, %5.1f inches\n",
426                    FDMExec->GetMassBalance()->GetWeight(),
427                    FDMExec->GetMassBalance()->GetXYZcg(1),
428                    FDMExec->GetMassBalance()->GetXYZcg(2),
429                    FDMExec->GetMassBalance()->GetXYZcg(3));
430   cout << out;             
431   if ( FCS->GetDfPos() <= 0.01)
432     snprintf(flap,10,"Up");
433   else
434     snprintf(flap,10,"%2.0f",FCS->GetDfPos());
435
436   if (FCS->GetGearPos() < 0.01)
437     snprintf(gear,12,"Up");
438   else if (FCS->GetGearPos() > 0.99)
439     snprintf(gear,12,"Down");
440   else
441     snprintf(gear,12,"In Transit");
442
443   snprintf(out,80, "    Flaps: %3s  Gear: %12s\n",flap,gear);
444   cout << out;
445   snprintf(out,80, "    Speed: %4.0f KCAS  Mach: %5.2f\n",
446                     FDMExec->GetAuxiliary()->GetVcalibratedKTS(),
447                     Translation->GetMach() );
448   cout << out;
449   snprintf(out,80, "    Altitude: %7.0f ft.  AGL Altitude: %7.0f ft.\n",
450                     Position->Geth(),
451                     Position->GetDistanceAGL() );
452   cout << out;
453   snprintf(out,80, "    Angle of Attack: %6.2f deg  Pitch Angle: %6.2f deg\n",
454                     Translation->Getalpha()*radtodeg,
455                     Rotation->Gettht()*radtodeg );
456   cout << out;
457   snprintf(out,80, "    Flight Path Angle: %6.2f deg  Climb Rate: %5.0f ft/min\n",
458                     Position->GetGamma()*radtodeg,
459                     Position->Gethdot()*60 );
460   cout << out;                  
461   snprintf(out,80, "    Normal Load Factor: %4.2f g's  Pitch Rate: %5.2f deg/s\n",
462                     Aircraft->GetNlf(),
463                     Rotation->GetPQR(2)*radtodeg );
464   cout << out;
465   snprintf(out,80, "    Heading: %3.0f deg true  Sideslip: %5.2f deg  Yaw Rate: %5.2f deg/s\n",
466                     Rotation->Getpsi()*radtodeg,
467                     Translation->Getbeta()*radtodeg,
468                     Rotation->GetPQR(3)*radtodeg  );                  
469   cout << out;
470   snprintf(out,80, "    Bank Angle: %5.2f deg  Roll Rate: %5.2f deg/s\n",
471                     Rotation->Getphi()*radtodeg, 
472                     Rotation->GetPQR(1)*radtodeg );
473   cout << out;
474   snprintf(out,80, "    Elevator: %5.2f deg  Left Aileron: %5.2f deg  Rudder: %5.2f deg\n",
475                     FCS->GetDePos(ofRad)*radtodeg,
476                     FCS->GetDaLPos(ofRad)*radtodeg,
477                     FCS->GetDrPos(ofRad)*radtodeg );
478   cout << out;                  
479   snprintf(out,80, "    Throttle: %5.2f%c\n",
480                     FCS->GetThrottlePos(0)*100,'%' );
481   cout << out;
482   
483   snprintf(out,80, "    Wind Components: %5.2f kts head wind, %5.2f kts cross wind\n",
484                     FDMExec->GetAuxiliary()->GetHeadWind()*fpstokts,
485                     FDMExec->GetAuxiliary()->GetCrossWind()*fpstokts );
486   cout << out; 
487   
488   snprintf(out,80, "    Ground Speed: %4.0f knots , Ground Track: %3.0f deg true\n",
489                     Position->GetVground()*fpstokts,
490                     Position->GetGroundTrack()*radtodeg );
491   cout << out;                                   
492 #endif
493
494
495 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
496
497 void FGState::InitPropertyMaps(void)
498 {
499   ParamNameToProp[  "FG_TIME" ]="sim-time-sec";
500   ParamNameToProp[  "FG_QBAR" ]="aero/qbar-psf";
501   ParamNameToProp[  "FG_QBARUW" ]="aero/qbarUW-psf";
502   ParamNameToProp[  "FG_QBARUV" ]="aero/qbarUV-psf";
503   ParamNameToProp[  "FG_WINGAREA" ]="metrics/Sw-sqft";
504   ParamNameToProp[  "FG_WINGSPAN" ]="metrics/bw-ft";
505   ParamNameToProp[  "FG_CBAR" ]="metrics/cbarw-ft";
506   ParamNameToProp[  "FG_ALPHA" ]="aero/alpha-rad";
507   ParamNameToProp[  "FG_ALPHADOT" ]="aero/alphadot-rad_sec";
508   ParamNameToProp[  "FG_BETA" ]="aero/beta-rad";
509   ParamNameToProp[  "FG_ABETA" ]="aero/mag-beta-rad";
510   ParamNameToProp[  "FG_BETADOT" ]="aero/betadot-rad_sec";
511   ParamNameToProp[  "FG_PHI" ]="attitude/phi-rad";
512   ParamNameToProp[  "FG_THT" ]="attitude/theta-rad";
513   ParamNameToProp[  "FG_PSI" ]="attitude/psi-true-rad";
514   ParamNameToProp[  "FG_PITCHRATE" ]="velocities/q-rad_sec";
515   ParamNameToProp[  "FG_ROLLRATE" ]="velocities/p-rad_sec";
516   ParamNameToProp[  "FG_YAWRATE" ]="velocities/r-rad_sec";
517   ParamNameToProp[  "FG_AEROP" ]="velocities/p-aero-rad_sec";
518   ParamNameToProp[  "FG_AEROQ" ]="velocities/q-aero-rad_sec";
519   ParamNameToProp[  "FG_AEROR" ]="velocities/r-aero-rad_sec";
520   ParamNameToProp[  "FG_CL_SQRD" ]="aero/cl-squared-norm";
521   ParamNameToProp[  "FG_MACH" ]="velocities/mach-norm";
522   ParamNameToProp[  "FG_ALTITUDE" ]="position/h-sl-ft";
523   ParamNameToProp[  "FG_BI2VEL" ]="aero/bi2vel";
524   ParamNameToProp[  "FG_CI2VEL" ]="aero/ci2vel";
525   ParamNameToProp[  "FG_ELEVATOR_POS" ]="fcs/elevator-pos-rad";
526   ParamNameToProp[  "FG_AELEVATOR_POS" ]="fcs/mag-elevator-pos-rad";
527   ParamNameToProp[  "FG_NELEVATOR_POS" ]="fcs/elevator-pos-norm";
528   ParamNameToProp[  "FG_AILERON_POS" ]="fcs/left-aileron-pos-rad";
529   ParamNameToProp[  "FG_AAILERON_POS" ]="fcs/mag-aileron-pos-rad";
530   ParamNameToProp[  "FG_NAILERON_POS" ]="fcs/left-aileron-pos-norm";
531   ParamNameToProp[  "FG_LEFT_AILERON_POS" ]="fcs/left-aileron-pos-rad";
532   ParamNameToProp[  "FG_ALEFT_AILERON_POS" ]="fcs/mag-left-aileron-pos-rad";
533   ParamNameToProp[  "FG_NLEFT_AILERON_POS" ]="fcs/left-aileron-pos-norm";
534   ParamNameToProp[  "FG_RIGHT_AILERON_POS" ]="fcs/right-aileron-pos-rad";
535   ParamNameToProp[  "FG_ARIGHT_AILERON_POS" ]="fcs/mag-aileron-pos-rad";
536   ParamNameToProp[  "FG_NRIGHT_AILERON_POS" ]="fcs/right-aileron-pos-norm";
537   ParamNameToProp[  "FG_RUDDER_POS" ]="fcs/rudder-pos-rad";
538   ParamNameToProp[  "FG_ARUDDER_POS" ]="fcs/mag-rudder-pos-rad";
539   ParamNameToProp[  "FG_NRUDDER_POS" ]="fcs/rudder-pos-norm";
540   ParamNameToProp[  "FG_SPDBRAKE_POS" ]="fcs/speedbrake-pos-rad";
541   ParamNameToProp[  "FG_NSPDBRAKE_POS" ]="fcs/speedbrake-pos-norm";
542   ParamNameToProp[  "FG_SPOILERS_POS" ]="fcs/spoiler-pos-rad";
543   ParamNameToProp[  "FG_NSPOILERS_POS" ]="fcs/spoiler-pos-norm";
544   ParamNameToProp[  "FG_FLAPS_POS" ]="fcs/flap-pos-deg";
545   ParamNameToProp[  "FG_NFLAPS_POS" ]="fcs/flap-pos-norm";
546   ParamNameToProp[  "FG_ELEVATOR_CMD" ]="fcs/elevator-cmd-norm";
547   ParamNameToProp[  "FG_AILERON_CMD" ]="fcs/aileron-cmd-norm";
548   ParamNameToProp[  "FG_RUDDER_CMD" ]="fcs/rudder-cmd-norm";
549   ParamNameToProp[  "FG_SPDBRAKE_CMD" ]="fcs/speedbrake-cmd-norm";
550   ParamNameToProp[  "FG_SPOILERS_CMD" ]="fcs/spoiler-cmd-norm";
551   ParamNameToProp[  "FG_FLAPS_CMD" ]="fcs/flap-cmd-norm";
552   ParamNameToProp[  "FG_THROTTLE_CMD" ]="fcs/throttle-cmd-norm";
553   ParamNameToProp[  "FG_THROTTLE_POS" ]="fcs/throttle-pos-norm";
554   ParamNameToProp[  "FG_MIXTURE_CMD" ]="fcs/mixture-cmd-norm";
555   ParamNameToProp[  "FG_MIXTURE_POS" ]="fcs/mixture-pos-norm";
556   ParamNameToProp[  "FG_MAGNETO_CMD" ]="zero";
557   ParamNameToProp[  "FG_STARTER_CMD" ]="zero";
558   ParamNameToProp[  "FG_ACTIVE_ENGINE" ]="zero";
559   ParamNameToProp[  "FG_HOVERB" ]="aero/h_b-mac-ft";
560   ParamNameToProp[  "FG_PITCH_TRIM_CMD" ]="fcs/pitch-trim-cmd-norm";
561   ParamNameToProp[  "FG_YAW_TRIM_CMD" ]="fcs/yaw-trim-cmd-norm";
562   ParamNameToProp[  "FG_ROLL_TRIM_CMD" ]="fcs/roll-trim-cmd-norm";
563   ParamNameToProp[  "FG_LEFT_BRAKE_CMD" ]="zero";
564   ParamNameToProp[  "FG_CENTER_BRAKE_CMD" ]="zero";
565   ParamNameToProp[  "FG_RIGHT_BRAKE_CMD" ]="zero";
566   ParamNameToProp[  "FG_SET_LOGGING" ]="zero";
567   ParamNameToProp[  "FG_ALPHAH" ]="aero/alpha-rad";
568   ParamNameToProp[  "FG_ALPHAW" ]="aero/alpha-wing-rad";
569   ParamNameToProp[  "FG_LBARH" ]="metrics/lh-norm";     
570   ParamNameToProp[  "FG_LBARV" ]="metrics/lv-norm";     
571   ParamNameToProp[  "FG_HTAILAREA" ]="metrics/Sh-sqft";
572   ParamNameToProp[  "FG_VTAILAREA" ]="metrics/Sv-sqft";
573   ParamNameToProp[  "FG_VBARH" ]="metrics/vbarh-norm";    
574   ParamNameToProp[  "FG_VBARV" ]="metrics/vbarv-norm";     
575   ParamNameToProp[  "FG_GEAR_CMD" ]="gear/gear-cmd-norm";
576   ParamNameToProp[  "FG_GEAR_POS" ]="gear/gear-pos-norm";
577   ParamNameToProp[  "FG_HYSTPARM" ]="aero/stall-hyst-norm";
578 }
579
580 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
581
582 void FGState::bind(void)
583 {
584   PropertyManager->Tie("sim-time-sec",this,
585                         &FGState::Getsim_time);
586 }
587
588 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
589                         
590 void FGState::unbind(void)
591 {
592   PropertyManager->Untie("sim-time-sec");
593 }
594
595 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
596 //    The bitmasked value choices are as follows:
597 //    unset: In this case (the default) JSBSim would only print
598 //       out the normally expected messages, essentially echoing
599 //       the config files as they are read. If the environment
600 //       variable is not set, debug_lvl is set to 1 internally
601 //    0: This requests JSBSim not to output any messages
602 //       whatsoever.
603 //    1: This value explicity requests the normal JSBSim
604 //       startup messages
605 //    2: This value asks for a message to be printed out when
606 //       a class is instantiated
607 //    4: When this value is set, a message is displayed when a
608 //       FGModel object executes its Run() method
609 //    8: When this value is set, various runtime state variables
610 //       are printed out periodically
611 //    16: When set various parameters are sanity checked and
612 //       a message is printed out when they go out of bounds
613
614 void FGState::Debug(int from)
615 {
616   if (debug_lvl <= 0) return;
617
618   if (debug_lvl & 1) { // Standard console startup message output
619     if (from == 0) { // Constructor
620
621     }
622   }
623   if (debug_lvl & 2 ) { // Instantiation/Destruction notification
624     if (from == 0) cout << "Instantiated: FGState" << endl;
625     if (from == 1) cout << "Destroyed:    FGState" << endl;
626   }
627   if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
628   }
629   if (debug_lvl & 8 ) { // Runtime state variables
630   }
631   if (debug_lvl & 16) { // Sanity checking
632   }
633   if (debug_lvl & 64) {
634     if (from == 0) { // Constructor
635       cout << IdSrc << endl;
636       cout << IdHdr << endl;
637     }
638   }
639 }
640