Add support for plotting boolean values.
Append a "-b" and then a float to plot boolean values as going
between 0 and that value.
For example, a plot definition of:
fridge status zeroed -b 0.5
would plot the zeroed flag as 0 when it's false and 0.5 when it's true.
Change-Id: Ie118d02c2079a92b43756c664a3927ace468eebe
diff --git a/frc971/analysis/analysis.py b/frc971/analysis/analysis.py
index 66a4dd4..e477bdd 100755
--- a/frc971/analysis/analysis.py
+++ b/frc971/analysis/analysis.py
@@ -49,6 +49,14 @@
binary = key[0]
struct_instance_name = key[1]
data_search_path = key[2]
+ boolean_multiplier = None
+
+ # If the plot definition line ends with a "-b X" where X is a number then
+ # that number gets drawn when the value is True. Zero gets drawn when the
+ # value is False.
+ if len(data_search_path) >= 2 and data_search_path[-2] == '-b':
+ boolean_multiplier = float(data_search_path[-1])
+ data_search_path = data_search_path[:-2]
# Make sure that we're looking at the right binary structure instance.
if binary == pline.name:
@@ -60,7 +68,13 @@
for path in data_search_path:
data = data[path]
- value.Add(pline.time, data)
+ if boolean_multiplier is not None:
+ if data == 'T':
+ value.Add(pline.time, boolean_multiplier)
+ else:
+ value.Add(pline.time, 0)
+ else:
+ value.Add(pline.time, data)
def Plot(self, no_binary_in_legend):
"""