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/math/fg_types.hxx>
37 #include <simgear/misc/props.hxx>
39 #include <Aircraft/aircraft.hxx>
40 #include <FDM/UIUCModel/uiuc_aircraftdir.h>
41 #include <Controls/controls.hxx>
42 #include <Autopilot/newauto.hxx>
43 #include <Scenery/scenery.hxx>
44 #include <Time/fg_time.hxx>
45 #include <Time/light.hxx>
46 #include <Time/event.hxx>
47 #include <Time/sunpos.hxx>
48 #include <Cockpit/radiostack.hxx>
49 #include <Ephemeris/ephemeris.hxx>
50 #ifndef FG_OLD_WEATHER
51 # include <WeatherCM/FGLocalWeatherDatabase.h>
53 # include <Weather/weather.hxx>
56 #include "options.hxx"
58 #include "fg_init.hxx"
60 FG_USING_NAMESPACE(std);
67 ////////////////////////////////////////////////////////////////////////
69 ////////////////////////////////////////////////////////////////////////
71 bool FGBFI::_needReinit = false;
75 ////////////////////////////////////////////////////////////////////////
77 ////////////////////////////////////////////////////////////////////////
81 * Initialize the BFI by binding its functions to properties.
83 * TODO: perhaps these should migrate into the individual modules
84 * (i.e. they should register themselves).
89 FG_LOG(FG_GENERAL, FG_INFO, "Starting BFI init");
91 current_properties.tieInt("/sim/flight-model",
92 getFlightModel, setFlightModel);
93 // current_properties.tieString("/sim/aircraft",
94 // getAircraft, setAircraft);
96 current_properties.tieBool("/sim/hud/visibility",
97 getHUDVisible, setHUDVisible);
98 current_properties.tieBool("/sim/panel/visibility",
99 getPanelVisible, setPanelVisible);
102 current_properties.tieDouble("/position/latitude",
103 getLatitude, setLatitude);
104 current_properties.tieDouble("/position/longitude",
105 getLongitude, setLongitude);
106 current_properties.tieDouble("/position/altitude",
107 getAltitude, setAltitude);
108 current_properties.tieDouble("/position/altitude-agl",
112 current_properties.tieDouble("/orientation/heading",
113 getHeading, setHeading);
114 current_properties.tieDouble("/orientation/heading-magnetic",
116 current_properties.tieDouble("/orientation/pitch",
118 current_properties.tieDouble("/orientation/roll",
122 current_properties.tieDouble("/velocities/airspeed",
124 current_properties.tieDouble("/velocities/side-slip",
126 current_properties.tieDouble("/velocities/vertical-speed",
127 getVerticalSpeed, 0);
128 current_properties.tieDouble("/velocities/speed-north",
129 getSpeedNorth, setSpeedNorth);
130 current_properties.tieDouble("/velocities/speed-east",
131 getSpeedEast, setSpeedEast);
132 current_properties.tieDouble("/velocities/speed-down",
133 getSpeedDown, setSpeedDown);
136 current_properties.tieDouble("/controls/throttle",
137 getThrottle, setThrottle);
138 current_properties.tieDouble("/controls/flaps",
140 current_properties.tieDouble("/controls/aileron",
141 getAileron, setAileron);
142 current_properties.tieDouble("/controls/rudder",
143 getRudder, setRudder);
144 current_properties.tieDouble("/controls/elevator",
145 getElevator, setElevator);
146 current_properties.tieDouble("/controls/elevator-trim",
147 getElevatorTrim, setElevatorTrim);
148 current_properties.tieDouble("/controls/brake",
152 current_properties.tieBool("/autopilot/locks/altitude",
153 getAPAltitudeLock, setAPAltitudeLock);
154 current_properties.tieDouble("/autopilot/settings/altitude",
155 getAPAltitude, setAPAltitude);
156 current_properties.tieBool("/autopilot/locks/heading",
157 getAPHeadingLock, setAPHeadingLock);
158 current_properties.tieDouble("/autopilot/settings/heading-magnetic",
159 getAPHeadingMag, setAPHeadingMag);
160 current_properties.tieBool("/autopilot/locks/nav1",
161 getAPNAV1Lock, setAPNAV1Lock);
164 current_properties.tieDouble("/radios/nav1/frequencies/selected",
165 getNAV1Freq, setNAV1Freq);
166 current_properties.tieDouble("/radios/nav1/frequencies/standby",
167 getNAV1AltFreq, setNAV1AltFreq);
168 current_properties.tieDouble("/radios/nav1/radials/actual",
170 current_properties.tieDouble("/radios/nav1/radials/selected",
171 getNAV1SelRadial, setNAV1SelRadial);
172 current_properties.tieDouble("/radios/nav1/dme/distance",
174 current_properties.tieBool("/radios/nav1/in-range",
176 current_properties.tieBool("/radios/nav1/dme/in-range",
177 getNAV1DMEInRange, 0);
179 current_properties.tieDouble("/radios/nav2/frequencies/selected",
180 getNAV2Freq, setNAV2Freq);
181 current_properties.tieDouble("/radios/nav2/frequencies/standby",
182 getNAV2AltFreq, setNAV2AltFreq);
183 current_properties.tieDouble("/radios/nav2/radials/actual",
185 current_properties.tieDouble("/radios/nav2/radials/selected",
186 getNAV2SelRadial, setNAV2SelRadial);
187 current_properties.tieDouble("/radios/nav2/dme/distance",
189 current_properties.tieBool("/radios/nav2/in-range",
191 current_properties.tieBool("/radios/nav2/dme/in-range",
192 getNAV2DMEInRange, 0);
194 current_properties.tieDouble("/radios/adf/frequencies/selected",
195 getADFFreq, setADFFreq);
196 current_properties.tieDouble("/radios/adf/frequencies/standby",
197 getADFAltFreq, setADFAltFreq);
198 current_properties.tieDouble("/radios/adf/rotation",
199 getADFRotation, setADFRotation);
201 FG_LOG(FG_GENERAL, FG_INFO, "Ending BFI init");
206 * Reinitialize FGFS if required.
208 * Some changes (especially those in aircraft position) require that
209 * FGFS be reinitialized afterwards. Rather than reinitialize after
210 * every change, the setter methods simply set a flag so that there
211 * can be a single reinit at the end of the frame.
223 * Reinitialize FGFS to use the new BFI settings.
228 // Save the state of everything
229 // that's going to get clobbered
230 // when we reinit the subsystems.
232 cout << "BFI: start reinit\n";
234 setHeading(getHeading());
235 setPitch(getPitch());
237 setSpeedNorth(getSpeedNorth());
238 setSpeedEast(getSpeedEast());
239 setSpeedDown(getSpeedDown());
240 setLatitude(getLatitude());
241 setLongitude(getLongitude());
242 setAltitude(getAltitude());
244 // TODO: add more AP stuff
245 double elevator = getElevator();
246 double aileron = getAileron();
247 double rudder = getRudder();
248 double throttle = getThrottle();
249 double elevator_trim = getElevatorTrim();
250 double flaps = getFlaps();
251 double brake = getBrake();
252 bool apHeadingLock = getAPHeadingLock();
253 double apHeadingMag = getAPHeadingMag();
254 bool apAltitudeLock = getAPAltitudeLock();
255 double apAltitude = getAPAltitude();
256 const string &targetAirport = getTargetAirport();
257 bool gpsLock = getGPSLock();
258 double gpsLatitude = getGPSTargetLatitude();
259 double gpsLongitude = getGPSTargetLongitude();
261 setTargetAirport("");
262 cout << "Target airport is " << current_options.get_airport_id() << endl;
264 fgReInitSubsystems();
266 // FIXME: this is wrong.
267 // All of these are scheduled events,
268 // and it should be possible to force
269 // them all to run once.
272 cur_light_params.Update();
273 FGTime::cur_time_params->updateLocal();
274 fgUpdateWeatherDatabase();
277 // Restore all of the old states.
278 setElevator(elevator);
281 setThrottle(throttle);
282 setElevatorTrim(elevator_trim);
285 setAPHeadingLock(apHeadingLock);
286 setAPHeadingMag(apHeadingMag);
287 setAPAltitudeLock(apAltitudeLock);
288 setAPAltitude(apAltitude);
289 setTargetAirport(targetAirport);
291 setGPSTargetLatitude(gpsLatitude);
292 setGPSTargetLongitude(gpsLongitude);
296 cout << "BFI: end reinit\n";
301 ////////////////////////////////////////////////////////////////////////
303 ////////////////////////////////////////////////////////////////////////
307 * Return the flight model as an integer.
309 * TODO: use a string instead.
312 FGBFI::getFlightModel ()
314 return current_options.get_flight_model();
319 * Return the current aircraft as a string.
322 FGBFI::getAircraft ()
324 return current_options.get_aircraft();
329 * Return the current aircraft directory (UIUC) as a string.
332 FGBFI::getAircraftDir ()
339 * Set the flight model as an integer.
341 * TODO: use a string instead.
344 FGBFI::setFlightModel (int model)
346 current_options.set_flight_model(model);
352 * Set the current aircraft.
355 FGBFI::setAircraft (const string &aircraft)
357 current_options.set_aircraft(aircraft);
363 * Set the current aircraft directory (UIUC).
366 FGBFI::setAircraftDir (const string &dir)
374 * Return the current Zulu time.
379 return FGTime::cur_time_params->get_cur_time();
384 * Set the current Zulu time.
387 FGBFI::setTimeGMT (time_t time)
389 // FIXME: need to update lighting
391 current_options.set_time_offset(time);
392 current_options.set_time_offset_type(fgOPTIONS::FG_TIME_GMT_ABSOLUTE);
393 FGTime::cur_time_params->init( cur_fdm_state->get_Longitude(),
394 cur_fdm_state->get_Latitude() );
395 FGTime::cur_time_params->update( cur_fdm_state->get_Longitude(),
396 cur_fdm_state->get_Latitude(),
397 cur_fdm_state->get_Altitude()
404 * Return true if the HUD is visible.
407 FGBFI::getHUDVisible ()
409 return current_options.get_hud_status();
414 * Ensure that the HUD is visible or hidden.
417 FGBFI::setHUDVisible (bool visible)
419 current_options.set_hud_status(visible);
424 * Return true if the 2D panel is visible.
427 FGBFI::getPanelVisible ()
429 return current_options.get_panel_status();
434 * Ensure that the 2D panel is visible or hidden.
437 FGBFI::setPanelVisible (bool visible)
439 if (current_options.get_panel_status() != visible) {
440 current_options.toggle_panel();
446 ////////////////////////////////////////////////////////////////////////
448 ////////////////////////////////////////////////////////////////////////
452 * Return the current latitude in degrees (negative for south).
455 FGBFI::getLatitude ()
457 return current_aircraft.fdm_state->get_Latitude() * RAD_TO_DEG;
462 * Set the current latitude in degrees (negative for south).
465 FGBFI::setLatitude (double latitude)
467 current_options.set_lat(latitude);
468 current_aircraft.fdm_state->set_Latitude(latitude * DEG_TO_RAD);
474 * Return the current longitude in degrees (negative for west).
477 FGBFI::getLongitude ()
479 return current_aircraft.fdm_state->get_Longitude() * RAD_TO_DEG;
484 * Set the current longitude in degrees (negative for west).
487 FGBFI::setLongitude (double longitude)
489 current_options.set_lon(longitude);
490 current_aircraft.fdm_state->set_Longitude(longitude * DEG_TO_RAD);
496 * Return the current altitude in feet.
499 FGBFI::getAltitude ()
501 return current_aircraft.fdm_state->get_Altitude();
507 * Return the current altitude in above the terrain.
512 return current_aircraft.fdm_state->get_Altitude()
513 - scenery.cur_elev * METER_TO_FEET;
518 * Set the current altitude in feet.
521 FGBFI::setAltitude (double altitude)
523 fgFDMForceAltitude(getFlightModel(), altitude * FEET_TO_METER);
524 // current_options.set_altitude(altitude * FEET_TO_METER);
525 // current_aircraft.fdm_state->set_Altitude(altitude);
531 ////////////////////////////////////////////////////////////////////////
533 ////////////////////////////////////////////////////////////////////////
537 * Return the current heading in degrees.
542 return current_aircraft.fdm_state->get_Psi() * RAD_TO_DEG;
547 * Return the current heading in degrees.
550 FGBFI::getHeadingMag ()
552 return current_aircraft.fdm_state->get_Psi() * RAD_TO_DEG - getMagVar();
557 * Set the current heading in degrees.
560 FGBFI::setHeading (double heading)
562 current_options.set_heading(heading);
563 current_aircraft.fdm_state->set_Euler_Angles(getRoll() * DEG_TO_RAD,
564 getPitch() * DEG_TO_RAD,
565 heading * DEG_TO_RAD);
571 * Return the current pitch in degrees.
576 return current_aircraft.fdm_state->get_Theta() * RAD_TO_DEG;
581 * Set the current pitch in degrees.
584 FGBFI::setPitch (double pitch)
587 current_options.set_pitch(pitch);
588 current_aircraft.fdm_state->set_Euler_Angles(getRoll() * DEG_TO_RAD,
590 getHeading() * DEG_TO_RAD);
596 * Return the current roll in degrees.
601 return current_aircraft.fdm_state->get_Phi() * RAD_TO_DEG;
606 * Set the current roll in degrees.
609 FGBFI::setRoll (double roll)
611 current_options.set_roll(roll);
612 current_aircraft.fdm_state->set_Euler_Angles(roll * DEG_TO_RAD,
613 getPitch() * DEG_TO_RAD,
614 getHeading() * DEG_TO_RAD);
620 ////////////////////////////////////////////////////////////////////////
622 ////////////////////////////////////////////////////////////////////////
626 * Return the current airspeed in knots.
629 FGBFI::getAirspeed ()
631 // FIXME: should we add speed-up?
632 return current_aircraft.fdm_state->get_V_calibrated_kts();
637 * Return the current sideslip (FIXME: units unknown).
640 FGBFI::getSideSlip ()
642 return current_aircraft.fdm_state->get_Beta();
647 * Return the current climb rate in feet/minute
650 FGBFI::getVerticalSpeed ()
652 // What about meters?
653 return current_aircraft.fdm_state->get_Climb_Rate() * 60.0;
658 * Get the current north velocity (units??).
661 FGBFI::getSpeedNorth ()
663 return current_aircraft.fdm_state->get_V_north();
668 * Set the current north velocity (units??).
671 FGBFI::setSpeedNorth (double speed)
673 current_options.set_uBody(speed);
674 current_aircraft.fdm_state->set_Velocities_Local(speed,
682 * Get the current east velocity (units??).
685 FGBFI::getSpeedEast ()
687 return current_aircraft.fdm_state->get_V_east();
692 * Set the current east velocity (units??).
695 FGBFI::setSpeedEast (double speed)
697 current_options.set_vBody(speed);
698 current_aircraft.fdm_state->set_Velocities_Local(getSpeedNorth(),
706 * Get the current down velocity (units??).
709 FGBFI::getSpeedDown ()
711 return current_aircraft.fdm_state->get_V_down();
716 * Set the current down velocity (units??).
719 FGBFI::setSpeedDown (double speed)
721 current_options.set_wBody(speed);
722 current_aircraft.fdm_state->set_Velocities_Local(getSpeedNorth(),
730 ////////////////////////////////////////////////////////////////////////
732 ////////////////////////////////////////////////////////////////////////
736 * Get the throttle setting, from 0.0 (none) to 1.0 (full).
739 FGBFI::getThrottle ()
741 // FIXME: add throttle selector
742 return controls.get_throttle(0);
747 * Set the throttle, from 0.0 (none) to 1.0 (full).
750 FGBFI::setThrottle (double throttle)
752 // FIXME: allow throttle selection
754 controls.set_throttle(0, throttle);
759 * Get the flaps setting, from 0.0 (none) to 1.0 (full).
764 return controls.get_flaps();
769 * Set the flaps, from 0.0 (none) to 1.0 (full).
772 FGBFI::setFlaps (double flaps)
775 controls.set_flaps(flaps);
780 * Get the aileron, from -1.0 (left) to 1.0 (right).
785 return controls.get_aileron();
790 * Set the aileron, from -1.0 (left) to 1.0 (right).
793 FGBFI::setAileron (double aileron)
796 controls.set_aileron(aileron);
801 * Get the rudder setting, from -1.0 (left) to 1.0 (right).
806 return controls.get_rudder();
811 * Set the rudder, from -1.0 (left) to 1.0 (right).
814 FGBFI::setRudder (double rudder)
817 controls.set_rudder(rudder);
822 * Get the elevator setting, from -1.0 (down) to 1.0 (up).
825 FGBFI::getElevator ()
827 return controls.get_elevator();
832 * Set the elevator, from -1.0 (down) to 1.0 (up).
835 FGBFI::setElevator (double elevator)
838 controls.set_elevator(elevator);
843 * Get the elevator trim, from -1.0 (down) to 1.0 (up).
846 FGBFI::getElevatorTrim ()
848 return controls.get_elevator_trim();
853 * Set the elevator trim, from -1.0 (down) to 1.0 (up).
856 FGBFI::setElevatorTrim (double trim)
859 controls.set_elevator_trim(trim);
864 * Get the brake setting, from 0.0 (none) to 1.0 (full).
869 // FIXME: add brake selector
870 return controls.get_brake(0);
875 * Set the brake, from 0.0 (none) to 1.0 (full).
878 FGBFI::setBrake (double brake)
881 // FIXME: allow brake selection
882 controls.set_brake(0, brake);
887 ////////////////////////////////////////////////////////////////////////
889 ////////////////////////////////////////////////////////////////////////
893 * Get the autopilot altitude lock (true=on).
896 FGBFI::getAPAltitudeLock ()
898 return current_autopilot->get_AltitudeEnabled();
903 * Set the autopilot altitude lock (true=on).
906 FGBFI::setAPAltitudeLock (bool lock)
908 current_autopilot->set_AltitudeMode(FGAutopilot::FG_ALTITUDE_LOCK);
909 current_autopilot->set_AltitudeEnabled(lock);
914 * Get the autopilot target altitude in feet.
917 FGBFI::getAPAltitude ()
919 return current_autopilot->get_TargetAltitude() * METER_TO_FEET;
924 * Set the autopilot target altitude in feet.
927 FGBFI::setAPAltitude (double altitude)
929 current_autopilot->set_TargetAltitude( altitude );
934 * Get the autopilot heading lock (true=on).
937 FGBFI::getAPHeadingLock ()
940 (current_autopilot->get_HeadingEnabled() &&
941 current_autopilot->get_HeadingMode() == FGAutopilot::FG_HEADING_LOCK);
946 * Set the autopilot heading lock (true=on).
949 FGBFI::setAPHeadingLock (bool lock)
952 // We need to do this so that
953 // it's possible to lock onto a
954 // heading other than the current
956 double heading = getAPHeadingMag();
957 current_autopilot->set_HeadingMode(FGAutopilot::FG_HEADING_LOCK);
958 current_autopilot->set_HeadingEnabled(true);
959 setAPHeadingMag(heading);
960 } else if (current_autopilot->get_HeadingMode() ==
961 FGAutopilot::FG_HEADING_LOCK) {
962 current_autopilot->set_HeadingEnabled(false);
968 * Get the autopilot target heading in degrees.
971 FGBFI::getAPHeadingMag ()
973 return current_autopilot->get_TargetHeading() - getMagVar();
978 * Set the autopilot target heading in degrees.
981 FGBFI::setAPHeadingMag (double heading)
983 current_autopilot->set_TargetHeading( heading + getMagVar() );
988 * Return true if the autopilot is locked to NAV1.
991 FGBFI::getAPNAV1Lock ()
994 (current_autopilot->get_HeadingEnabled() &&
995 current_autopilot->get_HeadingMode() == FGAutopilot::FG_HEADING_NAV1);
1000 * Set the autopilot NAV1 lock.
1003 FGBFI::setAPNAV1Lock (bool lock)
1006 current_autopilot->set_HeadingMode(FGAutopilot::FG_HEADING_NAV1);
1007 current_autopilot->set_HeadingEnabled(true);
1008 } else if (current_autopilot->get_HeadingMode() ==
1009 FGAutopilot::FG_HEADING_NAV1) {
1010 current_autopilot->set_HeadingEnabled(false);
1016 ////////////////////////////////////////////////////////////////////////
1017 // Radio navigation.
1018 ////////////////////////////////////////////////////////////////////////
1021 FGBFI::getNAV1Freq ()
1023 return current_radiostack->get_nav1_freq();
1027 FGBFI::getNAV1AltFreq ()
1029 return current_radiostack->get_nav1_alt_freq();
1033 FGBFI::getNAV1Radial ()
1035 return current_radiostack->get_nav1_radial();
1039 FGBFI::getNAV1SelRadial ()
1041 return current_radiostack->get_nav1_sel_radial();
1045 FGBFI::getNAV1DistDME ()
1047 return current_radiostack->get_nav1_dme_dist();
1051 FGBFI::getNAV1InRange ()
1053 return current_radiostack->get_nav1_inrange();
1057 FGBFI::getNAV1DMEInRange ()
1059 return (current_radiostack->get_nav1_inrange() &&
1060 current_radiostack->get_nav1_has_dme());
1064 FGBFI::getNAV2Freq ()
1066 return current_radiostack->get_nav2_freq();
1070 FGBFI::getNAV2AltFreq ()
1072 return current_radiostack->get_nav2_alt_freq();
1076 FGBFI::getNAV2Radial ()
1078 return current_radiostack->get_nav2_radial();
1082 FGBFI::getNAV2SelRadial ()
1084 return current_radiostack->get_nav2_sel_radial();
1088 FGBFI::getNAV2DistDME ()
1090 return current_radiostack->get_nav2_dme_dist();
1094 FGBFI::getNAV2InRange ()
1096 return current_radiostack->get_nav2_inrange();
1100 FGBFI::getNAV2DMEInRange ()
1102 return (current_radiostack->get_nav2_inrange() &&
1103 current_radiostack->get_nav2_has_dme());
1107 FGBFI::getADFFreq ()
1109 return current_radiostack->get_adf_freq();
1113 FGBFI::getADFAltFreq ()
1115 return current_radiostack->get_adf_alt_freq();
1119 FGBFI::getADFRotation ()
1121 return current_radiostack->get_adf_rotation();
1125 FGBFI::setNAV1Freq (double freq)
1127 current_radiostack->set_nav1_freq(freq);
1131 FGBFI::setNAV1AltFreq (double freq)
1133 current_radiostack->set_nav1_alt_freq(freq);
1137 FGBFI::setNAV1SelRadial (double radial)
1139 current_radiostack->set_nav1_sel_radial(radial);
1143 FGBFI::setNAV2Freq (double freq)
1145 current_radiostack->set_nav2_freq(freq);
1149 FGBFI::setNAV2AltFreq (double freq)
1151 current_radiostack->set_nav2_alt_freq(freq);
1155 FGBFI::setNAV2SelRadial (double radial)
1157 current_radiostack->set_nav2_sel_radial(radial);
1161 FGBFI::setADFFreq (double freq)
1163 current_radiostack->set_adf_freq(freq);
1167 FGBFI::setADFAltFreq (double freq)
1169 current_radiostack->set_adf_alt_freq(freq);
1173 FGBFI::setADFRotation (double rot)
1175 current_radiostack->set_adf_rotation(rot);
1180 ////////////////////////////////////////////////////////////////////////
1182 ////////////////////////////////////////////////////////////////////////
1186 * Get the autopilot GPS lock (true=on).
1189 FGBFI::getGPSLock ()
1191 return (current_autopilot->get_HeadingEnabled() &&
1192 (current_autopilot->get_HeadingMode() ==
1193 FGAutopilot::FG_HEADING_WAYPOINT ));
1198 * Set the autopilot GPS lock (true=on).
1201 FGBFI::setGPSLock (bool lock)
1204 current_autopilot->set_HeadingMode(FGAutopilot::FG_HEADING_WAYPOINT);
1205 current_autopilot->set_HeadingEnabled(true);
1206 } else if (current_autopilot->get_HeadingMode() ==
1207 FGAutopilot::FG_HEADING_WAYPOINT) {
1208 current_autopilot->set_HeadingEnabled(false);
1214 * Get the GPS target airport code.
1217 FGBFI::getTargetAirport ()
1219 return current_options.get_airport_id();
1224 * Set the GPS target airport code.
1227 FGBFI::setTargetAirport (const string &airportId)
1229 current_options.set_airport_id(airportId);
1234 * Get the GPS target latitude in degrees (negative for south).
1237 FGBFI::getGPSTargetLatitude ()
1239 return current_autopilot->get_TargetLatitude();
1244 * Set the GPS target latitude in degrees (negative for south).
1247 FGBFI::setGPSTargetLatitude (double latitude)
1249 current_autopilot->set_TargetLatitude( latitude );
1254 * Get the GPS target longitude in degrees (negative for west).
1257 FGBFI::getGPSTargetLongitude ()
1259 return current_autopilot->get_TargetLongitude();
1264 * Set the GPS target longitude in degrees (negative for west).
1267 FGBFI::setGPSTargetLongitude (double longitude)
1269 current_autopilot->set_TargetLongitude( longitude );
1274 ////////////////////////////////////////////////////////////////////////
1276 ////////////////////////////////////////////////////////////////////////
1280 * Get the current visible (units??).
1283 FGBFI::getVisibility ()
1285 #ifndef FG_OLD_WEATHER
1286 return WeatherDatabase->getWeatherVisibility();
1288 return current_weather.get_visibility();
1294 * Check whether clouds are enabled.
1299 return current_options.get_clouds();
1304 * Check the height of the clouds ASL (units?).
1307 FGBFI::getCloudsASL ()
1309 return current_options.get_clouds_asl();
1314 * Set the current visibility (units??).
1317 FGBFI::setVisibility (double visibility)
1319 #ifndef FG_OLD_WEATHER
1320 WeatherDatabase->setWeatherVisibility(visibility);
1322 current_weather.set_visibility(visibility);
1328 * Switch clouds on or off.
1331 FGBFI::setClouds (bool clouds)
1333 cout << "Set clouds to " << clouds << endl;
1334 current_options.set_clouds(clouds);
1340 * Set the cloud height.
1343 FGBFI::setCloudsASL (double cloudsASL)
1345 current_options.set_clouds_asl(cloudsASL);
1351 ////////////////////////////////////////////////////////////////////////
1353 ////////////////////////////////////////////////////////////////////////
1356 * Return the magnetic variation
1361 return FGTime::cur_time_params->getMagVar() * RAD_TO_DEG;
1366 * Return the magnetic variation
1371 return FGTime::cur_time_params->getMagDip() * RAD_TO_DEG;