]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/JSBSim/FGOutput.cpp
JSBSim updates. This update changes the file format, so an update of the base
[flightgear.git] / src / FDM / JSBSim / FGOutput.cpp
index 5b1d3501a0708b0968f481b876748bd6ae28daba..b3b3858088f2c6d0986a541acef77d82397ac8e3 100644 (file)
@@ -69,9 +69,6 @@ FGOutput::FGOutput(FGFDMExec* fdmex) : FGModel(fdmex)
   SubSystems = 0;
   enabled = true;
   
-#ifdef FG_WITH_JSBSIM_SOCKET
-  socket = new FGfdmSocket("localhost",1138);
-#endif
   Debug(0);
 }
 
@@ -101,8 +98,9 @@ bool FGOutput::Run(void)
       } else {
         // Not a valid type of output
       }
-
+         return false;
     } else {
+         return true;
     }
   }
   return false;
@@ -120,7 +118,7 @@ void FGOutput::SetType(string type)
     Type = otSocket;
   } else if (type == "TERMINAL") {
     Type = otTerminal;
-  } else if (type != string("NONE")){
+  } else if (type != string("NONE")) {
     Type = otUnknown;
     cerr << "Unknown type of output specified in config file" << endl;
   }
@@ -151,9 +149,12 @@ void FGOutput::DelimitedOutput(string fname)
       outstream << "Aileron Cmd, ";
       outstream << "Elevator Cmd, ";
       outstream << "Rudder Cmd, ";
-      outstream << "Aileron Pos, ";
+      outstream << "Flap Cmd, ";
+      outstream << "Left Aileron Pos, ";
+      outstream << "Right Aileron Pos, ";
       outstream << "Elevator Pos, ";
-      outstream << "Rudder Pos";
+      outstream << "Rudder Pos, ";
+      outstream << "Flap Pos"; 
     }
     if (SubSystems & ssRates) {
       outstream << ", ";
@@ -172,7 +173,10 @@ void FGOutput::DelimitedOutput(string fname)
       outstream << ", ";
       outstream << "Drag, Side, Lift, ";
       outstream << "L/D, ";
-      outstream << "Xforce, Yforce, Zforce";
+      outstream << "Xforce, Yforce, Zforce, ";
+      outstream << "xGravity, yGravity, zGravity, ";
+      outstream << "xCoriolis, yCoriolis, zCoriolis, ";
+      outstream << "xCentrifugal, yCentrifugal, zCentrifugal";
     }
     if (SubSystems & ssMoments) {
       outstream << ", ";
@@ -207,6 +211,10 @@ void FGOutput::DelimitedOutput(string fname)
       outstream << ", ";
       outstream << Aerodynamics->GetCoefficientStrings();
     }
+    if (SubSystems & ssFCS) {
+      outstream << ", ";
+      outstream << FCS->GetComponentStrings();
+    }
     if (SubSystems & ssGroundReactions) {
       outstream << ", ";
       outstream << GroundReactions->GetGroundReactionStrings();
@@ -228,9 +236,12 @@ void FGOutput::DelimitedOutput(string fname)
     outstream << FCS->GetDaCmd() << ", ";
     outstream << FCS->GetDeCmd() << ", ";
     outstream << FCS->GetDrCmd() << ", ";
-    outstream << FCS->GetDaPos() << ", ";
+    outstream << FCS->GetDfCmd() << ", ";
+    outstream << FCS->GetDaLPos() << ", ";
+    outstream << FCS->GetDaRPos() << ", ";
     outstream << FCS->GetDePos() << ", ";
-    outstream << FCS->GetDrPos();
+    outstream << FCS->GetDrPos() << ", ";
+    outstream << FCS->GetDfPos();
   }
   if (SubSystems & ssRates) {
     outstream << ", ";
@@ -242,14 +253,17 @@ void FGOutput::DelimitedOutput(string fname)
     outstream << Translation->Getqbar() << ", ";
     outstream << Translation->GetVt() << ", ";
     outstream << Translation->GetUVW() << ", ";
-    outstream << Translation->GetvAeroUVW() << ", ";
+    outstream << Translation->GetAeroUVW() << ", ";
     outstream << Position->GetVel();
   }
   if (SubSystems & ssForces) {
     outstream << ", ";
     outstream << Aerodynamics->GetvFs() << ", ";
     outstream << Aerodynamics->GetLoD() << ", ";
-    outstream << Aircraft->GetForces();
+    outstream << Aircraft->GetForces() << ", ";
+    outstream << Inertial->GetGravity() << ", ";
+    outstream << Inertial->GetCoriolis() << ", ";
+    outstream << Inertial->GetCentrifugal();
   }
   if (SubSystems & ssMoments) {
     outstream << ", ";
@@ -284,6 +298,10 @@ void FGOutput::DelimitedOutput(string fname)
     outstream << ", ";
     outstream << Aerodynamics->GetCoefficientValues();
   }
+  if (SubSystems & ssFCS) {
+    outstream << ", ";
+    outstream << FCS->GetComponentValues();
+  }
   if (SubSystems & ssGroundReactions) {
     outstream << ", ";
     outstream << GroundReactions->GetGroundReactionValues();
@@ -302,8 +320,9 @@ void FGOutput::DelimitedOutput(string fname)
 void FGOutput::SocketOutput(void)
 {
   string asciiData;
-  /*
+
   if (socket == NULL) return;
+  if (!socket->GetConnectStatus()) return;
 
   socket->Clear();
   if (sFirstPass) {
@@ -343,10 +362,11 @@ void FGOutput::SocketOutput(void)
     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();
   }
@@ -362,36 +382,37 @@ void FGOutput::SocketOutput(void)
   socket->Append(Translation->GetUVW(eU));
   socket->Append(Translation->GetUVW(eV));
   socket->Append(Translation->GetUVW(eW));
-  socket->Append(Translation->GetvAeroUVW(eU));
-  socket->Append(Translation->GetvAeroUVW(eV));
-  socket->Append(Translation->GetvAeroUVW(eW));
+  socket->Append(Translation->GetAeroUVW(eU));
+  socket->Append(Translation->GetAeroUVW(eV));
+  socket->Append(Translation->GetAeroUVW(eW));
   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(Translation->GetUVWdot(eU));
+  socket->Append(Translation->GetUVWdot(eV));
+  socket->Append(Translation->GetUVWdot(eW));
+  socket->Append(Rotation->GetPQR(eP));
+  socket->Append(Rotation->GetPQR(eQ));
+  socket->Append(Rotation->GetPQR(eR));
+  socket->Append(Rotation->GetPQRdot(eP));
+  socket->Append(Rotation->GetPQRdot(eQ));
+  socket->Append(Rotation->GetPQRdot(eR));
+  socket->Append(Aircraft->GetForces(eX));
+  socket->Append(Aircraft->GetForces(eY));
+  socket->Append(Aircraft->GetForces(eZ));
   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(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();
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -419,6 +440,13 @@ bool FGOutput::Load(FGConfigFile* AC_cfg)
   Output->SetFilename(token);
   token = AC_cfg->GetValue("TYPE");
   Output->SetType(token);
+
+#if defined( FG_WITH_JSBSIM_SOCKET ) || !defined( FGFS )
+  if (token == "SOCKET") {
+    socket = new FGfdmSocket("localhost",1138);
+  }
+#endif
+  
   AC_cfg->GetNextConfigLine();
 
   while ((token = AC_cfg->GetValue()) != string("/OUTPUT")) {