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)
41 FGInstrumentMgr::FGInstrumentMgr ()
43 set_subsystem("annunciator", new Annunciator);
45 config_props = new SGPropertyNode;
47 SGPropertyNode *path_n = fgGetNode("/sim/instrumentation/path");
50 SGPath config( globals->get_fg_root() );
51 config.append( path_n->getStringValue() );
53 SG_LOG( SG_ALL, SG_INFO, "Reading instruments from "
56 readProperties( config.str(), config_props );
61 SG_LOG( SG_ALL, SG_ALERT,
62 "Detected an internal inconsistancy in the instrumentation");
63 SG_LOG( SG_ALL, SG_ALERT,
64 " system specification file. See earlier errors for" );
65 SG_LOG( SG_ALL, SG_ALERT,
69 } catch (const sg_exception& exc) {
70 SG_LOG( SG_ALL, SG_ALERT, "Failed to load instrumentation system model: "
75 SG_LOG( SG_ALL, SG_WARN,
76 "No instrumentation model specified for this model!");
82 FGInstrumentMgr::~FGInstrumentMgr ()
86 bool FGInstrumentMgr::build ()
91 int count = config_props->nChildren();
92 for ( i = 0; i < count; ++i ) {
93 node = config_props->getChild(i);
94 string name = node->getName();
95 std::ostringstream temp;
97 if ( name == "adf" ) {
98 set_subsystem( "instrument" + temp.str(),
99 new ADF( node ), 0.15 );
100 } else if ( name == "airspeed-indicator" ) {
101 set_subsystem( "instrument" + temp.str(),
102 new AirspeedIndicator( node ) );
103 } else if ( name == "altimeter" ) {
104 set_subsystem( "instrument" + temp.str(),
105 new Altimeter( node ) );
106 } else if ( name == "attitude-indicator" ) {
107 set_subsystem( "instrument" + temp.str(),
108 new AttitudeIndicator( node ) );
109 } else if ( name == "clock" ) {
110 set_subsystem( "instrument" + temp.str(),
111 new Clock( node ), 0.25 );
112 } else if ( name == "dme" ) {
113 set_subsystem( "instrument" + temp.str(),
114 new DME( node ), 1.0 );
115 } else if ( name == "encoder" ) {
116 set_subsystem( "instrument" + temp.str(),
117 new Encoder( node ) );
118 } else if ( name == "gps" ) {
119 set_subsystem( "instrument" + temp.str(),
120 new GPS( node ), 0.45 );
121 } else if ( name == "heading-indicator" ) {
122 set_subsystem( "instrument" + temp.str(),
123 new HeadingIndicator( node ) );
124 } else if ( name == "KR-87" ) {
125 set_subsystem( "instrument" + temp.str(),
126 new FGKR_87( node ) );
127 } else if ( name == "KT-70" ) {
128 set_subsystem( "instrument" + temp.str(),
129 new FGKT_70( node ) );
130 } else if ( name == "magnetic-compass" ) {
131 set_subsystem( "instrument" + temp.str(),
132 new MagCompass( node ) );
133 } else if ( name == "marker-beacon" ) {
134 set_subsystem( "instrument" + temp.str(),
135 new FGMarkerBeacon( node ) );
136 } else if ( name == "nav-radio" ) {
137 set_subsystem( "instrument" + temp.str(),
138 new FGNavRadio( node ) );
139 } else if ( name == "slip-skid-ball" ) {
140 set_subsystem( "instrument" + temp.str(),
141 new SlipSkidBall( node ) );
142 } else if ( name == "transponder" ) {
143 set_subsystem( "instrument" + temp.str(),
144 new Transponder( node ) );
145 } else if ( name == "turn-indicator" ) {
146 set_subsystem( "instrument" + temp.str(),
147 new TurnIndicator( node ) );
148 } else if ( name == "vertical-speed-indicator" ) {
149 set_subsystem( "instrument" + temp.str(),
150 new VerticalSpeedIndicator( node ) );
151 } else if ( name == "inst-vertical-speed-indicator" ) { // (TJ)
152 set_subsystem( "instrument" + temp.str(),
153 new InstVerticalSpeedIndicator( node ) );
155 SG_LOG( SG_ALL, SG_ALERT, "Unknown top level section: "
163 // end of instrument_manager.cxx