]> git.mxchange.org Git - flightgear.git/blob - src/Systems/system_mgr.cxx
Remove debug console output in FGApproachController
[flightgear.git] / src / Systems / system_mgr.cxx
1 // system_mgr.cxx - manage aircraft systems.
2 // Written by David Megginson, started 2002.
3 //
4 // This file is in the Public Domain and comes with no warranty.
5
6 #ifdef HAVE_CONFIG_H
7 #  include <config.h>
8 #endif
9
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>
14
15 #include <Main/fg_props.hxx>
16 #include <Main/globals.hxx>
17 #include <Main/util.hxx>
18
19 #include <cstdlib>
20 #include <iostream>
21 #include <string>
22 #include <sstream>
23
24 #include "system_mgr.hxx"
25 #include "electrical.hxx"
26 #include "pitot.hxx"
27 #include "static.hxx"
28 #include "vacuum.hxx"
29
30
31 FGSystemMgr::FGSystemMgr ()
32 {
33     SGPropertyNode_ptr config_props = new SGPropertyNode;
34
35     SGPropertyNode *path_n = fgGetNode("/sim/systems/path");
36
37     if (path_n) {
38         SGPath config = globals->resolve_aircraft_path(path_n->getStringValue());
39
40         SG_LOG( SG_SYSTEMS, SG_INFO, "Reading systems from "
41                 << config.str() );
42         try
43         {
44           readProperties( config.str(), config_props );
45           build(config_props);
46         }
47         catch( const sg_exception& )
48         {
49           SG_LOG( SG_SYSTEMS, SG_ALERT, "Failed to load systems system model: "
50                   << config.str() );
51         }
52
53     } else {
54         SG_LOG( SG_SYSTEMS, SG_WARN,
55                 "No systems model specified for this model!");
56     }
57
58 }
59
60 FGSystemMgr::~FGSystemMgr ()
61 {
62 }
63
64 bool FGSystemMgr::build (SGPropertyNode* config_props)
65 {
66     SGPropertyNode *node;
67     int i;
68
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;
74         temp << i;
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 ) );
87         } else {
88             SG_LOG(SG_SYSTEMS, SG_ALERT, "Ignoring unknown system: " << name);
89         }
90     }
91     return true;
92 }
93
94 // end of system_manager.cxx