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