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"
61 #include <simgear/misc/props.hxx>
63 FG_USING_NAMESPACE(std);
70 ////////////////////////////////////////////////////////////////////////
72 ////////////////////////////////////////////////////////////////////////
74 bool FGBFI::_needReinit = false;
78 ////////////////////////////////////////////////////////////////////////
80 ////////////////////////////////////////////////////////////////////////
84 * Initialize the BFI by binding its functions to properties.
86 * TODO: perhaps these should migrate into the individual modules
87 * (i.e. they should register themselves).
92 FG_LOG(FG_GENERAL, FG_INFO, "Starting BFI init");
94 current_properties.tieInt("/sim/flight-model",
95 getFlightModel, setFlightModel);
96 // current_properties.tieString("/sim/aircraft",
97 // getAircraft, setAircraft);
99 current_properties.tieBool("/sim/hud/visibility",
100 getHUDVisible, setHUDVisible);
101 current_properties.tieBool("/sim/panel/visibility",
102 getPanelVisible, setPanelVisible);
105 current_properties.tieDouble("/position/latitude",
106 getLatitude, setLatitude);
107 current_properties.tieDouble("/position/longitude",
108 getLongitude, setLongitude);
109 current_properties.tieDouble("/position/altitude",
110 getAltitude, setAltitude);
111 current_properties.tieDouble("/position/altitude-agl",
115 current_properties.tieDouble("/orientation/heading",
116 getHeading, setHeading);
117 current_properties.tieDouble("/orientation/heading-magnetic",
119 current_properties.tieDouble("/orientation/pitch",
121 current_properties.tieDouble("/orientation/roll",
125 current_properties.tieDouble("/velocities/airspeed",
127 current_properties.tieDouble("/velocities/side-slip",
129 current_properties.tieDouble("/velocities/vertical-speed",
130 getVerticalSpeed, 0);
131 current_properties.tieDouble("/velocities/speed-north",
132 getSpeedNorth, setSpeedNorth);
133 current_properties.tieDouble("/velocities/speed-east",
134 getSpeedEast, setSpeedEast);
135 current_properties.tieDouble("/velocities/speed-down",
136 getSpeedDown, setSpeedDown);
139 current_properties.tieDouble("/controls/throttle",
140 getThrottle, setThrottle);
141 current_properties.tieDouble("/controls/flaps",
143 current_properties.tieDouble("/controls/aileron",
144 getAileron, setAileron);
145 current_properties.tieDouble("/controls/rudder",
146 getRudder, setRudder);
147 current_properties.tieDouble("/controls/elevator",
148 getElevator, setElevator);
149 current_properties.tieDouble("/controls/elevator-trim",
150 getElevatorTrim, setElevatorTrim);
151 current_properties.tieDouble("/controls/brakes/all",
152 getBrakes, setBrakes);
153 current_properties.tieDouble("/controls/brakes/left",
154 getLeftBrake, setLeftBrake);
155 current_properties.tieDouble("/controls/brakes/right",
156 getRightBrake, setRightBrake);
157 current_properties.tieDouble("/controls/brakes/Center",
158 getRightBrake, setCenterBrake);
161 current_properties.tieDouble("/controls/brake",
162 getBrakes, setBrakes);
163 current_properties.tieDouble("/controls/left-brake",
164 getLeftBrake, setLeftBrake);
165 current_properties.tieDouble("/controls/right-brake",
166 getRightBrake, setRightBrake);
169 current_properties.tieBool("/autopilot/locks/altitude",
170 getAPAltitudeLock, setAPAltitudeLock);
171 current_properties.tieDouble("/autopilot/settings/altitude",
172 getAPAltitude, setAPAltitude);
173 current_properties.tieBool("/autopilot/locks/heading",
174 getAPHeadingLock, setAPHeadingLock);
175 current_properties.tieDouble("/autopilot/settings/heading",
176 getAPHeading, setAPHeading);
177 current_properties.tieDouble("/autopilot/settings/heading-magnetic",
178 getAPHeadingMag, setAPHeadingMag);
179 current_properties.tieBool("/autopilot/locks/nav1",
180 getAPNAV1Lock, setAPNAV1Lock);
183 current_properties.tieDouble("/radios/nav1/frequencies/selected",
184 getNAV1Freq, setNAV1Freq);
185 current_properties.tieDouble("/radios/nav1/frequencies/standby",
186 getNAV1AltFreq, setNAV1AltFreq);
187 current_properties.tieDouble("/radios/nav1/radials/actual",
189 current_properties.tieDouble("/radios/nav1/radials/selected",
190 getNAV1SelRadial, setNAV1SelRadial);
191 current_properties.tieDouble("/radios/nav1/dme/distance",
193 current_properties.tieBool("/radios/nav1/in-range",
195 current_properties.tieBool("/radios/nav1/dme/in-range",
196 getNAV1DMEInRange, 0);
198 current_properties.tieDouble("/radios/nav2/frequencies/selected",
199 getNAV2Freq, setNAV2Freq);
200 current_properties.tieDouble("/radios/nav2/frequencies/standby",
201 getNAV2AltFreq, setNAV2AltFreq);
202 current_properties.tieDouble("/radios/nav2/radials/actual",
204 current_properties.tieDouble("/radios/nav2/radials/selected",
205 getNAV2SelRadial, setNAV2SelRadial);
206 current_properties.tieDouble("/radios/nav2/dme/distance",
208 current_properties.tieBool("/radios/nav2/in-range",
210 current_properties.tieBool("/radios/nav2/dme/in-range",
211 getNAV2DMEInRange, 0);
213 current_properties.tieDouble("/radios/adf/frequencies/selected",
214 getADFFreq, setADFFreq);
215 current_properties.tieDouble("/radios/adf/frequencies/standby",
216 getADFAltFreq, setADFAltFreq);
217 current_properties.tieDouble("/radios/adf/rotation",
218 getADFRotation, setADFRotation);
220 FG_LOG(FG_GENERAL, FG_INFO, "Ending BFI init");
225 * Reinitialize FGFS if required.
227 * Some changes (especially those in aircraft position) require that
228 * FGFS be reinitialized afterwards. Rather than reinitialize after
229 * every change, the setter methods simply set a flag so that there
230 * can be a single reinit at the end of the frame.
242 * Reinitialize FGFS to use the new BFI settings.
247 // Save the state of everything
248 // that's going to get clobbered
249 // when we reinit the subsystems.
251 cout << "BFI: start reinit\n";
253 setHeading(getHeading());
254 setPitch(getPitch());
256 setSpeedNorth(getSpeedNorth());
257 setSpeedEast(getSpeedEast());
258 setSpeedDown(getSpeedDown());
259 setLatitude(getLatitude());
260 setLongitude(getLongitude());
261 setAltitude(getAltitude());
263 // TODO: add more AP stuff
264 double elevator = getElevator();
265 double aileron = getAileron();
266 double rudder = getRudder();
267 double throttle = getThrottle();
268 double elevator_trim = getElevatorTrim();
269 double flaps = getFlaps();
270 double brake = getBrakes();
271 bool apHeadingLock = getAPHeadingLock();
272 double apHeadingMag = getAPHeadingMag();
273 bool apAltitudeLock = getAPAltitudeLock();
274 double apAltitude = getAPAltitude();
275 const string &targetAirport = getTargetAirport();
276 bool gpsLock = getGPSLock();
277 double gpsLatitude = getGPSTargetLatitude();
278 double gpsLongitude = getGPSTargetLongitude();
280 setTargetAirport("");
281 cout << "Target airport is " << current_options.get_airport_id() << endl;
283 fgReInitSubsystems();
285 // FIXME: this is wrong.
286 // All of these are scheduled events,
287 // and it should be possible to force
288 // them all to run once.
291 cur_light_params.Update();
293 fgUpdateWeatherDatabase();
296 // Restore all of the old states.
297 setElevator(elevator);
300 setThrottle(throttle);
301 setElevatorTrim(elevator_trim);
304 setAPHeadingLock(apHeadingLock);
305 setAPHeadingMag(apHeadingMag);
306 setAPAltitudeLock(apAltitudeLock);
307 setAPAltitude(apAltitude);
308 setTargetAirport(targetAirport);
310 setGPSTargetLatitude(gpsLatitude);
311 setGPSTargetLongitude(gpsLongitude);
315 cout << "BFI: end reinit\n";
320 ////////////////////////////////////////////////////////////////////////
322 ////////////////////////////////////////////////////////////////////////
326 * Return the flight model as an integer.
328 * TODO: use a string instead.
331 FGBFI::getFlightModel ()
333 return current_options.get_flight_model();
338 * Return the current aircraft as a string.
341 FGBFI::getAircraft ()
343 return current_options.get_aircraft();
348 * Return the current aircraft directory (UIUC) as a string.
351 FGBFI::getAircraftDir ()
358 * Set the flight model as an integer.
360 * TODO: use a string instead.
363 FGBFI::setFlightModel (int model)
365 current_options.set_flight_model(model);
371 * Set the current aircraft.
374 FGBFI::setAircraft (const string &aircraft)
376 current_options.set_aircraft(aircraft);
382 * Set the current aircraft directory (UIUC).
385 FGBFI::setAircraftDir (const string &dir)
393 * Return the current Zulu time.
398 return globals->get_time_params()->get_cur_time();
403 * Set the current Zulu time.
406 FGBFI::setTimeGMT (time_t time)
408 // FIXME: need to update lighting
410 current_options.set_time_offset(time);
411 current_options.set_time_offset_type(fgOPTIONS::FG_TIME_GMT_ABSOLUTE);
412 globals->get_time_params()->update( cur_fdm_state->get_Longitude(),
413 cur_fdm_state->get_Latitude(),
414 globals->get_warp() );
420 * Return true if the HUD is visible.
423 FGBFI::getHUDVisible ()
425 return current_options.get_hud_status();
430 * Ensure that the HUD is visible or hidden.
433 FGBFI::setHUDVisible (bool visible)
435 current_options.set_hud_status(visible);
440 * Return true if the 2D panel is visible.
443 FGBFI::getPanelVisible ()
445 return current_options.get_panel_status();
450 * Ensure that the 2D panel is visible or hidden.
453 FGBFI::setPanelVisible (bool visible)
455 if (current_options.get_panel_status() != visible) {
456 current_options.toggle_panel();
462 ////////////////////////////////////////////////////////////////////////
464 ////////////////////////////////////////////////////////////////////////
468 * Return the current latitude in degrees (negative for south).
471 FGBFI::getLatitude ()
473 return current_aircraft.fdm_state->get_Latitude() * RAD_TO_DEG;
478 * Set the current latitude in degrees (negative for south).
481 FGBFI::setLatitude (double latitude)
483 current_options.set_lat(latitude);
484 current_aircraft.fdm_state->set_Latitude(latitude * DEG_TO_RAD);
490 * Return the current longitude in degrees (negative for west).
493 FGBFI::getLongitude ()
495 return current_aircraft.fdm_state->get_Longitude() * RAD_TO_DEG;
500 * Set the current longitude in degrees (negative for west).
503 FGBFI::setLongitude (double longitude)
505 current_options.set_lon(longitude);
506 current_aircraft.fdm_state->set_Longitude(longitude * DEG_TO_RAD);
512 * Return the current altitude in feet.
515 FGBFI::getAltitude ()
517 return current_aircraft.fdm_state->get_Altitude();
523 * Return the current altitude in above the terrain.
528 return current_aircraft.fdm_state->get_Altitude()
529 - (scenery.cur_elev * METER_TO_FEET);
534 * Set the current altitude in feet.
537 FGBFI::setAltitude (double altitude)
539 fgFDMForceAltitude(getFlightModel(), altitude * FEET_TO_METER);
540 current_options.set_altitude(altitude * FEET_TO_METER);
541 current_aircraft.fdm_state->set_Altitude(altitude);
547 ////////////////////////////////////////////////////////////////////////
549 ////////////////////////////////////////////////////////////////////////
553 * Return the current heading in degrees.
558 return current_aircraft.fdm_state->get_Psi() * RAD_TO_DEG;
563 * Return the current heading in degrees.
566 FGBFI::getHeadingMag ()
568 return current_aircraft.fdm_state->get_Psi() * RAD_TO_DEG - getMagVar();
573 * Set the current heading in degrees.
576 FGBFI::setHeading (double heading)
578 current_options.set_heading(heading);
579 current_aircraft.fdm_state->set_Euler_Angles(getRoll() * DEG_TO_RAD,
580 getPitch() * DEG_TO_RAD,
581 heading * DEG_TO_RAD);
587 * Return the current pitch in degrees.
592 return current_aircraft.fdm_state->get_Theta() * RAD_TO_DEG;
597 * Set the current pitch in degrees.
600 FGBFI::setPitch (double pitch)
603 current_options.set_pitch(pitch);
604 current_aircraft.fdm_state->set_Euler_Angles(getRoll() * DEG_TO_RAD,
606 getHeading() * DEG_TO_RAD);
612 * Return the current roll in degrees.
617 return current_aircraft.fdm_state->get_Phi() * RAD_TO_DEG;
622 * Set the current roll in degrees.
625 FGBFI::setRoll (double roll)
627 current_options.set_roll(roll);
628 current_aircraft.fdm_state->set_Euler_Angles(roll * DEG_TO_RAD,
629 getPitch() * DEG_TO_RAD,
630 getHeading() * DEG_TO_RAD);
636 ////////////////////////////////////////////////////////////////////////
638 ////////////////////////////////////////////////////////////////////////
642 * Return the current airspeed in knots.
645 FGBFI::getAirspeed ()
647 // FIXME: should we add speed-up?
648 return current_aircraft.fdm_state->get_V_calibrated_kts();
653 * Return the current sideslip (FIXME: units unknown).
656 FGBFI::getSideSlip ()
658 return current_aircraft.fdm_state->get_Beta();
663 * Return the current climb rate in feet/minute
666 FGBFI::getVerticalSpeed ()
668 // What about meters?
669 return current_aircraft.fdm_state->get_Climb_Rate() * 60.0;
674 * Get the current north velocity (units??).
677 FGBFI::getSpeedNorth ()
679 return current_aircraft.fdm_state->get_V_north();
684 * Set the current north velocity (units??).
687 FGBFI::setSpeedNorth (double speed)
689 current_options.set_uBody(speed);
690 current_aircraft.fdm_state->set_Velocities_Local(speed,
698 * Get the current east velocity (units??).
701 FGBFI::getSpeedEast ()
703 return current_aircraft.fdm_state->get_V_east();
708 * Set the current east velocity (units??).
711 FGBFI::setSpeedEast (double speed)
713 current_options.set_vBody(speed);
714 current_aircraft.fdm_state->set_Velocities_Local(getSpeedNorth(),
722 * Get the current down velocity (units??).
725 FGBFI::getSpeedDown ()
727 return current_aircraft.fdm_state->get_V_down();
732 * Set the current down velocity (units??).
735 FGBFI::setSpeedDown (double speed)
737 current_options.set_wBody(speed);
738 current_aircraft.fdm_state->set_Velocities_Local(getSpeedNorth(),
746 ////////////////////////////////////////////////////////////////////////
748 ////////////////////////////////////////////////////////////////////////
752 * Get the throttle setting, from 0.0 (none) to 1.0 (full).
755 FGBFI::getThrottle ()
757 // FIXME: add throttle selector
758 return controls.get_throttle(0);
763 * Set the throttle, from 0.0 (none) to 1.0 (full).
766 FGBFI::setThrottle (double throttle)
768 // FIXME: allow throttle selection
770 controls.set_throttle(0, throttle);
775 * Get the flaps setting, from 0.0 (none) to 1.0 (full).
780 return controls.get_flaps();
785 * Set the flaps, from 0.0 (none) to 1.0 (full).
788 FGBFI::setFlaps (double flaps)
791 controls.set_flaps(flaps);
796 * Get the aileron, from -1.0 (left) to 1.0 (right).
801 return controls.get_aileron();
806 * Set the aileron, from -1.0 (left) to 1.0 (right).
809 FGBFI::setAileron (double aileron)
812 controls.set_aileron(aileron);
817 * Get the rudder setting, from -1.0 (left) to 1.0 (right).
822 return controls.get_rudder();
827 * Set the rudder, from -1.0 (left) to 1.0 (right).
830 FGBFI::setRudder (double rudder)
833 controls.set_rudder(rudder);
838 * Get the elevator setting, from -1.0 (down) to 1.0 (up).
841 FGBFI::getElevator ()
843 return controls.get_elevator();
848 * Set the elevator, from -1.0 (down) to 1.0 (up).
851 FGBFI::setElevator (double elevator)
854 controls.set_elevator(elevator);
859 * Get the elevator trim, from -1.0 (down) to 1.0 (up).
862 FGBFI::getElevatorTrim ()
864 return controls.get_elevator_trim();
869 * Set the elevator trim, from -1.0 (down) to 1.0 (up).
872 FGBFI::setElevatorTrim (double trim)
875 controls.set_elevator_trim(trim);
880 * Get the highest brake setting, from 0.0 (none) to 1.0 (full).
885 double b1 = getCenterBrake();
886 double b2 = getLeftBrake();
887 double b3 = getRightBrake();
888 return (b1 > b2 ? (b1 > b3 ? b1 : b3) : (b2 > b3 ? b2 : b3));
893 * Set all brakes, from 0.0 (none) to 1.0 (full).
896 FGBFI::setBrakes (double brake)
898 setCenterBrake(brake);
900 setRightBrake(brake);
905 * Get the center brake, from 0.0 (none) to 1.0 (full).
908 FGBFI::getCenterBrake ()
910 return controls.get_brake(2);
915 * Set the center brake, from 0.0 (none) to 1.0 (full).
918 FGBFI::setCenterBrake (double brake)
920 controls.set_brake(2, brake);
925 * Get the left brake, from 0.0 (none) to 1.0 (full).
928 FGBFI::getLeftBrake ()
930 return controls.get_brake(0);
935 * Set the left brake, from 0.0 (none) to 1.0 (full).
938 FGBFI::setLeftBrake (double brake)
940 controls.set_brake(0, brake);
945 * Get the right brake, from 0.0 (none) to 1.0 (full).
948 FGBFI::getRightBrake ()
950 return controls.get_brake(1);
955 * Set the right brake, from 0.0 (none) to 1.0 (full).
958 FGBFI::setRightBrake (double brake)
960 controls.set_brake(1, brake);
967 ////////////////////////////////////////////////////////////////////////
969 ////////////////////////////////////////////////////////////////////////
973 * Get the autopilot altitude lock (true=on).
976 FGBFI::getAPAltitudeLock ()
978 return current_autopilot->get_AltitudeEnabled();
983 * Set the autopilot altitude lock (true=on).
986 FGBFI::setAPAltitudeLock (bool lock)
988 current_autopilot->set_AltitudeMode(FGAutopilot::FG_ALTITUDE_LOCK);
989 current_autopilot->set_AltitudeEnabled(lock);
994 * Get the autopilot target altitude in feet.
997 FGBFI::getAPAltitude ()
999 return current_autopilot->get_TargetAltitude() * METER_TO_FEET;
1004 * Set the autopilot target altitude in feet.
1007 FGBFI::setAPAltitude (double altitude)
1009 current_autopilot->set_TargetAltitude( altitude );
1014 * Get the autopilot heading lock (true=on).
1017 FGBFI::getAPHeadingLock ()
1020 (current_autopilot->get_HeadingEnabled() &&
1021 current_autopilot->get_HeadingMode() == FGAutopilot::FG_HEADING_LOCK);
1026 * Set the autopilot heading lock (true=on).
1029 FGBFI::setAPHeadingLock (bool lock)
1032 // We need to do this so that
1033 // it's possible to lock onto a
1034 // heading other than the current
1036 double heading = getAPHeadingMag();
1037 current_autopilot->set_HeadingMode(FGAutopilot::FG_HEADING_LOCK);
1038 current_autopilot->set_HeadingEnabled(true);
1039 setAPHeadingMag(heading);
1040 } else if (current_autopilot->get_HeadingMode() ==
1041 FGAutopilot::FG_HEADING_LOCK) {
1042 current_autopilot->set_HeadingEnabled(false);
1048 * Get the autopilot target heading in degrees.
1051 FGBFI::getAPHeading ()
1053 return current_autopilot->get_TargetHeading();
1058 * Set the autopilot target heading in degrees.
1061 FGBFI::setAPHeading (double heading)
1063 current_autopilot->set_TargetHeading( heading );
1068 * Get the autopilot target heading in degrees.
1071 FGBFI::getAPHeadingMag ()
1073 return current_autopilot->get_TargetHeading() - getMagVar();
1078 * Set the autopilot target heading in degrees.
1081 FGBFI::setAPHeadingMag (double heading)
1083 current_autopilot->set_TargetHeading( heading + getMagVar() );
1088 * Return true if the autopilot is locked to NAV1.
1091 FGBFI::getAPNAV1Lock ()
1094 (current_autopilot->get_HeadingEnabled() &&
1095 current_autopilot->get_HeadingMode() == FGAutopilot::FG_HEADING_NAV1);
1100 * Set the autopilot NAV1 lock.
1103 FGBFI::setAPNAV1Lock (bool lock)
1106 current_autopilot->set_HeadingMode(FGAutopilot::FG_HEADING_NAV1);
1107 current_autopilot->set_HeadingEnabled(true);
1108 } else if (current_autopilot->get_HeadingMode() ==
1109 FGAutopilot::FG_HEADING_NAV1) {
1110 current_autopilot->set_HeadingEnabled(false);
1116 ////////////////////////////////////////////////////////////////////////
1117 // Radio navigation.
1118 ////////////////////////////////////////////////////////////////////////
1121 FGBFI::getNAV1Freq ()
1123 return current_radiostack->get_nav1_freq();
1127 FGBFI::getNAV1AltFreq ()
1129 return current_radiostack->get_nav1_alt_freq();
1133 FGBFI::getNAV1Radial ()
1135 return current_radiostack->get_nav1_radial();
1139 FGBFI::getNAV1SelRadial ()
1141 return current_radiostack->get_nav1_sel_radial();
1145 FGBFI::getNAV1DistDME ()
1147 return current_radiostack->get_nav1_dme_dist();
1151 FGBFI::getNAV1InRange ()
1153 return current_radiostack->get_nav1_inrange();
1157 FGBFI::getNAV1DMEInRange ()
1159 return (current_radiostack->get_nav1_inrange() &&
1160 current_radiostack->get_nav1_has_dme());
1164 FGBFI::getNAV2Freq ()
1166 return current_radiostack->get_nav2_freq();
1170 FGBFI::getNAV2AltFreq ()
1172 return current_radiostack->get_nav2_alt_freq();
1176 FGBFI::getNAV2Radial ()
1178 return current_radiostack->get_nav2_radial();
1182 FGBFI::getNAV2SelRadial ()
1184 return current_radiostack->get_nav2_sel_radial();
1188 FGBFI::getNAV2DistDME ()
1190 return current_radiostack->get_nav2_dme_dist();
1194 FGBFI::getNAV2InRange ()
1196 return current_radiostack->get_nav2_inrange();
1200 FGBFI::getNAV2DMEInRange ()
1202 return (current_radiostack->get_nav2_inrange() &&
1203 current_radiostack->get_nav2_has_dme());
1207 FGBFI::getADFFreq ()
1209 return current_radiostack->get_adf_freq();
1213 FGBFI::getADFAltFreq ()
1215 return current_radiostack->get_adf_alt_freq();
1219 FGBFI::getADFRotation ()
1221 return current_radiostack->get_adf_rotation();
1225 FGBFI::setNAV1Freq (double freq)
1227 current_radiostack->set_nav1_freq(freq);
1231 FGBFI::setNAV1AltFreq (double freq)
1233 current_radiostack->set_nav1_alt_freq(freq);
1237 FGBFI::setNAV1SelRadial (double radial)
1239 current_radiostack->set_nav1_sel_radial(radial);
1243 FGBFI::setNAV2Freq (double freq)
1245 current_radiostack->set_nav2_freq(freq);
1249 FGBFI::setNAV2AltFreq (double freq)
1251 current_radiostack->set_nav2_alt_freq(freq);
1255 FGBFI::setNAV2SelRadial (double radial)
1257 current_radiostack->set_nav2_sel_radial(radial);
1261 FGBFI::setADFFreq (double freq)
1263 current_radiostack->set_adf_freq(freq);
1267 FGBFI::setADFAltFreq (double freq)
1269 current_radiostack->set_adf_alt_freq(freq);
1273 FGBFI::setADFRotation (double rot)
1275 current_radiostack->set_adf_rotation(rot);
1280 ////////////////////////////////////////////////////////////////////////
1282 ////////////////////////////////////////////////////////////////////////
1286 * Get the autopilot GPS lock (true=on).
1289 FGBFI::getGPSLock ()
1291 return (current_autopilot->get_HeadingEnabled() &&
1292 (current_autopilot->get_HeadingMode() ==
1293 FGAutopilot::FG_HEADING_WAYPOINT ));
1298 * Set the autopilot GPS lock (true=on).
1301 FGBFI::setGPSLock (bool lock)
1304 current_autopilot->set_HeadingMode(FGAutopilot::FG_HEADING_WAYPOINT);
1305 current_autopilot->set_HeadingEnabled(true);
1306 } else if (current_autopilot->get_HeadingMode() ==
1307 FGAutopilot::FG_HEADING_WAYPOINT) {
1308 current_autopilot->set_HeadingEnabled(false);
1314 * Get the GPS target airport code.
1317 FGBFI::getTargetAirport ()
1319 return current_options.get_airport_id();
1324 * Set the GPS target airport code.
1327 FGBFI::setTargetAirport (const string &airportId)
1329 current_options.set_airport_id(airportId);
1334 * Get the GPS target latitude in degrees (negative for south).
1337 FGBFI::getGPSTargetLatitude ()
1339 return current_autopilot->get_TargetLatitude();
1344 * Set the GPS target latitude in degrees (negative for south).
1347 FGBFI::setGPSTargetLatitude (double latitude)
1349 current_autopilot->set_TargetLatitude( latitude );
1354 * Get the GPS target longitude in degrees (negative for west).
1357 FGBFI::getGPSTargetLongitude ()
1359 return current_autopilot->get_TargetLongitude();
1364 * Set the GPS target longitude in degrees (negative for west).
1367 FGBFI::setGPSTargetLongitude (double longitude)
1369 current_autopilot->set_TargetLongitude( longitude );
1374 ////////////////////////////////////////////////////////////////////////
1376 ////////////////////////////////////////////////////////////////////////
1380 * Get the current visible (units??).
1383 FGBFI::getVisibility ()
1385 #ifndef FG_OLD_WEATHER
1386 return WeatherDatabase->getWeatherVisibility();
1388 return current_weather.get_visibility();
1394 * Check whether clouds are enabled.
1399 return current_options.get_clouds();
1404 * Check the height of the clouds ASL (units?).
1407 FGBFI::getCloudsASL ()
1409 return current_options.get_clouds_asl();
1414 * Set the current visibility (units??).
1417 FGBFI::setVisibility (double visibility)
1419 #ifndef FG_OLD_WEATHER
1420 WeatherDatabase->setWeatherVisibility(visibility);
1422 current_weather.set_visibility(visibility);
1428 * Switch clouds on or off.
1431 FGBFI::setClouds (bool clouds)
1433 cout << "Set clouds to " << clouds << endl;
1434 current_options.set_clouds(clouds);
1440 * Set the cloud height.
1443 FGBFI::setCloudsASL (double cloudsASL)
1445 current_options.set_clouds_asl(cloudsASL);
1451 ////////////////////////////////////////////////////////////////////////
1453 ////////////////////////////////////////////////////////////////////////
1456 * Return the magnetic variation
1461 return globals->get_mag()->get_magvar() * RAD_TO_DEG;
1466 * Return the magnetic variation
1471 return globals->get_mag()->get_magdip() * RAD_TO_DEG;