]> git.mxchange.org Git - flightgear.git/commitdiff
TACAN improvements.
authorThomas Geymayer <tomgey@gmail.com>
Sun, 2 Mar 2014 00:34:04 +0000 (01:34 +0100)
committerThomas Geymayer <tomgey@gmail.com>
Sun, 2 Mar 2014 00:34:04 +0000 (01:34 +0100)
 - Make search interval for new mobile tacan larger.
 - Continuous update of mobile tacan position.

src/Instrumentation/tacan.cxx
src/Navaids/navrecord.cxx
src/Navaids/navrecord.hxx

index f9b463f506bf4a8b13b90f6c068f06080bd26c9b..ca0320abbb38b3c880d053f7ae3753c126abf1e7 100644 (file)
@@ -208,7 +208,7 @@ void TACAN::disabled()
 void TACAN::search (double frequency_mhz,const SGGeod& pos)
 {
   // reset search time
-  _time_before_search_sec = 1.0;
+  _time_before_search_sec = 5;
 
   // Get first matching mobile station (carriers/tankers/etc.)
   // TODO do we need to check for mobile stations with same frequency? Currently
index bfc78f6326a2ce1453c7fafab8a53541f4dbc9c7..37bd5a194aea4f83221831c42b0f4a7189283e8c 100644 (file)
@@ -119,7 +119,8 @@ FGMobileNavRecord::FGMobileNavRecord( PositionedID aGuid,
                                       int range,
                                       double multiuse,
                                       PositionedID aRunway ):
-  FGNavRecord(aGuid, type, ident, name, aPos, freq, range, multiuse, aRunway)
+  FGNavRecord(aGuid, type, ident, name, aPos, freq, range, multiuse, aRunway),
+  _initial_elevation_ft(aPos.getElevationFt())
 {
 
 }
@@ -139,12 +140,9 @@ const SGVec3d& FGMobileNavRecord::cart() const
 }
 
 //------------------------------------------------------------------------------
-void FGMobileNavRecord::updatePos()
+void FGMobileNavRecord::updateVehicle()
 {
-  SGTimeStamp now = SGTimeStamp::now();
-  if( (now - _last_position_update).toSecs() < 1 )
-    return;
-  _last_position_update = now;
+  _vehicle_node.clear();
 
   SGPropertyNode* ai_branch = fgGetNode("ai/models");
   if( !ai_branch )
@@ -155,7 +153,6 @@ void FGMobileNavRecord::updatePos()
     return;
   }
 
-  serviceable = true;
   const std::string& nav_name = name();
 
   // Try any aircraft carriers first
@@ -168,11 +165,7 @@ void FGMobileNavRecord::updatePos()
         || nav_name.find(carrier_name) == std::string::npos )
       continue;
 
-    modifyPosition(SGGeod::fromDegFt(
-      carrier[i]->getDoubleValue("position/longitude-deg"),
-      carrier[i]->getDoubleValue("position/latitude-deg"),
-      get_elev_ft()
-    ));
+    _vehicle_node = carrier[i];
     return;
   }
 
@@ -195,22 +188,38 @@ void FGMobileNavRecord::updatePos()
           || nav_name.find(callsign) == std::string::npos )
         continue;
 
-      modifyPosition(SGGeod::fromDegFt(
-        tanker[j]->getDoubleValue("position/longitude-deg"),
-        tanker[j]->getDoubleValue("position/latitude-deg"),
-        tanker[j]->getDoubleValue("position/altitude-ft")
-      ));
+      _vehicle_node = tanker[j];
       return;
     }
   }
+}
+
+//------------------------------------------------------------------------------
+void FGMobileNavRecord::updatePos()
+{
+  SGTimeStamp now = SGTimeStamp::now();
+  if( (now - _last_vehicle_update).toSecs() > (_vehicle_node.valid() ? 5 : 2) )
+  {
+    updateVehicle();
+    _last_vehicle_update = now;
+  }
 
-  // If no match was found set 'invalid' position (lat = lon = alt = 0)
-  modifyPosition(SGGeod());
+  if( _vehicle_node.valid() )
+    modifyPosition(SGGeod::fromDegFt(
+      _vehicle_node->getDoubleValue("position/longitude-deg"),
+      _vehicle_node->getDoubleValue("position/latitude-deg"),
+      _vehicle_node->getNameString() == "carrier"
+      ? _initial_elevation_ft
+      : _vehicle_node->getDoubleValue("position/altitude-ft")
+    ));
+  else
+    // If no match was found set 'invalid' position (lat = lon = 0)
+    modifyPosition(SGGeod());
 
-  // It's mobile but we do not know where it is...
-  serviceable = false;
+  serviceable = _vehicle_node.valid();
 }
 
+//------------------------------------------------------------------------------
 FGTACANRecord::FGTACANRecord(void) :
     channel(""),
     freq(0)
index f7400ba8f399c974774b30293fabfd747b9a0468..8aa6fb1bd98b36594b8be9845aa38f4375ea5f90 100644 (file)
@@ -30,6 +30,7 @@
 #include "positioned.hxx"
 #include <Airports/airports_fwd.hxx>
 
+#include <simgear/props/propsfwd.hxx>
 #include <simgear/timing/timestamp.hxx>
 
 const double FG_NAV_DEFAULT_RANGE = 50; // nm
@@ -122,10 +123,13 @@ class FGMobileNavRecord:
     virtual const SGGeod& geod() const;
     virtual const SGVec3d& cart() const;
 
+    void updateVehicle();
     void updatePos();
 
   protected:
-    SGTimeStamp _last_position_update;
+    SGTimeStamp _last_vehicle_update;
+    SGPropertyNode_ptr _vehicle_node;
+    double _initial_elevation_ft; // Elevation as given in the config file
 };
 
 class FGTACANRecord : public SGReferenced {