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/fg_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 "options.hxx"
59 #include "fg_init.hxx"
61 FG_USING_NAMESPACE(std);
68 ////////////////////////////////////////////////////////////////////////
70 ////////////////////////////////////////////////////////////////////////
72 bool FGBFI::_needReinit = false;
76 ////////////////////////////////////////////////////////////////////////
78 ////////////////////////////////////////////////////////////////////////
82 * Initialize the BFI by binding its functions to properties.
84 * TODO: perhaps these should migrate into the individual modules
85 * (i.e. they should register themselves).
90 FG_LOG(FG_GENERAL, FG_INFO, "Starting BFI init");
92 current_properties.tieInt("/sim/flight-model",
93 getFlightModel, setFlightModel);
94 // current_properties.tieString("/sim/aircraft",
95 // getAircraft, setAircraft);
97 current_properties.tieBool("/sim/hud/visibility",
98 getHUDVisible, setHUDVisible);
99 current_properties.tieBool("/sim/panel/visibility",
100 getPanelVisible, setPanelVisible);
103 current_properties.tieDouble("/position/latitude",
104 getLatitude, setLatitude);
105 current_properties.tieDouble("/position/longitude",
106 getLongitude, setLongitude);
107 current_properties.tieDouble("/position/altitude",
108 getAltitude, setAltitude);
109 current_properties.tieDouble("/position/altitude-agl",
113 current_properties.tieDouble("/orientation/heading",
114 getHeading, setHeading);
115 current_properties.tieDouble("/orientation/heading-magnetic",
117 current_properties.tieDouble("/orientation/pitch",
119 current_properties.tieDouble("/orientation/roll",
123 current_properties.tieDouble("/velocities/airspeed",
125 current_properties.tieDouble("/velocities/side-slip",
127 current_properties.tieDouble("/velocities/vertical-speed",
128 getVerticalSpeed, 0);
129 current_properties.tieDouble("/velocities/speed-north",
130 getSpeedNorth, setSpeedNorth);
131 current_properties.tieDouble("/velocities/speed-east",
132 getSpeedEast, setSpeedEast);
133 current_properties.tieDouble("/velocities/speed-down",
134 getSpeedDown, setSpeedDown);
137 current_properties.tieDouble("/controls/throttle",
138 getThrottle, setThrottle);
139 current_properties.tieDouble("/controls/flaps",
141 current_properties.tieDouble("/controls/aileron",
142 getAileron, setAileron);
143 current_properties.tieDouble("/controls/rudder",
144 getRudder, setRudder);
145 current_properties.tieDouble("/controls/elevator",
146 getElevator, setElevator);
147 current_properties.tieDouble("/controls/elevator-trim",
148 getElevatorTrim, setElevatorTrim);
149 current_properties.tieDouble("/controls/brake",
153 current_properties.tieBool("/autopilot/locks/altitude",
154 getAPAltitudeLock, setAPAltitudeLock);
155 current_properties.tieDouble("/autopilot/settings/altitude",
156 getAPAltitude, setAPAltitude);
157 current_properties.tieBool("/autopilot/locks/heading",
158 getAPHeadingLock, setAPHeadingLock);
159 current_properties.tieDouble("/autopilot/settings/heading-magnetic",
160 getAPHeadingMag, setAPHeadingMag);
161 current_properties.tieBool("/autopilot/locks/nav1",
162 getAPNAV1Lock, setAPNAV1Lock);
165 current_properties.tieDouble("/radios/nav1/frequencies/selected",
166 getNAV1Freq, setNAV1Freq);
167 current_properties.tieDouble("/radios/nav1/frequencies/standby",
168 getNAV1AltFreq, setNAV1AltFreq);
169 current_properties.tieDouble("/radios/nav1/radials/actual",
171 current_properties.tieDouble("/radios/nav1/radials/selected",
172 getNAV1SelRadial, setNAV1SelRadial);
173 current_properties.tieDouble("/radios/nav1/dme/distance",
175 current_properties.tieBool("/radios/nav1/in-range",
177 current_properties.tieBool("/radios/nav1/dme/in-range",
178 getNAV1DMEInRange, 0);
180 current_properties.tieDouble("/radios/nav2/frequencies/selected",
181 getNAV2Freq, setNAV2Freq);
182 current_properties.tieDouble("/radios/nav2/frequencies/standby",
183 getNAV2AltFreq, setNAV2AltFreq);
184 current_properties.tieDouble("/radios/nav2/radials/actual",
186 current_properties.tieDouble("/radios/nav2/radials/selected",
187 getNAV2SelRadial, setNAV2SelRadial);
188 current_properties.tieDouble("/radios/nav2/dme/distance",
190 current_properties.tieBool("/radios/nav2/in-range",
192 current_properties.tieBool("/radios/nav2/dme/in-range",
193 getNAV2DMEInRange, 0);
195 current_properties.tieDouble("/radios/adf/frequencies/selected",
196 getADFFreq, setADFFreq);
197 current_properties.tieDouble("/radios/adf/frequencies/standby",
198 getADFAltFreq, setADFAltFreq);
199 current_properties.tieDouble("/radios/adf/rotation",
200 getADFRotation, setADFRotation);
202 FG_LOG(FG_GENERAL, FG_INFO, "Ending BFI init");
207 * Reinitialize FGFS if required.
209 * Some changes (especially those in aircraft position) require that
210 * FGFS be reinitialized afterwards. Rather than reinitialize after
211 * every change, the setter methods simply set a flag so that there
212 * can be a single reinit at the end of the frame.
224 * Reinitialize FGFS to use the new BFI settings.
229 // Save the state of everything
230 // that's going to get clobbered
231 // when we reinit the subsystems.
233 cout << "BFI: start reinit\n";
235 setHeading(getHeading());
236 setPitch(getPitch());
238 setSpeedNorth(getSpeedNorth());
239 setSpeedEast(getSpeedEast());
240 setSpeedDown(getSpeedDown());
241 setLatitude(getLatitude());
242 setLongitude(getLongitude());
243 setAltitude(getAltitude());
245 // TODO: add more AP stuff
246 double elevator = getElevator();
247 double aileron = getAileron();
248 double rudder = getRudder();
249 double throttle = getThrottle();
250 double elevator_trim = getElevatorTrim();
251 double flaps = getFlaps();
252 double brake = getBrake();
253 bool apHeadingLock = getAPHeadingLock();
254 double apHeadingMag = getAPHeadingMag();
255 bool apAltitudeLock = getAPAltitudeLock();
256 double apAltitude = getAPAltitude();
257 const string &targetAirport = getTargetAirport();
258 bool gpsLock = getGPSLock();
259 double gpsLatitude = getGPSTargetLatitude();
260 double gpsLongitude = getGPSTargetLongitude();
262 setTargetAirport("");
263 cout << "Target airport is " << current_options.get_airport_id() << endl;
265 fgReInitSubsystems();
267 // FIXME: this is wrong.
268 // All of these are scheduled events,
269 // and it should be possible to force
270 // them all to run once.
273 cur_light_params.Update();
275 fgUpdateWeatherDatabase();
278 // Restore all of the old states.
279 setElevator(elevator);
282 setThrottle(throttle);
283 setElevatorTrim(elevator_trim);
286 setAPHeadingLock(apHeadingLock);
287 setAPHeadingMag(apHeadingMag);
288 setAPAltitudeLock(apAltitudeLock);
289 setAPAltitude(apAltitude);
290 setTargetAirport(targetAirport);
292 setGPSTargetLatitude(gpsLatitude);
293 setGPSTargetLongitude(gpsLongitude);
297 cout << "BFI: end reinit\n";
302 ////////////////////////////////////////////////////////////////////////
304 ////////////////////////////////////////////////////////////////////////
308 * Return the flight model as an integer.
310 * TODO: use a string instead.
313 FGBFI::getFlightModel ()
315 return current_options.get_flight_model();
320 * Return the current aircraft as a string.
323 FGBFI::getAircraft ()
325 return current_options.get_aircraft();
330 * Return the current aircraft directory (UIUC) as a string.
333 FGBFI::getAircraftDir ()
340 * Set the flight model as an integer.
342 * TODO: use a string instead.
345 FGBFI::setFlightModel (int model)
347 current_options.set_flight_model(model);
353 * Set the current aircraft.
356 FGBFI::setAircraft (const string &aircraft)
358 current_options.set_aircraft(aircraft);
364 * Set the current aircraft directory (UIUC).
367 FGBFI::setAircraftDir (const string &dir)
375 * Return the current Zulu time.
380 return FGTime::cur_time_params->get_cur_time();
385 * Set the current Zulu time.
388 FGBFI::setTimeGMT (time_t time)
390 // FIXME: need to update lighting
392 current_options.set_time_offset(time);
393 current_options.set_time_offset_type(SG_TIME_GMT_ABSOLUTE);
394 FGTime::cur_time_params->init( cur_fdm_state->get_Longitude(),
395 cur_fdm_state->get_Latitude(),
396 current_options.get_fg_root(),
397 current_options.get_time_offset(),
398 current_options.get_time_offset_type() );
399 FGTime::cur_time_params->update( cur_fdm_state->get_Longitude(),
400 cur_fdm_state->get_Latitude(),
401 cur_fdm_state->get_Altitude()
408 * Return true if the HUD is visible.
411 FGBFI::getHUDVisible ()
413 return current_options.get_hud_status();
418 * Ensure that the HUD is visible or hidden.
421 FGBFI::setHUDVisible (bool visible)
423 current_options.set_hud_status(visible);
428 * Return true if the 2D panel is visible.
431 FGBFI::getPanelVisible ()
433 return current_options.get_panel_status();
438 * Ensure that the 2D panel is visible or hidden.
441 FGBFI::setPanelVisible (bool visible)
443 if (current_options.get_panel_status() != visible) {
444 current_options.toggle_panel();
450 ////////////////////////////////////////////////////////////////////////
452 ////////////////////////////////////////////////////////////////////////
456 * Return the current latitude in degrees (negative for south).
459 FGBFI::getLatitude ()
461 return current_aircraft.fdm_state->get_Latitude() * RAD_TO_DEG;
466 * Set the current latitude in degrees (negative for south).
469 FGBFI::setLatitude (double latitude)
471 current_options.set_lat(latitude);
472 current_aircraft.fdm_state->set_Latitude(latitude * DEG_TO_RAD);
478 * Return the current longitude in degrees (negative for west).
481 FGBFI::getLongitude ()
483 return current_aircraft.fdm_state->get_Longitude() * RAD_TO_DEG;
488 * Set the current longitude in degrees (negative for west).
491 FGBFI::setLongitude (double longitude)
493 current_options.set_lon(longitude);
494 current_aircraft.fdm_state->set_Longitude(longitude * DEG_TO_RAD);
500 * Return the current altitude in feet.
503 FGBFI::getAltitude ()
505 return current_aircraft.fdm_state->get_Altitude();
511 * Return the current altitude in above the terrain.
516 return current_aircraft.fdm_state->get_Altitude()
517 - scenery.cur_elev * METER_TO_FEET;
522 * Set the current altitude in feet.
525 FGBFI::setAltitude (double altitude)
527 fgFDMForceAltitude(getFlightModel(), altitude * FEET_TO_METER);
528 // current_options.set_altitude(altitude * FEET_TO_METER);
529 // current_aircraft.fdm_state->set_Altitude(altitude);
535 ////////////////////////////////////////////////////////////////////////
537 ////////////////////////////////////////////////////////////////////////
541 * Return the current heading in degrees.
546 return current_aircraft.fdm_state->get_Psi() * RAD_TO_DEG;
551 * Return the current heading in degrees.
554 FGBFI::getHeadingMag ()
556 return current_aircraft.fdm_state->get_Psi() * RAD_TO_DEG - getMagVar();
561 * Set the current heading in degrees.
564 FGBFI::setHeading (double heading)
566 current_options.set_heading(heading);
567 current_aircraft.fdm_state->set_Euler_Angles(getRoll() * DEG_TO_RAD,
568 getPitch() * DEG_TO_RAD,
569 heading * DEG_TO_RAD);
575 * Return the current pitch in degrees.
580 return current_aircraft.fdm_state->get_Theta() * RAD_TO_DEG;
585 * Set the current pitch in degrees.
588 FGBFI::setPitch (double pitch)
591 current_options.set_pitch(pitch);
592 current_aircraft.fdm_state->set_Euler_Angles(getRoll() * DEG_TO_RAD,
594 getHeading() * DEG_TO_RAD);
600 * Return the current roll in degrees.
605 return current_aircraft.fdm_state->get_Phi() * RAD_TO_DEG;
610 * Set the current roll in degrees.
613 FGBFI::setRoll (double roll)
615 current_options.set_roll(roll);
616 current_aircraft.fdm_state->set_Euler_Angles(roll * DEG_TO_RAD,
617 getPitch() * DEG_TO_RAD,
618 getHeading() * DEG_TO_RAD);
624 ////////////////////////////////////////////////////////////////////////
626 ////////////////////////////////////////////////////////////////////////
630 * Return the current airspeed in knots.
633 FGBFI::getAirspeed ()
635 // FIXME: should we add speed-up?
636 return current_aircraft.fdm_state->get_V_calibrated_kts();
641 * Return the current sideslip (FIXME: units unknown).
644 FGBFI::getSideSlip ()
646 return current_aircraft.fdm_state->get_Beta();
651 * Return the current climb rate in feet/minute
654 FGBFI::getVerticalSpeed ()
656 // What about meters?
657 return current_aircraft.fdm_state->get_Climb_Rate() * 60.0;
662 * Get the current north velocity (units??).
665 FGBFI::getSpeedNorth ()
667 return current_aircraft.fdm_state->get_V_north();
672 * Set the current north velocity (units??).
675 FGBFI::setSpeedNorth (double speed)
677 current_options.set_uBody(speed);
678 current_aircraft.fdm_state->set_Velocities_Local(speed,
686 * Get the current east velocity (units??).
689 FGBFI::getSpeedEast ()
691 return current_aircraft.fdm_state->get_V_east();
696 * Set the current east velocity (units??).
699 FGBFI::setSpeedEast (double speed)
701 current_options.set_vBody(speed);
702 current_aircraft.fdm_state->set_Velocities_Local(getSpeedNorth(),
710 * Get the current down velocity (units??).
713 FGBFI::getSpeedDown ()
715 return current_aircraft.fdm_state->get_V_down();
720 * Set the current down velocity (units??).
723 FGBFI::setSpeedDown (double speed)
725 current_options.set_wBody(speed);
726 current_aircraft.fdm_state->set_Velocities_Local(getSpeedNorth(),
734 ////////////////////////////////////////////////////////////////////////
736 ////////////////////////////////////////////////////////////////////////
740 * Get the throttle setting, from 0.0 (none) to 1.0 (full).
743 FGBFI::getThrottle ()
745 // FIXME: add throttle selector
746 return controls.get_throttle(0);
751 * Set the throttle, from 0.0 (none) to 1.0 (full).
754 FGBFI::setThrottle (double throttle)
756 // FIXME: allow throttle selection
758 controls.set_throttle(0, throttle);
763 * Get the flaps setting, from 0.0 (none) to 1.0 (full).
768 return controls.get_flaps();
773 * Set the flaps, from 0.0 (none) to 1.0 (full).
776 FGBFI::setFlaps (double flaps)
779 controls.set_flaps(flaps);
784 * Get the aileron, from -1.0 (left) to 1.0 (right).
789 return controls.get_aileron();
794 * Set the aileron, from -1.0 (left) to 1.0 (right).
797 FGBFI::setAileron (double aileron)
800 controls.set_aileron(aileron);
805 * Get the rudder setting, from -1.0 (left) to 1.0 (right).
810 return controls.get_rudder();
815 * Set the rudder, from -1.0 (left) to 1.0 (right).
818 FGBFI::setRudder (double rudder)
821 controls.set_rudder(rudder);
826 * Get the elevator setting, from -1.0 (down) to 1.0 (up).
829 FGBFI::getElevator ()
831 return controls.get_elevator();
836 * Set the elevator, from -1.0 (down) to 1.0 (up).
839 FGBFI::setElevator (double elevator)
842 controls.set_elevator(elevator);
847 * Get the elevator trim, from -1.0 (down) to 1.0 (up).
850 FGBFI::getElevatorTrim ()
852 return controls.get_elevator_trim();
857 * Set the elevator trim, from -1.0 (down) to 1.0 (up).
860 FGBFI::setElevatorTrim (double trim)
863 controls.set_elevator_trim(trim);
868 * Get the brake setting, from 0.0 (none) to 1.0 (full).
873 // FIXME: add brake selector
874 return controls.get_brake(0);
879 * Set the brake, from 0.0 (none) to 1.0 (full).
882 FGBFI::setBrake (double brake)
885 // FIXME: allow brake selection
886 controls.set_brake(0, brake);
891 ////////////////////////////////////////////////////////////////////////
893 ////////////////////////////////////////////////////////////////////////
897 * Get the autopilot altitude lock (true=on).
900 FGBFI::getAPAltitudeLock ()
902 return current_autopilot->get_AltitudeEnabled();
907 * Set the autopilot altitude lock (true=on).
910 FGBFI::setAPAltitudeLock (bool lock)
912 current_autopilot->set_AltitudeMode(FGAutopilot::FG_ALTITUDE_LOCK);
913 current_autopilot->set_AltitudeEnabled(lock);
918 * Get the autopilot target altitude in feet.
921 FGBFI::getAPAltitude ()
923 return current_autopilot->get_TargetAltitude() * METER_TO_FEET;
928 * Set the autopilot target altitude in feet.
931 FGBFI::setAPAltitude (double altitude)
933 current_autopilot->set_TargetAltitude( altitude );
938 * Get the autopilot heading lock (true=on).
941 FGBFI::getAPHeadingLock ()
944 (current_autopilot->get_HeadingEnabled() &&
945 current_autopilot->get_HeadingMode() == FGAutopilot::FG_HEADING_LOCK);
950 * Set the autopilot heading lock (true=on).
953 FGBFI::setAPHeadingLock (bool lock)
956 // We need to do this so that
957 // it's possible to lock onto a
958 // heading other than the current
960 double heading = getAPHeadingMag();
961 current_autopilot->set_HeadingMode(FGAutopilot::FG_HEADING_LOCK);
962 current_autopilot->set_HeadingEnabled(true);
963 setAPHeadingMag(heading);
964 } else if (current_autopilot->get_HeadingMode() ==
965 FGAutopilot::FG_HEADING_LOCK) {
966 current_autopilot->set_HeadingEnabled(false);
972 * Get the autopilot target heading in degrees.
975 FGBFI::getAPHeadingMag ()
977 return current_autopilot->get_TargetHeading() - getMagVar();
982 * Set the autopilot target heading in degrees.
985 FGBFI::setAPHeadingMag (double heading)
987 current_autopilot->set_TargetHeading( heading + getMagVar() );
992 * Return true if the autopilot is locked to NAV1.
995 FGBFI::getAPNAV1Lock ()
998 (current_autopilot->get_HeadingEnabled() &&
999 current_autopilot->get_HeadingMode() == FGAutopilot::FG_HEADING_NAV1);
1004 * Set the autopilot NAV1 lock.
1007 FGBFI::setAPNAV1Lock (bool lock)
1010 current_autopilot->set_HeadingMode(FGAutopilot::FG_HEADING_NAV1);
1011 current_autopilot->set_HeadingEnabled(true);
1012 } else if (current_autopilot->get_HeadingMode() ==
1013 FGAutopilot::FG_HEADING_NAV1) {
1014 current_autopilot->set_HeadingEnabled(false);
1020 ////////////////////////////////////////////////////////////////////////
1021 // Radio navigation.
1022 ////////////////////////////////////////////////////////////////////////
1025 FGBFI::getNAV1Freq ()
1027 return current_radiostack->get_nav1_freq();
1031 FGBFI::getNAV1AltFreq ()
1033 return current_radiostack->get_nav1_alt_freq();
1037 FGBFI::getNAV1Radial ()
1039 return current_radiostack->get_nav1_radial();
1043 FGBFI::getNAV1SelRadial ()
1045 return current_radiostack->get_nav1_sel_radial();
1049 FGBFI::getNAV1DistDME ()
1051 return current_radiostack->get_nav1_dme_dist();
1055 FGBFI::getNAV1InRange ()
1057 return current_radiostack->get_nav1_inrange();
1061 FGBFI::getNAV1DMEInRange ()
1063 return (current_radiostack->get_nav1_inrange() &&
1064 current_radiostack->get_nav1_has_dme());
1068 FGBFI::getNAV2Freq ()
1070 return current_radiostack->get_nav2_freq();
1074 FGBFI::getNAV2AltFreq ()
1076 return current_radiostack->get_nav2_alt_freq();
1080 FGBFI::getNAV2Radial ()
1082 return current_radiostack->get_nav2_radial();
1086 FGBFI::getNAV2SelRadial ()
1088 return current_radiostack->get_nav2_sel_radial();
1092 FGBFI::getNAV2DistDME ()
1094 return current_radiostack->get_nav2_dme_dist();
1098 FGBFI::getNAV2InRange ()
1100 return current_radiostack->get_nav2_inrange();
1104 FGBFI::getNAV2DMEInRange ()
1106 return (current_radiostack->get_nav2_inrange() &&
1107 current_radiostack->get_nav2_has_dme());
1111 FGBFI::getADFFreq ()
1113 return current_radiostack->get_adf_freq();
1117 FGBFI::getADFAltFreq ()
1119 return current_radiostack->get_adf_alt_freq();
1123 FGBFI::getADFRotation ()
1125 return current_radiostack->get_adf_rotation();
1129 FGBFI::setNAV1Freq (double freq)
1131 current_radiostack->set_nav1_freq(freq);
1135 FGBFI::setNAV1AltFreq (double freq)
1137 current_radiostack->set_nav1_alt_freq(freq);
1141 FGBFI::setNAV1SelRadial (double radial)
1143 current_radiostack->set_nav1_sel_radial(radial);
1147 FGBFI::setNAV2Freq (double freq)
1149 current_radiostack->set_nav2_freq(freq);
1153 FGBFI::setNAV2AltFreq (double freq)
1155 current_radiostack->set_nav2_alt_freq(freq);
1159 FGBFI::setNAV2SelRadial (double radial)
1161 current_radiostack->set_nav2_sel_radial(radial);
1165 FGBFI::setADFFreq (double freq)
1167 current_radiostack->set_adf_freq(freq);
1171 FGBFI::setADFAltFreq (double freq)
1173 current_radiostack->set_adf_alt_freq(freq);
1177 FGBFI::setADFRotation (double rot)
1179 current_radiostack->set_adf_rotation(rot);
1184 ////////////////////////////////////////////////////////////////////////
1186 ////////////////////////////////////////////////////////////////////////
1190 * Get the autopilot GPS lock (true=on).
1193 FGBFI::getGPSLock ()
1195 return (current_autopilot->get_HeadingEnabled() &&
1196 (current_autopilot->get_HeadingMode() ==
1197 FGAutopilot::FG_HEADING_WAYPOINT ));
1202 * Set the autopilot GPS lock (true=on).
1205 FGBFI::setGPSLock (bool lock)
1208 current_autopilot->set_HeadingMode(FGAutopilot::FG_HEADING_WAYPOINT);
1209 current_autopilot->set_HeadingEnabled(true);
1210 } else if (current_autopilot->get_HeadingMode() ==
1211 FGAutopilot::FG_HEADING_WAYPOINT) {
1212 current_autopilot->set_HeadingEnabled(false);
1218 * Get the GPS target airport code.
1221 FGBFI::getTargetAirport ()
1223 return current_options.get_airport_id();
1228 * Set the GPS target airport code.
1231 FGBFI::setTargetAirport (const string &airportId)
1233 current_options.set_airport_id(airportId);
1238 * Get the GPS target latitude in degrees (negative for south).
1241 FGBFI::getGPSTargetLatitude ()
1243 return current_autopilot->get_TargetLatitude();
1248 * Set the GPS target latitude in degrees (negative for south).
1251 FGBFI::setGPSTargetLatitude (double latitude)
1253 current_autopilot->set_TargetLatitude( latitude );
1258 * Get the GPS target longitude in degrees (negative for west).
1261 FGBFI::getGPSTargetLongitude ()
1263 return current_autopilot->get_TargetLongitude();
1268 * Set the GPS target longitude in degrees (negative for west).
1271 FGBFI::setGPSTargetLongitude (double longitude)
1273 current_autopilot->set_TargetLongitude( longitude );
1278 ////////////////////////////////////////////////////////////////////////
1280 ////////////////////////////////////////////////////////////////////////
1284 * Get the current visible (units??).
1287 FGBFI::getVisibility ()
1289 #ifndef FG_OLD_WEATHER
1290 return WeatherDatabase->getWeatherVisibility();
1292 return current_weather.get_visibility();
1298 * Check whether clouds are enabled.
1303 return current_options.get_clouds();
1308 * Check the height of the clouds ASL (units?).
1311 FGBFI::getCloudsASL ()
1313 return current_options.get_clouds_asl();
1318 * Set the current visibility (units??).
1321 FGBFI::setVisibility (double visibility)
1323 #ifndef FG_OLD_WEATHER
1324 WeatherDatabase->setWeatherVisibility(visibility);
1326 current_weather.set_visibility(visibility);
1332 * Switch clouds on or off.
1335 FGBFI::setClouds (bool clouds)
1337 cout << "Set clouds to " << clouds << endl;
1338 current_options.set_clouds(clouds);
1344 * Set the cloud height.
1347 FGBFI::setCloudsASL (double cloudsASL)
1349 current_options.set_clouds_asl(cloudsASL);
1355 ////////////////////////////////////////////////////////////////////////
1357 ////////////////////////////////////////////////////////////////////////
1360 * Return the magnetic variation
1365 return cur_magvar.get_magvar() * RAD_TO_DEG;
1370 * Return the magnetic variation
1375 return cur_magvar.get_magdip() * RAD_TO_DEG;