X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FInstrumentation%2Fheading_indicator_fg.cxx;h=32332a3e1a648a257cabee0e140e8eaef96909e3;hb=def81b4de5f87c28b5afd92264e40e66e4fd93e3;hp=960bd98ab55570157b1b706c308a25dba3615f17;hpb=c1bb4aec97f0ae8e6bbe970acfd1a5f53127a723;p=flightgear.git diff --git a/src/Instrumentation/heading_indicator_fg.cxx b/src/Instrumentation/heading_indicator_fg.cxx index 960bd98ab..32332a3e1 100644 --- a/src/Instrumentation/heading_indicator_fg.cxx +++ b/src/Instrumentation/heading_indicator_fg.cxx @@ -5,15 +5,23 @@ // // This file is in the Public Domain and comes with no warranty. +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + #include #include #include #include -#include "heading_indicator_fg.hxx" +#include + #include
-#include
+#include
+#include "heading_indicator_fg.hxx" + +using std::string; HeadingIndicatorFG::HeadingIndicatorFG ( SGPropertyNode *node ) : @@ -52,19 +60,30 @@ HeadingIndicatorFG::init () string branch; branch = "/instrumentation/" + name; - _heading_in_node = fgGetNode("/orientation/heading-deg", true); + _heading_in_node = fgGetNode("/orientation/heading-deg", true); SGPropertyNode *node = fgGetNode(branch.c_str(), num, true ); - _offset_node = node->getChild("offset-deg", 0, true); + if( NULL == (_offset_node = node->getChild("offset-deg", 0, false)) ) { + _offset_node = node->getChild("offset-deg", 0, true); + _offset_node->setDoubleValue( -fgGetDouble("/environment/magnetic-variation-deg") ); + } _serviceable_node = node->getChild("serviceable", 0, true); - _error_node = node->getChild("heading-bug-error-deg", 0, true); - _nav1_error_node = node->getChild("nav1-course-error-deg", 0, true); + _error_node = node->getChild("heading-bug-error-deg", 0, true); + _nav1_error_node = node->getChild("nav1-course-error-deg", 0, true); _heading_out_node = node->getChild("indicated-heading-deg", 0, true); _off_node = node->getChild("off-flag", 0, true); + _electrical_node = fgGetNode("/systems/electrical/outputs/DG", true); + + reinit(); +} + +void +HeadingIndicatorFG::reinit () +{ _last_heading_deg = (_heading_in_node->getDoubleValue() + _offset_node->getDoubleValue()); - _electrical_node = fgGetNode("/systems/electrical/outputs/DG", true); + _gyro.reinit(); } void @@ -79,7 +98,6 @@ HeadingIndicatorFG::bind () &_gyro, &Gyro::is_serviceable, &Gyro::set_serviceable); fgTie((branch + "/spin").c_str(), &_gyro, &Gyro::get_spin_norm, &Gyro::set_spin_norm); - } void @@ -142,7 +160,7 @@ HeadingIndicatorFG::update (double dt) // calculate the difference between the indicated heading // and the selected heading for use with an autopilot - static SGPropertyNode *bnode + SGPropertyNode *bnode = fgGetNode( "/autopilot/settings/heading-bug-deg", false ); double diff = 0; if ( bnode ){