From f14aa4e57f3c39d57649ebac4b625a07dd5fcce7 Mon Sep 17 00:00:00 2001 From: James Turner Date: Mon, 10 Dec 2018 16:09:42 +0000 Subject: [PATCH] Navradio: move glideslope angle to NavRecord Simplifies logic in testing code --- src/Instrumentation/navradio.cxx | 3 +-- src/Navaids/navrecord.cxx | 11 +++++++++++ src/Navaids/navrecord.hxx | 7 +++++++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/Instrumentation/navradio.cxx b/src/Instrumentation/navradio.cxx index 03e049b26..ff8144664 100644 --- a/src/Instrumentation/navradio.cxx +++ b/src/Instrumentation/navradio.cxx @@ -958,8 +958,7 @@ void FGNavRadio::updateNav() SG_NORMALIZE_RANGE(target_radial, 0.0, 360.0); if (_gs) { - int tmp = (int)(_gs->get_multiuse() / 1000.0); - target_gs = (double)tmp / 100.0; + target_gs = _gs->glideSlopeAngleDeg(); double gs_radial = fmod(_gs->get_multiuse(), 1000.0); SG_NORMALIZE_RANGE(gs_radial, 0.0, 360.0); diff --git a/src/Navaids/navrecord.cxx b/src/Navaids/navrecord.cxx index 4b06f7aa0..0dffadb05 100644 --- a/src/Navaids/navrecord.cxx +++ b/src/Navaids/navrecord.cxx @@ -124,6 +124,17 @@ void FGNavRecord::updateFromXML(const SGGeod& geod, double heading) multiuse = heading; } +double FGNavRecord::glideSlopeAngleDeg() const +{ + if (type() != FGPositioned::GS) { + SG_LOG(SG_NAVAID, SG_DEV_WARN, "called glideSlopeAngleDeg on non-GS navaid:" << ident()); + return 0.0; + } + + const auto tmp = static_cast(get_multiuse() / 1000.0); + return static_cast(tmp) / 100.0; +} + //------------------------------------------------------------------------------ FGMobileNavRecord::FGMobileNavRecord( PositionedID aGuid, Type type, diff --git a/src/Navaids/navrecord.hxx b/src/Navaids/navrecord.hxx index 7e4c0da61..1350e9bfc 100644 --- a/src/Navaids/navrecord.hxx +++ b/src/Navaids/navrecord.hxx @@ -97,6 +97,13 @@ class FGNavRecord : public FGPositioned */ double localizerWidth() const; + /** + * extract the glide slope angle, in degrees, from the multiuse field + * Return 0.0 for non-GS navaids (including an ILS or LOC - you need + * to call this on the paired GS record. + */ + double glideSlopeAngleDeg() const; + void bindToNode(SGPropertyNode* nd) const; void unbindFromNode(SGPropertyNode* nd) const;