-
-/**
- * Get the pause state of the sim.
- */
-static bool
-getFreeze ()
-{
- return globals->get_freeze();
-}
-
-
-/**
- * Set the pause state of the sim.
- */
-static void
-setFreeze (bool freeze)
-{
- globals->set_freeze(freeze);
-}
-
-/**
- * Return the current aircraft directory (UIUC) as a string.
- */
-static string
-getAircraftDir ()
-{
- return aircraft_dir;
-}
-
-
-/**
- * Set the current aircraft directory (UIUC).
- */
-static void
-setAircraftDir (string dir)
-{
- if (getAircraftDir() != dir) {
- aircraft_dir = dir;
-// needReinit(); FIXME!!
- }
-}
-
-
-/**
- * Get the current view offset in degrees.
- */
-static double
-getViewOffset ()
-{
- return (globals->get_current_view()
- ->get_view_offset() * SGD_RADIANS_TO_DEGREES);
-}
-
-
-static void
-setViewOffset (double offset)
-{
- globals->get_current_view()->set_view_offset(offset * SGD_DEGREES_TO_RADIANS);
-}
-
-static double
-getGoalViewOffset ()
-{
- return (globals->get_current_view()
- ->get_goal_view_offset() * SGD_RADIANS_TO_DEGREES);
-}
-
-static void
-setGoalViewOffset (double offset)
-{
- while ( offset < 0 ) {
- offset += 360.0;
- }
- while ( offset > 360.0 ) {
- offset -= 360.0;
- }
- // Snap to center if we are close
- if ( fabs(offset) < 1.0 || fabs(offset) > 359.0 ) {
- offset = 0.0;
- }
-
- globals->get_current_view()
- ->set_goal_view_offset(offset * SGD_DEGREES_TO_RADIANS);
-}
-
-
-/**
- * Pilot position offset from CG.
- */
-static float
-getPilotPositionXOffset ()
-{
- FGViewer * pilot_view = globals->get_viewmgr()->get_view(0);
- float * offset = pilot_view->get_pilot_offset();
- return offset[0];
-}
-
-static void
-setPilotPositionXOffset (float x)
-{
- FGViewer * pilot_view = globals->get_viewmgr()->get_view(0);
- float * offset = pilot_view->get_pilot_offset();
- pilot_view->set_pilot_offset(x, offset[1], offset[2]);
-}
-
-static float
-getPilotPositionYOffset ()
-{
- FGViewer * pilot_view = globals->get_viewmgr()->get_view(0);
- float * offset = pilot_view->get_pilot_offset();
- return offset[1];
-}
-
-static void
-setPilotPositionYOffset (float y)
-{
- FGViewer * pilot_view = globals->get_viewmgr()->get_view(0);
- float * offset = pilot_view->get_pilot_offset();
- pilot_view->set_pilot_offset(offset[0], y, offset[2]);
-}
-
-static float
-getPilotPositionZOffset ()
-{
- FGViewer * pilot_view = globals->get_viewmgr()->get_view(0);
- float * offset = pilot_view->get_pilot_offset();
- return offset[2];
-}
-
-static void
-setPilotPositionZOffset (float z)
-{
- FGViewer * pilot_view = globals->get_viewmgr()->get_view(0);
- float * offset = pilot_view->get_pilot_offset();
- pilot_view->set_pilot_offset(offset[0], offset[1], z);
-}
-
-
-/**
- * Return the current Zulu time.
- */
-static string
-getDateString ()
-{
- string out;
- char buf[64];
- struct tm * t = globals->get_time_params()->getGmt();
- sprintf(buf, "%.4d-%.2d-%.2dT%.2d:%.2d:%.2d",
- t->tm_year + 1900, t->tm_mon + 1, t->tm_mday,
- t->tm_hour, t->tm_min, t->tm_sec);
- out = buf;
- return out;
-}
-
-
-/**
- * Set the current Zulu time.
- */
-static void
-setDateString (string date_string)
-{
- SGTime * st = globals->get_time_params();
- struct tm * current_time = st->getGmt();
- struct tm new_time;
-
- // Scan for basic ISO format
- // YYYY-MM-DDTHH:MM:SS
- int ret = sscanf(date_string.c_str(), "%d-%d-%dT%d:%d:%d",
- &(new_time.tm_year), &(new_time.tm_mon),
- &(new_time.tm_mday), &(new_time.tm_hour),
- &(new_time.tm_min), &(new_time.tm_sec));
-
- // Be pretty picky about this, so
- // that strange things don't happen
- // if the save file has been edited
- // by hand.
- if (ret != 6) {
- SG_LOG(SG_INPUT, SG_ALERT, "Date/time string " << date_string
- << " not in YYYY-MM-DDTHH:MM:SS format; skipped");
- return;
- }
-
- // OK, it looks like we got six
- // values, one way or another.
- new_time.tm_year -= 1900;
- new_time.tm_mon -= 1;
-
- // Now, tell flight gear to use
- // the new time. This was far
- // too difficult, by the way.
- long int warp =
- mktime(&new_time) - mktime(current_time) + globals->get_warp();
- double lon = current_aircraft.fdm_state->get_Longitude();
- double lat = current_aircraft.fdm_state->get_Latitude();
- globals->set_warp(warp);
- st->update(lon, lat, warp);
- fgUpdateSkyAndLightingParams();
-}
-
-/**
- * Return the GMT as a string.
- */
-static string
-getGMTString ()
-{
- string out;
- char buf[16];
- struct tm * t = globals->get_time_params()->getGmt();
- sprintf(buf, " %.2d:%.2d:%.2d",
- t->tm_hour, t->tm_min, t->tm_sec);
- out = buf;
- return out;
-}
-
-
-/**
- * Get the texture rendering state.
- */
-static bool
-getTextures ()
-{
- return (material_lib.get_step() == 0);
-}
-
-
-/**
- * Set the texture rendering state.
- */
-static void
-setTextures (bool textures)
-{
- if (textures)
- material_lib.set_step(0);
- else
- material_lib.set_step(1);
-}
-
-
-/**
- * Return the magnetic variation
- */
-static double
-getMagVar ()
-{
- return globals->get_mag()->get_magvar() * SGD_RADIANS_TO_DEGREES;
-}
-
-
-/**
- * Return the magnetic dip
- */
-static double
-getMagDip ()
-{
- return globals->get_mag()->get_magdip() * SGD_RADIANS_TO_DEGREES;
-}
-
-
-/**
- * Return the current heading in degrees.
- */
-static double
-getHeadingMag ()
-{
- return current_aircraft.fdm_state->get_Psi() * SGD_RADIANS_TO_DEGREES - getMagVar();
-}
-
-
-/**
- * Return the current engine0 rpm
- */
-static double
-getRPM ()
-{
- if ( current_aircraft.fdm_state->get_engine(0) != NULL ) {
- return current_aircraft.fdm_state->get_engine(0)->get_RPM();
- } else {
- return 0.0;
- }
-}
-
-
-/**
- * Return the current engine0 EGT.
- */
-static double
-getEGT ()
-{
- if ( current_aircraft.fdm_state->get_engine(0) != NULL ) {
- return current_aircraft.fdm_state->get_engine(0)->get_EGT();
- } else {
- return 0.0;
- }
-}
-
-/**
- * Return the current engine0 CHT.
- */
-static double
-getCHT ()
-{
- if ( current_aircraft.fdm_state->get_engine(0) != NULL ) {
- return current_aircraft.fdm_state->get_engine(0)->get_CHT();
- } else {
- return 0.0;
- }
-}
-
-/**
- * Return the current engine0 Oil Temp.
- */
-static double
-getOilTemp ()
-{
- if ( current_aircraft.fdm_state->get_engine(0) != NULL ) {
- return current_aircraft.fdm_state->get_engine(0)->get_Oil_Temp();
- } else {
- return 0.0;
- }
-}
-
-/**
- * Return the current engine0 Manifold Pressure.
- */
-static double
-getMP ()
-{
- if ( current_aircraft.fdm_state->get_engine(0) != NULL ) {
- return current_aircraft.fdm_state->get_engine(0)->get_Manifold_Pressure();
- } else {
- return 0.0;
- }
-}
-
-
-/**
- * Return the current engine0 fuel flow
- */
-static double
-getFuelFlow ()
-{
- if ( current_aircraft.fdm_state->get_engine(0) != NULL ) {
- return current_aircraft.fdm_state->get_engine(0)->get_Fuel_Flow();
- } else {
- return 0.0;
- }
-}
-
-/**
- * Return the current engine0 running flag
- */
-static bool
-getRunningFlag ()
-{
- if ( current_aircraft.fdm_state->get_engine(0) != NULL ) {
- return current_aircraft.fdm_state->get_engine(0)->get_Running_Flag();
- } else {
- return false;
- }
-}
-
-/**
- * Return the current engine0 cranking flag
- */
-static bool
-getCrankingFlag ()
-{
- if ( current_aircraft.fdm_state->get_engine(0) != NULL ) {
- return current_aircraft.fdm_state->get_engine(0)->get_Cranking_Flag();
- } else {
- return false;
- }
-}
-
-/**
- * Return the fuel level in tank 1
- */
-static double
-getTank1Fuel ()
-{
- return current_aircraft.fdm_state->get_Tank1Fuel();
-}
-
-static void
-setTank1Fuel ( double gals )
-{
- current_aircraft.fdm_state->set_Tank1Fuel( gals );
-}
-
-/**
- * Return the fuel level in tank 2
- */
-static double
-getTank2Fuel ()
-{
- return current_aircraft.fdm_state->get_Tank2Fuel();
-}
-
-static void
-setTank2Fuel ( double gals )
-{
- current_aircraft.fdm_state->set_Tank2Fuel( gals );
-}
-
-
-/**
- * Get the autopilot altitude lock (true=on).
- */
-static bool
-getAPAltitudeLock ()
-{
- return (current_autopilot->get_AltitudeEnabled() &&
- current_autopilot->get_AltitudeMode()
- == FGAutopilot::FG_ALTITUDE_LOCK);
-}
-
-
-/**
- * Set the autopilot altitude lock (true=on).
- */
-static void
-setAPAltitudeLock (bool lock)
-{
- current_autopilot->set_AltitudeMode(FGAutopilot::FG_ALTITUDE_LOCK);
- current_autopilot->set_AltitudeEnabled(lock);
-}
-
-
-/**
- * Get the autopilot target altitude in feet.
- */
-static double
-getAPAltitude ()
-{
- return current_autopilot->get_TargetAltitude() * SG_METER_TO_FEET;
-}
-
-
-/**
- * Set the autopilot target altitude in feet.
- */
-static void
-setAPAltitude (double altitude)
-{
- current_autopilot->set_TargetAltitude( altitude * SG_FEET_TO_METER );
-}
-
-/**
- * Get the autopilot altitude lock (true=on).
- */
-static bool
-getAPGSLock ()
-{
- return (current_autopilot->get_AltitudeEnabled() &&
- (current_autopilot->get_AltitudeMode()
- == FGAutopilot::FG_ALTITUDE_GS1));
-}
-
-
-/**
- * Set the autopilot altitude lock (true=on).
- */
-static void
-setAPGSLock (bool lock)
-{
- current_autopilot->set_AltitudeMode(FGAutopilot::FG_ALTITUDE_GS1);
- current_autopilot->set_AltitudeEnabled(lock);
-}
-
-
-/**
- * Get the autopilot terrain lock (true=on).
- */
-static bool
-getAPTerrainLock ()
-{
- return (current_autopilot->get_AltitudeEnabled() &&
- (current_autopilot->get_AltitudeMode()
- == FGAutopilot::FG_ALTITUDE_TERRAIN));
-}
-
-
-/**
- * Set the autopilot terrain lock (true=on).
- */
-static void
-setAPTerrainLock (bool lock)
-{
- current_autopilot->set_AltitudeMode(FGAutopilot::FG_ALTITUDE_TERRAIN);
- current_autopilot->set_AltitudeEnabled(lock);
- current_autopilot->set_TargetAGL(
- current_aircraft.fdm_state->get_Altitude_AGL() * SG_FEET_TO_METER
- );
- cout << "Target AGL = "
- << current_aircraft.fdm_state->get_Altitude_AGL() * SG_FEET_TO_METER
- << endl;
-}
-
-
-/**
- * Get the autopilot target altitude in feet.
- */
-static double
-getAPClimb ()
-{
- return current_autopilot->get_TargetClimbRate() * SG_METER_TO_FEET;
-}
-
-
-/**
- * Set the autopilot target altitude in feet.
- */
-static void
-setAPClimb (double rate)
-{
- current_autopilot->set_TargetClimbRate( rate * SG_FEET_TO_METER );
-}
-
-
-/**
- * Get the autopilot heading lock (true=on).
- */
-static bool
-getAPHeadingLock ()
-{
- return
- (current_autopilot->get_HeadingEnabled() &&
- current_autopilot->get_HeadingMode() == DEFAULT_AP_HEADING_LOCK);
-}
-
-
-/**
- * Set the autopilot heading lock (true=on).
- */
-static void
-setAPHeadingLock (bool lock)
-{
- if (lock) {
- current_autopilot->set_HeadingMode(DEFAULT_AP_HEADING_LOCK);
- current_autopilot->set_HeadingEnabled(true);
- } else {
- current_autopilot->set_HeadingEnabled(false);
- }
-}
-
-
-/**
- * Get the autopilot heading bug in degrees.
- */
-static double
-getAPHeadingBug ()
-{
- return current_autopilot->get_DGTargetHeading();
-}
-
-
-/**
- * Set the autopilot heading bug in degrees.
- */
-static void
-setAPHeadingBug (double heading)
-{
- current_autopilot->set_DGTargetHeading( heading );
-}
-
-
-/**
- * Get the autopilot wing leveler lock (true=on).
- */
-static bool
-getAPWingLeveler ()
-{
- return
- (current_autopilot->get_HeadingEnabled() &&
- current_autopilot->get_HeadingMode() == FGAutopilot::FG_TC_HEADING_LOCK);
-}
-
-
-/**
- * Set the autopilot wing leveler lock (true=on).
- */
-static void
-setAPWingLeveler (bool lock)
-{
- if (lock) {
- current_autopilot->set_HeadingMode(FGAutopilot::FG_TC_HEADING_LOCK);
- current_autopilot->set_HeadingEnabled(true);
- } else {
- current_autopilot->set_HeadingEnabled(false);
+struct LogClassMapping {
+ sgDebugClass c;
+ string name;
+ LogClassMapping(sgDebugClass cc, string nname) { c = cc; name = nname; }
+};
+
+LogClassMapping log_class_mappings [] = {
+ LogClassMapping(SG_NONE, "none"),
+ LogClassMapping(SG_TERRAIN, "terrain"),
+ LogClassMapping(SG_ASTRO, "astro"),
+ LogClassMapping(SG_FLIGHT, "flight"),
+ LogClassMapping(SG_INPUT, "input"),
+ LogClassMapping(SG_GL, "gl"),
+ LogClassMapping(SG_VIEW, "view"),
+ LogClassMapping(SG_COCKPIT, "cockpit"),
+ LogClassMapping(SG_GENERAL, "general"),
+ LogClassMapping(SG_MATH, "math"),
+ LogClassMapping(SG_EVENT, "event"),
+ LogClassMapping(SG_AIRCRAFT, "aircraft"),
+ LogClassMapping(SG_AUTOPILOT, "autopilot"),
+ LogClassMapping(SG_IO, "io"),
+ LogClassMapping(SG_CLIPPER, "clipper"),
+ LogClassMapping(SG_NETWORK, "network"),
+ LogClassMapping(SG_UNDEFD, "")
+};
+
+
+/**
+ * Get the logging classes.
+ */
+static const char *
+getLoggingClasses ()
+{
+ sgDebugClass classes = logbuf::get_log_classes();
+ static string result = ""; // FIXME
+ for (int i = 0; log_class_mappings[i].c != SG_UNDEFD; i++) {
+ if ((classes&log_class_mappings[i].c) > 0) {
+ if (!result.empty())
+ result += '|';
+ result += log_class_mappings[i].name;