]> git.mxchange.org Git - flightgear.git/commitdiff
Latest JSBSim changes, including a kludge from Tony to keep the
authordavid <david>
Wed, 6 Feb 2002 04:07:12 +0000 (04:07 +0000)
committerdavid <david>
Wed, 6 Feb 2002 04:07:12 +0000 (04:07 +0000)
slip/skid ball still when the plane is stationary.

src/FDM/JSBSim.cxx
src/FDM/JSBSim/FGAircraft.h
src/FDM/JSBSim/FGAuxiliary.cpp
src/FDM/JSBSim/FGInitialCondition.cpp
src/FDM/JSBSim/FGOutput.cpp
src/FDM/JSBSim/FGfdmSocket.cpp
src/FDM/JSBSim/FGfdmSocket.h
src/FDM/JSBSim/JSBSim.cpp

index d45f0bb5c500cf7dc8e69084b1c458b20a9d5938..c7dd94bb8c62cbd9f8e46eff2b4af9c266d2b94d 100644 (file)
@@ -373,9 +373,9 @@ bool FGJSBsim::copy_from_JSBsim() {
                             Aircraft->GetNcg()(2),
                             Aircraft->GetNcg()(3) );
     
-    _set_Accels_Pilot_Body( Auxiliary->GetNpilot()(1),
-                            Auxiliary->GetNpilot()(2),
-                            Auxiliary->GetNpilot()(3) );
+    _set_Accels_Pilot_Body( Auxiliary->GetPilotAccel()(1),
+                            Auxiliary->GetPilotAccel()(2),
+                            Auxiliary->GetPilotAccel()(3) );
 
    // _set_Accels_Pilot_Body_N( Auxiliary->GetPilotAccel()(1)/32.1739,
    //                           Auxiliary->GetNpilot(2)/32.1739,
index 240d75259477cd2ef6a6dd9a4abeb9eaeb09b12c..b9624792d1995756abc0d29cd9cc389224d9b0b0 100644 (file)
@@ -145,7 +145,9 @@ public:
   inline double Getvbarh(void) { return vbarh; } // H. Tail Volume
   inline double Getvbarv(void) { return vbarv; } // V. Tail Volume
   inline FGColumnVector3& GetMoments(void) { return vMoments; }
+  inline double GetMoments(int idx) { return vMoments(idx); }
   inline FGColumnVector3& GetForces(void) { return vForces; }
+  inline double GetForces(int idx) { return vForces(idx); }
   inline FGColumnVector3& GetBodyAccel(void) { return vBodyAccel; }
   inline FGColumnVector3& GetNcg   (void)    { return vNcg; }
   inline FGColumnVector3& GetXYZrp(void) { return vXYZrp; }
index d744579d36a3d63647cfc2c67f444e4143838778..84232e89b14ae52b2114d6976a70add99bf91674 100644 (file)
@@ -145,14 +145,18 @@ bool FGAuxiliary::Run()
     // mass, the acceleration vector is calculated. The term wdot is equivalent
     // to the JSBSim vPQRdot vector, and the w parameter is equivalent to vPQR.
     // The radius R is calculated below in the vector vToEyePt.
-        
-    vToEyePt = Aircraft->GetXYZep() - MassBalance->GetXYZcg();
-
-    vPilotAccel = Aircraft->GetBodyAccel()
-                  + Rotation->GetPQRdot() * vToEyePt
-                  + Rotation->GetPQR() * (Rotation->GetPQR() * vToEyePt)
-                  + Inertial->GetGravity();
-
+    
+    vPilotAccel.InitMatrix();   
+    if( Translation->GetVt() > 1 ) {
+      vToEyePt = Aircraft->GetXYZep() - MassBalance->GetXYZcg();
+
+      vPilotAccel =  Aerodynamics->GetForces() 
+                  +  Propulsion->GetForces()
+                  +  GroundReactions->GetForces();
+      vPilotAccel /= MassBalance->GetMass();
+      vPilotAccel += Rotation->GetPQRdot() * vToEyePt;
+      vPilotAccel += Rotation->GetPQR() * (Rotation->GetPQR() * vToEyePt);
+    }
     earthPosAngle += State->Getdt()*Inertial->omega();
     return false;
   } else {
index a76ef2a92f20e4dd527359f9a981b30f4346bf15..1b70824ade43ef6857f62cce61b5007363a3532d 100644 (file)
@@ -671,7 +671,6 @@ bool FGInitialCondition::solve(double *y,double x)
   i=0;
   while ((fabs(d) > eps) && (i < 100)) {
     d=(x3-x1)/d0;
-    cout << "f3-f1= " << f3-f1 << endl;
     x2 = x1-d*d0*f1/(f3-f1);
     
     f2=(this->*sfunc)(x2)-x;
index 5b1d3501a0708b0968f481b876748bd6ae28daba..77bd0f66388a205e926f9d4a71dfd7a4c972545a 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);
 }
 
