]> git.mxchange.org Git - flightgear.git/blob - src/FDM/YASim/FGFDM.hpp
Solve for the elevator control input during approach. It turns out that
[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     struct PropOut { SGPropertyNode* prop; int handle, type; bool left;
34                      float min, max; };
35
36     void setOutputProperties();
37
38     Wing* parseWing(XMLAttributes* a, const char* name);
39     int parseAxis(const char* name);
40     int parseOutput(const char* name);
41     void parseWeight(XMLAttributes* a);
42     void parsePropeller(XMLAttributes* a);
43     bool eq(const char* a, const char* b);
44     char* dup(const char* s);
45     int attri(XMLAttributes* atts, char* attr);
46     int attri(XMLAttributes* atts, char* attr, int def); 
47     float attrf(XMLAttributes* atts, char* attr);
48     float attrf(XMLAttributes* atts, char* attr, float def); 
49
50     // The core Airplane object we manage.
51     Airplane _airplane;
52
53     // The list of "axes" that we expect to find as input.  These are
54     // typically property names.
55     Vector _axes;
56
57     // Settable weights
58     Vector _weights;
59
60     // Engine types.  Contains an EngRec structure.
61     Vector _thrusters;
62
63     // Output properties for the ControlMap
64     Vector _controlProps;
65
66     // Parsing temporaries
67     void* _currObj;
68     bool _cruiseCurr;
69     int _nextEngine;
70 };
71
72 }; // namespace yasim
73 #endif // _FGFDM_HPP