X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FSystems%2Fsystem_mgr.cxx;h=4936ea63818fec9a43fe5ceaac56d9fb75ff18ed;hb=91976472206ba8319cc41cd3ff468fec04a52a78;hp=fbd6ee6a0c7ae5e64f3f9cc87cf5e94d087d861e;hpb=2f581faf3e03536201e1aad34417b7cd7bea26a9;p=flightgear.git diff --git a/src/Systems/system_mgr.cxx b/src/Systems/system_mgr.cxx index fbd6ee6a0..4936ea638 100644 --- a/src/Systems/system_mgr.cxx +++ b/src/Systems/system_mgr.cxx @@ -3,27 +3,102 @@ // // This file is in the Public Domain and comes with no warranty. +#ifdef HAVE_CONFIG_H +# include +#endif + +#include +#include +#include +#include + +#include
+#include
+#include
+ +#include +#include +#include #include "system_mgr.hxx" #include "electrical.hxx" #include "pitot.hxx" #include "static.hxx" #include "vacuum.hxx" -#include "submodel.hxx" FGSystemMgr::FGSystemMgr () { - set_subsystem( "electrical", new FGElectricalSystem ); - set_subsystem( "pitot", new PitotSystem ); - set_subsystem( "static", new StaticSystem ); - set_subsystem( "vacuum-l", new VacuumSystem(0) ); - set_subsystem( "vacuum-r", new VacuumSystem(1) ); - set_subsystem( "submodel", new SubmodelSystem() ); + SGPropertyNode_ptr config_props = new SGPropertyNode; + + SGPropertyNode *path_n = fgGetNode("/sim/systems/path"); + + if (path_n) { + SGPath config( globals->get_fg_root() ); + config.append( path_n->getStringValue() ); + + SG_LOG( SG_ALL, SG_INFO, "Reading systems from " + << config.str() ); + try { + readProperties( config.str(), config_props ); + + if ( build(config_props) ) { + enabled = true; + } else { + SG_LOG( SG_ALL, SG_ALERT, + "Detected an internal inconsistency in the systems"); + SG_LOG( SG_ALL, SG_ALERT, + " system specification file. See earlier errors for" ); + SG_LOG( SG_ALL, SG_ALERT, + " details."); + exit(-1); + } + } catch (const sg_exception&) { + SG_LOG( SG_ALL, SG_ALERT, "Failed to load systems system model: " + << config.str() ); + } + + } else { + SG_LOG( SG_ALL, SG_WARN, + "No systems model specified for this model!"); + } + } FGSystemMgr::~FGSystemMgr () { } +bool FGSystemMgr::build (SGPropertyNode* config_props) +{ + SGPropertyNode *node; + int i; + + int count = config_props->nChildren(); + for ( i = 0; i < count; ++i ) { + node = config_props->getChild(i); + string name = node->getName(); + std::ostringstream temp; + temp << i; + if ( name == "electrical" ) { + set_subsystem( "electrical" + temp.str(), + new FGElectricalSystem( node ) ); + } else if ( name == "pitot" ) { + set_subsystem( "system" + temp.str(), + new PitotSystem( node ) ); + } else if ( name == "static" ) { + set_subsystem( "system" + temp.str(), + new StaticSystem( node ) ); + } else if ( name == "vacuum" ) { + set_subsystem( "system" + temp.str(), + new VacuumSystem( node ) ); + } else { + SG_LOG( SG_ALL, SG_ALERT, "Unknown top level section: " + << name ); + return false; + } + } + return true; +} + // end of system_manager.cxx