mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-23 05:45:35 +08:00
Avoid too many booking reader values
This commit is contained in:
committed by
Mat Sutcliffe
parent
a646e122af
commit
909a9e55d7
@@ -164,12 +164,12 @@ namespace BlackCore
|
|||||||
}
|
}
|
||||||
else if (name == "time_end")
|
else if (name == "time_end")
|
||||||
{
|
{
|
||||||
QDateTime t = fromStringUtc(value, timestampFormat);
|
const QDateTime t = fromStringUtc(value, timestampFormat);
|
||||||
bookedStation.setBookedUntilUtc(t);
|
bookedStation.setBookedUntilUtc(t);
|
||||||
}
|
}
|
||||||
else if (name == "time_start")
|
else if (name == "time_start")
|
||||||
{
|
{
|
||||||
QDateTime t = fromStringUtc(value, timestampFormat);
|
const QDateTime t = fromStringUtc(value, timestampFormat);
|
||||||
bookedStation.setBookedFromUtc(t);
|
bookedStation.setBookedFromUtc(t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -180,6 +180,7 @@ namespace BlackCore
|
|||||||
bookedStation.setController(user);
|
bookedStation.setController(user);
|
||||||
bookedStations.push_back(bookedStation);
|
bookedStations.push_back(bookedStation);
|
||||||
}
|
}
|
||||||
|
m_failures = 0;
|
||||||
this->setUpdateTimestamp(updateTimestamp); // thread safe update
|
this->setUpdateTimestamp(updateTimestamp); // thread safe update
|
||||||
emit this->atcBookingsRead(bookedStations);
|
emit this->atcBookingsRead(bookedStations);
|
||||||
emit this->dataRead(CEntityFlags::BookingEntity, CEntityFlags::ReadFinished, bookedStations.size());
|
emit this->dataRead(CEntityFlags::BookingEntity, CEntityFlags::ReadFinished, bookedStations.size());
|
||||||
@@ -188,16 +189,24 @@ namespace BlackCore
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// network error
|
// network error
|
||||||
CLogMessage(this).warning(u"Reading bookings failed %1 %2") << nwReply->errorString() << nwReply->url().toString();
|
CLogMessage(this).warning(u"Reading bookings failed '%1' '%2'") << nwReply->errorString() << nwReply->url().toString();
|
||||||
nwReply->abort();
|
nwReply->abort();
|
||||||
|
m_failures++;
|
||||||
|
if (m_failures > 3)
|
||||||
|
{
|
||||||
|
// slow updates from now on
|
||||||
|
const CReaderSettings s = m_settings.get();
|
||||||
|
this->setInitialAndPeriodicTime(s.getInitialTime().toMs(), 10 * s.getPeriodicTime().toMs());
|
||||||
|
CLogMessage(this).warning(u"Too many booking reader failures %1, slower updates") << m_failures;
|
||||||
|
}
|
||||||
emit this->dataRead(CEntityFlags::BookingEntity, CEntityFlags::ReadFailed, 0);
|
emit this->dataRead(CEntityFlags::BookingEntity, CEntityFlags::ReadFailed, 0);
|
||||||
}
|
}
|
||||||
} // method
|
} // method
|
||||||
|
|
||||||
void CVatsimBookingReader::settingsChanged()
|
void CVatsimBookingReader::settingsChanged()
|
||||||
{
|
{
|
||||||
CReaderSettings s = m_settings.get();
|
const CReaderSettings s = m_settings.get();
|
||||||
setInitialAndPeriodicTime(s.getInitialTime().toMs(), s.getPeriodicTime().toMs());
|
this->setInitialAndPeriodicTime(s.getInitialTime().toMs(), s.getPeriodicTime().toMs());
|
||||||
}
|
}
|
||||||
} // ns
|
} // ns
|
||||||
} // ns
|
} // ns
|
||||||
|
|||||||
@@ -66,6 +66,7 @@ namespace BlackCore
|
|||||||
//! Settings changed
|
//! Settings changed
|
||||||
void settingsChanged();
|
void settingsChanged();
|
||||||
|
|
||||||
|
int m_failures = 0;
|
||||||
BlackMisc::CSettingReadOnly<BlackCore::Vatsim::TVatsimBookings> m_settings { this, &CVatsimBookingReader::settingsChanged };
|
BlackMisc::CSettingReadOnly<BlackCore::Vatsim::TVatsimBookings> m_settings { this, &CVatsimBookingReader::settingsChanged };
|
||||||
};
|
};
|
||||||
} // ns
|
} // ns
|
||||||
|
|||||||
Reference in New Issue
Block a user