]> git.mxchange.org Git - flightgear.git/blob - src/FDM/YASim/FGFDM.hpp
Moved JSBSim.hxx to src/FDM/JSBSim/
[flightgear.git] / src / FDM / YASim / FGFDM.hpp
1 #ifndef _FGFDM_HPP
2 #define _FGFDM_HPP
3
4 #include <simgear/xml/easyxml.hxx>
5
6 #include "Airplane.hpp"
7 #include "Vector.hpp"
8
9 namespace yasim {
10
11 class Wing;
12
13 // This class forms the "glue" to the FlightGear codebase.  It handles
14 // parsing of XML airplane files, interfacing to the properties
15 // system, and providing data for the use of the FGInterface object.
16 class FGFDM : public XMLVisitor {
17 public:
18     FGFDM();
19     ~FGFDM();
20     void init();
21     void iterate(float dt);
22     void getExternalInput(float dt=1e6);
23
24     Airplane* getAirplane();
25
26     // XML parsing callback from XMLVisitor
27     virtual void startElement(const char* name, const XMLAttributes &atts);
28
29 private:
30     struct AxisRec { char* name; int handle; };
31     struct EngRec { char* prefix; Thruster* eng; };
32     struct WeightRec { char* prop; float size; int handle; };
33
34     void setOutputProperties();
35
36     Wing* parseWing(XMLAttributes* a, const char* name);
37     int parseAxis(const char* name);
38     int parseOutput(const char* name);
39     void parseWeight(XMLAttributes* a);
40     void parsePropeller(XMLAttributes* a);
41     bool eq(const char* a, const char* b);
42     char* dup(const char* s);
43     int attri(XMLAttributes* atts, char* attr);
44     int attri(XMLAttributes* atts, char* attr, int def); 
45     float attrf(XMLAttributes* atts, char* attr);
46     float attrf(XMLAttributes* atts, char* attr, float def); 
47
48     // The core Airplane object we manage.
49     Airplane _airplane;
50
51     // The list of "axes" that we expect to find as input.  These are
52     // typically property names.
53     Vector _axes;
54
55     // Settable weights
56     Vector _weights;
57
58     // Engine types.  Contains an EngRec structure.
59     Vector _thrusters;
60
61     // Parsing temporaries
62     void* _currObj;
63     bool _cruiseCurr;
64     int _nextEngine;
65 };
66
67 }; // namespace yasim
68 #endif // _FGFDM_HPP