]> git.mxchange.org Git - flightgear.git/blob - src/Instrumentation/slip_skid_ball.cxx
Fix (nearly) all the std:: namespace violations in headers, in preparation for fixing...
[flightgear.git] / src / Instrumentation / slip_skid_ball.cxx
1 // slip_skid_ball.cxx - an electric-powered turn indicator.
2 // Written by David Megginson, started 2003.
3 //
4 // This file is in the Public Domain and comes with no warranty.
5
6 #include "slip_skid_ball.hxx"
7 #include <Main/fg_props.hxx>
8 #include <Main/util.hxx>
9
10 using std::string;
11
12 SlipSkidBall::SlipSkidBall ( SGPropertyNode *node)
13     :
14     _name(node->getStringValue("name", "slip-skid-ball")),
15     _num(node->getIntValue("number", 0))
16 {
17 }
18
19 SlipSkidBall::~SlipSkidBall ()
20 {
21 }
22
23 void
24 SlipSkidBall::init ()
25 {
26     string branch;
27     branch = "/instrumentation/" + _name;
28
29     SGPropertyNode *node = fgGetNode(branch.c_str(), _num, true );
30     _serviceable_node = node->getChild("serviceable", 0, true);
31     _y_accel_node = fgGetNode("/accelerations/pilot/y-accel-fps_sec", true);
32     _z_accel_node = fgGetNode("/accelerations/pilot/z-accel-fps_sec", true);
33     _out_node = node->getChild("indicated-slip-skid", 0, true);
34     _override_node = node->getChild("override", 0, true);
35 }
36
37 void
38 SlipSkidBall::update (double delta_time_sec)
39 {
40     if (_serviceable_node->getBoolValue() && !_override_node->getBoolValue()) {
41         double d = -_z_accel_node->getDoubleValue();
42         if (d < 1.0)
43             d = 1.0;
44         double pos = _y_accel_node->getDoubleValue() / d * 10.0;
45         pos = fgGetLowPass(_out_node->getDoubleValue(), pos, delta_time_sec);
46         _out_node->setDoubleValue(pos);
47     }
48 }
49
50 // end of slip_skid_ball.cxx