-/* -------------------------------------------------------------------------------- */
-
-class NoaaMetarRealWxController : public BasicRealWxController {
-public:
- NoaaMetarRealWxController( SGPropertyNode_ptr rootNode );
- virtual ~NoaaMetarRealWxController();
- virtual void update (bool first, double delta_time_sec);
-
- class MetarLoadRequest {
- public:
- MetarLoadRequest( const string & stationId ) :
- _stationId(stationId),
- _proxyHost(fgGetNode("/sim/presets/proxy/host", true)->getStringValue()),
- _proxyPort(fgGetNode("/sim/presets/proxy/port", true)->getStringValue()),
- _proxyAuth(fgGetNode("/sim/presets/proxy/authentication", true)->getStringValue())
- {}
- MetarLoadRequest( const MetarLoadRequest & other ) :
- _stationId(other._stationId),
- _proxyHost(other._proxyAuth),
- _proxyPort(other._proxyPort),
- _proxyAuth(other._proxyAuth)
- {}
- string _stationId;
- string _proxyHost;
- string _proxyPort;
- string _proxyAuth;
- private:
- };
-
- class MetarLoadResponse {
- public:
- MetarLoadResponse( const string & stationId, const string metar ) {
- _stationId = stationId;
- _metar = metar;
- }
- MetarLoadResponse( const MetarLoadResponse & other ) {
- _stationId = other._stationId;
- _metar = other._metar;
- }
- string _stationId;
- string _metar;
- };
-private:
- double _positionTimeToLive;
- double _requestTimer;
-
-#if defined(ENABLE_THREADS)
- class MetarLoadThread : public OpenThreads::Thread {
- public:
- MetarLoadThread( long maxAge );
- void requestMetar( const MetarLoadRequest & metarRequest, bool background = true );
- bool hasMetar() { return _responseQueue.size() > 0; }
- MetarLoadResponse getMetar() { return _responseQueue.pop(); }
- virtual void run();
- private:
- void fetch( const MetarLoadRequest & );
- long _maxAge;
- long _minRequestInterval;
- SGBlockingQueue <MetarLoadRequest> _requestQueue;
- SGBlockingQueue <MetarLoadResponse> _responseQueue;
- };
-
- MetarLoadThread * _metarLoadThread;
-#endif
-};
-
-NoaaMetarRealWxController::NoaaMetarRealWxController( SGPropertyNode_ptr rootNode ) :
- BasicRealWxController(rootNode),
- _positionTimeToLive(0.0),
- _requestTimer(0.0)
-{
-#if defined(ENABLE_THREADS)
- _metarLoadThread = new MetarLoadThread(getMetarMaxAgeMin());
- _metarLoadThread->start();
-#endif
-}
-
-NoaaMetarRealWxController::~NoaaMetarRealWxController()