X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FInstrumentation%2Fmrg.cxx;h=d890ee266b6a28ffd6097f2779a80560978d0e22;hb=9bb55e78be6c6a9da4be26a3671e7d4bf6332d50;hp=918160ae54eaf8053c4a4e293cb8afe4a61a0a24;hpb=eb6b28f5074654f25fb9118160a70f5a114f6970;p=flightgear.git diff --git a/src/Instrumentation/mrg.cxx b/src/Instrumentation/mrg.cxx index 918160ae5..d890ee266 100644 --- a/src/Instrumentation/mrg.cxx +++ b/src/Instrumentation/mrg.cxx @@ -1,5 +1,5 @@ -// MRG.cxx - an electrcally powered master reference gyro. -// Written by Vivian Meazza based on wrok by David Megginson, started 2006. +// MRG.cxx - an electrically powered master reference gyro. +// Written by Vivian Meazza based on work by David Megginson, started 2006. // // This file is in the Public Domain and comes with no warranty. @@ -20,28 +20,8 @@ MasterReferenceGyro::MasterReferenceGyro ( SGPropertyNode *node ) : - name("master-reference-gyro"), - 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 = (int) child->getDoubleValue(); - } else { - SG_LOG( SG_INSTR, SG_WARN, "Error in mrg config logic" ); - if ( name.length() ) { - SG_LOG( SG_INSTR, SG_WARN, "Section = " << name ); - } - } - } -} - -MasterReferenceGyro::MasterReferenceGyro () + _name(node->getStringValue("name", "master-reference-gyro")), + _num(node->getIntValue("number", 0)) { } @@ -63,7 +43,7 @@ MasterReferenceGyro::init () _indicated_pitch_rate = 0; string branch; - branch = "/instrumentation/" + name; + branch = "/instrumentation/" + _name; _pitch_in_node = fgGetNode("/orientation/pitch-deg", true); _roll_in_node = fgGetNode("/orientation/roll-deg", true); @@ -74,7 +54,7 @@ MasterReferenceGyro::init () _g_in_node = fgGetNode("/accelerations/pilot-g-damped", true); _electrical_node = fgGetNode("/systems/electrical/outputs/MRG", true); - SGPropertyNode *node = fgGetNode(branch.c_str(), num, true ); + SGPropertyNode *node = fgGetNode(branch.c_str(), _num, true ); _off_node = node->getChild("off-flag", 0, true); _pitch_out_node = node->getChild("indicated-pitch-deg", 0, true); _roll_out_node = node->getChild("indicated-roll-deg", 0, true); @@ -95,8 +75,8 @@ MasterReferenceGyro::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); @@ -109,8 +89,8 @@ MasterReferenceGyro::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 + "/spin").c_str()); @@ -167,7 +147,7 @@ MasterReferenceGyro::update (double dt) _last_yaw_rate = yaw_rate; //the gyro only erects inside limits - if ( abs ( yaw_rate ) <= 5 + if ( fabs ( yaw_rate ) <= 5 && (_g_in_node->getDoubleValue() <= 1.5 || _g_in_node->getDoubleValue() >= -0.5) ) { indicated_roll = _last_roll;