cabana: make highlight fade time independent of playback speed (#27951)

old-commit-hash: fbe70c43a4
beeps
Willem Melching 2 years ago committed by GitHub
parent 48eb186464
commit ca245b4973
  1. 8
      tools/cabana/streams/abstractstream.cc
  2. 3
      tools/cabana/streams/abstractstream.h
  3. 1
      tools/cabana/streams/livestream.h
  4. 1
      tools/cabana/streams/replaystream.h

@ -33,7 +33,7 @@ bool AbstractStream::updateEvent(const Event *event) {
for (const auto &c : event->event.getCan()) {
MessageId id = {.source = c.getSrc(), .address = c.getAddress()};
const auto dat = c.getDat();
all_msgs[id].compute((const char *)dat.begin(), dat.size(), current_sec);
all_msgs[id].compute((const char *)dat.begin(), dat.size(), current_sec, getSpeed());
if (!new_msgs->contains(id)) {
new_msgs->insert(id, {});
}
@ -74,7 +74,7 @@ void AbstractStream::updateLastMsgsTo(double sec) {
if (it != e.crend()) {
double ts = it->mono_time / 1e9 - routeStartTime();
auto &m = all_msgs[id];
m.compute((const char *)it->dat, it->size, ts);
m.compute((const char *)it->dat, it->size, ts, getSpeed());
m.count = std::distance(it, e.crend());
m.freq = m.count / std::max(1.0, ts);
}
@ -138,7 +138,7 @@ static inline QColor blend(const QColor &a, const QColor &b) {
return QColor((a.red() + b.red()) / 2, (a.green() + b.green()) / 2, (a.blue() + b.blue()) / 2, (a.alpha() + b.alpha()) / 2);
}
void CanData::compute(const char *can_data, const int size, double current_sec, uint32_t in_freq) {
void CanData::compute(const char *can_data, const int size, double current_sec, double playback_speed, uint32_t in_freq) {
ts = current_sec;
++count;
freq = in_freq == 0 ? count / std::max(1.0, current_sec) : in_freq;
@ -178,7 +178,7 @@ void CanData::compute(const char *can_data, const int size, double current_sec,
last_change_t[i] = ts;
} else {
// Fade out
float alpha_delta = 1.0 / (freq + 1) / fade_time;
float alpha_delta = 1.0 / (freq + 1) / (fade_time * playback_speed);
colors[i].setAlphaF(std::max(0.0, colors[i].alphaF() - alpha_delta));
}
}

@ -13,7 +13,7 @@
#include "tools/replay/replay.h"
struct CanData {
void compute(const char *dat, const int size, double current_sec, uint32_t in_freq = 0);
void compute(const char *dat, const int size, double current_sec, double playback_speed, uint32_t in_freq = 0);
double ts = 0.;
uint32_t count = 0;
@ -51,6 +51,7 @@ public:
virtual VisionStreamType visionStreamType() const { return VISION_STREAM_ROAD; }
virtual const Route *route() const { return nullptr; }
virtual void setSpeed(float speed) {}
virtual double getSpeed() { return 1; }
virtual bool isPaused() const { return false; }
virtual void pause(bool pause) {}
virtual const std::vector<Event*> *rawEvents() const { return nullptr; }

@ -11,6 +11,7 @@ public:
inline double routeStartTime() const override { return start_ts / (double)1e9; }
inline double currentSec() const override { return (current_ts - start_ts) / (double)1e9; }
void setSpeed(float speed) override { speed_ = std::min<float>(1.0, speed); }
double getSpeed() override { return speed_; }
bool isPaused() const override { return pause_; }
void pause(bool pause) override;

@ -21,6 +21,7 @@ public:
inline QDateTime currentDateTime() const override { return replay->currentDateTime(); }
inline const Route *route() const override { return replay->route(); }
inline void setSpeed(float speed) override { replay->setSpeed(speed); }
inline float getSpeed() const { return replay->getSpeed(); }
inline bool isPaused() const override { return replay->isPaused(); }
void pause(bool pause) override;
const std::vector<Event*> *rawEvents() const override { return replay->events(); }

Loading…
Cancel
Save