]> git.mxchange.org Git - flightgear.git/commitdiff
Sync with latest JSBSim.
authorcurt <curt>
Sat, 1 Dec 2001 04:03:57 +0000 (04:03 +0000)
committercurt <curt>
Sat, 1 Dec 2001 04:03:57 +0000 (04:03 +0000)
src/FDM/JSBSim/FGAircraft.cpp
src/FDM/JSBSim/FGAircraft.h
src/FDM/JSBSim/FGFDMExec.cpp
src/FDM/JSBSim/FGJSBBase.cpp
src/FDM/JSBSim/FGPropulsion.cpp
src/FDM/JSBSim/JSBSim.cpp

index 1ea85b39fb42049a06d2c5e208dba6b793d69606..214dd844641626b5717915b7e0d50936f64e115e 100644 (file)
@@ -133,28 +133,28 @@ bool FGAircraft::Load(FGConfigFile* AC_cfg)
 {
   string token;
 
-  ReadPrologue(AC_cfg);
+  if (!ReadPrologue(AC_cfg)) return false;
 
   while ((AC_cfg->GetNextConfigLine() != string("EOF")) &&
          (token = AC_cfg->GetValue()) != string("/FDM_CONFIG")) {
     if (token == "METRICS") {
       if (debug_lvl > 0) cout << fgcyan << "\n  Reading Metrics" << fgdef << endl;
-      ReadMetrics(AC_cfg);
+      if (!ReadMetrics(AC_cfg)) return false;
     } else if (token == "AERODYNAMICS") {
       if (debug_lvl > 0) cout << fgcyan << "\n  Reading Aerodynamics" << fgdef << endl;
-      ReadAerodynamics(AC_cfg);
+      if (!ReadAerodynamics(AC_cfg)) return false;
     } else if (token == "UNDERCARRIAGE") {
       if (debug_lvl > 0) cout << fgcyan << "\n  Reading Landing Gear" << fgdef << endl;
-      ReadUndercarriage(AC_cfg);
+      if (!ReadUndercarriage(AC_cfg)) return false;
     } else if (token == "PROPULSION") {
       if (debug_lvl > 0) cout << fgcyan << "\n  Reading Propulsion" << fgdef << endl;
-      ReadPropulsion(AC_cfg);
+      if (!ReadPropulsion(AC_cfg)) return false;
     } else if (token == "FLIGHT_CONTROL") {
       if (debug_lvl > 0) cout << fgcyan << "\n  Reading Flight Control" << fgdef << endl;
-      ReadFlightControls(AC_cfg);
+      if (!ReadFlightControls(AC_cfg)) return false;
     } else if (token == "OUTPUT") {
       if (debug_lvl > 0) cout << fgcyan << "\n  Reading Output directives" << fgdef << endl;
-      ReadOutput(AC_cfg);
+      if (!ReadOutput(AC_cfg)) return false;
     }
   }
   
@@ -207,7 +207,7 @@ float FGAircraft::GetNlf(void)
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-void FGAircraft::ReadPrologue(FGConfigFile* AC_cfg)
+bool FGAircraft::ReadPrologue(FGConfigFile* AC_cfg)
 {
   string token = AC_cfg->GetValue();
   string scratch;
@@ -226,12 +226,14 @@ void FGAircraft::ReadPrologue(FGConfigFile* AC_cfg)
             " RESULTS WILL BE UNPREDICTABLE !!" << endl;
     cerr << "Current version needed is: " << needed_cfg_version << endl;
     cerr << "         You have version: " << CFGVersion << endl << fgdef << endl;
+    return false;
   }
+  return true;
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-void FGAircraft::ReadMetrics(FGConfigFile* AC_cfg)
+bool FGAircraft::ReadMetrics(FGConfigFile* AC_cfg)
 {
   string token = "";
   string parameter;
@@ -317,52 +319,62 @@ void FGAircraft::ReadMetrics(FGConfigFile* AC_cfg)
       vbarv = VTailArm*VTailArea / (cbar*WingArea);
     }
   }     
