Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

add charts to debug module as well

  • Loading branch information...
commit 7bdfecfbe7d0eebeb535a5755477a34b1c040c1b 1 parent 7370607
Pavol Rusnak authored May 08, 2011
45  software/modules/ModuleDebug.py
... ...
@@ -1,4 +1,8 @@
1 1
 from PyQt4.QtGui import QWidget
  2
+from PyQt4.QtGui import QGraphicsScene
  3
+from PyQt4.QtGui import QPainterPath
  4
+from PyQt4.QtGui import QPen
  5
+from PyQt4.QtGui import QColor
2 6
 from PyQt4.QtCore import pyqtSlot
3 7
 from PyQt4.QtCore import SIGNAL
4 8
 from PyQt4.QtCore import QObject
@@ -31,6 +35,9 @@ def __init__(self):
31 35
         self.timer = QTimer()
32 36
         QObject.connect(self.timer, SIGNAL("timeout()"), self.read_inputs)
33 37
 
  38
+        self.data1 = 100*[0.0]
  39
+        self.data2 = 100*[0.0]
  40
+
34 41
     @pyqtSlot(int)
35 42
     def on_dialPWM1_valueChanged(self, val):
36 43
         self.dev.pwm(1, val)
@@ -151,6 +158,44 @@ def read_inputs(self):
151 158
         self.ui.labelIO1.setText('IO1: ' + str(r[7]))
152 159
         self.ui.labelIO2.setText('IO2: ' + str(r[8]))
153 160
         self.ui.labelIO3.setText('IO3: ' + str(r[9]))
  161
+        v1 = -1
  162
+        if self.ui.comboChart1.currentIndex() > 0:
  163
+            v1 = r[self.ui.comboChart1.currentIndex() - 1]
  164
+        v2 = -1
  165
+        if self.ui.comboChart2.currentIndex() > 0:
  166
+            v2 = r[self.ui.comboChart2.currentIndex() - 1]
  167
+        if v1 != -1 or v2 != -1:
  168
+            self.chart(v1, v2)
  169
+
  170
+    def setup_scene(self, scene):
  171
+        scene.addLine(-5, 0, 205, 0)
  172
+        scene.addLine(-5, -512/6, 205, -512/6)
  173
+        scene.addLine(-5, -1023/6, 205, -1023/6)
  174
+        scene.addSimpleText('0').moveBy(-40, -10)
  175
+        scene.addSimpleText('512').moveBy(-40, -512/6-10)
  176
+        scene.addSimpleText('1023').moveBy(-40, -1023/6-10)
  177
+
  178
+    def chart(self, v1, v2):
  179
+        self.data1.pop(0)
  180
+        self.data2.pop(0)
  181
+        self.data1.append(v1)
  182
+        self.data2.append(v2)
  183
+        self.scene1 = QGraphicsScene()
  184
+        self.scene2 = QGraphicsScene()
  185
+        self.setup_scene(self.scene1)
  186
+        self.setup_scene(self.scene2)
  187
+        path = QPainterPath()
  188
+        path.moveTo(0,-self.data1[0]/6)
  189
+        for i in xrange(1,100):
  190
+            path.lineTo(2*(i+1), -self.data1[i]/6)
  191
+        self.scene1.addPath(path, QPen(QColor(0,0,255), 3))
  192
+        path = QPainterPath()
  193
+        path.moveTo(0,-self.data2[0]/6)
  194
+        for i in xrange(1,100):
  195
+            path.lineTo(2*(i+1), -self.data2[i]/6)
  196
+        self.scene2.addPath(path, QPen(QColor(0,0,255), 3))
  197
+        self.ui.chart1.setScene(self.scene1)
  198
+        self.ui.chart2.setScene(self.scene2)
154 199
 
155 200
 class ModuleDebug():
156 201
 
148  software/modules/ModuleDebug.ui
@@ -644,7 +644,7 @@
644 644
      <x>10</x>
645 645
      <y>270</y>
646 646
      <width>461</width>
647  
-     <height>161</height>
  647
+     <height>241</height>
648 648
     </rect>
649 649
    </property>
650 650
    <property name="title">
@@ -846,6 +846,152 @@
846 846
      <bool>true</bool>
847 847
     </property>
848 848
    </widget>
  849
+   <widget class="QComboBox" name="comboChart1">
  850
+    <property name="geometry">
  851
+     <rect>
  852
