1
0
Fork 0

Autopilot: save loads of CPU cycles

Not every xml-autopilot filter needs to run at the update rate
of the FDM. This only makes sense for the autpilot filters. Those,
who update instrument needles or environment properties for example
may run at frame rate.
This patch (thanks to ThorstenB, who is the author) forces those
filters defined in /sim/systems/autopilot into the FDM loop and those
defined in /sim/systems/property-rule into the default loop. They
show up as xml-autopilot and xml-proprules in the performance monitor
This commit is contained in:
Torsten Dreyer 2012-04-05 20:40:07 +02:00
parent 44de0e1df4
commit 68e1a8c4cb
3 changed files with 9 additions and 10 deletions

View file

@ -44,6 +44,8 @@ using simgear::PropertyList;
class FGXMLAutopilotGroupImplementation : public FGXMLAutopilotGroup
{
public:
FGXMLAutopilotGroupImplementation(const std::string& nodeName) :
FGXMLAutopilotGroup(), _nodeName(nodeName) {}
virtual void addAutopilot( const std::string & name, SGPropertyNode_ptr apNode, SGPropertyNode_ptr config );
virtual void removeAutopilot( const std::string & name );
void init();
@ -52,6 +54,7 @@ public:
private:
void initFrom( SGPropertyNode_ptr rootNode, const char * childName );
vector<string> _autopilotNames;
std::string _nodeName;
};
@ -100,12 +103,7 @@ void FGXMLAutopilotGroupImplementation::reinit()
void FGXMLAutopilotGroupImplementation::init()
{
static const char * nodeNames[] = {
"autopilot",
"property-rule"
};
for( unsigned i = 0; i < sizeof(nodeNames)/sizeof(nodeNames[0]); i++ )
initFrom( fgGetNode( "/sim/systems" ), nodeNames[i] );
initFrom( fgGetNode( "/sim/systems" ), _nodeName.c_str() );
SGSubsystemGroup::bind();
SGSubsystemGroup::init();
@ -173,7 +171,7 @@ void FGXMLAutopilotGroup::addAutopilotFromFile( const std::string & name, SGProp
}
}
FGXMLAutopilotGroup * FGXMLAutopilotGroup::createInstance()
FGXMLAutopilotGroup * FGXMLAutopilotGroup::createInstance(const std::string& nodeName)
{
return new FGXMLAutopilotGroupImplementation();
return new FGXMLAutopilotGroupImplementation(nodeName);
}

View file

@ -31,7 +31,7 @@
class FGXMLAutopilotGroup : public SGSubsystemGroup
{
public:
static FGXMLAutopilotGroup * createInstance();
static FGXMLAutopilotGroup * createInstance(const std::string& nodeName);
void addAutopilotFromFile( const std::string & name, SGPropertyNode_ptr apNode, const char * path );
virtual void addAutopilot( const std::string & name, SGPropertyNode_ptr apNode, SGPropertyNode_ptr config ) = 0;
virtual void removeAutopilot( const std::string & name ) = 0;

View file

@ -1251,7 +1251,8 @@ bool fgInitSubsystems() {
// Initialize the XML Autopilot subsystem.
////////////////////////////////////////////////////////////////////
globals->add_subsystem( "xml-autopilot", FGXMLAutopilotGroup::createInstance(), SGSubsystemMgr::FDM );
globals->add_subsystem( "xml-autopilot", FGXMLAutopilotGroup::createInstance("autopilot"), SGSubsystemMgr::FDM );
globals->add_subsystem( "xml-proprules", FGXMLAutopilotGroup::createInstance("property-rule"), SGSubsystemMgr::GENERAL );
globals->add_subsystem( "route-manager", new FGRouteMgr );
////////////////////////////////////////////////////////////////////