-
+  return true;
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-void FGAircraft::ReadPropulsion(FGConfigFile* AC_cfg)
+bool FGAircraft::ReadPropulsion(FGConfigFile* AC_cfg)
 {
   if (!Propulsion->Load(AC_cfg)) {
-    cerr << "Propulsion not successfully loaded" << endl;
+    cerr << "  Propulsion not successfully loaded" << endl;
+    return false;
   }
+  return true;
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-void FGAircraft::ReadFlightControls(FGConfigFile* AC_cfg)
+bool FGAircraft::ReadFlightControls(FGConfigFile* AC_cfg)
 {
   if (!FCS->Load(AC_cfg)) {
-    cerr << "Flight Controls not successfully loaded" << endl;
+    cerr << "  Flight Controls not successfully loaded" << endl;
+    return false;
   }
+  return true;
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-void FGAircraft::ReadAerodynamics(FGConfigFile* AC_cfg)
+bool FGAircraft::ReadAerodynamics(FGConfigFile* AC_cfg)
 {
   if (!Aerodynamics->Load(AC_cfg)) {
-    cerr << "Aerodynamics not successfully loaded" << endl;
+    cerr << "  Aerodynamics not successfully loaded" << endl;
+    return false;
   }
+  return true;
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-void FGAircraft::ReadUndercarriage(FGConfigFile* AC_cfg)
+bool FGAircraft::ReadUndercarriage(FGConfigFile* AC_cfg)
 {
   if (!GroundReactions->Load(AC_cfg)) {
-    cerr << "Ground Reactions not successfully loaded" << endl;
+    cerr << "  Ground Reactions not successfully loaded" << endl;
+    return false;
   }
+  return true;
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-void FGAircraft::ReadOutput(FGConfigFile* AC_cfg)
+bool FGAircraft::ReadOutput(FGConfigFile* AC_cfg)
 {
   if (!Output->Load(AC_cfg)) {
-    cerr << "Output not successfully loaded" << endl;
+    cerr << "  Output not successfully loaded" << endl;
+    return false;
   }
+  return true;
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
index e4110fc9b2050f92b61a3829e429d3a1c1c4cce9..8dc7beb7c92532714af6e0ff5a545c16b49c9fd9 100644 (file)
@@ -225,13 +225,13 @@ private:
   string CFGVersion;
   string AircraftName;
 
-  void ReadMetrics(FGConfigFile*);
-  void ReadPropulsion(FGConfigFile*);
-  void ReadFlightControls(FGConfigFile*);
-  void ReadAerodynamics(FGConfigFile*);
-  void ReadUndercarriage(FGConfigFile*);
-  void ReadPrologue(FGConfigFile*);
-  void ReadOutput(FGConfigFile*);
+  bool ReadMetrics(FGConfigFile*);
+  bool ReadPropulsion(FGConfigFile*);
+  bool ReadFlightControls(FGConfigFile*);
+  bool ReadAerodynamics(FGConfigFile*);
+  bool ReadUndercarriage(FGConfigFile*);
+  bool ReadPrologue(FGConfigFile*);
+  bool ReadOutput(FGConfigFile*);
   void Debug(void);
 };
 
index 1031a17b09fb6f8d3aa3109fac898814ce86956c..b191a901cbed58d33faf58e2f3e44f5f093a1617 100644 (file)
@@ -395,13 +395,13 @@ bool FGFDMExec::LoadModel(string APath, string EPath, string model)
 
   if (result) {
     modelLoaded = true;
+    if (debug_lvl > 0) cout << "\n\nJSBSim startup complete\n\n";
   } else {
     cerr << fgred
-         << "FGFDMExec: Failed to load aircraft and/or engine model"
+         << "  FGFDMExec: Failed to load aircraft and/or engine model"
          << fgdef << endl;
   }
 
-  if (debug_lvl > 0) cout << "\n\nJSBSim startup complete\n\n";
   return result;
 }
 
index ccc6b88e6f0928ef69fdcb67302fb56e363a20ca..d04fdfd1f3b9e1792f650127fb8a17c2d5b0428e 100644 (file)
@@ -64,7 +64,7 @@ const double FGJSBBase::ktstofps = 1.68781;
 const double FGJSBBase::inchtoft = 0.08333333;
 const double FGJSBBase::Reng = 1716.0;
 const double FGJSBBase::SHRatio = 1.40;
-const string FGJSBBase::needed_cfg_version = "1.55";
+const string FGJSBBase::needed_cfg_version = "1.56";
 const string FGJSBBase::JSBSim_version = "0.9.1";
 
 queue <FGJSBBase::Message*> FGJSBBase::Messages;
index 98d5ab3c5d1caddd190c759ebbab52562045c033..0dcaf9010a93d43cff6a2acecff911da636127af 100644 (file)
@@ -226,7 +226,9 @@ bool FGPropulsion::Load(FGConfigFile* AC_cfg)
         } else if (engType == "FG_TURBOPROP") {
           Engines.push_back(new FGTurboProp(FDMExec, &Eng_cfg));
         } else {
-          cerr << "    Unrecognized engine type: " << engType << " found in config file.\n";
+          cerr << fgred << "    Unrecognized engine type: " << underon << engType
+                    << underoff << " found in config file." << fgdef << endl;
+          return false;
         }
 
         AC_cfg->GetNextConfigLine();
@@ -259,8 +261,8 @@ bool FGPropulsion::Load(FGConfigFile* AC_cfg)
 
       } else {
 
-        cerr << "Could not read engine config file: " << fullpath
-                                                  + engineFileName + ".xml" << endl;
+        cerr << fgred << "\n  Could not read engine config file: " << underon <<
+                    fullpath + engineFileName + ".xml" << underoff << fgdef << endl;
         return false;
       }
 
@@ -346,19 +348,20 @@ string FGPropulsion::GetPropulsionStrings(void)
 {
   string PropulsionStrings = "";
   bool firstime = true;
+  char buffer[5];
 
   for (unsigned int i=0;i<Engines.size();i++) {
-    if (!firstime) {
-      PropulsionStrings += ", ";
-      firstime = false;
-    }
+    if (firstime)  firstime = false;
+    else           PropulsionStrings += ", ";
+
+    sprintf(buffer, "%d", i);
 
     switch(Engines[i]->GetType()) {
     case FGEngine::etPiston:
-      PropulsionStrings += (Engines[i]->GetName() + "_PwrAvail");
+      PropulsionStrings += (Engines[i]->GetName() + "_PwrAvail[" + buffer + "]");
       break;
     case FGEngine::etRocket:
-      PropulsionStrings += (Engines[i]->GetName() + "_ChamberPress");
+      PropulsionStrings += (Engines[i]->GetName() + "_ChamberPress[" + buffer + "]");
       break;
     case FGEngine::etTurboJet:
     case FGEngine::etTurboProp:
@@ -373,14 +376,14 @@ string FGPropulsion::GetPropulsionStrings(void)
 
     switch(Thrusters[i]->GetType()) {
     case FGThruster::ttNozzle:
-      PropulsionStrings += (Thrusters[i]->GetName() + "_Thrust");
+      PropulsionStrings += (Thrusters[i]->GetName() + "_Thrust[" + buffer + "]");
       break;
     case FGThruster::ttRotor:
       break;
     case FGThruster::ttPropeller:
-      PropulsionStrings += (Thrusters[i]->GetName() + "_Torque, ");
-      PropulsionStrings += (Thrusters[i]->GetName() + "_Thrust, ");
-      PropulsionStrings += (Thrusters[i]->GetName() + "_RPM");
+      PropulsionStrings += (Thrusters[i]->GetName() + "_Torque[" + buffer + "], ");
+      PropulsionStrings += (Thrusters[i]->GetName() + "_Thrust[" + buffer + "], ");
+      PropulsionStrings += (Thrusters[i]->GetName() + "_RPM[" + buffer + "]");
       break;
     default:
       PropulsionStrings += "INVALID THRUSTER TYPE";
@@ -400,10 +403,8 @@ string FGPropulsion::GetPropulsionValues(void)
   bool firstime = true;
 
   for (unsigned int i=0;i<Engines.size();i++) {
-    if (!firstime) {
-      PropulsionValues += ", ";
-      firstime = false;
-    }
+    if (firstime)  firstime = false;
+    else           PropulsionValues += ", ";
 
     switch(Engines[i]->GetType()) {
     case FGEngine::etPiston:
index e5b3b4e12ef845b37d45e565097cdb8185a7ec27..a5ffaab0427a1619111fe88511c2a9096027f187 100644 (file)
-/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
- 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"
-
-#ifdef FGFS
-#include <simgear/compiler.h>
-#include STL_IOSTREAM
-#  ifdef SG_HAVE_STD_INCLUDES
-#    include <ctime>
-#  else
-#    include <time.h>
-#  endif
-#else
-#  if defined(sgi) && !defined(__GNUC__)
-#    include <iostream.h>
-#    include <time.h>
-#  else
-#    include <iostream>
-#    include <ctime>
-#  endif
-#endif
-
-/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-DEFINITIONS
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-
-/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-GLOBAL DATA
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-
-static const char *IdSrc = "$Id$";
-
-/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-COMMENTS, REFERENCES, and NOTES [use "class documentation" below for API docs]
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-
-/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-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)
-{
-  FGFDMExec* FDMExec;
-  float cmd = 0.0;
-  bool result = false;
-  bool scripted = false;
-
-  if (argc == 2) {
-    FGConfigFile testFile(argv[1]);
-
-    if (!testFile.IsOpen()) {
-      cout << "Script file not opened" << endl;
-      exit(-1); 
-    }
-
-    testFile.GetNextConfigLine();
-    if (testFile.GetValue("runscript").length() <= 0) {
-      cout << "File: " << argv[1] << " is not a script file" << endl;
-      exit(-1); 
-    }
-    scripted = true;
-  } else if (argc != 3) {
-    cout << endl
-         << "  You must enter the name of a registered aircraft and reset point:"
-         << endl << endl << "  FDM <aircraft name> <reset file>" << endl;
-    cout << endl << "  Alternatively, you may specify only the name of a script file:"
-         << endl << endl << "  FDM <script file>" << endl << endl;
-    exit(0);
-  }
-
-  FDMExec = new FGFDMExec();
-
-  if (scripted) { // form jsbsim <scriptfile>
-    result = FDMExec->LoadScript(argv[1]);
-    if (!result) {
-      cerr << "Script file " << argv[1] << " was not successfully loaded" << endl;
-      exit(-1);
-    }
-  } else {        // form jsbsim <acname> <resetfile>
-    if ( ! FDMExec->LoadModel("aircraft", "engine", string(argv[1]))) {
-       cerr << "JSBSim could not be started" << endl;
-      exit(-1);
-    }                   
-
-    FGInitialCondition IC(FDMExec);
-    if ( ! IC.Load("aircraft",string(argv[1]),string(argv[2]))) {
-       cerr << "Initialization unsuccessful" << endl;
-      exit(-1);
-    }
-  }
-
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\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
+\r
+#ifdef FGFS\r
+#include <simgear/compiler.h>\r
+#include STL_IOSTREAM\r
+#  ifdef SG_HAVE_STD_INCLUDES\r
+#    include <ctime>\r
+#  else\r
+#    include <time.h>\r
+#  endif\r
+#else\r
+#  if defined(sgi) && !defined(__GNUC__)\r
+#    include <iostream.h>\r
+#    include <time.h>\r
+#  else\r
+#    include <iostream>\r
+#    include <ctime>\r
+#  endif\r
+#endif\r
+\r
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r
+DEFINITIONS\r
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/\r
+\r
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r
+GLOBAL DATA\r
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/\r
+\r
+static const char *IdSrc = "$Id$";\r
+\r
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r
+COMMENTS, REFERENCES, and NOTES [use "class documentation" below for API docs]\r
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/\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
+  FGFDMExec* FDMExec;\r
+  float cmd = 0.0;\r
+  bool result = false;\r
+  bool scripted = false;\r
+\r
+  if (argc == 2) {\r
+    FGConfigFile testFile(argv[1]);\r
+\r
+    if (!testFile.IsOpen()) {\r
+      cout << "Script file not opened" << endl;\r
+      exit(-1); \r
+    }\r
+\r
+    testFile.GetNextConfigLine();\r
+    if (testFile.GetValue("runscript").length() <= 0) {\r
+      cout << "File: " << argv[1] << " is not a script file" << endl;\r
+      exit(-1); \r
+    }\r
+    scripted = true;\r
+  } else if (argc != 3) {\r
+    cout << endl\r
+         << "  You must enter the name of a registered aircraft and reset point:"\r
+         << endl << endl << "  FDM <aircraft name> <reset file>" << endl;\r
+    cout << endl << "  Alternatively, you may specify only the name of a script file:"\r
+         << endl << endl << "  FDM <script file>" << endl << endl;\r
+    exit(0);\r
+  }\r
+\r
+  FDMExec = new FGFDMExec();\r
+\r
+  if (scripted) { // form jsbsim <scriptfile>\r
+    result = FDMExec->LoadScript(argv[1]);\r
+    if (!result) {\r
+      cerr << "Script file " << argv[1] << " was not successfully loaded" << endl;\r
+      exit(-1);\r
+    }\r
+  } else {        // form jsbsim <acname> <resetfile>\r
+    if ( ! FDMExec->LoadModel("aircraft", "engine", string(argv[1]))) {\r
+       cerr << "  JSBSim could not be started" << endl << endl;\r
+      exit(-1);\r
+    }                   \r
+\r
+    FGInitialCondition IC(FDMExec);\r
+    if ( ! IC.Load("aircraft",string(argv[1]),string(argv[2]))) {\r
+       cerr << "Initialization unsuccessful" << endl;\r
+      exit(-1);\r
+    }\r
+  }\r
+\r
   FGJSBBase::Message* msg;\r
-  while (FDMExec->Run()) {
-    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;
-      }
-    }
-  }
-
-  delete FDMExec;
-
-  return 0;
-}
+  while (FDMExec->Run()) {\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
+\r
+  delete FDMExec;\r
+\r
+  return 0;\r
+}\r