Support plotting log files with only one direction
We were looking for 1 of the 2 direction's CSV files, and then assuming
that meant the other was or was not there. For a log file only going 1
way this was resulting in the data being skipped, and nothing being
shown anywhere.
Change-Id: I225094b9ef93628558db65945b38298724de61ac
Signed-off-by: Austin Schuh <austin.linux@gmail.com>
diff --git a/aos/events/logging/timestamp_plot.cc b/aos/events/logging/timestamp_plot.cc
index 1239eb2..ddc8381 100644
--- a/aos/events/logging/timestamp_plot.cc
+++ b/aos/events/logging/timestamp_plot.cc
@@ -48,9 +48,13 @@
std::string_view node1, std::string_view node2, bool flip) {
std::vector<double> samplefile12_t;
std::vector<double> samplefile12_o;
+ const std::string path = SampleFile(node1, node2);
- const std::string file =
- aos::util::ReadFileToStringOrDie(SampleFile(node1, node2));
+ if (!aos::util::PathExists(path)) {
+ return {};
+ }
+
+ const std::string file = aos::util::ReadFileToStringOrDie(path);
bool first = true;
std::vector<std::string_view> lines = absl::StrSplit(file, '\n');
samplefile12_t.reserve(lines.size());
@@ -91,7 +95,8 @@
for (size_t j = 0; j < i; ++j) {
const std::string_view node1 = nodes[j];
const std::string_view node2 = nodes[i];
- if (aos::util::PathExists(SampleFile(node1, node2))) {
+ if (aos::util::PathExists(SampleFile(node1, node2)) ||
+ aos::util::PathExists(SampleFile(node2, node1))) {
result.emplace_back(node1, node2);
LOG(INFO) << "Found pairing " << node1 << ", " << node2;
}
@@ -152,9 +157,13 @@
std::string_view node1, std::string_view node2, bool flip) {
std::vector<double> samplefile12_t;
std::vector<double> samplefile12_o;
+ const std::string path = absl::StrCat("/tmp/timestamp_noncausal_", node1, "_", node2, ".csv");
- const std::string file = aos::util::ReadFileToStringOrDie(
- absl::StrCat("/tmp/timestamp_noncausal_", node1, "_", node2, ".csv"));
+ if (!aos::util::PathExists(path)) {
+ return {};
+ }
+
+ const std::string file = aos::util::ReadFileToStringOrDie(path);
bool first = true;
std::vector<std::string_view> lines = absl::StrSplit(file, '\n');
samplefile12_t.reserve(lines.size());
@@ -306,9 +315,14 @@
NodePlotter plotter;
if (FLAGS_all) {
- for (std::pair<std::string, std::string> ab : NodeConnections()) {
+ const std::vector<std::pair<std::string, std::string>> connections =
+ NodeConnections();
+ for (std::pair<std::string, std::string> ab : connections) {
plotter.AddNodes(ab.first, ab.second);
}
+ if (connections.size() == 0) {
+ LOG(WARNING) << "No connections found, is something wrong?";
+ }
} else {
CHECK_EQ(argc, 3);