-
Notifications
You must be signed in to change notification settings - Fork 0
/
VacuumControl.py
74 lines (61 loc) · 2.18 KB
/
VacuumControl.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
61
62
63
64
65
66
67
68
69
70
71
72
73
#
# Updated: 02/17/21
#
from PyQt5 import QtGui,QtCore,QtWidgets,uic
from PyQt5.QtCore import QThread,pyqtSignal
from pexpect import pxssh
import time,pexpect
import vacuumwindow #imports PyQt vacuum window
class VacuumWindow(QtWidgets.QMainWindow, vacuumwindow.Ui_VacummWindow):
#Widget definitions
def __init__(self, main):
self.main = main
super(VacuumWindow,self).__init__(main)
self.setupUi(self)
#Toggle backing, turbo, ion pumps [admin]
self.backing_btn.setCheckable(True)
self.backing_btn.setStyleSheet("background-color: #c9d1d1")
self.backing_btn.setStyleSheet("QPushButton:checked {background-color: #95fef9}") #blue/ON
#self.backing_btn.pressed.connect(
self.turbo_btn.setCheckable(True)
self.turbo_btn.setStyleSheet("background-color: #c9d1d1")
self.turbo_btn.setStyleSheet("QPushButton:checked {background-color: #95fef9}")
#self.turbo_btn.pressed.connect(self.main.vacuumthread.printing)
self.ion_btn.setCheckable(True)
self.ion_btn.setStyleSheet("background-color: #c9d1d1")
self.ion_btn.setStyleSheet("QPushButton:checked {background-color: #95fef9}")
#self.ion_btn.pressed.connect(self.main.vacuumthread.continuePrinting)
class Vacuum(QtCore.QThread):
signal = pyqtSignal('PyQt_PyObject')
def __init__(self,parent=None):
super(Vacuum,self).__init__(parent)
def run(self):
time.sleep(5)
start = time.time()
self.lnk = pxssh.pxssh()
hostname = '10.212.212.49'
username = 'fhire'
password = 'WIROfhire17'
self.lnk.login(hostname,username,password)
end = time.time()
print('Vacuum RPi connected. Time elapsed: '+str('%.2f'%(end-start))+" seconds")
self.lnk.sendline("cd ~/Desktop/vacuum_controller2")
self.lnk.sendline("python")
self.lnk.sendline("import vacuum_control")
self.lnk.sendline("tic = vacuum_control.TIC()")
print("Vacuum RPi - connected to vacuum_control.py")
def sendCommand(self,cmd):
self.lnk.sendline(cmd)
'''
def printing(self):
print("Printing ls")
self.lnk.sendline("test.printThis()")
def continuePrinting(self):
self.lnk.sendline("test.testThis()")
self.lnk.prompt()
output = self.lnk.before.decode('utf-8','ignore')
print(output)
#print(type(output))
'''
def stop(self):
self.terminate()