X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=src%2FCockpit%2Fsteam.cxx;h=cd78bf303259ab843f2575299c14f3eb0854a6c0;hb=d13b46b8f1efc36057c98fd396c306cbfd7a3612;hp=5716b16d9d66dd9d79ab106a7a70ec23ad2cb3ac;hpb=5ea9c04c644a7e115f651132a6179d4e9d1ef8ce;p=flightgear.git diff --git a/src/Cockpit/steam.cxx b/src/Cockpit/steam.cxx index 5716b16d9..cd78bf303 100644 --- a/src/Cockpit/steam.cxx +++ b/src/Cockpit/steam.cxx @@ -23,18 +23,14 @@ # include #endif -#if defined( SG_HAVE_NATIVE_SGI_COMPILERS ) -# include -#else -# include -#endif +#include + +#include STL_IOSTREAM #include #include #include #include -#include
-#include SG_USING_NAMESPACE(std); @@ -49,9 +45,6 @@ static bool isTied = false; // Declare the functions that read the variables //////////////////////////////////////////////////////////////////////// -// Anything that reads the BFI directly is not implemented at all! - - double FGSteam::the_STATIC_inhg = 29.92; double FGSteam::the_ALT_ft = 0.0; // Indicated altitude double FGSteam::get_ALT_ft() { _CatchUp(); return the_ALT_ft; } @@ -63,7 +56,7 @@ void FGSteam::set_ALT_datum_mb ( double datum_mb ) { the_ALT_datum_mb = datum_mb; } -double FGSteam::get_ASI_kias() { return FGBFI::getAirspeed(); } +double FGSteam::get_ASI_kias() { return fgGetDouble("/velocities/airspeed-kt"); } double FGSteam::the_VSI_case = 29.92; double FGSteam::the_VSI_fps = 0.0; @@ -107,24 +100,34 @@ int FGSteam::_UpdatesPending = 1000000; /* Forces filter to reset */ void FGSteam::update ( int timesteps ) { - if (!isTied) { - isTied = true; - fgTie("/steam/airspeed", FGSteam::get_ASI_kias); - fgTie("/steam/altitude", FGSteam::get_ALT_ft); - fgTie("/steam/altimeter-datum-mb", - FGSteam::get_ALT_datum_mb, FGSteam::set_ALT_datum_mb, - false); /* don't modify the value */ - fgTie("/steam/turn-rate", FGSteam::get_TC_std); - 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/adf", FGSteam::get_HackADF_deg); - fgTie("/steam/gyro-compass-error", - FGSteam::get_DG_err, FGSteam::set_DG_err, - false); /* don't modify the value */ - fgTie("/steam/mag-compass", FGSteam::get_MH_deg); - } - _UpdatesPending += timesteps; + if (!isTied) { + isTied = true; + fgTie("/steam/airspeed-kt", FGSteam::get_ASI_kias); + fgSetArchivable("/steam/airspeed-kt"); + fgTie("/steam/altitude-ft", FGSteam::get_ALT_ft); + fgSetArchivable("/steam/altitude-ft"); + fgTie("/steam/altimeter-datum-mb", + FGSteam::get_ALT_datum_mb, FGSteam::set_ALT_datum_mb, + false); /* don't modify the value */ + fgSetArchivable("/steam/altimeter-datum-mb"); + fgTie("/steam/turn-rate", FGSteam::get_TC_std); + fgSetArchivable("/steam/turn-rate"); + fgTie("/steam/slip-skid", FGSteam::get_TC_rad); + fgSetArchivable("/steam/slip-skid"); + fgTie("/steam/vertical-speed-fpm", FGSteam::get_VSI_fps); + fgSetArchivable("/steam/vertical-speed-fpm"); + fgTie("/steam/gyro-compass-deg", FGSteam::get_DG_deg); + fgSetArchivable("/steam/gyro-compass-deg"); + fgTie("/steam/adf-deg", FGSteam::get_HackADF_deg); + fgSetArchivable("/steam/adf-deg"); + fgTie("/steam/gyro-compass-error-deg", + FGSteam::get_DG_err, FGSteam::set_DG_err, + false); /* don't modify the value */ + fgSetArchivable("/steam/gyro-compass-error-deg"); + fgTie("/steam/mag-compass-deg", FGSteam::get_MH_deg); + fgSetArchivable("/steam/mag-compass-deg"); + } + _UpdatesPending += timesteps; } @@ -245,7 +248,6 @@ void FGSteam::_CatchUp() More subtle flaw is having it not move or a travel limit occasionally due to some dirt in the tube or on the ball. */ - // the_TC_rad = - ( FGBFI::getSideSlip () ); /* incorrect */ d = - current_aircraft.fdm_state->get_A_Z_pilot(); if ( d < 1 ) d = 1; set_lowpass ( & the_TC_rad, @@ -273,18 +275,20 @@ void FGSteam::_CatchUp() AccE = current_aircraft.fdm_state->get_V_dot_east(); AccU = current_aircraft.fdm_state->get_V_dot_down() - 9.81 / 0.3; - if ( fabs(the_TC_rad) > 0.2 ) + if ( fabs(the_TC_rad) > 0.2 /* 2.0 */ ) { /* Massive sideslip jams it; it stops turning */ the_MH_degps = 0.0; - the_MH_err = FGBFI::getHeading () - the_MH_deg; + the_MH_err = fgGetDouble("/orientation/heading-deg") - the_MH_deg; } else { double MagDip, MagVar, CosDip; double FrcN, FrcE, FrcU, AccTot; double EdgN, EdgE, EdgU; double TrqN, TrqE, TrqU, Torque; /* Find a force vector towards exact magnetic north */ - MagVar = FGBFI::getMagVar() / SGD_RADIANS_TO_DEGREES; - MagDip = FGBFI::getMagDip() / SGD_RADIANS_TO_DEGREES; + MagVar = fgGetDouble("/environment/magnetic-variation-deg") + / SGD_RADIANS_TO_DEGREES; + MagDip = fgGetDouble("/environment/magnetic-dip-deg") + / SGD_RADIANS_TO_DEGREES; CosDip = cos ( MagDip ); FrcN = CosDip * cos ( MagVar ); FrcE = CosDip * sin ( MagVar ); @@ -314,7 +318,7 @@ void FGSteam::_CatchUp() } if ( the_MH_err > 180.0 ) the_MH_err -= 360.0; else if ( the_MH_err < -180.0 ) the_MH_err += 360.0; - the_MH_deg = FGBFI::getHeading () - the_MH_err; + the_MH_deg = fgGetDouble("/orientation/heading-deg") - the_MH_err; } /************************** @@ -322,7 +326,7 @@ void FGSteam::_CatchUp() scaling capability for the vacuum pump later on. When we have a real engine model, we can ask it. */ - the_ENGINE_rpm = controls.get_throttle(0) * 26.0; + the_ENGINE_rpm = globals->get_controls()->get_throttle(0) * 26.0; /************************** First, we need to know what the static line is reporting, @@ -330,7 +334,8 @@ void FGSteam::_CatchUp() We filter the actual value by one second to account for the line impedance of the plumbing. */ - double static_inhg = altFtToPressInHg(FGBFI::getAltitude()); + double static_inhg + = altFtToPressInHg(fgGetDouble("/position/altitude-ft")); set_lowpass ( & the_STATIC_inhg, static_inhg, dt ); /* @@ -390,10 +395,10 @@ void FGSteam::_CatchUp() > put in those insidious turning errors ... for now anyway. */ if ( _UpdatesPending > 999999 ) - the_DG_err = FGBFI::getMagVar(); + the_DG_err = fgGetDouble("/environment/magnetic-variation-deg"); the_DG_degps = 0.01; /* HACK! */ if (dt<1.0) the_DG_err += dt * the_DG_degps; - the_DG_deg = FGBFI::getHeading () - the_DG_err; + the_DG_deg = fgGetDouble("/orientation/heading-deg") - the_DG_err; /************************** Finished updates, now clear the timer @@ -417,7 +422,8 @@ double FGSteam::get_HackGS_deg () { current_radiostack->get_nav1_has_gs() ) { double x = current_radiostack->get_nav1_gs_dist(); - double y = (FGBFI::getAltitude() - current_radiostack->get_nav1_elev()) + double y = (fgGetDouble("/position/altitude-ft") + - current_radiostack->get_nav1_elev()) * SG_FEET_TO_METER; double angle = atan2( y, x ) * SGD_RADIANS_TO_DEGREES; return (current_radiostack->get_nav1_target_gs() - angle) * 5.0; @@ -485,10 +491,10 @@ double FGSteam::get_HackOBS2_deg () { double FGSteam::get_HackADF_deg () { static double last_r = 0; - double r; if ( current_radiostack->get_adf_inrange() ) { - double r = current_radiostack->get_adf_heading() - FGBFI::getHeading(); + double r = current_radiostack->get_adf_heading() + - fgGetDouble("/orientation/heading-deg"); last_r = r; // cout << "Radial = " << current_radiostack->get_adf_heading() // << " Heading = " << FGBFI::getHeading() << endl;