1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6 Purpose: Standalone version of JSBSim.
9 ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
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
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
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.
25 Further information about the GNU General Public License can also be found on
26 the world wide web at http://www.gnu.org.
28 FUNCTIONAL DESCRIPTION
29 --------------------------------------------------------------------------------
31 This class Handles calling JSBSim standalone. It is set up for compilation under
32 Borland C+Builder or other compiler.
35 --------------------------------------------------------------------------------
38 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
40 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
42 #if __BCPLUSPLUS__ == 0x0540 // If compiling under Borland C++Builder
45 USEUNIT("FGUtility.cpp");
46 USEUNIT("FGAtmosphere.cpp");
47 USEUNIT("FGAuxiliary.cpp");
48 USEUNIT("FGCoefficient.cpp");
49 USEUNIT("FGConfigFile.cpp");
50 USEUNIT("FGControls.cpp");
51 USEUNIT("FGEngine.cpp");
53 USEUNIT("FGFDMExec.cpp");
54 USEUNIT("FGfdmSocket.cpp");
55 USEUNIT("FGInitialCondition.cpp");
56 USEUNIT("FGLGear.cpp");
57 USEUNIT("FGMatrix.cpp");
58 USEUNIT("FGModel.cpp");
59 USEUNIT("FGOutput.cpp");
60 USEUNIT("FGPosition.cpp");
61 USEUNIT("FGRotation.cpp");
62 USEUNIT("FGState.cpp");
63 USEUNIT("FGTank.cpp");
64 USEUNIT("FGTranslation.cpp");
65 USEUNIT("FGAircraft.cpp");
67 USEUNIT("filtersjb\FGfcsComponent.cpp");
68 USEUNIT("filtersjb\FGSwitch.cpp");
69 USEUNIT("filtersjb\FGFilter.cpp");
70 USEUNIT("filtersjb\FGGain.cpp");
71 USEUNIT("filtersjb\FGGradient.cpp");
72 USEUNIT("filtersjb\FGSummer.cpp");
73 USEUNIT("filtersjb\FGDeadBand.cpp");
74 USEUNIT("filtersjb\FGFlaps.cpp");
75 USEFILE("JSBSim.cxx");
76 USEUNIT("FGForce.cpp");
77 USEUNIT("FGInertial.cpp");
78 USEUNIT("FGNozzle.cpp");
79 USEUNIT("FGPropeller.cpp");
80 USEUNIT("FGRotor.cpp");
81 USEUNIT("FGThruster.cpp");
82 USEUNIT("FGMassBalance.cpp");
83 USEUNIT("FGRocket.cpp");
84 USEUNIT("FGTurboJet.cpp");
85 USEUNIT("FGPiston.cpp");
86 USEUNIT("FGTurboShaft.cpp");
87 USEUNIT("FGPropulsion.cpp");
88 USEUNIT("FGGroundReactions.cpp");
89 USEUNIT("FGAerodynamics.cpp");
94 #include "FGFDMExec.h"
95 #include "FGRotation.h"
96 #include "FGAtmosphere.h"
99 #include "FGAircraft.h"
100 #include "FGTranslation.h"
101 #include "FGPosition.h"
102 #include "FGAuxiliary.h"
103 #include "FGOutput.h"
106 #include <simgear/compiler.h>
107 #include STL_IOSTREAM
108 # ifdef SG_HAVE_STD_INCLUDES
118 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
120 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
122 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
124 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
126 static const char *IdSrc = "$Header$";
128 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
129 COMMENTS, REFERENCES, and NOTES [use "class documentation" below for API docs]
130 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
132 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
134 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
136 /** Standalone JSBSim main program
137 This is the wrapper program used to instantiate the JSBSim system and control
138 it. Use this program to build a version of JSBSim that can be run from the
139 command line. This program is also designed to be built using Borland C++
140 Builder, v4.0 or greater.
141 @author Jon S. Berndt
146 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
148 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
150 int main(int argc, char** argv)
157 << " You must enter the name of a registered aircraft and reset point:"
158 << endl << endl << " FDM <aircraft name> <reset file>" << endl;
162 FDMExec = new FGFDMExec();
164 result = FDMExec->LoadModel("aircraft", "engine", string(argv[1]));
167 cerr << "Aircraft file " << argv[1] << " was not found" << endl;
171 if ( ! FDMExec->GetState()->Reset("aircraft", string(argv[1]), string(argv[2])))
172 FDMExec->GetState()->Initialize(2000,0,0,0,0,0,0.5,0.5,40000);
176 while (FDMExec->GetState()->Getsim_time() <= 10.0)
178 // Fake an elevator ramp here after 1 second, hold for one second, ramp down
180 if (FDMExec->GetState()->Getsim_time() >= 1.00 &&
181 FDMExec->GetState()->Getsim_time() < 2.0)
183 cmd = -(FDMExec->GetState()->Getsim_time() - 1.00)/4.0;
184 } else if (FDMExec->GetState()->Getsim_time() >= 2.00 &&
185 FDMExec->GetState()->Getsim_time() < 6.0)
188 } else if (FDMExec->GetState()->Getsim_time() >= 6.00 &&
189 FDMExec->GetState()->Getsim_time() < 7.0)
191 cmd = -(7.0 - FDMExec->GetState()->Getsim_time())/4.0;
195 FDMExec->GetFCS()->SetDeCmd(cmd); // input between -1 and 1