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.tieBool ("/controls/flaps/raise",
144 current_properties.tieBool ("/controls/flaps/lower",
146 current_properties.tieDouble("/controls/aileron",
147 getAileron, setAileron);
148 current_properties.tieDouble("/controls/rudder",
149 getRudder, setRudder);
150 current_properties.tieDouble("/controls/elevator",
151 getElevator, setElevator);
152 current_properties.tieDouble("/controls/elevator-trim",
153 getElevatorTrim, setElevatorTrim);
154 current_properties.tieDouble("/controls/brake",
156 current_properties.tieDouble("/controls/left-brake",
157 getLeftBrake, setLeftBrake);
158 current_properties.tieDouble("/controls/right-brake",
159 getRightBrake, setRightBrake);
162 current_properties.tieBool("/autopilot/locks/altitude",
163 getAPAltitudeLock, setAPAltitudeLock);
164 current_properties.tieDouble("/autopilot/settings/altitude",
165 getAPAltitude, setAPAltitude);
166 current_properties.tieBool("/autopilot/locks/heading",
167 getAPHeadingLock, setAPHeadingLock);
168 current_properties.tieDouble("/autopilot/settings/heading-magnetic",
169 getAPHeadingMag, setAPHeadingMag);
170 current_properties.tieBool("/autopilot/locks/nav1",
171 getAPNAV1Lock, setAPNAV1Lock);
174 current_properties.tieDouble("/radios/nav1/frequencies/selected",
175 getNAV1Freq, setNAV1Freq);
176 current_properties.tieDouble("/radios/nav1/frequencies/standby",
177 getNAV1AltFreq, setNAV1AltFreq);
178 current_properties.tieDouble("/radios/nav1/radials/actual",
180 current_properties.tieDouble("/radios/nav1/radials/selected",
181 getNAV1SelRadial, setNAV1SelRadial);
182 current_properties.tieDouble("/radios/nav1/dme/distance",
184 current_properties.tieBool("/radios/nav1/in-range",
186 current_properties.tieBool("/radios/nav1/dme/in-range",
187 getNAV1DMEInRange, 0);
189 current_properties.tieDouble("/radios/nav2/frequencies/selected",
190 getNAV2Freq, setNAV2Freq);
191 current_properties.tieDouble("/radios/nav2/frequencies/standby",
192 getNAV2AltFreq, setNAV2AltFreq);
193 current_properties.tieDouble("/radios/nav2/radials/actual",
195 current_properties.tieDouble("/radios/nav2/radials/selected",
196 getNAV2SelRadial, setNAV2SelRadial);
197 current_properties.tieDouble("/radios/nav2/dme/distance",
199 current_properties.tieBool("/radios/nav2/in-range",
201 current_properties.tieBool("/radios/nav2/dme/in-range",
202 getNAV2DMEInRange, 0);
204 current_properties.tieDouble("/radios/adf/frequencies/selected",
205 getADFFreq, setADFFreq);
206 current_properties.tieDouble("/radios/adf/frequencies/standby",
207 getADFAltFreq, setADFAltFreq);
208 current_properties.tieDouble("/radios/adf/rotation",
209 getADFRotation, setADFRotation);
211 FG_LOG(FG_GENERAL, FG_INFO, "Ending BFI init");
216 * Reinitialize FGFS if required.
218 * Some changes (especially those in aircraft position) require that
219 * FGFS be reinitialized afterwards. Rather than reinitialize after
220 * every change, the setter methods simply set a flag so that there
221 * can be a single reinit at the end of the frame.
233 * Reinitialize FGFS to use the new BFI settings.
238 // Save the state of everything
239 // that's going to get clobbered
240 // when we reinit the subsystems.
242 cout << "BFI: start reinit\n";
244 setHeading(getHeading());
245 setPitch(getPitch());
247 setSpeedNorth(getSpeedNorth());
248 setSpeedEast(getSpeedEast());
249 setSpeedDown(getSpeedDown());
250 setLatitude(getLatitude());
251 setLongitude(getLongitude());
252 setAltitude(getAltitude());
254 // TODO: add more AP stuff
255 double elevator = getElevator();
256 double aileron = getAileron();
257 double rudder = getRudder();
258 double throttle = getThrottle();
259 double elevator_trim = getElevatorTrim();
260 double flaps = getFlaps();
261 double brake = getBrake();
262 bool apHeadingLock = getAPHeadingLock();
263 double apHeadingMag = getAPHeadingMag();
264 bool apAltitudeLock = getAPAltitudeLock();
265 double apAltitude = getAPAltitude();
266 const string &targetAirport = getTargetAirport();
267 bool gpsLock = getGPSLock();
268 double gpsLatitude = getGPSTargetLatitude();
269 double gpsLongitude = getGPSTargetLongitude();
271 setTargetAirport("");
272 cout << "Target airport is " << current_options.get_airport_id() << endl;
274 fgReInitSubsystems();
276 // FIXME: this is wrong.
277 // All of these are scheduled events,
278 // and it should be possible to force
279 // them all to run once.
282 cur_light_params.Update();
284 fgUpdateWeatherDatabase();
287 // Restore all of the old states.
288 setElevator(elevator);
291 setThrottle(throttle);
292 setElevatorTrim(elevator_trim);
295 setAPHeadingLock(apHeadingLock);
296 setAPHeadingMag(apHeadingMag);
297 setAPAltitudeLock(apAltitudeLock);
298 setAPAltitude(apAltitude);
299 setTargetAirport(targetAirport);
301 setGPSTargetLatitude(gpsLatitude);
302 setGPSTargetLongitude(gpsLongitude);
306 cout << "BFI: end reinit\n";
311 ////////////////////////////////////////////////////////////////////////
313 ////////////////////////////////////////////////////////////////////////
317 * Return the flight model as an integer.
319 * TODO: use a string instead.
322 FGBFI::getFlightModel ()
324 return current_options.get_flight_model();
329 * Return the current aircraft as a string.
332 FGBFI::getAircraft ()
334 return current_options.get_aircraft();
339 * Return the current aircraft directory (UIUC) as a string.
342 FGBFI::getAircraftDir ()
349 * Set the flight model as an integer.
351 * TODO: use a string instead.
354 FGBFI::setFlightModel (int model)
356 current_options.set_flight_model(model);
362 * Set the current aircraft.
365 FGBFI::setAircraft (const string &aircraft)
367 current_options.set_aircraft(aircraft);
373 * Set the current aircraft directory (UIUC).
376 FGBFI::setAircraftDir (const string &dir)
384 * Return the current Zulu time.
389 return globals->get_time_params()->get_cur_time();
394 * Set the current Zulu time.
397 FGBFI::setTimeGMT (time_t time)
399 // FIXME: need to update lighting
401 current_options.set_time_offset(time);
402 current_options.set_time_offset_type(fgOPTIONS::FG_TIME_GMT_ABSOLUTE);
403 globals->get_time_params()->update( cur_fdm_state->get_Longitude(),
404 cur_fdm_state->get_Latitude(),
405 globals->get_warp() );
411 * Return true if the HUD is visible.
414 FGBFI::getHUDVisible ()
416 return current_options.get_hud_status();
421 * Ensure that the HUD is visible or hidden.
424 FGBFI::setHUDVisible (bool visible)
426 current_options.set_hud_status(visible);
431 * Return true if the 2D panel is visible.
434 FGBFI::getPanelVisible ()
436 return current_options.get_panel_status();
441 * Ensure that the 2D panel is visible or hidden.
444 FGBFI::setPanelVisible (bool visible)
446 if (current_options.get_panel_status() != visible) {
447 current_options.toggle_panel();
453 ////////////////////////////////////////////////////////////////////////
455 ////////////////////////////////////////////////////////////////////////
459 * Return the current latitude in degrees (negative for south).
462 FGBFI::getLatitude ()
464 return current_aircraft.fdm_state->get_Latitude() * RAD_TO_DEG;
469 * Set the current latitude in degrees (negative for south).
472 FGBFI::setLatitude (double latitude)
474 current_options.set_lat(latitude);
475 current_aircraft.fdm_state->set_Latitude(latitude * DEG_TO_RAD);
481 * Return the current longitude in degrees (negative for west).
484 FGBFI::getLongitude ()
486 return current_aircraft.fdm_state->get_Longitude() * RAD_TO_DEG;
491 * Set the current longitude in degrees (negative for west).
494 FGBFI::setLongitude (double longitude)
496 current_options.set_lon(longitude);
497 current_aircraft.fdm_state->set_Longitude(longitude * DEG_TO_RAD);
503 * Return the current altitude in feet.
506 FGBFI::getAltitude ()
508 return current_aircraft.fdm_state->get_Altitude();
514 * Return the current altitude in above the terrain.
519 return current_aircraft.fdm_state->get_Altitude()
520 - (scenery.cur_elev * METER_TO_FEET);
525 * Set the current altitude in feet.
528 FGBFI::setAltitude (double altitude)
530 fgFDMForceAltitude(getFlightModel(), altitude * FEET_TO_METER);
531 // current_options.set_altitude(altitude * FEET_TO_METER);
532 // current_aircraft.fdm_state->set_Altitude(altitude);
538 ////////////////////////////////////////////////////////////////////////
540 ////////////////////////////////////////////////////////////////////////
544 * Return the current heading in degrees.
549 return current_aircraft.fdm_state->get_Psi() * RAD_TO_DEG;
554 * Return the current heading in degrees.
557 FGBFI::getHeadingMag ()
559 return current_aircraft.fdm_state->get_Psi() * RAD_TO_DEG - getMagVar();
564 * Set the current heading in degrees.
567 FGBFI::setHeading (double heading)
569 current_options.set_heading(heading);
570 current_aircraft.fdm_state->set_Euler_Angles(getRoll() * DEG_TO_RAD,
571 getPitch() * DEG_TO_RAD,
572 heading * DEG_TO_RAD);
578 * Return the current pitch in degrees.
583 return current_aircraft.fdm_state->get_Theta() * RAD_TO_DEG;
588 * Set the current pitch in degrees.
591 FGBFI::setPitch (double pitch)
594 current_options.set_pitch(pitch);
595 current_aircraft.fdm_state->set_Euler_Angles(getRoll() * DEG_TO_RAD,
597 getHeading() * DEG_TO_RAD);
603 * Return the current roll in degrees.
608 return current_aircraft.fdm_state->get_Phi() * RAD_TO_DEG;
613 * Set the current roll in degrees.
616 FGBFI::setRoll (double roll)
618 current_options.set_roll(roll);
619 current_aircraft.fdm_state->set_Euler_Angles(roll * DEG_TO_RAD,
620 getPitch() * DEG_TO_RAD,
621 getHeading() * DEG_TO_RAD);
627 ////////////////////////////////////////////////////////////////////////
629 ////////////////////////////////////////////////////////////////////////
633 * Return the current airspeed in knots.
636 FGBFI::getAirspeed ()
638 // FIXME: should we add speed-up?
639 return current_aircraft.fdm_state->get_V_calibrated_kts();
644 * Return the current sideslip (FIXME: units unknown).
647 FGBFI::getSideSlip ()
649 return current_aircraft.fdm_state->get_Beta();
654 * Return the current climb rate in feet/minute
657 FGBFI::getVerticalSpeed ()
659 // What about meters?
660 return current_aircraft.fdm_state->get_Climb_Rate() * 60.0;
665 * Get the current north velocity (units??).
668 FGBFI::getSpeedNorth ()
670 return current_aircraft.fdm_state->get_V_north();
675 * Set the current north velocity (units??).
678 FGBFI::setSpeedNorth (double speed)
680 current_options.set_uBody(speed);
681 current_aircraft.fdm_state->set_Velocities_Local(speed,
689 * Get the current east velocity (units??).
692 FGBFI::getSpeedEast ()
694 return current_aircraft.fdm_state->get_V_east();
699 * Set the current east velocity (units??).
702 FGBFI::setSpeedEast (double speed)
704 current_options.set_vBody(speed);
705 current_aircraft.fdm_state->set_Velocities_Local(getSpeedNorth(),
713 * Get the current down velocity (units??).
716 FGBFI::getSpeedDown ()
718 return current_aircraft.fdm_state->get_V_down();
723 * Set the current down velocity (units??).
726 FGBFI::setSpeedDown (double speed)
728 current_options.set_wBody(speed);
729 current_aircraft.fdm_state->set_Velocities_Local(getSpeedNorth(),
737 ////////////////////////////////////////////////////////////////////////
739 ////////////////////////////////////////////////////////////////////////
743 * Get the throttle setting, from 0.0 (none) to 1.0 (full).
746 FGBFI::getThrottle ()
748 // FIXME: add throttle selector
749 return controls.get_throttle(0);
754 * Set the throttle, from 0.0 (none) to 1.0 (full).
757 FGBFI::setThrottle (double throttle)
759 // FIXME: allow throttle selection
761 controls.set_throttle(0, throttle);
766 * Get the flaps setting, from 0.0 (none) to 1.0 (full).
771 return controls.get_flaps();
776 * Set the flaps, from 0.0 (none) to 1.0 (full).
779 FGBFI::setFlaps (double flaps)
782 controls.set_flaps(flaps);
787 FGBFI::setFlapsRaise (bool step)
790 controls.set_flaps(controls.get_flaps() - 0.26);
791 printf ( "Raise: %i\n", step );
796 FGBFI::setFlapsLower (bool step)
799 controls.set_flaps(controls.get_flaps() + 0.26);
800 printf ( "Lower: %i\n", step );
805 * Get the aileron, from -1.0 (left) to 1.0 (right).
810 return controls.get_aileron();
815 * Set the aileron, from -1.0 (left) to 1.0 (right).
818 FGBFI::setAileron (double aileron)
821 controls.set_aileron(aileron);
826 * Get the rudder setting, from -1.0 (left) to 1.0 (right).
831 return controls.get_rudder();
836 * Set the rudder, from -1.0 (left) to 1.0 (right).
839 FGBFI::setRudder (double rudder)
842 controls.set_rudder(rudder);
847 * Get the elevator setting, from -1.0 (down) to 1.0 (up).
850 FGBFI::getElevator ()
852 return controls.get_elevator();
857 * Set the elevator, from -1.0 (down) to 1.0 (up).
860 FGBFI::setElevator (double elevator)
863 controls.set_elevator(elevator);
868 * Get the elevator trim, from -1.0 (down) to 1.0 (up).
871 FGBFI::getElevatorTrim ()
873 return controls.get_elevator_trim();
878 * Set the elevator trim, from -1.0 (down) to 1.0 (up).
881 FGBFI::setElevatorTrim (double trim)
884 controls.set_elevator_trim(trim);
889 * Get the brake setting, from 0.0 (none) to 1.0 (full).
894 // FIXME: add brake selector
895 return controls.get_brake(2);
900 * Set the brake, from 0.0 (none) to 1.0 (full).
903 FGBFI::setBrake (double brake)
905 controls.set_brake(FGControls::ALL_WHEELS, brake);
910 * Get the left brake, from 0.0 (none) to 1.0 (full).
913 FGBFI::getLeftBrake ()
915 return controls.get_brake(0);
920 * Set the left brake, from 0.0 (none) to 1.0 (full).
923 FGBFI::setLeftBrake (double brake)
925 controls.set_brake(0, brake);
930 * Get the right brake, from 0.0 (none) to 1.0 (full).
933 FGBFI::getRightBrake ()
935 return controls.get_brake(1);
940 * Set the right brake, from 0.0 (none) to 1.0 (full).
943 FGBFI::setRightBrake (double brake)
945 controls.set_brake(1, brake);
952 ////////////////////////////////////////////////////////////////////////
954 ////////////////////////////////////////////////////////////////////////
958 * Get the autopilot altitude lock (true=on).
961 FGBFI::getAPAltitudeLock ()
963 return current_autopilot->get_AltitudeEnabled();
968 * Set the autopilot altitude lock (true=on).
971 FGBFI::setAPAltitudeLock (bool lock)
973 current_autopilot->set_AltitudeMode(FGAutopilot::FG_ALTITUDE_LOCK);
974 current_autopilot->set_AltitudeEnabled(lock);
979 * Get the autopilot target altitude in feet.
982 FGBFI::getAPAltitude ()
984 return current_autopilot->get_TargetAltitude() * METER_TO_FEET;
989 * Set the autopilot target altitude in feet.
992 FGBFI::setAPAltitude (double altitude)
994 current_autopilot->set_TargetAltitude( altitude );
999 * Get the autopilot heading lock (true=on).
1002 FGBFI::getAPHeadingLock ()
1005 (current_autopilot->get_HeadingEnabled() &&
1006 current_autopilot->get_HeadingMode() == FGAutopilot::FG_HEADING_LOCK);
1011 * Set the autopilot heading lock (true=on).
1014 FGBFI::setAPHeadingLock (bool lock)
1017 // We need to do this so that
1018 // it's possible to lock onto a
1019 // heading other than the current
1021 double heading = getAPHeadingMag();
1022 current_autopilot->set_HeadingMode(FGAutopilot::FG_HEADING_LOCK);
1023 current_autopilot->set_HeadingEnabled(true);
1024 setAPHeadingMag(heading);
1025 } else if (current_autopilot->get_HeadingMode() ==
1026 FGAutopilot::FG_HEADING_LOCK) {
1027 current_autopilot->set_HeadingEnabled(false);
1033 * Get the autopilot target heading in degrees.
1036 FGBFI::getAPHeadingMag ()
1038 return current_autopilot->get_TargetHeading() - getMagVar();
1043 * Set the autopilot target heading in degrees.
1046 FGBFI::setAPHeadingMag (double heading)
1048 current_autopilot->set_TargetHeading( heading + getMagVar() );
1053 * Return true if the autopilot is locked to NAV1.
1056 FGBFI::getAPNAV1Lock ()
1059 (current_autopilot->get_HeadingEnabled() &&
1060 current_autopilot->get_HeadingMode() == FGAutopilot::FG_HEADING_NAV1);
1065 * Set the autopilot NAV1 lock.
1068 FGBFI::setAPNAV1Lock (bool lock)
1071 current_autopilot->set_HeadingMode(FGAutopilot::FG_HEADING_NAV1);
1072 current_autopilot->set_HeadingEnabled(true);
1073 } else if (current_autopilot->get_HeadingMode() ==
1074 FGAutopilot::FG_HEADING_NAV1) {
1075 current_autopilot->set_HeadingEnabled(false);
1081 ////////////////////////////////////////////////////////////////////////
1082 // Radio navigation.
1083 ////////////////////////////////////////////////////////////////////////
1086 FGBFI::getNAV1Freq ()
1088 return current_radiostack->get_nav1_freq();
1092 FGBFI::getNAV1AltFreq ()
1094 return current_radiostack->get_nav1_alt_freq();
1098 FGBFI::getNAV1Radial ()
1100 return current_radiostack->get_nav1_radial();
1104 FGBFI::getNAV1SelRadial ()
1106 return current_radiostack->get_nav1_sel_radial();
1110 FGBFI::getNAV1DistDME ()
1112 return current_radiostack->get_nav1_dme_dist();
1116 FGBFI::getNAV1InRange ()
1118 return current_radiostack->get_nav1_inrange();
1122 FGBFI::getNAV1DMEInRange ()
1124 return (current_radiostack->get_nav1_inrange() &&
1125 current_radiostack->get_nav1_has_dme());
1129 FGBFI::getNAV2Freq ()
1131 return current_radiostack->get_nav2_freq();
1135 FGBFI::getNAV2AltFreq ()
1137 return current_radiostack->get_nav2_alt_freq();
1141 FGBFI::getNAV2Radial ()
1143 return current_radiostack->get_nav2_radial();
1147 FGBFI::getNAV2SelRadial ()
1149 return current_radiostack->get_nav2_sel_radial();
1153 FGBFI::getNAV2DistDME ()
1155 return current_radiostack->get_nav2_dme_dist();
1159 FGBFI::getNAV2InRange ()
1161 return current_radiostack->get_nav2_inrange();
1165 FGBFI::getNAV2DMEInRange ()
1167 return (current_radiostack->get_nav2_inrange() &&
1168 current_radiostack->get_nav2_has_dme());
1172 FGBFI::getADFFreq ()
1174 return current_radiostack->get_adf_freq();
1178 FGBFI::getADFAltFreq ()
1180 return current_radiostack->get_adf_alt_freq();
1184 FGBFI::getADFRotation ()
1186 return current_radiostack->get_adf_rotation();
1190 FGBFI::setNAV1Freq (double freq)
1192 current_radiostack->set_nav1_freq(freq);
1196 FGBFI::setNAV1AltFreq (double freq)
1198 current_radiostack->set_nav1_alt_freq(freq);
1202 FGBFI::setNAV1SelRadial (double radial)
1204 current_radiostack->set_nav1_sel_radial(radial);
1208 FGBFI::setNAV2Freq (double freq)
1210 current_radiostack->set_nav2_freq(freq);
1214 FGBFI::setNAV2AltFreq (double freq)
1216 current_radiostack->set_nav2_alt_freq(freq);
1220 FGBFI::setNAV2SelRadial (double radial)
1222 current_radiostack->set_nav2_sel_radial(radial);
1226 FGBFI::setADFFreq (double freq)
1228 current_radiostack->set_adf_freq(freq);
1232 FGBFI::setADFAltFreq (double freq)
1234 current_radiostack->set_adf_alt_freq(freq);
1238 FGBFI::setADFRotation (double rot)
1240 current_radiostack->set_adf_rotation(rot);
1245 ////////////////////////////////////////////////////////////////////////
1247 ////////////////////////////////////////////////////////////////////////
1251 * Get the autopilot GPS lock (true=on).
1254 FGBFI::getGPSLock ()
1256 return (current_autopilot->get_HeadingEnabled() &&
1257 (current_autopilot->get_HeadingMode() ==
1258 FGAutopilot::FG_HEADING_WAYPOINT ));
1263 * Set the autopilot GPS lock (true=on).
1266 FGBFI::setGPSLock (bool lock)
1269 current_autopilot->set_HeadingMode(FGAutopilot::FG_HEADING_WAYPOINT);
1270 current_autopilot->set_HeadingEnabled(true);
1271 } else if (current_autopilot->get_HeadingMode() ==
1272 FGAutopilot::FG_HEADING_WAYPOINT) {
1273 current_autopilot->set_HeadingEnabled(false);
1279 * Get the GPS target airport code.
1282 FGBFI::getTargetAirport ()
1284 return current_options.get_airport_id();
1289 * Set the GPS target airport code.
1292 FGBFI::setTargetAirport (const string &airportId)
1294 current_options.set_airport_id(airportId);
1299 * Get the GPS target latitude in degrees (negative for south).
1302 FGBFI::getGPSTargetLatitude ()
1304 return current_autopilot->get_TargetLatitude();
1309 * Set the GPS target latitude in degrees (negative for south).
1312 FGBFI::setGPSTargetLatitude (double latitude)
1314 current_autopilot->set_TargetLatitude( latitude );
1319 * Get the GPS target longitude in degrees (negative for west).
1322 FGBFI::getGPSTargetLongitude ()
1324 return current_autopilot->get_TargetLongitude();
1329 * Set the GPS target longitude in degrees (negative for west).
1332 FGBFI::setGPSTargetLongitude (double longitude)
1334 current_autopilot->set_TargetLongitude( longitude );
1339 ////////////////////////////////////////////////////////////////////////
1341 ////////////////////////////////////////////////////////////////////////
1345 * Get the current visible (units??).
1348 FGBFI::getVisibility ()
1350 #ifndef FG_OLD_WEATHER
1351 return WeatherDatabase->getWeatherVisibility();
1353 return current_weather.get_visibility();
1359 * Check whether clouds are enabled.
1364 return current_options.get_clouds();
1369 * Check the height of the clouds ASL (units?).
1372 FGBFI::getCloudsASL ()
1374 return current_options.get_clouds_asl();
1379 * Set the current visibility (units??).
1382 FGBFI::setVisibility (double visibility)
1384 #ifndef FG_OLD_WEATHER
1385 WeatherDatabase->setWeatherVisibility(visibility);
1387 current_weather.set_visibility(visibility);
1393 * Switch clouds on or off.
1396 FGBFI::setClouds (bool clouds)
1398 cout << "Set clouds to " << clouds << endl;
1399 current_options.set_clouds(clouds);
1405 * Set the cloud height.
1408 FGBFI::setCloudsASL (double cloudsASL)
1410 current_options.set_clouds_asl(cloudsASL);
1416 ////////////////////////////////////////////////////////////////////////
1418 ////////////////////////////////////////////////////////////////////////
1421 * Return the magnetic variation
1426 return cur_magvar.get_magvar() * RAD_TO_DEG;
1431 * Return the magnetic variation
1436 return cur_magvar.get_magdip() * RAD_TO_DEG;