X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FInstrumentation%2Fturn_indicator.cxx;h=973b4054aad99d6f46df5edf915ace15cf5f8536;hb=bb2b03c7e392e107aeaf7dbc4eecc59064b28512;hp=5e052397452e7b59f98922f185b2f5869b01c0d6;hpb=677c3e3e9ab9598c40a23cc89f99235d618b3a6f;p=flightgear.git diff --git a/src/Instrumentation/turn_indicator.cxx b/src/Instrumentation/turn_indicator.cxx index 5e0523974..973b4054a 100644 --- a/src/Instrumentation/turn_indicator.cxx +++ b/src/Instrumentation/turn_indicator.cxx @@ -3,12 +3,25 @@ // // This file is in the Public Domain and comes with no warranty. +#include +#include +#include +#include + #include "turn_indicator.hxx" #include
#include
-TurnIndicator::TurnIndicator () +// Use a bigger number to be more responsive, or a smaller number +// to be more sluggish. +#define RESPONSIVENESS 0.5 + + +TurnIndicator::TurnIndicator ( SGPropertyNode *node) : + _last_rate(0), + _name(node->getStringValue("name", "turn-indicator")), + _num(node->getIntValue("number", 0)) { } @@ -19,35 +32,49 @@ TurnIndicator::~TurnIndicator () void TurnIndicator::init () { + string branch; + branch = "/instrumentation/" + _name; + + SGPropertyNode *node = fgGetNode(branch.c_str(), _num, true ); _roll_rate_node = fgGetNode("/orientation/roll-rate-degps", true); _yaw_rate_node = fgGetNode("/orientation/yaw-rate-degps", true); _electric_current_node = fgGetNode("/systems/electrical/outputs/turn-coordinator", true); - _rate_out_node = - fgGetNode("/instrumentation/turn-indicator/indicated-turn-rate", true); + _rate_out_node = node->getChild("indicated-turn-rate", 0, true); } void TurnIndicator::bind () { - fgTie("/instrumentation/turn-indicator/serviceable", - &_gyro, &Gyro::is_serviceable); - fgTie("/instrumentation/turn-indicator/spin", + std::ostringstream temp; + string branch; + temp << _num; + branch = "/instrumentation/" + _name + "[" + temp.str() + "]"; + + fgTie((branch + "/serviceable").c_str(), + &_gyro, &Gyro::is_serviceable, &Gyro::set_serviceable); + fgTie((branch + "/spin").c_str(), &_gyro, &Gyro::get_spin_norm, &Gyro::set_spin_norm); } void TurnIndicator::unbind () { - fgUntie("/instrumentation/turn-indicator/serviceable"); - fgUntie("/instrumentation/turn-indicator/spin"); + std::ostringstream temp; + string branch; + temp << _num; + branch = "/instrumentation/" + _name + "[" + temp.str() + "]"; + + fgUntie((branch + "/serviceable").c_str()); + fgUntie((branch + "/serviceable").c_str()); } void TurnIndicator::update (double dt) { // Get the spin from the gyro - _gyro.set_power_norm(_electric_current_node->getDoubleValue()/60.0); + double power = _electric_current_node->getDoubleValue() / 12.0; + _gyro.set_power_norm(power); _gyro.update(dt); double spin = _gyro.get_spin_norm(); @@ -62,8 +89,9 @@ TurnIndicator::update (double dt) else if (rate > 2.5) rate = 2.5; - // Add a lag, based on gyro spin - rate = fgGetLowPass(_last_rate, rate, dt/(factor*3)); + // Lag left, based on gyro spin + rate = -2.5 + (factor * (rate + 2.5)); + rate = fgGetLowPass(_last_rate, rate, dt*RESPONSIVENESS); _last_rate = rate; // Publish the indicated rate