Line | Branch | Exec | Source |
---|---|---|---|
1 | #include "Observation.hpp" | ||
2 | #include <array> | ||
3 | #include <cstddef> | ||
4 | #include <unordered_set> | ||
5 | |||
6 | #include "Navigation/GNSS/Core/SatelliteIdentifier.hpp" | ||
7 | |||
8 | namespace NAV | ||
9 | { | ||
10 | |||
11 | ✗ | size_t Observations::countObservations(const SatSigId& satSigId, const GnssObs::ObservationType& obsType) const | |
12 | { | ||
13 | ✗ | if (!signals.contains(satSigId)) { return 0; } | |
14 | |||
15 | ✗ | const auto& recvObs = signals.at(satSigId).recvObs; | |
16 | ✗ | return static_cast<size_t>(std::ranges::count_if(recvObs, [&obsType](const auto& obs) { | |
17 | ✗ | return obs.second->obs.contains(obsType); | |
18 | ✗ | })); | |
19 | } | ||
20 | |||
21 | 1127 | void Observations::recalcObservableCounts([[maybe_unused]] const std::string& nameId) | |
22 | { | ||
23 | 1127 | std::array<std::unordered_set<SatId>, GnssObs::ObservationType_COUNT> nMeasUniqueSat; | |
24 | 1127 | systems.clear(); | |
25 | 1127 | satellites.clear(); | |
26 |
1/2✓ Branch 1 taken 1127 times.
✗ Branch 2 not taken.
|
1127 | nObservables.fill(0); |
27 |
1/2✓ Branch 1 taken 1127 times.
✗ Branch 2 not taken.
|
1127 | nObservablesUniqueSatellite.fill(0); |
28 | |||
29 |
2/2✓ Branch 7 taken 41798 times.
✓ Branch 8 taken 1127 times.
|
42925 | for (const auto& [satSigId, sigObs] : signals) |
30 | { | ||
31 |
1/2✓ Branch 1 taken 41798 times.
✗ Branch 2 not taken.
|
41798 | auto satId = satSigId.toSatId(); |
32 |
1/2✓ Branch 1 taken 41798 times.
✗ Branch 2 not taken.
|
41798 | satellites.insert(satId); |
33 |
1/2✓ Branch 1 taken 41798 times.
✗ Branch 2 not taken.
|
41798 | systems.insert(satId.satSys); |
34 | |||
35 | 41798 | const auto& recvObs = sigObs.recvObs.begin(); | |
36 |
2/2✓ Branch 7 taken 82720 times.
✓ Branch 8 taken 41798 times.
|
124518 | for (const auto& obs : recvObs->second->obs) |
37 | { | ||
38 | 82720 | auto obsType = static_cast<size_t>(obs.first); | |
39 |
1/2✓ Branch 1 taken 82720 times.
✗ Branch 2 not taken.
|
82720 | nObservables.at(obsType)++; |
40 |
2/4✓ Branch 1 taken 82720 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 82720 times.
✗ Branch 5 not taken.
|
82720 | nMeasUniqueSat.at(obsType).insert(satId); |
41 | } | ||
42 | } | ||
43 | |||
44 |
2/2✓ Branch 0 taken 3381 times.
✓ Branch 1 taken 1127 times.
|
4508 | for (size_t obsType = 0; obsType < GnssObs::ObservationType_COUNT; obsType++) |
45 | { | ||
46 |
2/4✓ Branch 1 taken 3381 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 3381 times.
✗ Branch 6 not taken.
|
3381 | nObservablesUniqueSatellite.at(obsType) = nMeasUniqueSat.at(obsType).size(); |
47 | } | ||
48 | |||
49 | #if LOG_LEVEL <= LOG_LEVEL_DATA | ||
50 | LOG_DATA("{}: systems: [{}]", nameId, fmt::join(systems, ", ")); | ||
51 | LOG_DATA("{}: satellites: [{}]", nameId, fmt::join(satellites, ", ")); | ||
52 | std::string observables; | ||
53 | std::string observablesUnique; | ||
54 | for (size_t obsType = 0; obsType < GnssObs::ObservationType_COUNT; obsType++) | ||
55 | { | ||
56 | observables += fmt::format("{} {}", nObservables.at(obsType), static_cast<GnssObs::ObservationType>(obsType)); | ||
57 | observablesUnique += fmt::format("{} {} [{}]", nObservablesUniqueSatellite.at(obsType), | ||
58 | static_cast<GnssObs::ObservationType>(obsType), fmt::join(nMeasUniqueSat.at(obsType), ", ")); | ||
59 | if (obsType < GnssObs::ObservationType_COUNT - 1) | ||
60 | { | ||
61 | observables += ", "; | ||
62 | observablesUnique += ", "; | ||
63 | } | ||
64 | } | ||
65 | LOG_DATA("{}: nObservables: {}", nameId, observables); | ||
66 | LOG_DATA("{}: nObservablesUniqueSatellite: {}", nameId, observablesUnique); | ||
67 | #endif | ||
68 | 1127 | } | |
69 | |||
70 | ✗ | bool Observations::removeSignal(const SatSigId& satSigId, [[maybe_unused]] const std::string& nameId) | |
71 | { | ||
72 | ✗ | bool somethingRemoved = false; | |
73 | ✗ | if (signals.contains(satSigId)) | |
74 | { | ||
75 | LOG_DATA("{}: Erasing signal [{}]", nameId, satSigId); | ||
76 | ✗ | signals.erase(satSigId); | |
77 | ✗ | somethingRemoved = true; | |
78 | } | ||
79 | ✗ | if (somethingRemoved) { recalcObservableCounts(nameId); } | |
80 | ✗ | return somethingRemoved; | |
81 | } | ||
82 | |||
83 | ✗ | bool Observations::removeSignal(const SatSigId& satSigId, const GnssObs::ObservationType& obsType, [[maybe_unused]] const std::string& nameId) | |
84 | { | ||
85 | ✗ | bool somethingRemoved = false; | |
86 | ✗ | if (signals.contains(satSigId)) | |
87 | { | ||
88 | LOG_DATA("{}: Erasing signal [{}][{}]", nameId, satSigId, obsType); | ||
89 | ✗ | size_t emptyReceiver = 0; | |
90 | ✗ | for (auto& recvObs : signals.at(satSigId).recvObs) | |
91 | { | ||
92 | ✗ | if (recvObs.second->obs.contains(obsType)) | |
93 | { | ||
94 | ✗ | recvObs.second->obs.erase(obsType); | |
95 | } | ||
96 | ✗ | if (recvObs.second->obs.empty()) { emptyReceiver++; } | |
97 | } | ||
98 | ✗ | if (emptyReceiver == signals.at(satSigId).recvObs.size()) | |
99 | { | ||
100 | ✗ | signals.erase(satSigId); | |
101 | } | ||
102 | ✗ | somethingRemoved = true; | |
103 | } | ||
104 | ✗ | if (somethingRemoved) { recalcObservableCounts(nameId); } | |
105 | ✗ | return somethingRemoved; | |
106 | } | ||
107 | |||
108 | ✗ | bool Observations::removeSatellite(const SatId& satId, [[maybe_unused]] const std::string& nameId) | |
109 | { | ||
110 | ✗ | std::vector<SatSigId> toRemove; | |
111 | ✗ | for (const auto& signal : signals) | |
112 | { | ||
113 | ✗ | if (signal.first.toSatId() == satId) | |
114 | { | ||
115 | ✗ | toRemove.push_back(signal.first); | |
116 | } | ||
117 | } | ||
118 | ✗ | for (const auto& satSigId : toRemove) | |
119 | { | ||
120 | LOG_DATA("{}: Erasing signal [{}]", nameId, satSigId); | ||
121 | ✗ | signals.erase(satSigId); | |
122 | } | ||
123 | ✗ | if (!toRemove.empty()) { recalcObservableCounts(nameId); } | |
124 | ✗ | return !toRemove.empty(); | |
125 | ✗ | } | |
126 | |||
127 | } // namespace NAV | ||
128 |