]> git.mxchange.org Git - flightgear.git/blob - src/FDM/YASim/FGFDM.hpp
Port over remaining Point3D usage to the more type and unit safe SG* classes.
[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     float getVehicleRadius(void) const { return _vehicle_radius; }
31
32 private:
33     struct AxisRec { char* name; int handle; };
34     struct EngRec { char* prefix; Thruster* eng; };
35     struct WeightRec { char* prop; float size; int handle; };
36     struct PropOut { SGPropertyNode* prop; int handle, type; bool left;
37                      float min, max; };
38
39     void setOutputProperties(float dt);
40
41     Rotor* parseRotor(XMLAttributes* a, const char* name);
42     Wing* parseWing(XMLAttributes* a, const char* name);
43     int parseAxis(const char* name);
44     int parseOutput(const char* name);
45     void parseWeight(XMLAttributes* a);
46     void parseTurbineEngine(XMLAttributes* a);
47     void parsePistonEngine(XMLAttributes* a);
48     void parsePropeller(XMLAttributes* a);
49     bool eq(const char* a, const char* b);
50     bool caseeq(const char* a, const char* b);
51     char* dup(const char* s);
52     int attri(XMLAttributes* atts, const char* attr);
53     int attri(XMLAttributes* atts, const char* attr, int def); 
54     float attrf(XMLAttributes* atts, const char* attr);
55     float attrf(XMLAttributes* atts, const char* attr, float def); 
56     double attrd(XMLAttributes* atts, const char* attr);
57     double attrd(XMLAttributes* atts, const char* attr, double def); 
58     bool attrb(XMLAttributes* atts, const char* attr);
59
60     // The core Airplane object we manage.
61     Airplane _airplane;
62
63     // Aerodynamic turbulence model
64     Turbulence* _turb;
65
66     // The list of "axes" that we expect to find as input.  These are
67     // typically property names.
68     Vector _axes;
69
70     // Settable weights
71     Vector _weights;
72
73     // Engine types.  Contains an EngRec structure.
74     Vector _thrusters;
75
76     // Output properties for the ControlMap
77     Vector _controlProps;
78
79     // Radius of the vehicle, for intersection testing.
80     float _vehicle_radius;
81
82     // Parsing temporaries
83     void* _currObj;
84     bool _cruiseCurr;
85     int _nextEngine;
86 };
87
88 }; // namespace yasim
89 #endif // _FGFDM_HPP