#include "agradar.hxx"
#include "rad_alt.hxx"
-FGInstrumentMgr::FGInstrumentMgr ()
+FGInstrumentMgr::FGInstrumentMgr () :
+ _explicitGps(false)
{
set_subsystem("od_gauge", new FGODGauge);
set_subsystem("hud", new HUD);
- config_props = new SGPropertyNode;
+ SGPropertyNode_ptr config_props = new SGPropertyNode;
SGPropertyNode *path_n = fgGetNode("/sim/instrumentation/path");
try {
readProperties( config.str(), config_props );
- if ( !build() ) {
- throw sg_throwable(string(
- "Detected an internal inconsistency in the instrumentation\n"
- "system specification file. See earlier errors for details."));
+ if ( !build(config_props) ) {
+ throw sg_error(
+ "Detected an internal inconsistency in the instrumentation\n"
+ "system specification file. See earlier errors for details.");
}
- } catch (const sg_exception& exc) {
+ } catch (const sg_exception&) {
SG_LOG( SG_ALL, SG_ALERT, "Failed to load instrumentation system model: "
<< config.str() );
}
"No instrumentation model specified for this model!");
}
- delete config_props;
+ if (!_explicitGps) {
+ SG_LOG(SG_INSTR, SG_INFO, "creating default GPS instrument");
+ SGPropertyNode_ptr nd(new SGPropertyNode);
+ nd->setStringValue("name", "gps");
+ nd->setIntValue("number", 0);
+ set_subsystem("gps[0]", new GPS(nd));
+ }
}
FGInstrumentMgr::~FGInstrumentMgr ()
{
}
-bool FGInstrumentMgr::build ()
+bool FGInstrumentMgr::build (SGPropertyNode* config_props)
{
for ( int i = 0; i < config_props->nChildren(); ++i ) {
SGPropertyNode *node = config_props->getChild(i);
set_subsystem( id, new Altimeter( node ) );
} else if ( name == "gps" ) {
- set_subsystem( id, new GPS( node ), 0.45 );
-
+ set_subsystem( id, new GPS( node ) );
+ _explicitGps = true;
} else if ( name == "gsdi" ) {
set_subsystem( id, new GSDI( node ) );