Allow using shortened channel names in foxglove_websocket
This makes the websocket server's defaults consistent with log_to_mcap.
By using shortened channel names, we make ti easier to reuse layouts
across nodes (e.g., this way, the /piX prefix will be removed for
the channels available on the current pi being debugged).
Change-Id: Ief1f0c5a8932425017b4718ec9f9d2bae1de2c72
Signed-off-by: James Kuszmaul <jabukuszmaul@gmail.com>
diff --git a/aos/util/foxglove_websocket_lib.h b/aos/util/foxglove_websocket_lib.h
index 9be2f61..7c326c2 100644
--- a/aos/util/foxglove_websocket_lib.h
+++ b/aos/util/foxglove_websocket_lib.h
@@ -24,9 +24,20 @@
kYes,
kNo,
};
+ // Whether to attempt to shorten channel names.
+ enum class CanonicalChannelNames {
+ // Just use the full, unambiguous, channel names.
+ kCanonical,
+ // Use GetChannelAliases() to determine the shortest possible name for the
+ // channel for the current node, and use that in the MCAP file. This makes
+ // it so that the channels in the resulting file are more likely to match
+ // the channel names that are used in "real" applications.
+ kShortened,
+ };
FoxgloveWebsocketServer(aos::EventLoop *event_loop, uint32_t port,
Serialization serialization,
- FetchPinnedChannels fetch_pinned_channels);
+ FetchPinnedChannels fetch_pinned_channels,
+ CanonicalChannelNames canonical_channels);
~FoxgloveWebsocketServer();
private:
@@ -47,6 +58,7 @@
aos::EventLoop *event_loop_;
const Serialization serialization_;
const FetchPinnedChannels fetch_pinned_channels_;
+ const CanonicalChannelNames canonical_channels_;
foxglove::websocket::Server server_;
// A map of fetchers for every single channel that could be subscribed to.
std::map<ChannelId, FetcherState> fetchers_;