From 45d0e14cad43042825b991ab2f96530d20417f3f Mon Sep 17 00:00:00 2001 From: jmt Date: Sun, 20 Dec 2009 16:13:20 +0000 Subject: [PATCH] JSD: Make false courses work for more than one instance of navradio. --- src/Instrumentation/navradio.cxx | 16 ++++++++++------ src/Instrumentation/navradio.hxx | 6 +++--- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/Instrumentation/navradio.cxx b/src/Instrumentation/navradio.cxx index 40a33844b..c8c959937 100644 --- a/src/Instrumentation/navradio.cxx +++ b/src/Instrumentation/navradio.cxx @@ -156,7 +156,6 @@ FGNavRadio::FGNavRadio(SGPropertyNode *node) : _name(node->getStringValue("name", "nav")), _num(node->getIntValue("number", 0)), _time_before_search_sec(-1.0), - _falseCoursesEnabled(true), _sgr(NULL) { SGPath path( globals->get_fg_root() ); @@ -217,9 +216,14 @@ FGNavRadio::init () tofrom_serviceable_node = createServiceableProp(node, "to-from"); dme_serviceable_node = createServiceableProp(node, "dme"); - globals->get_props()->tie("sim/realism/false-radio-courses-enabled", - SGRawValuePointer(&_falseCoursesEnabled)); - + falseCoursesEnabledNode = + fgGetNode("/sim/realism/false-radio-courses-enabled"); + if (!falseCoursesEnabledNode) { + falseCoursesEnabledNode = + fgGetNode("/sim/realism/false-radio-courses-enabled", true); + falseCoursesEnabledNode->setBoolValue(true); + } + // frequencies SGPropertyNode *subnode = node->getChild("frequencies", 0, true); freq_node = subnode->getChild("selected-mhz", 0, true); @@ -532,7 +536,7 @@ void FGNavRadio::updateReceiver(double dt) SG_NORMALIZE_RANGE(r, -180.0, 180.0); if ( is_loc ) { - if (_falseCoursesEnabled) { + if (falseCoursesEnabledNode->getBoolValue()) { // The factor of 30.0 gives a period of 120 which gives us 3 cycles and six // zeros i.e. six courses: one front course, one back course, and four // false courses. Three of the six are reverse sensing. @@ -604,7 +608,7 @@ void FGNavRadio::updateGlideSlope(double dt, const SGVec3d& aircraft, double sig double angle = atan2(dot_v, dot_h) * SGD_RADIANS_TO_DEGREES; double deflectionAngle = target_gs - angle; - if (_falseCoursesEnabled) { + if (falseCoursesEnabledNode->getBoolValue()) { // Construct false glideslopes. The scale factor of 1.5 // in the sawtooth gives a period of 6 degrees. // There will be zeros at 3, 6r, 9, 12r et cetera diff --git a/src/Instrumentation/navradio.hxx b/src/Instrumentation/navradio.hxx index 88f67685a..82e1498bd 100644 --- a/src/Instrumentation/navradio.hxx +++ b/src/Instrumentation/navradio.hxx @@ -120,6 +120,9 @@ class FGNavRadio : public SGSubsystem SGPropertyNode_ptr gps_xtrack_error_nm_node; SGPropertyNode_ptr _magvarNode; + // realism setting, are false courses and GS lobes enabled? + SGPropertyNode_ptr falseCoursesEnabledNode; + // internal (private) values int play_count; @@ -161,9 +164,6 @@ class FGNavRadio : public SGSubsystem double _gsNeedleDeflection; double _gsNeedleDeflectionNorm; - // realism setting, are false courses and GS lobes enabled? - bool _falseCoursesEnabled; - SGSharedPtr _sgr; bool updateWithPower(double aDt);