17 navigation.speedMetersPerSecond = NAN;
18 navigation.courseRadians = NAN;
24 integrity = integrity.freshAt(nowUs ? nowUs : std::max(navigation.timestampUs, diagnostic.
timestampUs));
31 for (
auto& [constellation, counts] : _constellations) {
38 for (
const auto& native : reported) {
39 auto& counts = _constellations[native.constellation];
40 _accept(counts.inView, native.inViewTimestampUs, std::clamp(native.inView, 0, LIMIT), nowUs);
41 _accept(counts.used, native.inUseTimestampUs,
42 native.inUse ? std::optional<int>(std::clamp(*native.inUse, 0, LIMIT)) : std::nullopt, nowUs);
44 (void) _expire(nowUs);
45 return _report(
false);
51 (void) _expire(nowUs);
57 if (!_expire(nowUs)) {
60 return _report(
false);
63void SatelliteCounts::_accept(
Count& count, uint64_t receivedAtUs, std::optional<int> value, uint64_t nowUs)
65 if (receivedAtUs >= count.receivedAtUs &&
67 count = {receivedAtUs, value};
71bool SatelliteCounts::_expire(uint64_t nowUs)
74 for (
auto& [constellation, counts] : _constellations) {
75 for (Count* count : {&counts.inView, &counts.used}) {
76 if (count->receivedAtUs &&
86GPSSatelliteReport SatelliteCounts::_report(
bool countOnlyUsed)
const
88 GPSSatelliteReport report;
91 bool usedKnown =
true;
92 for (
const auto& [constellation, counts] : _constellations) {
93 if (!counts.inView.receivedAtUs) {
97 const int visible = counts.inView.value.value_or(0);
102 if (counts.used.receivedAtUs && counts.used.value) {
103 used += *counts.used.value;
108 std::optional<int> viewUsed;
113 }
else if (usedKnown) {
117 report.
used = countOnlyUsed || !viewUsed ? _countOnlyUsed : viewUsed;