4 #include <simgear/xml/easyxml.hxx>
5 #include <simgear/props/props.hxx>
7 #include "Airplane.hpp"
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 {
22 void iterate(float dt);
23 void getExternalInput(float dt=1e6);
25 Airplane* getAirplane();
27 // XML parsing callback from XMLVisitor
28 virtual void startElement(const char* name, const XMLAttributes &atts);
30 float getVehicleRadius(void) const { return _vehicle_radius; }
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;
39 void setOutputProperties(float dt);
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);
60 // The core Airplane object we manage.
63 // Aerodynamic turbulence model
66 // The list of "axes" that we expect to find as input. These are
67 // typically property names.
73 // Engine types. Contains an EngRec structure.
76 // Output properties for the ControlMap
79 // Radius of the vehicle, for intersection testing.
80 float _vehicle_radius;
82 // Parsing temporaries
90 SGPropertyNode_ptr _out_of_fuel;
91 SGPropertyNode_ptr _fuel_consumed_lbs;
97 SGPropertyNode_ptr _running, _cranking;
98 SGPropertyNode_ptr _prop_thrust, _thrust_lbs, _fuel_flow_gph;
99 SGPropertyNode_ptr _rpm, _torque_ftlb, _mp_osi, _mp_inhg;
100 SGPropertyNode_ptr _oil_temperature_degf, _boost_gauge_inhg;
101 SGPropertyNode_ptr _n1, _n2, _epr, _egt_degf;
104 SGPropertyNode_ptr _turb_magnitude_norm, _turb_rate_hz;
105 SGPropertyNode_ptr _gross_weight_lbs;
106 vector<SGPropertyNode_ptr> _tank_level_lbs;
107 vector<ThrusterProps> _thrust_props;
108 vector<FuelProps> _fuel_props;
111 }; // namespace yasim