13 auto& navigation = result.navigation;
16 navigation.speedMetersPerSecond = NAN;
17 navigation.courseRadians = NAN;
19 auto& integrity = result.integrity;
23 integrity = integrity.freshAt(nowUs ? nowUs : std::max(navigation.timestampUs, diagnostic.
timestampUs));
30 for (
auto& [constellation, counts] : _constellations) {
37 for (
const auto& native : reported) {
38 auto& counts = _constellations[native.constellation];
39 _accept(counts.inView, native.inViewTimestampUs, std::clamp(native.inView, 0, LIMIT), nowUs);
40 _accept(counts.used, native.inUseTimestampUs,
41 native.inUse ? std::optional<int>(std::clamp(*native.inUse, 0, LIMIT)) : std::nullopt, nowUs);
43 (void) _expire(nowUs);
44 return _report(
false);
50 (void) _expire(nowUs);
56 if (!_expire(nowUs)) {
59 return _report(
false);
62void SatelliteCounts::_accept(Count& count, uint64_t receivedAtUs, std::optional<int> value, uint64_t nowUs)
64 if (receivedAtUs >= count.receivedAtUs &&
66 count = {receivedAtUs, value};
70bool SatelliteCounts::_expire(uint64_t nowUs)
73 for (
auto& [constellation, counts] : _constellations) {
74 for (Count* count : {&counts.inView, &counts.used}) {
75 if (count->receivedAtUs &&
90 bool usedKnown =
true;
91 for (
const auto& [constellation, counts] : _constellations) {
92 if (!counts.inView.receivedAtUs) {
96 const int visible = counts.inView.value.value_or(0);
101 if (counts.used.receivedAtUs && counts.used.value) {
102 used += *counts.used.value;
107 std::optional<int> viewUsed;
112 }
else if (usedKnown) {
116 report.
used = countOnlyUsed || !viewUsed ? _countOnlyUsed : viewUsed;