X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FInstrumentation%2Fturn_indicator.cxx;h=06fd868e2ba8f313b10b35efe54f581fd64c74b6;hb=f04d5f8758ef4b5524a9396a84351bf86db6763e;hp=be03a8879beadb07fe2cc294ec788c604831da82;hpb=e9b70e3ab8ab098a5a59f5ea2c13bed9e8c5695c;p=flightgear.git diff --git a/src/Instrumentation/turn_indicator.cxx b/src/Instrumentation/turn_indicator.cxx index be03a8879..06fd868e2 100644 --- a/src/Instrumentation/turn_indicator.cxx +++ b/src/Instrumentation/turn_indicator.cxx @@ -3,15 +3,20 @@ // // This file is in the Public Domain and comes with no warranty. +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + #include -#include STL_IOSTREAM -#include STL_STRING +#include +#include #include #include "turn_indicator.hxx" #include
#include
+using std::string; // Use a bigger number to be more responsive, or a smaller number // to be more sluggish. @@ -20,29 +25,8 @@ 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 () : - _last_rate(0) + _name(node->getStringValue("name", "turn-indicator")), + _num(node->getIntValue("number", 0)) { } @@ -54,14 +38,23 @@ void TurnIndicator::init () { string branch; - branch = "/instrumentation/" + name; + branch = "/instrumentation/" + _name; - SGPropertyNode *node = fgGetNode(branch.c_str(), num, true ); + 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 = node->getChild("indicated-turn-rate", 0, true); + + reinit(); +} + +void +TurnIndicator::reinit () +{ + _last_rate = 0; + _gyro.reinit(); } void @@ -69,8 +62,8 @@ TurnIndicator::bind () { std::ostringstream temp; string branch; - temp << num; - branch = "/instrumentation/" + name + "[" + temp.str() + "]"; + temp << _num; + branch = "/instrumentation/" + _name + "[" + temp.str() + "]"; fgTie((branch + "/serviceable").c_str(), &_gyro, &Gyro::is_serviceable, &Gyro::set_serviceable); @@ -83,8 +76,8 @@ TurnIndicator::unbind () { std::ostringstream temp; string branch; - temp << num; - branch = "/instrumentation/" + name + "[" + temp.str() + "]"; + temp << _num; + branch = "/instrumentation/" + _name + "[" + temp.str() + "]"; fgUntie((branch + "/serviceable").c_str()); fgUntie((branch + "/serviceable").c_str()); @@ -94,7 +87,8 @@ 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();