FlightGear next
slip_skid_ball.cxx
Go to the documentation of this file.
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#ifdef HAVE_CONFIG_H
7# include "config.h"
8#endif
9
10#include "slip_skid_ball.hxx"
11#include <Main/fg_props.hxx>
12#include <Main/util.hxx>
13
14using std::string;
15
16SlipSkidBall::SlipSkidBall ( SGPropertyNode *node)
17 :
18 _name(node->getStringValue("name", "slip-skid-ball")),
19 _num(node->getIntValue("number", 0))
20{
21}
22
26
27void
29{
30 string branch;
31 branch = "/instrumentation/" + _name;
32
33 SGPropertyNode *node = fgGetNode(branch, _num, true );
34 _serviceable_node = node->getChild("serviceable", 0, true);
35 _y_accel_node = fgGetNode("/accelerations/pilot/y-accel-fps_sec", true);
36 _z_accel_node = fgGetNode("/accelerations/pilot/z-accel-fps_sec", true);
37 _out_node = node->getChild("indicated-slip-skid", 0, true);
38 _override_node = node->getChild("override", 0, true);
39
40 reinit();
41}
42
43void
45{
46 _out_node->setDoubleValue(0.0);
47}
48
49void
50SlipSkidBall::update (double delta_time_sec)
51{
52 if (_serviceable_node->getBoolValue() && !_override_node->getBoolValue()) {
53 double d = -_z_accel_node->getDoubleValue();
54 if (d < 1.0)
55 d = 1.0;
56 double pos = _y_accel_node->getDoubleValue() / d * 10.0;
57 pos = fgGetLowPass(_out_node->getDoubleValue(), pos, delta_time_sec);
58 _out_node->setDoubleValue(pos);
59 }
60}
61
62
63// Register the subsystem.
64#if 0
65SGSubsystemMgr::InstancedRegistrant<SlipSkidBall> registrantSlipSkidBall(
66 SGSubsystemMgr::FDM,
67 {{"instrumentation", SGSubsystemMgr::Dependency::HARD}},
68 0.03);
69#endif
70
71// end of slip_skid_ball.cxx
void update(double dt) override
void reinit() override
void init() override
SlipSkidBall(SGPropertyNode *node)
virtual ~SlipSkidBall()
SGPropertyNode * fgGetNode(const char *path, bool create)
Get a property node.
Definition proptest.cpp:27
double fgGetLowPass(double current, double target, double timeratio)
Move a value towards a target.
Definition util.cxx:46