mirror of
https://github.com/brmlab/edubrm.git
synced 2025-06-08 12:53:59 +02:00
finish module B
This commit is contained in:
parent
03006e9d37
commit
854d40738f
6 changed files with 190 additions and 124 deletions
|
@ -25,7 +25,7 @@ class ModuleAWidget(QWidget):
|
|||
class ModuleA():
|
||||
|
||||
def __init__(self):
|
||||
self.title = 'Simple dynamo'
|
||||
self.title = 'Sources of Electricity'
|
||||
self.widget = ModuleAWidget()
|
||||
|
||||
def start(self):
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 17 KiB |
|
@ -1,4 +1,6 @@
|
|||
from PyQt4.QtGui import QWidget
|
||||
from PyQt4.QtGui import QGraphicsScene
|
||||
from PyQt4.QtGui import QPixmap
|
||||
from PyQt4.QtCore import pyqtSlot
|
||||
from PyQt4.QtCore import SIGNAL
|
||||
from PyQt4.QtCore import QObject
|
||||
|
@ -16,12 +18,29 @@ class ModuleBWidget(QWidget):
|
|||
self.timer = QTimer()
|
||||
QObject.connect(self.timer, SIGNAL("timeout()"), self.read_inputs)
|
||||
|
||||
self.scene_nobat = QGraphicsScene()
|
||||
self.scene_nobat.addPixmap(QPixmap('modules/ModuleB-nobat.png'))
|
||||
self.scene_off = QGraphicsScene()
|
||||
self.scene_off.addPixmap(QPixmap('modules/ModuleB-off.png'))
|
||||
self.scene_on = QGraphicsScene()
|
||||
self.scene_on.addPixmap(QPixmap('modules/ModuleB-on.png'))
|
||||
self.ui.widgetImg.setScene(self.scene_nobat)
|
||||
|
||||
def read_inputs(self):
|
||||
pass
|
||||
# r = self.dev.read()
|
||||
# v = r[0]/1023.0 * 3.3
|
||||
# self.ui.labelV.setText('{:0.3f} V'.format(v))
|
||||
# self.ui.progressV.setValue(1000*v)
|
||||
r = self.dev.read()
|
||||
us = r[1]/1023.0 * 3.3
|
||||
uc = r[2]/1023.0 * 3.3
|
||||
i = (us-uc)*10
|
||||
self.ui.labelUs.setText('Us = %0.3f V' % us)
|
||||
self.ui.labelUc.setText('Uc = %0.3f V' % uc)
|
||||
self.ui.labelI.setText('I = %0.2f mA' % i)
|
||||
if us < 1.5:
|
||||
self.ui.widgetImg.setScene(self.scene_nobat)
|
||||
else:
|
||||
if uc < 1.5:
|
||||
self.ui.widgetImg.setScene(self.scene_off)
|
||||
else:
|
||||
self.ui.widgetImg.setScene(self.scene_on)
|
||||
|
||||
class ModuleB():
|
||||
|
||||
|
|
|
@ -13,16 +13,64 @@
|
|||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="widgetImg" native="true">
|
||||
<widget class="QGraphicsView" name="widgetImg">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>10</y>
|
||||
<width>761</width>
|
||||
<height>511</height>
|
||||
<height>471</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="labelUs">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>490</y>
|
||||
<width>251</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Us = 0.000 V</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="labelUc">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>260</x>
|
||||
<y>490</y>
|
||||
<width>261</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Uc = 0.000 V</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="labelI">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>520</x>
|
||||
<y>490</y>
|
||||
<width>251</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>I = 0.000 mA</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
|
|
@ -6,6 +6,9 @@
|
|||
<file>icon.png</file>
|
||||
<file>modules/ModuleA.png</file>
|
||||
<file>modules/ModuleB.png</file>
|
||||
<file>modules/ModuleB-nobat.png</file>
|
||||
<file>modules/ModuleB-off.png</file>
|
||||
<file>modules/ModuleB-on.png</file>
|
||||
<file>modules/ModuleC.png</file>
|
||||
<file>modules/ModuleDebug.png</file>
|
||||
</qresource>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue