From 97121a8f517001f052d84ae1b42c22a3a9ce1f92 Mon Sep 17 00:00:00 2001 From: deanlee Date: Wed, 22 Dec 2021 17:40:59 +0800 Subject: [PATCH] lgtm --- selfdrive/ui/replay/main.cc | 8 ++++---- selfdrive/ui/replay/replay.cc | 18 ++++++------------ 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/selfdrive/ui/replay/main.cc b/selfdrive/ui/replay/main.cc index 7ede23d0a5b22a..ebd0d0f0aca009 100644 --- a/selfdrive/ui/replay/main.cc +++ b/selfdrive/ui/replay/main.cc @@ -59,6 +59,10 @@ void keyboardThread(Replay *replay_) { qDebug() << "invalid argument"; } getch(); // remove \n from entering seek + } else if (c == 'e') { + replay_->seekToFlag(FindFlag::nextEngagement); + } else if (c == 'd') { + replay_->seekToFlag(FindFlag::nextDisEngagement); } else if (c == 'm') { replay_->seekTo(+60, true); } else if (c == 'M') { @@ -69,10 +73,6 @@ void keyboardThread(Replay *replay_) { replay_->seekTo(-10, true); } else if (c == 'G') { replay_->seekTo(0, true); - } else if (c == 'e') { - replay_->seekToFlag(FindFlag::nextEngagement); - } else if (c == 'd') { - replay_->seekToFlag(FindFlag::nextDisEngagement); } else if (c == ' ') { replay_->pause(!replay_->isPaused()); } diff --git a/selfdrive/ui/replay/replay.cc b/selfdrive/ui/replay/replay.cc index cafcc560d8a3bd..f5744227cf19d6 100644 --- a/selfdrive/ui/replay/replay.cc +++ b/selfdrive/ui/replay/replay.cc @@ -124,9 +124,6 @@ void Replay::doSeekToFlag(FindFlag flag) { if (auto next = find(flag)) { uint64_t tm = *next - 2 * 1e9; // seek to 2 seconds before next if (tm <= cur_mono_time_) { - if (flag == FindFlag::nextEngagement) { - qInfo() << "already in engagement"; - } return true; } @@ -152,15 +149,12 @@ std::optional Replay::find(FindFlag flag) { if (!log.load(route_->at(n).qlog.toStdString(), nullptr, cache_to_local, 0, 3)) continue; for (const Event *e : log.events) { - if (e->mono_time > cur_mono_time_) { - if (flag == FindFlag::nextEngagement) { - if (e->which == cereal::Event::Which::CONTROLS_STATE && e->event.getControlsState().getEnabled()) { - return e->mono_time; - } - } else if (flag == FindFlag::nextDisEngagement) { - if (e->which == cereal::Event::Which::CONTROLS_STATE && !e->event.getControlsState().getEnabled()) { - return e->mono_time; - } + if (e->mono_time > cur_mono_time_ && e->which == cereal::Event::Which::CONTROLS_STATE) { + const auto cs = e->event.getControlsState(); + if (flag == FindFlag::nextEngagement && cs.getEnabled()) { + return e->mono_time; + } else if (flag == FindFlag::nextDisEngagement && !cs.getEnabled()) { + return e->mono_time; } } }