2001-12-01 06:22:24 +00:00
|
|
|
#ifndef _FGFDM_HPP
|
|
|
|
#define _FGFDM_HPP
|
|
|
|
|
2001-12-16 22:00:35 +00:00
|
|
|
#include <simgear/xml/easyxml.hxx>
|
2003-05-06 23:46:24 +00:00
|
|
|
#include <simgear/props/props.hxx>
|
2001-12-01 06:22:24 +00:00
|
|
|
|
|
|
|
#include "Airplane.hpp"
|
2001-12-06 18:16:22 +00:00
|
|
|
#include "Vector.hpp"
|
2001-12-01 06:22:24 +00:00
|
|
|
|
|
|
|
namespace yasim {
|
|
|
|
|
|
|
|
class Wing;
|
|
|
|
|
|
|
|
// This class forms the "glue" to the FlightGear codebase. It handles
|
|
|
|
// parsing of XML airplane files, interfacing to the properties
|
|
|
|
// system, and providing data for the use of the FGInterface object.
|
|
|
|
class FGFDM : public XMLVisitor {
|
|
|
|
public:
|
|
|
|
FGFDM();
|
|
|
|
~FGFDM();
|
|
|
|
void init();
|
|
|
|
void iterate(float dt);
|
2001-12-24 13:54:03 +00:00
|
|
|
void getExternalInput(float dt=1e6);
|
2001-12-01 06:22:24 +00:00
|
|
|
|
|
|
|
Airplane* getAirplane();
|
|
|
|
|
|
|
|
// XML parsing callback from XMLVisitor
|
|
|
|
virtual void startElement(const char* name, const XMLAttributes &atts);
|
|
|
|
|
2005-02-17 10:26:14 +00:00
|
|
|
float getVehicleRadius(void) const { return _vehicle_radius; }
|
|
|
|
|
2001-12-01 06:22:24 +00:00
|
|
|
private:
|
|
|
|
struct AxisRec { char* name; int handle; };
|
2001-12-24 13:54:03 +00:00
|
|
|
struct EngRec { char* prefix; Thruster* eng; };
|
2001-12-01 06:22:24 +00:00
|
|
|
struct WeightRec { char* prop; float size; int handle; };
|
2002-03-01 06:47:28 +00:00
|
|
|
struct PropOut { SGPropertyNode* prop; int handle, type; bool left;
|
|
|
|
float min, max; };
|
2001-12-01 06:22:24 +00:00
|
|
|
|
2004-11-23 21:35:30 +00:00
|
|
|
void setOutputProperties(float dt);
|
2001-12-01 06:22:24 +00:00
|
|
|
|
2003-10-16 14:56:13 +00:00
|
|
|
Rotor* parseRotor(XMLAttributes* a, const char* name);
|
2001-12-01 06:22:24 +00:00
|
|
|
Wing* parseWing(XMLAttributes* a, const char* name);
|
|
|
|
int parseAxis(const char* name);
|
|
|
|
int parseOutput(const char* name);
|
|
|
|
void parseWeight(XMLAttributes* a);
|
2004-05-01 00:26:33 +00:00
|
|
|
void parseTurbineEngine(XMLAttributes* a);
|
|
|
|
void parsePistonEngine(XMLAttributes* a);
|
2001-12-01 06:22:24 +00:00
|
|
|
void parsePropeller(XMLAttributes* a);
|
|
|
|
bool eq(const char* a, const char* b);
|
2004-01-09 17:05:26 +00:00
|
|
|
bool caseeq(const char* a, const char* b);
|
2001-12-01 06:22:24 +00:00
|
|
|
char* dup(const char* s);
|
2008-04-13 21:12:36 +00:00
|
|
|
int attri(XMLAttributes* atts, const char* attr);
|
|
|
|
int attri(XMLAttributes* atts, const char* attr, int def);
|
|
|
|
float attrf(XMLAttributes* atts, const char* attr);
|
|
|
|
float attrf(XMLAttributes* atts, const char* attr, float def);
|
|
|
|
double attrd(XMLAttributes* atts, const char* attr);
|
|
|
|
double attrd(XMLAttributes* atts, const char* attr, double def);
|
|
|
|
bool attrb(XMLAttributes* atts, const char* attr);
|
2001-12-01 06:22:24 +00:00
|
|
|
|
|
|
|
// The core Airplane object we manage.
|
|
|
|
Airplane _airplane;
|
|
|
|
|
2004-01-09 17:05:26 +00:00
|
|
|
// Aerodynamic turbulence model
|
|
|
|
Turbulence* _turb;
|
|
|
|
|
2001-12-01 06:22:24 +00:00
|
|
|
// The list of "axes" that we expect to find as input. These are
|
|
|
|
// typically property names.
|
|
|
|
Vector _axes;
|
|
|
|
|
|
|
|
// Settable weights
|
|
|
|
Vector _weights;
|
|
|
|
|
|
|
|
// Engine types. Contains an EngRec structure.
|
2001-12-24 13:54:03 +00:00
|
|
|
Vector _thrusters;
|
2001-12-01 06:22:24 +00:00
|
|
|
|
2002-03-01 06:47:28 +00:00
|
|
|
// Output properties for the ControlMap
|
|
|
|
Vector _controlProps;
|
|
|
|
|
2005-02-17 10:26:14 +00:00
|
|
|
// Radius of the vehicle, for intersection testing.
|
|
|
|
float _vehicle_radius;
|
|
|
|
|
2001-12-01 06:22:24 +00:00
|
|
|
// Parsing temporaries
|
|
|
|
void* _currObj;
|
|
|
|
bool _cruiseCurr;
|
|
|
|
int _nextEngine;
|
2012-04-05 19:06:39 +00:00
|
|
|
|
|
|
|
class FuelProps
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
SGPropertyNode_ptr _out_of_fuel;
|
|
|
|
SGPropertyNode_ptr _fuel_consumed_lbs;
|
|
|
|
};
|
|
|
|
|
|
|
|
class ThrusterProps
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
SGPropertyNode_ptr _running, _cranking;
|
|
|
|
SGPropertyNode_ptr _prop_thrust, _thrust_lbs, _fuel_flow_gph;
|
|
|
|
SGPropertyNode_ptr _rpm, _torque_ftlb, _mp_osi, _mp_inhg;
|
|
|
|
SGPropertyNode_ptr _oil_temperature_degf, _boost_gauge_inhg;
|
|
|
|
SGPropertyNode_ptr _n1, _n2, _epr, _egt_degf;
|
|
|
|
};
|
|
|
|
|
|
|
|
SGPropertyNode_ptr _turb_magnitude_norm, _turb_rate_hz;
|
|
|
|
SGPropertyNode_ptr _gross_weight_lbs;
|
|
|
|
vector<SGPropertyNode_ptr> _tank_level_lbs;
|
|
|
|
vector<ThrusterProps> _thrust_props;
|
|
|
|
vector<FuelProps> _fuel_props;
|
2001-12-01 06:22:24 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}; // namespace yasim
|
|
|
|
#endif // _FGFDM_HPP
|