-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathThermoTekConnection_v1_00.py
58 lines (48 loc) · 2.05 KB
/
ThermoTekConnection_v1_00.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
# -*- coding: utf-8 -*-
"""
Created on Sun Nov 26 11:41:13 2017
@author: 1109282
"""
import ImportForSpyderAndQt5
from PyQt5 import QtWidgets
from connectionDialog.connectionUI_v1_00 import Ui_ConnectionDialog
class ThermoTekConnectDialog(QtWidgets.QDialog):
def __init__(self, parent=None):
QtWidgets.QDialog.__init__(self, parent)
self.ui = Ui_ConnectionDialog()
self.ui.setupUi(self)
self.setWindowTitle('Connection to Chiller')
self.parent = parent
def updateParameterStatus(self):
chiller = self.parent.chiller
self.ui.IPAddressEdit.setText(chiller.IPAddress)
self.ui.TCPPortEdit.setText(str(chiller.TCPPort))
if chiller.isConnected():
buttonText = 'Disconnect'
self.ui.statusLabel.setText('Connected')
else:
buttonText = 'Connect'
self.ui.statusLabel.setText('Disconnected')
self.ui.connectButton.setText(buttonText)
def connectButtonClicked(self):
chiller = self.parent.chiller
if chiller.isConnected():
chiller.disconnect()
self.parent.enableSubMenus(self.parent.chillerMenuActionList, False)
buttonText = 'Connect'
self.ui.statusLabel.setText('Disconnected')
else:
chiller.IPAddress = self.ui.IPAddressEdit.text()
chiller.TCPPort = int(self.ui.TCPPortEdit.text())
try:
chiller.connectToThermoTek()
except ConnectionRefusedError:
QtWidgets.QMessageBox.critical(self, 'Error during connection', \
'Connection refused. Please check if the ThermoTekTCPServer is' +\
' running and check IP address and port number.')
return
self.parent.enableSubMenus(self.parent.chillerMenuActionList, True)
buttonText = 'Disonnect'
self.ui.statusLabel.setText('Connected')
self.ui.connectButton.setText(buttonText)
#print('connectButtonClicked called')