X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FSystems%2Fstatic.cxx;h=f58d1ce3cd457a675caa914515a2eaef4bf0a4b0;hb=81cd33e2fa9b5930784d3aed920eea0e3038e7f7;hp=59111d32233a4c4e3d6903748c1920867e31a710;hpb=0ab2a40c2a2c75d117744f63a1bd74ccc7ea3a4e;p=flightgear.git diff --git a/src/Systems/static.cxx b/src/Systems/static.cxx index 59111d322..f58d1ce3c 100644 --- a/src/Systems/static.cxx +++ b/src/Systems/static.cxx @@ -3,38 +3,25 @@ // // This file is in the Public Domain and comes with no warranty. +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + #include "static.hxx" + +#include + #include
#include
StaticSystem::StaticSystem ( SGPropertyNode *node ) : - name("static"), - 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_SYSTEMS, SG_WARN, "Error in systems config logic" ); - if ( name.length() ) { - SG_LOG( SG_SYSTEMS, SG_WARN, "Section = " << name ); - } - } - } -} + _name(node->getStringValue("name", "static")), + _num(node->getIntValue("number", 0)), + _tau(node->getDoubleValue("tau", 1)) -StaticSystem::StaticSystem ( int i ) { - name = "static"; - num = i; } StaticSystem::~StaticSystem () @@ -44,15 +31,21 @@ StaticSystem::~StaticSystem () void StaticSystem::init () { - string branch; - branch = "/systems/" + name; + std::string 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_in_node = fgGetNode("/environment/pressure-inhg", true); _pressure_out_node = node->getChild("pressure-inhg", 0, true); - _serviceable_node->setBoolValue(true); + reinit(); +} + +void +StaticSystem::reinit () +{ + // start with settled static pressure + _pressure_out_node->setDoubleValue(_pressure_in_node->getDoubleValue()); } void @@ -69,11 +62,10 @@ void StaticSystem::update (double dt) { if (_serviceable_node->getBoolValue()) { - + double trat = _tau ? dt/_tau : 100; double target = _pressure_in_node->getDoubleValue(); double current = _pressure_out_node->getDoubleValue(); - // double delta = target - current; - _pressure_out_node->setDoubleValue(fgGetLowPass(current, target, dt)); + _pressure_out_node->setDoubleValue(fgGetLowPass(current, target, trat)); } }