X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FSystems%2Fpitot.cxx;h=535caa09db89e5af9d2e40e0e9ccb7af8659f27f;hb=c5366cceb6d345d3526ab013b04eb815fe0a6845;hp=71b27fc7a05a3884938a6f8e95ef592635023090;hpb=f614545fc5a6f0fb12a05344d9ee41b2a49cc04a;p=flightgear.git diff --git a/src/Systems/pitot.cxx b/src/Systems/pitot.cxx index 71b27fc7a..535caa09d 100644 --- a/src/Systems/pitot.cxx +++ b/src/Systems/pitot.cxx @@ -3,39 +3,19 @@ // // This file is in the Public Domain and comes with no warranty. -#include "pitot.hxx" +#include + #include
#include
+#include "pitot.hxx" PitotSystem::PitotSystem ( SGPropertyNode *node ) : - name("pitot"), - num(0) -{ - int i; - for ( i = 0; i < node->nChildren(); ++i ) { - SGPropertyNode *child = node->getChild(i); - string cname = child->getName(); - string cval = child->getStringValue(); - if ( cname == "name" ) { - name = cval; - } else if ( cname == "number" ) { - num = child->getIntValue(); - } else { - SG_LOG( SG_AUTOPILOT, SG_WARN, "Error in systems config logic" ); - if ( name.length() ) { - SG_LOG( SG_AUTOPILOT, SG_WARN, "Section = " << name ); - } - } - } -} - -PitotSystem::PitotSystem ( int i ) + _name(node->getStringValue("name", "pitot")), + _num(node->getIntValue("number", 0)) { - num = i; - name = "pitot"; } PitotSystem::~PitotSystem () @@ -46,16 +26,15 @@ void PitotSystem::init () { string branch; - branch = "/systems/" + name; + branch = "/systems/" + _name; - SGPropertyNode *node = fgGetNode(branch.c_str(), num, true ); + SGPropertyNode *node = fgGetNode(branch.c_str(), _num, true ); _serviceable_node = node->getChild("serviceable", 0, true); _pressure_node = fgGetNode("/environment/pressure-inhg", true); _density_node = fgGetNode("/environment/density-slugft3", true); _velocity_node = fgGetNode("/velocities/airspeed-kt", true); + _slip_angle = fgGetNode("/orientation/side-slip-rad", true); _total_pressure_node = node->getChild("total-pressure-inhg", 0, true); - - _serviceable_node->setBoolValue(true); } void @@ -76,10 +55,6 @@ PitotSystem::unbind () # define PSFTOINHG (1/INHGTOPSF) #endif -#ifndef KTTOFPS -# define KTTOFPS 1.68781 -#endif - void PitotSystem::update (double dt) @@ -89,7 +64,10 @@ PitotSystem::update (double dt) // velocity in the body axis. double p = _pressure_node->getDoubleValue() * INHGTOPSF; double r = _density_node->getDoubleValue(); - double v = _velocity_node->getDoubleValue() * KTTOFPS; + double v = _velocity_node->getDoubleValue() * SG_KT_TO_FPS; + v *= cos(_slip_angle->getDoubleValue()); + if (v < 0.0) + v = 0.0; double q = 0.5 * r * v * v; // dynamic _total_pressure_node->setDoubleValue((p + q) * PSFTOINHG); }