]> git.mxchange.org Git - flightgear.git/commitdiff
DME units report a distance based on the assumption that the ground station
authorcurt <curt>
Wed, 9 Jun 2004 20:21:18 +0000 (20:21 +0000)
committercurt <curt>
Wed, 9 Jun 2004 20:21:18 +0000 (20:21 +0000)
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
src/Instrumentation/dme.cxx

index f8e40efd38af14c20a11285bf890e88001eb19e6..fb416fcaaa34e9d8d806e0f8b180389eb0359241 100644 (file)
@@ -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;
index f9d186ca12c578853b7dc02ae58cb6bb6de59582..5aea2a8ba6ab74176c29cc7a0de7ec8633553d44 100644 (file)
@@ -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);