1
0
Fork 0

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.
This commit is contained in:
david 2004-02-20 17:35:33 +00:00
parent 32a17bf442
commit 9409d5e35e
4 changed files with 83 additions and 36 deletions

View file

@ -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.
////////////////////////////////////////////////////////////////////

View file

@ -351,7 +351,6 @@ getGMTString ()
return buf;
}
/**
* Return the magnetic variation
*/
@ -555,10 +554,22 @@ setFDMDataLogging (bool state)
// Tie the properties.
////////////////////////////////////////////////////////////////////////
void
fgInitProps ()
FGProperties::FGProperties ()
{
}
FGProperties::~FGProperties ()
{
}
void
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
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
fgUpdateProps ()
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);
}

View file

@ -9,6 +9,7 @@
#include <simgear/debug/logstream.hxx>
#include <simgear/props/props.hxx>
#include <simgear/props/props_io.hxx>
#include <simgear/structure/subsystem_mgr.hxx>
#include "globals.hxx"
@ -17,25 +18,17 @@
// Property management.
////////////////////////////////////////////////////////////////////////
class FGProperties : public SGSubsystem
{
public:
FGProperties ();
virtual ~FGProperties ();
/**
* 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 ();
void init ();
void bind ();
void unbind ();
void update (double dt);
};
/**

View file

@ -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"));