From af206bb5fc1a255b48dbab344a2bba7581535cb0 Mon Sep 17 00:00:00 2001
From: Tom Rondeau <trondeau@vt.edu>
Date: Tue, 16 Jul 2013 14:55:28 -0700
Subject: controlport: Added probes for byte, short, and int data types
 (ctrlport_probe2_x).

Had to add some more plumbing to ControlPort to handle different data
types to support the new probes.

TODO: in 3.8, we will remove ctrlport_probe_c and make a single GRC
file for all data types and remove blocks_ctrlport_probe2_c.xml.
---
 .../python/gnuradio/ctrlport/GrDataPlotter.py         | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

(limited to 'gnuradio-runtime/python/gnuradio/ctrlport/GrDataPlotter.py')

diff --git a/gnuradio-runtime/python/gnuradio/ctrlport/GrDataPlotter.py b/gnuradio-runtime/python/gnuradio/ctrlport/GrDataPlotter.py
index b240dcb8f2..069f3d90ff 100644
--- a/gnuradio-runtime/python/gnuradio/ctrlport/GrDataPlotter.py
+++ b/gnuradio-runtime/python/gnuradio/ctrlport/GrDataPlotter.py
@@ -24,7 +24,7 @@ from gnuradio import gr
 from gnuradio import blocks
 from gnuradio import filter
 from gnuradio.ctrlport import GNURadio
-import sys, time
+import sys, time, struct
 
 try:
     from gnuradio import qtgui
@@ -426,12 +426,17 @@ class GrDataPlotterValueTable:
         numItems = self.treeWidget.topLevelItemCount()
 
         # The input knobs variable is a dict of stats to display in the tree.
-
-        # Update tree stat values with new values found in knobs.
-        # Track found keys and track keys in tree that are not in input knobs.
-        for i in range(0, numItems):
-            item = self.treeWidget.topLevelItem(i)
-
+        self.treeWidget.clear()
+        for k, v in knobs.iteritems():
+            val = v.value
+            if(type(val) == GNURadio.complex):
+                val = val.re + val.im*1j
+
+            # If it's a byte stream, Python thinks it's a string.
+            # Unpack and convert to floats for plotting.
+            # Ignore the edge list knob if it's being exported
+            elif(type(val) == str and k.find('edge list') == -1):
+                val = struct.unpack(len(val)*'b', val)
             # itemKey is the text in the first column of a QTreeWidgetItem
             itemKey = str(item.text(0))
             if itemKey in knobs.keys():
-- 
cgit v1.2.3