]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/JSBSim/FGOutput.cpp
Fix stall widths for the "auxilliary" (reverse flow) stalls so they
[flightgear.git] / src / FDM / JSBSim / FGOutput.cpp
index e03f0266ef3aafcb3b76ef71a41baf4e289a33b6..dc3e43facb197af9cf7cd35e5a06df378193b1c4 100644 (file)
@@ -28,7 +28,7 @@
 FUNCTIONAL DESCRIPTION
 --------------------------------------------------------------------------------
 This is the place where you create output routines to dump data for perusal
-later. 
+later.
 
 HISTORY
 --------------------------------------------------------------------------------
@@ -44,18 +44,20 @@ INCLUDES
 #include "FGAtmosphere.h"
 #include "FGFCS.h"
 #include "FGAerodynamics.h"
+#include "FGGroundReactions.h"
 #include "FGAircraft.h"
 #include "FGMassBalance.h"
-#include "FGTranslation.h"
-#include "FGRotation.h"
-#include "FGPosition.h"
+#include "FGPropagate.h"
 #include "FGAuxiliary.h"
+#include "FGInertial.h"
+
+#include <iomanip>
+
+namespace JSBSim {
 
 static const char *IdSrc = "$Id$";
 static const char *IdHdr = ID_OUTPUT;
 
-extern short debug_lvl;
-
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 CLASS IMPLEMENTATION
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
@@ -66,14 +68,13 @@ FGOutput::FGOutput(FGFDMExec* fdmex) : FGModel(fdmex)
   sFirstPass = dFirstPass = true;
   socket = 0;
   Type = otNone;
-  Filename = "JSBSim.out";
+  Filename = "";
   SubSystems = 0;
   enabled = true;
-  
-#ifdef FG_WITH_JSBSIM_SOCKET
-  socket = new FGfdmSocket("localhost",1138);
-#endif
-  if (debug_lvl & 2) cout << "Instantiated: " << Name << endl;
+  outputInFileName = "";
+  delimeter = ", ";
+
+  Debug(0);
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -81,7 +82,9 @@ FGOutput::FGOutput(FGFDMExec* fdmex) : FGModel(fdmex)
 FGOutput::~FGOutput()
 {
   if (socket) delete socket;
-  if (debug_lvl & 2) cout << "Destroyed:    FGOutput" << endl;
+  for (unsigned int i=0; i<OutputProperties.size(); i++) delete OutputProperties[i];
+
+  Debug(1);
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -89,25 +92,17 @@ FGOutput::~FGOutput()
 bool FGOutput::Run(void)
 {
   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 {
-        // Not a valid type of output
-      }
-
+    if (FGModel::Run()) return true;
+    if (Type == otSocket) {
+      SocketOutput();
+    } else if (Type == otCSV || Type == otTab) {
+      DelimitedOutput(Filename);
+    } else if (Type == otTerminal) {
+      // Not done yet
+    } else if (Type == otNone) {
+      // Do nothing
     } else {
+      // Not a valid type of output
     }
   }
   return false;
@@ -119,13 +114,15 @@ void FGOutput::SetType(string type)
 {
   if (type == "CSV") {
     Type = otCSV;
+    delimeter = ", ";
   } else if (type == "TABULAR") {
     Type = otTab;
+    delimeter = "\t";
   } else if (type == "SOCKET") {
     Type = otSocket;
   } else if (type == "TERMINAL") {
     Type = otTerminal;
-  } else if (type != "NONE"){
+  } else if (type != string("NONE")) {
     Type = otUnknown;
     cerr << "Unknown type of output specified in config file" << endl;
   }
@@ -133,316 +130,199 @@ void FGOutput::SetType(string type)
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-void FGOutput::DelimitedOutput(void)
+void FGOutput::DelimitedOutput(string fname)
 {
-  if (dFirstPass) {
-    cout << "Time";
-    if (SubSystems & FGAircraft::ssSimulation) {
-      // Nothing here, yet
-    }
-    if (SubSystems & FGAircraft::ssAerosurfaces) {
-      cout << ", ";
-      cout << "Throttle, ";
-      cout << "Aileron Cmd, ";
-      cout << "Elevator Cmd, ";
-      cout << "Rudder Cmd, ";
-      cout << "Aileron Pos, ";
-      cout << "Elevator Pos, ";
-      cout << "Rudder Pos";
-    }
-    if (SubSystems & FGAircraft::ssRates) {
-      cout << ", ";
-      cout << "P, Q, R";
-    }
-    if (SubSystems & FGAircraft::ssVelocities) {
-      cout << ", ";
-      cout << "QBar, ";
-      cout << "Vtotal, ";
-      cout << "U, V, W, ";
-      cout << "Vn, Ve, Vd";
-    }
-    if (SubSystems & FGAircraft::ssForces) {
-      cout << ", ";
-      cout << "Drag, Side, Lift, ";
-      cout << "L/D, ";
-      cout << "Xforce, Yforce, Zforce";
-    }
-    if (SubSystems & FGAircraft::ssMoments) {
-      cout << ", ";
-      cout << "L, M, N";
-    }
-    if (SubSystems & FGAircraft::ssAtmosphere) {
-      cout << ", ";
-      cout << "Rho";
-    }
-    if (SubSystems & FGAircraft::ssMassProps) {
-      cout << ", ";
-      cout << "Ixx, ";
-      cout << "Iyy, ";
-      cout << "Izz, ";
-      cout << "Ixz, ";
-      cout << "Mass, ";
-      cout << "Xcg, Ycg, Zcg";
-    }
-    if (SubSystems & FGAircraft::ssPosition) {
-      cout << ", ";
-      cout << "Altitude, ";
-      cout << "Phi, Tht, Psi, ";
-      cout << "Alpha, ";
-      cout << "Latitude, ";
-      cout << "Longitude, ";
-      cout << "Distance AGL, ";
-      cout << "Runway Radius";
-    }
-    if (SubSystems & FGAircraft::ssCoefficients) {
-      cout << ", ";
-      cout << Aerodynamics->GetCoefficientStrings();
-    }
-    if (SubSystems & FGAircraft::ssGroundReactions) {
-      cout << ", ";
-      cout << Aircraft->GetGroundReactionStrings();
-    }
-    if (SubSystems & FGAircraft::ssPropulsion) {
-      cout << ", ";
-      cout << Propulsion->GetPropulsionStrings();
-    }
-
-    cout << endl;
-    dFirstPass = false;
-  }
+  streambuf* buffer;
+  string scratch = "";
 
-  cout << State->Getsim_time();
-  if (SubSystems & FGAircraft::ssSimulation) {
-  }
-  if (SubSystems & FGAircraft::ssAerosurfaces) {
-    cout << ", ";
-    cout << FCS->GetThrottlePos(0) << ", ";
-    cout << FCS->GetDaCmd() << ", ";
-    cout << FCS->GetDeCmd() << ", ";
-    cout << FCS->GetDrCmd() << ", ";
-    cout << FCS->GetDaPos() << ", ";
-    cout << FCS->GetDePos() << ", ";
-    cout << FCS->GetDrPos();
-  }
-  if (SubSystems & FGAircraft::ssRates) {
-    cout << ", ";
-    cout << Rotation->GetPQR();
-  }
-  if (SubSystems & FGAircraft::ssVelocities) {
-    cout << ", ";
-    cout << Translation->Getqbar() << ", ";
-    cout << Translation->GetVt() << ", ";
-    cout << Translation->GetUVW() << ", ";
-    cout << Position->GetVel();
-  }
-  if (SubSystems & FGAircraft::ssForces) {
-    cout << ", ";
-    cout << Aerodynamics->GetvFs() << ", ";
-    cout << Aerodynamics->GetLoD() << ", ";
-    cout << Aircraft->GetForces();
-  }
-  if (SubSystems & FGAircraft::ssMoments) {
-    cout << ", ";
-    cout << Aircraft->GetMoments();
-  }
-  if (SubSystems & FGAircraft::ssAtmosphere) {
-    cout << ", ";
-    cout << Atmosphere->GetDensity();
-  }
-  if (SubSystems & FGAircraft::ssMassProps) {
-    cout << ", ";
-    cout << MassBalance->GetIxx() << ", ";
-    cout << MassBalance->GetIyy() << ", ";
-    cout << MassBalance->GetIzz() << ", ";
-    cout << MassBalance->GetIxz() << ", ";
-    cout << MassBalance->GetMass() << ", ";
-    cout << MassBalance->GetXYZcg();
-  }
-  if (SubSystems & FGAircraft::ssPosition) {
-    cout << ", ";
-    cout << Position->Geth() << ", ";
-    cout << Rotation->GetEuler() << ", ";
-    cout << Translation->Getalpha() << ", ";
-    cout << Position->GetLatitude() << ", ";
-    cout << Position->GetLongitude() << ", ";
-    cout << Position->GetDistanceAGL() << ", ";
-    cout << Position->GetRunwayRadius();
-  }
-  if (SubSystems & FGAircraft::ssCoefficients) {
-    cout << ", ";
-    cout << Aerodynamics->GetCoefficientValues();
-  }
-  if (SubSystems & FGAircraft::ssGroundReactions) {
-    cout << ", ";
-    cout << Aircraft->GetGroundReactionValues();
-  }
-  if (SubSystems & FGAircraft::ssPropulsion) {
-    cout << ", ";
-    cout << Propulsion->GetPropulsionValues();
+  if (fname == "COUT" || fname == "cout") {
+    buffer = cout.rdbuf();
+  } else {
+    datafile.open(fname.c_str());
+    buffer = datafile.rdbuf();
   }
 
-  cout << endl;
-}
-
-//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+  ostream outstream(buffer);
 
-void FGOutput::DelimitedOutput(string fname)
-{
-  if (sFirstPass) {
-    datafile.open(fname.c_str());
-    datafile << "Time";
-    if (SubSystems & FGAircraft::ssSimulation) {
+  if (dFirstPass) {
+    outstream << "Time";
+    if (SubSystems & ssSimulation) {
       // Nothing here, yet
     }
-    if (SubSystems & FGAircraft::ssAerosurfaces) {
-      datafile << ", ";
-      datafile << "Throttle, ";
-      datafile << "Aileron Cmd, ";
-      datafile << "Elevator Cmd, ";
-      datafile << "Rudder Cmd, ";
-      datafile << "Aileron Pos, ";
-      datafile << "Elevator Pos, ";
-      datafile << "Rudder Pos";
-    }
-    if (SubSystems & FGAircraft::ssRates) {
-      datafile << ", ";
-      datafile << "P, Q, R";
-    }
-    if (SubSystems & FGAircraft::ssVelocities) {
-      datafile << ", ";
-      datafile << "QBar, ";
-      datafile << "Vtotal, ";
-      datafile << "U, V, W, ";
-      datafile << "Vn, Ve, Vd";
-    }
-    if (SubSystems & FGAircraft::ssForces) {
-      datafile << ", ";
-      datafile << "Drag, Side, Lift, ";
-      datafile << "L/D, ";
-      datafile << "Xforce, Yforce, Zforce";
-    }
-    if (SubSystems & FGAircraft::ssMoments) {
-      datafile << ", ";
-      datafile << "L, M, N";
-    }
-    if (SubSystems & FGAircraft::ssAtmosphere) {
-      datafile << ", ";
-      datafile << "Rho";
-    }
-    if (SubSystems & FGAircraft::ssMassProps) {
-      datafile << ", ";
-      datafile << "Ixx, ";
-      datafile << "Iyy, ";
-      datafile << "Izz, ";
-      datafile << "Ixz, ";
-      datafile << "Mass, ";
-      datafile << "Xcg, Ycg, Zcg";
-    }
-    if (SubSystems & FGAircraft::ssPosition) {
-      datafile << ", ";
-      datafile << "Altitude, ";
-      datafile << "Phi, Tht, Psi, ";
-      datafile << "Alpha, ";
-      datafile << "Latitude, ";
-      datafile << "Longitude, ";
-      datafile << "Distance AGL, ";
-      datafile << "Runway Radius";
-    }
-    if (SubSystems & FGAircraft::ssCoefficients) {
-      datafile << ", ";
-      datafile << Aerodynamics->GetCoefficientStrings();
-    }
-    if (SubSystems & FGAircraft::ssGroundReactions) {
-      datafile << ", ";
-      datafile << Aircraft->GetGroundReactionStrings();
-    }
-    if (SubSystems & FGAircraft::ssFCS) {
-      datafile << ", ";
-      datafile << FCS->GetComponentStrings();
-    }
-    if (SubSystems & FGAircraft::ssPropulsion) {
-      datafile << ", ";
-      datafile << Propulsion->GetPropulsionStrings();
-    }
-    datafile << endl;
-    sFirstPass = false;
+    if (SubSystems & ssAerosurfaces) {
+      outstream << delimeter;
+      outstream << "Aileron Cmd" + delimeter;
+      outstream << "Elevator Cmd" + delimeter;
+      outstream << "Rudder Cmd" + delimeter;
+      outstream << "Flap Cmd" + delimeter;
+      outstream << "Left Aileron Pos" + delimeter;
+      outstream << "Right Aileron Pos" + delimeter;
+      outstream << "Elevator Pos" + delimeter;
+      outstream << "Rudder Pos" + delimeter;
+      outstream << "Flap Pos";
+    }
+    if (SubSystems & ssRates) {
+      outstream << delimeter;
+      outstream << "P" + delimeter + "Q" + delimeter + "R" + delimeter;
+      outstream << "Pdot" + delimeter + "Qdot" + delimeter + "Rdot";
+    }
+    if (SubSystems & ssVelocities) {
+      outstream << delimeter;
+      outstream << "QBar" + delimeter;
+      outstream << "Vtotal" + delimeter;
+      outstream << "UBody" + delimeter + "VBody" + delimeter + "WBody" + delimeter;
+      outstream << "UAero" + delimeter + "VAero" + delimeter + "WAero" + delimeter;
+      outstream << "Vn" + delimeter + "Ve" + delimeter + "Vd";
+    }
+    if (SubSystems & ssForces) {
+      outstream << delimeter;
+      outstream << "Drag" + delimeter + "Side" + delimeter + "Lift" + delimeter;
+      outstream << "L/D" + delimeter;
+      outstream << "Xforce" + delimeter + "Yforce" + delimeter + "Zforce";
+    }
+    if (SubSystems & ssMoments) {
+      outstream << delimeter;
+      outstream << "L" + delimeter + "M" + delimeter + "N";
+    }
+    if (SubSystems & ssAtmosphere) {
+      outstream << delimeter;
+      outstream << "Rho" + delimeter;
+      outstream << "NWind" + delimeter + "EWind" + delimeter + "DWind";
+    }
+    if (SubSystems & ssMassProps) {
+      outstream << delimeter;
+      outstream << "Ixx" + delimeter;
+      outstream << "Ixy" + delimeter;
+      outstream << "Ixz" + delimeter;
+      outstream << "Iyx" + delimeter;
+      outstream << "Iyy" + delimeter;
+      outstream << "Iyz" + delimeter;
+      outstream << "Izx" + delimeter;
+      outstream << "Izy" + delimeter;
+      outstream << "Izz" + delimeter;
+      outstream << "Mass" + delimeter;
+      outstream << "Xcg" + delimeter + "Ycg" + delimeter + "Zcg";
+    }
+    if (SubSystems & ssPropagate) {
+      outstream << delimeter;
+      outstream << "Altitude" + delimeter;
+      outstream << "Phi" + delimeter + "Tht" + delimeter + "Psi" + delimeter;
+      outstream << "Alpha" + delimeter;
+      outstream << "Beta" + delimeter;
+      outstream << "Latitude (Deg)" + delimeter;
+      outstream << "Longitude (Deg)" + delimeter;
+      outstream << "Distance AGL" + delimeter;
+      outstream << "Runway Radius";
+    }
+    if (SubSystems & ssCoefficients) {
+      scratch = Aerodynamics->GetCoefficientStrings(delimeter);
+      if (scratch.length() != 0) outstream << delimeter << scratch;
+    }
+    if (SubSystems & ssFCS) {
+      scratch = FCS->GetComponentStrings(delimeter);
+      if (scratch.length() != 0) outstream << delimeter << scratch;
+    }
+    if (SubSystems & ssGroundReactions) {
+      outstream << delimeter;
+      outstream << GroundReactions->GetGroundReactionStrings(delimeter);
+    }
+    if (SubSystems & ssPropulsion && Propulsion->GetNumEngines() > 0) {
+      outstream << delimeter;
+      outstream << Propulsion->GetPropulsionStrings(delimeter);
+    }
+    if (OutputProperties.size() > 0) {
+      for (unsigned int i=0;i<OutputProperties.size();i++) {
+        outstream << delimeter << OutputProperties[i]->GetName();
+      }
+    }
+
+    outstream << endl;
+    dFirstPass = false;
   }
 
-  datafile << State->Getsim_time();
-  if (SubSystems & FGAircraft::ssSimulation) {
+  outstream << State->Getsim_time();
+  if (SubSystems & ssSimulation) {
   }
-  if (SubSystems & FGAircraft::ssAerosurfaces) {
-    datafile << ", ";
-    datafile << FCS->GetThrottlePos(0) << ", ";
-    datafile << FCS->GetDaCmd() << ", ";
-    datafile << FCS->GetDeCmd() << ", ";
-    datafile << FCS->GetDrCmd() << ", ";
-    datafile << FCS->GetDaPos() << ", ";
-    datafile << FCS->GetDePos() << ", ";
-    datafile << FCS->GetDrPos();
+  if (SubSystems & ssAerosurfaces) {
+    outstream << delimeter;
+    outstream << FCS->GetDaCmd() << delimeter;
+    outstream << FCS->GetDeCmd() << delimeter;
+    outstream << FCS->GetDrCmd() << delimeter;
+    outstream << FCS->GetDfCmd() << delimeter;
+    outstream << FCS->GetDaLPos() << delimeter;
+    outstream << FCS->GetDaRPos() << delimeter;
+    outstream << FCS->GetDePos() << delimeter;
+    outstream << FCS->GetDrPos() << delimeter;
+    outstream << FCS->GetDfPos();
   }
-  if (SubSystems & FGAircraft::ssRates) {
-    datafile << ", ";
-    datafile << Rotation->GetPQR();
+  if (SubSystems & ssRates) {
+    outstream << delimeter;
+    outstream << Propagate->GetPQR().Dump(delimeter) << delimeter;
+    outstream << Propagate->GetPQRdot().Dump(delimeter);
   }
-  if (SubSystems & FGAircraft::ssVelocities) {
-    datafile << ", ";
-    datafile << Translation->Getqbar() << ", ";
-    datafile << Translation->GetVt() << ", ";
-    datafile << Translation->GetUVW() << ", ";
-    datafile << Position->GetVel();
+  if (SubSystems & ssVelocities) {
+    outstream << delimeter;
+    outstream << Auxiliary->Getqbar() << delimeter;
+    outstream << setprecision(12) << Auxiliary->GetVt() << delimeter;
+    outstream << setprecision(12) << Propagate->GetUVW().Dump(delimeter) << delimeter;
+    outstream << Auxiliary->GetAeroUVW().Dump(delimeter) << delimeter;
+    outstream << Propagate->GetVel().Dump(delimeter);
   }
-  if (SubSystems & FGAircraft::ssForces) {
-    datafile << ", ";
-    datafile << Aerodynamics->GetvFs() << ", ";
-    datafile << Aerodynamics->GetLoD() << ", ";
-    datafile << Aircraft->GetForces();
+  if (SubSystems & ssForces) {
+    outstream << delimeter;
+    outstream << Aerodynamics->GetvFs() << delimeter;
+    outstream << Aerodynamics->GetLoD() << delimeter;
+    outstream << Aircraft->GetForces().Dump(delimeter);
   }
-  if (SubSystems & FGAircraft::ssMoments) {
-    datafile << ", ";
-    datafile << Aircraft->GetMoments();
+  if (SubSystems & ssMoments) {
+    outstream << delimeter;
+    outstream << Aircraft->GetMoments().Dump(delimeter);
   }
-  if (SubSystems & FGAircraft::ssAtmosphere) {
-    datafile << ", ";
-    datafile << Atmosphere->GetDensity();
+  if (SubSystems & ssAtmosphere) {
+    outstream << delimeter;
+    outstream << Atmosphere->GetDensity() << delimeter;
+    outstream << Atmosphere->GetWindNED().Dump(delimeter);
   }
-  if (SubSystems & FGAircraft::ssMassProps) {
-    datafile << ", ";
-    datafile << MassBalance->GetIxx() << ", ";
-    datafile << MassBalance->GetIyy() << ", ";
-    datafile << MassBalance->GetIzz() << ", ";
-    datafile << MassBalance->GetIxz() << ", ";
-    datafile << MassBalance->GetMass() << ", ";
-    datafile << MassBalance->GetXYZcg();
+  if (SubSystems & ssMassProps) {
+    outstream << delimeter;
+    outstream << MassBalance->GetJ() << delimeter;
+    outstream << MassBalance->GetMass() << delimeter;
+    outstream << MassBalance->GetXYZcg();
   }
-  if (SubSystems & FGAircraft::ssPosition) {
-    datafile << ", ";
-    datafile << Position->Geth() << ", ";
-    datafile << Rotation->GetEuler() << ", ";
-    datafile << Translation->Getalpha() << ", ";
-    datafile << Position->GetLatitude() << ", ";
-    datafile << Position->GetLongitude() << ", ";
-    datafile << Position->GetDistanceAGL() << ", ";
-    datafile << Position->GetRunwayRadius();
+  if (SubSystems & ssPropagate) {
+    outstream << delimeter;
+    outstream << Propagate->Geth() << delimeter;
+    outstream << Propagate->GetEuler().Dump(delimeter) << delimeter;
+    outstream << Auxiliary->Getalpha(inDegrees) << delimeter;
+    outstream << Auxiliary->Getbeta(inDegrees) << delimeter;
+    outstream << Propagate->GetLocation().GetLatitudeDeg() << delimeter;
+    outstream << Propagate->GetLocation().GetLongitudeDeg() << delimeter;
+    outstream << Propagate->GetDistanceAGL() << delimeter;
+    outstream << Propagate->GetRunwayRadius();
   }
-  if (SubSystems & FGAircraft::ssCoefficients) {
-    datafile << ", ";
-    datafile << Aerodynamics->GetCoefficientValues();
+  if (SubSystems & ssCoefficients) {
+    scratch = Aerodynamics->GetCoefficientValues(delimeter);
+    if (scratch.length() != 0) outstream << delimeter << scratch;
   }
-  if (SubSystems & FGAircraft::ssGroundReactions) {
-    datafile << ", ";
-    datafile << Aircraft->GetGroundReactionValues();
+  if (SubSystems & ssFCS) {
+    scratch = FCS->GetComponentValues(delimeter);
+    if (scratch.length() != 0) outstream << delimeter << scratch;
   }
-  if (SubSystems & FGAircraft::ssFCS) {
-    datafile << ", ";
-    datafile << FCS->GetComponentValues();
+  if (SubSystems & ssGroundReactions) {
+    outstream << delimeter;
+    outstream << GroundReactions->GetGroundReactionValues(delimeter);
   }
-  if (SubSystems & FGAircraft::ssPropulsion) {
-    datafile << ", ";
-    datafile << Propulsion->GetPropulsionValues();
+  if (SubSystems & ssPropulsion && Propulsion->GetNumEngines() > 0) {
+    outstream << delimeter;
+    outstream << Propulsion->GetPropulsionValues(delimeter);
   }
-  datafile << endl;
-  datafile.flush();
+
+  for (unsigned int i=0;i<OutputProperties.size();i++) {
+    outstream << delimeter << OutputProperties[i]->getDoubleValue();
+  }
+
+  outstream << endl;
+  outstream.flush();
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -450,8 +330,9 @@ void FGOutput::DelimitedOutput(string fname)
 void FGOutput::SocketOutput(void)
 {
   string asciiData;
-  /*
+
   if (socket == NULL) return;
+  if (!socket->GetConnectStatus()) return;
 
   socket->Clear();
   if (sFirstPass) {
@@ -463,9 +344,12 @@ void FGOutput::SocketOutput(void)
     socket->Append("Psi");
     socket->Append("Rho");
     socket->Append("Vtotal");
-    socket->Append("U");
-    socket->Append("V");
-    socket->Append("W");
+    socket->Append("UBody");
+    socket->Append("VBody");
+    socket->Append("WBody");
+    socket->Append("UAero");
+    socket->Append("VAero");
+    socket->Append("WAero");
     socket->Append("Vn");
     socket->Append("Ve");
     socket->Append("Vd");
@@ -481,59 +365,64 @@ void FGOutput::SocketOutput(void)
     socket->Append("Fx");
     socket->Append("Fy");
     socket->Append("Fz");
-    socket->Append("Latitude");
-    socket->Append("Longitude");
+    socket->Append("Latitude (Deg)");
+    socket->Append("Longitude (Deg)");
     socket->Append("QBar");
     socket->Append("Alpha");
     socket->Append("L");
     socket->Append("M");
     socket->Append("N");
-    socket->Append("Throttle");
-    socket->Append("Aileron");
-    socket->Append("Elevator");
-    socket->Append("Rudder");
+    socket->Append("Throttle Position");
+    socket->Append("Left Aileron Position");
+    socket->Append("Right Aileron Position");
+    socket->Append("Elevator Position");
+    socket->Append("Rudder Position");
     sFirstPass = false;
     socket->Send();
   }
 
   socket->Clear();
   socket->Append(State->Getsim_time());
-  socket->Append(Position->Geth());
-  socket->Append(Rotation->Getphi());
-  socket->Append(Rotation->Gettht());
-  socket->Append(Rotation->Getpsi());
+  socket->Append(Propagate->Geth());
+  socket->Append(Propagate->GetEuler(ePhi));
+  socket->Append(Propagate->GetEuler(eTht));
+  socket->Append(Propagate->GetEuler(ePsi));
   socket->Append(Atmosphere->GetDensity());
-  socket->Append(Translation->GetVt());
-  socket->Append(Translation->GetU());
-  socket->Append(Translation->GetV());
-  socket->Append(Translation->GetW());
-  socket->Append(Position->GetVn());
-  socket->Append(Position->GetVe());
-  socket->Append(Position->GetVd());
-  socket->Append(Translation->GetUdot());
-  socket->Append(Translation->GetVdot());
-  socket->Append(Translation->GetWdot());
-  socket->Append(Rotation->GetP());
-  socket->Append(Rotation->GetQ());
-  socket->Append(Rotation->GetR());
-  socket->Append(Rotation->GetPdot());
-  socket->Append(Rotation->GetQdot());
-  socket->Append(Rotation->GetRdot());
-  socket->Append(Aircraft->GetFx());
-  socket->Append(Aircraft->GetFy());
-  socket->Append(Aircraft->GetFz());
-  socket->Append(Position->GetLatitude());
-  socket->Append(Position->GetLongitude());
-  socket->Append(Translation->Getqbar());
-  socket->Append(Translation->Getalpha());
-  socket->Append(Aircraft->GetL());
-  socket->Append(Aircraft->GetM());
-  socket->Append(Aircraft->GetN());
-  socket->Append(FCS->GetThrottle(0));
-  socket->Append(FCS->GetDa());
-  socket->Append(FCS->GetDe());
-  socket->Append(FCS->GetDr());
-  socket->Send(); */
+  socket->Append(Auxiliary->GetVt());
+  socket->Append(Propagate->GetUVW(eU));
+  socket->Append(Propagate->GetUVW(eV));
+  socket->Append(Propagate->GetUVW(eW));
+  socket->Append(Auxiliary->GetAeroUVW(eU));
+  socket->Append(Auxiliary->GetAeroUVW(eV));
+  socket->Append(Auxiliary->GetAeroUVW(eW));
+  socket->Append(Propagate->GetVel(eNorth));
+  socket->Append(Propagate->GetVel(eEast));
+  socket->Append(Propagate->GetVel(eDown));
+  socket->Append(Propagate->GetUVWdot(eU));
+  socket->Append(Propagate->GetUVWdot(eV));
+  socket->Append(Propagate->GetUVWdot(eW));
+  socket->Append(Propagate->GetPQR(eP));
+  socket->Append(Propagate->GetPQR(eQ));
+  socket->Append(Propagate->GetPQR(eR));
+  socket->Append(Propagate->GetPQRdot(eP));
+  socket->Append(Propagate->GetPQRdot(eQ));
+  socket->Append(Propagate->GetPQRdot(eR));
+  socket->Append(Aircraft->GetForces(eX));
+  socket->Append(Aircraft->GetForces(eY));
+  socket->Append(Aircraft->GetForces(eZ));
+  socket->Append(Propagate->GetLocation().GetLatitudeDeg());
+  socket->Append(Propagate->GetLocation().GetLongitudeDeg());
+  socket->Append(Auxiliary->Getqbar());
+  socket->Append(Auxiliary->Getalpha(inDegrees));
+  socket->Append(Aircraft->GetMoments(eL));
+  socket->Append(Aircraft->GetMoments(eM));
+  socket->Append(Aircraft->GetMoments(eN));
+  socket->Append(FCS->GetThrottlePos(0));
+  socket->Append(FCS->GetDaLPos());
+  socket->Append(FCS->GetDaRPos());
+  socket->Append(FCS->GetDePos());
+  socket->Append(FCS->GetDrPos());
+  socket->Send();
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -552,8 +441,201 @@ void FGOutput::SocketStatusOutput(string out_str)
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-void FGOutput::Debug(void)
+bool FGOutput::Load(FGConfigFile* AC_cfg)
 {
-    //TODO: Add your source code here
+  string token="", parameter="", separator="";
+  string name="", fname="";
+  int OutRate = 0;
+  FGConfigFile* Output_cfg;
+  string property;
+  unsigned int port;
+
+# ifndef macintosh
+    separator = "/";
+# else
+    separator = ";";
+# endif
+
+  name = AC_cfg->GetValue("NAME");
+  fname = AC_cfg->GetValue("FILE");
+  token = AC_cfg->GetValue("TYPE");
+  port = atoi(AC_cfg->GetValue("PORT").c_str());
+
+  Output->SetType(token);
+
+  if (token == "SOCKET") {
+    socket = new FGfdmSocket(name,port);
+  }
+
+  if (!fname.empty()) {
+    outputInFileName = FDMExec->GetAircraftPath() + separator
+                        + FDMExec->GetModelName() + separator + fname + ".xml";
+    Output_cfg = new FGConfigFile(outputInFileName);
+    if (!Output_cfg->IsOpen()) {
+      cerr << "Could not open file: " << outputInFileName << endl;
+      return false;
+    }
+  } else {
+    Output_cfg = AC_cfg;
+  }
+  Output->SetFilename(name);
+
+  while ((token = Output_cfg->GetValue()) != string("/OUTPUT")) {
+    *Output_cfg >> parameter;
+    if (parameter == "RATE_IN_HZ") {
+      *Output_cfg >> OutRate;
+    }
+    if (parameter == "SIMULATION") {
+      *Output_cfg >> parameter;
+      if (parameter == "ON") SubSystems += ssSimulation;
+    }
+    if (parameter == "AEROSURFACES") {
+      *Output_cfg >> parameter;
+      if (parameter == "ON") SubSystems += ssAerosurfaces;
+    }
+    if (parameter == "RATES") {
+      *Output_cfg >> parameter;
+      if (parameter == "ON") SubSystems += ssRates;
+    }
+    if (parameter == "VELOCITIES") {
+      *Output_cfg >> parameter;
+      if (parameter == "ON") SubSystems += ssVelocities;
+    }
+    if (parameter == "FORCES") {
+      *Output_cfg >> parameter;
+      if (parameter == "ON") SubSystems += ssForces;
+    }
+    if (parameter == "MOMENTS") {
+      *Output_cfg >> parameter;
+      if (parameter == "ON") SubSystems += ssMoments;
+    }
+    if (parameter == "ATMOSPHERE") {
+      *Output_cfg >> parameter;
+      if (parameter == "ON") SubSystems += ssAtmosphere;
+    }
+    if (parameter == "MASSPROPS") {
+      *Output_cfg >> parameter;
+      if (parameter == "ON") SubSystems += ssMassProps;
+    }
+    if (parameter == "POSITION") {
+      *Output_cfg >> parameter;
+      if (parameter == "ON") SubSystems += ssPropagate;
+    }
+    if (parameter == "COEFFICIENTS") {
+      *Output_cfg >> parameter;
+      if (parameter == "ON") SubSystems += ssCoefficients;
+    }
+    if (parameter == "GROUND_REACTIONS") {
+      *Output_cfg >> parameter;
+      if (parameter == "ON") SubSystems += ssGroundReactions;
+    }
+    if (parameter == "FCS") {
+      *Output_cfg >> parameter;
+      if (parameter == "ON") SubSystems += ssFCS;
+    }
+    if (parameter == "PROPULSION") {
+      *Output_cfg >> parameter;
+      if (parameter == "ON") SubSystems += ssPropulsion;
+    }
+    if (parameter == "PROPERTY") {
+      *Output_cfg >> property;
+      OutputProperties.push_back(PropertyManager->GetNode(property));
+    }
+
+    if (parameter == "EOF") break;
+  }
+
+  OutRate = OutRate>120?120:(OutRate<0?0:OutRate);
+  rate = (int)(0.5 + 1.0/(State->Getdt()*OutRate));
+
+  Debug(2);
+
+  return true;
 }
 
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+//    The bitmasked value choices are as follows:
+//    unset: In this case (the default) JSBSim would only print
+//       out the normally expected messages, essentially echoing
+//       the config files as they are read. If the environment
+//       variable is not set, debug_lvl is set to 1 internally
+//    0: This requests JSBSim not to output any messages
+//       whatsoever.
+//    1: This value explicity requests the normal JSBSim
+//       startup messages
+//    2: This value asks for a message to be printed out when
+//       a class is instantiated
+//    4: When this value is set, a message is displayed when a
+//       FGModel object executes its Run() method
+//    8: When this value is set, various runtime state variables
+//       are printed out periodically
+//    16: When set various parameters are sanity checked and
+//       a message is printed out when they go out of bounds
+
+void FGOutput::Debug(int from)
+{
+  string scratch="";
+
+  if (debug_lvl <= 0) return;
+
+  if (debug_lvl & 1) { // Standard console startup message output
+    if (from == 0) { // Constructor
+
+    }
+    if (from == 2) {
+      if (outputInFileName.empty())
+        cout << "  " << "Output parameters read inline" << endl;
+      else
+        cout << "    Output parameters read from file: " << outputInFileName << endl;
+
+      if (Filename == "cout" || Filename == "COUT") {
+        scratch = "    Log output goes to screen console";
+      } else if (!Filename.empty()) {
+        scratch = "    Log output goes to file: " + Filename;
+      }
+      switch (Type) {
+      case otCSV:
+        cout << scratch << " in CSV format output at rate " << 120/rate << " Hz" << endl;
+        break;
+      case otNone:
+        cout << "  No log output" << endl;
+        break;
+      }
+
+      if (SubSystems & ssSimulation)      cout << "    Simulation parameters logged" << endl;
+      if (SubSystems & ssAerosurfaces)    cout << "    Aerosurface parameters logged" << endl;
+      if (SubSystems & ssRates)           cout << "    Rate parameters logged" << endl;
+      if (SubSystems & ssVelocities)      cout << "    Velocity parameters logged" << endl;
+      if (SubSystems & ssForces)          cout << "    Force parameters logged" << endl;
+      if (SubSystems & ssMoments)         cout << "    Moments parameters logged" << endl;
+      if (SubSystems & ssAtmosphere)      cout << "    Atmosphere parameters logged" << endl;
+      if (SubSystems & ssMassProps)       cout << "    Mass parameters logged" << endl;
+      if (SubSystems & ssCoefficients)    cout << "    Coefficient parameters logged" << endl;
+      if (SubSystems & ssPropagate)       cout << "    Propagate parameters logged" << endl;
+      if (SubSystems & ssGroundReactions) cout << "    Ground parameters logged" << endl;
+      if (SubSystems & ssFCS)             cout << "    FCS parameters logged" << endl;
+      if (SubSystems & ssPropulsion)      cout << "    Propulsion parameters logged" << endl;
+      if (OutputProperties.size() > 0)    cout << "    Properties logged:" << endl;
+      for (unsigned int i=0;i<OutputProperties.size();i++) {
+        cout << "      - " << OutputProperties[i]->GetName() << endl;
+      }
+    }
+  }
+  if (debug_lvl & 2 ) { // Instantiation/Destruction notification
+    if (from == 0) cout << "Instantiated: FGOutput" << endl;
+    if (from == 1) cout << "Destroyed:    FGOutput" << endl;
+  }
+  if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
+  }
+  if (debug_lvl & 8 ) { // Runtime state variables
+  }
+  if (debug_lvl & 16) { // Sanity checking
+  }
+  if (debug_lvl & 64) {
+    if (from == 0) { // Constructor
+      cout << IdSrc << endl;
+      cout << IdHdr << endl;
+    }
+  }
+}
+}