2002-09-27 22:03:48 +00:00
|
|
|
// vertical_speed_indicator.cxx - a regular VSI.
|
|
|
|
// Written by David Megginson, started 2002.
|
|
|
|
//
|
|
|
|
// This file is in the Public Domain and comes with no warranty.
|
|
|
|
|
|
|
|
#include <simgear/math/interpolater.hxx>
|
|
|
|
|
|
|
|
#include "vertical_speed_indicator.hxx"
|
|
|
|
#include <Main/fg_props.hxx>
|
|
|
|
#include <Main/util.hxx>
|
|
|
|
|
|
|
|
|
2004-10-16 12:37:39 +00:00
|
|
|
VerticalSpeedIndicator::VerticalSpeedIndicator ( SGPropertyNode *node )
|
|
|
|
: _internal_pressure_inhg(29.92),
|
2006-12-06 22:11:43 +00:00
|
|
|
_name(node->getStringValue("name", "vertical-speed-indicator")),
|
|
|
|
_num(node->getIntValue("number", 0)),
|
|
|
|
_static_pressure(node->getStringValue("static-pressure", "/Systems/static/pressure-inhg"))
|
2002-09-27 22:03:48 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
VerticalSpeedIndicator::~VerticalSpeedIndicator ()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
VerticalSpeedIndicator::init ()
|
|
|
|
{
|
2004-10-16 12:37:39 +00:00
|
|
|
string branch;
|
2006-12-06 22:11:43 +00:00
|
|
|
branch = "/instrumentation/" + _name;
|
2004-10-16 12:37:39 +00:00
|
|
|
|
2006-12-06 22:11:43 +00:00
|
|
|
SGPropertyNode *node = fgGetNode(branch.c_str(), _num, true );
|
2004-10-16 12:37:39 +00:00
|
|
|
_serviceable_node = node->getChild("serviceable", 0, true);
|
2006-12-06 22:11:43 +00:00
|
|
|
_pressure_node = fgGetNode(_static_pressure.c_str(), true);
|
2004-10-16 12:37:39 +00:00
|
|
|
_speed_node = node->getChild("indicated-speed-fpm", 0, true);
|
2003-02-25 20:04:22 +00:00
|
|
|
|
|
|
|
// Initialize at ambient pressure
|
|
|
|
_internal_pressure_inhg = _pressure_node->getDoubleValue();
|
2002-09-27 22:03:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
VerticalSpeedIndicator::update (double dt)
|
|
|
|
{
|
2003-01-29 15:30:29 +00:00
|
|
|
// model taken from steam.cxx, with change
|
2002-09-27 22:03:48 +00:00
|
|
|
// from 10000 to 10500 for manual factor
|
|
|
|
if (_serviceable_node->getBoolValue()) {
|
|
|
|
double pressure = _pressure_node->getDoubleValue();
|
|
|
|
_speed_node
|
|
|
|
->setDoubleValue((_internal_pressure_inhg - pressure) * 10500);
|
|
|
|
_internal_pressure_inhg =
|
|
|
|
fgGetLowPass(_internal_pressure_inhg,
|
|
|
|
_pressure_node->getDoubleValue(),
|
|
|
|
dt/6.0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// end of vertical_speed_indicator.cxx
|