]> git.mxchange.org Git - flightgear.git/blobdiff - src/Environment/environment_ctrl.hxx
More fixes to get the code working when threads are disabled.
[flightgear.git] / src / Environment / environment_ctrl.hxx
index 5b48823ac4ed737dc4027f934d2185cbb48d6f05..bb3460484ff1c626838b8cdf33ae779d83ecb3e6 100644 (file)
@@ -27,7 +27,7 @@
 #include <simgear/structure/subsystem_mgr.hxx>
 #include <simgear/environment/metar.hxx>
 
-#ifdef ENABLE_THREADS
+#if defined(ENABLE_THREADS) && ENABLE_THREADS
 # include <simgear/threads/SGThread.hxx>
 # include <simgear/threads/SGQueue.hxx>
 #endif
 #  include <math.h>
 #endif
 
+#include <queue>
 #include <vector>
 
+SG_USING_STD(queue);
 SG_USING_STD(vector);
 
 class SGPropertyNode;
@@ -139,6 +141,13 @@ private:
 };
 
 
+// A convenience wrapper around SGMetar
+struct FGMetarResult {
+    string icao;
+    SGMetar *m;
+};
+
+
 \f
 /**
  * Interplation controller using the SGMetar class
@@ -152,7 +161,6 @@ public:
     virtual void init ();
     virtual void reinit ();
     virtual void update (double delta_time_sec);
-
     virtual void setEnvironment (FGEnvironment * environment);
 
 private:
@@ -160,19 +168,44 @@ private:
 
     string _icao;
     float station_elevation_ft;
-    float update_interval_sec;
-    float elapsed;
-    bool fetch_data (const string &icao);
+    float search_interval_sec;
+    float same_station_interval_sec;
+    float search_elapsed;
+    float fetch_elapsed;
+    FGAirport last_apt;
+    SGPropertyNode *proxy_host;
+    SGPropertyNode *proxy_port;
+    SGPropertyNode *proxy_auth;
+
+    FGMetarResult fetch_data( const string &icao );
+    virtual void update_metar_properties( SGMetar *m );
     void update_env_config();
 
 private:
 
-#ifdef ENABLE_THREADS
+#if defined(ENABLE_THREADS) && ENABLE_THREADS
     /**
      * FIFO queue which holds a pointer to the fetched metar data.
      */
-    SGBlockingQueue< SGMetar * > metar_queue;
+    SGBlockingQueue < string > request_queue;
 
+    /**
+     * FIFO queue which holds a pointer to the fetched metar data.
+     */
+    SGBlockingQueue < FGMetarResult > result_queue;
+#else
+    /**
+     * FIFO queue which holds a pointer to the fetched metar data.
+     */
+    queue < string > request_queue;
+
+    /**
+     * FIFO queue which holds a pointer to the fetched metar data.
+     */
+    queue < FGMetarResult > result_queue;
+#endif
+
+#if defined(ENABLE_THREADS) && ENABLE_THREADS
     /**
      * This class represents the thread of execution responsible for
      * fetching the metar data.
@@ -184,7 +217,7 @@ private:
         ~MetarThread() {}
 
         /**
-         * Reads the tile from disk.
+         * Fetche the metar data from the NOAA.
          */
         void run();
 
@@ -215,7 +248,12 @@ private:
      * Thread cleanup handler.
      */
     friend void metar_cleanup_handler( void* );
+
 #endif // ENABLE_THREADS
+
+    int _error_count;
+    double _dt;
+    double _error_dt;
 };
 
 #endif // _ENVIRONMENT_CTRL_HXX