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",
152 current_properties.tieDouble("/controls/left-brake",
153 getLeftBrake, setLeftBrake);
154 current_properties.tieDouble("/controls/right-brake",
155 getRightBrake, setRightBrake);
158 current_properties.tieBool("/autopilot/locks/altitude",
159 getAPAltitudeLock, setAPAltitudeLock);
160 current_properties.tieDouble("/autopilot/settings/altitude",
161 getAPAltitude, setAPAltitude);
162 current_properties.tieBool("/autopilot/locks/heading",
163 getAPHeadingLock, setAPHeadingLock);
164 current_properties.tieDouble("/autopilot/settings/heading-magnetic",
165 getAPHeadingMag, setAPHeadingMag);
166 current_properties.tieBool("/autopilot/locks/nav1",
167 getAPNAV1Lock, setAPNAV1Lock);
170 current_properties.tieDouble("/radios/nav1/frequencies/selected",
171 getNAV1Freq, setNAV1Freq);
172 current_properties.tieDouble("/radios/nav1/frequencies/standby",
173 getNAV1AltFreq, setNAV1AltFreq);
174 current_properties.tieDouble("/radios/nav1/radials/actual",
176 current_properties.tieDouble("/radios/nav1/radials/selected",
177 getNAV1SelRadial, setNAV1SelRadial);
178 current_properties.tieDouble("/radios/nav1/dme/distance",
180 current_properties.tieBool("/radios/nav1/in-range",
182 current_properties.tieBool("/radios/nav1/dme/in-range",
183 getNAV1DMEInRange, 0);
185 current_properties.tieDouble("/radios/nav2/frequencies/selected",
186 getNAV2Freq, setNAV2Freq);
187 current_properties.tieDouble("/radios/nav2/frequencies/standby",
188 getNAV2AltFreq, setNAV2AltFreq);
189 current_properties.tieDouble("/radios/nav2/radials/actual",
191 current_properties.tieDouble("/radios/nav2/radials/selected",
192 getNAV2SelRadial, setNAV2SelRadial);
193 current_properties.tieDouble("/radios/nav2/dme/distance",
195 current_properties.tieBool("/radios/nav2/in-range",
197 current_properties.tieBool("/radios/nav2/dme/in-range",
198 getNAV2DMEInRange, 0);
200 current_properties.tieDouble("/radios/adf/frequencies/selected",
201 getADFFreq, setADFFreq);
202 current_properties.tieDouble("/radios/adf/frequencies/standby",
203 getADFAltFreq, setADFAltFreq);
204 current_properties.tieDouble("/radios/adf/rotation",
205 getADFRotation, setADFRotation);
207 FG_LOG(FG_GENERAL, FG_INFO, "Ending BFI init");
212 * Reinitialize FGFS if required.
214 * Some changes (especially those in aircraft position) require that
215 * FGFS be reinitialized afterwards. Rather than reinitialize after
216 * every change, the setter methods simply set a flag so that there
217 * can be a single reinit at the end of the frame.
229 * Reinitialize FGFS to use the new BFI settings.
234 // Save the state of everything
235 // that's going to get clobbered
236 // when we reinit the subsystems.
238 cout << "BFI: start reinit\n";
240 setHeading(getHeading());
241 setPitch(getPitch());
243 setSpeedNorth(getSpeedNorth());
244 setSpeedEast(getSpeedEast());
245 setSpeedDown(getSpeedDown());
246 setLatitude(getLatitude());
247 setLongitude(getLongitude());
248 setAltitude(getAltitude());
250 // TODO: add more AP stuff
251 double elevator = getElevator();
252 double aileron = getAileron();
253 double rudder = getRudder();
254 double throttle = getThrottle();
255 double elevator_trim = getElevatorTrim();
256 double flaps = getFlaps();
257 double brake = getBrake();
258 bool apHeadingLock = getAPHeadingLock();
259 double apHeadingMag = getAPHeadingMag();
260 bool apAltitudeLock = getAPAltitudeLock();
261 double apAltitude = getAPAltitude();
262 const string &targetAirport = getTargetAirport();
263 bool gpsLock = getGPSLock();
264 double gpsLatitude = getGPSTargetLatitude();
265 double gpsLongitude = getGPSTargetLongitude();
267 setTargetAirport("");
268 cout << "Target airport is " << current_options.get_airport_id() << endl;
270 fgReInitSubsystems();
272 // FIXME: this is wrong.
273 // All of these are scheduled events,
274 // and it should be possible to force
275 // them all to run once.
278 cur_light_params.Update();
280 fgUpdateWeatherDatabase();
283 // Restore all of the old states.
284 setElevator(elevator);
287 setThrottle(throttle);
288 setElevatorTrim(elevator_trim);
291 setAPHeadingLock(apHeadingLock);
292 setAPHeadingMag(apHeadingMag);
293 setAPAltitudeLock(apAltitudeLock);
294 setAPAltitude(apAltitude);
295 setTargetAirport(targetAirport);
297 setGPSTargetLatitude(gpsLatitude);
298 setGPSTargetLongitude(gpsLongitude);
302 cout << "BFI: end reinit\n";
307 ////////////////////////////////////////////////////////////////////////
309 ////////////////////////////////////////////////////////////////////////
313 * Return the flight model as an integer.
315 * TODO: use a string instead.
318 FGBFI::getFlightModel ()
320 return current_options.get_flight_model();
325 * Return the current aircraft as a string.
328 FGBFI::getAircraft ()
330 return current_options.get_aircraft();
335 * Return the current aircraft directory (UIUC) as a string.
338 FGBFI::getAircraftDir ()
345 * Set the flight model as an integer.
347 * TODO: use a string instead.
350 FGBFI::setFlightModel (int model)
352 current_options.set_flight_model(model);
358 * Set the current aircraft.
361 FGBFI::setAircraft (const string &aircraft)
363 current_options.set_aircraft(aircraft);
369 * Set the current aircraft directory (UIUC).
372 FGBFI::setAircraftDir (const string &dir)
380 * Return the current Zulu time.
385 return globals->get_time_params()->get_cur_time();
390 * Set the current Zulu time.
393 FGBFI::setTimeGMT (time_t time)
395 // FIXME: need to update lighting
397 current_options.set_time_offset(time);
398 current_options.set_time_offset_type(fgOPTIONS::FG_TIME_GMT_ABSOLUTE);
399 globals->get_time_params()->update( cur_fdm_state->get_Longitude(),
400 cur_fdm_state->get_Latitude(),
401 globals->get_warp() );
407 * Return true if the HUD is visible.
410 FGBFI::getHUDVisible ()
412 return current_options.get_hud_status();
417 * Ensure that the HUD is visible or hidden.
420 FGBFI::setHUDVisible (bool visible)
422 current_options.set_hud_status(visible);
427 * Return true if the 2D panel is visible.
430 FGBFI::getPanelVisible ()
432 return current_options.get_panel_status();
437 * Ensure that the 2D panel is visible or hidden.
440 FGBFI::setPanelVisible (bool visible)
442 if (current_options.get_panel_status() != visible) {
443 current_options.toggle_panel();
449 ////////////////////////////////////////////////////////////////////////
451 ////////////////////////////////////////////////////////////////////////
455 * Return the current latitude in degrees (negative for south).
458 FGBFI::getLatitude ()
460 return current_aircraft.fdm_state->get_Latitude() * RAD_TO_DEG;
465 * Set the current latitude in degrees (negative for south).
468 FGBFI::setLatitude (double latitude)
470 current_options.set_lat(latitude);
471 current_aircraft.fdm_state->set_Latitude(latitude * DEG_TO_RAD);
477 * Return the current longitude in degrees (negative for west).
480 FGBFI::getLongitude ()
482 return current_aircraft.fdm_state->get_Longitude() * RAD_TO_DEG;
487 * Set the current longitude in degrees (negative for west).
490 FGBFI::setLongitude (double longitude)
492 current_options.set_lon(longitude);
493 current_aircraft.fdm_state->set_Longitude(longitude * DEG_TO_RAD);
499 * Return the current altitude in feet.
502 FGBFI::getAltitude ()
504 return current_aircraft.fdm_state->get_Altitude();
510 * Return the current altitude in above the terrain.
515 return current_aircraft.fdm_state->get_Altitude()
516 - (scenery.cur_elev * METER_TO_FEET);
521 * Set the current altitude in feet.
524 FGBFI::setAltitude (double altitude)
526 fgFDMForceAltitude(getFlightModel(), altitude * FEET_TO_METER);
527 // current_options.set_altitude(altitude * FEET_TO_METER);
528 // current_aircraft.fdm_state->set_Altitude(altitude);
534 ////////////////////////////////////////////////////////////////////////
536 ////////////////////////////////////////////////////////////////////////
540 * Return the current heading in degrees.
545 return current_aircraft.fdm_state->get_Psi() * RAD_TO_DEG;
550 * Return the current heading in degrees.
553 FGBFI::getHeadingMag ()
555 return current_aircraft.fdm_state->get_Psi() * RAD_TO_DEG - getMagVar();
560 * Set the current heading in degrees.
563 FGBFI::setHeading (double heading)
565 current_options.set_heading(heading);
566 current_aircraft.fdm_state->set_Euler_Angles(getRoll() * DEG_TO_RAD,
567 getPitch() * DEG_TO_RAD,
568 heading * DEG_TO_RAD);
574 * Return the current pitch in degrees.
579 return current_aircraft.fdm_state->get_Theta() * RAD_TO_DEG;
584 * Set the current pitch in degrees.
587 FGBFI::setPitch (double pitch)
590 current_options.set_pitch(pitch);
591 current_aircraft.fdm_state->set_Euler_Angles(getRoll() * DEG_TO_RAD,
593 getHeading() * DEG_TO_RAD);
599 * Return the current roll in degrees.
604 return current_aircraft.fdm_state->get_Phi() * RAD_TO_DEG;
609 * Set the current roll in degrees.
612 FGBFI::setRoll (double roll)
614 current_options.set_roll(roll);
615 current_aircraft.fdm_state->set_Euler_Angles(roll * DEG_TO_RAD,
616 getPitch() * DEG_TO_RAD,
617 getHeading() * DEG_TO_RAD);
623 ////////////////////////////////////////////////////////////////////////
625 ////////////////////////////////////////////////////////////////////////
629 * Return the current airspeed in knots.
632 FGBFI::getAirspeed ()
634 // FIXME: should we add speed-up?
635 return current_aircraft.fdm_state->get_V_calibrated_kts();
640 * Return the current sideslip (FIXME: units unknown).
643 FGBFI::getSideSlip ()
645 return current_aircraft.fdm_state->get_Beta();
650 * Return the current climb rate in feet/minute
653 FGBFI::getVerticalSpeed ()
655 // What about meters?
656 return current_aircraft.fdm_state->get_Climb_Rate() * 60.0;
661 * Get the current north velocity (units??).
664 FGBFI::getSpeedNorth ()
666 return current_aircraft.fdm_state->get_V_north();
671 * Set the current north velocity (units??).
674 FGBFI::setSpeedNorth (double speed)
676 current_options.set_uBody(speed);
677 current_aircraft.fdm_state->set_Velocities_Local(speed,
685 * Get the current east velocity (units??).
688 FGBFI::getSpeedEast ()
690 return current_aircraft.fdm_state->get_V_east();
695 * Set the current east velocity (units??).
698 FGBFI::setSpeedEast (double speed)
700 current_options.set_vBody(speed);
701 current_aircraft.fdm_state->set_Velocities_Local(getSpeedNorth(),
709 * Get the current down velocity (units??).
712 FGBFI::getSpeedDown ()
714 return current_aircraft.fdm_state->get_V_down();
719 * Set the current down velocity (units??).
722 FGBFI::setSpeedDown (double speed)
724 current_options.set_wBody(speed);
725 current_aircraft.fdm_state->set_Velocities_Local(getSpeedNorth(),
733 ////////////////////////////////////////////////////////////////////////
735 ////////////////////////////////////////////////////////////////////////
739 * Get the throttle setting, from 0.0 (none) to 1.0 (full).
742 FGBFI::getThrottle ()
744 // FIXME: add throttle selector
745 return controls.get_throttle(0);
750 * Set the throttle, from 0.0 (none) to 1.0 (full).
753 FGBFI::setThrottle (double throttle)
755 // FIXME: allow throttle selection
757 controls.set_throttle(0, throttle);
762 * Get the flaps setting, from 0.0 (none) to 1.0 (full).
767 return controls.get_flaps();
772 * Set the flaps, from 0.0 (none) to 1.0 (full).
775 FGBFI::setFlaps (double flaps)
778 controls.set_flaps(flaps);
783 * Get the aileron, from -1.0 (left) to 1.0 (right).
788 return controls.get_aileron();
793 * Set the aileron, from -1.0 (left) to 1.0 (right).
796 FGBFI::setAileron (double aileron)
799 controls.set_aileron(aileron);
804 * Get the rudder setting, from -1.0 (left) to 1.0 (right).
809 return controls.get_rudder();
814 * Set the rudder, from -1.0 (left) to 1.0 (right).
817 FGBFI::setRudder (double rudder)
820 controls.set_rudder(rudder);
825 * Get the elevator setting, from -1.0 (down) to 1.0 (up).
828 FGBFI::getElevator ()
830 return controls.get_elevator();
835 * Set the elevator, from -1.0 (down) to 1.0 (up).
838 FGBFI::setElevator (double elevator)
841 controls.set_elevator(elevator);
846 * Get the elevator trim, from -1.0 (down) to 1.0 (up).
849 FGBFI::getElevatorTrim ()
851 return controls.get_elevator_trim();
856 * Set the elevator trim, from -1.0 (down) to 1.0 (up).
859 FGBFI::setElevatorTrim (double trim)
862 controls.set_elevator_trim(trim);
867 * Get the brake setting, from 0.0 (none) to 1.0 (full).
872 // FIXME: add brake selector
873 return controls.get_brake(2);
878 * Set the brake, from 0.0 (none) to 1.0 (full).
881 FGBFI::setBrake (double brake)
883 controls.set_brake(FGControls::ALL_WHEELS, brake);
888 * Get the left brake, from 0.0 (none) to 1.0 (full).
891 FGBFI::getLeftBrake ()
893 return controls.get_brake(0);
898 * Set the left brake, from 0.0 (none) to 1.0 (full).
901 FGBFI::setLeftBrake (double brake)
903 controls.set_brake(0, brake);
908 * Get the right brake, from 0.0 (none) to 1.0 (full).
911 FGBFI::getRightBrake ()
913 return controls.get_brake(1);
918 * Set the right brake, from 0.0 (none) to 1.0 (full).
921 FGBFI::setRightBrake (double brake)
923 controls.set_brake(1, brake);
930 ////////////////////////////////////////////////////////////////////////
932 ////////////////////////////////////////////////////////////////////////
936 * Get the autopilot altitude lock (true=on).
939 FGBFI::getAPAltitudeLock ()
941 return current_autopilot->get_AltitudeEnabled();
946 * Set the autopilot altitude lock (true=on).
949 FGBFI::setAPAltitudeLock (bool lock)
951 current_autopilot->set_AltitudeMode(FGAutopilot::FG_ALTITUDE_LOCK);
952 current_autopilot->set_AltitudeEnabled(lock);
957 * Get the autopilot target altitude in feet.
960 FGBFI::getAPAltitude ()
962 return current_autopilot->get_TargetAltitude() * METER_TO_FEET;
967 * Set the autopilot target altitude in feet.
970 FGBFI::setAPAltitude (double altitude)
972 current_autopilot->set_TargetAltitude( altitude );
977 * Get the autopilot heading lock (true=on).
980 FGBFI::getAPHeadingLock ()
983 (current_autopilot->get_HeadingEnabled() &&
984 current_autopilot->get_HeadingMode() == FGAutopilot::FG_HEADING_LOCK);
989 * Set the autopilot heading lock (true=on).
992 FGBFI::setAPHeadingLock (bool lock)
995 // We need to do this so that
996 // it's possible to lock onto a
997 // heading other than the current
999 double heading = getAPHeadingMag();
1000 current_autopilot->set_HeadingMode(FGAutopilot::FG_HEADING_LOCK);
1001 current_autopilot->set_HeadingEnabled(true);
1002 setAPHeadingMag(heading);
1003 } else if (current_autopilot->get_HeadingMode() ==
1004 FGAutopilot::FG_HEADING_LOCK) {
1005 current_autopilot->set_HeadingEnabled(false);
1011 * Get the autopilot target heading in degrees.
1014 FGBFI::getAPHeadingMag ()
1016 return current_autopilot->get_TargetHeading() - getMagVar();
1021 * Set the autopilot target heading in degrees.
1024 FGBFI::setAPHeadingMag (double heading)
1026 current_autopilot->set_TargetHeading( heading + getMagVar() );
1031 * Return true if the autopilot is locked to NAV1.
1034 FGBFI::getAPNAV1Lock ()
1037 (current_autopilot->get_HeadingEnabled() &&
1038 current_autopilot->get_HeadingMode() == FGAutopilot::FG_HEADING_NAV1);
1043 * Set the autopilot NAV1 lock.
1046 FGBFI::setAPNAV1Lock (bool lock)
1049 current_autopilot->set_HeadingMode(FGAutopilot::FG_HEADING_NAV1);
1050 current_autopilot->set_HeadingEnabled(true);
1051 } else if (current_autopilot->get_HeadingMode() ==
1052 FGAutopilot::FG_HEADING_NAV1) {
1053 current_autopilot->set_HeadingEnabled(false);
1059 ////////////////////////////////////////////////////////////////////////
1060 // Radio navigation.
1061 ////////////////////////////////////////////////////////////////////////
1064 FGBFI::getNAV1Freq ()
1066 return current_radiostack->get_nav1_freq();
1070 FGBFI::getNAV1AltFreq ()
1072 return current_radiostack->get_nav1_alt_freq();
1076 FGBFI::getNAV1Radial ()
1078 return current_radiostack->get_nav1_radial();
1082 FGBFI::getNAV1SelRadial ()
1084 return current_radiostack->get_nav1_sel_radial();
1088 FGBFI::getNAV1DistDME ()
1090 return current_radiostack->get_nav1_dme_dist();
1094 FGBFI::getNAV1InRange ()
1096 return current_radiostack->get_nav1_inrange();
1100 FGBFI::getNAV1DMEInRange ()
1102 return (current_radiostack->get_nav1_inrange() &&
1103 current_radiostack->get_nav1_has_dme());
1107 FGBFI::getNAV2Freq ()
1109 return current_radiostack->get_nav2_freq();
1113 FGBFI::getNAV2AltFreq ()
1115 return current_radiostack->get_nav2_alt_freq();
1119 FGBFI::getNAV2Radial ()
1121 return current_radiostack->get_nav2_radial();
1125 FGBFI::getNAV2SelRadial ()
1127 return current_radiostack->get_nav2_sel_radial();
1131 FGBFI::getNAV2DistDME ()
1133 return current_radiostack->get_nav2_dme_dist();
1137 FGBFI::getNAV2InRange ()
1139 return current_radiostack->get_nav2_inrange();
1143 FGBFI::getNAV2DMEInRange ()
1145 return (current_radiostack->get_nav2_inrange() &&
1146 current_radiostack->get_nav2_has_dme());
1150 FGBFI::getADFFreq ()
1152 return current_radiostack->get_adf_freq();
1156 FGBFI::getADFAltFreq ()
1158 return current_radiostack->get_adf_alt_freq();
1162 FGBFI::getADFRotation ()
1164 return current_radiostack->get_adf_rotation();
1168 FGBFI::setNAV1Freq (double freq)
1170 current_radiostack->set_nav1_freq(freq);
1174 FGBFI::setNAV1AltFreq (double freq)
1176 current_radiostack->set_nav1_alt_freq(freq);
1180 FGBFI::setNAV1SelRadial (double radial)
1182 current_radiostack->set_nav1_sel_radial(radial);
1186 FGBFI::setNAV2Freq (double freq)
1188 current_radiostack->set_nav2_freq(freq);
1192 FGBFI::setNAV2AltFreq (double freq)
1194 current_radiostack->set_nav2_alt_freq(freq);
1198 FGBFI::setNAV2SelRadial (double radial)
1200 current_radiostack->set_nav2_sel_radial(radial);
1204 FGBFI::setADFFreq (double freq)
1206 current_radiostack->set_adf_freq(freq);
1210 FGBFI::setADFAltFreq (double freq)
1212 current_radiostack->set_adf_alt_freq(freq);
1216 FGBFI::setADFRotation (double rot)
1218 current_radiostack->set_adf_rotation(rot);
1223 ////////////////////////////////////////////////////////////////////////
1225 ////////////////////////////////////////////////////////////////////////
1229 * Get the autopilot GPS lock (true=on).
1232 FGBFI::getGPSLock ()
1234 return (current_autopilot->get_HeadingEnabled() &&
1235 (current_autopilot->get_HeadingMode() ==
1236 FGAutopilot::FG_HEADING_WAYPOINT ));
1241 * Set the autopilot GPS lock (true=on).
1244 FGBFI::setGPSLock (bool lock)
1247 current_autopilot->set_HeadingMode(FGAutopilot::FG_HEADING_WAYPOINT);
1248 current_autopilot->set_HeadingEnabled(true);
1249 } else if (current_autopilot->get_HeadingMode() ==
1250 FGAutopilot::FG_HEADING_WAYPOINT) {
1251 current_autopilot->set_HeadingEnabled(false);
1257 * Get the GPS target airport code.
1260 FGBFI::getTargetAirport ()
1262 return current_options.get_airport_id();
1267 * Set the GPS target airport code.
1270 FGBFI::setTargetAirport (const string &airportId)
1272 current_options.set_airport_id(airportId);
1277 * Get the GPS target latitude in degrees (negative for south).
1280 FGBFI::getGPSTargetLatitude ()
1282 return current_autopilot->get_TargetLatitude();
1287 * Set the GPS target latitude in degrees (negative for south).
1290 FGBFI::setGPSTargetLatitude (double latitude)
1292 current_autopilot->set_TargetLatitude( latitude );
1297 * Get the GPS target longitude in degrees (negative for west).
1300 FGBFI::getGPSTargetLongitude ()
1302 return current_autopilot->get_TargetLongitude();
1307 * Set the GPS target longitude in degrees (negative for west).
1310 FGBFI::setGPSTargetLongitude (double longitude)
1312 current_autopilot->set_TargetLongitude( longitude );
1317 ////////////////////////////////////////////////////////////////////////
1319 ////////////////////////////////////////////////////////////////////////
1323 * Get the current visible (units??).
1326 FGBFI::getVisibility ()
1328 #ifndef FG_OLD_WEATHER
1329 return WeatherDatabase->getWeatherVisibility();
1331 return current_weather.get_visibility();
1337 * Check whether clouds are enabled.
1342 return current_options.get_clouds();
1347 * Check the height of the clouds ASL (units?).
1350 FGBFI::getCloudsASL ()
1352 return current_options.get_clouds_asl();
1357 * Set the current visibility (units??).
1360 FGBFI::setVisibility (double visibility)
1362 #ifndef FG_OLD_WEATHER
1363 WeatherDatabase->setWeatherVisibility(visibility);
1365 current_weather.set_visibility(visibility);
1371 * Switch clouds on or off.
1374 FGBFI::setClouds (bool clouds)
1376 cout << "Set clouds to " << clouds << endl;
1377 current_options.set_clouds(clouds);
1383 * Set the cloud height.
1386 FGBFI::setCloudsASL (double cloudsASL)
1388 current_options.set_clouds_asl(cloudsASL);
1394 ////////////////////////////////////////////////////////////////////////
1396 ////////////////////////////////////////////////////////////////////////
1399 * Return the magnetic variation
1404 return cur_magvar.get_magvar() * RAD_TO_DEG;
1409 * Return the magnetic variation
1414 return cur_magvar.get_magdip() * RAD_TO_DEG;