mirror of
https://github.com/brmlab/edubrm.git
synced 2025-06-07 20:34:00 +02:00
add charts to debug module as well
This commit is contained in:
parent
73706073da
commit
7bdfecfbe7
2 changed files with 192 additions and 1 deletions
|
@ -1,4 +1,8 @@
|
|||
from PyQt4.QtGui import QWidget
|
||||
from PyQt4.QtGui import QGraphicsScene
|
||||
from PyQt4.QtGui import QPainterPath
|
||||
from PyQt4.QtGui import QPen
|
||||
from PyQt4.QtGui import QColor
|
||||
from PyQt4.QtCore import pyqtSlot
|
||||
from PyQt4.QtCore import SIGNAL
|
||||
from PyQt4.QtCore import QObject
|
||||
|
@ -31,6 +35,9 @@ class ModuleDebugWidget(QWidget):
|
|||
self.timer = QTimer()
|
||||
QObject.connect(self.timer, SIGNAL("timeout()"), self.read_inputs)
|
||||
|
||||
self.data1 = 100*[0.0]
|
||||
self.data2 = 100*[0.0]
|
||||
|
||||
@pyqtSlot(int)
|
||||
def on_dialPWM1_valueChanged(self, val):
|
||||
self.dev.pwm(1, val)
|
||||
|
@ -151,6 +158,44 @@ class ModuleDebugWidget(QWidget):
|
|||
self.ui.labelIO1.setText('IO1: ' + str(r[7]))
|
||||
self.ui.labelIO2.setText('IO2: ' + str(r[8]))
|
||||
self.ui.labelIO3.setText('IO3: ' + str(r[9]))
|
||||
v1 = -1
|
||||
if self.ui.comboChart1.currentIndex() > 0:
|
||||
v1 = r[self.ui.comboChart1.currentIndex() - 1]
|
||||
v2 = -1
|
||||
if self.ui.comboChart2.currentIndex() > 0:
|
||||
v2 = r[self.ui.comboChart2.currentIndex() - 1]
|
||||
if v1 != -1 or v2 != -1:
|
||||
self.chart(v1, v2)
|
||||
|
||||
def setup_scene(self, scene):
|
||||
scene.addLine(-5, 0, 205, 0)
|
||||
scene.addLine(-5, -512/6, 205, -512/6)
|
||||
scene.addLine(-5, -1023/6, 205, -1023/6)
|
||||
scene.addSimpleText('0').moveBy(-40, -10)
|
||||
scene.addSimpleText('512').moveBy(-40, -512/6-10)
|
||||
scene.addSimpleText('1023').moveBy(-40, -1023/6-10)
|
||||
|
||||
def chart(self, v1, v2):
|
||||
self.data1.pop(0)
|
||||
self.data2.pop(0)
|
||||
self.data1.append(v1)
|
||||
self.data2.append(v2)
|
||||
self.scene1 = QGraphicsScene()
|
||||
self.scene2 = QGraphicsScene()
|
||||
self.setup_scene(self.scene1)
|
||||
self.setup_scene(self.scene2)
|
||||
path = QPainterPath()
|
||||
path.moveTo(0,-self.data1[0]/6)
|
||||
for i in xrange(1,100):
|
||||
path.lineTo(2*(i+1), -self.data1[i]/6)
|
||||
self.scene1.addPath(path, QPen(QColor(0,0,255), 3))
|
||||
path = QPainterPath()
|
||||
path.moveTo(0,-self.data2[0]/6)
|
||||
for i in xrange(1,100):
|
||||
path.lineTo(2*(i+1), -self.data2[i]/6)
|
||||
self.scene2.addPath(path, QPen(QColor(0,0,255), 3))
|
||||
self.ui.chart1.setScene(self.scene1)
|
||||
self.ui.chart2.setScene(self.scene2)
|
||||
|
||||
class ModuleDebug():
|
||||
|
||||
|
|
|
@ -644,7 +644,7 @@
|
|||
<x>10</x>
|
||||
<y>270</y>
|
||||
<width>461</width>
|
||||
<height>161</height>
|
||||
<height>241</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="title">
|
||||
|
@ -846,6 +846,152 @@
|
|||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QComboBox" name="comboChart1">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>90</x>
|
||||
<y>170</y>
|
||||
<width>85</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>none</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>AD0</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>AD1</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>AD2</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>AD3</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>AD4</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>AD5</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>AD6</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
<widget class="QComboBox" name="comboChart2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>290</x>
|
||||
<y>170</y>
|
||||
<width>85</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>none</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>AD0</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>AD1</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>AD2</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>AD3</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>AD4</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>AD5</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>AD6</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
<widget class="QLabel" name="labelChart1">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>170</y>
|
||||
<width>66</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Chart1:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="labelChart2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>210</x>
|
||||
<y>170</y>
|
||||
<width>66</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Chart2:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QGraphicsView" name="chart1">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>480</x>
|
||||
<y>10</y>
|
||||
<width>291</width>
|
||||
<height>251</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QGraphicsView" name="chart2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>480</x>
|
||||
<y>270</y>
|
||||
<width>291</width>
|
||||
<height>251</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue