X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FMain%2Fbfi.cxx;h=1137c0359c2bfe4d174d4ebf0b846ae89d4f9785;hb=a6e0a696376ba2d426eb534bb83ec42038a501e7;hp=8b749b2bdee84887e6d8021057b00c9a946b2ca7;hpb=f780c27787836a552f5dd13a980228e3ae6e711e;p=flightgear.git diff --git a/src/Main/bfi.cxx b/src/Main/bfi.cxx index 8b749b2bd..1137c0359 100644 --- a/src/Main/bfi.cxx +++ b/src/Main/bfi.cxx @@ -52,7 +52,7 @@ #include "fg_init.hxx" #include "fg_props.hxx" -FG_USING_NAMESPACE(std); +SG_USING_NAMESPACE(std); #include "bfi.hxx" @@ -83,11 +83,10 @@ reinit () // that's going to get clobbered // when we reinit the subsystems. - FG_LOG(FG_GENERAL, FG_INFO, "Starting BFI reinit"); + SG_LOG(SG_GENERAL, SG_INFO, "Starting BFI reinit"); // TODO: add more AP stuff bool apHeadingLock = FGBFI::getAPHeadingLock(); - double apHeadingMag = FGBFI::getAPHeadingMag(); bool apAltitudeLock = FGBFI::getAPAltitudeLock(); double apAltitude = FGBFI::getAPAltitude(); bool gpsLock = FGBFI::getGPSLock(); @@ -104,19 +103,20 @@ reinit () fgUpdateMoonPos(); cur_light_params.Update(); fgUpdateLocalTime(); +#ifndef FG_OLD_WEATHER fgUpdateWeatherDatabase(); +#endif current_radiostack->search(); // Restore all of the old states. FGBFI::setAPHeadingLock(apHeadingLock); - FGBFI::setAPHeadingMag(apHeadingMag); FGBFI::setAPAltitudeLock(apAltitudeLock); FGBFI::setAPAltitude(apAltitude); FGBFI::setGPSLock(gpsLock); _needReinit = false; - FG_LOG(FG_GENERAL, FG_INFO, "Ending BFI reinit"); + SG_LOG(SG_GENERAL, SG_INFO, "Ending BFI reinit"); } // BEGIN: kludge @@ -155,8 +155,8 @@ _set_view_from_axes () viewDir = 270; } - globals->get_current_view()->set_goal_view_offset(viewDir*DEG_TO_RAD); -// globals->get_current_view()->set_view_offset(viewDir*DEG_TO_RAD); + globals->get_current_view()->set_goal_view_offset(viewDir*SGD_DEGREES_TO_RADIANS); +// globals->get_current_view()->set_view_offset(viewDir*SGD_DEGREES_TO_RADIANS); } // END: kludge @@ -167,6 +167,7 @@ _set_view_from_axes () // Local functions //////////////////////////////////////////////////////////////////////// + /** * Initialize the BFI by binding its functions to properties. * @@ -176,10 +177,12 @@ _set_view_from_axes () void FGBFI::init () { - FG_LOG(FG_GENERAL, FG_INFO, "Starting BFI init"); + SG_LOG(SG_GENERAL, SG_INFO, "Starting BFI init"); // Simulation fgTie("/sim/aircraft-dir", getAircraftDir, setAircraftDir); + fgTie("/sim/view/offset", getViewOffset, setViewOffset); + fgTie("/sim/view/goal-offset", getGoalViewOffset, setGoalViewOffset); fgTie("/sim/time/gmt", getDateString, setDateString); fgTie("/sim/time/gmt-string", getGMTString); @@ -191,16 +194,30 @@ FGBFI::init () fgTie("/engines/engine0/egt", getEGT); fgTie("/engines/engine0/cht", getCHT); fgTie("/engines/engine0/mp", getMP); + fgTie("/engines/engine0/fuel-flow", getFuelFlow); + + //consumables + fgTie("/consumables/fuel/tank1/level", getTank1Fuel, setTank1Fuel, false); + fgTie("/consumables/fuel/tank2/level", getTank2Fuel, setTank2Fuel, false); // Autopilot fgTie("/autopilot/locks/altitude", getAPAltitudeLock, setAPAltitudeLock); fgTie("/autopilot/settings/altitude", getAPAltitude, setAPAltitude); + fgTie("/autopilot/locks/glide-slope", getAPGSLock, setAPGSLock); + fgTie("/autopilot/settings/climb-rate", getAPClimb, setAPClimb, false); fgTie("/autopilot/locks/heading", getAPHeadingLock, setAPHeadingLock); - fgTie("/autopilot/settings/heading", getAPHeading, setAPHeading); - fgTie("/autopilot/settings/heading-dg", getAPHeadingDG, setAPHeadingDG); - fgTie("/autopilot/settings/heading-magnetic", - getAPHeadingMag, setAPHeadingMag); + fgTie("/autopilot/settings/heading-bug", getAPHeadingBug, setAPHeadingBug, + false); + fgTie("/autopilot/locks/wing-leveler", getAPWingLeveler, setAPWingLeveler); fgTie("/autopilot/locks/nav1", getAPNAV1Lock, setAPNAV1Lock); + fgTie("/autopilot/locks/auto-throttle", + getAPAutoThrottleLock, setAPAutoThrottleLock); + fgTie("/autopilot/control-overrides/rudder", + getAPRudderControl, setAPRudderControl); + fgTie("/autopilot/control-overrides/elevator", + getAPElevatorControl, setAPElevatorControl); + fgTie("/autopilot/control-overrides/throttle", + getAPThrottleControl, setAPThrottleControl); // Weather fgTie("/environment/visibility", getVisibility, setVisibility); @@ -209,12 +226,13 @@ FGBFI::init () fgTie("/environment/wind-down", getWindDown, setWindDown); // View + fgTie("/sim/field-of-view", getFOV, setFOV); fgTie("/sim/view/axes/long", (double(*)())0, setViewAxisLong); fgTie("/sim/view/axes/lat", (double(*)())0, setViewAxisLat); _needReinit = false; - FG_LOG(FG_GENERAL, FG_INFO, "Ending BFI init"); + SG_LOG(SG_GENERAL, SG_INFO, "Ending BFI init"); } @@ -265,6 +283,39 @@ FGBFI::setAircraftDir (string dir) } +/** + * Get the current view offset in degrees. + */ +double +FGBFI::getViewOffset () +{ + return (globals->get_current_view() + ->get_view_offset() * SGD_RADIANS_TO_DEGREES); +} + +void +FGBFI::setViewOffset (double offset) +{ + globals->get_current_view()->set_view_offset(offset * SGD_DEGREES_TO_RADIANS); +} + +double +FGBFI::getGoalViewOffset () +{ + return (globals->get_current_view() + ->get_goal_view_offset() * SGD_RADIANS_TO_DEGREES); +} + +void +FGBFI::setGoalViewOffset (double offset) +{ + globals->get_current_view() + ->set_goal_view_offset(offset * SGD_DEGREES_TO_RADIANS); +} + + + + /** * Return the current Zulu time. */ @@ -305,7 +356,7 @@ FGBFI::setDateString (string date_string) // if the save file has been edited // by hand. if (ret != 6) { - FG_LOG(FG_INPUT, FG_ALERT, "Date/time string " << date_string + SG_LOG(SG_INPUT, SG_ALERT, "Date/time string " << date_string << " not in YYYY-MM-DDTHH:MM:SS format; skipped"); return; } @@ -322,7 +373,7 @@ FGBFI::setDateString (string date_string) mktime(&new_time) - mktime(current_time) + globals->get_warp(); double lon = current_aircraft.fdm_state->get_Longitude(); double lat = current_aircraft.fdm_state->get_Latitude(); - double alt = current_aircraft.fdm_state->get_Altitude() * FEET_TO_METER; + // double alt = current_aircraft.fdm_state->get_Altitude() * SG_FEET_TO_METER; globals->set_warp(warp); st->update(lon, lat, warp); fgUpdateSkyAndLightingParams(); @@ -357,7 +408,7 @@ FGBFI::getGMTString () double FGBFI::getLatitude () { - return current_aircraft.fdm_state->get_Latitude() * RAD_TO_DEG; + return current_aircraft.fdm_state->get_Latitude() * SGD_RADIANS_TO_DEGREES; } @@ -367,7 +418,7 @@ FGBFI::getLatitude () void FGBFI::setLatitude (double latitude) { - current_aircraft.fdm_state->set_Latitude(latitude * DEG_TO_RAD); + current_aircraft.fdm_state->set_Latitude(latitude * SGD_DEGREES_TO_RADIANS); } @@ -377,7 +428,7 @@ FGBFI::setLatitude (double latitude) double FGBFI::getLongitude () { - return current_aircraft.fdm_state->get_Longitude() * RAD_TO_DEG; + return current_aircraft.fdm_state->get_Longitude() * SGD_RADIANS_TO_DEGREES; } @@ -387,7 +438,7 @@ FGBFI::getLongitude () void FGBFI::setLongitude (double longitude) { - current_aircraft.fdm_state->set_Longitude(longitude * DEG_TO_RAD); + current_aircraft.fdm_state->set_Longitude(longitude * SGD_DEGREES_TO_RADIANS); } @@ -409,7 +460,7 @@ double FGBFI::getAGL () { return current_aircraft.fdm_state->get_Altitude() - - (scenery.cur_elev * METER_TO_FEET); + - (scenery.cur_elev * SG_METER_TO_FEET); } @@ -435,7 +486,7 @@ FGBFI::setAltitude (double altitude) double FGBFI::getHeading () { - return current_aircraft.fdm_state->get_Psi() * RAD_TO_DEG; + return current_aircraft.fdm_state->get_Psi() * SGD_RADIANS_TO_DEGREES; } @@ -445,7 +496,7 @@ FGBFI::getHeading () double FGBFI::getHeadingMag () { - return current_aircraft.fdm_state->get_Psi() * RAD_TO_DEG - getMagVar(); + return current_aircraft.fdm_state->get_Psi() * SGD_RADIANS_TO_DEGREES - getMagVar(); } @@ -457,7 +508,7 @@ FGBFI::setHeading (double heading) { FGInterface * fdm = current_aircraft.fdm_state; fdm->set_Euler_Angles(fdm->get_Phi(), fdm->get_Theta(), - heading * DEG_TO_RAD); + heading * SGD_DEGREES_TO_RADIANS); } @@ -467,7 +518,7 @@ FGBFI::setHeading (double heading) double FGBFI::getPitch () { - return current_aircraft.fdm_state->get_Theta() * RAD_TO_DEG; + return current_aircraft.fdm_state->get_Theta() * SGD_RADIANS_TO_DEGREES; } @@ -478,7 +529,7 @@ void FGBFI::setPitch (double pitch) { FGInterface * fdm = current_aircraft.fdm_state; - fdm->set_Euler_Angles(fdm->get_Phi(), pitch * DEG_TO_RAD, fdm->get_Psi()); + fdm->set_Euler_Angles(fdm->get_Phi(), pitch * SGD_DEGREES_TO_RADIANS, fdm->get_Psi()); } @@ -488,7 +539,7 @@ FGBFI::setPitch (double pitch) double FGBFI::getRoll () { - return current_aircraft.fdm_state->get_Phi() * RAD_TO_DEG; + return current_aircraft.fdm_state->get_Phi() * SGD_RADIANS_TO_DEGREES; } @@ -499,7 +550,7 @@ void FGBFI::setRoll (double roll) { FGInterface * fdm = current_aircraft.fdm_state; - fdm->set_Euler_Angles(roll * DEG_TO_RAD, fdm->get_Theta(), fdm->get_Psi()); + fdm->set_Euler_Angles(roll * SGD_DEGREES_TO_RADIANS, fdm->get_Theta(), fdm->get_Psi()); } @@ -560,7 +611,7 @@ FGBFI::getCHT () /** - * Return the current engine0 CHT. + * Return the current engine0 Manifold Pressure. */ double FGBFI::getMP () @@ -572,6 +623,52 @@ FGBFI::getMP () } } +/** + * Return the current engine0 fuel flow + */ +double +FGBFI::getFuelFlow () +{ + if ( current_aircraft.fdm_state->get_engine(0) != NULL ) { + return current_aircraft.fdm_state->get_engine(0)->get_Fuel_Flow(); + } else { + return 0.0; + } +} + +//////////////////////////////////////////////////////////////////////// +// Consumables +//////////////////////////////////////////////////////////////////////// + +/** + * Return the fuel level in tank 1 + */ +double +FGBFI::getTank1Fuel () +{ + return current_aircraft.fdm_state->get_Tank1Fuel(); +} + +void +FGBFI::setTank1Fuel ( double gals ) +{ + current_aircraft.fdm_state->set_Tank1Fuel( gals ); +} + +/** + * Return the fuel level in tank 2 + */ +double +FGBFI::getTank2Fuel () +{ + return current_aircraft.fdm_state->get_Tank2Fuel(); +} + +void +FGBFI::setTank2Fuel ( double gals ) +{ + current_aircraft.fdm_state->set_Tank2Fuel( gals ); +} //////////////////////////////////////////////////////////////////////// @@ -686,435 +783,277 @@ FGBFI::getSpeedDown () //////////////////////////////////////////////////////////////////////// -// Controls +// Autopilot //////////////////////////////////////////////////////////////////////// -#if 0 - -/** - * Get the throttle setting, from 0.0 (none) to 1.0 (full). - */ -double -FGBFI::getThrottle () -{ - // FIXME: add engine selector - return controls.get_throttle(0); -} - - -/** - * Set the throttle, from 0.0 (none) to 1.0 (full). - */ -void -FGBFI::setThrottle (double throttle) -{ - // FIXME: allow engine selection - controls.set_throttle(0, throttle); -} - - -/** - * Get the fuel mixture setting, from 0.0 (none) to 1.0 (full). - */ -double -FGBFI::getMixture () -{ - // FIXME: add engine selector - return controls.get_mixture(0); -} - - -/** - * Set the fuel mixture, from 0.0 (none) to 1.0 (full). - */ -void -FGBFI::setMixture (double mixture) -{ - // FIXME: allow engine selection - controls.set_mixture(0, mixture); -} - - -/** - * Get the propellor pitch setting, from 0.0 (none) to 1.0 (full). - */ -double -FGBFI::getPropAdvance () -{ - // FIXME: add engine selector - return controls.get_prop_advance(0); -} - - -/** - * Set the propellor pitch, from 0.0 (none) to 1.0 (full). - */ -void -FGBFI::setPropAdvance (double pitch) -{ - // FIXME: allow engine selection - controls.set_prop_advance(0, pitch); -} - - -/** - * Get the flaps setting, from 0.0 (none) to 1.0 (full). - */ -double -FGBFI::getFlaps () -{ - return controls.get_flaps(); -} - - -/** - * Set the flaps, from 0.0 (none) to 1.0 (full). - */ -void -FGBFI::setFlaps (double flaps) -{ - // FIXME: clamp? - controls.set_flaps(flaps); -} - - -/** - * Get the aileron, from -1.0 (left) to 1.0 (right). - */ -double -FGBFI::getAileron () -{ - return controls.get_aileron(); -} - - -/** - * Set the aileron, from -1.0 (left) to 1.0 (right). - */ -void -FGBFI::setAileron (double aileron) -{ - // FIXME: clamp? - controls.set_aileron(aileron); -} - - -/** - * Get the rudder setting, from -1.0 (left) to 1.0 (right). - */ -double -FGBFI::getRudder () -{ - return controls.get_rudder(); -} - - -/** - * Set the rudder, from -1.0 (left) to 1.0 (right). - */ -void -FGBFI::setRudder (double rudder) -{ - // FIXME: clamp? - controls.set_rudder(rudder); -} - /** - * Get the elevator setting, from -1.0 (down) to 1.0 (up). + * Get the autopilot altitude lock (true=on). */ -double -FGBFI::getElevator () +bool +FGBFI::getAPAltitudeLock () { - return controls.get_elevator(); + return current_autopilot->get_AltitudeEnabled(); } /** - * Set the elevator, from -1.0 (down) to 1.0 (up). + * Set the autopilot altitude lock (true=on). */ void -FGBFI::setElevator (double elevator) +FGBFI::setAPAltitudeLock (bool lock) { - // FIXME: clamp? - controls.set_elevator(elevator); + current_autopilot->set_AltitudeMode(FGAutopilot::FG_ALTITUDE_LOCK); + current_autopilot->set_AltitudeEnabled(lock); } /** - * Get the elevator trim, from -1.0 (down) to 1.0 (up). + * Get the autopilot altitude lock (true=on). */ -double -FGBFI::getElevatorTrim () +bool +FGBFI::getAPGSLock () { - return controls.get_elevator_trim(); + return current_autopilot->get_AltitudeEnabled(); } /** - * Set the elevator trim, from -1.0 (down) to 1.0 (up). + * Set the autopilot altitude lock (true=on). */ void -FGBFI::setElevatorTrim (double trim) +FGBFI::setAPGSLock (bool lock) { - // FIXME: clamp? - controls.set_elevator_trim(trim); + current_autopilot->set_AltitudeMode(FGAutopilot::FG_ALTITUDE_GS1); + current_autopilot->set_AltitudeEnabled(lock); } /** - * Get the highest brake setting, from 0.0 (none) to 1.0 (full). + * Get the autopilot target altitude in feet. */ double -FGBFI::getBrakes () +FGBFI::getAPAltitude () { - double b1 = getCenterBrake(); - double b2 = getLeftBrake(); - double b3 = getRightBrake(); - return (b1 > b2 ? (b1 > b3 ? b1 : b3) : (b2 > b3 ? b2 : b3)); + return current_autopilot->get_TargetAltitude() * SG_METER_TO_FEET; } /** - * Set all brakes, from 0.0 (none) to 1.0 (full). + * Set the autopilot target altitude in feet. */ void -FGBFI::setBrakes (double brake) +FGBFI::setAPAltitude (double altitude) { - setCenterBrake(brake); - setLeftBrake(brake); - setRightBrake(brake); + current_autopilot->set_TargetAltitude( altitude * SG_FEET_TO_METER ); } /** - * Get the center brake, from 0.0 (none) to 1.0 (full). + * Get the autopilot target altitude in feet. */ double -FGBFI::getCenterBrake () +FGBFI::getAPClimb () { - return controls.get_brake(2); + return current_autopilot->get_TargetClimbRate() * SG_METER_TO_FEET; } /** - * Set the center brake, from 0.0 (none) to 1.0 (full). + * Set the autopilot target altitude in feet. */ void -FGBFI::setCenterBrake (double brake) +FGBFI::setAPClimb (double rate) { - controls.set_brake(2, brake); + current_autopilot->set_TargetClimbRate( rate * SG_FEET_TO_METER ); } /** - * Get the left brake, from 0.0 (none) to 1.0 (full). + * Get the autopilot heading lock (true=on). */ -double -FGBFI::getLeftBrake () +bool +FGBFI::getAPHeadingLock () { - return controls.get_brake(0); + return + (current_autopilot->get_HeadingEnabled() && + current_autopilot->get_HeadingMode() == DEFAULT_AP_HEADING_LOCK); } /** - * Set the left brake, from 0.0 (none) to 1.0 (full). + * Set the autopilot heading lock (true=on). */ void -FGBFI::setLeftBrake (double brake) +FGBFI::setAPHeadingLock (bool lock) { - controls.set_brake(0, brake); + if (lock) { + current_autopilot->set_HeadingMode(DEFAULT_AP_HEADING_LOCK); + current_autopilot->set_HeadingEnabled(true); + } else { + current_autopilot->set_HeadingEnabled(false); + } } /** - * Get the right brake, from 0.0 (none) to 1.0 (full). + * Get the autopilot heading bug in degrees. */ double -FGBFI::getRightBrake () +FGBFI::getAPHeadingBug () { - return controls.get_brake(1); + return current_autopilot->get_DGTargetHeading(); } /** - * Set the right brake, from 0.0 (none) to 1.0 (full). + * Set the autopilot heading bug in degrees. */ void -FGBFI::setRightBrake (double brake) +FGBFI::setAPHeadingBug (double heading) { - controls.set_brake(1, brake); + current_autopilot->set_DGTargetHeading( heading ); } -#endif - - -//////////////////////////////////////////////////////////////////////// -// Autopilot -//////////////////////////////////////////////////////////////////////// - - /** - * Get the autopilot altitude lock (true=on). + * Get the autopilot wing leveler lock (true=on). */ bool -FGBFI::getAPAltitudeLock () -{ - return current_autopilot->get_AltitudeEnabled(); -} - - -/** - * Set the autopilot altitude lock (true=on). - */ -void -FGBFI::setAPAltitudeLock (bool lock) +FGBFI::getAPWingLeveler () { - current_autopilot->set_AltitudeMode(FGAutopilot::FG_ALTITUDE_LOCK); - current_autopilot->set_AltitudeEnabled(lock); -} - - -/** - * Get the autopilot target altitude in feet. - */ -double -FGBFI::getAPAltitude () -{ - return current_autopilot->get_TargetAltitude() * METER_TO_FEET; + return + (current_autopilot->get_HeadingEnabled() && + current_autopilot->get_HeadingMode() == FGAutopilot::FG_TC_HEADING_LOCK); } /** - * Set the autopilot target altitude in feet. + * Set the autopilot wing leveler lock (true=on). */ void -FGBFI::setAPAltitude (double altitude) +FGBFI::setAPWingLeveler (bool lock) { - current_autopilot->set_TargetAltitude( altitude ); + if (lock) { + current_autopilot->set_HeadingMode(FGAutopilot::FG_TC_HEADING_LOCK); + current_autopilot->set_HeadingEnabled(true); + } else { + current_autopilot->set_HeadingEnabled(false); + } } /** - * Get the autopilot heading lock (true=on). + * Return true if the autopilot is locked to NAV1. */ bool -FGBFI::getAPHeadingLock () +FGBFI::getAPNAV1Lock () { - return - (current_autopilot->get_HeadingEnabled() && - current_autopilot->get_HeadingMode() == FGAutopilot::FG_HEADING_LOCK); + return + (current_autopilot->get_HeadingEnabled() && + current_autopilot->get_HeadingMode() == FGAutopilot::FG_HEADING_NAV1); } /** - * Set the autopilot heading lock (true=on). + * Set the autopilot NAV1 lock. */ void -FGBFI::setAPHeadingLock (bool lock) +FGBFI::setAPNAV1Lock (bool lock) { if (lock) { - // We need to do this so that - // it's possible to lock onto a - // heading other than the current - // heading. - double heading = getAPHeadingMag(); - current_autopilot->set_HeadingMode(FGAutopilot::FG_HEADING_LOCK); + current_autopilot->set_HeadingMode(FGAutopilot::FG_HEADING_NAV1); current_autopilot->set_HeadingEnabled(true); - setAPHeadingMag(heading); } else if (current_autopilot->get_HeadingMode() == - FGAutopilot::FG_HEADING_LOCK) { + FGAutopilot::FG_HEADING_NAV1) { current_autopilot->set_HeadingEnabled(false); } } - /** - * Get the autopilot target heading in degrees. + * Get the autopilot autothrottle lock. */ -double -FGBFI::getAPHeading () +bool +FGBFI::getAPAutoThrottleLock () { - return current_autopilot->get_TargetHeading(); + return current_autopilot->get_AutoThrottleEnabled(); } /** - * Set the autopilot target heading in degrees. + * Set the autothrottle lock. */ void -FGBFI::setAPHeading (double heading) +FGBFI::setAPAutoThrottleLock (bool lock) { - current_autopilot->set_TargetHeading( heading ); + current_autopilot->set_AutoThrottleEnabled(lock); } -/** - * Get the autopilot DG target heading in degrees. - */ +// kludge double -FGBFI::getAPHeadingDG () +FGBFI::getAPRudderControl () { - return current_autopilot->get_DGTargetHeading(); + if (getAPHeadingLock()) + return current_autopilot->get_TargetHeading(); + else + return controls.get_rudder(); } - -/** - * Set the autopilot DG target heading in degrees. - */ +// kludge void -FGBFI::setAPHeadingDG (double heading) -{ - current_autopilot->set_DGTargetHeading( heading ); +FGBFI::setAPRudderControl (double value) +{ + if (getAPHeadingLock()) { + SG_LOG(SG_GENERAL, SG_DEBUG, "setAPRudderControl " << value ); + value -= current_autopilot->get_TargetHeading(); + current_autopilot->HeadingAdjust(value < 0.0 ? -1.0 : 1.0); + } else { + controls.set_rudder(value); + } } - -/** - * Get the autopilot target heading in degrees. - */ +// kludge double -FGBFI::getAPHeadingMag () +FGBFI::getAPElevatorControl () { - return current_autopilot->get_TargetHeading() - getMagVar(); + if (getAPAltitudeLock()) + return current_autopilot->get_TargetAltitude(); + else + return controls.get_elevator(); } - -/** - * Set the autopilot target heading in degrees. - */ +// kludge void -FGBFI::setAPHeadingMag (double heading) -{ - current_autopilot->set_TargetHeading( heading + getMagVar() ); +FGBFI::setAPElevatorControl (double value) +{ + if (getAPAltitudeLock()) { + SG_LOG(SG_GENERAL, SG_DEBUG, "setAPElevatorControl " << value ); + value -= current_autopilot->get_TargetAltitude(); + current_autopilot->AltitudeAdjust(value < 0.0 ? 100.0 : -100.0); + } else { + controls.set_elevator(value); + } } - -/** - * Return true if the autopilot is locked to NAV1. - */ -bool -FGBFI::getAPNAV1Lock () +// kludge +double +FGBFI::getAPThrottleControl () { - return - (current_autopilot->get_HeadingEnabled() && - current_autopilot->get_HeadingMode() == FGAutopilot::FG_HEADING_NAV1); + if (getAPAutoThrottleLock()) + return 0.0; // always resets + else + return controls.get_throttle(0); } - -/** - * Set the autopilot NAV1 lock. - */ +// kludge void -FGBFI::setAPNAV1Lock (bool lock) +FGBFI::setAPThrottleControl (double value) { - if (lock) { - current_autopilot->set_HeadingMode(FGAutopilot::FG_HEADING_NAV1); - current_autopilot->set_HeadingEnabled(true); - } else if (current_autopilot->get_HeadingMode() == - FGAutopilot::FG_HEADING_NAV1) { - current_autopilot->set_HeadingEnabled(false); - } + if (getAPAutoThrottleLock()) + current_autopilot->AutoThrottleAdjust(value < 0.0 ? -0.01 : 0.01); + else + controls.set_throttle(0, value); } @@ -1171,17 +1110,6 @@ FGBFI::getGPSTargetLongitude () return current_autopilot->get_TargetLongitude(); } -#if 0 -/** - * Set the GPS target longitude in degrees (negative for west). - */ -void -FGBFI::setGPSTargetLongitude (double longitude) -{ - current_autopilot->set_TargetLongitude( longitude ); -} -#endif - //////////////////////////////////////////////////////////////////////// @@ -1289,6 +1217,18 @@ FGBFI::setWindDown (double speed) // View. //////////////////////////////////////////////////////////////////////// +double +FGBFI::getFOV () +{ + return globals->get_current_view()->get_fov(); +} + +void +FGBFI::setFOV (double fov) +{ + globals->get_current_view()->set_fov( fov ); +} + void FGBFI::setViewAxisLong (double axis) { @@ -1312,7 +1252,7 @@ FGBFI::setViewAxisLat (double axis) double FGBFI::getMagVar () { - return globals->get_mag()->get_magvar() * RAD_TO_DEG; + return globals->get_mag()->get_magvar() * SGD_RADIANS_TO_DEGREES; } @@ -1322,7 +1262,7 @@ FGBFI::getMagVar () double FGBFI::getMagDip () { - return globals->get_mag()->get_magdip() * RAD_TO_DEG; + return globals->get_mag()->get_magdip() * SGD_RADIANS_TO_DEGREES; }