X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=src%2FEnvironment%2Fenvironment_ctrl.hxx;h=054a0a2f9ec3577d35c12183adb04713f6e0a6ae;hb=d8000569eabff436d5452f84b40ca88ecd8f0cdd;hp=5032a9f590214d02e9c4f324ff9fc128f521ecf3;hpb=061f1688c3cb77f0171d38a987f2d1ff52c2d188;p=flightgear.git diff --git a/src/Environment/environment_ctrl.hxx b/src/Environment/environment_ctrl.hxx index 5032a9f59..054a0a2f9 100644 --- a/src/Environment/environment_ctrl.hxx +++ b/src/Environment/environment_ctrl.hxx @@ -38,8 +38,10 @@ # include #endif +#include #include +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; +}; + + /** * Interplation controller using the SGMetar class @@ -152,31 +161,51 @@ public: virtual void init (); virtual void reinit (); virtual void update (double delta_time_sec); - virtual void setEnvironment (FGEnvironment * environment); private: FGInterpolateEnvironmentCtrl *env; - float station_elevation_ft; - float update_interval_sec; - float elapsed; - bool fetch_data (const string &icao); - void update_env_config(); - string _icao; + float station_elevation_ft; + 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 /** * 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 + +#ifdef ENABLE_THREADS /** * This class represents the thread of execution responsible for * fetching the metar data. @@ -188,7 +217,7 @@ private: ~MetarThread() {} /** - * Reads the tile from disk. + * Fetched the metar data from the NOAA. */ void run();