X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FInstrumentation%2Fturn_indicator.cxx;h=124186c1fec5537385a8d1559ead506238749f20;hb=010e03fab49219813f2957b0e494672d01d62ff4;hp=6cdaef9dc18cf15326df7a1a9399d5a7c3a92f73;hpb=7470eadbe7600e18f22845b74b38b1ec7f57438c;p=flightgear.git diff --git a/src/Instrumentation/turn_indicator.cxx b/src/Instrumentation/turn_indicator.cxx index 6cdaef9dc..124186c1f 100644 --- a/src/Instrumentation/turn_indicator.cxx +++ b/src/Instrumentation/turn_indicator.cxx @@ -3,17 +3,46 @@ // // This file is in the Public Domain and comes with no warranty. +#include +#include STL_IOSTREAM +#include STL_STRING +#include + #include "turn_indicator.hxx" #include
#include
// Use a bigger number to be more responsive, or a smaller number -// to be more sluggish (the base time is 1.0). -#define RESPONSIVENESS 0.25 +// to be more sluggish. +#define RESPONSIVENESS 0.5 + +TurnIndicator::TurnIndicator ( SGPropertyNode *node) : + _last_rate(0), + name("turn-indicator"), + num(0) +{ + int i; + for ( i = 0; i < node->nChildren(); ++i ) { + SGPropertyNode *child = node->getChild(i); + string cname = child->getName(); + string cval = child->getStringValue(); + if ( cname == "name" ) { + name = cval; + } else if ( cname == "number" ) { + num = child->getIntValue(); + } else { + SG_LOG( SG_INSTR, SG_WARN, "Error in turn-indicator config logic" ); + if ( name.length() ) { + SG_LOG( SG_INSTR, SG_WARN, "Section = " << name ); + } + } + } +} -TurnIndicator::TurnIndicator () +TurnIndicator::TurnIndicator () : + _last_rate(0) { } @@ -24,35 +53,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", + 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("/instrumentation/turn-indicator/spin", + 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();