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.
10 #include <simgear/structure/exception.hxx>
11 #include <simgear/misc/sg_path.hxx>
12 #include <simgear/sg_inlines.h>
13 #include <simgear/props/props_io.hxx>
15 #include <Main/fg_props.hxx>
16 #include <Main/globals.hxx>
17 #include <Main/util.hxx>
24 #include "system_mgr.hxx"
25 #include "electrical.hxx"
31 FGSystemMgr::FGSystemMgr ()
33 SGPropertyNode_ptr config_props = new SGPropertyNode;
35 SGPropertyNode *path_n = fgGetNode("/sim/systems/path");
38 SGPath config = globals->resolve_aircraft_path(path_n->getStringValue());
40 SG_LOG( SG_SYSTEMS, SG_INFO, "Reading systems from "
44 readProperties( config.str(), config_props );
47 catch( const sg_exception& )
49 SG_LOG( SG_SYSTEMS, SG_ALERT, "Failed to load systems system model: "
54 SG_LOG( SG_SYSTEMS, SG_WARN,
55 "No systems model specified for this model!");
60 FGSystemMgr::~FGSystemMgr ()
64 bool FGSystemMgr::build (SGPropertyNode* config_props)
69 int count = config_props->nChildren();
70 for ( i = 0; i < count; ++i ) {
71 node = config_props->getChild(i);
72 string name = node->getName();
73 std::ostringstream temp;
75 if ( name == "electrical" ) {
76 set_subsystem( "electrical" + temp.str(),
77 new FGElectricalSystem( node ) );
78 } else if ( name == "pitot" ) {
79 set_subsystem( "system" + temp.str(),
80 new PitotSystem( node ) );
81 } else if ( name == "static" ) {
82 set_subsystem( "system" + temp.str(),
83 new StaticSystem( node ) );
84 } else if ( name == "vacuum" ) {
85 set_subsystem( "system" + temp.str(),
86 new VacuumSystem( node ) );
88 SG_LOG(SG_SYSTEMS, SG_ALERT, "Ignoring unknown system: " << name);
94 // end of system_manager.cxx