-
Notifications
You must be signed in to change notification settings - Fork 0
/
wirock_gui.py
60 lines (46 loc) · 1.6 KB
/
wirock_gui.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
from PyQt4.QtCore import *
from PyQt4.QtGui import *
import sys
import wirock
from wirock_topblock import top_block
class MainDialog(QDialog, wirock.Ui_dialog):
def __init__(self, parent=None):
super(MainDialog, self).__init__(parent)
self.setupUi(self)
self.tb = top_block(dev_addr='addr=192.168.10.2')
self.connect(self.onButton, SIGNAL("clicked()"), self.turn_on)
self.connect(self.offButton, SIGNAL("clicked()"), self.turn_off)
def turn_on(self):
print "Turn on!"
self.refresh_tb()
self.tb.set_func("on")
self.tb.run()
def turn_off(self):
print "Turn off!"
self.refresh_tb()
self.tb.set_func("off")
self.tb.run()
def refresh_tb(self):
self.tb.set_device(self.devtypeBox.currentText(), str(self.devaddrEdit.text()))
self.tb.set_dip_conf(self.evaluate_dip())
self.tb.set_gain(int(self.gainSlider.value()))
self.tb.set_socket(str(self.comboBox.itemText(self.comboBox.currentIndex())))
def evaluate_dip(self):
dips = []
dips.append(self.checkBox_1.isChecked())
dips.append(self.checkBox_2.isChecked())
dips.append(self.checkBox_3.isChecked())
dips.append(self.checkBox_4.isChecked())
dips.append(self.checkBox_5.isChecked())
dip_config = ''
for dip in dips:
if dip:
dip_config += '1'
else:
dip_config += '0'
print "DIP config:", dip_config
return dip_config
app = QApplication(sys.argv)
form = MainDialog()
form.show()
app.exec_()