#include <simgear/scene/model/particles.hxx>
#include <simgear/sound/soundmgr_openal.hxx>
-#include <Aircraft/aircraft.hxx>
-#include <FDM/flight.hxx>
#include <GUI/gui.h>
#include "globals.hxx"
static bool winding_ccw = true; // FIXME: temporary
-static bool fdm_data_logging = false; // FIXME: temporary
-
static bool frozen = false; // FIXME: temporary
using std::string;
LogClassMapping(SG_CLIPPER, "clipper"),
LogClassMapping(SG_NETWORK, "network"),
LogClassMapping(SG_INSTR, "instrumentation"),
+ LogClassMapping(SG_ATC, "atc"),
+ LogClassMapping(SG_NASAL, "nasal"),
LogClassMapping(SG_SYSTEMS, "systems"),
+ LogClassMapping(SG_AI, "ai"),
+ LogClassMapping(SG_ENVIRONMENT, "environment"),
+ LogClassMapping(SG_SOUND, "sound"),
LogClassMapping(SG_UNDEFD, "")
};
/**
* Set the logging classes.
*/
-static void
+void
setLoggingClasses (const char * c)
{
string classes = c;
string rest = classes;
string name = "";
- int sep = rest.find('|');
- while (sep > 0) {
+ string::size_type sep = rest.find('|');
+ if (sep == string::npos)
+ sep = rest.find(',');
+ while (sep != string::npos) {
name = rest.substr(0, sep);
rest = rest.substr(sep+1);
addLoggingClass(name);
sep = rest.find('|');
+ if (sep == string::npos)
+ sep = rest.find(',');
}
addLoggingClass(rest);
SG_LOG(SG_GENERAL, SG_INFO, "Set logging classes to "
/**
* Set the logging priority.
*/
-static void
+void
setLoggingPriority (const char * p)
{
if (p == 0)
getDateString ()
{
static char buf[64]; // FIXME
- struct tm * t = globals->get_time_params()->getGmt();
+
+ SGTime * st = globals->get_time_params();
+ if (!st) {
+ buf[0] = 0;
+ return buf;
+ }
+
+ struct tm * t = st->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);
static void
setDateString (const char * date_string)
{
- static const SGPropertyNode *cur_time_override
- = fgGetNode("/sim/time/cur-time-override", true);
-
SGTime * st = globals->get_time_params();
struct tm * current_time = st->getGmt();
struct tm new_time;
// 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, cur_time_override->getLongValue(), warp);
+
+ fgSetInt("/sim/time/warp", warp);
}
/**
getGMTString ()
{
static char buf[16];
- struct tm *t = globals->get_time_params()->getGmt();
+ SGTime * st = globals->get_time_params();
+ if (!st) {
+ buf[0] = 0;
+ return buf;
+ }
+
+ struct tm *t = st->getGmt();
snprintf(buf, 16, "%.2d:%.2d:%.2d",
t->tm_hour, t->tm_min, t->tm_sec);
return buf;
static double
getHeadingMag ()
{
- double magheading;
- magheading = current_aircraft.fdm_state->get_Psi() * SGD_RADIANS_TO_DEGREES - getMagVar();
- if (magheading < 0) magheading += 360;
- return magheading;
+ double magheading = fgGetDouble("/orientation/heading-deg") - getMagVar();
+ return SGMiscd::normalizePeriodic(0, 360, magheading );
}
/**
static double
getTrackMag ()
{
- double magtrack;
- magtrack = current_aircraft.fdm_state->get_Track() - getMagVar();
- if (magtrack < 0) magtrack += 360;
- return magtrack;
-}
-
-static long
-getWarp ()
-{
- return globals->get_warp();
-}
-
-static void
-setWarp (long warp)
-{
- globals->set_warp(warp);
-}
-
-static long
-getWarpDelta ()
-{
- return globals->get_warp_delta();
-}
-
-static void
-setWarpDelta (long delta)
-{
- globals->set_warp_delta(delta);
+ double magtrack = fgGetDouble("/orientation/track-deg") - getMagVar();
+ return SGMiscd::normalizePeriodic(0, 360, magtrack );
}
static bool
glFrontFace ( GL_CW );
}
-static bool
-getFDMDataLogging ()
-{
- return fdm_data_logging;
-}
-
-static void
-setFDMDataLogging (bool state)
-{
- // kludge; no getter or setter available
- if (state != fdm_data_logging) {
- fgToggleFDMdataLogging();
- fdm_data_logging = state;
- }
-}
-
static const char *
getLongitudeString ()
{
void
FGProperties::bind ()
{
- // Simulation
- fgTie("/sim/logging/priority", getLoggingPriority, setLoggingPriority);
- fgTie("/sim/logging/classes", getLoggingClasses, setLoggingClasses);
- fgTie("/sim/freeze/master", getFreeze, setFreeze);
+ _tiedProperties.setRoot(globals->get_props());
- fgTie("/sim/time/elapsed-sec", getElapsedTime_sec);
- fgTie("/sim/time/gmt", getDateString, setDateString);
- fgSetArchivable("/sim/time/gmt");
- fgTie("/sim/time/gmt-string", getGMTString);
+ // Simulation
+ _tiedProperties.Tie("/sim/logging/priority", getLoggingPriority, setLoggingPriority);
+ _tiedProperties.Tie("/sim/logging/classes", getLoggingClasses, setLoggingClasses);
+ _tiedProperties.Tie("/sim/freeze/master", getFreeze, setFreeze);
- // Position
- fgTie("/position/latitude-string", getLatitudeString);
- fgTie("/position/longitude-string", getLongitudeString);
+ _tiedProperties.Tie("/sim/time/elapsed-sec", getElapsedTime_sec);
+ _tiedProperties.Tie("/sim/time/gmt", getDateString, setDateString);
+ fgSetArchivable("/sim/time/gmt");
+ _tiedProperties.Tie("/sim/time/gmt-string", getGMTString);
- // Orientation
- fgTie("/orientation/heading-magnetic-deg", getHeadingMag);
- fgTie("/orientation/track-magnetic-deg", getTrackMag);
+ // Position
+ _tiedProperties.Tie("/position/latitude-string", getLatitudeString);
+ _tiedProperties.Tie("/position/longitude-string", getLongitudeString);
- fgTie("/environment/magnetic-variation-deg", getMagVar);
- fgTie("/environment/magnetic-dip-deg", getMagDip);
+ // Orientation
+ _tiedProperties.Tie("/orientation/heading-magnetic-deg", getHeadingMag);
+ _tiedProperties.Tie("/orientation/track-magnetic-deg", getTrackMag);
- fgTie("/sim/time/warp", getWarp, setWarp, false);
- fgTie("/sim/time/warp-delta", getWarpDelta, setWarpDelta);
+ _tiedProperties.Tie("/environment/magnetic-variation-deg", getMagVar);
+ _tiedProperties.Tie("/environment/magnetic-dip-deg", getMagDip);
- // Misc. Temporary junk.
- fgTie("/sim/temp/winding-ccw", getWindingCCW, setWindingCCW, false);
- fgTie("/sim/temp/fdm-data-logging", getFDMDataLogging, setFDMDataLogging);
+ // Misc. Temporary junk.
+ _tiedProperties.Tie("/sim/temp/winding-ccw", getWindingCCW, setWindingCCW, false);
}
void
FGProperties::unbind ()
{
- // Simulation
- fgUntie("/sim/logging/priority");
- fgUntie("/sim/logging/classes");
- fgUntie("/sim/freeze/master");
-
- fgUntie("/sim/time/elapsed-sec");
- fgUntie("/sim/time/gmt");
- fgUntie("/sim/time/gmt-string");
- // Position
- fgUntie("/position/latitude-string");
- fgUntie("/position/longitude-string");
-
- // Orientation
- fgUntie("/orientation/heading-magnetic-deg");
- fgUntie("/orientation/track-magnetic-deg");
-
- // Environment
- fgUntie("/environment/magnetic-variation-deg");
- fgUntie("/environment/magnetic-dip-deg");
-
- fgUntie("/sim/time/warp");
- fgUntie("/sim/time/warp-delta");
-
- // Misc. Temporary junk.
- fgUntie("/sim/temp/winding-ccw");
- fgUntie("/sim/temp/full-screen");
- fgUntie("/sim/temp/fdm-data-logging");
+ _tiedProperties.Untie();
}
void
static SGPropertyNode_ptr offset = fgGetNode("/sim/time/local-offset", true);
offset->setIntValue(globals->get_time_params()->get_local_offset());
-
// utc date/time
static SGPropertyNode_ptr uyear = fgGetNode("/sim/time/utc/year", true);
static SGPropertyNode_ptr umonth = fgGetNode("/sim/time/utc/month", true);
}
void
-fgUntie (const char * name)
+fgUntie(const char * name)
{
- if (!globals->get_props()->untie(name))
+ SGPropertyNode* node = globals->get_props()->getNode(name);
+ if (!node) {
+ SG_LOG(SG_GENERAL, SG_WARN, "fgUntie: unknown property " << name);
+ return;
+ }
+
+ if (!node->isTied()) {
+ return;
+ }
+
+ if (!node->untie()) {
SG_LOG(SG_GENERAL, SG_WARN, "Failed to untie property " << name);
+ }
}