* @brief Updates linear plot data series for all active plot widgets. */
| 2146 | * @brief Updates linear plot data series for all active plot widgets. |
| 2147 | */ |
| 2148 | void UI::Dashboard::updateLineSeries(int sourceId) |
| 2149 | { |
| 2150 | Q_ASSERT(m_pltValues.size() == widgetCount(SerialStudio::DashboardPlot)); |
| 2151 | Q_ASSERT(m_activePlots.size() == widgetCount(SerialStudio::DashboardPlot)); |
| 2152 | |
| 2153 | auto fire = [sourceId](const LinePush& p) { |
| 2154 | for (const auto& c : p.consumers) { |
| 2155 | if (sourceId >= 0 && c.sourceId != sourceId) |
| 2156 | continue; |
| 2157 | |
| 2158 | if (*c.activeFlag) { |
| 2159 | p.buf->push(*p.value); |
| 2160 | return; |
| 2161 | } |
| 2162 | } |
| 2163 | }; |
| 2164 | |
| 2165 | for (const auto& p : m_yLinePushes) |
| 2166 | fire(p); |
| 2167 | |
| 2168 | for (const auto& p : m_xLinePushes) |
| 2169 | fire(p); |
| 2170 | |
| 2171 | auto feedSweep = [this](const TimePush& p) { |
| 2172 | auto sIt = m_plotSweep.find(p.plotIndex); |
| 2173 | if (sIt == m_plotSweep.end()) |
| 2174 | return; |
| 2175 | |
| 2176 | DSP::SweepEngine& sweep = sIt.value(); |
| 2177 | if (!sweep.enabled || sweep.back.empty()) |
| 2178 | return; |
| 2179 | |
| 2180 | const double st = sweep.advance(m_plotDisplayTimeSec, *p.value); |
| 2181 | if (st >= 0) |
| 2182 | sweep.back[0].appendDecimated(st, *p.value); |
| 2183 | }; |
| 2184 | |
| 2185 | for (const auto& p : m_timePushes) { |
| 2186 | auto rIt = m_plotTimeRings.find(p.plotIndex); |
| 2187 | if (rIt == m_plotTimeRings.end()) [[unlikely]] |
| 2188 | continue; |
| 2189 | |
| 2190 | for (const auto& c : p.consumers) { |
| 2191 | if (sourceId >= 0 && c.sourceId != sourceId) |
| 2192 | continue; |
| 2193 | |
| 2194 | if (*c.activeFlag) { |
| 2195 | rIt.value().appendDecimated(m_plotDisplayTimeSec, *p.value); |
| 2196 | feedSweep(p); |
| 2197 | break; |
| 2198 | } |
| 2199 | } |
| 2200 | } |
| 2201 | } |
| 2202 | |
| 2203 | /** |
| 2204 | * @brief Initializes the GPS series structure for all GPS widgets. |