MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / readAxisData

Function readAxisData

app/src/Sessions/ReportData.cpp:293–328  ·  view source on GitHub ↗

* @brief Reads a query result set into parallel DSP ring buffers. */

Source from the content-addressed store, hash-verified

291 * @brief Reads a query result set into parallel DSP ring buffers.
292 */
293static std::size_t readAxisData(QSqlQuery& rows,
294 qint64 originNs,
295 qint64 reservation,
296 DSP::AxisData& x,
297 DSP::AxisData& y,
298 double& globalMin,
299 double& globalMax)
300{
301 const std::size_t capacity = static_cast<std::size_t>(std::max<qint64>(reservation, 1));
302 x.resize(capacity);
303 y.resize(capacity);
304 x.clear();
305 y.clear();
306
307 globalMin = std::numeric_limits<double>::infinity();
308 globalMax = -std::numeric_limits<double>::infinity();
309 std::size_t count = 0;
310
311 constexpr double kInvNs = 1.0 / 1.0e9;
312 while (rows.next()) {
313 const double val = SerialStudio::toDouble(rows.value(1));
314 if (!std::isfinite(val))
315 continue;
316
317 const qint64 ts = rows.value(0).toLongLong();
318 const double tSec = static_cast<double>(ts - originNs) * kInvNs;
319 x.push(tSec);
320 y.push(val);
321
322 globalMin = std::min(globalMin, val);
323 globalMax = std::max(globalMax, val);
324 ++count;
325 }
326
327 return count;
328}
329
330/**
331 * @brief Appends @p index to @p indices when it is not already present.

Callers 1

loadChartSeriesMethod · 0.85

Calls 6

isfiniteFunction · 0.85
nextMethod · 0.80
pushMethod · 0.80
resizeMethod · 0.45
clearMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected