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/brakes/all",
151 getBrakes, setBrakes);
152 current_properties.tieDouble("/controls/brakes/left",
153 getLeftBrake, setLeftBrake);
154 current_properties.tieDouble("/controls/brakes/right",
155 getRightBrake, setRightBrake);
156 current_properties.tieDouble("/controls/brakes/Center",
157 getRightBrake, setCenterBrake);
160 current_properties.tieDouble("/controls/brake",
161 getBrakes, setBrakes);
162 current_properties.tieDouble("/controls/left-brake",
163 getLeftBrake, setLeftBrake);
164 current_properties.tieDouble("/controls/right-brake",
165 getRightBrake, setRightBrake);
168 current_properties.tieBool("/autopilot/locks/altitude",
169 getAPAltitudeLock, setAPAltitudeLock);
170 current_properties.tieDouble("/autopilot/settings/altitude",
171 getAPAltitude, setAPAltitude);
172 current_properties.tieBool("/autopilot/locks/heading",
173 getAPHeadingLock, setAPHeadingLock);
174 current_properties.tieDouble("/autopilot/settings/heading",
175 getAPHeading, setAPHeading);
176 current_properties.tieDouble("/autopilot/settings/heading-magnetic",
177 getAPHeadingMag, setAPHeadingMag);
178 current_properties.tieBool("/autopilot/locks/nav1",
179 getAPNAV1Lock, setAPNAV1Lock);
182 current_properties.tieDouble("/radios/nav1/frequencies/selected",
183 getNAV1Freq, setNAV1Freq);
184 current_properties.tieDouble("/radios/nav1/frequencies/standby",
185 getNAV1AltFreq, setNAV1AltFreq);
186 current_properties.tieDouble("/radios/nav1/radials/actual",
188 current_properties.tieDouble("/radios/nav1/radials/selected",
189 getNAV1SelRadial, setNAV1SelRadial);
190 current_properties.tieDouble("/radios/nav1/dme/distance",
192 current_properties.tieBool("/radios/nav1/in-range",
194 current_properties.tieBool("/radios/nav1/dme/in-range",
195 getNAV1DMEInRange, 0);
197 current_properties.tieDouble("/radios/nav2/frequencies/selected",
198 getNAV2Freq, setNAV2Freq);
199 current_properties.tieDouble("/radios/nav2/frequencies/standby",
200 getNAV2AltFreq, setNAV2AltFreq);
201 current_properties.tieDouble("/radios/nav2/radials/actual",
203 current_properties.tieDouble("/radios/nav2/radials/selected",
204 getNAV2SelRadial, setNAV2SelRadial);
205 current_properties.tieDouble("/radios/nav2/dme/distance",
207 current_properties.tieBool("/radios/nav2/in-range",
209 current_properties.tieBool("/radios/nav2/dme/in-range",
210 getNAV2DMEInRange, 0);
212 current_properties.tieDouble("/radios/adf/frequencies/selected",
213 getADFFreq, setADFFreq);
214 current_properties.tieDouble("/radios/adf/frequencies/standby",
215 getADFAltFreq, setADFAltFreq);
216 current_properties.tieDouble("/radios/adf/rotation",
217 getADFRotation, setADFRotation);
219 FG_LOG(FG_GENERAL, FG_INFO, "Ending BFI init");
224 * Reinitialize FGFS if required.
226 * Some changes (especially those in aircraft position) require that
227 * FGFS be reinitialized afterwards. Rather than reinitialize after
228 * every change, the setter methods simply set a flag so that there
229 * can be a single reinit at the end of the frame.
241 * Reinitialize FGFS to use the new BFI settings.
246 // Save the state of everything
247 // that's going to get clobbered
248 // when we reinit the subsystems.
250 cout << "BFI: start reinit\n";
252 setHeading(getHeading());
253 setPitch(getPitch());
255 setSpeedNorth(getSpeedNorth());
256 setSpeedEast(getSpeedEast());
257 setSpeedDown(getSpeedDown());
258 setLatitude(getLatitude());
259 setLongitude(getLongitude());
260 setAltitude(getAltitude());
262 // TODO: add more AP stuff
263 double elevator = getElevator();
264 double aileron = getAileron();
265 double rudder = getRudder();
266 double throttle = getThrottle();
267 double elevator_trim = getElevatorTrim();
268 double flaps = getFlaps();
269 double brake = getBrakes();
270 bool apHeadingLock = getAPHeadingLock();
271 double apHeadingMag = getAPHeadingMag();
272 bool apAltitudeLock = getAPAltitudeLock();
273 double apAltitude = getAPAltitude();
274 const string &targetAirport = getTargetAirport();
275 bool gpsLock = getGPSLock();
276 double gpsLatitude = getGPSTargetLatitude();
277 double gpsLongitude = getGPSTargetLongitude();
279 setTargetAirport("");
280 cout << "Target airport is " << current_options.get_airport_id() << endl;
282 fgReInitSubsystems();
284 // FIXME: this is wrong.
285 // All of these are scheduled events,
286 // and it should be possible to force
287 // them all to run once.
290 cur_light_params.Update();
292 fgUpdateWeatherDatabase();
295 // Restore all of the old states.
296 setElevator(elevator);
299 setThrottle(throttle);
300 setElevatorTrim(elevator_trim);
303 setAPHeadingLock(apHeadingLock);
304 setAPHeadingMag(apHeadingMag);
305 setAPAltitudeLock(apAltitudeLock);
306 setAPAltitude(apAltitude);
307 setTargetAirport(targetAirport);
309 setGPSTargetLatitude(gpsLatitude);
310 setGPSTargetLongitude(gpsLongitude);
314 cout << "BFI: end reinit\n";
319 ////////////////////////////////////////////////////////////////////////
321 ////////////////////////////////////////////////////////////////////////
325 * Return the flight model as an integer.
327 * TODO: use a string instead.
330 FGBFI::getFlightModel ()
332 return current_options.get_flight_model();
337 * Return the current aircraft as a string.
340 FGBFI::getAircraft ()
342 return current_options.get_aircraft();
347 * Return the current aircraft directory (UIUC) as a string.
350 FGBFI::getAircraftDir ()
357 * Set the flight model as an integer.
359 * TODO: use a string instead.
362 FGBFI::setFlightModel (int model)
364 current_options.set_flight_model(model);
370 * Set the current aircraft.
373 FGBFI::setAircraft (const string &aircraft)
375 current_options.set_aircraft(aircraft);
381 * Set the current aircraft directory (UIUC).
384 FGBFI::setAircraftDir (const string &dir)
392 * Return the current Zulu time.
397 return globals->get_time_params()->get_cur_time();
402 * Set the current Zulu time.
405 FGBFI::setTimeGMT (time_t time)
407 // FIXME: need to update lighting
409 current_options.set_time_offset(time);
410 current_options.set_time_offset_type(fgOPTIONS::FG_TIME_GMT_ABSOLUTE);
411 globals->get_time_params()->update( cur_fdm_state->get_Longitude(),
412 cur_fdm_state->get_Latitude(),
413 globals->get_warp() );
419 * Return true if the HUD is visible.
422 FGBFI::getHUDVisible ()
424 return current_options.get_hud_status();
429 * Ensure that the HUD is visible or hidden.
432 FGBFI::setHUDVisible (bool visible)
434 current_options.set_hud_status(visible);
439 * Return true if the 2D panel is visible.
442 FGBFI::getPanelVisible ()
444 return current_options.get_panel_status();
449 * Ensure that the 2D panel is visible or hidden.
452 FGBFI::setPanelVisible (bool visible)
454 if (current_options.get_panel_status() != visible) {
455 current_options.toggle_panel();
461 ////////////////////////////////////////////////////////////////////////
463 ////////////////////////////////////////////////////////////////////////
467 * Return the current latitude in degrees (negative for south).
470 FGBFI::getLatitude ()
472 return current_aircraft.fdm_state->get_Latitude() * RAD_TO_DEG;
477 * Set the current latitude in degrees (negative for south).
480 FGBFI::setLatitude (double latitude)
482 current_options.set_lat(latitude);
483 current_aircraft.fdm_state->set_Latitude(latitude * DEG_TO_RAD);
489 * Return the current longitude in degrees (negative for west).
492 FGBFI::getLongitude ()
494 return current_aircraft.fdm_state->get_Longitude() * RAD_TO_DEG;
499 * Set the current longitude in degrees (negative for west).
502 FGBFI::setLongitude (double longitude)
504 current_options.set_lon(longitude);
505 current_aircraft.fdm_state->set_Longitude(longitude * DEG_TO_RAD);
511 * Return the current altitude in feet.
514 FGBFI::getAltitude ()
516 return current_aircraft.fdm_state->get_Altitude();
522 * Return the current altitude in above the terrain.
527 return current_aircraft.fdm_state->get_Altitude()
528 - (scenery.cur_elev * METER_TO_FEET);
533 * Set the current altitude in feet.
536 FGBFI::setAltitude (double altitude)
538 fgFDMForceAltitude(getFlightModel(), altitude * FEET_TO_METER);
539 current_options.set_altitude(altitude * FEET_TO_METER);
540 current_aircraft.fdm_state->set_Altitude(altitude);
546 ////////////////////////////////////////////////////////////////////////
548 ////////////////////////////////////////////////////////////////////////
552 * Return the current heading in degrees.
557 return current_aircraft.fdm_state->get_Psi() * RAD_TO_DEG;
562 * Return the current heading in degrees.
565 FGBFI::getHeadingMag ()
567 return current_aircraft.fdm_state->get_Psi() * RAD_TO_DEG - getMagVar();
572 * Set the current heading in degrees.
575 FGBFI::setHeading (double heading)
577 current_options.set_heading(heading);
578 current_aircraft.fdm_state->set_Euler_Angles(getRoll() * DEG_TO_RAD,
579 getPitch() * DEG_TO_RAD,
580 heading * DEG_TO_RAD);
586 * Return the current pitch in degrees.
591 return current_aircraft.fdm_state->get_Theta() * RAD_TO_DEG;
596 * Set the current pitch in degrees.
599 FGBFI::setPitch (double pitch)
602 current_options.set_pitch(pitch);
603 current_aircraft.fdm_state->set_Euler_Angles(getRoll() * DEG_TO_RAD,
605 getHeading() * DEG_TO_RAD);
611 * Return the current roll in degrees.
616 return current_aircraft.fdm_state->get_Phi() * RAD_TO_DEG;
621 * Set the current roll in degrees.
624 FGBFI::setRoll (double roll)
626 current_options.set_roll(roll);
627 current_aircraft.fdm_state->set_Euler_Angles(roll * DEG_TO_RAD,
628 getPitch() * DEG_TO_RAD,
629 getHeading() * DEG_TO_RAD);
635 ////////////////////////////////////////////////////////////////////////
637 ////////////////////////////////////////////////////////////////////////
641 * Return the current airspeed in knots.
644 FGBFI::getAirspeed ()
646 // FIXME: should we add speed-up?
647 return current_aircraft.fdm_state->get_V_calibrated_kts();
652 * Return the current sideslip (FIXME: units unknown).
655 FGBFI::getSideSlip ()
657 return current_aircraft.fdm_state->get_Beta();
662 * Return the current climb rate in feet/minute
665 FGBFI::getVerticalSpeed ()
667 // What about meters?
668 return current_aircraft.fdm_state->get_Climb_Rate() * 60.0;
673 * Get the current north velocity (units??).
676 FGBFI::getSpeedNorth ()
678 return current_aircraft.fdm_state->get_V_north();
683 * Set the current north velocity (units??).
686 FGBFI::setSpeedNorth (double speed)
688 current_options.set_uBody(speed);
689 current_aircraft.fdm_state->set_Velocities_Local(speed,
697 * Get the current east velocity (units??).
700 FGBFI::getSpeedEast ()
702 return current_aircraft.fdm_state->get_V_east();
707 * Set the current east velocity (units??).
710 FGBFI::setSpeedEast (double speed)
712 current_options.set_vBody(speed);
713 current_aircraft.fdm_state->set_Velocities_Local(getSpeedNorth(),
721 * Get the current down velocity (units??).
724 FGBFI::getSpeedDown ()
726 return current_aircraft.fdm_state->get_V_down();
731 * Set the current down velocity (units??).
734 FGBFI::setSpeedDown (double speed)
736 current_options.set_wBody(speed);
737 current_aircraft.fdm_state->set_Velocities_Local(getSpeedNorth(),
745 ////////////////////////////////////////////////////////////////////////
747 ////////////////////////////////////////////////////////////////////////
751 * Get the throttle setting, from 0.0 (none) to 1.0 (full).
754 FGBFI::getThrottle ()
756 // FIXME: add throttle selector
757 return controls.get_throttle(0);
762 * Set the throttle, from 0.0 (none) to 1.0 (full).
765 FGBFI::setThrottle (double throttle)
767 // FIXME: allow throttle selection
769 controls.set_throttle(0, throttle);
774 * Get the flaps setting, from 0.0 (none) to 1.0 (full).
779 return controls.get_flaps();
784 * Set the flaps, from 0.0 (none) to 1.0 (full).
787 FGBFI::setFlaps (double flaps)
790 controls.set_flaps(flaps);
795 * Get the aileron, from -1.0 (left) to 1.0 (right).
800 return controls.get_aileron();
805 * Set the aileron, from -1.0 (left) to 1.0 (right).
808 FGBFI::setAileron (double aileron)
811 controls.set_aileron(aileron);
816 * Get the rudder setting, from -1.0 (left) to 1.0 (right).
821 return controls.get_rudder();
826 * Set the rudder, from -1.0 (left) to 1.0 (right).
829 FGBFI::setRudder (double rudder)
832 controls.set_rudder(rudder);
837 * Get the elevator setting, from -1.0 (down) to 1.0 (up).
840 FGBFI::getElevator ()
842 return controls.get_elevator();
847 * Set the elevator, from -1.0 (down) to 1.0 (up).
850 FGBFI::setElevator (double elevator)
853 controls.set_elevator(elevator);
858 * Get the elevator trim, from -1.0 (down) to 1.0 (up).
861 FGBFI::getElevatorTrim ()
863 return controls.get_elevator_trim();
868 * Set the elevator trim, from -1.0 (down) to 1.0 (up).
871 FGBFI::setElevatorTrim (double trim)
874 controls.set_elevator_trim(trim);
879 * Get the highest brake setting, from 0.0 (none) to 1.0 (full).
884 double b1 = getCenterBrake();
885 double b2 = getLeftBrake();
886 double b3 = getRightBrake();
887 return (b1 > b2 ? (b1 > b3 ? b1 : b3) : (b2 > b3 ? b2 : b3));
892 * Set all brakes, from 0.0 (none) to 1.0 (full).
895 FGBFI::setBrakes (double brake)
897 setCenterBrake(brake);
899 setRightBrake(brake);
904 * Get the center brake, from 0.0 (none) to 1.0 (full).
907 FGBFI::getCenterBrake ()
909 return controls.get_brake(2);
914 * Set the center brake, from 0.0 (none) to 1.0 (full).
917 FGBFI::setCenterBrake (double brake)
919 controls.set_brake(2, brake);
924 * Get the left brake, from 0.0 (none) to 1.0 (full).
927 FGBFI::getLeftBrake ()
929 return controls.get_brake(0);
934 * Set the left brake, from 0.0 (none) to 1.0 (full).
937 FGBFI::setLeftBrake (double brake)
939 controls.set_brake(0, brake);
944 * Get the right brake, from 0.0 (none) to 1.0 (full).
947 FGBFI::getRightBrake ()
949 return controls.get_brake(1);
954 * Set the right brake, from 0.0 (none) to 1.0 (full).
957 FGBFI::setRightBrake (double brake)
959 controls.set_brake(1, brake);
966 ////////////////////////////////////////////////////////////////////////
968 ////////////////////////////////////////////////////////////////////////
972 * Get the autopilot altitude lock (true=on).
975 FGBFI::getAPAltitudeLock ()
977 return current_autopilot->get_AltitudeEnabled();
982 * Set the autopilot altitude lock (true=on).
985 FGBFI::setAPAltitudeLock (bool lock)
987 current_autopilot->set_AltitudeMode(FGAutopilot::FG_ALTITUDE_LOCK);
988 current_autopilot->set_AltitudeEnabled(lock);
993 * Get the autopilot target altitude in feet.
996 FGBFI::getAPAltitude ()
998 return current_autopilot->get_TargetAltitude() * METER_TO_FEET;
1003 * Set the autopilot target altitude in feet.
1006 FGBFI::setAPAltitude (double altitude)
1008 current_autopilot->set_TargetAltitude( altitude );
1013 * Get the autopilot heading lock (true=on).
1016 FGBFI::getAPHeadingLock ()
1019 (current_autopilot->get_HeadingEnabled() &&
1020 current_autopilot->get_HeadingMode() == FGAutopilot::FG_HEADING_LOCK);
1025 * Set the autopilot heading lock (true=on).
1028 FGBFI::setAPHeadingLock (bool lock)
1031 // We need to do this so that
1032 // it's possible to lock onto a
1033 // heading other than the current
1035 double heading = getAPHeadingMag();
1036 current_autopilot->set_HeadingMode(FGAutopilot::FG_HEADING_LOCK);
1037 current_autopilot->set_HeadingEnabled(true);
1038 setAPHeadingMag(heading);
1039 } else if (current_autopilot->get_HeadingMode() ==
1040 FGAutopilot::FG_HEADING_LOCK) {
1041 current_autopilot->set_HeadingEnabled(false);
1047 * Get the autopilot target heading in degrees.
1050 FGBFI::getAPHeading ()
1052 return current_autopilot->get_TargetHeading();
1057 * Set the autopilot target heading in degrees.
1060 FGBFI::setAPHeading (double heading)
1062 current_autopilot->set_TargetHeading( heading );
1067 * Get the autopilot target heading in degrees.
1070 FGBFI::getAPHeadingMag ()
1072 return current_autopilot->get_TargetHeading() - getMagVar();
1077 * Set the autopilot target heading in degrees.
1080 FGBFI::setAPHeadingMag (double heading)
1082 current_autopilot->set_TargetHeading( heading + getMagVar() );
1087 * Return true if the autopilot is locked to NAV1.
1090 FGBFI::getAPNAV1Lock ()
1093 (current_autopilot->get_HeadingEnabled() &&
1094 current_autopilot->get_HeadingMode() == FGAutopilot::FG_HEADING_NAV1);
1099 * Set the autopilot NAV1 lock.
1102 FGBFI::setAPNAV1Lock (bool lock)
1105 current_autopilot->set_HeadingMode(FGAutopilot::FG_HEADING_NAV1);
1106 current_autopilot->set_HeadingEnabled(true);
1107 } else if (current_autopilot->get_HeadingMode() ==
1108 FGAutopilot::FG_HEADING_NAV1) {
1109 current_autopilot->set_HeadingEnabled(false);
1115 ////////////////////////////////////////////////////////////////////////
1116 // Radio navigation.
1117 ////////////////////////////////////////////////////////////////////////
1120 FGBFI::getNAV1Freq ()
1122 return current_radiostack->get_nav1_freq();
1126 FGBFI::getNAV1AltFreq ()
1128 return current_radiostack->get_nav1_alt_freq();
1132 FGBFI::getNAV1Radial ()
1134 return current_radiostack->get_nav1_radial();
1138 FGBFI::getNAV1SelRadial ()
1140 return current_radiostack->get_nav1_sel_radial();
1144 FGBFI::getNAV1DistDME ()
1146 return current_radiostack->get_nav1_dme_dist();
1150 FGBFI::getNAV1InRange ()
1152 return current_radiostack->get_nav1_inrange();
1156 FGBFI::getNAV1DMEInRange ()
1158 return (current_radiostack->get_nav1_inrange() &&
1159 current_radiostack->get_nav1_has_dme());
1163 FGBFI::getNAV2Freq ()
1165 return current_radiostack->get_nav2_freq();
1169 FGBFI::getNAV2AltFreq ()
1171 return current_radiostack->get_nav2_alt_freq();
1175 FGBFI::getNAV2Radial ()
1177 return current_radiostack->get_nav2_radial();
1181 FGBFI::getNAV2SelRadial ()
1183 return current_radiostack->get_nav2_sel_radial();
1187 FGBFI::getNAV2DistDME ()
1189 return current_radiostack->get_nav2_dme_dist();
1193 FGBFI::getNAV2InRange ()
1195 return current_radiostack->get_nav2_inrange();
1199 FGBFI::getNAV2DMEInRange ()
1201 return (current_radiostack->get_nav2_inrange() &&
1202 current_radiostack->get_nav2_has_dme());
1206 FGBFI::getADFFreq ()
1208 return current_radiostack->get_adf_freq();
1212 FGBFI::getADFAltFreq ()
1214 return current_radiostack->get_adf_alt_freq();
1218 FGBFI::getADFRotation ()
1220 return current_radiostack->get_adf_rotation();
1224 FGBFI::setNAV1Freq (double freq)
1226 current_radiostack->set_nav1_freq(freq);
1230 FGBFI::setNAV1AltFreq (double freq)
1232 current_radiostack->set_nav1_alt_freq(freq);
1236 FGBFI::setNAV1SelRadial (double radial)
1238 current_radiostack->set_nav1_sel_radial(radial);
1242 FGBFI::setNAV2Freq (double freq)
1244 current_radiostack->set_nav2_freq(freq);
1248 FGBFI::setNAV2AltFreq (double freq)
1250 current_radiostack->set_nav2_alt_freq(freq);
1254 FGBFI::setNAV2SelRadial (double radial)
1256 current_radiostack->set_nav2_sel_radial(radial);
1260 FGBFI::setADFFreq (double freq)
1262 current_radiostack->set_adf_freq(freq);
1266 FGBFI::setADFAltFreq (double freq)
1268 current_radiostack->set_adf_alt_freq(freq);
1272 FGBFI::setADFRotation (double rot)
1274 current_radiostack->set_adf_rotation(rot);
1279 ////////////////////////////////////////////////////////////////////////
1281 ////////////////////////////////////////////////////////////////////////
1285 * Get the autopilot GPS lock (true=on).
1288 FGBFI::getGPSLock ()
1290 return (current_autopilot->get_HeadingEnabled() &&
1291 (current_autopilot->get_HeadingMode() ==
1292 FGAutopilot::FG_HEADING_WAYPOINT ));
1297 * Set the autopilot GPS lock (true=on).
1300 FGBFI::setGPSLock (bool lock)
1303 current_autopilot->set_HeadingMode(FGAutopilot::FG_HEADING_WAYPOINT);
1304 current_autopilot->set_HeadingEnabled(true);
1305 } else if (current_autopilot->get_HeadingMode() ==
1306 FGAutopilot::FG_HEADING_WAYPOINT) {
1307 current_autopilot->set_HeadingEnabled(false);
1313 * Get the GPS target airport code.
1316 FGBFI::getTargetAirport ()
1318 return current_options.get_airport_id();
1323 * Set the GPS target airport code.
1326 FGBFI::setTargetAirport (const string &airportId)
1328 current_options.set_airport_id(airportId);
1333 * Get the GPS target latitude in degrees (negative for south).
1336 FGBFI::getGPSTargetLatitude ()
1338 return current_autopilot->get_TargetLatitude();
1343 * Set the GPS target latitude in degrees (negative for south).
1346 FGBFI::setGPSTargetLatitude (double latitude)
1348 current_autopilot->set_TargetLatitude( latitude );
1353 * Get the GPS target longitude in degrees (negative for west).
1356 FGBFI::getGPSTargetLongitude ()
1358 return current_autopilot->get_TargetLongitude();
1363 * Set the GPS target longitude in degrees (negative for west).
1366 FGBFI::setGPSTargetLongitude (double longitude)
1368 current_autopilot->set_TargetLongitude( longitude );
1373 ////////////////////////////////////////////////////////////////////////
1375 ////////////////////////////////////////////////////////////////////////
1379 * Get the current visible (units??).
1382 FGBFI::getVisibility ()
1384 #ifndef FG_OLD_WEATHER
1385 return WeatherDatabase->getWeatherVisibility();
1387 return current_weather.get_visibility();
1393 * Check whether clouds are enabled.
1398 return current_options.get_clouds();
1403 * Check the height of the clouds ASL (units?).
1406 FGBFI::getCloudsASL ()
1408 return current_options.get_clouds_asl();
1413 * Set the current visibility (units??).
1416 FGBFI::setVisibility (double visibility)
1418 #ifndef FG_OLD_WEATHER
1419 WeatherDatabase->setWeatherVisibility(visibility);
1421 current_weather.set_visibility(visibility);
1427 * Switch clouds on or off.
1430 FGBFI::setClouds (bool clouds)
1432 cout << "Set clouds to " << clouds << endl;
1433 current_options.set_clouds(clouds);
1439 * Set the cloud height.
1442 FGBFI::setCloudsASL (double cloudsASL)
1444 current_options.set_clouds_asl(cloudsASL);
1450 ////////////////////////////////////////////////////////////////////////
1452 ////////////////////////////////////////////////////////////////////////
1455 * Return the magnetic variation
1460 return cur_magvar.get_magvar() * RAD_TO_DEG;
1465 * Return the magnetic variation
1470 return cur_magvar.get_magdip() * RAD_TO_DEG;