1 // instrument_mgr.cxx - manage aircraft instruments.
2 // Written by David Megginson, started 2002.
4 // This file is in the Public Domain and comes with no warranty.
14 #include <simgear/structure/exception.hxx>
15 #include <simgear/misc/sg_path.hxx>
16 #include <simgear/sg_inlines.h>
18 #include <Main/fg_props.hxx>
19 #include <Main/globals.hxx>
20 #include <Main/util.hxx>
21 #include <Instrumentation/HUD/HUD.hxx>
23 #include "instrument_mgr.hxx"
25 #include "airspeed_indicator.hxx"
26 #include "altimeter.hxx"
27 #include "annunciator.hxx"
28 #include "attitude_indicator.hxx"
31 #include "encoder.hxx"
34 #include "heading_indicator.hxx"
35 #include "heading_indicator_fg.hxx"
38 #include "mag_compass.hxx"
39 #include "marker_beacon.hxx"
40 #include "navradio.hxx"
41 #include "slip_skid_ball.hxx"
42 #include "transponder.hxx"
43 #include "turn_indicator.hxx"
44 #include "vertical_speed_indicator.hxx"
45 #include "inst_vertical_speed_indicator.hxx" // (TJ)
46 #include "od_gauge.hxx"
47 #include "wxradar.hxx"
49 #include "mk_viii.hxx"
52 FGInstrumentMgr::FGInstrumentMgr ()
54 set_subsystem("annunciator", new Annunciator);
55 set_subsystem("od_gauge", new FGODGauge, 1.0);
56 set_subsystem("hud", new HUD);
58 config_props = new SGPropertyNode;
60 SGPropertyNode *path_n = fgGetNode("/sim/instrumentation/path");
63 SGPath config( globals->get_fg_root() );
64 config.append( path_n->getStringValue() );
66 SG_LOG( SG_ALL, SG_INFO, "Reading instruments from "
69 readProperties( config.str(), config_props );
72 throw sg_throwable(string(
73 "Detected an internal inconsistency in the instrumentation\n"
74 "system specification file. See earlier errors for details."));
76 } catch (const sg_exception& exc) {
77 SG_LOG( SG_ALL, SG_ALERT, "Failed to load instrumentation system model: "
82 SG_LOG( SG_ALL, SG_WARN,
83 "No instrumentation model specified for this model!");
89 FGInstrumentMgr::~FGInstrumentMgr ()
93 bool FGInstrumentMgr::build ()
98 int count = config_props->nChildren();
99 for ( i = 0; i < count; ++i ) {
100 node = config_props->getChild(i);
101 string name = node->getName();
102 std::ostringstream temp;
104 if ( name == "adf" ) {
105 set_subsystem( "instrument" + temp.str(),
106 new ADF( node ), 0.15 );
107 } else if ( name == "airspeed-indicator" ) {
108 set_subsystem( "instrument" + temp.str(),
109 new AirspeedIndicator( node ) );
110 } else if ( name == "altimeter" ) {
111 set_subsystem( "instrument" + temp.str(),
112 new Altimeter( node ) );
113 } else if ( name == "attitude-indicator" ) {
114 set_subsystem( "instrument" + temp.str(),
115 new AttitudeIndicator( node ) );
116 } else if ( name == "clock" ) {
117 set_subsystem( "instrument" + temp.str(),
118 new Clock( node ), 0.25 );
119 } else if ( name == "dme" ) {
120 set_subsystem( "instrument" + temp.str(),
121 new DME( node ), 1.0 );
122 } else if ( name == "encoder" ) {
123 set_subsystem( "instrument" + temp.str(),
124 new Encoder( node ) );
125 } else if ( name == "gps" ) {
126 set_subsystem( "instrument" + temp.str(),
127 new GPS( node ), 0.45 );
128 } else if ( name == "gsdi" ) {
129 set_subsystem( "instrument" + temp.str(),
131 } else if ( name == "heading-indicator" ) {
132 set_subsystem( "instrument" + temp.str(),
133 new HeadingIndicator( node ) );
134 } else if ( name == "heading-indicator-fg" ) {
135 set_subsystem( "instrument" + temp.str(),
136 new HeadingIndicatorFG( node ) );
137 } else if ( name == "KR-87" ) {
138 set_subsystem( "instrument" + temp.str(),
139 new FGKR_87( node ) );
140 } else if ( name == "KT-70" ) {
141 set_subsystem( "instrument" + temp.str(),
142 new FGKT_70( node ) );
143 } else if ( name == "magnetic-compass" ) {
144 set_subsystem( "instrument" + temp.str(),
145 new MagCompass( node ) );
146 } else if ( name == "marker-beacon" ) {
147 set_subsystem( "instrument" + temp.str(),
148 new FGMarkerBeacon( node ) );
149 } else if ( name == "nav-radio" ) {
150 set_subsystem( "instrument" + temp.str(),
151 new FGNavRadio( node ) );
152 } else if ( name == "slip-skid-ball" ) {
153 set_subsystem( "instrument" + temp.str(),
154 new SlipSkidBall( node ) );
155 } else if ( name == "transponder" ) {
156 set_subsystem( "instrument" + temp.str(),
157 new Transponder( node ) );
158 } else if ( name == "turn-indicator" ) {
159 set_subsystem( "instrument" + temp.str(),
160 new TurnIndicator( node ) );
161 } else if ( name == "vertical-speed-indicator" ) {
162 set_subsystem( "instrument" + temp.str(),
163 new VerticalSpeedIndicator( node ) );
164 } else if ( name == "wxradar" ) {
165 set_subsystem( "instrument" + temp.str(),
166 new wxRadarBg ( node ), 0.5 );
167 } else if ( name == "inst-vertical-speed-indicator" ) { // (TJ)
168 set_subsystem( "instrument" + temp.str(),
169 new InstVerticalSpeedIndicator( node ) );
170 } else if ( name == "tacan" ) {
171 set_subsystem( "instrument" + temp.str(),
173 } else if ( name == "mk-viii" ) {
174 set_subsystem( "instrument" + temp.str(),
175 new MK_VIII( node ) );
177 SG_LOG( SG_ALL, SG_ALERT, "Unknown top level section: "
185 // end of instrument_manager.cxx