From: andy Date: Mon, 10 Jun 2002 20:15:35 +0000 (+0000) Subject: Really simple command line airplane compiler. Basically a test program; X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=df2b147ef532483bb8a4bf9448e4760a17ccb7ad;p=flightgear.git Really simple command line airplane compiler. Basically a test program; not integrated into the Makefile.am stuff. --- diff --git a/src/FDM/YASim/yasim-test.cpp b/src/FDM/YASim/yasim-test.cpp new file mode 100644 index 000000000..438d88b02 --- /dev/null +++ b/src/FDM/YASim/yasim-test.cpp @@ -0,0 +1,52 @@ +#include + +#include +#include + +#include "FGFDM.hpp" +#include "Airplane.hpp" + +using namespace yasim; + +// Stubs. Not needed by a batch program, but required to link. +bool fgSetFloat (const char * name, float val) { return false; } +bool fgSetBool(char const * name, bool val) { return false; } +SGPropertyNode* fgGetNode (const char * path, bool create) { return 0; } +float fgGetFloat (const char * name, float defaultValue) { return 0; } + +static const float RAD2DEG = 57.2957795131; + +int main(int argc, char** argv) +{ + FGFDM fdm; + Airplane* a = fdm.getAirplane(); + + // Read + try { + readXML(argv[1], fdm); + } catch (const sg_exception &e) { + printf("XML parse error: %s (%s)\n", + e.getFormattedMessage().c_str(), e.getOrigin().c_str()); + } + + // ... and run + a->compile(); + + float aoa = a->getCruiseAoA() * RAD2DEG; + float tail = -1 * a->getTailIncidence() * RAD2DEG; + float drag = 1000 * a->getDragCoefficient(); + float cg[3]; + a->getModel()->getBody()->getCG(cg); + + printf("Solution results:"); + printf(" Iterations: %d\n", a->getSolutionIterations()); + printf(" Drag Coefficient: %f\n", drag); + printf(" Lift Ratio: %f\n", a->getLiftRatio()); + printf(" Cruise AoA: %f\n", aoa); + printf(" Tail Incidence: %f\n", tail); + printf("Approach Elevator: %f\n", a->getApproachElevator()); + printf(" CG: %.1f, %.1f, %.1f\n", cg[0], cg[1], cg[2]); + + if(a->getFailureMsg()) + printf("SOLUTION FAILURE: %s\n", a->getFailureMsg()); +}