class MetarDataHandler {
public:
virtual void handleMetarData( const std::string & data ) = 0;
+ virtual void handleMetarFailure() = 0;
};
class MetarRequester {
// implementation of MetarDataHandler
virtual void handleMetarData( const std::string & data );
-
+ virtual void handleMetarFailure();
+
static const unsigned MAX_POLLING_INTERVAL_SECONDS = 10;
static const unsigned DEFAULT_TIME_TO_LIVE_SECONDS = 900;
double _pollingTimer;
MetarRequester * _metarRequester;
int _maxAge;
+ bool _failure;
};
typedef SGSharedPtr<LiveMetarProperties> LiveMetarProperties_ptr;
_timeToLive(0.0),
_pollingTimer(0.0),
_metarRequester(metarRequester),
- _maxAge(maxAge)
+ _maxAge(maxAge),
+ _failure(false)
{
_tiedProperties.Tie("time-to-live", &_timeToLive );
+ _tiedProperties.Tie("failure", &_failure);
}
LiveMetarProperties::~LiveMetarProperties()
}
catch( sg_io_exception ) {
SG_LOG( SG_ENVIRONMENT, SG_WARN, "Can't parse metar: " << data );
+ _failure = true;
return;
}
SG_LOG( SG_ENVIRONMENT, SG_DEBUG, "Ignoring outdated METAR for " << getStationId());
return;
}
-
+
+ _failure = false;
setMetar( m );
}
+void LiveMetarProperties::handleMetarFailure()
+{
+ _failure = true;
+}
+
/* -------------------------------------------------------------------------------- */
class BasicRealWxController : public RealWxController
virtual void onFail()
{
SG_LOG(SG_ENVIRONMENT, SG_INFO, "metar download failure");
+ _metarDataHandler->handleMetarFailure();
}
private:
bool finalizeMetar()
{
+ if (!fgGetBool("/environment/realwx/enabled")) {
+ return true;
+ }
+
double hdg = fgGetDouble( "/environment/metar/base-wind-dir-deg", 9999.0 );
string apt = fgGetString("/sim/presets/airport-id");
string rwy = fgGetString("/sim/presets/runway");
if (needMetar) {
// timeout so we don't spin forever if the network is down
- if (global_finalizeTime.elapsedMSec() > fgGetInt("/sim/startup/metar-fetch-timeout-msec", 10000)) {
+ if (global_finalizeTime.elapsedMSec() > fgGetInt("/sim/startup/metar-fetch-timeout-msec", 6000)) {
SG_LOG(SG_GENERAL, SG_WARN, "finalizePosition: timed out waiting for METAR fetch");
return true;
}
+ if (fgGetBool( "/environment/metar/failure" )) {
+ SG_LOG(SG_ENVIRONMENT, SG_INFO, "metar download failed, not waiting");
+ return true;
+ }
+
if (!fgGetBool( "/environment/metar/valid" )) {
return false;
}