2002-09-27 18:27:58 +00:00
|
|
|
// static.cxx - the static air system.
|
|
|
|
// Written by David Megginson, started 2002.
|
|
|
|
//
|
|
|
|
// This file is in the Public Domain and comes with no warranty.
|
|
|
|
|
|
|
|
#include "static.hxx"
|
|
|
|
#include <Main/fg_props.hxx>
|
2002-09-27 22:04:21 +00:00
|
|
|
#include <Main/util.hxx>
|
2002-09-27 18:27:58 +00:00
|
|
|
|
|
|
|
|
2004-10-16 12:37:39 +00:00
|
|
|
StaticSystem::StaticSystem ( SGPropertyNode *node )
|
|
|
|
:
|
|
|
|
name("static"),
|
|
|
|
num(0)
|
2002-09-27 18:27:58 +00:00
|
|
|
{
|
2004-10-16 12:37:39 +00:00
|
|
|
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 {
|
2004-10-24 11:05:14 +00:00
|
|
|
SG_LOG( SG_SYSTEMS, SG_WARN, "Error in systems config logic" );
|
2004-10-16 12:37:39 +00:00
|
|
|
if ( name.length() ) {
|
2004-10-24 11:05:14 +00:00
|
|
|
SG_LOG( SG_SYSTEMS, SG_WARN, "Section = " << name );
|
2004-10-16 12:37:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StaticSystem::StaticSystem ( int i )
|
|
|
|
{
|
|
|
|
name = "static";
|
|
|
|
num = i;
|
2002-09-27 18:27:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
StaticSystem::~StaticSystem ()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
StaticSystem::init ()
|
|
|
|
{
|
2004-10-16 12:37:39 +00:00
|
|
|
string branch;
|
|
|
|
branch = "/systems/" + name;
|
|
|
|
|
|
|
|
SGPropertyNode *node = fgGetNode(branch.c_str(), num, true );
|
|
|
|
_serviceable_node = node->getChild("serviceable", 0, true);
|
2002-09-27 18:27:58 +00:00
|
|
|
_pressure_in_node = fgGetNode("/environment/pressure-inhg", true);
|
2004-10-16 12:37:39 +00:00
|
|
|
_pressure_out_node = node->getChild("pressure-inhg", 0, true);
|
2002-09-27 18:27:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
StaticSystem::bind ()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
StaticSystem::unbind ()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
StaticSystem::update (double dt)
|
|
|
|
{
|
|
|
|
if (_serviceable_node->getBoolValue()) {
|
2002-09-27 22:04:21 +00:00
|
|
|
|
2002-09-27 18:27:58 +00:00
|
|
|
double target = _pressure_in_node->getDoubleValue();
|
|
|
|
double current = _pressure_out_node->getDoubleValue();
|
2004-04-01 15:27:53 +00:00
|
|
|
// double delta = target - current;
|
2002-09-27 22:04:21 +00:00
|
|
|
_pressure_out_node->setDoubleValue(fgGetLowPass(current, target, dt));
|
2002-09-27 18:27:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// end of static.cxx
|