|
|
@ -119,14 +119,15 @@ template <class InputIt> |
|
|
|
std::deque<HistoryLogModel::Message> HistoryLogModel::fetchData(InputIt first, InputIt last, uint64_t min_time) { |
|
|
|
std::deque<HistoryLogModel::Message> HistoryLogModel::fetchData(InputIt first, InputIt last, uint64_t min_time) { |
|
|
|
std::deque<HistoryLogModel::Message> msgs; |
|
|
|
std::deque<HistoryLogModel::Message> msgs; |
|
|
|
QVector<double> values(sigs.size()); |
|
|
|
QVector<double> values(sigs.size()); |
|
|
|
for (; first != last && first->mono_time > min_time; ++first) { |
|
|
|
for (; first != last && (*first)->mono_time > min_time; ++first) { |
|
|
|
|
|
|
|
const CanEvent *e = *first; |
|
|
|
for (int i = 0; i < sigs.size(); ++i) { |
|
|
|
for (int i = 0; i < sigs.size(); ++i) { |
|
|
|
values[i] = get_raw_value(first->dat, first->size, *sigs[i]); |
|
|
|
values[i] = get_raw_value(e->dat, e->size, *sigs[i]); |
|
|
|
} |
|
|
|
} |
|
|
|
if (!filter_cmp || filter_cmp(values[filter_sig_idx], filter_value)) { |
|
|
|
if (!filter_cmp || filter_cmp(values[filter_sig_idx], filter_value)) { |
|
|
|
auto &m = msgs.emplace_back(); |
|
|
|
auto &m = msgs.emplace_back(); |
|
|
|
m.mono_time = first->mono_time; |
|
|
|
m.mono_time = e->mono_time; |
|
|
|
m.data = QByteArray((const char *)first->dat, first->size); |
|
|
|
m.data = QByteArray((const char *)e->dat, e->size); |
|
|
|
m.sig_values = values; |
|
|
|
m.sig_values = values; |
|
|
|
if (msgs.size() >= batch_size && min_time == 0) { |
|
|
|
if (msgs.size() >= batch_size && min_time == 0) { |
|
|
|
return msgs; |
|
|
|
return msgs; |
|
|
@ -141,23 +142,28 @@ std::deque<HistoryLogModel::Message> HistoryLogModel::fetchData(uint64_t from_ti |
|
|
|
const auto freq = can->lastMessage(msg_id).freq; |
|
|
|
const auto freq = can->lastMessage(msg_id).freq; |
|
|
|
const bool update_colors = !display_signals_mode || sigs.empty(); |
|
|
|
const bool update_colors = !display_signals_mode || sigs.empty(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const auto speed = can->getSpeed(); |
|
|
|
if (dynamic_mode) { |
|
|
|
if (dynamic_mode) { |
|
|
|
auto first = std::upper_bound(events.rbegin(), events.rend(), CanEvent{.mono_time=from_time}, std::greater<CanEvent>()); |
|
|
|
auto first = std::upper_bound(events.rbegin(), events.rend(), from_time, [](uint64_t ts, auto e) { |
|
|
|
|
|
|
|
return ts > e->mono_time; |
|
|
|
|
|
|
|
}); |
|
|
|
auto msgs = fetchData(first, events.rend(), min_time); |
|
|
|
auto msgs = fetchData(first, events.rend(), min_time); |
|
|
|
if (update_colors && (min_time > 0 || messages.empty())) { |
|
|
|
if (update_colors && (min_time > 0 || messages.empty())) { |
|
|
|
for (auto it = msgs.rbegin(); it != msgs.rend(); ++it) { |
|
|
|
for (auto it = msgs.rbegin(); it != msgs.rend(); ++it) { |
|
|
|
hex_colors.compute(it->data.data(), it->data.size(), it->mono_time / (double)1e9, freq); |
|
|
|
hex_colors.compute(it->data.data(), it->data.size(), it->mono_time / (double)1e9, speed, freq); |
|
|
|
it->colors = hex_colors.colors; |
|
|
|
it->colors = hex_colors.colors; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return msgs; |
|
|
|
return msgs; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
assert(min_time == 0); |
|
|
|
assert(min_time == 0); |
|
|
|
auto first = std::upper_bound(events.begin(), events.end(), CanEvent{.mono_time=from_time}); |
|
|
|
auto first = std::upper_bound(events.cbegin(), events.cend(), from_time, [](uint64_t ts, auto e) { |
|
|
|
auto msgs = fetchData(first, events.end(), 0); |
|
|
|
return ts < e->mono_time; |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
auto msgs = fetchData(first, events.cend(), 0); |
|
|
|
if (update_colors) { |
|
|
|
if (update_colors) { |
|
|
|
for (auto it = msgs.begin(); it != msgs.end(); ++it) { |
|
|
|
for (auto it = msgs.begin(); it != msgs.end(); ++it) { |
|
|
|
hex_colors.compute(it->data.data(), it->data.size(), it->mono_time / (double)1e9, freq); |
|
|
|
hex_colors.compute(it->data.data(), it->data.size(), it->mono_time / (double)1e9, speed, freq); |
|
|
|
it->colors = hex_colors.colors; |
|
|
|
it->colors = hex_colors.colors; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|