]> git.mxchange.org Git - flightgear.git/blob - src/FDM/YASim/yasim-test.cpp
Add support for a turbo prop condition lever.
[flightgear.git] / src / FDM / YASim / yasim-test.cpp
1 #include <stdio.h>
2
3 #include <simgear/props/props.hxx>
4 #include <simgear/xml/easyxml.hxx>
5
6 #include "FGFDM.hpp"
7 #include "Airplane.hpp"
8
9 using namespace yasim;
10
11 // Stubs.  Not needed by a batch program, but required to link.
12 bool fgSetFloat (const char * name, float val) { return false; }
13 bool fgSetBool(char const * name, bool val) { return false; }
14 bool fgGetBool(char const * name, bool def) { return false; }
15 SGPropertyNode* fgGetNode (const char * path, bool create) { return 0; }
16 SGPropertyNode* fgGetNode (const char * path, int i, bool create) { return 0; }
17 float fgGetFloat (const char * name, float defaultValue) { return 0; }
18 float fgGetDouble (const char * name, double defaultValue) { return 0; }
19 float fgSetDouble (const char * name, double defaultValue) { return 0; }
20
21 static const float RAD2DEG = 57.2957795131;
22
23 int main(int argc, char** argv)
24 {
25     FGFDM fdm;
26     Airplane* a = fdm.getAirplane();
27
28     // Read
29     try {
30         readXML(argv[1], fdm);
31     } catch (const sg_exception &e) {
32         printf("XML parse error: %s (%s)\n",
33                e.getFormattedMessage().c_str(), e.getOrigin().c_str());
34     }
35
36     // ... and run
37     a->compile();
38
39     float aoa = a->getCruiseAoA() * RAD2DEG;
40     float tail = -1 * a->getTailIncidence() * RAD2DEG;
41     float drag = 1000 * a->getDragCoefficient();
42     float cg[3];
43     a->getModel()->getBody()->getCG(cg);
44
45     printf("Solution results:");
46     printf("       Iterations: %d\n", a->getSolutionIterations());
47     printf(" Drag Coefficient: %f\n", drag);
48     printf("       Lift Ratio: %f\n", a->getLiftRatio());
49     printf("       Cruise AoA: %f\n", aoa);
50     printf("   Tail Incidence: %f\n", tail);
51     printf("Approach Elevator: %f\n", a->getApproachElevator());
52     printf("               CG: %.3f, %.3f, %.3f\n", cg[0], cg[1], cg[2]);
53
54     if(a->getFailureMsg())
55         printf("SOLUTION FAILURE: %s\n", a->getFailureMsg());
56 }