]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/JSBSim/FGOutput.cpp
Check return value of FDM::init().
[flightgear.git] / src / FDM / JSBSim / FGOutput.cpp
index a9fc0cac1bc3015f9ed1b032d305e992db5a3651..e61bf5a408d5260242364efff456a63b6a812ca1 100644 (file)
@@ -49,6 +49,9 @@ INCLUDES
 #include "FGPosition.h"
 #include "FGAuxiliary.h"
 
+static const char *IdSrc = "$Header$";
+static const char *IdHdr = ID_OUTPUT;
+
 /*******************************************************************************
 ************************************ CODE **************************************
 *******************************************************************************/
@@ -61,6 +64,7 @@ FGOutput::FGOutput(FGFDMExec* fdmex) : FGModel(fdmex)
   Type = otNone;
   Filename = "JSBSim.out";
   SubSystems = 0;
+  enabled = true;
   
 #ifdef FG_WITH_JSBSIM_SOCKET
   socket = new FGfdmSocket("localhost",1138);
@@ -78,27 +82,28 @@ FGOutput::~FGOutput(void)
 
 bool FGOutput::Run(void)
 {
-  if (!FGModel::Run()) {
-
-    if (Type == otSocket) {
-      SocketOutput();
-    } else if (Type == otCSV) {
-      if (Filename != "COUT" && Filename != "cout" && Filename.size() > 0) {
-        DelimitedOutput(Filename);
+  if (enabled) {
+    if (!FGModel::Run()) {
+
+      if (Type == otSocket) {
+        SocketOutput();
+      } else if (Type == otCSV) {
+        if (Filename != "COUT" && Filename != "cout" && Filename.size() > 0) {
+          DelimitedOutput(Filename);
+        } else {
+          DelimitedOutput();
+        }
+      } else if (Type == otTerminal) {
+        // Not done yet
+      } else if (Type == otNone) {
+        // Do nothing
       } else {
-        DelimitedOutput();
+        // Not a valid type of output
       }
-    } else if (Type == otTerminal) {
-      // Not done yet
-    } else if (Type == otNone) {
-      // Do nothing
+
     } else {
-      // Not a valid type of output
     }
-
-  } else {
   }
-
   return false;
 }
 
@@ -411,7 +416,7 @@ void FGOutput::SocketOutput(void)
 {
   string asciiData;
   /*
-  if (socket <= 0) return;
+  if (socket == NULL) return;
 
   socket->Clear();
   if (sFirstPass) {
@@ -502,7 +507,7 @@ void FGOutput::SocketStatusOutput(string out_str)
 {
   string asciiData;
 
-  if (socket <= 0) return;
+  if (socket == NULL) return;
 
   socket->Clear();
   asciiData = string("<STATUS>") + out_str;