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 program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 // General Public License for more details.
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 #if defined( FG_HAVE_NATIVE_SGI_COMPILERS )
29 # include <iostream.h>
34 #include <simgear/constants.h>
35 #include <simgear/debug/logstream.hxx>
36 #include <simgear/ephemeris/ephemeris.hxx>
37 #include <simgear/math/fg_types.hxx>
38 #include <simgear/misc/props.hxx>
39 #include <simgear/timing/sg_time.hxx>
41 #include <Aircraft/aircraft.hxx>
42 #include <FDM/UIUCModel/uiuc_aircraftdir.h>
43 #include <Controls/controls.hxx>
44 #include <Autopilot/newauto.hxx>
45 #include <Scenery/scenery.hxx>
46 #include <Time/light.hxx>
47 #include <Time/event.hxx>
48 #include <Time/sunpos.hxx>
49 #include <Time/tmp.hxx>
50 #include <Cockpit/radiostack.hxx>
51 #ifndef FG_OLD_WEATHER
52 # include <WeatherCM/FGLocalWeatherDatabase.h>
54 # include <Weather/weather.hxx>
57 #include "globals.hxx"
58 #include "options.hxx"
60 #include "fg_init.hxx"
62 FG_USING_NAMESPACE(std);
69 ////////////////////////////////////////////////////////////////////////
71 ////////////////////////////////////////////////////////////////////////
73 bool FGBFI::_needReinit = false;
77 ////////////////////////////////////////////////////////////////////////
79 ////////////////////////////////////////////////////////////////////////
83 * Initialize the BFI by binding its functions to properties.
85 * TODO: perhaps these should migrate into the individual modules
86 * (i.e. they should register themselves).
91 FG_LOG(FG_GENERAL, FG_INFO, "Starting BFI init");
93 current_properties.tieInt("/sim/flight-model",
94 getFlightModel, setFlightModel);
95 // current_properties.tieString("/sim/aircraft",
96 // getAircraft, setAircraft);
98 current_properties.tieBool("/sim/hud/visibility",
99 getHUDVisible, setHUDVisible);
100 current_properties.tieBool("/sim/panel/visibility",
101 getPanelVisible, setPanelVisible);
104 current_properties.tieDouble("/position/latitude",
105 getLatitude, setLatitude);
106 current_properties.tieDouble("/position/longitude",
107 getLongitude, setLongitude);
108 current_properties.tieDouble("/position/altitude",
109 getAltitude, setAltitude);
110 current_properties.tieDouble("/position/altitude-agl",
114 current_properties.tieDouble("/orientation/heading",
115 getHeading, setHeading);
116 current_properties.tieDouble("/orientation/heading-magnetic",
118 current_properties.tieDouble("/orientation/pitch",
120 current_properties.tieDouble("/orientation/roll",
124 current_properties.tieDouble("/velocities/airspeed",
126 current_properties.tieDouble("/velocities/side-slip",
128 current_properties.tieDouble("/velocities/vertical-speed",
129 getVerticalSpeed, 0);
130 current_properties.tieDouble("/velocities/speed-north",
131 getSpeedNorth, setSpeedNorth);
132 current_properties.tieDouble("/velocities/speed-east",
133 getSpeedEast, setSpeedEast);
134 current_properties.tieDouble("/velocities/speed-down",
135 getSpeedDown, setSpeedDown);
138 current_properties.tieDouble("/controls/throttle",
139 getThrottle, setThrottle);
140 current_properties.tieDouble("/controls/flaps",
142 current_properties.tieDouble("/controls/aileron",
143 getAileron, setAileron);
144 current_properties.tieDouble("/controls/rudder",
145 getRudder, setRudder);
146 current_properties.tieDouble("/controls/elevator",
147 getElevator, setElevator);
148 current_properties.tieDouble("/controls/elevator-trim",
149 getElevatorTrim, setElevatorTrim);
150 current_properties.tieDouble("/controls/brake",
154 current_properties.tieBool("/autopilot/locks/altitude",
155 getAPAltitudeLock, setAPAltitudeLock);
156 current_properties.tieDouble("/autopilot/settings/altitude",
157 getAPAltitude, setAPAltitude);
158 current_properties.tieBool("/autopilot/locks/heading",
159 getAPHeadingLock, setAPHeadingLock);
160 current_properties.tieDouble("/autopilot/settings/heading-magnetic",
161 getAPHeadingMag, setAPHeadingMag);
162 current_properties.tieBool("/autopilot/locks/nav1",
163 getAPNAV1Lock, setAPNAV1Lock);
166 current_properties.tieDouble("/radios/nav1/frequencies/selected",
167 getNAV1Freq, setNAV1Freq);
168 current_properties.tieDouble("/radios/nav1/frequencies/standby",
169 getNAV1AltFreq, setNAV1AltFreq);
170 current_properties.tieDouble("/radios/nav1/radials/actual",
172 current_properties.tieDouble("/radios/nav1/radials/selected",
173 getNAV1SelRadial, setNAV1SelRadial);
174 current_properties.tieDouble("/radios/nav1/dme/distance",
176 current_properties.tieBool("/radios/nav1/in-range",
178 current_properties.tieBool("/radios/nav1/dme/in-range",
179 getNAV1DMEInRange, 0);
181 current_properties.tieDouble("/radios/nav2/frequencies/selected",
182 getNAV2Freq, setNAV2Freq);
183 current_properties.tieDouble("/radios/nav2/frequencies/standby",
184 getNAV2AltFreq, setNAV2AltFreq);
185 current_properties.tieDouble("/radios/nav2/radials/actual",
187 current_properties.tieDouble("/radios/nav2/radials/selected",
188 getNAV2SelRadial, setNAV2SelRadial);
189 current_properties.tieDouble("/radios/nav2/dme/distance",
191 current_properties.tieBool("/radios/nav2/in-range",
193 current_properties.tieBool("/radios/nav2/dme/in-range",
194 getNAV2DMEInRange, 0);
196 current_properties.tieDouble("/radios/adf/frequencies/selected",
197 getADFFreq, setADFFreq);
198 current_properties.tieDouble("/radios/adf/frequencies/standby",
199 getADFAltFreq, setADFAltFreq);
200 current_properties.tieDouble("/radios/adf/rotation",
201 getADFRotation, setADFRotation);
203 FG_LOG(FG_GENERAL, FG_INFO, "Ending BFI init");
208 * Reinitialize FGFS if required.
210 * Some changes (especially those in aircraft position) require that
211 * FGFS be reinitialized afterwards. Rather than reinitialize after
212 * every change, the setter methods simply set a flag so that there
213 * can be a single reinit at the end of the frame.
225 * Reinitialize FGFS to use the new BFI settings.
230 // Save the state of everything
231 // that's going to get clobbered
232 // when we reinit the subsystems.
234 cout << "BFI: start reinit\n";
236 setHeading(getHeading());
237 setPitch(getPitch());
239 setSpeedNorth(getSpeedNorth());
240 setSpeedEast(getSpeedEast());
241 setSpeedDown(getSpeedDown());
242 setLatitude(getLatitude());
243 setLongitude(getLongitude());
244 setAltitude(getAltitude());
246 // TODO: add more AP stuff
247 double elevator = getElevator();
248 double aileron = getAileron();
249 double rudder = getRudder();
250 double throttle = getThrottle();
251 double elevator_trim = getElevatorTrim();
252 double flaps = getFlaps();
253 double brake = getBrake();
254 bool apHeadingLock = getAPHeadingLock();
255 double apHeadingMag = getAPHeadingMag();
256 bool apAltitudeLock = getAPAltitudeLock();
257 double apAltitude = getAPAltitude();
258 const string &targetAirport = getTargetAirport();
259 bool gpsLock = getGPSLock();
260 double gpsLatitude = getGPSTargetLatitude();
261 double gpsLongitude = getGPSTargetLongitude();
263 setTargetAirport("");
264 cout << "Target airport is " << current_options.get_airport_id() << endl;
266 fgReInitSubsystems();
268 // FIXME: this is wrong.
269 // All of these are scheduled events,
270 // and it should be possible to force
271 // them all to run once.
274 cur_light_params.Update();
276 fgUpdateWeatherDatabase();
279 // Restore all of the old states.
280 setElevator(elevator);
283 setThrottle(throttle);
284 setElevatorTrim(elevator_trim);
287 setAPHeadingLock(apHeadingLock);
288 setAPHeadingMag(apHeadingMag);
289 setAPAltitudeLock(apAltitudeLock);
290 setAPAltitude(apAltitude);
291 setTargetAirport(targetAirport);
293 setGPSTargetLatitude(gpsLatitude);
294 setGPSTargetLongitude(gpsLongitude);
298 cout << "BFI: end reinit\n";
303 ////////////////////////////////////////////////////////////////////////
305 ////////////////////////////////////////////////////////////////////////
309 * Return the flight model as an integer.
311 * TODO: use a string instead.
314 FGBFI::getFlightModel ()
316 return current_options.get_flight_model();
321 * Return the current aircraft as a string.
324 FGBFI::getAircraft ()
326 return current_options.get_aircraft();
331 * Return the current aircraft directory (UIUC) as a string.
334 FGBFI::getAircraftDir ()
341 * Set the flight model as an integer.
343 * TODO: use a string instead.
346 FGBFI::setFlightModel (int model)
348 current_options.set_flight_model(model);
354 * Set the current aircraft.
357 FGBFI::setAircraft (const string &aircraft)
359 current_options.set_aircraft(aircraft);
365 * Set the current aircraft directory (UIUC).
368 FGBFI::setAircraftDir (const string &dir)
376 * Return the current Zulu time.
381 return globals->get_time_params()->get_cur_time();
386 * Set the current Zulu time.
389 FGBFI::setTimeGMT (time_t time)
391 // FIXME: need to update lighting
393 current_options.set_time_offset(time);
394 current_options.set_time_offset_type(fgOPTIONS::FG_TIME_GMT_ABSOLUTE);
395 globals->get_time_params()->init( cur_fdm_state->get_Longitude(),
396 cur_fdm_state->get_Latitude(),
397 current_options.get_fg_root() );
398 globals->get_time_params()->update( cur_fdm_state->get_Longitude(),
399 cur_fdm_state->get_Latitude(),
400 globals->get_warp() );
406 * Return true if the HUD is visible.
409 FGBFI::getHUDVisible ()
411 return current_options.get_hud_status();
416 * Ensure that the HUD is visible or hidden.
419 FGBFI::setHUDVisible (bool visible)
421 current_options.set_hud_status(visible);
426 * Return true if the 2D panel is visible.
429 FGBFI::getPanelVisible ()
431 return current_options.get_panel_status();
436 * Ensure that the 2D panel is visible or hidden.
439 FGBFI::setPanelVisible (bool visible)
441 if (current_options.get_panel_status() != visible) {
442 current_options.toggle_panel();
448 ////////////////////////////////////////////////////////////////////////
450 ////////////////////////////////////////////////////////////////////////
454 * Return the current latitude in degrees (negative for south).
457 FGBFI::getLatitude ()
459 return current_aircraft.fdm_state->get_Latitude() * RAD_TO_DEG;
464 * Set the current latitude in degrees (negative for south).
467 FGBFI::setLatitude (double latitude)
469 current_options.set_lat(latitude);
470 current_aircraft.fdm_state->set_Latitude(latitude * DEG_TO_RAD);
476 * Return the current longitude in degrees (negative for west).
479 FGBFI::getLongitude ()
481 return current_aircraft.fdm_state->get_Longitude() * RAD_TO_DEG;
486 * Set the current longitude in degrees (negative for west).
489 FGBFI::setLongitude (double longitude)
491 current_options.set_lon(longitude);
492 current_aircraft.fdm_state->set_Longitude(longitude * DEG_TO_RAD);
498 * Return the current altitude in feet.
501 FGBFI::getAltitude ()
503 return current_aircraft.fdm_state->get_Altitude();
509 * Return the current altitude in above the terrain.
514 return current_aircraft.fdm_state->get_Altitude()
515 - scenery.cur_elev * METER_TO_FEET;
520 * Set the current altitude in feet.
523 FGBFI::setAltitude (double altitude)
525 fgFDMForceAltitude(getFlightModel(), altitude * FEET_TO_METER);
526 // current_options.set_altitude(altitude * FEET_TO_METER);
527 // current_aircraft.fdm_state->set_Altitude(altitude);
533 ////////////////////////////////////////////////////////////////////////
535 ////////////////////////////////////////////////////////////////////////
539 * Return the current heading in degrees.
544 return current_aircraft.fdm_state->get_Psi() * RAD_TO_DEG;
549 * Return the current heading in degrees.
552 FGBFI::getHeadingMag ()
554 return current_aircraft.fdm_state->get_Psi() * RAD_TO_DEG - getMagVar();
559 * Set the current heading in degrees.
562 FGBFI::setHeading (double heading)
564 current_options.set_heading(heading);
565 current_aircraft.fdm_state->set_Euler_Angles(getRoll() * DEG_TO_RAD,
566 getPitch() * DEG_TO_RAD,
567 heading * DEG_TO_RAD);
573 * Return the current pitch in degrees.
578 return current_aircraft.fdm_state->get_Theta() * RAD_TO_DEG;
583 * Set the current pitch in degrees.
586 FGBFI::setPitch (double pitch)
589 current_options.set_pitch(pitch);
590 current_aircraft.fdm_state->set_Euler_Angles(getRoll() * DEG_TO_RAD,
592 getHeading() * DEG_TO_RAD);
598 * Return the current roll in degrees.
603 return current_aircraft.fdm_state->get_Phi() * RAD_TO_DEG;
608 * Set the current roll in degrees.
611 FGBFI::setRoll (double roll)
613 current_options.set_roll(roll);
614 current_aircraft.fdm_state->set_Euler_Angles(roll * DEG_TO_RAD,
615 getPitch() * DEG_TO_RAD,
616 getHeading() * DEG_TO_RAD);
622 ////////////////////////////////////////////////////////////////////////
624 ////////////////////////////////////////////////////////////////////////
628 * Return the current airspeed in knots.
631 FGBFI::getAirspeed ()
633 // FIXME: should we add speed-up?
634 return current_aircraft.fdm_state->get_V_calibrated_kts();
639 * Return the current sideslip (FIXME: units unknown).
642 FGBFI::getSideSlip ()
644 return current_aircraft.fdm_state->get_Beta();
649 * Return the current climb rate in feet/minute
652 FGBFI::getVerticalSpeed ()
654 // What about meters?
655 return current_aircraft.fdm_state->get_Climb_Rate() * 60.0;
660 * Get the current north velocity (units??).
663 FGBFI::getSpeedNorth ()
665 return current_aircraft.fdm_state->get_V_north();
670 * Set the current north velocity (units??).
673 FGBFI::setSpeedNorth (double speed)
675 current_options.set_uBody(speed);
676 current_aircraft.fdm_state->set_Velocities_Local(speed,
684 * Get the current east velocity (units??).
687 FGBFI::getSpeedEast ()
689 return current_aircraft.fdm_state->get_V_east();
694 * Set the current east velocity (units??).
697 FGBFI::setSpeedEast (double speed)
699 current_options.set_vBody(speed);
700 current_aircraft.fdm_state->set_Velocities_Local(getSpeedNorth(),
708 * Get the current down velocity (units??).
711 FGBFI::getSpeedDown ()
713 return current_aircraft.fdm_state->get_V_down();
718 * Set the current down velocity (units??).
721 FGBFI::setSpeedDown (double speed)
723 current_options.set_wBody(speed);
724 current_aircraft.fdm_state->set_Velocities_Local(getSpeedNorth(),
732 ////////////////////////////////////////////////////////////////////////
734 ////////////////////////////////////////////////////////////////////////
738 * Get the throttle setting, from 0.0 (none) to 1.0 (full).
741 FGBFI::getThrottle ()
743 // FIXME: add throttle selector
744 return controls.get_throttle(0);
749 * Set the throttle, from 0.0 (none) to 1.0 (full).
752 FGBFI::setThrottle (double throttle)
754 // FIXME: allow throttle selection
756 controls.set_throttle(0, throttle);
761 * Get the flaps setting, from 0.0 (none) to 1.0 (full).
766 return controls.get_flaps();
771 * Set the flaps, from 0.0 (none) to 1.0 (full).
774 FGBFI::setFlaps (double flaps)
777 controls.set_flaps(flaps);
782 * Get the aileron, from -1.0 (left) to 1.0 (right).
787 return controls.get_aileron();
792 * Set the aileron, from -1.0 (left) to 1.0 (right).
795 FGBFI::setAileron (double aileron)
798 controls.set_aileron(aileron);
803 * Get the rudder setting, from -1.0 (left) to 1.0 (right).
808 return controls.get_rudder();
813 * Set the rudder, from -1.0 (left) to 1.0 (right).
816 FGBFI::setRudder (double rudder)
819 controls.set_rudder(rudder);
824 * Get the elevator setting, from -1.0 (down) to 1.0 (up).
827 FGBFI::getElevator ()
829 return controls.get_elevator();
834 * Set the elevator, from -1.0 (down) to 1.0 (up).
837 FGBFI::setElevator (double elevator)
840 controls.set_elevator(elevator);
845 * Get the elevator trim, from -1.0 (down) to 1.0 (up).
848 FGBFI::getElevatorTrim ()
850 return controls.get_elevator_trim();
855 * Set the elevator trim, from -1.0 (down) to 1.0 (up).
858 FGBFI::setElevatorTrim (double trim)
861 controls.set_elevator_trim(trim);
866 * Get the brake setting, from 0.0 (none) to 1.0 (full).
871 // FIXME: add brake selector
872 return controls.get_brake(0);
877 * Set the brake, from 0.0 (none) to 1.0 (full).
880 FGBFI::setBrake (double brake)
883 // FIXME: allow brake selection
884 controls.set_brake(0, brake);
889 ////////////////////////////////////////////////////////////////////////
891 ////////////////////////////////////////////////////////////////////////
895 * Get the autopilot altitude lock (true=on).
898 FGBFI::getAPAltitudeLock ()
900 return current_autopilot->get_AltitudeEnabled();
905 * Set the autopilot altitude lock (true=on).
908 FGBFI::setAPAltitudeLock (bool lock)
910 current_autopilot->set_AltitudeMode(FGAutopilot::FG_ALTITUDE_LOCK);
911 current_autopilot->set_AltitudeEnabled(lock);
916 * Get the autopilot target altitude in feet.
919 FGBFI::getAPAltitude ()
921 return current_autopilot->get_TargetAltitude() * METER_TO_FEET;
926 * Set the autopilot target altitude in feet.
929 FGBFI::setAPAltitude (double altitude)
931 current_autopilot->set_TargetAltitude( altitude );
936 * Get the autopilot heading lock (true=on).
939 FGBFI::getAPHeadingLock ()
942 (current_autopilot->get_HeadingEnabled() &&
943 current_autopilot->get_HeadingMode() == FGAutopilot::FG_HEADING_LOCK);
948 * Set the autopilot heading lock (true=on).
951 FGBFI::setAPHeadingLock (bool lock)
954 // We need to do this so that
955 // it's possible to lock onto a
956 // heading other than the current
958 double heading = getAPHeadingMag();
959 current_autopilot->set_HeadingMode(FGAutopilot::FG_HEADING_LOCK);
960 current_autopilot->set_HeadingEnabled(true);
961 setAPHeadingMag(heading);
962 } else if (current_autopilot->get_HeadingMode() ==
963 FGAutopilot::FG_HEADING_LOCK) {
964 current_autopilot->set_HeadingEnabled(false);
970 * Get the autopilot target heading in degrees.
973 FGBFI::getAPHeadingMag ()
975 return current_autopilot->get_TargetHeading() - getMagVar();
980 * Set the autopilot target heading in degrees.
983 FGBFI::setAPHeadingMag (double heading)
985 current_autopilot->set_TargetHeading( heading + getMagVar() );
990 * Return true if the autopilot is locked to NAV1.
993 FGBFI::getAPNAV1Lock ()
996 (current_autopilot->get_HeadingEnabled() &&
997 current_autopilot->get_HeadingMode() == FGAutopilot::FG_HEADING_NAV1);
1002 * Set the autopilot NAV1 lock.
1005 FGBFI::setAPNAV1Lock (bool lock)
1008 current_autopilot->set_HeadingMode(FGAutopilot::FG_HEADING_NAV1);
1009 current_autopilot->set_HeadingEnabled(true);
1010 } else if (current_autopilot->get_HeadingMode() ==
1011 FGAutopilot::FG_HEADING_NAV1) {
1012 current_autopilot->set_HeadingEnabled(false);
1018 ////////////////////////////////////////////////////////////////////////
1019 // Radio navigation.
1020 ////////////////////////////////////////////////////////////////////////
1023 FGBFI::getNAV1Freq ()
1025 return current_radiostack->get_nav1_freq();
1029 FGBFI::getNAV1AltFreq ()
1031 return current_radiostack->get_nav1_alt_freq();
1035 FGBFI::getNAV1Radial ()
1037 return current_radiostack->get_nav1_radial();
1041 FGBFI::getNAV1SelRadial ()
1043 return current_radiostack->get_nav1_sel_radial();
1047 FGBFI::getNAV1DistDME ()
1049 return current_radiostack->get_nav1_dme_dist();
1053 FGBFI::getNAV1InRange ()
1055 return current_radiostack->get_nav1_inrange();
1059 FGBFI::getNAV1DMEInRange ()
1061 return (current_radiostack->get_nav1_inrange() &&
1062 current_radiostack->get_nav1_has_dme());
1066 FGBFI::getNAV2Freq ()
1068 return current_radiostack->get_nav2_freq();
1072 FGBFI::getNAV2AltFreq ()
1074 return current_radiostack->get_nav2_alt_freq();
1078 FGBFI::getNAV2Radial ()
1080 return current_radiostack->get_nav2_radial();
1084 FGBFI::getNAV2SelRadial ()
1086 return current_radiostack->get_nav2_sel_radial();
1090 FGBFI::getNAV2DistDME ()
1092 return current_radiostack->get_nav2_dme_dist();
1096 FGBFI::getNAV2InRange ()
1098 return current_radiostack->get_nav2_inrange();
1102 FGBFI::getNAV2DMEInRange ()
1104 return (current_radiostack->get_nav2_inrange() &&
1105 current_radiostack->get_nav2_has_dme());
1109 FGBFI::getADFFreq ()
1111 return current_radiostack->get_adf_freq();
1115 FGBFI::getADFAltFreq ()
1117 return current_radiostack->get_adf_alt_freq();
1121 FGBFI::getADFRotation ()
1123 return current_radiostack->get_adf_rotation();
1127 FGBFI::setNAV1Freq (double freq)
1129 current_radiostack->set_nav1_freq(freq);
1133 FGBFI::setNAV1AltFreq (double freq)
1135 current_radiostack->set_nav1_alt_freq(freq);
1139 FGBFI::setNAV1SelRadial (double radial)
1141 current_radiostack->set_nav1_sel_radial(radial);
1145 FGBFI::setNAV2Freq (double freq)
1147 current_radiostack->set_nav2_freq(freq);
1151 FGBFI::setNAV2AltFreq (double freq)
1153 current_radiostack->set_nav2_alt_freq(freq);
1157 FGBFI::setNAV2SelRadial (double radial)
1159 current_radiostack->set_nav2_sel_radial(radial);
1163 FGBFI::setADFFreq (double freq)
1165 current_radiostack->set_adf_freq(freq);
1169 FGBFI::setADFAltFreq (double freq)
1171 current_radiostack->set_adf_alt_freq(freq);
1175 FGBFI::setADFRotation (double rot)
1177 current_radiostack->set_adf_rotation(rot);
1182 ////////////////////////////////////////////////////////////////////////
1184 ////////////////////////////////////////////////////////////////////////
1188 * Get the autopilot GPS lock (true=on).
1191 FGBFI::getGPSLock ()
1193 return (current_autopilot->get_HeadingEnabled() &&
1194 (current_autopilot->get_HeadingMode() ==
1195 FGAutopilot::FG_HEADING_WAYPOINT ));
1200 * Set the autopilot GPS lock (true=on).
1203 FGBFI::setGPSLock (bool lock)
1206 current_autopilot->set_HeadingMode(FGAutopilot::FG_HEADING_WAYPOINT);
1207 current_autopilot->set_HeadingEnabled(true);
1208 } else if (current_autopilot->get_HeadingMode() ==
1209 FGAutopilot::FG_HEADING_WAYPOINT) {
1210 current_autopilot->set_HeadingEnabled(false);
1216 * Get the GPS target airport code.
1219 FGBFI::getTargetAirport ()
1221 return current_options.get_airport_id();
1226 * Set the GPS target airport code.
1229 FGBFI::setTargetAirport (const string &airportId)
1231 current_options.set_airport_id(airportId);
1236 * Get the GPS target latitude in degrees (negative for south).
1239 FGBFI::getGPSTargetLatitude ()
1241 return current_autopilot->get_TargetLatitude();
1246 * Set the GPS target latitude in degrees (negative for south).
1249 FGBFI::setGPSTargetLatitude (double latitude)
1251 current_autopilot->set_TargetLatitude( latitude );
1256 * Get the GPS target longitude in degrees (negative for west).
1259 FGBFI::getGPSTargetLongitude ()
1261 return current_autopilot->get_TargetLongitude();
1266 * Set the GPS target longitude in degrees (negative for west).
1269 FGBFI::setGPSTargetLongitude (double longitude)
1271 current_autopilot->set_TargetLongitude( longitude );
1276 ////////////////////////////////////////////////////////////////////////
1278 ////////////////////////////////////////////////////////////////////////
1282 * Get the current visible (units??).
1285 FGBFI::getVisibility ()
1287 #ifndef FG_OLD_WEATHER
1288 return WeatherDatabase->getWeatherVisibility();
1290 return current_weather.get_visibility();
1296 * Check whether clouds are enabled.
1301 return current_options.get_clouds();
1306 * Check the height of the clouds ASL (units?).
1309 FGBFI::getCloudsASL ()
1311 return current_options.get_clouds_asl();
1316 * Set the current visibility (units??).
1319 FGBFI::setVisibility (double visibility)
1321 #ifndef FG_OLD_WEATHER
1322 WeatherDatabase->setWeatherVisibility(visibility);
1324 current_weather.set_visibility(visibility);
1330 * Switch clouds on or off.
1333 FGBFI::setClouds (bool clouds)
1335 cout << "Set clouds to " << clouds << endl;
1336 current_options.set_clouds(clouds);
1342 * Set the cloud height.
1345 FGBFI::setCloudsASL (double cloudsASL)
1347 current_options.set_clouds_asl(cloudsASL);
1353 ////////////////////////////////////////////////////////////////////////
1355 ////////////////////////////////////////////////////////////////////////
1358 * Return the magnetic variation
1363 return cur_magvar.get_magvar() * RAD_TO_DEG;
1368 * Return the magnetic variation
1373 return cur_magvar.get_magdip() * RAD_TO_DEG;