X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FCockpit%2Fsteam.cxx;h=af1a588963e9c906d932b1dafd43b235ded34953;hb=29275ce1ecf9c4ea302aacca8c5ae5d4d3319a17;hp=3c4f93b62e38cbdafa6a86f6531d2147199dd421;hpb=cbaf01548180f2dcaafd04676c4832b7297abc27;p=flightgear.git diff --git a/src/Cockpit/steam.cxx b/src/Cockpit/steam.cxx index 3c4f93b62..af1a58896 100644 --- a/src/Cockpit/steam.cxx +++ b/src/Cockpit/steam.cxx @@ -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. +} + + //////////////////////////////////////////////////////////////////////// // 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() ) @@ -429,9 +433,9 @@ double FGSteam::get_HackVOR1_deg () { if ( current_radiostack->get_nav1_inrange() ) { r = current_radiostack->get_nav1_heading() - current_radiostack->get_nav1_radial(); - cout << "Radial = " << current_radiostack->get_nav1_radial() - << " Bearing = " << current_radiostack->get_nav1_heading() - << endl; + // cout << "Radial = " << current_radiostack->get_nav1_radial() + // << " Bearing = " << current_radiostack->get_nav1_heading() + // << endl; if (r> 180.0) r-=360.0; else if (r<-180.0) r+=360.0; @@ -466,6 +470,7 @@ double FGSteam::get_HackVOR2_deg () { return r; } +#endif double FGSteam::get_HackOBS1_deg () {