1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6 Called by: FGFDMExec and accessed by all models.
8 ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
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
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
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.
24 Further information about the GNU General Public License can also be found on
25 the world wide web at http://www.gnu.org.
27 FUNCTIONAL DESCRIPTION
28 --------------------------------------------------------------------------------
32 --------------------------------------------------------------------------------
35 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
37 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
40 # include <simgear/compiler.h>
43 # if defined(sgi) && !defined(__GNUC__)
51 #define snprintf _snprintf
56 static const char *IdSrc = "$Id$";
57 static const char *IdHdr = ID_STATE;
59 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
61 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
63 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
65 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
67 FGState::FGState(FGFDMExec* fdex)
75 Aircraft = FDMExec->GetAircraft();
76 Translation = FDMExec->GetTranslation();
77 Rotation = FDMExec->GetRotation();
78 Position = FDMExec->GetPosition();
79 FCS = FDMExec->GetFCS();
80 Output = FDMExec->GetOutput();
81 Atmosphere = FDMExec->GetAtmosphere();
82 Aerodynamics = FDMExec->GetAerodynamics();
83 GroundReactions = FDMExec->GetGroundReactions();
84 Propulsion = FDMExec->GetPropulsion();
85 PropertyManager = FDMExec->GetPropertyManager();
87 for(int i=0;i<3;i++) vQdot_prev[i].InitMatrix();
96 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
104 //***************************************************************************
106 // Reset: Assume all angles READ FROM FILE IN DEGREES !!
109 bool FGState::Reset(string path, string acname, string fname)
115 double phi, tht, psi;
116 double latitude, longitude, h;
117 double wdir, wmag, wnorth, weast;
120 resetDef = path + "/" + acname + "/" + fname + ".xml";
122 resetDef = path + ";" + acname + ";" + fname + ".xml";
125 FGConfigFile resetfile(resetDef);
126 if (!resetfile.IsOpen()) return false;
128 resetfile.GetNextConfigLine();
129 token = resetfile.GetValue();
130 if (token != string("initialize")) {
131 cerr << "The reset file " << resetDef
132 << " does not appear to be a reset file" << endl;
135 resetfile.GetNextConfigLine();
137 cout << "Resetting using: " << token << endl << endl;
140 while (token != string("/initialize") && token != string("EOF")) {
141 if (token == "UBODY") resetfile >> U;
142 if (token == "VBODY") resetfile >> V;
143 if (token == "WBODY") resetfile >> W;
144 if (token == "LATITUDE") resetfile >> latitude;
145 if (token == "LONGITUDE") resetfile >> longitude;
146 if (token == "PHI") resetfile >> phi;
147 if (token == "THETA") resetfile >> tht;
148 if (token == "PSI") resetfile >> psi;
149 if (token == "ALTITUDE") resetfile >> h;
150 if (token == "WINDDIR") resetfile >> wdir;
151 if (token == "VWIND") resetfile >> wmag;
156 Position->SetLatitude(latitude*degtorad);
157 Position->SetLongitude(longitude*degtorad);
160 wnorth = wmag*ktstofps*cos(wdir*degtorad);
161 weast = wmag*ktstofps*sin(wdir*degtorad);
163 Initialize(U, V, W, phi*degtorad, tht*degtorad, psi*degtorad,
164 latitude*degtorad, longitude*degtorad, h, wnorth, weast, 0.0);
169 //***************************************************************************
171 // Initialize: Assume all angles GIVEN IN RADIANS !!
174 void FGState::Initialize(double U, double V, double W,
175 double phi, double tht, double psi,
176 double Latitude, double Longitude, double H,
177 double wnorth, double weast, double wdown)
181 FGColumnVector3 vAeroUVW;
183 Position->SetLatitude(Latitude);
184 Position->SetLongitude(Longitude);
189 vLocalEuler << phi << tht << psi;
190 Rotation->SetEuler(vLocalEuler);
192 InitMatrices(phi, tht, psi);
195 Translation->SetUVW(vUVW);
197 Atmosphere->SetWindNED(wnorth, weast, wdown);
199 vAeroUVW = vUVW + mTl2b*Atmosphere->GetWindNED();
201 if (vAeroUVW(eW) != 0.0)
202 alpha = vAeroUVW(eU)*vAeroUVW(eU) > 0.0 ? atan2(vAeroUVW(eW), vAeroUVW(eU)) : 0.0;
205 if (vAeroUVW(eV) != 0.0)
206 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;
210 Translation->SetAB(alpha, beta);
212 Vt = sqrt(U*U + V*V + W*W);
213 Translation->SetVt(Vt);
215 Translation->SetMach(Vt/Atmosphere->GetSoundSpeed());
217 qbar = 0.5*(U*U + V*V + W*W)*Atmosphere->GetDensity();
218 Translation->Setqbar(qbar);
220 vLocalVelNED = mTb2l*vUVW;
221 Position->SetvVel(vLocalVelNED);
224 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
226 void FGState::Initialize(FGInitialCondition *FGIC)
230 double latitude, longitude;
231 double wnorth,weast, wdown;
233 latitude = FGIC->GetLatitudeRadIC();
234 longitude = FGIC->GetLongitudeRadIC();
235 h = FGIC->GetAltitudeFtIC();
236 U = FGIC->GetUBodyFpsIC();
237 V = FGIC->GetVBodyFpsIC();
238 W = FGIC->GetWBodyFpsIC();
239 tht = FGIC->GetThetaRadIC();
240 phi = FGIC->GetPhiRadIC();
241 psi = FGIC->GetPsiRadIC();
242 wnorth = FGIC->GetWindNFpsIC();
243 weast = FGIC->GetWindEFpsIC();
244 wdown = FGIC->GetWindDFpsIC();
246 Position->SetSeaLevelRadius( FGIC->GetSeaLevelRadiusFtIC() );
247 Position->SetRunwayRadius( FGIC->GetSeaLevelRadiusFtIC() +
248 FGIC->GetTerrainAltitudeFtIC() );
250 // need to fix the wind speed args, here.
251 Initialize(U, V, W, phi, tht, psi, latitude, longitude, h, wnorth, weast, wdown);
254 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
256 void FGState::InitMatrices(double phi, double tht, double psi)
258 double thtd2, psid2, phid2;
259 double Sthtd2, Spsid2, Sphid2;
260 double Cthtd2, Cpsid2, Cphid2;
278 Cphid2Cthtd2 = Cphid2*Cthtd2;
279 Cphid2Sthtd2 = Cphid2*Sthtd2;
280 Sphid2Sthtd2 = Sphid2*Sthtd2;
281 Sphid2Cthtd2 = Sphid2*Cthtd2;
283 vQtrn(1) = Cphid2Cthtd2*Cpsid2 + Sphid2Sthtd2*Spsid2;
284 vQtrn(2) = Sphid2Cthtd2*Cpsid2 - Cphid2Sthtd2*Spsid2;
285 vQtrn(3) = Cphid2Sthtd2*Cpsid2 + Sphid2Cthtd2*Spsid2;
286 vQtrn(4) = Cphid2Cthtd2*Spsid2 - Sphid2Sthtd2*Cpsid2;
291 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
293 void FGState::CalcMatrices(void)
295 double Q0Q0, Q1Q1, Q2Q2, Q3Q3;
296 double Q0Q1, Q0Q2, Q0Q3, Q1Q2;
299 Q0Q0 = vQtrn(1)*vQtrn(1);
300 Q1Q1 = vQtrn(2)*vQtrn(2);
301 Q2Q2 = vQtrn(3)*vQtrn(3);
302 Q3Q3 = vQtrn(4)*vQtrn(4);
303 Q0Q1 = vQtrn(1)*vQtrn(2);
304 Q0Q2 = vQtrn(1)*vQtrn(3);
305 Q0Q3 = vQtrn(1)*vQtrn(4);
306 Q1Q2 = vQtrn(2)*vQtrn(3);
307 Q1Q3 = vQtrn(2)*vQtrn(4);
308 Q2Q3 = vQtrn(3)*vQtrn(4);
310 mTl2b(1,1) = Q0Q0 + Q1Q1 - Q2Q2 - Q3Q3;
311 mTl2b(1,2) = 2*(Q1Q2 + Q0Q3);
312 mTl2b(1,3) = 2*(Q1Q3 - Q0Q2);
313 mTl2b(2,1) = 2*(Q1Q2 - Q0Q3);
314 mTl2b(2,2) = Q0Q0 - Q1Q1 + Q2Q2 - Q3Q3;
315 mTl2b(2,3) = 2*(Q2Q3 + Q0Q1);
316 mTl2b(3,1) = 2*(Q1Q3 + Q0Q2);
317 mTl2b(3,2) = 2*(Q2Q3 - Q0Q1);
318 mTl2b(3,3) = Q0Q0 - Q1Q1 - Q2Q2 + Q3Q3;
324 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
326 void FGState::IntegrateQuat(FGColumnVector3 vPQR, int rate)
328 vQdot(1) = -0.5*(vQtrn(2)*vPQR(eP) + vQtrn(3)*vPQR(eQ) + vQtrn(4)*vPQR(eR));
329 vQdot(2) = 0.5*(vQtrn(1)*vPQR(eP) + vQtrn(3)*vPQR(eR) - vQtrn(4)*vPQR(eQ));
330 vQdot(3) = 0.5*(vQtrn(1)*vPQR(eQ) + vQtrn(4)*vPQR(eP) - vQtrn(2)*vPQR(eR));
331 vQdot(4) = 0.5*(vQtrn(1)*vPQR(eR) + vQtrn(2)*vPQR(eQ) - vQtrn(3)*vPQR(eP));
333 vQtrn += Integrate(TRAPZ, dt*rate, vQdot, vQdot_prev);
338 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
340 FGColumnVector3& FGState::CalcEuler(void)
342 if (mTl2b(3,3) == 0.0) mTl2b(3,3) = 0.0000001;
343 if (mTl2b(1,1) == 0.0) mTl2b(1,1) = 0.0000001;
345 vEuler(ePhi) = atan2(mTl2b(2,3), mTl2b(3,3));
346 vEuler(eTht) = asin(-mTl2b(1,3));
347 vEuler(ePsi) = atan2(mTl2b(1,2), mTl2b(1,1));
349 if (vEuler(ePsi) < 0.0) vEuler(ePsi) += 2*M_PI;
354 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
356 FGMatrix33& FGState::GetTs2b(void)
358 double ca, cb, sa, sb;
360 double alpha = Translation->Getalpha();
361 double beta = Translation->Getbeta();
381 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
383 FGMatrix33& FGState::GetTb2s(void)
386 float ca, cb, sa, sb;
388 alpha = Translation->Getalpha();
389 beta = Translation->Getbeta();
409 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
411 void FGState::ReportState(void)
413 #if !defined(__BORLANDCPP__)
414 char out[80], flap[10], gear[12];
416 cout << endl << " JSBSim State" << endl;
417 snprintf(out,80," Weight: %7.0f lbs. CG: %5.1f, %5.1f, %5.1f inches\n",
418 FDMExec->GetMassBalance()->GetWeight(),
419 FDMExec->GetMassBalance()->GetXYZcg(1),
420 FDMExec->GetMassBalance()->GetXYZcg(2),
421 FDMExec->GetMassBalance()->GetXYZcg(3));
423 if ( FCS->GetDfPos() <= 0.01)
424 snprintf(flap,10,"Up");
426 snprintf(flap,10,"%2.0f",FCS->GetDfPos());
428 if (FCS->GetGearPos() < 0.01)
429 snprintf(gear,12,"Up");
430 else if (FCS->GetGearPos() > 0.99)
431 snprintf(gear,12,"Down");
433 snprintf(gear,12,"In Transit");
435 snprintf(out,80, " Flaps: %3s Gear: %12s\n",flap,gear);
437 snprintf(out,80, " Speed: %4.0f KCAS Mach: %5.2f\n",
438 FDMExec->GetAuxiliary()->GetVcalibratedKTS(),
439 Translation->GetMach() );
441 snprintf(out,80, " Altitude: %7.0f ft. AGL Altitude: %7.0f ft.\n",
443 Position->GetDistanceAGL() );
445 snprintf(out,80, " Angle of Attack: %6.2f deg Pitch Angle: %6.2f deg\n",
446 Translation->Getalpha()*radtodeg,
447 Rotation->Gettht()*radtodeg );
449 snprintf(out,80, " Flight Path Angle: %6.2f deg Climb Rate: %5.0f ft/min\n",
450 Position->GetGamma()*radtodeg,
451 Position->Gethdot()*60 );
453 snprintf(out,80, " Normal Load Factor: %4.2f g's Pitch Rate: %5.2f deg/s\n",
455 Rotation->GetPQR(2)*radtodeg );
457 snprintf(out,80, " Heading: %3.0f deg true Sideslip: %5.2f deg Yaw Rate: %5.2f deg/s\n",
458 Rotation->Getpsi()*radtodeg,
459 Translation->Getbeta()*radtodeg,
460 Rotation->GetPQR(3)*radtodeg );
462 snprintf(out,80, " Bank Angle: %5.2f deg Roll Rate: %5.2f deg/s\n",
463 Rotation->Getphi()*radtodeg,
464 Rotation->GetPQR(1)*radtodeg );
466 snprintf(out,80, " Elevator: %5.2f deg Left Aileron: %5.2f deg Rudder: %5.2f deg\n",
467 FCS->GetDePos(ofRad)*radtodeg,
468 FCS->GetDaLPos(ofRad)*radtodeg,
469 FCS->GetDrPos(ofRad)*radtodeg );
471 snprintf(out,80, " Throttle: %5.2f%c\n",
472 FCS->GetThrottlePos(0)*100,'%' );
475 snprintf(out,80, " Wind Components: %5.2f kts head wind, %5.2f kts cross wind\n",
476 FDMExec->GetAuxiliary()->GetHeadWind()*fpstokts,
477 FDMExec->GetAuxiliary()->GetCrossWind()*fpstokts );
480 snprintf(out,80, " Ground Speed: %4.0f knots , Ground Track: %3.0f deg true\n",
481 Position->GetVground()*fpstokts,
482 Position->GetGroundTrack()*radtodeg );
487 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
489 void FGState::InitPropertyMaps(void)
491 ParamNameToProp[ "FG_TIME" ]="sim-time-sec";
492 ParamNameToProp[ "FG_QBAR" ]="aero/qbar-psf";
493 ParamNameToProp[ "FG_QBARUW" ]="aero/qbarUW-psf";
494 ParamNameToProp[ "FG_QBARUV" ]="aero/qbarUV-psf";
495 ParamNameToProp[ "FG_WINGAREA" ]="metrics/Sw-sqft";
496 ParamNameToProp[ "FG_WINGSPAN" ]="metrics/bw-ft";
497 ParamNameToProp[ "FG_CBAR" ]="metrics/cbarw-ft";
498 ParamNameToProp[ "FG_ALPHA" ]="aero/alpha-rad";
499 ParamNameToProp[ "FG_ALPHADOT" ]="aero/alphadot-rad_sec";
500 ParamNameToProp[ "FG_BETA" ]="aero/beta-rad";
501 ParamNameToProp[ "FG_ABETA" ]="aero/mag-beta-rad";
502 ParamNameToProp[ "FG_BETADOT" ]="aero/betadot-rad_sec";
503 ParamNameToProp[ "FG_PHI" ]="attitude/phi-rad";
504 ParamNameToProp[ "FG_THT" ]="attitude/theta-rad";
505 ParamNameToProp[ "FG_PSI" ]="attitude/psi-true-rad";
506 ParamNameToProp[ "FG_PITCHRATE" ]="velocities/q-rad_sec";
507 ParamNameToProp[ "FG_ROLLRATE" ]="velocities/p-rad_sec";
508 ParamNameToProp[ "FG_YAWRATE" ]="velocities/r-rad_sec";
509 ParamNameToProp[ "FG_AEROP" ]="velocities/p-aero-rad_sec";
510 ParamNameToProp[ "FG_AEROQ" ]="velocities/q-aero-rad_sec";
511 ParamNameToProp[ "FG_AEROR" ]="velocities/r-aero-rad_sec";
512 ParamNameToProp[ "FG_CL_SQRD" ]="aero/cl-squared-norm";
513 ParamNameToProp[ "FG_MACH" ]="velocities/mach-norm";
514 ParamNameToProp[ "FG_ALTITUDE" ]="position/h-sl-ft";
515 ParamNameToProp[ "FG_BI2VEL" ]="aero/bi2vel";
516 ParamNameToProp[ "FG_CI2VEL" ]="aero/ci2vel";
517 ParamNameToProp[ "FG_ELEVATOR_POS" ]="fcs/elevator-pos-rad";
518 ParamNameToProp[ "FG_AELEVATOR_POS" ]="fcs/mag-elevator-pos-rad";
519 ParamNameToProp[ "FG_NELEVATOR_POS" ]="fcs/elevator-pos-norm";
520 ParamNameToProp[ "FG_AILERON_POS" ]="fcs/left-aileron-pos-rad";
521 ParamNameToProp[ "FG_AAILERON_POS" ]="fcs/mag-aileron-pos-rad";
522 ParamNameToProp[ "FG_NAILERON_POS" ]="fcs/left-aileron-pos-norm";
523 ParamNameToProp[ "FG_LEFT_AILERON_POS" ]="fcs/left-aileron-pos-rad";
524 ParamNameToProp[ "FG_ALEFT_AILERON_POS" ]="fcs/mag-left-aileron-pos-rad";
525 ParamNameToProp[ "FG_NLEFT_AILERON_POS" ]="fcs/left-aileron-pos-norm";
526 ParamNameToProp[ "FG_RIGHT_AILERON_POS" ]="fcs/right-aileron-pos-rad";
527 ParamNameToProp[ "FG_ARIGHT_AILERON_POS" ]="fcs/mag-aileron-pos-rad";
528 ParamNameToProp[ "FG_NRIGHT_AILERON_POS" ]="fcs/right-aileron-pos-norm";
529 ParamNameToProp[ "FG_RUDDER_POS" ]="fcs/rudder-pos-rad";
530 ParamNameToProp[ "FG_ARUDDER_POS" ]="fcs/mag-rudder-pos-rad";
531 ParamNameToProp[ "FG_NRUDDER_POS" ]="fcs/rudder-pos-norm";
532 ParamNameToProp[ "FG_SPDBRAKE_POS" ]="fcs/speedbrake-pos-rad";
533 ParamNameToProp[ "FG_NSPDBRAKE_POS" ]="fcs/speedbrake-pos-norm";
534 ParamNameToProp[ "FG_SPOILERS_POS" ]="fcs/spoiler-pos-rad";
535 ParamNameToProp[ "FG_NSPOILERS_POS" ]="fcs/spoiler-pos-norm";
536 ParamNameToProp[ "FG_FLAPS_POS" ]="fcs/flap-pos-deg";
537 ParamNameToProp[ "FG_NFLAPS_POS" ]="fcs/flap-pos-norm";
538 ParamNameToProp[ "FG_ELEVATOR_CMD" ]="fcs/elevator-cmd-norm";
539 ParamNameToProp[ "FG_AILERON_CMD" ]="fcs/aileron-cmd-norm";
540 ParamNameToProp[ "FG_RUDDER_CMD" ]="fcs/rudder-cmd-norm";
541 ParamNameToProp[ "FG_SPDBRAKE_CMD" ]="fcs/speedbrake-cmd-norm";
542 ParamNameToProp[ "FG_SPOILERS_CMD" ]="fcs/spoiler-cmd-norm";
543 ParamNameToProp[ "FG_FLAPS_CMD" ]="fcs/flap-cmd-norm";
544 ParamNameToProp[ "FG_THROTTLE_CMD" ]="fcs/throttle-cmd-norm";
545 ParamNameToProp[ "FG_THROTTLE_POS" ]="fcs/throttle-pos-norm";
546 ParamNameToProp[ "FG_MIXTURE_CMD" ]="fcs/mixture-cmd-norm";
547 ParamNameToProp[ "FG_MIXTURE_POS" ]="fcs/mixture-pos-norm";
548 ParamNameToProp[ "FG_MAGNETO_CMD" ]="propulsion/magneto_cmd";
549 ParamNameToProp[ "FG_STARTER_CMD" ]="propulsion/starter_cmd";
550 ParamNameToProp[ "FG_ACTIVE_ENGINE" ]="propulsion/active_engine";
551 ParamNameToProp[ "FG_HOVERB" ]="aero/h_b-mac-ft";
552 ParamNameToProp[ "FG_PITCH_TRIM_CMD" ]="fcs/pitch-trim-cmd-norm";
553 ParamNameToProp[ "FG_YAW_TRIM_CMD" ]="fcs/yaw-trim-cmd-norm";
554 ParamNameToProp[ "FG_ROLL_TRIM_CMD" ]="fcs/roll-trim-cmd-norm";
555 ParamNameToProp[ "FG_LEFT_BRAKE_CMD" ]="fcs/left_brake";
556 ParamNameToProp[ "FG_CENTER_BRAKE_CMD" ]="fcs/center_brake";
557 ParamNameToProp[ "FG_RIGHT_BRAKE_CMD" ]="fcs/right_brake";
558 ParamNameToProp[ "FG_SET_LOGGING" ]="sim/set_logging";
559 ParamNameToProp[ "FG_ALPHAH" ]="aero/alpha-rad";
560 ParamNameToProp[ "FG_ALPHAW" ]="aero/alpha-wing-rad";
561 ParamNameToProp[ "FG_LBARH" ]="metrics/lh-norm";
562 ParamNameToProp[ "FG_LBARV" ]="metrics/lv-norm";
563 ParamNameToProp[ "FG_HTAILAREA" ]="metrics/Sh-sqft";
564 ParamNameToProp[ "FG_VTAILAREA" ]="metrics/Sv-sqft";
565 ParamNameToProp[ "FG_VBARH" ]="metrics/vbarh-norm";
566 ParamNameToProp[ "FG_VBARV" ]="metrics/vbarv-norm";
567 ParamNameToProp[ "FG_GEAR_CMD" ]="gear/gear-cmd-norm";
568 ParamNameToProp[ "FG_GEAR_POS" ]="gear/gear-pos-norm";
569 ParamNameToProp[ "FG_HYSTPARM" ]="aero/stall-hyst-norm";
570 ParamNameToProp[ "AP_ELEVATOR_CMD" ]="jsbsim/ap/elevator_cmd";
571 ParamNameToProp[ "AP_AILERON_CMD" ]="jsbsim/ap/aileron_cmd";
572 ParamNameToProp[ "AP_RUDDER_CMD" ]="jsbsim/ap/rudder_cmd";
573 ParamNameToProp[ "AP_THROTTLE_CMD" ]="jsbsim/ap/throttle_cmd";
574 ParamNameToProp[ "AP_SET_ATTITUDE" ]="jsbsim/ap/set_attitude";
575 ParamNameToProp[ "AP_SET_ALTITUDE" ]="jsbsim/ap/set_altitude";
576 ParamNameToProp[ "AP_SET_HEADING" ]="jsbsim/ap/set_heading";
577 ParamNameToProp[ "AP_SET_AIRSPEED" ]="jsbsim/ap/set_airspeed";
578 ParamNameToProp[ "AP_ACQUIRE_ATTITUDE" ]="jsbsim/ap/acquire_attitude";
579 ParamNameToProp[ "AP_ACQUIRE_ALTITUDE" ]="jsbsim/ap/acquire_altitude";
580 ParamNameToProp[ "AP_ACQUIRE_HEADING" ]="jsbsim/ap/acquire_heading";
581 ParamNameToProp[ "AP_ACQUIRE_AIRSPEED" ]="jsbsim/ap/acquire_aispeed";
582 ParamNameToProp[ "AP_ATTITUDE_HOLD_ON" ]="jsbsim/ap/attitude_hold_on";
583 ParamNameToProp[ "AP_ALTITUDE,_HOLD_ON" ]="jsbsim/ap/altitude_hold_on";
584 ParamNameToProp[ "AP_HEADING_HOLD_ON" ]="jsbsim/ap/heading_hold_on";
585 ParamNameToProp[ "AP_AIRSPEED_HOLD_ON" ]="jsbsim/ap/airspeed_hold_on";
586 ParamNameToProp[ "AP_WINGSLEVEL_HOLD_ON" ]="jsbsim/ap/wingslevel_hold_on";
589 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
591 void FGState::bind(void)
593 PropertyManager->Tie("sim-time-sec",this,
594 &FGState::Getsim_time);
597 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
599 void FGState::unbind(void)
601 PropertyManager->Untie("sim-time-sec");
604 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
605 // The bitmasked value choices are as follows:
606 // unset: In this case (the default) JSBSim would only print
607 // out the normally expected messages, essentially echoing
608 // the config files as they are read. If the environment
609 // variable is not set, debug_lvl is set to 1 internally
610 // 0: This requests JSBSim not to output any messages
612 // 1: This value explicity requests the normal JSBSim
614 // 2: This value asks for a message to be printed out when
615 // a class is instantiated
616 // 4: When this value is set, a message is displayed when a
617 // FGModel object executes its Run() method
618 // 8: When this value is set, various runtime state variables
619 // are printed out periodically
620 // 16: When set various parameters are sanity checked and
621 // a message is printed out when they go out of bounds
623 void FGState::Debug(int from)
625 if (debug_lvl <= 0) return;
627 if (debug_lvl & 1) { // Standard console startup message output
628 if (from == 0) { // Constructor
632 if (debug_lvl & 2 ) { // Instantiation/Destruction notification
633 if (from == 0) cout << "Instantiated: FGState" << endl;
634 if (from == 1) cout << "Destroyed: FGState" << endl;
636 if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
638 if (debug_lvl & 8 ) { // Runtime state variables
640 if (debug_lvl & 16) { // Sanity checking
642 if (debug_lvl & 64) {
643 if (from == 0) { // Constructor
644 cout << IdSrc << endl;
645 cout << IdHdr << endl;