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 config_props = new SGPropertyNode;
29 SGPropertyNode *path_n = fgGetNode("/sim/systems/path");
32 SGPath config( globals->get_fg_root() );
33 config.append( path_n->getStringValue() );
35 SG_LOG( SG_ALL, SG_INFO, "Reading systems from "
38 readProperties( config.str(), config_props );
43 SG_LOG( SG_ALL, SG_ALERT,
44 "Detected an internal inconsistency in the systems");
45 SG_LOG( SG_ALL, SG_ALERT,
46 " system specification file. See earlier errors for" );
47 SG_LOG( SG_ALL, SG_ALERT,
51 } catch (const sg_exception& exc) {
52 SG_LOG( SG_ALL, SG_ALERT, "Failed to load systems system model: "
57 SG_LOG( SG_ALL, SG_WARN,
58 "No systems model specified for this model!");
64 FGSystemMgr::~FGSystemMgr ()
68 bool FGSystemMgr::build ()
73 int count = config_props->nChildren();
74 for ( i = 0; i < count; ++i ) {
75 node = config_props->getChild(i);
76 string name = node->getName();
77 std::ostringstream temp;
79 if ( name == "electrical" ) {
80 set_subsystem( "electrical" + temp.str(),
81 new FGElectricalSystem( node ) );
82 } else if ( name == "pitot" ) {
83 set_subsystem( "system" + temp.str(),
84 new PitotSystem( node ) );
85 } else if ( name == "static" ) {
86 set_subsystem( "system" + temp.str(),
87 new StaticSystem( node ) );
88 } else if ( name == "vacuum" ) {
89 set_subsystem( "system" + temp.str(),
90 new VacuumSystem( node ) );
92 SG_LOG( SG_ALL, SG_ALERT, "Unknown top level section: "
100 // end of system_manager.cxx