]> git.mxchange.org Git - flightgear.git/blob - src/Main/bfi.cxx
Fixes to ILS approaches ... now takes into consideration actual GS and DME
[flightgear.git] / src / Main / bfi.cxx
1 // bfi.cxx - Big Friendly Interface implementation
2 //
3 // Written by David Megginson, started February, 2000.
4 //
5 // Copyright (C) 2000  David Megginson - david@megginson.com
6 //
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.
11 //
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.
16 //
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.
20 //
21 // $Id$
22
23
24 #ifdef HAVE_CONFIG_H
25 #  include <config.h>
26 #endif
27
28 #if defined( FG_HAVE_NATIVE_SGI_COMPILERS )
29 #  include <iostream.h>
30 #else
31 #  include <iostream>
32 #endif
33
34 #include <simgear/constants.h>
35 #include <simgear/debug/logstream.hxx>
36 #include <simgear/math/fg_types.hxx>
37
38 #include <Aircraft/aircraft.hxx>
39 #include <FDM/UIUCModel/uiuc_aircraftdir.h>
40 #include <Controls/controls.hxx>
41 #include <Autopilot/newauto.hxx>
42 #include <Scenery/scenery.hxx>
43 #include <Time/fg_time.hxx>
44 #include <Time/light.hxx>
45 #include <Cockpit/radiostack.hxx>
46 #ifndef FG_OLD_WEATHER
47 #  include <WeatherCM/FGLocalWeatherDatabase.h>
48 #else
49 #  include <Weather/weather.hxx>
50 #endif
51
52 #include "options.hxx"
53 #include "save.hxx"
54 #include "fg_init.hxx"
55
56 FG_USING_NAMESPACE(std);
57
58                                 // FIXME: these are not part of the
59                                 // published interface!!!
60 // extern fgAPDataPtr APDataGlobal;
61 // extern void fgAPAltitudeSet (double new_altitude);
62 // extern void fgAPHeadingSet (double new_heading);
63
64
65 #include "bfi.hxx"
66
67
68 \f
69 ////////////////////////////////////////////////////////////////////////
70 // Static variables.
71 ////////////////////////////////////////////////////////////////////////
72
73 bool FGBFI::_needReinit = false;
74
75
76 \f
77 ////////////////////////////////////////////////////////////////////////
78 // Local functions
79 ////////////////////////////////////////////////////////////////////////
80
81
82 /**
83  * Reinitialize FGFS if required.
84  *
85  * Some changes (especially those in aircraft position) require that
86  * FGFS be reinitialized afterwards.  Rather than reinitialize after
87  * every change, the setter methods simply set a flag so that there
88  * can be a single reinit at the end of the frame.
89  */
90 void
91 FGBFI::update ()
92 {
93   if (_needReinit) {
94     reinit();
95   }
96 }
97
98
99 /**
100  * Reinitialize FGFS to use the new BFI settings.
101  */
102 void
103 FGBFI::reinit ()
104 {
105                                 // Save the state of everything
106                                 // that's going to get clobbered
107                                 // when we reinit the subsystems.
108
109   cout << "BFI: start reinit\n";
110
111                                 // TODO: add more AP stuff
112   double elevator = getElevator();
113   double aileron = getAileron();
114   double rudder = getRudder();
115   double throttle = getThrottle();
116   double elevator_trim = getElevatorTrim();
117   double flaps = getFlaps();
118   double brake = getBrake();
119   bool apHeadingLock = getAPHeadingLock();
120   double apHeading = getAPHeading();
121   bool apAltitudeLock = getAPAltitudeLock();
122   double apAltitude = getAPAltitude();
123   const string &targetAirport = getTargetAirport();
124   bool gpsLock = getGPSLock();
125   double gpsLatitude = getGPSTargetLatitude();
126   double gpsLongitude = getGPSTargetLongitude();
127
128   fgReInitSubsystems();
129   // solarSystemRebuild();
130   cur_light_params.Update();
131
132                                 // Restore all of the old states.
133   setElevator(elevator);
134   setAileron(aileron);
135   setRudder(rudder);
136   setThrottle(throttle);
137   setElevatorTrim(elevator_trim);
138   setFlaps(flaps);
139   setBrake(brake);
140   setAPHeadingLock(apHeadingLock);
141   setAPHeading(apHeading);
142   setAPAltitudeLock(apAltitudeLock);
143   setAPAltitude(apAltitude);
144   setTargetAirport(targetAirport);
145   setGPSLock(gpsLock);
146   setGPSTargetLatitude(gpsLatitude);
147   setGPSTargetLongitude(gpsLongitude);
148
149   _needReinit = false;
150
151   cout << "BFI: end reinit\n";
152 }
153
154
155 \f
156 ////////////////////////////////////////////////////////////////////////
157 // Simulation.
158 ////////////////////////////////////////////////////////////////////////
159
160
161 /**
162  * Return the flight model as an integer.
163  *
164  * TODO: use a string instead.
165  */
166 int
167 FGBFI::getFlightModel ()
168 {
169   return current_options.get_flight_model();
170 }
171
172
173 /**
174  * Return the current aircraft as a string.
175  */
176 const string
177 FGBFI::getAircraft ()
178 {
179   return current_options.get_aircraft();
180 }
181
182
183 /**
184  * Return the current aircraft directory (UIUC) as a string.
185  */
186 const string
187 FGBFI::getAircraftDir ()
188 {
189   return aircraft_dir;
190 }
191
192
193 /**
194  * Set the flight model as an integer.
195  *
196  * TODO: use a string instead.
197  */
198 void
199 FGBFI::setFlightModel (int model)
200 {
201   current_options.set_flight_model(model);
202   needReinit();
203 }
204
205
206 /**
207  * Set the current aircraft.
208  */
209 void
210 FGBFI::setAircraft (const string &aircraft)
211 {
212   current_options.set_aircraft(aircraft);
213   needReinit();
214 }
215
216
217 /**
218  * Set the current aircraft directory (UIUC).
219  */
220 void
221 FGBFI::setAircraftDir (const string &dir)
222 {
223   aircraft_dir = dir;
224   needReinit();
225 }
226
227
228 /**
229  * Return the current Zulu time.
230  */
231 time_t
232 FGBFI::getTimeGMT ()
233 {
234                                 // FIXME: inefficient
235   return mktime(FGTime::cur_time_params->getGmt());
236 }
237
238
239 /**
240  * Set the current Zulu time.
241  */
242 void
243 FGBFI::setTimeGMT (time_t time)
244 {
245                                 // FIXME: need to update lighting
246                                 // and solar system
247   current_options.set_time_offset(time);
248   current_options.set_time_offset_type(fgOPTIONS::FG_TIME_GMT_ABSOLUTE);
249   FGTime::cur_time_params->init( cur_fdm_state->get_Longitude(),
250                                  cur_fdm_state->get_Latitude() );
251   FGTime::cur_time_params->update( cur_fdm_state->get_Longitude(),
252                                    cur_fdm_state->get_Latitude(),
253                                    cur_fdm_state->get_Altitude()
254                                    * FEET_TO_METER );
255   needReinit();
256 }
257
258
259 /**
260  * Return true if the HUD is visible.
261  */
262 bool
263 FGBFI::getHUDVisible ()
264 {
265   return current_options.get_hud_status();
266 }
267
268
269 /**
270  * Ensure that the HUD is visible or hidden.
271  */
272 void
273 FGBFI::setHUDVisible (bool visible)
274 {
275   current_options.set_hud_status(visible);
276 }
277
278
279 /**
280  * Return true if the 2D panel is visible.
281  */
282 bool
283 FGBFI::getPanelVisible ()
284 {
285   return current_options.get_panel_status();
286 }
287
288
289 /**
290  * Ensure that the 2D panel is visible or hidden.
291  */
292 void
293 FGBFI::setPanelVisible (bool visible)
294 {
295   if (current_options.get_panel_status() != visible) {
296     current_options.toggle_panel();
297   }
298 }
299
300
301 \f
302 ////////////////////////////////////////////////////////////////////////
303 // Position
304 ////////////////////////////////////////////////////////////////////////
305
306
307 /**
308  * Return the current latitude in degrees (negative for south).
309  */
310 double
311 FGBFI::getLatitude ()
312 {
313   return current_aircraft.fdm_state->get_Latitude() * RAD_TO_DEG;
314 }
315
316
317 /**
318  * Set the current latitude in degrees (negative for south).
319  */
320 void
321 FGBFI::setLatitude (double latitude)
322 {
323   current_options.set_lat(latitude);
324   needReinit();
325 }
326
327
328 /**
329  * Return the current longitude in degrees (negative for west).
330  */
331 double
332 FGBFI::getLongitude ()
333 {
334   return current_aircraft.fdm_state->get_Longitude() * RAD_TO_DEG;
335 }
336
337
338 /**
339  * Set the current longitude in degrees (negative for west).
340  */
341 void
342 FGBFI::setLongitude (double longitude)
343 {
344   current_options.set_lon(longitude);
345   needReinit();
346 }
347
348
349 /**
350  * Return the current altitude in feet.
351  */
352 double
353 FGBFI::getAltitude ()
354 {
355   return current_aircraft.fdm_state->get_Altitude();
356 }
357
358
359
360 /**
361  * Return the current altitude in above the terrain.
362  */
363 double
364 FGBFI::getAGL ()
365 {
366   return current_aircraft.fdm_state->get_Altitude()
367          - scenery.cur_elev * METER_TO_FEET;
368 }
369
370
371 /**
372  * Set the current altitude in feet.
373  */
374 void
375 FGBFI::setAltitude (double altitude)
376 {
377   current_options.set_altitude(altitude * FEET_TO_METER);
378   needReinit();
379 }
380
381
382 \f
383 ////////////////////////////////////////////////////////////////////////
384 // Attitude
385 ////////////////////////////////////////////////////////////////////////
386
387
388 /**
389  * Return the current heading in degrees.
390  */
391 double
392 FGBFI::getHeading ()
393 {
394   return current_aircraft.fdm_state->get_Psi() * RAD_TO_DEG;
395 }
396
397
398 /**
399  * Set the current heading in degrees.
400  */
401 void
402 FGBFI::setHeading (double heading)
403 {
404   current_options.set_heading(heading);
405   needReinit();
406 }
407
408
409 /**
410  * Return the current pitch in degrees.
411  */
412 double
413 FGBFI::getPitch ()
414 {
415   return current_aircraft.fdm_state->get_Theta() * RAD_TO_DEG;
416 }
417
418
419 /**
420  * Set the current pitch in degrees.
421  */
422 void
423 FGBFI::setPitch (double pitch)
424 {
425
426   current_options.set_pitch(pitch);
427   needReinit();
428 }
429
430
431 /**
432  * Return the current roll in degrees.
433  */
434 double
435 FGBFI::getRoll ()
436 {
437   return current_aircraft.fdm_state->get_Phi() * RAD_TO_DEG;
438 }
439
440
441 /**
442  * Set the current roll in degrees.
443  */
444 void
445 FGBFI::setRoll (double roll)
446 {
447   current_options.set_roll(roll);
448   needReinit();
449 }
450
451
452 \f
453 ////////////////////////////////////////////////////////////////////////
454 // Velocities
455 ////////////////////////////////////////////////////////////////////////
456
457
458 /**
459  * Return the current airspeed in knots.
460  */
461 double
462 FGBFI::getAirspeed ()
463 {
464                                 // FIXME: should we add speed-up?
465   return current_aircraft.fdm_state->get_V_calibrated_kts();
466 }
467
468
469 /**
470  * Return the current sideslip (FIXME: units unknown).
471  */
472 double
473 FGBFI::getSideSlip ()
474 {
475   return current_aircraft.fdm_state->get_Beta();
476 }
477
478
479 /**
480  * Return the current climb rate in feet/minute
481  */
482 double
483 FGBFI::getVerticalSpeed ()
484 {
485                                 // What about meters?
486   return current_aircraft.fdm_state->get_Climb_Rate() * 60.0;
487 }
488
489
490 /**
491  * Get the current north velocity (units??).
492  */
493 double
494 FGBFI::getSpeedNorth ()
495 {
496   return current_aircraft.fdm_state->get_V_north();
497 }
498
499
500 /**
501  * Set the current north velocity (units??).
502  */
503 void
504 FGBFI::setSpeedNorth (double speed)
505 {
506   current_options.set_uBody(speed);
507   needReinit();
508 }
509
510
511 /**
512  * Get the current east velocity (units??).
513  */
514 double
515 FGBFI::getSpeedEast ()
516 {
517   return current_aircraft.fdm_state->get_V_east();
518 }
519
520
521 /**
522  * Set the current east velocity (units??).
523  */
524 void
525 FGBFI::setSpeedEast (double speed)
526 {
527   current_options.set_vBody(speed);
528   needReinit();
529 }
530
531
532 /**
533  * Get the current down velocity (units??).
534  */
535 double
536 FGBFI::getSpeedDown ()
537 {
538   return current_aircraft.fdm_state->get_V_down();
539 }
540
541
542 /**
543  * Set the current down velocity (units??).
544  */
545 void
546 FGBFI::setSpeedDown (double speed)
547 {
548   current_options.set_wBody(speed);
549   needReinit();
550 }
551
552
553 \f
554 ////////////////////////////////////////////////////////////////////////
555 // Controls
556 ////////////////////////////////////////////////////////////////////////
557
558
559 /**
560  * Get the throttle setting, from 0.0 (none) to 1.0 (full).
561  */
562 double
563 FGBFI::getThrottle ()
564 {
565                                 // FIXME: add throttle selector
566   return controls.get_throttle(0);
567 }
568
569
570 /**
571  * Set the throttle, from 0.0 (none) to 1.0 (full).
572  */
573 void
574 FGBFI::setThrottle (double throttle)
575 {
576                                 // FIXME: allow throttle selection
577                                 // FIXME: clamp?
578   controls.set_throttle(0, throttle);
579 }
580
581
582 /**
583  * Get the flaps setting, from 0.0 (none) to 1.0 (full).
584  */
585 double
586 FGBFI::getFlaps ()
587 {
588   return controls.get_flaps();
589 }
590
591
592 /**
593  * Set the flaps, from 0.0 (none) to 1.0 (full).
594  */
595 void
596 FGBFI::setFlaps (double flaps)
597 {
598                                 // FIXME: clamp?
599   controls.set_flaps(flaps);
600 }
601
602
603 /**
604  * Get the aileron, from -1.0 (left) to 1.0 (right).
605  */
606 double
607 FGBFI::getAileron ()
608 {
609   return controls.get_aileron();
610 }
611
612
613 /**
614  * Set the aileron, from -1.0 (left) to 1.0 (right).
615  */
616 void
617 FGBFI::setAileron (double aileron)
618 {
619                                 // FIXME: clamp?
620   controls.set_aileron(aileron);
621 }
622
623
624 /**
625  * Get the rudder setting, from -1.0 (left) to 1.0 (right).
626  */
627 double
628 FGBFI::getRudder ()
629 {
630   return controls.get_rudder();
631 }
632
633
634 /**
635  * Set the rudder, from -1.0 (left) to 1.0 (right).
636  */
637 void
638 FGBFI::setRudder (double rudder)
639 {
640                                 // FIXME: clamp?
641   controls.set_rudder(rudder);
642 }
643
644
645 /**
646  * Get the elevator setting, from -1.0 (down) to 1.0 (up).
647  */
648 double
649 FGBFI::getElevator ()
650 {
651   return controls.get_elevator();
652 }
653
654
655 /**
656  * Set the elevator, from -1.0 (down) to 1.0 (up).
657  */
658 void
659 FGBFI::setElevator (double elevator)
660 {
661                                 // FIXME: clamp?
662   controls.set_elevator(elevator);
663 }
664
665
666 /**
667  * Get the elevator trim, from -1.0 (down) to 1.0 (up).
668  */
669 double
670 FGBFI::getElevatorTrim ()
671 {
672   return controls.get_elevator_trim();
673 }
674
675
676 /**
677  * Set the elevator trim, from -1.0 (down) to 1.0 (up).
678  */
679 void
680 FGBFI::setElevatorTrim (double trim)
681 {
682                                 // FIXME: clamp?
683   controls.set_elevator_trim(trim);
684 }
685
686
687 /**
688  * Get the brake setting, from 0.0 (none) to 1.0 (full).
689  */
690 double
691 FGBFI::getBrake ()
692 {
693                                 // FIXME: add brake selector
694   return controls.get_brake(0);
695 }
696
697
698 /**
699  * Set the brake, from 0.0 (none) to 1.0 (full).
700  */
701 void
702 FGBFI::setBrake (double brake)
703 {
704                                 // FIXME: clamp?
705                                 // FIXME: allow brake selection
706   controls.set_brake(0, brake);
707 }
708
709
710 \f
711 ////////////////////////////////////////////////////////////////////////
712 // Autopilot
713 ////////////////////////////////////////////////////////////////////////
714
715
716 /**
717  * Get the autopilot altitude lock (true=on).
718  */
719 bool
720 FGBFI::getAPAltitudeLock ()
721 {
722     return current_autopilot->get_AltitudeEnabled();
723 }
724
725
726 /**
727  * Set the autopilot altitude lock (true=on).
728  */
729 void
730 FGBFI::setAPAltitudeLock (bool lock)
731 {
732   current_autopilot->set_AltitudeMode(FGAutopilot::FG_ALTITUDE_LOCK);
733   current_autopilot->set_AltitudeEnabled(lock);
734 }
735
736
737 /**
738  * Get the autopilot target altitude in feet.
739  */
740 double
741 FGBFI::getAPAltitude ()
742 {
743   return current_autopilot->get_TargetAltitude() * METER_TO_FEET;
744 }
745
746
747 /**
748  * Set the autopilot target altitude in feet.
749  */
750 void
751 FGBFI::setAPAltitude (double altitude)
752 {
753     current_autopilot->set_TargetAltitude( altitude );
754 }
755
756
757 /**
758  * Get the autopilot heading lock (true=on).
759  */
760 bool
761 FGBFI::getAPHeadingLock ()
762 {
763     return
764       (current_autopilot->get_HeadingEnabled() &&
765        current_autopilot->get_HeadingMode() == FGAutopilot::FG_HEADING_LOCK);
766 }
767
768
769 /**
770  * Set the autopilot heading lock (true=on).
771  */
772 void
773 FGBFI::setAPHeadingLock (bool lock)
774 {
775   if (lock) {
776     current_autopilot->set_HeadingMode(FGAutopilot::FG_HEADING_LOCK);
777     current_autopilot->set_HeadingEnabled(true);
778   } else if (current_autopilot->get_HeadingMode() ==
779              FGAutopilot::FG_HEADING_LOCK) {
780     current_autopilot->set_HeadingEnabled(false);
781   }
782 }
783
784
785 /**
786  * Get the autopilot target heading in degrees.
787  */
788 double
789 FGBFI::getAPHeading ()
790 {
791   return current_autopilot->get_TargetHeading();
792 }
793
794
795 /**
796  * Set the autopilot target heading in degrees.
797  */
798 void
799 FGBFI::setAPHeading (double heading)
800 {
801   current_autopilot->set_TargetHeading( heading );
802 }
803
804
805 /**
806  * Return true if the autopilot is locked to NAV1.
807  */
808 bool
809 FGBFI::getAPNAV1Lock ()
810 {
811   return
812     (current_autopilot->get_HeadingEnabled() &&
813      current_autopilot->get_HeadingMode() == FGAutopilot::FG_HEADING_NAV1);
814 }
815
816
817 /**
818  * Set the autopilot NAV1 lock.
819  */
820 void
821 FGBFI::setAPNAV1Lock (bool lock)
822 {
823   if (lock) {
824     current_autopilot->set_HeadingMode(FGAutopilot::FG_HEADING_NAV1);
825     current_autopilot->set_HeadingEnabled(true);
826   } else if (current_autopilot->get_HeadingMode() ==
827              FGAutopilot::FG_HEADING_NAV1) {
828     current_autopilot->set_HeadingEnabled(false);
829   }
830 }
831
832
833 \f
834 ////////////////////////////////////////////////////////////////////////
835 // Radio navigation.
836 ////////////////////////////////////////////////////////////////////////
837
838 double
839 FGBFI::getNAV1Freq ()
840 {
841   return current_radiostack->get_nav1_freq();
842 }
843
844 double
845 FGBFI::getNAV1AltFreq ()
846 {
847   return current_radiostack->get_nav1_alt_freq();
848 }
849
850 double
851 FGBFI::getNAV1Radial ()
852 {
853   return current_radiostack->get_nav1_radial();
854 }
855
856 double
857 FGBFI::getNAV1SelRadial ()
858 {
859   return current_radiostack->get_nav1_sel_radial();
860 }
861
862 double
863 FGBFI::getNAV1DistDME ()
864 {
865   return current_radiostack->get_nav1_dme_dist();
866 }
867
868 double
869 FGBFI::getNAV2Freq ()
870 {
871   return current_radiostack->get_nav2_freq();
872 }
873
874 double
875 FGBFI::getNAV2AltFreq ()
876 {
877   return current_radiostack->get_nav2_alt_freq();
878 }
879
880 double
881 FGBFI::getNAV2Radial ()
882 {
883   return current_radiostack->get_nav2_radial();
884 }
885
886 double
887 FGBFI::getNAV2SelRadial ()
888 {
889   return current_radiostack->get_nav2_sel_radial();
890 }
891
892 double
893 FGBFI::getNAV2DistDME ()
894 {
895   return current_radiostack->get_nav2_dme_dist();
896 }
897
898 double
899 FGBFI::getADFFreq ()
900 {
901   return current_radiostack->get_adf_freq();
902 }
903
904 double
905 FGBFI::getADFAltFreq ()
906 {
907   return current_radiostack->get_adf_alt_freq();
908 }
909
910 double
911 FGBFI::getADFRotation ()
912 {
913   return current_radiostack->get_adf_rotation();
914 }
915
916 void
917 FGBFI::setNAV1Freq (double freq)
918 {
919   current_radiostack->set_nav1_freq(freq);
920 }
921
922 void
923 FGBFI::setNAV1AltFreq (double freq)
924 {
925   current_radiostack->set_nav1_alt_freq(freq);
926 }
927
928 void
929 FGBFI::setNAV1SelRadial (double radial)
930 {
931   current_radiostack->set_nav1_sel_radial(radial);
932 }
933
934 void
935 FGBFI::setNAV2Freq (double freq)
936 {
937   current_radiostack->set_nav2_freq(freq);
938 }
939
940 void
941 FGBFI::setNAV2AltFreq (double freq)
942 {
943   current_radiostack->set_nav2_alt_freq(freq);
944 }
945
946 void
947 FGBFI::setNAV2SelRadial (double radial)
948 {
949   current_radiostack->set_nav2_sel_radial(radial);
950 }
951
952 void
953 FGBFI::setADFFreq (double freq)
954 {
955   current_radiostack->set_adf_freq(freq);
956 }
957
958 void
959 FGBFI::setADFAltFreq (double freq)
960 {
961   current_radiostack->set_adf_alt_freq(freq);
962 }
963
964 void
965 FGBFI::setADFRotation (double rot)
966 {
967   current_radiostack->set_adf_rotation(rot);
968 }
969
970
971 \f
972 ////////////////////////////////////////////////////////////////////////
973 // GPS
974 ////////////////////////////////////////////////////////////////////////
975
976
977 /**
978  * Get the autopilot GPS lock (true=on).
979  */
980 bool
981 FGBFI::getGPSLock ()
982 {
983   return (current_autopilot->get_HeadingEnabled() &&
984           (current_autopilot->get_HeadingMode() ==
985            FGAutopilot::FG_HEADING_WAYPOINT ));
986 }
987
988
989 /**
990  * Set the autopilot GPS lock (true=on).
991  */
992 void
993 FGBFI::setGPSLock (bool lock)
994 {
995   if (lock) {
996     current_autopilot->set_HeadingMode(FGAutopilot::FG_HEADING_WAYPOINT);
997     current_autopilot->set_HeadingEnabled(true);
998   } else if (current_autopilot->get_HeadingMode() ==
999              FGAutopilot::FG_HEADING_WAYPOINT) {
1000     current_autopilot->set_HeadingEnabled(false);
1001   }
1002 }
1003
1004
1005 /**
1006  * Get the GPS target airport code.
1007  */
1008 const string
1009 FGBFI::getTargetAirport ()
1010 {
1011   return current_options.get_airport_id();
1012 }
1013
1014
1015 /**
1016  * Set the GPS target airport code.
1017  */
1018 void
1019 FGBFI::setTargetAirport (const string &airportId)
1020 {
1021   current_options.set_airport_id(airportId);
1022 }
1023
1024
1025 /**
1026  * Get the GPS target latitude in degrees (negative for south).
1027  */
1028 double
1029 FGBFI::getGPSTargetLatitude ()
1030 {
1031     return current_autopilot->get_TargetLatitude();
1032 }
1033
1034
1035 /**
1036  * Set the GPS target latitude in degrees (negative for south).
1037  */
1038 void
1039 FGBFI::setGPSTargetLatitude (double latitude)
1040 {
1041   current_autopilot->set_TargetLatitude( latitude );
1042 }
1043
1044
1045 /**
1046  * Get the GPS target longitude in degrees (negative for west).
1047  */
1048 double
1049 FGBFI::getGPSTargetLongitude ()
1050 {
1051   return current_autopilot->get_TargetLongitude();
1052 }
1053
1054
1055 /**
1056  * Set the GPS target longitude in degrees (negative for west).
1057  */
1058 void
1059 FGBFI::setGPSTargetLongitude (double longitude)
1060 {
1061   current_autopilot->set_TargetLongitude( longitude );
1062 }
1063
1064
1065 \f
1066 ////////////////////////////////////////////////////////////////////////
1067 // Weather
1068 ////////////////////////////////////////////////////////////////////////
1069
1070
1071 /**
1072  * Get the current visible (units??).
1073  */
1074 double
1075 FGBFI::getVisibility ()
1076 {
1077 #ifndef FG_OLD_WEATHER
1078   return WeatherDatabase->getWeatherVisibility();
1079 #else
1080   return current_weather.get_visibility();
1081 #endif
1082 }
1083
1084
1085 /**
1086  * Check whether clouds are enabled.
1087  */
1088 bool
1089 FGBFI::getClouds ()
1090 {
1091   return current_options.get_clouds();
1092 }
1093
1094
1095 /**
1096  * Check the height of the clouds ASL (units?).
1097  */
1098 double
1099 FGBFI::getCloudsASL ()
1100 {
1101   return current_options.get_clouds_asl();
1102 }
1103
1104
1105 /**
1106  * Set the current visibility (units??).
1107  */
1108 void
1109 FGBFI::setVisibility (double visibility)
1110 {
1111 #ifndef FG_OLD_WEATHER
1112   WeatherDatabase->setWeatherVisibility(visibility);
1113 #else
1114   current_weather.set_visibility(visibility);
1115 #endif
1116 }
1117
1118
1119 /**
1120  * Switch clouds on or off.
1121  */
1122 void
1123 FGBFI::setClouds (bool clouds)
1124 {
1125   current_options.set_clouds(clouds);
1126   needReinit();
1127 }
1128
1129
1130 /**
1131  * Set the cloud height.
1132  */
1133 void
1134 FGBFI::setCloudsASL (double cloudsASL)
1135 {
1136   current_options.set_clouds_asl(cloudsASL);
1137   needReinit();
1138 }
1139
1140
1141 \f
1142 ////////////////////////////////////////////////////////////////////////
1143 // Time
1144 ////////////////////////////////////////////////////////////////////////
1145
1146 /**
1147  * Return the magnetic variation
1148  */
1149 double
1150 FGBFI::getMagVar ()
1151 {
1152   return FGTime::cur_time_params->getMagVar() * RAD_TO_DEG;
1153 }
1154
1155
1156 /**
1157  * Return the magnetic variation
1158  */
1159 double
1160 FGBFI::getMagDip ()
1161 {
1162   return FGTime::cur_time_params->getMagDip() * RAD_TO_DEG;
1163 }
1164
1165
1166 // end of bfi.cxx
1167