1 // bfi.cxx - Big Friendly Interface implementation
3 // Written by David Megginson, started February, 2000.
5 // Copyright (C) 2000 David Megginson - david@megginson.com
7 // THIS CLASS IS DEPRECATED; USE THE PROPERTY MANAGER INSTEAD.
9 // This program is free software; you can redistribute it and/or
10 // modify it under the terms of the GNU General Public License as
11 // published by the Free Software Foundation; either version 2 of the
12 // License, or (at your option) any later version.
14 // This program is distributed in the hope that it will be useful, but
15 // WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 // General Public License for more details.
19 // You should have received a copy of the GNU General Public License
20 // along with this program; if not, write to the Free Software
21 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27 #include <simgear/constants.h>
28 #include <simgear/debug/logstream.hxx>
29 #include <simgear/ephemeris/ephemeris.hxx>
30 #include <simgear/math/sg_types.hxx>
31 #include <simgear/misc/props.hxx>
32 #include <simgear/timing/sg_time.hxx>
34 #include <Aircraft/aircraft.hxx>
35 #include <FDM/UIUCModel/uiuc_aircraftdir.h>
36 #include <Controls/controls.hxx>
37 #include <Autopilot/newauto.hxx>
38 #include <Scenery/scenery.hxx>
39 #include <Time/light.hxx>
40 #include <Time/event.hxx>
41 #include <Time/sunpos.hxx>
42 #include <Time/tmp.hxx>
43 #include <Cockpit/radiostack.hxx>
44 #include <Cockpit/panel.hxx>
45 #ifndef FG_OLD_WEATHER
46 # include <WeatherCM/FGLocalWeatherDatabase.h>
48 # include <Weather/weather.hxx>
51 #include "globals.hxx"
52 #include "fg_init.hxx"
53 #include "fg_props.hxx"
55 FG_USING_NAMESPACE(std);
62 ////////////////////////////////////////////////////////////////////////
64 ////////////////////////////////////////////////////////////////////////
66 // Yech -- not thread-safe, etc. etc.
67 static bool _needReinit = false;
70 static inline void needReinit ()
77 * Reinitialize FGFS to use the new BFI settings.
82 // Save the state of everything
83 // that's going to get clobbered
84 // when we reinit the subsystems.
86 FG_LOG(FG_GENERAL, FG_INFO, "Starting BFI reinit");
88 // TODO: add more AP stuff
89 bool apHeadingLock = FGBFI::getAPHeadingLock();
90 double apHeadingMag = FGBFI::getAPHeadingMag();
91 bool apAltitudeLock = FGBFI::getAPAltitudeLock();
92 double apAltitude = FGBFI::getAPAltitude();
93 bool gpsLock = FGBFI::getGPSLock();
94 // double gpsLatitude = FGBFI::getGPSTargetLatitude();
95 // double gpsLongitude = FGBFI::getGPSTargetLongitude();
99 // FIXME: this is wrong.
100 // All of these are scheduled events,
101 // and it should be possible to force
102 // them all to run once.
105 cur_light_params.Update();
107 fgUpdateWeatherDatabase();
108 current_radiostack->search();
110 // Restore all of the old states.
111 FGBFI::setAPHeadingLock(apHeadingLock);
112 FGBFI::setAPHeadingMag(apHeadingMag);
113 FGBFI::setAPAltitudeLock(apAltitudeLock);
114 FGBFI::setAPAltitude(apAltitude);
115 FGBFI::setGPSLock(gpsLock);
119 FG_LOG(FG_GENERAL, FG_INFO, "Ending BFI reinit");
122 // BEGIN: kludge 2000-12-07
123 // This is a kludge around a LaRCsim problem; see setAltitude()
125 static int _altitude_countdown = 0;
126 static double _requested_altitude = -9999;
127 static bool _saved_freeze = false;
128 static inline void _check_altitude ()
130 if (_altitude_countdown > 0) {
131 _altitude_countdown--;
132 if (_altitude_countdown == 0) {
133 current_aircraft.fdm_state->set_Altitude(_requested_altitude);
134 globals->set_freeze(_saved_freeze);
139 static int _lighting_countdown = 0;
140 static inline void _check_lighting ()
142 if (_lighting_countdown > 0) {
143 _lighting_countdown--;
144 if (_lighting_countdown == 0)
145 fgUpdateSkyAndLightingParams();
152 // Allow the view to be set from two axes (i.e. a joystick hat)
153 // This needs to be in FGViewer itself, somehow.
154 static double axisLong = 0.0;
155 static double axisLat = 0.0;
158 _set_view_from_axes ()
160 // Take no action when hat is centered
161 if (axisLong == 0 && axisLat == 0)
166 if (axisLong < 0) { // Longitudinal axis forward
169 else if (axisLat > 0)
173 } else if (axisLong > 0) { // Longitudinal axis backward
176 else if (axisLat > 0)
180 } else { // Longitudinal axis neutral
187 globals->get_current_view()->set_goal_view_offset(viewDir*DEG_TO_RAD);
188 // globals->get_current_view()->set_view_offset(viewDir*DEG_TO_RAD);
195 ////////////////////////////////////////////////////////////////////////
197 ////////////////////////////////////////////////////////////////////////
200 * Initialize the BFI by binding its functions to properties.
202 * TODO: perhaps these should migrate into the individual modules
203 * (i.e. they should register themselves).
208 FG_LOG(FG_GENERAL, FG_INFO, "Starting BFI init");
210 fgTie("/sim/aircraft-dir", getAircraftDir, setAircraftDir);
211 fgTie("/sim/time/gmt", getDateString, setDateString);
212 fgTie("/sim/time/gmt-string", getGMTString);
215 // fgTie("/position/latitude", getLatitude, setLatitude);
216 // fgTie("/position/longitude", getLongitude, setLongitude);
217 // fgTie("/position/altitude", getAltitude, setAltitude);
218 // fgTie("/position/altitude-agl", getAGL);
221 // fgTie("/orientation/heading", getHeading, setHeading);
222 fgTie("/orientation/heading-magnetic", getHeadingMag);
223 // fgTie("/orientation/pitch", getPitch, setPitch);
224 // fgTie("/orientation/roll", getRoll, setRoll);
227 fgTie("/engines/engine0/rpm", getRPM);
228 fgTie("/engines/engine0/egt", getEGT);
229 fgTie("/engines/engine0/cht", getCHT);
230 fgTie("/engines/engine0/mp", getMP);
233 // fgTie("/velocities/airspeed", getAirspeed, setAirspeed);
234 // fgTie("/velocities/side-slip", getSideSlip);
235 // fgTie("/velocities/vertical-speed", getVerticalSpeed);
236 // fgTie("/velocities/speed-north", getSpeedNorth);
237 // fgTie("/velocities/speed-east", getSpeedEast);
238 // fgTie("/velocities/speed-down", getSpeedDown);
241 fgTie("/autopilot/locks/altitude", getAPAltitudeLock, setAPAltitudeLock);
242 fgTie("/autopilot/settings/altitude", getAPAltitude, setAPAltitude);
243 fgTie("/autopilot/locks/heading", getAPHeadingLock, setAPHeadingLock);
244 fgTie("/autopilot/settings/heading", getAPHeading, setAPHeading);
245 fgTie("/autopilot/settings/heading-magnetic",
246 getAPHeadingMag, setAPHeadingMag);
247 fgTie("/autopilot/locks/nav1", getAPNAV1Lock, setAPNAV1Lock);
250 fgTie("/environment/visibility", getVisibility, setVisibility);
251 fgTie("/environment/wind-north", getWindNorth, setWindNorth);
252 fgTie("/environment/wind-east", getWindEast, setWindEast);
253 fgTie("/environment/wind-down", getWindDown, setWindDown);
256 fgTie("/sim/view/axes/long", (double(*)())0, setViewAxisLong);
257 fgTie("/sim/view/axes/lat", (double(*)())0, setViewAxisLat);
259 _altitude_countdown = 0;
260 globals->set_freeze(_saved_freeze);
263 FG_LOG(FG_GENERAL, FG_INFO, "Ending BFI init");
268 * Reinitialize FGFS if required.
270 * Some changes (especially those in aircraft position) require that
271 * FGFS be reinitialized afterwards. Rather than reinitialize after
272 * every change, the setter methods simply set a flag so that there
273 * can be a single reinit at the end of the frame.
280 _set_view_from_axes();
288 ////////////////////////////////////////////////////////////////////////
290 ////////////////////////////////////////////////////////////////////////
294 * Return the current aircraft directory (UIUC) as a string.
297 FGBFI::getAircraftDir ()
304 * Set the current aircraft directory (UIUC).
307 FGBFI::setAircraftDir (string dir)
309 if (getAircraftDir() != dir) {
317 * Return the current Zulu time.
320 FGBFI::getDateString ()
324 struct tm * t = globals->get_time_params()->getGmt();
325 sprintf(buf, "%.4d-%.2d-%.2dT%.2d:%.2d:%.2d",
326 t->tm_year + 1900, t->tm_mon + 1, t->tm_mday,
327 t->tm_hour, t->tm_min, t->tm_sec);
334 * Set the current Zulu time.
337 FGBFI::setDateString (string date_string)
338 // FGBFI::setTimeGMT (time_t time)
340 SGTime * st = globals->get_time_params();
341 struct tm * current_time = st->getGmt();
344 // Scan for basic ISO format
345 // YYYY-MM-DDTHH:MM:SS
346 int ret = sscanf(date_string.c_str(), "%d-%d-%dT%d:%d:%d",
347 &(new_time.tm_year), &(new_time.tm_mon),
348 &(new_time.tm_mday), &(new_time.tm_hour),
349 &(new_time.tm_min), &(new_time.tm_sec));
351 // Be pretty picky about this, so
352 // that strange things don't happen
353 // if the save file has been edited
356 FG_LOG(FG_INPUT, FG_ALERT, "Date/time string " << date_string
357 << " not in YYYY-MM-DDTHH:MM:SS format; skipped");
361 // OK, it looks like we got six
362 // values, one way or another.
363 new_time.tm_year -= 1900;
364 new_time.tm_mon -= 1;
366 // Now, tell flight gear to use
367 // the new time. This was far
368 // too difficult, by the way.
370 mktime(&new_time) - mktime(current_time) + globals->get_warp();
371 double lon = current_aircraft.fdm_state->get_Longitude();
372 double lat = current_aircraft.fdm_state->get_Latitude();
373 double alt = current_aircraft.fdm_state->get_Altitude() * FEET_TO_METER;
374 globals->set_warp(warp);
375 st->update(lon, lat, warp);
376 fgUpdateSkyAndLightingParams();
381 * Return the GMT as a string.
384 FGBFI::getGMTString ()
388 struct tm * t = globals->get_time_params()->getGmt();
389 sprintf(buf, " %.2d:%.2d:%.2d",
390 t->tm_hour, t->tm_min, t->tm_sec);
397 ////////////////////////////////////////////////////////////////////////
399 ////////////////////////////////////////////////////////////////////////
403 * Return the current latitude in degrees (negative for south).
406 FGBFI::getLatitude ()
408 return current_aircraft.fdm_state->get_Latitude() * RAD_TO_DEG;
413 * Set the current latitude in degrees (negative for south).
416 FGBFI::setLatitude (double latitude)
418 current_aircraft.fdm_state->set_Latitude(latitude * DEG_TO_RAD);
419 fgUpdateSkyAndLightingParams();
420 if (_lighting_countdown <= 0)
421 _lighting_countdown = 5;
426 * Return the current longitude in degrees (negative for west).
429 FGBFI::getLongitude ()
431 return current_aircraft.fdm_state->get_Longitude() * RAD_TO_DEG;
436 * Set the current longitude in degrees (negative for west).
439 FGBFI::setLongitude (double longitude)
441 current_aircraft.fdm_state->set_Longitude(longitude * DEG_TO_RAD);
442 fgUpdateSkyAndLightingParams();
443 if (_lighting_countdown <= 0)
444 _lighting_countdown = 5;
449 * Return the current altitude in feet.
452 FGBFI::getAltitude ()
454 return current_aircraft.fdm_state->get_Altitude();
460 * Return the current altitude in above the terrain.
465 return current_aircraft.fdm_state->get_Altitude()
466 - (scenery.cur_elev * METER_TO_FEET);
471 * Set the current altitude in feet.
474 FGBFI::setAltitude (double altitude)
476 current_aircraft.fdm_state->set_Altitude(altitude);
479 // This is an ugly kludge around a
480 // LaRCsim problem; if the
481 // requested altitude cannot be
482 // set right away (because it's
483 // below the last-calculated ground
484 // level), pause FGFS, wait for
485 // five frames, and then try again.
486 if (_altitude_countdown <= 0 &&
487 fabs(getAltitude() - altitude) > 5.0) {
488 _altitude_countdown = 5;
489 _requested_altitude = altitude;
490 _saved_freeze = globals->get_freeze();
491 globals->set_freeze(true);
497 ////////////////////////////////////////////////////////////////////////
499 ////////////////////////////////////////////////////////////////////////
503 * Return the current heading in degrees.
508 return current_aircraft.fdm_state->get_Psi() * RAD_TO_DEG;
513 * Return the current heading in degrees.
516 FGBFI::getHeadingMag ()
518 return current_aircraft.fdm_state->get_Psi() * RAD_TO_DEG - getMagVar();
523 * Set the current heading in degrees.
526 FGBFI::setHeading (double heading)
528 FGInterface * fdm = current_aircraft.fdm_state;
529 fdm->set_Euler_Angles(fdm->get_Phi(), fdm->get_Theta(),
530 heading * DEG_TO_RAD);
535 * Return the current pitch in degrees.
540 return current_aircraft.fdm_state->get_Theta() * RAD_TO_DEG;
545 * Set the current pitch in degrees.
548 FGBFI::setPitch (double pitch)
550 FGInterface * fdm = current_aircraft.fdm_state;
551 fdm->set_Euler_Angles(fdm->get_Phi(), pitch * DEG_TO_RAD, fdm->get_Psi());
556 * Return the current roll in degrees.
561 return current_aircraft.fdm_state->get_Phi() * RAD_TO_DEG;
566 * Set the current roll in degrees.
569 FGBFI::setRoll (double roll)
571 FGInterface * fdm = current_aircraft.fdm_state;
572 fdm->set_Euler_Angles(roll * DEG_TO_RAD, fdm->get_Theta(), fdm->get_Psi());
577 * Return the current engine0 rpm
582 if ( current_aircraft.fdm_state->get_engine(0) != NULL ) {
583 return current_aircraft.fdm_state->get_engine(0)->get_RPM();
591 * Set the current engine0 rpm
594 FGBFI::setRPM (double rpm)
596 if ( current_aircraft.fdm_state->get_engine(0) != NULL ) {
597 if (getRPM() != rpm) {
598 current_aircraft.fdm_state->get_engine(0)->set_RPM( rpm );
605 * Return the current engine0 EGT.
610 if ( current_aircraft.fdm_state->get_engine(0) != NULL ) {
611 return current_aircraft.fdm_state->get_engine(0)->get_EGT();
619 * Return the current engine0 CHT.
624 if ( current_aircraft.fdm_state->get_engine(0) != NULL ) {
625 return current_aircraft.fdm_state->get_engine(0)->get_CHT();
633 * Return the current engine0 CHT.
638 if ( current_aircraft.fdm_state->get_engine(0) != NULL ) {
639 return current_aircraft.fdm_state->get_engine(0)->get_Manifold_Pressure();
647 ////////////////////////////////////////////////////////////////////////
649 ////////////////////////////////////////////////////////////////////////
653 * Return the current airspeed in knots.
656 FGBFI::getAirspeed ()
658 // FIXME: should we add speed-up?
659 return current_aircraft.fdm_state->get_V_calibrated_kts();
664 * Set the calibrated airspeed in knots.
667 FGBFI::setAirspeed (double speed)
669 current_aircraft.fdm_state->set_V_calibrated_kts(speed);
674 * Return the current sideslip (FIXME: units unknown).
677 FGBFI::getSideSlip ()
679 return current_aircraft.fdm_state->get_Beta();
684 * Return the current climb rate in feet/minute
687 FGBFI::getVerticalSpeed ()
689 // What about meters?
690 return current_aircraft.fdm_state->get_Climb_Rate() * 60.0;
695 * Get the current north velocity (units??).
698 FGBFI::getSpeedNorth ()
700 return current_aircraft.fdm_state->get_V_north();
705 // * Set the current north velocity (units??).
708 // FGBFI::setSpeedNorth (double speed)
710 // FGInterface * fdm = current_aircraft.fdm_state;
711 // // fdm->set_Velocities_Local(speed, fdm->get_V_east(), fdm->get_V_down());
716 * Get the current east velocity (units??).
719 FGBFI::getSpeedEast ()
721 return current_aircraft.fdm_state->get_V_east();
726 // * Set the current east velocity (units??).
729 // FGBFI::setSpeedEast (double speed)
731 // FGInterface * fdm = current_aircraft.fdm_state;
732 // // fdm->set_Velocities_Local(fdm->get_V_north(), speed, fdm->get_V_down());
737 * Get the current down velocity (units??).
740 FGBFI::getSpeedDown ()
742 return current_aircraft.fdm_state->get_V_down();
747 // * Set the current down velocity (units??).
750 // FGBFI::setSpeedDown (double speed)
752 // FGInterface * fdm = current_aircraft.fdm_state;
753 // // fdm->set_Velocities_Local(fdm->get_V_north(), fdm->get_V_east(), speed);
758 ////////////////////////////////////////////////////////////////////////
760 ////////////////////////////////////////////////////////////////////////
765 * Get the throttle setting, from 0.0 (none) to 1.0 (full).
768 FGBFI::getThrottle ()
770 // FIXME: add engine selector
771 return controls.get_throttle(0);
776 * Set the throttle, from 0.0 (none) to 1.0 (full).
779 FGBFI::setThrottle (double throttle)
781 // FIXME: allow engine selection
782 controls.set_throttle(0, throttle);
787 * Get the fuel mixture setting, from 0.0 (none) to 1.0 (full).
792 // FIXME: add engine selector
793 return controls.get_mixture(0);
798 * Set the fuel mixture, from 0.0 (none) to 1.0 (full).
801 FGBFI::setMixture (double mixture)
803 // FIXME: allow engine selection
804 controls.set_mixture(0, mixture);
809 * Get the propellor pitch setting, from 0.0 (none) to 1.0 (full).
812 FGBFI::getPropAdvance ()
814 // FIXME: add engine selector
815 return controls.get_prop_advance(0);
820 * Set the propellor pitch, from 0.0 (none) to 1.0 (full).
823 FGBFI::setPropAdvance (double pitch)
825 // FIXME: allow engine selection
826 controls.set_prop_advance(0, pitch);
831 * Get the flaps setting, from 0.0 (none) to 1.0 (full).
836 return controls.get_flaps();
841 * Set the flaps, from 0.0 (none) to 1.0 (full).
844 FGBFI::setFlaps (double flaps)
847 controls.set_flaps(flaps);
852 * Get the aileron, from -1.0 (left) to 1.0 (right).
857 return controls.get_aileron();
862 * Set the aileron, from -1.0 (left) to 1.0 (right).
865 FGBFI::setAileron (double aileron)
868 controls.set_aileron(aileron);
873 * Get the rudder setting, from -1.0 (left) to 1.0 (right).
878 return controls.get_rudder();
883 * Set the rudder, from -1.0 (left) to 1.0 (right).
886 FGBFI::setRudder (double rudder)
889 controls.set_rudder(rudder);
894 * Get the elevator setting, from -1.0 (down) to 1.0 (up).
897 FGBFI::getElevator ()
899 return controls.get_elevator();
904 * Set the elevator, from -1.0 (down) to 1.0 (up).
907 FGBFI::setElevator (double elevator)
910 controls.set_elevator(elevator);
915 * Get the elevator trim, from -1.0 (down) to 1.0 (up).
918 FGBFI::getElevatorTrim ()
920 return controls.get_elevator_trim();
925 * Set the elevator trim, from -1.0 (down) to 1.0 (up).
928 FGBFI::setElevatorTrim (double trim)
931 controls.set_elevator_trim(trim);
936 * Get the highest brake setting, from 0.0 (none) to 1.0 (full).
941 double b1 = getCenterBrake();
942 double b2 = getLeftBrake();
943 double b3 = getRightBrake();
944 return (b1 > b2 ? (b1 > b3 ? b1 : b3) : (b2 > b3 ? b2 : b3));
949 * Set all brakes, from 0.0 (none) to 1.0 (full).
952 FGBFI::setBrakes (double brake)
954 setCenterBrake(brake);
956 setRightBrake(brake);
961 * Get the center brake, from 0.0 (none) to 1.0 (full).
964 FGBFI::getCenterBrake ()
966 return controls.get_brake(2);
971 * Set the center brake, from 0.0 (none) to 1.0 (full).
974 FGBFI::setCenterBrake (double brake)
976 controls.set_brake(2, brake);
981 * Get the left brake, from 0.0 (none) to 1.0 (full).
984 FGBFI::getLeftBrake ()
986 return controls.get_brake(0);
991 * Set the left brake, from 0.0 (none) to 1.0 (full).
994 FGBFI::setLeftBrake (double brake)
996 controls.set_brake(0, brake);
1001 * Get the right brake, from 0.0 (none) to 1.0 (full).
1004 FGBFI::getRightBrake ()
1006 return controls.get_brake(1);
1011 * Set the right brake, from 0.0 (none) to 1.0 (full).
1014 FGBFI::setRightBrake (double brake)
1016 controls.set_brake(1, brake);
1023 ////////////////////////////////////////////////////////////////////////
1025 ////////////////////////////////////////////////////////////////////////
1029 * Get the autopilot altitude lock (true=on).
1032 FGBFI::getAPAltitudeLock ()
1034 return current_autopilot->get_AltitudeEnabled();
1039 * Set the autopilot altitude lock (true=on).
1042 FGBFI::setAPAltitudeLock (bool lock)
1044 current_autopilot->set_AltitudeMode(FGAutopilot::FG_ALTITUDE_LOCK);
1045 current_autopilot->set_AltitudeEnabled(lock);
1050 * Get the autopilot target altitude in feet.
1053 FGBFI::getAPAltitude ()
1055 return current_autopilot->get_TargetAltitude() * METER_TO_FEET;
1060 * Set the autopilot target altitude in feet.
1063 FGBFI::setAPAltitude (double altitude)
1065 current_autopilot->set_TargetAltitude( altitude );
1070 * Get the autopilot heading lock (true=on).
1073 FGBFI::getAPHeadingLock ()
1076 (current_autopilot->get_HeadingEnabled() &&
1077 current_autopilot->get_HeadingMode() == FGAutopilot::FG_HEADING_LOCK);
1082 * Set the autopilot heading lock (true=on).
1085 FGBFI::setAPHeadingLock (bool lock)
1088 // We need to do this so that
1089 // it's possible to lock onto a
1090 // heading other than the current
1092 double heading = getAPHeadingMag();
1093 current_autopilot->set_HeadingMode(FGAutopilot::FG_HEADING_LOCK);
1094 current_autopilot->set_HeadingEnabled(true);
1095 setAPHeadingMag(heading);
1096 } else if (current_autopilot->get_HeadingMode() ==
1097 FGAutopilot::FG_HEADING_LOCK) {
1098 current_autopilot->set_HeadingEnabled(false);
1104 * Get the autopilot target heading in degrees.
1107 FGBFI::getAPHeading ()
1109 return current_autopilot->get_TargetHeading();
1114 * Set the autopilot target heading in degrees.
1117 FGBFI::setAPHeading (double heading)
1119 current_autopilot->set_TargetHeading( heading );
1124 * Get the autopilot target heading in degrees.
1127 FGBFI::getAPHeadingMag ()
1129 return current_autopilot->get_TargetHeading() - getMagVar();
1134 * Set the autopilot target heading in degrees.
1137 FGBFI::setAPHeadingMag (double heading)
1139 current_autopilot->set_TargetHeading( heading + getMagVar() );
1144 * Return true if the autopilot is locked to NAV1.
1147 FGBFI::getAPNAV1Lock ()
1150 (current_autopilot->get_HeadingEnabled() &&
1151 current_autopilot->get_HeadingMode() == FGAutopilot::FG_HEADING_NAV1);
1156 * Set the autopilot NAV1 lock.
1159 FGBFI::setAPNAV1Lock (bool lock)
1162 current_autopilot->set_HeadingMode(FGAutopilot::FG_HEADING_NAV1);
1163 current_autopilot->set_HeadingEnabled(true);
1164 } else if (current_autopilot->get_HeadingMode() ==
1165 FGAutopilot::FG_HEADING_NAV1) {
1166 current_autopilot->set_HeadingEnabled(false);
1172 ////////////////////////////////////////////////////////////////////////
1174 ////////////////////////////////////////////////////////////////////////
1178 * Get the autopilot GPS lock (true=on).
1181 FGBFI::getGPSLock ()
1183 return (current_autopilot->get_HeadingEnabled() &&
1184 (current_autopilot->get_HeadingMode() ==
1185 FGAutopilot::FG_HEADING_WAYPOINT ));
1190 * Set the autopilot GPS lock (true=on).
1193 FGBFI::setGPSLock (bool lock)
1196 current_autopilot->set_HeadingMode(FGAutopilot::FG_HEADING_WAYPOINT);
1197 current_autopilot->set_HeadingEnabled(true);
1198 } else if (current_autopilot->get_HeadingMode() ==
1199 FGAutopilot::FG_HEADING_WAYPOINT) {
1200 current_autopilot->set_HeadingEnabled(false);
1206 * Get the GPS target latitude in degrees (negative for south).
1209 FGBFI::getGPSTargetLatitude ()
1211 return current_autopilot->get_TargetLatitude();
1216 * Get the GPS target longitude in degrees (negative for west).
1219 FGBFI::getGPSTargetLongitude ()
1221 return current_autopilot->get_TargetLongitude();
1226 * Set the GPS target longitude in degrees (negative for west).
1229 FGBFI::setGPSTargetLongitude (double longitude)
1231 current_autopilot->set_TargetLongitude( longitude );
1237 ////////////////////////////////////////////////////////////////////////
1239 ////////////////////////////////////////////////////////////////////////
1243 * Get the current visibility (meters).
1246 FGBFI::getVisibility ()
1248 #ifndef FG_OLD_WEATHER
1249 return WeatherDatabase->getWeatherVisibility();
1251 return current_weather.get_visibility();
1257 * Set the current visibility (meters).
1260 FGBFI::setVisibility (double visibility)
1262 #ifndef FG_OLD_WEATHER
1263 WeatherDatabase->setWeatherVisibility(visibility);
1265 current_weather.set_visibility(visibility);
1271 * Get the current wind north velocity (feet/second).
1274 FGBFI::getWindNorth ()
1276 return current_aircraft.fdm_state->get_V_north_airmass();
1281 * Set the current wind north velocity (feet/second).
1284 FGBFI::setWindNorth (double speed)
1286 current_aircraft.fdm_state->set_Velocities_Local_Airmass(speed,
1293 * Get the current wind east velocity (feet/second).
1296 FGBFI::getWindEast ()
1298 return current_aircraft.fdm_state->get_V_east_airmass();
1303 * Set the current wind east velocity (feet/second).
1306 FGBFI::setWindEast (double speed)
1308 cout << "Set wind-east to " << speed << endl;
1309 current_aircraft.fdm_state->set_Velocities_Local_Airmass(getWindNorth(),
1316 * Get the current wind down velocity (feet/second).
1319 FGBFI::getWindDown ()
1321 return current_aircraft.fdm_state->get_V_down_airmass();
1326 * Set the current wind down velocity (feet/second).
1329 FGBFI::setWindDown (double speed)
1331 current_aircraft.fdm_state->set_Velocities_Local_Airmass(getWindNorth(),
1338 ////////////////////////////////////////////////////////////////////////
1340 ////////////////////////////////////////////////////////////////////////
1343 FGBFI::setViewAxisLong (double axis)
1349 FGBFI::setViewAxisLat (double axis)
1355 ////////////////////////////////////////////////////////////////////////
1357 ////////////////////////////////////////////////////////////////////////
1360 * Return the magnetic variation
1365 return globals->get_mag()->get_magvar() * RAD_TO_DEG;
1370 * Return the magnetic variation
1375 return globals->get_mag()->get_magdip() * RAD_TO_DEG;