@@ -302,8 +299,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 +341,10 @@ 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("Aileron Position");
+    socket->Append("Elevator Position");
+    socket->Append("Rudder Position");
     sFirstPass = false;
     socket->Send();
   }
@@ -368,30 +366,30 @@ void FGOutput::SocketOutput(void)
   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->GetDaPos());
+  socket->Append(FCS->GetDePos());
+  socket->Append(FCS->GetDrPos());
+  socket->Send();
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -419,6 +417,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")) {
index a20a79ad7f539a36788e310350eca9ef50bf6b16..190d175980149823b7c79eb3df2c8f17228db87f 100644 (file)
@@ -49,6 +49,7 @@ CLASS IMPLEMENTATION
 FGfdmSocket::FGfdmSocket(string address, int port)
 {
   size = 0;
+  connected = false;
 
 #if defined(__BORLANDC__) || defined(_MSC_VER) || defined(__MINGW32__)
     WSADATA wsaData;
@@ -80,6 +81,7 @@ FGfdmSocket::FGfdmSocket(string address, int port)
       int len = sizeof(struct sockaddr_in);
       if (connect(sckt, (struct sockaddr*)&scktName, len) == 0) {   // successful
         cout << "Successfully connected to socket ..." << endl;
+        connected = true;
       } else {                // unsuccessful
         cout << "Could not connect to socket ..." << endl;
       }
index 0a405f32bd8f6502fd04aadcbeecfbd0b2a687d2..df9c3ec7b6ef9c7dec7e0cea3f83594a42e917f2 100644 (file)
@@ -100,6 +100,7 @@ public:
   void Append(double);
   void Append(long);
   void Clear(void);
+  bool GetConnectStatus(void) {return connected;}
 
 private:
   int sckt;
@@ -107,6 +108,7 @@ private:
   struct sockaddr_in scktName;
   struct hostent *host;
   string buffer;
+  bool connected;
   void Debug(int from);
 };
 
