FlightGear next
yasim-test.cpp File Reference
#include <stdio.h>
#include <cstring>
#include <cstdlib>
#include <simgear/props/props.hxx>
#include <simgear/xml/easyxml.hxx>
#include <simgear/misc/sg_path.hxx>
#include "yasim-common.hpp"
#include "FGFDM.hpp"
#include "Atmosphere.hpp"
#include "RigidBody.hpp"
#include "Airplane.hpp"

Go to the source code of this file.

Functions

bool fgSetFloat (const char *name, float val)
 Set a float value for a property.
 
bool fgSetBool (char const *name, bool val)
 Set a bool value for a property.
 
bool fgGetBool (char const *name, bool def)
 Get a bool value for a property.
 
bool fgSetString (char const *name, char const *str)
 Set a string value for a property.
 
SGPropertyNode * fgGetNode (const char *path, bool create)
 Get a property node.
 
SGPropertyNode * fgGetNode (const char *path, int i, bool create)
 Get a property node with separate index.
 
float fgGetFloat (const char *name, float defaultValue)
 Get a float value for a property.
 
double fgGetDouble (const char *name, double defaultValue=0.0)
 Get a double value for a property.
 
bool fgSetDouble (const char *name, double defaultValue=0.0)
 Set a double value for a property.
 
void _setup (Airplane *a, Airplane::Configuration cfgID, float altitude)
 
void _calculateAcceleration (Airplane *a, float aoa_rad, float speed_mps, float *output)
 
void yasim_graph (Airplane *a, const float alt, const float kts, Airplane::Configuration cfgID)
 
void yasim_masses (Airplane *a)
 
void yasim_drag (Airplane *a, const float aoa, const float alt, Airplane::Configuration cfgID)
 
float yasim_find_zero_lift_aoa (Airplane *a, const float alt, float kts, Airplane::Configuration cfgID, float *acc)
 
void yasim_best_speed_at_height (Airplane *a, const float alt, Airplane::Configuration cfgID, bool verbose, float &o_best_speed_kts, float &o_best_drag, float &o_best_aoa_deg)
 
void yasim_show_best_speed_at_heights (Airplane *a, Airplane::Configuration cfgID)
 
void findMinSpeed (Airplane *a, float alt)
 
void yasim_graph_detailed (Airplane *a, const float alt, const float kts, Airplane::Configuration cfgID)
 
void yasim_drag_detailed (Airplane *a, const float aoa, const float alt, Airplane::Configuration cfgID)
 
void findMinSpeedDetailed (Airplane *a, float alt)
 
void report (Airplane *a)
 
int usage ()
 
int main (int argc, char **argv)
 

Function Documentation

◆ _calculateAcceleration()

void _calculateAcceleration ( Airplane * a,
float aoa_rad,
float speed_mps,
float * output )

Definition at line 50 of file yasim-test.cpp.

◆ _setup()

void _setup ( Airplane * a,
Airplane::Configuration cfgID,
float altitude )

Definition at line 31 of file yasim-test.cpp.

◆ fgGetBool()

bool fgGetBool ( const char * name,
bool defaultValue = false )

Get a bool value for a property.

This method is convenient but inefficient. It should be used infrequently (i.e. for initializing, loading, saving, etc.), not in the main loop. If you need to get a value frequently, it is better to look up the node itself using fgGetNode and then use the node's getBoolValue() method, to avoid the lookup overhead.

Parameters
nameThe property name.
defaultValueThe default value to return if the property does not exist.
Returns
The property's value as a bool, or the default value provided.

Definition at line 22 of file yasim-test.cpp.

◆ fgGetDouble()

double fgGetDouble ( const char * name,
double defaultValue = 0.0 )

Get a double value for a property.

This method is convenient but inefficient. It should be used infrequently (i.e. for initializing, loading, saving, etc.), not in the main loop. If you need to get a value frequently, it is better to look up the node itself using fgGetNode and then use the node's getDoubleValue() method, to avoid the lookup overhead.

Parameters
nameThe property name.
defaultValueThe default value to return if the property does not exist.
Returns
The property's value as a double, or the default value provided.

Definition at line 27 of file yasim-test.cpp.

◆ fgGetFloat()

float fgGetFloat ( const char * name,
float defaultValue = 0.0 )

Get a float value for a property.

This method is convenient but inefficient. It should be used infrequently (i.e. for initializing, loading, saving, etc.), not in the main loop. If you need to get a value frequently, it is better to look up the node itself using fgGetNode and then use the node's getFloatValue() method, to avoid the lookup overhead.

Parameters
nameThe property name.
defaultValueThe default value to return if the property does not exist.
Returns
The property's value as a float, or the default value provided.

Definition at line 26 of file yasim-test.cpp.

◆ fgGetNode() [1/2]

SGPropertyNode * fgGetNode ( const char * path,
bool create = false )

Get a property node.

Parameters
pathThe path of the node, relative to root.
createtrue to create the node if it doesn't exist.
Returns
The node, or 0 if none exists and none was created.

