]> git.mxchange.org Git - flightgear.git/blobdiff - src/Systems/electrical.cxx
Fix two bugs in the new autopilot code
[flightgear.git] / src / Systems / electrical.cxx
index 0f0439556a685139e21d263b49089b946b5c5ba2..103456a485b899ecb1f6f3ddb21ebb14a69798e1 100644 (file)
@@ -26,6 +26,8 @@
 
 #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>
@@ -346,7 +348,7 @@ FGElectricalSystem::~FGElectricalSystem () {
 
 
 void FGElectricalSystem::init () {
-    config_props = new SGPropertyNode;
+    SGPropertyNode_ptr config_props = new SGPropertyNode;
 
     _volts_out = fgGetNode( "/systems/electrical/volts", true );
     _amps_out = fgGetNode( "/systems/electrical/amps", true );
@@ -379,7 +381,7 @@ void FGElectricalSystem::init () {
         try {
             readProperties( config.str(), config_props );
 
-            if ( build() ) {
+            if ( build(config_props) ) {
                 enabled = true;
             } else {
                 SG_LOG( SG_ALL, SG_ALERT,
@@ -390,7 +392,7 @@ void FGElectricalSystem::init () {
                         "details.");
                 exit(-1);
             }        
-        } catch (const sg_exception& exc) {
+        } catch (const sg_exception&) {
             SG_LOG( SG_ALL, SG_ALERT,
                     "Failed to load electrical system model: "
                     << config.str() );
@@ -404,7 +406,6 @@ void FGElectricalSystem::init () {
         _amps_out->setDoubleValue(0);
     }
 
-    delete config_props;
 }
 
 
@@ -453,7 +454,8 @@ void FGElectricalSystem::update (double dt) {
                               " " );
 
             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!");
             }
         }     
     }
@@ -472,7 +474,8 @@ void FGElectricalSystem::update (double dt) {
                               " " );
 
             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!");
             }
         }     
     }
@@ -492,7 +495,8 @@ void FGElectricalSystem::update (double dt) {
             // 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!");
             }
         }     
     }
@@ -548,7 +552,7 @@ void FGElectricalSystem::update (double dt) {
 }
 
 
-bool FGElectricalSystem::build () {
+bool FGElectricalSystem::build (SGPropertyNode* config_props) {
     SGPropertyNode *node;
     int i;