12 const uint64_t now = context.
nowUs();
17 for (
auto& epoch : _epochs) {
18 if (epoch && epoch->tow == tow) {
22 auto free = _epochs.begin();
23 while (free != _epochs.end() && *free) {
26 if (free == _epochs.end()) {
27 free =
GPSTime::towAdvances(_epochs[0]->tow, _epochs[1]->tow) ? _epochs.begin() + 1 : _epochs.begin();
31 _finish(*free, context);
35 (*free)->receipt = now;
41 const uint64_t now = context.
nowUs();
43 for (
auto& epoch : _epochs) {
44 if (epoch && now >= epoch->receipt && std::chrono::microseconds(now - epoch->receipt) >=
MAX_AGE) {
45 _finish(epoch, context);
53 for (
auto& epoch : _epochs) {
55 _finish(epoch, context);
60void EpochAssembler::_orderOldestFirst()
63 std::swap(_epochs[0], _epochs[1]);
67void EpochAssembler::_finish(std::optional<Epoch>& epoch,
GPSDecodeContext& context)
70 epoch->position.navigation.timestampUs = epoch->receipt;
74 _lastPublished = epoch->tow;
void publishPosition(const GPSDecodedPosition &report)
Epoch * find(uint32_t tow, GPSDecodeContext &context)
The epoch at tow, started now when new; nullptr for a time of week already published or too old.
void end(uint32_t tow, GPSDecodeContext &context)
Publishes the epoch at tow and the ones before it.
void expire(GPSDecodeContext &context)
Publishes epochs older than MAX_AGE.
static constexpr std::chrono::microseconds MAX_AGE
constexpr bool towAdvances(uint32_t later, uint32_t earlier)
Whether time of week later follows earlier by less than half a week, across the week rollover.
constexpr uint32_t WEEK_MS
Milliseconds in a GPS week; every time of week is below it.
u-blox receivers over UBX: CFG-VALSET configuration from protocol 27, CFG-MSG and CFG-TMODE3 before i...