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 )
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
}
+// 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
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 );
/*
////////////////////////////////////////////////////////////////////////
+#if 0
+
double FGSteam::get_HackGS_deg () {
if ( current_radiostack->get_nav1_inrange() &&
current_radiostack->get_nav1_has_gs() )
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()
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()
return r;
}
+#endif
double FGSteam::get_HackOBS1_deg () {