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 SG_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 SG_LOG(SG_GENERAL, SG_INFO, "Starting BFI reinit");
88 // TODO: add more AP stuff
89 bool apHeadingLock = FGBFI::getAPHeadingLock();
90 bool apAltitudeLock = FGBFI::getAPAltitudeLock();
91 double apAltitude = FGBFI::getAPAltitude();
92 bool gpsLock = FGBFI::getGPSLock();
93 // double gpsLatitude = FGBFI::getGPSTargetLatitude();
94 // double gpsLongitude = FGBFI::getGPSTargetLongitude();
98 // FIXME: this is wrong.
99 // All of these are scheduled events,
100 // and it should be possible to force
101 // them all to run once.
104 cur_light_params.Update();
106 #ifndef FG_OLD_WEATHER
107 fgUpdateWeatherDatabase();
109 current_radiostack->search();
111 // Restore all of the old states.
112 FGBFI::setAPHeadingLock(apHeadingLock);
113 FGBFI::setAPAltitudeLock(apAltitudeLock);
114 FGBFI::setAPAltitude(apAltitude);
115 FGBFI::setGPSLock(gpsLock);
119 SG_LOG(SG_GENERAL, SG_INFO, "Ending BFI reinit");
123 // Allow the view to be set from two axes (i.e. a joystick hat)
124 // This needs to be in FGViewer itself, somehow.
125 static double axisLong = 0.0;
126 static double axisLat = 0.0;
129 _set_view_from_axes ()
131 // Take no action when hat is centered
132 if (axisLong == 0 && axisLat == 0)
137 if (axisLong < 0) { // Longitudinal axis forward
140 else if (axisLat > 0)
144 } else if (axisLong > 0) { // Longitudinal axis backward
147 else if (axisLat > 0)
151 } else { // Longitudinal axis neutral
158 globals->get_current_view()->set_goal_view_offset(viewDir*SGD_DEGREES_TO_RADIANS);
159 // globals->get_current_view()->set_view_offset(viewDir*SGD_DEGREES_TO_RADIANS);
166 ////////////////////////////////////////////////////////////////////////
168 ////////////////////////////////////////////////////////////////////////
172 * Initialize the BFI by binding its functions to properties.
174 * TODO: perhaps these should migrate into the individual modules
175 * (i.e. they should register themselves).
180 SG_LOG(SG_GENERAL, SG_INFO, "Starting BFI init");
183 fgTie("/sim/aircraft-dir", getAircraftDir, setAircraftDir);
184 fgTie("/sim/time/gmt", getDateString, setDateString);
185 fgTie("/sim/time/gmt-string", getGMTString);
188 fgTie("/orientation/heading-magnetic", getHeadingMag);
191 fgTie("/engines/engine0/rpm", getRPM);
192 fgTie("/engines/engine0/egt", getEGT);
193 fgTie("/engines/engine0/cht", getCHT);
194 fgTie("/engines/engine0/mp", getMP);
195 fgTie("/engines/engine0/fuel-flow", getFuelFlow);
198 fgTie("/consumables/fuel/tank1/level", getTank1Fuel, setTank1Fuel, false);
199 fgTie("/consumables/fuel/tank2/level", getTank2Fuel, setTank2Fuel, false);
202 fgTie("/autopilot/locks/altitude", getAPAltitudeLock, setAPAltitudeLock);
203 fgTie("/autopilot/settings/altitude", getAPAltitude, setAPAltitude);
204 fgTie("/autopilot/settings/climb-rate", getAPClimb, setAPClimb, false);
205 fgTie("/autopilot/locks/heading", getAPHeadingLock, setAPHeadingLock);
206 fgTie("/autopilot/settings/heading-bug", getAPHeadingBug, setAPHeadingBug,
208 fgTie("/autopilot/locks/wing-leveler", getAPWingLeveler, setAPWingLeveler);
209 fgTie("/autopilot/locks/nav1", getAPNAV1Lock, setAPNAV1Lock);
212 fgTie("/environment/visibility", getVisibility, setVisibility);
213 fgTie("/environment/wind-north", getWindNorth, setWindNorth);
214 fgTie("/environment/wind-east", getWindEast, setWindEast);
215 fgTie("/environment/wind-down", getWindDown, setWindDown);
218 fgTie("/sim/field-of-view", getFOV, setFOV);
219 fgTie("/sim/view/axes/long", (double(*)())0, setViewAxisLong);
220 fgTie("/sim/view/axes/lat", (double(*)())0, setViewAxisLat);
224 SG_LOG(SG_GENERAL, SG_INFO, "Ending BFI init");
229 * Reinitialize FGFS if required.
231 * Some changes (especially those in aircraft position) require that
232 * FGFS be reinitialized afterwards. Rather than reinitialize after
233 * every change, the setter methods simply set a flag so that there
234 * can be a single reinit at the end of the frame.
239 _set_view_from_axes();
247 ////////////////////////////////////////////////////////////////////////
249 ////////////////////////////////////////////////////////////////////////
253 * Return the current aircraft directory (UIUC) as a string.
256 FGBFI::getAircraftDir ()
263 * Set the current aircraft directory (UIUC).
266 FGBFI::setAircraftDir (string dir)
268 if (getAircraftDir() != dir) {
276 * Return the current Zulu time.
279 FGBFI::getDateString ()
283 struct tm * t = globals->get_time_params()->getGmt();
284 sprintf(buf, "%.4d-%.2d-%.2dT%.2d:%.2d:%.2d",
285 t->tm_year + 1900, t->tm_mon + 1, t->tm_mday,
286 t->tm_hour, t->tm_min, t->tm_sec);
293 * Set the current Zulu time.
296 FGBFI::setDateString (string date_string)
297 // FGBFI::setTimeGMT (time_t time)
299 SGTime * st = globals->get_time_params();
300 struct tm * current_time = st->getGmt();
303 // Scan for basic ISO format
304 // YYYY-MM-DDTHH:MM:SS
305 int ret = sscanf(date_string.c_str(), "%d-%d-%dT%d:%d:%d",
306 &(new_time.tm_year), &(new_time.tm_mon),
307 &(new_time.tm_mday), &(new_time.tm_hour),
308 &(new_time.tm_min), &(new_time.tm_sec));
310 // Be pretty picky about this, so
311 // that strange things don't happen
312 // if the save file has been edited
315 SG_LOG(SG_INPUT, SG_ALERT, "Date/time string " << date_string
316 << " not in YYYY-MM-DDTHH:MM:SS format; skipped");
320 // OK, it looks like we got six
321 // values, one way or another.
322 new_time.tm_year -= 1900;
323 new_time.tm_mon -= 1;
325 // Now, tell flight gear to use
326 // the new time. This was far
327 // too difficult, by the way.
329 mktime(&new_time) - mktime(current_time) + globals->get_warp();
330 double lon = current_aircraft.fdm_state->get_Longitude();
331 double lat = current_aircraft.fdm_state->get_Latitude();
332 // double alt = current_aircraft.fdm_state->get_Altitude() * SG_FEET_TO_METER;
333 globals->set_warp(warp);
334 st->update(lon, lat, warp);
335 fgUpdateSkyAndLightingParams();
340 * Return the GMT as a string.
343 FGBFI::getGMTString ()
347 struct tm * t = globals->get_time_params()->getGmt();
348 sprintf(buf, " %.2d:%.2d:%.2d",
349 t->tm_hour, t->tm_min, t->tm_sec);
356 ////////////////////////////////////////////////////////////////////////
358 ////////////////////////////////////////////////////////////////////////
362 * Return the current latitude in degrees (negative for south).
365 FGBFI::getLatitude ()
367 return current_aircraft.fdm_state->get_Latitude() * SGD_RADIANS_TO_DEGREES;
372 * Set the current latitude in degrees (negative for south).
375 FGBFI::setLatitude (double latitude)
377 current_aircraft.fdm_state->set_Latitude(latitude * SGD_DEGREES_TO_RADIANS);
382 * Return the current longitude in degrees (negative for west).
385 FGBFI::getLongitude ()
387 return current_aircraft.fdm_state->get_Longitude() * SGD_RADIANS_TO_DEGREES;
392 * Set the current longitude in degrees (negative for west).
395 FGBFI::setLongitude (double longitude)
397 current_aircraft.fdm_state->set_Longitude(longitude * SGD_DEGREES_TO_RADIANS);
402 * Return the current altitude in feet.
405 FGBFI::getAltitude ()
407 return current_aircraft.fdm_state->get_Altitude();
413 * Return the current altitude in above the terrain.
418 return current_aircraft.fdm_state->get_Altitude()
419 - (scenery.cur_elev * SG_METER_TO_FEET);
424 * Set the current altitude in feet.
427 FGBFI::setAltitude (double altitude)
429 current_aircraft.fdm_state->set_Altitude(altitude);
434 ////////////////////////////////////////////////////////////////////////
436 ////////////////////////////////////////////////////////////////////////
440 * Return the current heading in degrees.
445 return current_aircraft.fdm_state->get_Psi() * SGD_RADIANS_TO_DEGREES;
450 * Return the current heading in degrees.
453 FGBFI::getHeadingMag ()
455 return current_aircraft.fdm_state->get_Psi() * SGD_RADIANS_TO_DEGREES - getMagVar();
460 * Set the current heading in degrees.
463 FGBFI::setHeading (double heading)
465 FGInterface * fdm = current_aircraft.fdm_state;
466 fdm->set_Euler_Angles(fdm->get_Phi(), fdm->get_Theta(),
467 heading * SGD_DEGREES_TO_RADIANS);
472 * Return the current pitch in degrees.
477 return current_aircraft.fdm_state->get_Theta() * SGD_RADIANS_TO_DEGREES;
482 * Set the current pitch in degrees.
485 FGBFI::setPitch (double pitch)
487 FGInterface * fdm = current_aircraft.fdm_state;
488 fdm->set_Euler_Angles(fdm->get_Phi(), pitch * SGD_DEGREES_TO_RADIANS, fdm->get_Psi());
493 * Return the current roll in degrees.
498 return current_aircraft.fdm_state->get_Phi() * SGD_RADIANS_TO_DEGREES;
503 * Set the current roll in degrees.
506 FGBFI::setRoll (double roll)
508 FGInterface * fdm = current_aircraft.fdm_state;
509 fdm->set_Euler_Angles(roll * SGD_DEGREES_TO_RADIANS, fdm->get_Theta(), fdm->get_Psi());
514 * Return the current engine0 rpm
519 if ( current_aircraft.fdm_state->get_engine(0) != NULL ) {
520 return current_aircraft.fdm_state->get_engine(0)->get_RPM();
528 * Set the current engine0 rpm
531 FGBFI::setRPM (double rpm)
533 if ( current_aircraft.fdm_state->get_engine(0) != NULL ) {
534 if (getRPM() != rpm) {
535 current_aircraft.fdm_state->get_engine(0)->set_RPM( rpm );
542 * Return the current engine0 EGT.
547 if ( current_aircraft.fdm_state->get_engine(0) != NULL ) {
548 return current_aircraft.fdm_state->get_engine(0)->get_EGT();
556 * Return the current engine0 CHT.
561 if ( current_aircraft.fdm_state->get_engine(0) != NULL ) {
562 return current_aircraft.fdm_state->get_engine(0)->get_CHT();
570 * Return the current engine0 Manifold Pressure.
575 if ( current_aircraft.fdm_state->get_engine(0) != NULL ) {
576 return current_aircraft.fdm_state->get_engine(0)->get_Manifold_Pressure();
583 * Return the current engine0 fuel flow
586 FGBFI::getFuelFlow ()
588 if ( current_aircraft.fdm_state->get_engine(0) != NULL ) {
589 return current_aircraft.fdm_state->get_engine(0)->get_Fuel_Flow();
595 ////////////////////////////////////////////////////////////////////////
597 ////////////////////////////////////////////////////////////////////////
600 * Return the fuel level in tank 1
603 FGBFI::getTank1Fuel ()
605 return current_aircraft.fdm_state->get_Tank1Fuel();
609 FGBFI::setTank1Fuel ( double gals )
611 current_aircraft.fdm_state->set_Tank1Fuel( gals );
615 * Return the fuel level in tank 2
618 FGBFI::getTank2Fuel ()
620 return current_aircraft.fdm_state->get_Tank2Fuel();
624 FGBFI::setTank2Fuel ( double gals )
626 current_aircraft.fdm_state->set_Tank2Fuel( gals );
630 ////////////////////////////////////////////////////////////////////////
632 ////////////////////////////////////////////////////////////////////////
636 * Return the current airspeed in knots.
639 FGBFI::getAirspeed ()
641 // FIXME: should we add speed-up?
642 return current_aircraft.fdm_state->get_V_calibrated_kts();
647 * Set the calibrated airspeed in knots.
650 FGBFI::setAirspeed (double speed)
652 current_aircraft.fdm_state->set_V_calibrated_kts(speed);
657 * Return the current sideslip (FIXME: units unknown).
660 FGBFI::getSideSlip ()
662 return current_aircraft.fdm_state->get_Beta();
667 * Return the current climb rate in feet/minute
670 FGBFI::getVerticalSpeed ()
672 // What about meters?
673 return current_aircraft.fdm_state->get_Climb_Rate() * 60.0;
678 * Get the current north velocity (units??).
681 FGBFI::getSpeedNorth ()
683 return current_aircraft.fdm_state->get_V_north();
688 // * Set the current north velocity (units??).
691 // FGBFI::setSpeedNorth (double speed)
693 // FGInterface * fdm = current_aircraft.fdm_state;
694 // // fdm->set_Velocities_Local(speed, fdm->get_V_east(), fdm->get_V_down());
699 * Get the current east velocity (units??).
702 FGBFI::getSpeedEast ()
704 return current_aircraft.fdm_state->get_V_east();
709 // * Set the current east velocity (units??).
712 // FGBFI::setSpeedEast (double speed)
714 // FGInterface * fdm = current_aircraft.fdm_state;
715 // // fdm->set_Velocities_Local(fdm->get_V_north(), speed, fdm->get_V_down());
720 * Get the current down velocity (units??).
723 FGBFI::getSpeedDown ()
725 return current_aircraft.fdm_state->get_V_down();
730 // * Set the current down velocity (units??).
733 // FGBFI::setSpeedDown (double speed)
735 // FGInterface * fdm = current_aircraft.fdm_state;
736 // // fdm->set_Velocities_Local(fdm->get_V_north(), fdm->get_V_east(), speed);
741 ////////////////////////////////////////////////////////////////////////
743 ////////////////////////////////////////////////////////////////////////
748 * Get the throttle setting, from 0.0 (none) to 1.0 (full).
751 FGBFI::getThrottle ()
753 // FIXME: add engine selector
754 return controls.get_throttle(0);
759 * Set the throttle, from 0.0 (none) to 1.0 (full).
762 FGBFI::setThrottle (double throttle)
764 // FIXME: allow engine selection
765 controls.set_throttle(0, throttle);
770 * Get the fuel mixture setting, from 0.0 (none) to 1.0 (full).
775 // FIXME: add engine selector
776 return controls.get_mixture(0);
781 * Set the fuel mixture, from 0.0 (none) to 1.0 (full).
784 FGBFI::setMixture (double mixture)
786 // FIXME: allow engine selection
787 controls.set_mixture(0, mixture);
792 * Get the propellor pitch setting, from 0.0 (none) to 1.0 (full).
795 FGBFI::getPropAdvance ()
797 // FIXME: add engine selector
798 return controls.get_prop_advance(0);
803 * Set the propellor pitch, from 0.0 (none) to 1.0 (full).
806 FGBFI::setPropAdvance (double pitch)
808 // FIXME: allow engine selection
809 controls.set_prop_advance(0, pitch);
814 * Get the flaps setting, from 0.0 (none) to 1.0 (full).
819 return controls.get_flaps();
824 * Set the flaps, from 0.0 (none) to 1.0 (full).
827 FGBFI::setFlaps (double flaps)
830 controls.set_flaps(flaps);
835 * Get the aileron, from -1.0 (left) to 1.0 (right).
840 return controls.get_aileron();
845 * Set the aileron, from -1.0 (left) to 1.0 (right).
848 FGBFI::setAileron (double aileron)
851 controls.set_aileron(aileron);
856 * Get the rudder setting, from -1.0 (left) to 1.0 (right).
861 return controls.get_rudder();
866 * Set the rudder, from -1.0 (left) to 1.0 (right).
869 FGBFI::setRudder (double rudder)
872 controls.set_rudder(rudder);
877 * Get the elevator setting, from -1.0 (down) to 1.0 (up).
880 FGBFI::getElevator ()
882 return controls.get_elevator();
887 * Set the elevator, from -1.0 (down) to 1.0 (up).
890 FGBFI::setElevator (double elevator)
893 controls.set_elevator(elevator);
898 * Get the elevator trim, from -1.0 (down) to 1.0 (up).
901 FGBFI::getElevatorTrim ()
903 return controls.get_elevator_trim();
908 * Set the elevator trim, from -1.0 (down) to 1.0 (up).
911 FGBFI::setElevatorTrim (double trim)
914 controls.set_elevator_trim(trim);
919 * Get the highest brake setting, from 0.0 (none) to 1.0 (full).
924 double b1 = getCenterBrake();
925 double b2 = getLeftBrake();
926 double b3 = getRightBrake();
927 return (b1 > b2 ? (b1 > b3 ? b1 : b3) : (b2 > b3 ? b2 : b3));
932 * Set all brakes, from 0.0 (none) to 1.0 (full).
935 FGBFI::setBrakes (double brake)
937 setCenterBrake(brake);
939 setRightBrake(brake);
944 * Get the center brake, from 0.0 (none) to 1.0 (full).
947 FGBFI::getCenterBrake ()
949 return controls.get_brake(2);
954 * Set the center brake, from 0.0 (none) to 1.0 (full).
957 FGBFI::setCenterBrake (double brake)
959 controls.set_brake(2, brake);
964 * Get the left brake, from 0.0 (none) to 1.0 (full).
967 FGBFI::getLeftBrake ()
969 return controls.get_brake(0);
974 * Set the left brake, from 0.0 (none) to 1.0 (full).
977 FGBFI::setLeftBrake (double brake)
979 controls.set_brake(0, brake);
984 * Get the right brake, from 0.0 (none) to 1.0 (full).
987 FGBFI::getRightBrake ()
989 return controls.get_brake(1);
994 * Set the right brake, from 0.0 (none) to 1.0 (full).
997 FGBFI::setRightBrake (double brake)
999 controls.set_brake(1, brake);
1006 ////////////////////////////////////////////////////////////////////////
1008 ////////////////////////////////////////////////////////////////////////
1012 * Get the autopilot altitude lock (true=on).
1015 FGBFI::getAPAltitudeLock ()
1017 return current_autopilot->get_AltitudeEnabled();
1022 * Set the autopilot altitude lock (true=on).
1025 FGBFI::setAPAltitudeLock (bool lock)
1027 current_autopilot->set_AltitudeMode(FGAutopilot::FG_ALTITUDE_LOCK);
1028 current_autopilot->set_AltitudeEnabled(lock);
1033 * Get the autopilot target altitude in feet.
1036 FGBFI::getAPAltitude ()
1038 return current_autopilot->get_TargetAltitude() * SG_METER_TO_FEET;
1043 * Set the autopilot target altitude in feet.
1046 FGBFI::setAPAltitude (double altitude)
1048 current_autopilot->set_TargetAltitude( altitude * SG_FEET_TO_METER );
1053 * Get the autopilot target altitude in feet.
1056 FGBFI::getAPClimb ()
1058 return current_autopilot->get_TargetClimbRate() * SG_METER_TO_FEET;
1063 * Set the autopilot target altitude in feet.
1066 FGBFI::setAPClimb (double rate)
1068 current_autopilot->set_TargetClimbRate( rate * SG_FEET_TO_METER );
1073 * Get the autopilot heading lock (true=on).
1076 FGBFI::getAPHeadingLock ()
1079 (current_autopilot->get_HeadingEnabled() &&
1080 current_autopilot->get_HeadingMode() == FGAutopilot::FG_DG_HEADING_LOCK);
1085 * Set the autopilot heading lock (true=on).
1088 FGBFI::setAPHeadingLock (bool lock)
1091 current_autopilot->set_HeadingMode(FGAutopilot::FG_DG_HEADING_LOCK);
1092 current_autopilot->set_HeadingEnabled(true);
1094 current_autopilot->set_HeadingEnabled(false);
1100 * Get the autopilot heading bug in degrees.
1103 FGBFI::getAPHeadingBug ()
1105 return current_autopilot->get_DGTargetHeading();
1110 * Set the autopilot heading bug in degrees.
1113 FGBFI::setAPHeadingBug (double heading)
1115 current_autopilot->set_DGTargetHeading( heading );
1120 * Get the autopilot wing leveler lock (true=on).
1123 FGBFI::getAPWingLeveler ()
1126 (current_autopilot->get_HeadingEnabled() &&
1127 current_autopilot->get_HeadingMode() == FGAutopilot::FG_TC_HEADING_LOCK);
1132 * Set the autopilot wing leveler lock (true=on).
1135 FGBFI::setAPWingLeveler (bool lock)
1138 current_autopilot->set_HeadingMode(FGAutopilot::FG_TC_HEADING_LOCK);
1139 current_autopilot->set_HeadingEnabled(true);
1141 current_autopilot->set_HeadingEnabled(false);
1147 * Return true if the autopilot is locked to NAV1.
1150 FGBFI::getAPNAV1Lock ()
1153 (current_autopilot->get_HeadingEnabled() &&
1154 current_autopilot->get_HeadingMode() == FGAutopilot::FG_HEADING_NAV1);
1159 * Set the autopilot NAV1 lock.
1162 FGBFI::setAPNAV1Lock (bool lock)
1165 current_autopilot->set_HeadingMode(FGAutopilot::FG_HEADING_NAV1);
1166 current_autopilot->set_HeadingEnabled(true);
1167 } else if (current_autopilot->get_HeadingMode() ==
1168 FGAutopilot::FG_HEADING_NAV1) {
1169 current_autopilot->set_HeadingEnabled(false);
1175 ////////////////////////////////////////////////////////////////////////
1177 ////////////////////////////////////////////////////////////////////////
1181 * Get the autopilot GPS lock (true=on).
1184 FGBFI::getGPSLock ()
1186 return (current_autopilot->get_HeadingEnabled() &&
1187 (current_autopilot->get_HeadingMode() ==
1188 FGAutopilot::FG_HEADING_WAYPOINT ));
1193 * Set the autopilot GPS lock (true=on).
1196 FGBFI::setGPSLock (bool lock)
1199 current_autopilot->set_HeadingMode(FGAutopilot::FG_HEADING_WAYPOINT);
1200 current_autopilot->set_HeadingEnabled(true);
1201 } else if (current_autopilot->get_HeadingMode() ==
1202 FGAutopilot::FG_HEADING_WAYPOINT) {
1203 current_autopilot->set_HeadingEnabled(false);
1209 * Get the GPS target latitude in degrees (negative for south).
1212 FGBFI::getGPSTargetLatitude ()
1214 return current_autopilot->get_TargetLatitude();
1219 * Get the GPS target longitude in degrees (negative for west).
1222 FGBFI::getGPSTargetLongitude ()
1224 return current_autopilot->get_TargetLongitude();
1229 * Set the GPS target longitude in degrees (negative for west).
1232 FGBFI::setGPSTargetLongitude (double longitude)
1234 current_autopilot->set_TargetLongitude( longitude );
1240 ////////////////////////////////////////////////////////////////////////
1242 ////////////////////////////////////////////////////////////////////////
1246 * Get the current visibility (meters).
1249 FGBFI::getVisibility ()
1251 #ifndef FG_OLD_WEATHER
1252 return WeatherDatabase->getWeatherVisibility();
1254 return current_weather.get_visibility();
1260 * Set the current visibility (meters).
1263 FGBFI::setVisibility (double visibility)
1265 #ifndef FG_OLD_WEATHER
1266 WeatherDatabase->setWeatherVisibility(visibility);
1268 current_weather.set_visibility(visibility);
1274 * Get the current wind north velocity (feet/second).
1277 FGBFI::getWindNorth ()
1279 return current_aircraft.fdm_state->get_V_north_airmass();
1284 * Set the current wind north velocity (feet/second).
1287 FGBFI::setWindNorth (double speed)
1289 current_aircraft.fdm_state->set_Velocities_Local_Airmass(speed,
1296 * Get the current wind east velocity (feet/second).
1299 FGBFI::getWindEast ()
1301 return current_aircraft.fdm_state->get_V_east_airmass();
1306 * Set the current wind east velocity (feet/second).
1309 FGBFI::setWindEast (double speed)
1311 cout << "Set wind-east to " << speed << endl;
1312 current_aircraft.fdm_state->set_Velocities_Local_Airmass(getWindNorth(),
1319 * Get the current wind down velocity (feet/second).
1322 FGBFI::getWindDown ()
1324 return current_aircraft.fdm_state->get_V_down_airmass();
1329 * Set the current wind down velocity (feet/second).
1332 FGBFI::setWindDown (double speed)
1334 current_aircraft.fdm_state->set_Velocities_Local_Airmass(getWindNorth(),
1341 ////////////////////////////////////////////////////////////////////////
1343 ////////////////////////////////////////////////////////////////////////
1348 return globals->get_current_view()->get_fov();
1352 FGBFI::setFOV (double fov)
1354 globals->get_current_view()->set_fov( fov );
1358 FGBFI::setViewAxisLong (double axis)
1364 FGBFI::setViewAxisLat (double axis)
1370 ////////////////////////////////////////////////////////////////////////
1372 ////////////////////////////////////////////////////////////////////////
1375 * Return the magnetic variation
1380 return globals->get_mag()->get_magvar() * SGD_RADIANS_TO_DEGREES;
1385 * Return the magnetic variation
1390 return globals->get_mag()->get_magdip() * SGD_RADIANS_TO_DEGREES;