From 9409d5e35e7553f71568758be6500f776c2072c5 Mon Sep 17 00:00:00 2001 From: david Date: Fri, 20 Feb 2004 17:35:33 +0000 Subject: [PATCH] Change fg_props.[ch]xx into a proper subsystem, under the control of the subsystem manager. Add properties for the individual parts of the time and date. --- src/Main/fg_init.cxx | 15 +++++---- src/Main/fg_props.cxx | 72 ++++++++++++++++++++++++++++++++++++++----- src/Main/fg_props.hxx | 31 ++++++++----------- src/Main/main.cxx | 3 -- 4 files changed, 84 insertions(+), 37 deletions(-) diff --git a/src/Main/fg_init.cxx b/src/Main/fg_init.cxx index cff3d0147..869134735 100644 --- a/src/Main/fg_init.cxx +++ b/src/Main/fg_init.cxx @@ -1455,7 +1455,13 @@ bool fgInitSubsystems() { //////////////////////////////////////////////////////////////////// // Initialize the property interpolator subsystem //////////////////////////////////////////////////////////////////// - globals->add_subsystem("interpolator", new SGInterpolator()); + globals->add_subsystem("interpolator", new SGInterpolator); + + + //////////////////////////////////////////////////////////////////// + // Add the FlightGear property utilities. + //////////////////////////////////////////////////////////////////// + globals->add_subsystem("properties", new FGProperties); //////////////////////////////////////////////////////////////////// // Initialize the material property subsystem. @@ -1743,13 +1749,6 @@ bool fgInitSubsystems() { } - //////////////////////////////////////////////////////////////////// - // Initialize the default (kludged) properties. - //////////////////////////////////////////////////////////////////// - - fgInitProps(); - - //////////////////////////////////////////////////////////////////// // Initialize the controls subsystem. //////////////////////////////////////////////////////////////////// diff --git a/src/Main/fg_props.cxx b/src/Main/fg_props.cxx index 46acff3e5..7f2c7e868 100644 --- a/src/Main/fg_props.cxx +++ b/src/Main/fg_props.cxx @@ -351,7 +351,6 @@ getGMTString () return buf; } - /** * Return the magnetic variation */ @@ -555,10 +554,22 @@ setFDMDataLogging (bool state) // Tie the properties. //////////////////////////////////////////////////////////////////////// +FGProperties::FGProperties () +{ +} + +FGProperties::~FGProperties () +{ +} + void -fgInitProps () +FGProperties::init () +{ +} + +void +FGProperties::bind () { - SG_LOG(SG_GENERAL, SG_DEBUG, "start of fgInitProps()" ); // Simulation fgTie("/sim/logging/priority", getLoggingPriority, setLoggingPriority); fgTie("/sim/logging/classes", getLoggingClasses, setLoggingClasses); @@ -595,14 +606,61 @@ fgInitProps () fgTie("/sim/temp/winding-ccw", getWindingCCW, setWindingCCW, false); fgTie("/sim/temp/full-screen", getFullScreen, setFullScreen); fgTie("/sim/temp/fdm-data-logging", getFDMDataLogging, setFDMDataLogging); - - SG_LOG(SG_GENERAL, SG_DEBUG, "end of fgInitProps()" ); } - void -fgUpdateProps () +FGProperties::unbind () { + // Simulation + fgUntie("/sim/logging/priority"); + fgUntie("/sim/logging/classes"); + fgUntie("/sim/freeze/master"); + fgUntie("/sim/aircraft-dir"); + + fgUntie("/sim/time/elapsed-sec"); + fgUntie("/sim/time/gmt"); + fgUntie("/sim/time/gmt-string"); + + // Orientation + fgUntie("/orientation/heading-magnetic-deg"); + + // Environment +#ifdef FG_WEATHERCM + fgUntie("/environment/visibility-m"); + fgUntie("/environment/wind-from-north-fps"); + fgUntie("/environment/wind-from-east-fps"); + fgUntie("/environment/wind-from-down-fps"); +#endif + + 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"); +} + +void +FGProperties::update (double dt) +{ + // Date and time + struct tm * t = globals->get_time_params()->getGmt(); + + fgSetInt("/sim/time/utc/year", t->tm_year + 1900); + fgSetInt("/sim/time/utc/month", t->tm_mon + 1); + fgSetInt("/sim/time/utc/day", t->tm_mday); + fgSetInt("/sim/time/utc/hour", t->tm_hour); + fgSetInt("/sim/time/utc/minute", t->tm_min); + fgSetInt("/sim/time/utc/second", t->tm_sec); + + fgSetDouble("/sim/time/utc/day-seconds", + t->tm_hour * 3600 + + t->tm_min * 60 + + t->tm_sec); } diff --git a/src/Main/fg_props.hxx b/src/Main/fg_props.hxx index 703636a96..8a53147c7 100644 --- a/src/Main/fg_props.hxx +++ b/src/Main/fg_props.hxx @@ -9,6 +9,7 @@ #include #include #include +#include #include "globals.hxx" @@ -17,25 +18,17 @@ // Property management. //////////////////////////////////////////////////////////////////////// - -/** - * Initialize the default FlightGear properties. - * - * These are mostly properties that haven't been claimed by a - * specific module yet. This function should be invoked once, - * while the program is starting (and after the global property - * tree has been created). - */ -extern void fgInitProps (); // fixme: how are they untied? - - -/** - * Update the default FlightGear properties. - * - * This function should be invoked once in each loop to update all - * of the default properties. - */ -extern void fgUpdateProps (); +class FGProperties : public SGSubsystem +{ +public: + FGProperties (); + virtual ~FGProperties (); + + void init (); + void bind (); + void unbind (); + void update (double dt); +}; /** diff --git a/src/Main/main.cxx b/src/Main/main.cxx index 502207bf2..0f7d536e9 100644 --- a/src/Main/main.cxx +++ b/src/Main/main.cxx @@ -371,9 +371,6 @@ void fgRenderFrame() { static const SGPropertyNode *groundlevel_nearplane = fgGetNode("/sim/current-view/ground-level-nearplane-m"); - // Update the default (kludged) properties. - fgUpdateProps(); - FGViewer *current__view = globals->get_current_view(); FGLight *l = (FGLight *)(globals->get_subsystem("lighting")); -- 2.39.5