Implemented qt port + e2e

This commit is contained in:
Martino Ferrari
2026-06-26 09:11:10 +02:00
parent 0d7d8f396b
commit 4702d0a217
146 changed files with 57272 additions and 128 deletions
+30 -6
View File
@@ -61,6 +61,11 @@ struct SignalBuffer {
/**
* @brief Read all points in [t0, t1] into tOut/vOut.
*
* Assumes points were pushed in non-decreasing time order (true for the
* StreamHub live stream) and binary-searches the logical [0,count) index
* space so the cost is O(log count + window) rather than O(count) — this
* keeps per-frame rendering cheap even with a million-point ring.
* @return Number of points written.
*/
size_t readRange(double t0, double t1,
@@ -69,13 +74,32 @@ struct SignalBuffer {
vOut.clear();
if (count == 0) { return 0; }
size_t startIdx = (head + capacity - count) % capacity;
for (size_t i = 0; i < count; i++) {
const size_t startIdx = (head + capacity - count) % capacity;
/* time at logical index i (0 = oldest, count-1 = newest) */
// first index with t >= t0
size_t lo = 0, hi = count;
while (lo < hi) {
size_t mid = lo + (hi - lo) / 2;
if (t[(startIdx + mid) % capacity] < t0) { lo = mid + 1; }
else { hi = mid; }
}
const size_t begin = lo;
// first index with t > t1
lo = begin; hi = count;
while (lo < hi) {
size_t mid = lo + (hi - lo) / 2;
if (t[(startIdx + mid) % capacity] <= t1) { lo = mid + 1; }
else { hi = mid; }
}
const size_t end = lo;
if (end <= begin) { return 0; }
tOut.reserve(end - begin);
vOut.reserve(end - begin);
for (size_t i = begin; i < end; i++) {
size_t idx = (startIdx + i) % capacity;
if (t[idx] >= t0 && t[idx] <= t1) {
tOut.push_back(t[idx]);
vOut.push_back(v[idx]);
}
tOut.push_back(t[idx]);
vOut.push_back(v[idx]);
}
return tOut.size();
}