Add drivetrain replay application
This adds a basic example application for replaying the 2019 drivetrain.
I also make it so that the LogReader will stop event processing once it
is done.
Change-Id: Icd0187f240191b8d23e31608eb6e5a5a49fd068c
diff --git a/aos/events/logging/logger.cc b/aos/events/logging/logger.cc
index 486cda9..d71c2d2 100644
--- a/aos/events/logging/logger.cc
+++ b/aos/events/logging/logger.cc
@@ -307,6 +307,10 @@
}
timer_handler_ = event_loop_->AddTimer([this]() {
+ if (sorted_message_reader_.active_channel_count() == 0u) {
+ event_loop_factory_->Exit();
+ return;
+ }
monotonic_clock::time_point channel_timestamp;
int channel_index;
FlatbufferVector<MessageHeader> channel_data =
@@ -358,6 +362,11 @@
if (sorted_message_reader_.active_channel_count() > 0u) {
timer_handler_->Setup(sorted_message_reader_.oldest_message().first);
+ } else {
+ // Set a timer up immediately after now to die. If we don't do this, then
+ // the senders waiting on the message we just read will never get called.
+ timer_handler_->Setup(monotonic_now + event_loop_factory_->send_delay() +
+ std::chrono::nanoseconds(1));
}
});
diff --git a/aos/events/simulated_event_loop.cc b/aos/events/simulated_event_loop.cc
index 1dfb3af..bfe0de7 100644
--- a/aos/events/simulated_event_loop.cc
+++ b/aos/events/simulated_event_loop.cc
@@ -467,6 +467,10 @@
}
}
+std::chrono::nanoseconds SimulatedEventLoopFactory::send_delay() const {
+ return send_delay_;
+}
+
void SimulatedEventLoop::MakeRawWatcher(
const Channel *channel,
std::function<void(const Context &channel, const void *message)> watcher) {
diff --git a/aos/events/simulated_event_loop.h b/aos/events/simulated_event_loop.h
index db0b840..99450a3 100644
--- a/aos/events/simulated_event_loop.h
+++ b/aos/events/simulated_event_loop.h
@@ -71,6 +71,7 @@
// Sets the simulated send delay for the factory.
void set_send_delay(std::chrono::nanoseconds send_delay);
+ std::chrono::nanoseconds send_delay() const;
// Returns the node that this factory is running as, or nullptr if this is a
// single node setup.