Skip to content

Commit

Permalink
lgtm
Browse files Browse the repository at this point in the history
  • Loading branch information
deanlee committed Dec 22, 2021
1 parent f9439e2 commit 81eed68
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
8 changes: 4 additions & 4 deletions selfdrive/ui/replay/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand All @@ -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());
}
Expand Down
15 changes: 6 additions & 9 deletions selfdrive/ui/replay/replay.cc
Original file line number Diff line number Diff line change
Expand Up @@ -152,15 +152,12 @@ std::optional<uint64_t> 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;
}
}
}
Expand Down

0 comments on commit 81eed68

Please sign in to comment.