index cbe40ff0b126c360182612031d241bf2e80393b6..5dd4add9d8afecd4049377c8ffd1a96085016629 100644 (file)
-/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r
-\r
- Module:       JSBSim.cpp\r
- Author:       Jon S. Berndt\r
- Date started: 08/17/99\r
- Purpose:      Standalone version of JSBSim.\r
- Called by:    The USER.\r
-\r
- ------------- Copyright (C) 1999  Jon S. Berndt (jsb@hal-pc.org) -------------\r
-\r
- This program is free software; you can redistribute it and/or modify it under\r
- the terms of the GNU General Public License as published by the Free Software\r
- Foundation; either version 2 of the License, or (at your option) any later\r
- version.\r
-\r
- This program is distributed in the hope that it will be useful, but WITHOUT\r
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\r
- FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more\r
- details.\r
-\r
- You should have received a copy of the GNU General Public License along with\r
- this program; if not, write to the Free Software Foundation, Inc., 59 Temple\r
- Place - Suite 330, Boston, MA  02111-1307, USA.\r
-\r
- Further information about the GNU General Public License can also be found on\r
- the world wide web at http://www.gnu.org.\r
-\r
-FUNCTIONAL DESCRIPTION\r
---------------------------------------------------------------------------------\r
-\r
-This class Handles calling JSBSim standalone. It is set up for compilation under\r
-Borland C+Builder or other compiler.\r
-\r
-HISTORY\r
---------------------------------------------------------------------------------\r
-08/17/99   JSB   Created\r
-\r
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r
-INCLUDES\r
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/\r
-\r
-#include "FGFDMExec.h"\r
-#include "FGRotation.h"\r
-#include "FGAtmosphere.h"\r
-#include "FGState.h"\r
-#include "FGFCS.h"\r
-#include "FGAircraft.h"\r
-#include "FGTranslation.h"\r
-#include "FGPosition.h"\r
-#include "FGAuxiliary.h"\r
-#include "FGOutput.h"\r
-#include "FGConfigFile.h"\r
-#include "FGScript.h"\r
-#include "FGJSBBase.h"\r
-\r
-#ifdef FGFS\r
-#include <simgear/compiler.h>\r
-#include STL_IOSTREAM\r
-#else\r
-#  if defined(sgi) && !defined(__GNUC__)\r
-#    include <iostream.h>\r
-#  else\r
-#    include <iostream>\r
-#  endif\r
-#endif\r
-\r
-#if __BCPLUSPLUS__ == 0x540\r
-#pragma hdrstop\r
-#include <condefs.h>\r
-//---------------------------------------------------------------------------\r
-USERES("JSBSim.res");\r
-USEUNIT("FGUtility.cpp");\r
-USEUNIT("FGAircraft.cpp");\r
-USEUNIT("FGAtmosphere.cpp");\r
-USEUNIT("FGAuxiliary.cpp");\r
-USEUNIT("FGCoefficient.cpp");\r
-USEUNIT("FGColumnVector3.cpp");\r
-USEUNIT("FGColumnVector4.cpp");\r
-USEUNIT("FGConfigFile.cpp");\r
-USEUNIT("FGEngine.cpp");\r
-USEUNIT("FGFactorGroup.cpp");\r
-USEUNIT("FGFCS.cpp");\r
-USEUNIT("FGFDMExec.cpp");\r
-USEUNIT("FGfdmSocket.cpp");\r
-USEUNIT("FGForce.cpp");\r
-USEUNIT("FGGroundReactions.cpp");\r
-USEUNIT("FGInertial.cpp");\r
-USEUNIT("FGInitialCondition.cpp");\r
-USEUNIT("FGJSBBase.cpp");\r
-USEUNIT("FGLGear.cpp");\r
-USEUNIT("FGMassBalance.cpp");\r
-USEUNIT("FGMatrix33.cpp");\r
-USEUNIT("FGModel.cpp");\r
-USEUNIT("FGNozzle.cpp");\r
-USEUNIT("FGOutput.cpp");\r
-USEUNIT("FGPiston.cpp");\r
-USEUNIT("FGPosition.cpp");\r
-USEUNIT("FGPropeller.cpp");\r
-USEUNIT("FGPropulsion.cpp");\r
-USEUNIT("FGRocket.cpp");\r
-USEUNIT("FGRotation.cpp");\r
-USEUNIT("FGRotor.cpp");\r
-USEUNIT("FGScript.cpp");\r
-USEUNIT("FGState.cpp");\r
-USEUNIT("FGTable.cpp");\r
-USEUNIT("FGTank.cpp");\r
-USEUNIT("FGThruster.cpp");\r
-USEUNIT("FGTranslation.cpp");\r
-USEUNIT("FGTrim.cpp");\r
-USEUNIT("FGTrimAxis.cpp");\r
-USEUNIT("FGTurboJet.cpp");\r
-USEUNIT("FGTurboProp.cpp");\r
-USEUNIT("FGTurboShaft.cpp");\r
-USEUNIT("FGAerodynamics.cpp");\r
-USEUNIT("filtersjb\FGSwitch.cpp");\r
-USEUNIT("filtersjb\FGFCSComponent.cpp");\r
-USEUNIT("filtersjb\FGFilter.cpp");\r
-USEUNIT("filtersjb\FGGain.cpp");\r
-USEUNIT("filtersjb\FGGradient.cpp");\r
-USEUNIT("filtersjb\FGKinemat.cpp");\r
-USEUNIT("filtersjb\FGSummer.cpp");\r
-USEUNIT("filtersjb\FGDeadBand.cpp");\r
-//---------------------------------------------------------------------------\r
-#pragma argsused\r
-#endif\r
-\r
-/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r
-DEFINITIONS\r
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/\r
-\r
-/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r
-GLOBAL DATA\r
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/\r
-\r
-static const char *IdSrc = "$Id$";\r
-\r
-string ScriptName;\r
-string AircraftName;\r
-string ResetName;\r
-string LogOutputName;\r
-string LogDirectiveName;\r
-FGFDMExec* FDMExec;\r
-\r
-/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r
-COMMENTS, REFERENCES, and NOTES [use "class documentation" below for API docs]\r
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/\r
-\r
-/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r
-FORWARD DECLARATIONS\r
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/\r
-\r
-void options(int, char**);\r
-\r
-/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r
-DOCUMENTATION\r
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/\r
-\r
-/** Standalone JSBSim main program\r
-    This is the wrapper program used to instantiate the JSBSim system and control\r
-    it. Use this program to build a version of JSBSim that can be run from the\r
-    command line. To get any use out of this, you will have to create a script\r
-    to run a test case and specify what kind of output you would like.\r
-    @author Jon S. Berndt\r
-    @version $Id$\r
-    @see -\r
-*/\r
-\r
-/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r
-IMPLEMENTATION\r
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/\r
-\r
-int main(int argc, char* argv[])\r
-{\r
-  ScriptName = "";\r
-  AircraftName = "";\r
-  ResetName = "";\r
-  LogOutputName = "";\r
-  LogDirectiveName = "";\r
-  bool result = false;\r
-  bool Scripted = false;\r
-  FGScript* Script;\r
-\r
-  options(argc, argv);\r
-\r
-  FDMExec = new FGFDMExec();\r
-\r
-  if (!ScriptName.empty()) { // SCRIPTED CASE\r
-\r
-    Script = new FGScript(FDMExec);\r
-    result = Script->LoadScript(ScriptName);\r
-\r
-    if (!result) {\r
-      cerr << "Script file " << ScriptName << " was not successfully loaded" << endl;\r
-      exit(-1);\r
-    }\r
-\r
-    Scripted = true;\r
-\r
-  } else if (!AircraftName.empty() || !ResetName.empty()) {        // form jsbsim <acname> <resetfile>\r
-\r
-    if ( ! FDMExec->LoadModel("aircraft", "engine", AircraftName)) {\r
-       cerr << "  JSBSim could not be started" << endl << endl;\r
-      exit(-1);\r
-    }\r
-\r
-    FGInitialCondition IC(FDMExec);\r
-    if ( ! IC.Load("aircraft",AircraftName,ResetName)) {\r
-       cerr << "Initialization unsuccessful" << endl;\r
-      exit(-1);\r
-    }\r
-  } else {\r
-    cout << "  No Aircraft, Script, or Reset information given" << endl << endl;\r
-    exit(-1);\r
-  }\r
-\r
-//\r
-// RUN loop. MESSAGES are read inside the Run() loop and output as necessary.\r
-//\r
-\r
-  FGJSBBase::Message* msg;\r
-  result = FDMExec->Run();\r
-  while (result) {\r
-    while (FDMExec->ReadMessage()) {\r
-      msg = FDMExec->ProcessMessage();\r
-      switch (msg->type) {\r
-      case FGJSBBase::Message::eText:\r
-        cout << msg->messageId << ": " << msg->text << endl;\r
-        break;\r
-      case FGJSBBase::Message::eBool:\r
-        cout << msg->messageId << ": " << msg->text << " " << msg->bVal << endl;\r
-        break;\r
-      case FGJSBBase::Message::eInteger:\r
-        cout << msg->messageId << ": " << msg->text << " " << msg->iVal << endl;\r
-        break;\r
-      case FGJSBBase::Message::eDouble:\r
-        cout << msg->messageId << ": " << msg->text << " " << msg->dVal << endl;\r
-        break;\r
-      default:\r
-        cerr << "Unrecognized message type." << endl;\r
-             break;\r
-      }\r
-    }\r
-\r
-    if (Scripted) {\r
-      if (!Script->RunScript()) break;\r
-    }\r
-\r
-    result = FDMExec->Run();\r
-  }\r
-\r
-  delete FDMExec;\r
-\r
-  return 0;\r
-}\r
-\r
-//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r
-\r
-void options(int count, char **arg)\r
-{\r
-  int i;\r
-\r
-  if (count == 1) {\r
-    cout << endl << "  JSBSim version " << FDMExec->GetVersion() << endl << endl;\r
-    cout << "  Usage: jsbsim <options>" << endl << endl;\r
-    cout << "  options:" << endl;\r
-      cout << "    --help  returns this message" << endl;\r
-      cout << "    --version  returns the version number" << endl;\r
-      cout << "    --outputlogfile=<filename>  sets the name of the data output file" << endl;\r
-      cout << "    --logdirectivefile=<filename>  specifies the name of the data logging directives file" << endl;\r
-      cout << "    --aircraft=<filename>  specifies the name of the aircraft to be modeled" << endl;\r
-      cout << "    --script=<filename>  specifies a script to run" << endl;\r
-      cout << "    --initfile=<filename>  specifies an initilization file" << endl << endl;\r
-    cout << "  NOTE: There can be no spaces around the = sign when" << endl;\r
-    cout << "        an option is followed by a filename" << endl << endl;\r
-  }\r
-\r
-  for (i=1; i<count; i++) {\r
-    string argument = string(arg[i]);\r
-    int n=0;\r
-    if (argument.find("--help") != string::npos) {\r
-      cout << endl << "  JSBSim version " << FDMExec->GetVersion() << endl << endl;\r
-      cout << "  Usage: jsbsim <options>" << endl << endl;\r
-      cout << "  options:" << endl;\r
-      cout << "    --help  returns this message" << endl;\r
-      cout << "    --version  returns the version number" << endl;\r
-      cout << "    --outputlogfile=<filename>  sets the name of the data output file" << endl;\r
-      cout << "    --logdirectivefile=<filename>  specifies the name of the data logging directives file" << endl;\r
-      cout << "    --aircraft=<filename>  specifies the name of the aircraft to be modeled" << endl;\r
-      cout << "    --script=<filename>  specifies a script to run" << endl;\r
-      cout << "    --initfile=<filename>  specifies an initilization file" << endl << endl;\r
-      cout << "  NOTE: There can be no spaces around the = sign when" << endl;\r
-      cout << "        an option is followed by a filename" << endl << endl;\r
-      exit(0);\r
-    } else if (argument.find("--version") != string::npos) {\r
-      cout << endl << "  JSBSim Version: " << FDMExec->GetVersion() << endl << endl;\r
-      exit (0);\r
-    } else if (argument.find("--outputlogfile") != string::npos) {\r
-      n = argument.find("=")+1;\r
-      if (n > 0) {\r
-        LogOutputName = argument.substr(argument.find("=")+1);\r
-      } else {\r
-        LogOutputName = "JSBout.csv";\r
-        cerr << "  Output log file name not valid or not understood. Using JSBout.csv as default";\r
-      }\r
-    } else if (argument.find("--logdirectivefile") != string::npos) {\r
-      n = argument.find("=")+1;\r
-      if (n > 0) {\r
-        LogDirectiveName = argument.substr(argument.find("=")+1);\r
-      } else {\r
-        cerr << "  Log directives file not valid or not understood." << endl << endl;\r
-        exit(1);\r
-      }\r
-    } else if (argument.find("--aircraft") != string::npos) {\r
-      n = argument.find("=")+1;\r
-      if (n > 0) {\r
-        AircraftName = argument.substr(argument.find("=")+1);\r
-      } else {\r
-        cerr << "  Aircraft name not valid or not understood." << endl << endl;\r
-        exit(1);\r
-      }\r
-    } else if (argument.find("--script") != string::npos) {\r
-      n = argument.find("=")+1;\r
-      if (n > 0) {\r
-        ScriptName = argument.substr(argument.find("=")+1);\r
-      } else {\r
-        cerr << "  Script name not valid or not understood." << endl << endl;\r
-        exit(1);\r
-      }\r
-    } else if (argument.find("--initfile") != string::npos) {\r
-      n = argument.find("=")+1;\r
-      if (n > 0) {\r
-        ResetName = argument.substr(argument.find("=")+1);\r
-      } else {\r
-        cerr << "  Reset name not valid or not understood." << endl << endl;\r
-        exit(1);\r
-      }\r
-    } else {\r
-      cerr << endl << "  Parameter: " << argument << " not understood" << endl;\r
-    }\r
-  }\r
-\r
-}\r
-\r
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+ Module:       JSBSim.cpp
+ Author:       Jon S. Berndt
+ Date started: 08/17/99
+ Purpose:      Standalone version of JSBSim.
+ Called by:    The USER.
+
+ ------------- Copyright (C) 1999  Jon S. Berndt (jsb@hal-pc.org) -------------
+
+ This program is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 2 of the License, or (at your option) any later
+ version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ details.
+
+ You should have received a copy of the GNU General Public License along with
+ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ Place - Suite 330, Boston, MA  02111-1307, USA.
+
+ Further information about the GNU General Public License can also be found on
+ the world wide web at http://www.gnu.org.
+
+FUNCTIONAL DESCRIPTION
+--------------------------------------------------------------------------------
+
+This class Handles calling JSBSim standalone. It is set up for compilation under
+Borland C+Builder or other compiler.
+
+HISTORY
+--------------------------------------------------------------------------------
+08/17/99   JSB   Created
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+INCLUDES
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
+#include "FGFDMExec.h"
+#include "FGRotation.h"
+#include "FGAtmosphere.h"
+#include "FGState.h"
+#include "FGFCS.h"
+#include "FGAircraft.h"
+#include "FGTranslation.h"
+#include "FGPosition.h"
+#include "FGAuxiliary.h"
+#include "FGOutput.h"
+#include "FGConfigFile.h"
+#include "FGScript.h"
+#include "FGJSBBase.h"
+
+#ifdef FGFS
+#include <simgear/compiler.h>
+#include STL_IOSTREAM
+#else
+#  if defined(sgi) && !defined(__GNUC__)
+#    include <iostream.h>
+#  else
+#    include <iostream>
+#  endif
+#endif
+
+#if __BCPLUSPLUS__ == 0x540
+#pragma hdrstop
+#include <condefs.h>
+//---------------------------------------------------------------------------
+USERES("JSBSim.res");
+USEUNIT("FGUtility.cpp");
+USEUNIT("FGAircraft.cpp");
+USEUNIT("FGAtmosphere.cpp");
+USEUNIT("FGAuxiliary.cpp");
+USEUNIT("FGCoefficient.cpp");
+USEUNIT("FGColumnVector3.cpp");
+USEUNIT("FGColumnVector4.cpp");
+USEUNIT("FGConfigFile.cpp");
+USEUNIT("FGEngine.cpp");
+USEUNIT("FGFactorGroup.cpp");
+USEUNIT("FGFCS.cpp");
+USEUNIT("FGFDMExec.cpp");
+USEUNIT("FGfdmSocket.cpp");
+USEUNIT("FGForce.cpp");
+USEUNIT("FGGroundReactions.cpp");
+USEUNIT("FGInertial.cpp");
+USEUNIT("FGInitialCondition.cpp");
+USEUNIT("FGJSBBase.cpp");
+USEUNIT("FGLGear.cpp");
+USEUNIT("FGMassBalance.cpp");
+USEUNIT("FGMatrix33.cpp");
+USEUNIT("FGModel.cpp");
+USEUNIT("FGNozzle.cpp");
+USEUNIT("FGOutput.cpp");
+USEUNIT("FGPiston.cpp");
+USEUNIT("FGPosition.cpp");
+USEUNIT("FGPropeller.cpp");
+USEUNIT("FGPropulsion.cpp");
+USEUNIT("FGRocket.cpp");
+USEUNIT("FGRotation.cpp");
+USEUNIT("FGRotor.cpp");
+USEUNIT("FGScript.cpp");
+USEUNIT("FGState.cpp");
+USEUNIT("FGTable.cpp");
+USEUNIT("FGTank.cpp");
+USEUNIT("FGThruster.cpp");
+USEUNIT("FGTranslation.cpp");
+USEUNIT("FGTrim.cpp");
+USEUNIT("FGTrimAxis.cpp");
+USEUNIT("FGTurboJet.cpp");
+USEUNIT("FGTurboProp.cpp");
+USEUNIT("FGTurboShaft.cpp");
+USEUNIT("FGAerodynamics.cpp");
+USEUNIT("filtersjb\FGSwitch.cpp");
+USEUNIT("filtersjb\FGFCSComponent.cpp");
+USEUNIT("filtersjb\FGFilter.cpp");
+USEUNIT("filtersjb\FGGain.cpp");
+USEUNIT("filtersjb\FGGradient.cpp");
+USEUNIT("filtersjb\FGKinemat.cpp");
+USEUNIT("filtersjb\FGSummer.cpp");
+USEUNIT("filtersjb\FGDeadBand.cpp");
+//---------------------------------------------------------------------------
+#pragma argsused
+#endif
+
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+DEFINITIONS
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+GLOBAL DATA
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
+static const char *IdSrc = "$Id$";
+
+string ScriptName;
+string AircraftName;
+string ResetName;
+string LogOutputName;
+string LogDirectiveName;
+FGFDMExec* FDMExec;
+
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+COMMENTS, REFERENCES, and NOTES [use "class documentation" below for API docs]
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+FORWARD DECLARATIONS
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
+void options(int, char**);
+
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+DOCUMENTATION
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
+/** Standalone JSBSim main program
+    This is the wrapper program used to instantiate the JSBSim system and control
+    it. Use this program to build a version of JSBSim that can be run from the
+    command line. To get any use out of this, you will have to create a script
+    to run a test case and specify what kind of output you would like.
+    @author Jon S. Berndt
+    @version $Id$
+    @see -
+*/
+
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+IMPLEMENTATION
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
+int main(int argc, char* argv[])
+{
+  ScriptName = "";
+  AircraftName = "";
+  ResetName = "";
+  LogOutputName = "";
+  LogDirectiveName = "";
+  bool result = false;
+  bool Scripted = false;
+  FGScript* Script;
+
+  options(argc, argv);
+
+  FDMExec = new FGFDMExec();
+
+  if (!ScriptName.empty()) { // SCRIPTED CASE
+
+    Script = new FGScript(FDMExec);
+    result = Script->LoadScript(ScriptName);
+
+    if (!result) {
+      cerr << "Script file " << ScriptName << " was not successfully loaded" << endl;
+      exit(-1);
+    }
+
+    Scripted = true;
+
+  } else if (!AircraftName.empty() || !ResetName.empty()) {        // form jsbsim <acname> <resetfile>
+
+    if ( ! FDMExec->LoadModel("aircraft", "engine", AircraftName)) {
+       cerr << "  JSBSim could not be started" << endl << endl;
+      exit(-1);
+    }
+
+    FGInitialCondition IC(FDMExec);
+    if ( ! IC.Load("aircraft",AircraftName,ResetName)) {
+       cerr << "Initialization unsuccessful" << endl;
+      exit(-1);
+    }
+  } else {
+    cout << "  No Aircraft, Script, or Reset information given" << endl << endl;
+    exit(-1);
+  }
+
+//
+// RUN loop. MESSAGES are read inside the Run() loop and output as necessary.
+//
+
+  FGJSBBase::Message* msg;
+  result = FDMExec->Run();
+  while (result) {
+    while (FDMExec->ReadMessage()) {
+      msg = FDMExec->ProcessMessage();
+      switch (msg->type) {
+      case FGJSBBase::Message::eText:
+        cout << msg->messageId << ": " << msg->text << endl;
+        break;
+      case FGJSBBase::Message::eBool:
+        cout << msg->messageId << ": " << msg->text << " " << msg->bVal << endl;
+        break;
+      case FGJSBBase::Message::eInteger:
+        cout << msg->messageId << ": " << msg->text << " " << msg->iVal << endl;
+        break;
+      case FGJSBBase::Message::eDouble:
+        cout << msg->messageId << ": " << msg->text << " " << msg->dVal << endl;
+        break;
+      default:
+        cerr << "Unrecognized message type." << endl;
+             break;
+      }
+    }
+
+    if (Scripted) {
+      if (!Script->RunScript()) break;
+    }
+
+    result = FDMExec->Run();
+  }
+
+  delete FDMExec;
+
+  return 0;
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+void options(int count, char **arg)
+{
+  int i;
+
+  if (count == 1) {
+    cout << endl << "  JSBSim version " << FDMExec->GetVersion() << endl << endl;
+    cout << "  Usage: jsbsim <options>" << endl << endl;
+    cout << "  options:" << endl;
+      cout << "    --help  returns this message" << endl;
+      cout << "    --version  returns the version number" << endl;
+      cout << "    --outputlogfile=<filename>  sets the name of the data output file" << endl;
+      cout << "    --logdirectivefile=<filename>  specifies the name of the data logging directives file" << endl;
+      cout << "    --aircraft=<filename>  specifies the name of the aircraft to be modeled" << endl;
+      cout << "    --script=<filename>  specifies a script to run" << endl;
+      cout << "    --initfile=<filename>  specifies an initilization file" << endl << endl;
+    cout << "  NOTE: There can be no spaces around the = sign when" << endl;
+    cout << "        an option is followed by a filename" << endl << endl;
+  }
+
+  for (i=1; i<count; i++) {
+    string argument = string(arg[i]);
+    int n=0;
+    if (argument.find("--help") != string::npos) {
+      cout << endl << "  JSBSim version " << FDMExec->GetVersion() << endl << endl;
+      cout << "  Usage: jsbsim <options>" << endl << endl;
+      cout << "  options:" << endl;
+      cout << "    --help  returns this message" << endl;
+      cout << "    --version  returns the version number" << endl;
+      cout << "    --outputlogfile=<filename>  sets the name of the data output file" << endl;
+      cout << "    --logdirectivefile=<filename>  specifies the name of the data logging directives file" << endl;
+      cout << "    --aircraft=<filename>  specifies the name of the aircraft to be modeled" << endl;
+      cout << "    --script=<filename>  specifies a script to run" << endl;
+      cout << "    --initfile=<filename>  specifies an initilization file" << endl << endl;
+      cout << "  NOTE: There can be no spaces around the = sign when" << endl;
+      cout << "        an option is followed by a filename" << endl << endl;
+      exit(0);
+    } else if (argument.find("--version") != string::npos) {
+      cout << endl << "  JSBSim Version: " << FDMExec->GetVersion() << endl << endl;
+      exit (0);
+    } else if (argument.find("--outputlogfile") != string::npos) {
+      n = argument.find("=")+1;
+      if (n > 0) {
+        LogOutputName = argument.substr(argument.find("=")+1);
+      } else {
+        LogOutputName = "JSBout.csv";
+        cerr << "  Output log file name not valid or not understood. Using JSBout.csv as default";
+      }
+    } else if (argument.find("--logdirectivefile") != string::npos) {
+      n = argument.find("=")+1;
+      if (n > 0) {
+        LogDirectiveName = argument.substr(argument.find("=")+1);
+      } else {
+        cerr << "  Log directives file not valid or not understood." << endl << endl;
+        exit(1);
+      }
+    } else if (argument.find("--aircraft") != string::npos) {
+      n = argument.find("=")+1;
+      if (n > 0) {
+        AircraftName = argument.substr(argument.find("=")+1);
+      } else {
+        cerr << "  Aircraft name not valid or not understood." << endl << endl;
+        exit(1);
+      }
+    } else if (argument.find("--script") != string::npos) {
+      n = argument.find("=")+1;
+      if (n > 0) {
+        ScriptName = argument.substr(argument.find("=")+1);
+      } else {
+        cerr << "  Script name not valid or not understood." << endl << endl;
+        exit(1);
+      }
+    } else if (argument.find("--initfile") != string::npos) {
+      n = argument.find("=")+1;
+      if (n > 0) {
+        ResetName = argument.substr(argument.find("=")+1);
+      } else {
+        cerr << "  Reset name not valid or not understood." << endl << endl;
+        exit(1);
+      }
+    } else {
+      cerr << endl << "  Parameter: " << argument << " not understood" << endl;
+    }
+  }
+
+}
+