]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/JSBSim.cpp
Updates to help work the kinks out of JSBsim.
[flightgear.git] / src / FDM / JSBSim / JSBSim.cpp
1 /*******************************************************************************
2
3  Module:       JSBSim.cpp
4  Author:       Jon S. Berndt
5  Date started: 08/17/99
6  Purpose:      Standalone version of JSBSim.
7  Called by:    The USER.
8
9  ------------- Copyright (C) 1999  Jon S. Berndt (jsb@hal-pc.org) -------------
10
11  This program is free software; you can redistribute it and/or modify it under
12  the terms of the GNU General Public License as published by the Free Software
13  Foundation; either version 2 of the License, or (at your option) any later
14  version.
15
16  This program is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
19  details.
20
21  You should have received a copy of the GNU General Public License along with
22  this program; if not, write to the Free Software Foundation, Inc., 59 Temple
23  Place - Suite 330, Boston, MA  02111-1307, USA.
24
25  Further information about the GNU General Public License can also be found on
26  the world wide web at http://www.gnu.org.
27
28 FUNCTIONAL DESCRIPTION
29 --------------------------------------------------------------------------------
30
31 This class Handles calling JSBSim standalone. It is set up for compilation under
32 Borland C+Builder or other compiler.
33
34 HISTORY
35 --------------------------------------------------------------------------------
36 08/17/99   JSB   Created
37
38 ********************************************************************************
39 INCLUDES
40 *******************************************************************************/
41
42 #if __BCPLUSPLUS__      >= 0x0540   // If compiling under Borland C++Builder
43 //---------------------------------------------------------------------------
44 #pragma hdrstop
45 #include <condefs.h>
46 USEUNIT("FGAircraft.cpp");
47 USEUNIT("FGAtmosphere.cpp");
48 USEUNIT("FGAuxiliary.cpp");
49 USEUNIT("FGCoefficient.cpp");
50 USEUNIT("FGEngine.cpp");
51 USEUNIT("FGFCS.cpp");
52 USEUNIT("FGFDMExec.cpp");
53 USEUNIT("FGInitialCondition.cpp");
54 USEUNIT("FGModel.cpp");
55 USEUNIT("FGOutput.cpp");
56 USEUNIT("FGPosition.cpp");
57 USEUNIT("FGRotation.cpp");
58 USEUNIT("FGState.cpp");
59 USEUNIT("FGTank.cpp");
60 USEUNIT("FGTranslation.cpp");
61 USEUNIT("FGUtility.cpp");
62 USERES("JSBSim.res");
63 USEUNIT("FGLGear.cpp");
64 USEUNIT("FGfdmSocket.cpp");
65 //---------------------------------------------------------------------------
66 #pragma argsused
67 #endif
68
69 #include "FGFDMExec.h"
70 #include "FGRotation.h"
71 #include "FGAtmosphere.h"
72 #include "FGState.h"
73 #include "FGFCS.h"
74 #include "FGAircraft.h"
75 #include "FGTranslation.h"
76 #include "FGPosition.h"
77 #include "FGAuxiliary.h"
78 #include "FGOutput.h"
79
80 #ifdef FGFS
81 #include <Include/compiler.h>
82 #include STL_IOSTREAM
83 #  ifdef FG_HAVE_STD_INCLUDES
84 #    include <ctime>
85 #  else
86 #    include <time.h>
87 #  endif
88 #else
89 #include <iostream>
90 #include <ctime>
91 #endif
92
93 int main(int argc, char** argv)
94 {
95         FGFDMExec* FDMExec;
96
97   if (argc != 3) {
98     cout << endl
99          << "  You must enter the name of a registered aircraft and reset point:"
100          << endl << endl << "  FDM <aircraft name> <reset file>" << endl;
101     exit(0);
102   }
103
104   FDMExec = new FGFDMExec();
105
106   FDMExec->GetAircraft()->LoadAircraft("aircraft", "engine", string(argv[1]));
107   FDMExec->GetState()->Reset("aircraft", string(argv[2]));
108
109   while (FDMExec->GetState()->Getsim_time() <= 25.0)
110   {
111     //
112     // Fake an elevator kick here after 5 seconds
113     //
114
115                 if (FDMExec->GetState()->Getsim_time() > 5.0 &&
116         FDMExec->GetState()->Getsim_time() < 6.0)
117     {
118                         FDMExec->GetFCS()->SetDe(0.05);
119                 } else {
120                         FDMExec->GetFCS()->SetDe(0.00);
121     }
122
123     FDMExec->Run();
124   }
125
126   delete FDMExec;
127   
128   return 0;
129 }
130
131 #ifndef FGFS
132 int WinMain()
133 {
134   return 0;
135 }
136 #endif