- _g_node = fgGetNode("/accelerations/pilot-g", true);
-
-\r
- SGPropertyNode *node = fgGetNode(branch.c_str(), num, true );\r
- _offset_node = node->getChild("offset-deg", 0, true);\r
- _serviceable_node = node->getChild("serviceable", 0, true);\r
- _heading_bug_error_node = node->getChild("heading-bug-error-deg", 0, true);\r
- _error_node = node->getChild("error-deg", 0, true);\r
- _nav1_error_node = node->getChild("nav1-course-error-deg", 0, true);\r
- _heading_out_node = node->getChild("indicated-heading-deg", 0, true);\r
- _align_node = node->getChild("align-deg", 0, true);\r
-\r
- _electrical_node = fgGetNode("/systems/electrical/outputs/DG", true);\r
-\r
- _align_node->setDoubleValue(0);\r
- _error_node->setDoubleValue(0);\r
-\r
- _last_heading_deg = (_heading_in_node->getDoubleValue() +\r
- _offset_node->getDoubleValue() + _align_node->getDoubleValue());\r
-}\r
-\r
-void\r
-HeadingIndicatorDG::bind ()\r
-{\r
- std::ostringstream temp;\r
- string branch;\r
- temp << num;\r
- branch = "/instrumentation/" + name + "[" + temp.str() + "]";\r
-\r
- fgTie((branch + "/serviceable").c_str(),\r
- &_gyro, &Gyro::is_serviceable, &Gyro::set_serviceable);\r
- fgTie((branch + "/spin").c_str(),\r
- &_gyro, &Gyro::get_spin_norm, &Gyro::set_spin_norm);\r
-}\r
-\r
-void\r
-HeadingIndicatorDG::unbind ()\r
-{\r
- std::ostringstream temp;\r
- string branch;\r
- temp << num;\r
- branch = "/instrumentation/" + name + "[" + temp.str() + "]";\r
-\r
- fgUntie((branch + "/serviceable").c_str());\r
- fgUntie((branch + "/spin").c_str());\r
-}\r
-\r
-void\r
-HeadingIndicatorDG::update (double dt)\r
-{\r
- // Get the spin from the gyro\r
- _gyro.set_power_norm(_electrical_node->getDoubleValue());\r
-\r
- _gyro.update(dt);\r
- double spin = _gyro.get_spin_norm();\r
-\r
- // Next, calculate time-based precession\r
- double offset = _offset_node->getDoubleValue();\r
- offset -= dt * (0.25 / 60.0); // 360deg/day\r
- SG_NORMALIZE_RANGE(offset, -360.0, 360.0);\r
-\r
- // No magvar - set the alignment manually\r
- double align = _align_node->getDoubleValue();\r
-\r
- // Movement-induced error\r
- double yaw_rate = _yaw_rate_node->getDoubleValue();\r
- double error = _error_node->getDoubleValue();\r
- double g = _g_node->getDoubleValue();
- int sign = 0;
+ _g_node = fgGetNode("/accelerations/pilot-g", true);
+
+ SGPropertyNode *node = fgGetNode(branch.c_str(), num, true );
+ _offset_node = node->getChild("offset-deg", 0, true);
+ _serviceable_node = node->getChild("serviceable", 0, true);
+ _heading_bug_error_node = node->getChild("heading-bug-error-deg", 0, true);
+ _error_node = node->getChild("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);
+ _align_node = node->getChild("align-deg", 0, true);
+
+ _electrical_node = fgGetNode("/systems/electrical/outputs/DG", true);
+
+ reinit();
+}
+
+void
+HeadingIndicatorDG::bind ()
+{
+ std::ostringstream temp;
+ std::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
+HeadingIndicatorDG::unbind ()
+{
+ std::ostringstream temp;
+ std::string branch;
+ temp << num;
+ branch = "/instrumentation/" + name + "[" + temp.str() + "]";
+
+ fgUntie((branch + "/serviceable").c_str());
+ fgUntie((branch + "/spin").c_str());
+}
+
+void
+HeadingIndicatorDG::reinit (void)
+{
+ // reset errors/drift values
+ _align_node->setDoubleValue(0.0);
+ _error_node->setDoubleValue(0.0);
+ _offset_node->setDoubleValue(0.0);