#include <simgear/structure/exception.hxx>
#include <simgear/misc/sg_path.hxx>
+#include <simgear/debug/logstream.hxx>
+#include <simgear/props/props_io.hxx>
#include <Main/fg_props.hxx>
#include <Main/globals.hxx>
FGElectricalSystem::FGElectricalSystem ( SGPropertyNode *node ) :
- name("electrical"),
- num(0),
- path(""),
+ name(node->getStringValue("name", "electrical")),
+ num(node->getIntValue("number", 0)),
+ path(node->getStringValue("path")),
enabled(false)
{
- int i;
- for ( i = 0; i < node->nChildren(); ++i ) {
- SGPropertyNode *child = node->getChild(i);
- string cname = child->getName();
- string cval = child->getStringValue();
- if ( cname == "name" ) {
- name = cval;
- } else if ( cname == "number" ) {
- num = child->getIntValue();
- } else if ( cname == "path" ) {
- path = cval;
- } else {
- SG_LOG( SG_SYSTEMS, SG_WARN,
- "Error in electrical system config logic" );
- if ( name.length() ) {
- SG_LOG( SG_SYSTEMS, SG_WARN, "Section = " << name );
- }
- }
- }
}
config.append( path );
// load an obsolete xml configuration
- SG_LOG( SG_ALL, SG_ALERT,
- "Reading xml electrical system model from "
+ SG_LOG( SG_ALL, SG_WARN,
+ "Reading deprecated xml electrical system model from\n "
<< config.str() );
try {
readProperties( config.str(), config_props );
" " );
if ( node->apply_load( load, dt ) < 0.0 ) {
- cout << "Error drawing more current than available!" << endl;
+ SG_LOG(SG_ALL, SG_ALERT,
+ "Error drawing more current than available!");
}
}
}
" " );
if ( node->apply_load( load, dt ) < 0.0 ) {
- cout << "Error drawing more current than available!" << endl;
+ SG_LOG(SG_ALL, SG_ALERT,
+ "Error drawing more current than available!");
}
}
}
// cout << "battery load = " << load << endl;
if ( node->apply_load( load, dt ) < 0.0 ) {
- cout << "Error drawing more current than available!" << endl;
+ SG_LOG(SG_ALL, SG_ALERT,
+ "Error drawing more current than available!");
}
}
}