]> 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 5e90adb18f18b08645550ffb79afe35fca5fbd5f..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;
 }
 
@@ -186,6 +191,10 @@ void FGOutput::DelimitedOutput(void)
       cout << ", ";
       cout << Aircraft->GetCoefficientStrings();
     }
+    if (SubSystems & FGAircraft::ssGroundReactions) {
+      cout << ", ";
+      cout << Aircraft->GetGroundReactionStrings();
+    }
 
     cout << endl;
     dFirstPass = false;
@@ -251,6 +260,10 @@ void FGOutput::DelimitedOutput(void)
     cout << ", ";
     cout << Aircraft->GetCoefficientValues();
   }
+  if (SubSystems & FGAircraft::ssGroundReactions) {
+    cout << ", ";
+    cout << Aircraft->GetGroundReactionValues();
+  }
   cout << endl;
 }
 
@@ -321,6 +334,10 @@ void FGOutput::DelimitedOutput(string fname)
       datafile << ", ";
       datafile << Aircraft->GetCoefficientStrings();
     }
+    if (SubSystems & FGAircraft::ssGroundReactions) {
+      datafile << ", ";
+      datafile << Aircraft->GetGroundReactionStrings();
+    }
     datafile << endl;
     sFirstPass = false;
   }
@@ -385,6 +402,10 @@ void FGOutput::DelimitedOutput(string fname)
     datafile << ", ";
     datafile << Aircraft->GetCoefficientValues();
   }
+  if (SubSystems & FGAircraft::ssGroundReactions) {
+    datafile << ", ";
+    datafile << Aircraft->GetGroundReactionValues();
+  }
   datafile << endl;
   datafile.flush();
 }
@@ -395,7 +416,7 @@ void FGOutput::SocketOutput(void)
 {
   string asciiData;
   /*
-  if (socket <= 0) return;
+  if (socket == NULL) return;
 
   socket->Clear();
   if (sFirstPass) {
@@ -486,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;