Definition at line 24 of file yasim-test.cpp.

◆ fgGetNode() [2/2]

SGPropertyNode * fgGetNode ( const char * path,
int index,
bool create = false )

Get a property node with separate index.

This method separates the index from the path string, to make it easier to iterate through multiple components without using sprintf to add indices. For example, fgGetNode("foo[1]/bar", 3) will return the same result as fgGetNode("foo[1]/bar[3]").

Parameters
pathThe path of the node, relative to root.
indexThe index for the last member of the path (overrides any given in the string).
createtrue to create the node if it doesn't exist.
Returns
The node, or 0 if none exists and none was created.

Definition at line 25 of file yasim-test.cpp.

◆ fgSetBool()

bool fgSetBool ( const char * name,
bool val )

Set a bool value for a property.

Assign a bool value to a property. If the property does not yet exist, it will be created and its type will be set to BOOL; if it has a type of UNKNOWN, the type will also be set to BOOL; otherwise, the bool value will be converted to the property's type.

Parameters
nameThe property name.
valThe new value for the property.
Returns
true if the assignment succeeded, false otherwise.

Definition at line 21 of file yasim-test.cpp.

◆ fgSetDouble()

bool fgSetDouble ( const char * name,
double val )

Set a double value for a property.

Assign a double value to a property. If the property does not yet exist, it will be created and its type will be set to DOUBLE; if it has a type of UNKNOWN, the type will also be set to DOUBLE; otherwise, the double value will be converted to the property's type.

Parameters
nameThe property name.
valThe new value for the property.
Returns
true if the assignment succeeded, false otherwise.

Definition at line 28 of file yasim-test.cpp.

◆ fgSetFloat()

bool fgSetFloat ( const char * name,
float val )

Set a float value for a property.

Assign a float value to a property. If the property does not yet exist, it will be created and its type will be set to FLOAT; if it has a type of UNKNOWN, the type will also be set to FLOAT; otherwise, the bool value will be converted to the property's type.

Parameters
nameThe property name.
valThe new value for the property.
Returns
true if the assignment succeeded, false otherwise.

Definition at line 20 of file yasim-test.cpp.

◆ fgSetString()

bool fgSetString ( const char * name,
const char * val )

Set a string value for a property.

Assign a string value to a property. If the property does not yet exist, it will be created and its type will be set to STRING; if it has a type of UNKNOWN, the type will also be set to STRING; otherwise, the string value will be converted to the property's type.

Parameters
nameThe property name.
valThe new value for the property.
Returns
true if the assignment succeeded, false otherwise.

Definition at line 23 of file yasim-test.cpp.

◆ findMinSpeed()

void findMinSpeed ( Airplane * a,
float alt )

Definition at line 221 of file yasim-test.cpp.

◆ findMinSpeedDetailed()

void findMinSpeedDetailed ( Airplane * a,
float alt )

Definition at line 309 of file yasim-test.cpp.

◆ main()

int main ( int argc,
char ** argv )

Definition at line 421 of file yasim-test.cpp.

◆ report()

void report ( Airplane * a)

Definition at line 329 of file yasim-test.cpp.

◆ usage()

int usage ( )

Definition at line 398 of file yasim-test.cpp.

◆ yasim_best_speed_at_height()

void yasim_best_speed_at_height ( Airplane * a,
const float alt,
Airplane::Configuration cfgID,
bool verbose,
float & o_best_speed_kts,
float & o_best_drag,
float & o_best_aoa_deg )

Definition at line 169 of file yasim-test.cpp.

◆ yasim_drag()

void yasim_drag ( Airplane * a,
const float aoa,
const float alt,
Airplane::Configuration cfgID )

Definition at line 127 of file yasim-test.cpp.

◆ yasim_drag_detailed()

void yasim_drag_detailed ( Airplane * a,
const float aoa,
const float alt,
Airplane::Configuration cfgID )

Definition at line 288 of file yasim-test.cpp.

◆ yasim_find_zero_lift_aoa()

float yasim_find_zero_lift_aoa ( Airplane * a,
const float alt,
float kts,
Airplane::Configuration cfgID,
float * acc )

Definition at line 149 of file yasim-test.cpp.

◆ yasim_graph()

void yasim_graph ( Airplane * a,
const float alt,
const float kts,
Airplane::Configuration cfgID )

Definition at line 75 of file yasim-test.cpp.

◆ yasim_graph_detailed()

void yasim_graph_detailed ( Airplane * a,
const float alt,
const float kts,
Airplane::Configuration cfgID )

Definition at line 253 of file yasim-test.cpp.

◆ yasim_masses()

void yasim_masses ( Airplane * a)

Definition at line 110 of file yasim-test.cpp.

◆ yasim_show_best_speed_at_heights()

void yasim_show_best_speed_at_heights ( Airplane * a,
Airplane::Configuration cfgID )

Definition at line 204 of file yasim-test.cpp.