]> git.mxchange.org Git - flightgear.git/blob - src/Instrumentation/slip_skid_ball.cxx
Roy Vegard Ovesen:
[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
11 SlipSkidBall::SlipSkidBall ( SGPropertyNode *node)
12     :
13     name("slip-skid-ball"),
14     num(0)
15 {
16     int i;
17     for ( i = 0; i < node->nChildren(); ++i ) {
18         SGPropertyNode *child = node->getChild(i);
19         string cname = child->getName();
20         string cval = child->getStringValue();
21         if ( cname == "name" ) {
22             name = cval;
23         } else if ( cname == "number" ) {
24             num = child->getIntValue();
25         } else {
26             SG_LOG( SG_INSTR, SG_WARN, "Error in slip-skid-ball config logic" );
27             if ( name.length() ) {
28                 SG_LOG( SG_INSTR, SG_WARN, "Section = " << name );
29             }
30         }
31     }
32 }
33
34 SlipSkidBall::SlipSkidBall ()
35 {
36 }
37
38 SlipSkidBall::~SlipSkidBall ()
39 {
40 }
41
42 void
43 SlipSkidBall::init ()
44 {
45     string branch;
46     branch = "/instrumentation/" + name;
47
48     SGPropertyNode *node = fgGetNode(branch.c_str(), num, true );
49     _serviceable_node = node->getChild("serviceable", 0, true);
50     _y_accel_node = fgGetNode("/accelerations/pilot/y-accel-fps_sec", true);
51     _z_accel_node = fgGetNode("/accelerations/pilot/z-accel-fps_sec", true);
52     _out_node = node->getChild("indicated-slip-skid", 0, true);
53     _override_node = node->getChild("iverride", 0, true);
54
55     _serviceable_node->setBoolValue(true);
56 }
57
58 void
59 SlipSkidBall::update (double delta_time_sec)
60 {
61     if (_serviceable_node->getBoolValue() && !_override_node->getBoolValue()) {
62         double d = -_z_accel_node->getDoubleValue();
63         if (d < 1.0)
64             d = 1.0;
65         double pos = _y_accel_node->getDoubleValue() / d * 10.0;
66         pos = fgGetLowPass(_out_node->getDoubleValue(), pos, delta_time_sec);
67         _out_node->setDoubleValue(pos);
68     }
69 }
70
71 // end of slip_skid_ball.cxx