#endif
#include <simgear/constants.h>
+#include <simgear/debug/logstream.hxx>
#include <simgear/math/fg_types.hxx>
#include <Aircraft/aircraft.hxx>
+#include <FDM/UIUCModel/uiuc_aircraftdir.h>
#include <Controls/controls.hxx>
#include <Autopilot/newauto.hxx>
#include <Scenery/scenery.hxx>
// that's going to get clobbered
// when we reinit the subsystems.
+ cout << "BFI: start reinit\n";
+
// TODO: add more AP stuff
double elevator = getElevator();
double aileron = getAileron();
setGPSTargetLongitude(gpsLongitude);
_needReinit = false;
+
+ cout << "BFI: end reinit\n";
}
}
+/**
+ * Return the current aircraft as a string.
+ */
+const string
+FGBFI::getAircraft ()
+{
+ return current_options.get_aircraft();
+}
+
+
+/**
+ * Return the current aircraft directory (UIUC) as a string.
+ */
+const string
+FGBFI::getAircraftDir ()
+{
+ return aircraft_dir;
+}
+
+
/**
* Set the flight model as an integer.
*
}
+/**
+ * Set the current aircraft.
+ */
+void
+FGBFI::setAircraft (const string &aircraft)
+{
+ current_options.set_aircraft(aircraft);
+ needReinit();
+}
+
+
+/**
+ * Set the current aircraft directory (UIUC).
+ */
+void
+FGBFI::setAircraftDir (const string &dir)
+{
+ aircraft_dir = dir;
+ needReinit();
+}
+
+
/**
* Return the current Zulu time.
*/
void
FGBFI::setAPHeadingLock (bool lock)
{
- double heading = getAPHeading();
- current_autopilot->set_HeadingMode(FGAutopilot::FG_HEADING_LOCK);
- current_autopilot->set_HeadingEnabled(lock);
- setAPHeading(heading);
+ if (lock) {
+ current_autopilot->set_HeadingMode(FGAutopilot::FG_HEADING_LOCK);
+ current_autopilot->set_HeadingEnabled(true);
+ } else if (current_autopilot->get_HeadingMode() ==
+ FGAutopilot::FG_HEADING_LOCK) {
+ current_autopilot->set_HeadingEnabled(false);
+ }
}
void
FGBFI::setAPNAV1Lock (bool lock)
{
- current_autopilot->set_HeadingMode(FGAutopilot::FG_HEADING_NAV1);
- current_autopilot->set_HeadingEnabled(lock);
+ if (lock) {
+ current_autopilot->set_HeadingMode(FGAutopilot::FG_HEADING_NAV1);
+ current_autopilot->set_HeadingEnabled(true);
+ } else if (current_autopilot->get_HeadingMode() ==
+ FGAutopilot::FG_HEADING_NAV1) {
+ current_autopilot->set_HeadingEnabled(false);
+ }
}
bool
FGBFI::getGPSLock ()
{
- return ( current_autopilot->get_HeadingEnabled() &&
- ( current_autopilot->get_HeadingMode() ==
- FGAutopilot::FG_HEADING_WAYPOINT )
- );
+ return (current_autopilot->get_HeadingEnabled() &&
+ (current_autopilot->get_HeadingMode() ==
+ FGAutopilot::FG_HEADING_WAYPOINT ));
}
void
FGBFI::setGPSLock (bool lock)
{
- current_autopilot->set_HeadingEnabled( true );
- current_autopilot->set_HeadingMode( FGAutopilot::FG_HEADING_WAYPOINT );
+ if (lock) {
+ current_autopilot->set_HeadingMode(FGAutopilot::FG_HEADING_WAYPOINT);
+ current_autopilot->set_HeadingEnabled(true);
+ } else if (current_autopilot->get_HeadingMode() ==
+ FGAutopilot::FG_HEADING_WAYPOINT) {
+ current_autopilot->set_HeadingEnabled(false);
+ }
}
}
+/**
+ * Check whether clouds are enabled.
+ */
+bool
+FGBFI::getClouds ()
+{
+ return current_options.get_clouds();
+}
+
+
+/**
+ * Check the height of the clouds ASL (units?).
+ */
+double
+FGBFI::getCloudsASL ()
+{
+ return current_options.get_clouds_asl();
+}
+
+
/**
* Set the current visibility (units??).
*/
}
+/**
+ * Switch clouds on or off.
+ */
+void
+FGBFI::setClouds (bool clouds)
+{
+ current_options.set_clouds(clouds);
+ needReinit();
+}
+
+
+/**
+ * Set the cloud height.
+ */
+void
+FGBFI::setCloudsASL (double cloudsASL)
+{
+ current_options.set_clouds_asl(cloudsASL);
+ needReinit();
+}
+
+
\f
////////////////////////////////////////////////////////////////////////
// Time
// Simulation
static int getFlightModel ();
+ static const string getAircraft ();
+ static const string getAircraftDir ();
static time_t getTimeGMT ();
static bool getHUDVisible ();
static bool getPanelVisible ();
static void setFlightModel (int flightModel);
+ static void setAircraft (const string &aircraft);
+ static void setAircraftDir (const string &aircraftDir);
static void setTimeGMT (time_t time);
static void setHUDVisible (bool hudVisible);
static void setPanelVisible (bool panelVisible);
// Weather
static double getVisibility ();
+ static bool getClouds ();
+ static double getCloudsASL ();
static void setVisibility (double visiblity);
+ static void setClouds (bool clouds);
+ static void setCloudsASL (double cloudsASL);
+
// Time (this varies with time) huh, huh
static double getMagVar ();
inline void set_hud_status( bool status ) { hud_status = status; }
inline void set_sound (bool value) { sound = value; }
inline void set_flight_model (int value) { flight_model = value; }
+ inline void set_aircraft (const string &ac) { aircraft = ac; }
inline void set_model_hz (int value) { model_hz = value; }
inline void set_fog (fgFogKind value) { fog = value; }
inline void set_clouds( bool value ) { clouds = value; }
// Simulation
//
SAVE("flight-model", FGBFI::getFlightModel());
+ if (FGBFI::getAircraft().length() > 0)
+ SAVE("aircraft", FGBFI::getAircraft());
+ if (FGBFI::getAircraftDir().length() > 0)
+ SAVE("aircraft-dir", FGBFI::getAircraftDir());
SAVE("time", FGBFI::getTimeGMT());
SAVE("hud", FGBFI::getHUDVisible());
SAVE("panel", FGBFI::getPanelVisible());
//
SAVE("latitude", FGBFI::getLatitude());
SAVE("longitude", FGBFI::getLongitude());
- SAVE("altitude", FGBFI::getAltitude());
+
+ // KLUDGE: deal with gear wierdness
+ if (FGBFI::getAGL() < 6) {
+ SAVE("altitude", FGBFI::getAltitude() - 6);
+ } else {
+ SAVE("altitude", FGBFI::getAltitude());
+ }
//
// Orientation
SAVE("brake", FGBFI::getBrake());
//
- // Navigation.
+ // Radio navigation
+ //
+ SAVE("nav1-active-frequency", FGBFI::getNAV1Freq());
+ SAVE("nav1-standby-frequency", FGBFI::getNAV1AltFreq());
+ SAVE("nav1-selected-radial", FGBFI::getNAV1SelRadial());
+ SAVE("nav2-active-frequency", FGBFI::getNAV2Freq());
+ SAVE("nav2-standby-frequency", FGBFI::getNAV2AltFreq());
+ SAVE("nav2-selected-radial", FGBFI::getNAV2SelRadial());
+ SAVE("adf-active-frequency", FGBFI::getADFFreq());
+ SAVE("adf-standby-frequency", FGBFI::getADFAltFreq());
+ SAVE("adf-rotation", FGBFI::getADFRotation());
+
//
- if (FGBFI::getTargetAirport().length() > 0) {
+ // Autopilot and GPS
+ //
+ if (FGBFI::getTargetAirport().length() > 0)
SAVE("target-airport", FGBFI::getTargetAirport());
- }
SAVE("autopilot-altitude-lock", FGBFI::getAPAltitudeLock());
SAVE("autopilot-altitude", FGBFI::getAPAltitude());
SAVE("autopilot-heading-lock", FGBFI::getAPHeadingLock());
// Environment.
//
SAVE("visibility", FGBFI::getVisibility());
+ SAVE("clouds", FGBFI::getClouds());
+ SAVE("clouds-asl", FGBFI::getCloudsASL());
return true;
}
FGBFI::setFlightModel(i);
}
+ else if (text == "aircraft:") {
+ input >> text;
+ cout << "aircraft is " << text << endl;
+ FGBFI::setAircraft(text);
+ }
+
+ else if (text == "aircraft-dir:") {
+ input >> text;
+ cout << "aircraft-dir is " << text << endl;
+ FGBFI::setAircraftDir(text);
+ }
+
else if (text == "time:") {
input >> i;
cout << "saved time is " << i << endl;
FGBFI::setBrake(n);
}
+
+ //
+ // Radio navigation
+ //
+
+ else if (text == "nav1-active-frequency:") {
+ input >> n;
+ FGBFI::setNAV1Freq(n);
+ }
+
+ else if (text == "nav1-standby-frequency:") {
+ input >> n;
+ FGBFI::setNAV1AltFreq(n);
+ }
+
+ else if (text == "nav1-selected-radial:") {
+ input >> n;
+ FGBFI::setNAV1SelRadial(n);
+ }
+
+ else if (text == "nav2-active-frequency:") {
+ input >> n;
+ FGBFI::setNAV2Freq(n);
+ }
+
+ else if (text == "nav2-standby-frequency:") {
+ input >> n;
+ FGBFI::setNAV2AltFreq(n);
+ }
+
+ else if (text == "nav2-selected-radial:") {
+ input >> n;
+ FGBFI::setNAV2SelRadial(n);
+ }
+
+ else if (text == "adf-active-frequency:") {
+ input >> n;
+ FGBFI::setADFFreq(n);
+ }
+
+ else if (text == "adf-standby-frequency:") {
+ input >> n;
+ FGBFI::setADFAltFreq(n);
+ }
+
+ else if (text == "adf-rotation:") {
+ input >> n;
+ FGBFI::setADFRotation(n);
+ }
+
+
//
- // Navigation.
+ // Autopilot and GPS
//
else if (text == "target-airport:") {
FGBFI::setVisibility(n);
}
+ else if (text == "clouds:") {
+ input >> i;
+ cout << "clouds is " << i << endl;
+ FGBFI::setClouds(i);
+ }
+
+ else if (text == "clouds-asl:") {
+ input >> n;
+ cout << "clouds-asl is " << n << endl;
+ FGBFI::setCloudsASL(n);
+ }
+
//
// Don't die if we don't recognize something
//