add delay to LoggerState StartLogging
In simulation, the log writer needs to start after the
constants message is sent. Add a delay of longer
than `aos::SimulatedEventLoopFactory::send_delay()` to ensure that
the StartLogging event occurs after the constants message
is written to the log.
Change-Id: I65bc5be359b1d11ebeed46c20fcc3ed015a93385
Signed-off-by: James Kuszmaul <james.kuszmaul@bluerivertech.com>
diff --git a/aos/util/simulation_logger.cc b/aos/util/simulation_logger.cc
index 513fa65..32ff706 100644
--- a/aos/util/simulation_logger.cc
+++ b/aos/util/simulation_logger.cc
@@ -15,7 +15,15 @@
event_loop_->SkipTimingReport();
}
event_loop_->SkipAosLog();
- event_loop_->OnRun([this]() { logger_->StartLogging(std::move(namer_)); });
+
+ // TODO (James, Maxwell) This shouldn't be necessary to have a delay here.
+ // We'd like to have the logger start as soon as the event loop starts. The
+ // logger must be started after (not on) `factory->send_delay()` amount of
+ // time. Keep this simple, use two of those delays.
+ TimerHandler *status_timer = event_loop_->AddTimer(
+ [this]() { logger_->StartLogging(std::move(namer_)); });
+ status_timer->Schedule(
+ monotonic_clock::time_point(factory->send_delay() * 2));
}
std::vector<std::unique_ptr<LoggerState>> MakeLoggersForNodes(