]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/JSBSim/JSBSim.cpp
Check return value of FDM::init().
[flightgear.git] / src / FDM / JSBSim / JSBSim.cpp
index 3e38cab84ff64b017b9277c9240cb329f678bedb..43850a69c3e11bf4c36d47cacd8681c8f0824242 100644 (file)
@@ -39,29 +39,56 @@ HISTORY
 INCLUDES
 *******************************************************************************/
 
-#if __BCPLUSPLUS__     >= 0x0540   // If compiling under Borland C++Builder
-  //---------------------------------------------------------------------------
-  #pragma hdrstop
-  #include <condefs.h>
-  USEUNIT("FGAircraft.cpp");
-  USEUNIT("FGAtmosphere.cpp");
-  USEUNIT("FGAuxiliary.cpp");
-  USEUNIT("FGCoefficient.cpp");
-  USEUNIT("FGEngine.cpp");
-  USEUNIT("FGFCS.cpp");
-  USEUNIT("FGFDMExec.cpp");
-  USEUNIT("FGInitialCondition.cpp");
-  USEUNIT("FGModel.cpp");
-  USEUNIT("FGOutput.cpp");
-  USEUNIT("FGPosition.cpp");
-  USEUNIT("FGRotation.cpp");
-  USEUNIT("FGState.cpp");
-  USEUNIT("FGTank.cpp");
-  USEUNIT("FGTranslation.cpp");
-  USEUNIT("FGUtility.cpp");
-  USERES("JSBSim.res");
-  //---------------------------------------------------------------------------
-  #pragma argsused
+#if __BCPLUSPLUS__  == 0x0540   // If compiling under Borland C++Builder
+#pragma hdrstop
+#include <condefs.h>
+USEUNIT("FGUtility.cpp");
+USEUNIT("FGAtmosphere.cpp");
+USEUNIT("FGAuxiliary.cpp");
+USEUNIT("FGCoefficient.cpp");
+USEUNIT("FGConfigFile.cpp");
+USEUNIT("FGControls.cpp");
+USEUNIT("FGEngine.cpp");
+USEUNIT("FGFCS.cpp");
+USEUNIT("FGFDMExec.cpp");
+USEUNIT("FGfdmSocket.cpp");
+USEUNIT("FGInitialCondition.cpp");
+USEUNIT("FGLGear.cpp");
+USEUNIT("FGMatrix.cpp");
+USEUNIT("FGModel.cpp");
+USEUNIT("FGOutput.cpp");
+USEUNIT("FGPosition.cpp");
+USEUNIT("FGRotation.cpp");
+USEUNIT("FGState.cpp");
+USEUNIT("FGTank.cpp");
+USEUNIT("FGTranslation.cpp");
+USEUNIT("FGAircraft.cpp");
+USERES("JSBSim.res");
+USEUNIT("filtersjb\FGfcsComponent.cpp");
+USEUNIT("filtersjb\FGSwitch.cpp");
+USEUNIT("filtersjb\FGFilter.cpp");
+USEUNIT("filtersjb\FGGain.cpp");
+USEUNIT("filtersjb\FGGradient.cpp");
+USEUNIT("filtersjb\FGSummer.cpp");
+USEUNIT("filtersjb\FGDeadBand.cpp");
+USEUNIT("filtersjb\FGFlaps.cpp");
+USEFILE("JSBSim.cxx");
+USEUNIT("FGForce.cpp");
+USEUNIT("FGInertial.cpp");
+USEUNIT("FGNozzle.cpp");
+USEUNIT("FGPropeller.cpp");
+USEUNIT("FGRotor.cpp");
+USEUNIT("FGThruster.cpp");
+USEUNIT("FGMassBalance.cpp");
+USEUNIT("FGRocket.cpp");
+USEUNIT("FGTurboJet.cpp");
+USEUNIT("FGPiston.cpp");
+USEUNIT("FGTurboShaft.cpp");
+USEUNIT("FGPropulsion.cpp");
+USEUNIT("FGGroundReactions.cpp");
+USEUNIT("FGAerodynamics.cpp");
+//---------------------------------------------------------------------------
+#pragma argsused
 #endif
 
 #include "FGFDMExec.h"
@@ -75,12 +102,25 @@ INCLUDES
 #include "FGAuxiliary.h"
 #include "FGOutput.h"
 
+#ifdef FGFS
+#include <simgear/compiler.h>
+#include STL_IOSTREAM
+#  ifdef FG_HAVE_STD_INCLUDES
+#    include <ctime>
+#  else
+#    include <time.h>
+#  endif
+#else
 #include <iostream>
 #include <ctime>
+#endif
+
+static const char *IdSrc = "$Header$";
 
 int main(int argc, char** argv)
 {
-       FGFDMExec* FDMExec;
+  FGFDMExec* FDMExec;
+  bool result = false;
 
   if (argc != 3) {
     cout << endl
@@ -91,29 +131,45 @@ int main(int argc, char** argv)
 
   FDMExec = new FGFDMExec();
 
-  FDMExec->GetAircraft()->LoadAircraft("aircraft", "engine", string(argv[1]));
-  FDMExec->GetState()->Reset("aircraft", string(argv[2]));
+  result = FDMExec->LoadModel("aircraft", "engine", string(argv[1]));
+  
+  if (!result) {
+       cerr << "Aircraft file " << argv[1] << " was not found" << endl;
+         exit(-1);
+  }
+  
+  if ( ! FDMExec->GetState()->Reset("aircraft", string(argv[1]), string(argv[2])))
+    FDMExec->GetState()->Initialize(2000,0,0,0,0,0,0.5,0.5,40000);
+
+  float cmd = 0.0;
 
-  while (FDMExec->GetState()->Getsim_time() <= 25.0)
+  while (FDMExec->GetState()->Getsim_time() <= 10.0)
   {
-    //
-    // Fake an elevator kick here after 5 seconds
-    //
-
-               if (FDMExec->GetState()->Getsim_time() > 5.0 &&
+    // Fake an elevator ramp here after 1 second, hold for one second, ramp down
+    
+    if (FDMExec->GetState()->Getsim_time() >= 1.00 &&
+        FDMExec->GetState()->Getsim_time() < 2.0)
+    {
+      cmd = -(FDMExec->GetState()->Getsim_time() - 1.00)/2.0;
+    } else if (FDMExec->GetState()->Getsim_time() >= 2.00 &&
         FDMExec->GetState()->Getsim_time() < 6.0)
     {
-                       FDMExec->GetFCS()->SetDe(0.05);
-               }
-
+      cmd = -1.00/2.0;
+    } else if (FDMExec->GetState()->Getsim_time() >= 6.00 &&
+        FDMExec->GetState()->Getsim_time() < 7.0)
+    {
+      cmd = -(7.0 - FDMExec->GetState()->Getsim_time())/2.0;
+    } else {
+      cmd = 0.00;
+    }
+    FDMExec->GetFCS()->SetDeCmd(cmd);    // input between -1 and 1
+    
     FDMExec->Run();
   }
 
   delete FDMExec;
-  
+
   return 0;
 }
 
-WinMain()
-{
-}
+