From 6c8f7fab01375b0204c5759d8ae75fe99d4da5e1 Mon Sep 17 00:00:00 2001 From: curt Date: Wed, 9 Jun 2004 20:21:18 +0000 Subject: [PATCH] DME units report a distance based on the assumption that the ground station will delay it's reply by 50ms. The ground station can change it's reply delay to trick the airborn dme unit into reporting a distance that is offset from the true distance by some constant value. In FG we model this by subtracting a fixed distance from the actual distance. It is thus possible in our implimentation for the displayed distance to become negative. This patch clamp DME distance to a minimum value of 0.00 so it can never go negative. --- src/Cockpit/dme.cxx | 3 +++ src/Instrumentation/dme.cxx | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Cockpit/dme.cxx b/src/Cockpit/dme.cxx index f8e40efd3..fb416fcaa 100644 --- a/src/Cockpit/dme.cxx +++ b/src/Cockpit/dme.cxx @@ -161,6 +161,9 @@ FGDME::update(double dt) station = Point3D( x, y, z ); dist = aircraft.distance3D( station ) * SG_METER_TO_NM; dist -= bias; + if ( dist < 0.0 ) { + dist = 0.0; + } current_time.stamp(); long dMs = (current_time - last_time) / 1000; diff --git a/src/Instrumentation/dme.cxx b/src/Instrumentation/dme.cxx index f9d186ca1..5aea2a8ba 100644 --- a/src/Instrumentation/dme.cxx +++ b/src/Instrumentation/dme.cxx @@ -128,7 +128,11 @@ DME::update (double delta_time_sec) _last_distance_nm = distance_nm; _in_range_node->setBoolValue(true); - _distance_node->setDoubleValue(distance_nm - _transmitter_bias); + double tmp_dist = distance_nm - _transmitter_bias; + if ( tmp_dist < 0.0 ) { + tmp_dist = 0.0; + } + _distance_node->setDoubleValue( tmp_dist ); _speed_node->setDoubleValue(speed_kt); _time_node->setDoubleValue(distance_nm/speed_kt*60.0);