+      <x>90</x>
  853
+      <y>170</y>
  854
+      <width>85</width>
  855
+      <height>31</height>
  856
+     </rect>
  857
+    </property>
  858
+    <item>
  859
+     <property name="text">
  860
+      <string>none</string>
  861
+     </property>
  862
+    </item>
  863
+    <item>
  864
+     <property name="text">
  865
+      <string>AD0</string>
  866
+     </property>
  867
+    </item>
  868
+    <item>
  869
+     <property name="text">
  870
+      <string>AD1</string>
  871
+     </property>
  872
+    </item>
  873
+    <item>
  874
+     <property name="text">
  875
+      <string>AD2</string>
  876
+     </property>
  877
+    </item>
  878
+    <item>
  879
+     <property name="text">
  880
+      <string>AD3</string>
  881
+     </property>
  882
+    </item>
  883
+    <item>
  884
+     <property name="text">
  885
+      <string>AD4</string>
  886
+     </property>
  887
+    </item>
  888
+    <item>
  889
+     <property name="text">
  890
+      <string>AD5</string>
  891
+     </property>
  892
+    </item>
  893
+    <item>
  894
+     <property name="text">
  895
+      <string>AD6</string>
  896
+     </property>
  897
+    </item>
  898
+   </widget>
  899
+   <widget class="QComboBox" name="comboChart2">
  900
+    <property name="geometry">
  901
+     <rect>
  902
+      <x>290</x>
  903
+      <y>170</y>
  904
+      <width>85</width>
  905
+      <height>31</height>
  906
+     </rect>
  907
+    </property>
  908
+    <item>
  909
+     <property name="text">
  910
+      <string>none</string>
  911
+     </property>
  912
+    </item>
  913
+    <item>
  914
+     <property name="text">
  915
+      <string>AD0</string>
  916
+     </property>
  917
+    </item>
  918
+    <item>
  919
+     <property name="text">
  920
+      <string>AD1</string>
  921
+     </property>
  922
+    </item>
  923
+    <item>
  924
+     <property name="text">
  925
+      <string>AD2</string>
  926
+     </property>
  927
+    </item>
  928
+    <item>
  929
+     <property name="text">
  930
+      <string>AD3</string>
  931
+     </property>
  932
+    </item>
  933
+    <item>
  934
+     <property name="text">
  935
+      <string>AD4</string>
  936
+     </property>
  937
+    </item>
  938
+    <item>
  939
+     <property name="text">
  940
+      <string>AD5</string>
  941
+     </property>
  942
+    </item>
  943
+    <item>
  944
+     <property name="text">
  945
+      <string>AD6</string>
  946
+     </property>
  947
+    </item>
  948
+   </widget>
  949
+   <widget class="QLabel" name="labelChart1">
  950
+    <property name="geometry">
  951
+     <rect>
  952
+      <x>10</x>
  953
+      <y>170</y>
  954
+      <width>66</width>
  955
+      <height>31</height>
  956
+     </rect>
  957
+    </property>
  958
+    <property name="text">
  959
+     <string>Chart1:</string>
  960
+    </property>
  961
+   </widget>
  962
+   <widget class="QLabel" name="labelChart2">
  963
+    <property name="geometry">
  964
+     <rect>
  965
+      <x>210</x>
  966
+      <y>170</y>
  967
+      <width>66</width>
  968
+      <height>31</height>
  969
+     </rect>
  970
+    </property>
  971
+    <property name="text">
  972
+     <string>Chart2:</string>
  973
+    </property>
  974
+   </widget>
  975
+  </widget>
  976
+  <widget class="QGraphicsView" name="chart1">
  977
+   <property name="geometry">
  978
+    <rect>
  979
+     <x>480</x>
  980
+     <y>10</y>
  981
+     <width>291</width>
  982
+     <height>251</height>
  983
+    </rect>
  984
+   </property>
  985
+  </widget>
  986
+  <widget class="QGraphicsView" name="chart2">
  987
+   <property name="geometry">
  988
+    <rect>
  989
+     <x>480</x>
  990
+     <y>270</y>
  991
+     <width>291</width>
  992
+     <height>251</height>
  993
+    </rect>
  994
+   </property>
849 995
   </widget>
850 996
  </widget>
851 997
  <resources/>

0 notes on commit 7bdfecf

Please sign in to comment.
Something went wrong with that request. Please try again.