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.
10 #include <simgear/structure/exception.hxx>
11 #include <simgear/misc/sg_path.hxx>
12 #include <simgear/sg_inlines.h>
14 #include <Main/fg_props.hxx>
15 #include <Main/globals.hxx>
16 #include <Main/util.hxx>
18 #include "instrument_mgr.hxx"
20 #include "airspeed_indicator.hxx"
21 #include "altimeter.hxx"
22 #include "annunciator.hxx"
23 #include "attitude_indicator.hxx"
26 #include "encoder.hxx"
28 #include "heading_indicator.hxx"
31 #include "mag_compass.hxx"
32 #include "marker_beacon.hxx"
33 #include "navradio.hxx"
34 #include "slip_skid_ball.hxx"
35 #include "transponder.hxx"
36 #include "turn_indicator.hxx"
37 #include "vertical_speed_indicator.hxx"
38 #include "inst_vertical_speed_indicator.hxx" // (TJ)
39 #include "od_gauge.hxx"
40 #include "wxradar.hxx"
44 FGInstrumentMgr::FGInstrumentMgr ()
46 set_subsystem("annunciator", new Annunciator);
47 set_subsystem("od_gauge", new FGODGauge, 1.0);
49 config_props = new SGPropertyNode;
51 SGPropertyNode *path_n = fgGetNode("/sim/instrumentation/path");
54 SGPath config( globals->get_fg_root() );
55 config.append( path_n->getStringValue() );
57 SG_LOG( SG_ALL, SG_INFO, "Reading instruments from "
60 readProperties( config.str(), config_props );
65 SG_LOG( SG_ALL, SG_ALERT,
66 "Detected an internal inconsistancy in the instrumentation");
67 SG_LOG( SG_ALL, SG_ALERT,
68 " system specification file. See earlier errors for" );
69 SG_LOG( SG_ALL, SG_ALERT,
73 } catch (const sg_exception& exc) {
74 SG_LOG( SG_ALL, SG_ALERT, "Failed to load instrumentation system model: "
79 SG_LOG( SG_ALL, SG_WARN,
80 "No instrumentation model specified for this model!");
86 FGInstrumentMgr::~FGInstrumentMgr ()
90 bool FGInstrumentMgr::build ()
95 int count = config_props->nChildren();
96 for ( i = 0; i < count; ++i ) {
97 node = config_props->getChild(i);
98 string name = node->getName();
99 cout<< "instrument name: " << name << endl;
100 std::ostringstream temp;
102 if ( name == "adf" ) {
103 set_subsystem( "instrument" + temp.str(),
104 new ADF( node ), 0.15 );
105 } else if ( name == "airspeed-indicator" ) {
106 set_subsystem( "instrument" + temp.str(),
107 new AirspeedIndicator( node ) );
108 } else if ( name == "altimeter" ) {
109 set_subsystem( "instrument" + temp.str(),
110 new Altimeter( node ) );
111 } else if ( name == "attitude-indicator" ) {
112 set_subsystem( "instrument" + temp.str(),
113 new AttitudeIndicator( node ) );
114 } else if ( name == "clock" ) {
115 set_subsystem( "instrument" + temp.str(),
116 new Clock( node ), 0.25 );
117 } else if ( name == "dme" ) {
118 set_subsystem( "instrument" + temp.str(),
119 new DME( node ), 1.0 );
120 } else if ( name == "encoder" ) {
121 set_subsystem( "instrument" + temp.str(),
122 new Encoder( node ) );
123 } else if ( name == "gps" ) {
124 set_subsystem( "instrument" + temp.str(),
125 new GPS( node ), 0.45 );
126 } else if ( name == "heading-indicator" ) {
127 set_subsystem( "instrument" + temp.str(),
128 new HeadingIndicator( node ) );
129 } else if ( name == "KR-87" ) {
130 set_subsystem( "instrument" + temp.str(),
131 new FGKR_87( node ) );
132 } else if ( name == "KT-70" ) {
133 set_subsystem( "instrument" + temp.str(),
134 new FGKT_70( node ) );
135 } else if ( name == "magnetic-compass" ) {
136 set_subsystem( "instrument" + temp.str(),
137 new MagCompass( node ) );
138 } else if ( name == "marker-beacon" ) {
139 set_subsystem( "instrument" + temp.str(),
140 new FGMarkerBeacon( node ) );
141 } else if ( name == "nav-radio" ) {
142 set_subsystem( "instrument" + temp.str(),
143 new FGNavRadio( node ) );
144 } else if ( name == "slip-skid-ball" ) {
145 set_subsystem( "instrument" + temp.str(),
146 new SlipSkidBall( node ) );
147 } else if ( name == "transponder" ) {
148 set_subsystem( "instrument" + temp.str(),
149 new Transponder( node ) );
150 } else if ( name == "turn-indicator" ) {
151 set_subsystem( "instrument" + temp.str(),
152 new TurnIndicator( node ) );
153 } else if ( name == "vertical-speed-indicator" ) {
154 set_subsystem( "instrument" + temp.str(),
155 new VerticalSpeedIndicator( node ) );
156 } else if ( name == "wxradar" ) {
157 set_subsystem( "instrument" + temp.str(),
158 new wxRadarBg ( node ), 0.5 );
159 } else if ( name == "inst-vertical-speed-indicator" ) { // (TJ)
160 set_subsystem( "instrument" + temp.str(),
161 new InstVerticalSpeedIndicator( node ) );
162 } else if ( name == "tacan" ) {
163 set_subsystem( "instrument" + temp.str(),
167 SG_LOG( SG_ALL, SG_ALERT, "Unknown top level section: "
175 // end of instrument_manager.cxx