#895: AI traffic not working when system is offline but real-wx is enabled
Add a timeout when waiting for valid METAR.
This commit is contained in:
parent
7fa2aecc22
commit
791389cb98
2 changed files with 37 additions and 4 deletions
src/Traffic
|
@ -151,6 +151,7 @@ private:
|
||||||
FGTrafficManager::FGTrafficManager() :
|
FGTrafficManager::FGTrafficManager() :
|
||||||
inited(false),
|
inited(false),
|
||||||
doingInit(false),
|
doingInit(false),
|
||||||
|
waitingMetarTime(0.0),
|
||||||
enabled("/sim/traffic-manager/enabled"),
|
enabled("/sim/traffic-manager/enabled"),
|
||||||
aiEnabled("/sim/ai/enabled"),
|
aiEnabled("/sim/ai/enabled"),
|
||||||
realWxEnabled("/environment/realwx/enabled"),
|
realWxEnabled("/environment/realwx/enabled"),
|
||||||
|
@ -339,7 +340,36 @@ void FGTrafficManager::loadHeuristics()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FGTrafficManager::update(double /*dt */ )
|
bool FGTrafficManager::metarReady(double dt)
|
||||||
|
{
|
||||||
|
// wait for valid METAR (when realWX is enabled only), since we need
|
||||||
|
// to know the active runway
|
||||||
|
if (metarValid || !realWxEnabled)
|
||||||
|
{
|
||||||
|
waitingMetarTime = 0.0;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// METAR timeout: when running offline, remote server is down etc
|
||||||
|
if (waitingMetarStation != fgGetString("/environment/metar/station-id"))
|
||||||
|
{
|
||||||
|
// station has changed: wait for reply, restart timeout
|
||||||
|
waitingMetarTime = 0.0;
|
||||||
|
waitingMetarStation = fgGetString("/environment/metar/station-id");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// timeout elapsed (10 seconds)?
|
||||||
|
if (waitingMetarTime > 20.0)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
waitingMetarTime += dt;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void FGTrafficManager::update(double dt)
|
||||||
{
|
{
|
||||||
if (!enabled)
|
if (!enabled)
|
||||||
{
|
{
|
||||||
|
@ -348,9 +378,8 @@ void FGTrafficManager::update(double /*dt */ )
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((realWxEnabled && !metarValid)) {
|
if (!metarReady(dt))
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
if (!aiEnabled)
|
if (!aiEnabled)
|
||||||
{
|
{
|
||||||
|
|
|
@ -86,6 +86,8 @@ class FGTrafficManager : public SGSubsystem, public XMLVisitor
|
||||||
private:
|
private:
|
||||||
bool inited;
|
bool inited;
|
||||||
bool doingInit;
|
bool doingInit;
|
||||||
|
double waitingMetarTime;
|
||||||
|
std::string waitingMetarStation;
|
||||||
|
|
||||||
ScheduleVector scheduledAircraft;
|
ScheduleVector scheduledAircraft;
|
||||||
ScheduleVectorIterator currAircraft, currAircraftClosest;
|
ScheduleVectorIterator currAircraft, currAircraftClosest;
|
||||||
|
@ -122,9 +124,11 @@ private:
|
||||||
|
|
||||||
// helper to read and parse the schedule data.
|
// helper to read and parse the schedule data.
|
||||||
// this is run on a helper thread, so be careful about
|
// this is run on a helper thread, so be careful about
|
||||||
// accesing properties during parsing
|
// accessing properties during parsing
|
||||||
void parseSchedule(const SGPath& path);
|
void parseSchedule(const SGPath& path);
|
||||||
|
|
||||||
|
bool metarReady(double dt);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FGTrafficManager();
|
FGTrafficManager();
|
||||||
~FGTrafficManager();
|
~FGTrafficManager();
|
||||||
|
|
Loading…
Add table
Reference in a new issue