Recreate remote timestamp logging in LogReader
It is useful to be able to log data, replay it into a simulation, and
then recreate a log again. To do this, we need remote timestamps to
work correctly.
When LogReader replays a forwarded message, it now creates the
corresponding MessageHeader and publishes it. It also tracks the queue
indicies such that the message is valid and can be logged.
Logger also translates channel indices as well when the logging config
is not the event loop config.
Change-Id: Iff6175a204b191c6f43a1d73ffce5b542925860c
diff --git a/aos/configuration.cc b/aos/configuration.cc
index c74234e..f466ee0 100644
--- a/aos/configuration.cc
+++ b/aos/configuration.cc
@@ -975,5 +975,40 @@
return result;
}
+std::vector<const Node *> TimestampNodes(const Configuration *config,
+ const Node *my_node) {
+ if (!configuration::MultiNode(config)) {
+ CHECK(my_node == nullptr);
+ return std::vector<const Node *>{};
+ }
+
+ std::set<const Node *> timestamp_logger_nodes;
+ for (const Channel *channel : *config->channels()) {
+ if (!configuration::ChannelIsSendableOnNode(channel, my_node)) {
+ continue;
+ }
+ if (!channel->has_destination_nodes()) {
+ continue;
+ }
+ for (const Connection *connection : *channel->destination_nodes()) {
+ const Node *other_node =
+ configuration::GetNode(config, connection->name()->string_view());
+
+ if (configuration::ConnectionDeliveryTimeIsLoggedOnNode(connection,
+ my_node)) {
+ VLOG(1) << "Timestamps are logged from "
+ << FlatbufferToJson(other_node);
+ timestamp_logger_nodes.insert(other_node);
+ }
+ }
+ }
+
+ std::vector<const Node *> result;
+ for (const Node *node : timestamp_logger_nodes) {
+ result.emplace_back(node);
+ }
+ return result;
+}
+
} // namespace configuration
} // namespace aos