]> git.mxchange.org Git - flightgear.git/blobdiff - src/Cockpit/steam.cxx
Tweaks for Mips Irix compilers.
[flightgear.git] / src / Cockpit / steam.cxx
index bd58a1bc54a7f7b117b55fae3ef864a528536fed..af1a588963e9c906d932b1dafd43b235ded34953 100644 (file)
@@ -118,21 +118,15 @@ void FGSteam::update ( int timesteps )
          fgTie("/steam/slip-skid", FGSteam::get_TC_rad);
          fgTie("/steam/vertical-speed", FGSteam::get_VSI_fps);
          fgTie("/steam/gyro-compass", FGSteam::get_DG_deg);
-         fgTie("/steam/vor1", FGSteam::get_HackVOR1_deg);
-         fgTie("/steam/vor2", FGSteam::get_HackVOR2_deg);
-         fgTie("/steam/glidescope1", FGSteam::get_HackGS_deg);
          fgTie("/steam/adf", FGSteam::get_HackADF_deg);
          fgTie("/steam/gyro-compass-error",
-               FGSteam::get_DG_err,
-               FGSteam::set_DG_err);
+               FGSteam::get_DG_err, FGSteam::set_DG_err,
+               false);  /* don't modify the value */
          fgTie("/steam/mag-compass", FGSteam::get_MH_deg);
        }
        _UpdatesPending += timesteps;
 }
 
-#undef DF1
-#undef DF2
-
 
 /* tc should be (elapsed_time_between_updates / desired_smoothing_time) */
 void FGSteam::set_lowpass ( double *outthe, double inthe, double tc )
@@ -169,11 +163,10 @@ void FGSteam::set_lowpass ( double *outthe, double inthe, double tc )
 double pressInHgToAltFt(double p_inhg)
 {
     // Ref. Aviation Formulary, Ed Williams, www.best.com/~williams/avform.htm
-    const double P_0 = 29.92126;  // Std. MSL pressure, inHg. (=10135.25 mb)
+    const double P_0 = 29.92126;  // Std. MSL pressure, inHg. (=1013.25 mb)
     const double p_Tr = 0.2233609 * P_0;  // Pressure at tropopause, same units.
     const double h_Tr = 36089.24;  // Alt of tropopause, ft. (=11.0 km)
 
-    // return (P_0 - p_inhg) * 1000.0;  // ### crude approx. for low alt's
     if (p_inhg > p_Tr)  // 0.0 to 11.0 km
        return (1.0 - pow((p_inhg / P_0), 1.0 / 5.2558797)) / 6.8755856e-6;
     return h_Tr + log10(p_inhg / p_Tr) / -4.806346e-5;  // 11.0 to 20.0 km
@@ -181,6 +174,21 @@ double pressInHgToAltFt(double p_inhg)
 }
 
 
+// Convert altitude to air pressure by ICAO Standard Atmosphere
+double altFtToPressInHg(double alt_ft)
+{
+    // Ref. Aviation Formulary, Ed Williams, www.best.com/~williams/avform.htm
+    const double P_0 = 29.92126;  // Std. MSL pressure, inHg. (=1013.25 mb)
+    const double p_Tr = 0.2233609 * P_0;  // Pressure at tropopause, same units.
+    const double h_Tr = 36089.24;  // Alt of tropopause, ft. (=11.0 km)
+
+    if (alt_ft < h_Tr)  // 0.0 to 11.0 km
+       return P_0 * pow(1.0 - 6.8755856e-6 * alt_ft, 5.2558797);
+    return p_Tr * exp(-4.806346e-5 * (alt_ft - h_Tr));  // 11.0 to 20.0 km
+    // We could put more code for higher altitudes here.
+}
+
+
 \f
 ////////////////////////////////////////////////////////////////////////
 // Here the fun really begins
@@ -322,13 +330,7 @@ void FGSteam::_CatchUp()
        We filter the actual value by one second to
        account for the line impedance of the plumbing.
        */
-       double static_inhg = 29.92; 
-       i = (int) FGBFI::getAltitude();
-       while ( i > 9000 )
-       {       static_inhg *= 0.707;
-               i -= 9000;
-       }
-       static_inhg *= ( 1.0 - 0.293 * i / 9000.0 );
+       double static_inhg = altFtToPressInHg(FGBFI::getAltitude());
        set_lowpass ( & the_STATIC_inhg, static_inhg, dt ); 
 
        /*
@@ -408,6 +410,8 @@ void FGSteam::_CatchUp()
 ////////////////////////////////////////////////////////////////////////
 
 
+#if 0
+
 double FGSteam::get_HackGS_deg () {
     if ( current_radiostack->get_nav1_inrange() && 
         current_radiostack->get_nav1_has_gs() )
@@ -427,17 +431,6 @@ double FGSteam::get_HackVOR1_deg () {
     double r;
 
     if ( current_radiostack->get_nav1_inrange() ) {
-#if 0
-       // depricated
-       if ( current_radiostack->get_nav1_loc() ) {
-           // localizer doesn't need magvar offset
-           r = current_radiostack->get_nav1_heading()
-               - current_radiostack->get_nav1_radial();
-       } else {
-           r = current_radiostack->get_nav1_heading() - FGBFI::getMagVar()
-               - current_radiostack->get_nav1_radial();
-       }
-#endif
         r = current_radiostack->get_nav1_heading()
            - current_radiostack->get_nav1_radial();
        // cout << "Radial = " << current_radiostack->get_nav1_radial() 
@@ -462,17 +455,6 @@ double FGSteam::get_HackVOR2_deg () {
     double r;
 
     if ( current_radiostack->get_nav2_inrange() ) {
-#if 0
-       // Depricated
-       if ( current_radiostack->get_nav2_loc() ) {
-           // localizer doesn't need magvar offset
-           r = current_radiostack->get_nav2_heading()
-               - current_radiostack->get_nav2_radial();
-       } else {
-           r = current_radiostack->get_nav2_heading() - FGBFI::getMagVar()
-               - current_radiostack->get_nav2_radial();
-       }
-#endif
         r = current_radiostack->get_nav2_heading()
            - current_radiostack->get_nav2_radial();
        // cout << "Radial = " << current_radiostack->get_nav1_radial() 
@@ -488,6 +470,7 @@ double FGSteam::get_HackVOR2_deg () {
 
     return r;
 }
+#endif
 
 
 double FGSteam::get_HackOBS1_deg () {