1
0
Fork 0
flightgear/src/Systems/static.cxx
ehofman 2c72f13163 Roy Vegard Ovesen:
We have decided that hardcoded initialization of instruments and systems is
bad. So we remove them.

Hardcoded initialization is bad because it can't be overridden from config
files or from the command line. We prefer to do it through config files that
should be, eventually, aircraft specific (*-set.xml), not global
(preferences.xml).
2004-11-13 15:00:00 +00:00

78 lines
1.8 KiB
C++

// 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>
#include <Main/util.hxx>
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 );
}
}
}
}
StaticSystem::StaticSystem ( int i )
{
name = "static";
num = i;
}
StaticSystem::~StaticSystem ()
{
}
void
StaticSystem::init ()
{
string branch;
branch = "/systems/" + name;
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);
}
void
StaticSystem::bind ()
{
}
void
StaticSystem::unbind ()
{
}
void
StaticSystem::update (double dt)
{
if (_serviceable_node->getBoolValue()) {
double target = _pressure_in_node->getDoubleValue();
double current = _pressure_out_node->getDoubleValue();
// double delta = target - current;
_pressure_out_node->setDoubleValue(fgGetLowPass(current, target, dt));
}
}
// end of static.cxx