2003-01-25 21:13:13 +00:00
|
|
|
// slip_skid_ball.cxx - an electric-powered turn indicator.
|
|
|
|
// Written by David Megginson, started 2003.
|
|
|
|
//
|
|
|
|
// This file is in the Public Domain and comes with no warranty.
|
|
|
|
|
|
|
|
#include "slip_skid_ball.hxx"
|
|
|
|
#include <Main/fg_props.hxx>
|
|
|
|
#include <Main/util.hxx>
|
|
|
|
|
|
|
|
|
2004-10-16 12:37:39 +00:00
|
|
|
SlipSkidBall::SlipSkidBall ( SGPropertyNode *node)
|
|
|
|
:
|
2006-12-06 22:11:43 +00:00
|
|
|
_name(node->getStringValue("name", "slip-skid-ball")),
|
|
|
|
_num(node->getIntValue("number", 0))
|
2003-01-25 21:13:13 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
SlipSkidBall::~SlipSkidBall ()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SlipSkidBall::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);
|
2003-01-26 15:56:11 +00:00
|
|
|
_y_accel_node = fgGetNode("/accelerations/pilot/y-accel-fps_sec", true);
|
|
|
|
_z_accel_node = fgGetNode("/accelerations/pilot/z-accel-fps_sec", true);
|
2004-10-16 12:37:39 +00:00
|
|
|
_out_node = node->getChild("indicated-slip-skid", 0, true);
|
2005-06-17 19:42:25 +00:00
|
|
|
_override_node = node->getChild("override", 0, true);
|
2003-01-25 21:13:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2003-01-26 15:56:11 +00:00
|
|
|
SlipSkidBall::update (double delta_time_sec)
|
2003-01-25 21:13:13 +00:00
|
|
|
{
|
2003-11-10 21:57:14 +00:00
|
|
|
if (_serviceable_node->getBoolValue() && !_override_node->getBoolValue()) {
|
2003-01-26 15:56:11 +00:00
|
|
|
double d = -_z_accel_node->getDoubleValue();
|
|
|
|
if (d < 1.0)
|
|
|
|
d = 1.0;
|
2003-07-01 21:22:01 +00:00
|
|
|
double pos = _y_accel_node->getDoubleValue() / d * 10.0;
|
2003-01-26 15:56:11 +00:00
|
|
|
pos = fgGetLowPass(_out_node->getDoubleValue(), pos, delta_time_sec);
|
|
|
|
_out_node->setDoubleValue(pos);
|
|
|
|
}
|
2003-01-25 21:13:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// end of slip_skid_ball.cxx
|