]> git.mxchange.org Git - flightgear.git/blob - src/Instrumentation/instrument_mgr.cxx
Added copyright to ground radar files
[flightgear.git] / src / Instrumentation / instrument_mgr.cxx
1 // instrument_mgr.cxx - manage aircraft instruments.
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 <iostream>
11 #include <string>
12 #include <sstream>
13
14 #include <simgear/structure/exception.hxx>
15 #include <simgear/misc/sg_path.hxx>
16 #include <simgear/sg_inlines.h>
17
18 #include <Main/fg_props.hxx>
19 #include <Main/globals.hxx>
20 #include <Main/util.hxx>
21 #include <Instrumentation/HUD/HUD.hxx>
22
23 #include "instrument_mgr.hxx"
24 #include "adf.hxx"
25 #include "airspeed_indicator.hxx"
26 #include "altimeter.hxx"
27 #include "attitude_indicator.hxx"
28 #include "clock.hxx"
29 #include "dme.hxx"
30 #include "gps.hxx"
31 #include "gsdi.hxx"
32 #include "heading_indicator.hxx"
33 #include "heading_indicator_fg.hxx"
34 #include "heading_indicator_dg.hxx"
35 #include "kr_87.hxx"
36 #include "kt_70.hxx"
37 #include "mag_compass.hxx"
38 #include "marker_beacon.hxx"
39 #include "navradio.hxx"
40 #include "slip_skid_ball.hxx"
41 #include "transponder.hxx"
42 #include "turn_indicator.hxx"
43 #include "vertical_speed_indicator.hxx"
44 #include "inst_vertical_speed_indicator.hxx" // (TJ)
45 #include "od_gauge.hxx"
46 #include "wxradar.hxx"
47 #include "tacan.hxx"
48 #include "mk_viii.hxx"
49 #include "mrg.hxx"
50 #include "groundradar.hxx"
51
52 FGInstrumentMgr::FGInstrumentMgr ()
53 {
54     set_subsystem("od_gauge", new FGODGauge);
55     set_subsystem("hud", new HUD);
56
57     config_props = new SGPropertyNode;
58
59     SGPropertyNode *path_n = fgGetNode("/sim/instrumentation/path");
60
61     if (path_n) {
62         SGPath config( globals->get_fg_root() );
63         config.append( path_n->getStringValue() );
64
65         SG_LOG( SG_ALL, SG_INFO, "Reading instruments from "
66                 << config.str() );
67         try {
68             readProperties( config.str(), config_props );
69
70             if ( !build() ) {
71                 throw sg_throwable(string(
72                         "Detected an internal inconsistency in the instrumentation\n"
73                         "system specification file.  See earlier errors for details."));
74             }
75         } catch (const sg_exception& exc) {
76             SG_LOG( SG_ALL, SG_ALERT, "Failed to load instrumentation system model: "
77                     << config.str() );
78         }
79
80     } else {
81         SG_LOG( SG_ALL, SG_WARN,
82                 "No instrumentation model specified for this model!");
83     }
84
85     delete config_props;
86 }
87
88 FGInstrumentMgr::~FGInstrumentMgr ()
89 {
90 }
91
92 bool FGInstrumentMgr::build ()
93 {
94     SGPropertyNode *node;
95     int i;
96
97     int count = config_props->nChildren();
98     for ( i = 0; i < count; ++i ) {
99         node = config_props->getChild(i);
100         string name = node->getName();
101         std::ostringstream temp;
102         temp << i;
103         if ( name == "adf" ) {
104             set_subsystem( "instrument" + temp.str(), 
105                            new ADF( node ), 0.15 );
106         } else if ( name == "airspeed-indicator" ) {
107             set_subsystem( "instrument" + temp.str(), 
108                            new AirspeedIndicator( node ) );
109         } else if ( name == "altimeter" ) {
110             set_subsystem( "instrument" + temp.str(), 
111                            new Altimeter( node ) );
112         } else if ( name == "attitude-indicator" ) {
113             set_subsystem( "instrument" + temp.str(), 
114                            new AttitudeIndicator( node ) );
115         } else if ( name == "clock" ) {
116             set_subsystem( "instrument" + temp.str(), 
117                            new Clock( node ), 0.25 );
118         } else if ( name == "dme" ) {
119             set_subsystem( "instrument" + temp.str(), 
120                            new DME( node ), 1.0 );
121         } else if ( name == "encoder" ) {
122             set_subsystem( "instrument" + temp.str(), 
123                            new Altimeter( node ) );
124         } else if ( name == "gps" ) {
125             set_subsystem( "instrument" + temp.str(), 
126                            new GPS( node ), 0.45 );
127         } else if ( name == "gsdi" ) {
128             set_subsystem( "instrument" + temp.str(),
129                            new GSDI( node ) );
130         } else if ( name == "heading-indicator" ) {
131             set_subsystem( "instrument" + temp.str(), 
132                            new HeadingIndicator( node ) );
133         } else if ( name == "heading-indicator-fg" ) {
134             set_subsystem( "instrument" + temp.str(), 
135                            new HeadingIndicatorFG( node ) );
136         } else if ( name == "heading-indicator-dg" ) {
137             set_subsystem( "instrument" + temp.str(), 
138                            new HeadingIndicatorDG( node ) );
139         } else if ( name == "KR-87" ) {
140             set_subsystem( "instrument" + temp.str(), 
141                            new FGKR_87( node ) );
142         } else if ( name == "KT-70" ) {
143             set_subsystem( "instrument" + temp.str(), 
144                            new FGKT_70( node ) );
145         } else if ( name == "magnetic-compass" ) {
146             set_subsystem( "instrument" + temp.str(), 
147                            new MagCompass( node ) );
148         } else if ( name == "marker-beacon" ) {
149             set_subsystem( "instrument" + temp.str(), 
150                            new FGMarkerBeacon( node ) );
151         } else if ( name == "nav-radio" ) {
152             set_subsystem( "instrument" + temp.str(), 
153                            new FGNavRadio( node ) );
154         } else if ( name == "slip-skid-ball" ) {
155             set_subsystem( "instrument" + temp.str(), 
156                            new SlipSkidBall( node ) );
157         } else if ( name == "transponder" ) {
158             set_subsystem( "instrument" + temp.str(), 
159                            new Transponder( node ) );
160         } else if ( name == "turn-indicator" ) {
161             set_subsystem( "instrument" + temp.str(), 
162                            new TurnIndicator( node ) );
163         } else if ( name == "vertical-speed-indicator" ) {
164             set_subsystem( "instrument" + temp.str(), 
165                            new VerticalSpeedIndicator( node ) );
166         } else if ( name == "radar" ) {
167             set_subsystem( "instrument" + temp.str(), 
168                            new wxRadarBg ( node ), 0.5 );
169         } else if ( name == "inst-vertical-speed-indicator" ) { // (TJ)
170             set_subsystem( "instrument" + temp.str(), 
171                            new InstVerticalSpeedIndicator( node ) );
172         } else if ( name == "tacan" ) { 
173             set_subsystem( "instrument" + temp.str(), 
174                            new TACAN( node ) );
175         } else if ( name == "mk-viii" ) { 
176             set_subsystem( "instrument" + temp.str(), 
177                            new MK_VIII( node ) );
178         } else if ( name == "master-reference-gyro" ) { 
179             set_subsystem( "instrument" + temp.str(), 
180                            new MasterReferenceGyro( node ) );
181         } else if ( name == "groundradar" ) { 
182             set_subsystem( "instrument" + temp.str(), 
183                            new GroundRadar( node ), 1 );
184
185         } else {
186             SG_LOG( SG_ALL, SG_ALERT, "Unknown top level section: " 
187                     << name );
188             return false;
189         }
190     }
191     return true;
192 }
193
194 // end of instrument_manager.cxx