1 // system_mgr.cxx - manage aircraft systems.
2 // Written by David Megginson, started 2002.
4 // This file is in the Public Domain and comes with no warranty.
6 #include <simgear/structure/exception.hxx>
7 #include <simgear/misc/sg_path.hxx>
8 #include <simgear/sg_inlines.h>
10 #include <Main/fg_props.hxx>
11 #include <Main/globals.hxx>
12 #include <Main/util.hxx>
18 #include "system_mgr.hxx"
19 #include "electrical.hxx"
25 FGSystemMgr::FGSystemMgr ()
27 set_subsystem( "electrical", new FGElectricalSystem );
29 config_props = new SGPropertyNode;
31 SGPropertyNode *path_n = fgGetNode("/sim/systems/path");
34 SGPath config( globals->get_fg_root() );
35 config.append( path_n->getStringValue() );
37 SG_LOG( SG_ALL, SG_INFO, "Reading systems from "
40 readProperties( config.str(), config_props );
45 SG_LOG( SG_ALL, SG_ALERT,
46 "Detected an internal inconsistancy in the systems");
47 SG_LOG( SG_ALL, SG_ALERT,
48 " system specification file. See earlier errors for" );
49 SG_LOG( SG_ALL, SG_ALERT,
53 } catch (const sg_exception& exc) {
54 SG_LOG( SG_ALL, SG_ALERT, "Failed to load systems system model: "
59 SG_LOG( SG_ALL, SG_WARN,
60 "No systems model specified for this model!");
66 FGSystemMgr::~FGSystemMgr ()
70 bool FGSystemMgr::build ()
75 int count = config_props->nChildren();
76 for ( i = 0; i < count; ++i ) {
77 node = config_props->getChild(i);
78 string name = node->getName();
79 std::ostringstream temp;
81 if ( name == "pitot" ) {
82 set_subsystem( "system" + temp.str(),
83 new PitotSystem( node ) );
84 } else if ( name == "static" ) {
85 set_subsystem( "system" + temp.str(),
86 new StaticSystem( node ) );
87 } else if ( name == "vacuum" ) {
88 set_subsystem( "system" + temp.str(),
89 new VacuumSystem( node ) );
91 SG_LOG( SG_ALL, SG_ALERT, "Unknown top level section: "
99 // end of system_manager.cxx