-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMainWindow_v2_02.py
231 lines (179 loc) · 8.56 KB
/
MainWindow_v2_02.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
#!/usr/bin/python3
# -*- coding: utf-8 -*-
"""
This script is stored in O:\Device Manuals and Data\???
Change log
v0_00: Initial version
"""
import ImportForSpyderAndQt5
import sys
from PyQt5 import QtWidgets, QtGui
from PyQt5.QtCore import Qt
from MiraControlUI_v1_02 import Ui_MainWindow
#Verdi CW green laser
from VerdiConnection_v1_00 import VerdiConnectDialog
from FrontPanel.FrontPanel_v1_00 import FrontPanelDialog
from InformationDialog.InformationDialog_v1_00 import InformationDialog
import V18.Verdi_v1_02 as Verdi
#ThermoTek Chiller
from ThermoTekConnection_v1_00 import ThermoTekConnectDialog
from ThermoTek.ThermoTek_v1_00 import ChillerControlDialog
import ThermoTek.ThermoTek_T255P_v1_00 as T255P
from ThermoTek.ThermoTek_Logger_v1_00 import T255P_Logger as chiller_Logger
from ConnectionDialogWidget_v1_00 import ConnectDialog
#Oscilloscope
from TDS220.TDS220_TCPClient_v1_00 import TDS220
from TDS220.TDS220_Widget_v1_02 import TDS220_Widget
from V18.Verdi_logger_v1_02 import Verdi_Logger
#import BME280.Adafruit_BME280 as AF_BME280
#from meteocalc import Temp as TemperatureClass
#from meteocalc import dew_point as calcuateDewpoint
DEBUG = True
Verdi.DEBUG = False
T255P.DEBUG = False
class MiraControlMainWindow(QtWidgets.QMainWindow):
def __init__(self, parent=None):
QtWidgets.QMainWindow.__init__(self, parent)
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
###################################################################
## Settings for Coherent Verdi-18
###################################################################
self.verdiMenuActionList = [self.ui.actionDiode_Parameters, \
self.ui.actionFault_Status, self.ui.actionFront_Panel, \
self.ui.actionLaser_Status, self.ui.actionServo_Status,\
self.ui.actionVerdi_Log_Start, self.ui.menuVerdi_Log]
self.verdi = Verdi.Verdi()
self.verdiConnectionDialog = VerdiConnectDialog(self)
self.frontPanelDialog = FrontPanelDialog(self)
self.informationDialog = InformationDialog(self)
self.verdi_Logger = Verdi_Logger(self)
###################################################################
## Settings for ThermoTek chiller
###################################################################
self.chillerMenuActionList = [self.ui.actionChiller_Control, \
self.ui.menuChiller_Log, self.ui.actionChiller_Log_Start]
self.chiller = T255P.T255P()
self.chillerConnectionDialog = ThermoTekConnectDialog(self)
self.chillerControlDialog = ChillerControlDialog(self)
self.chiller_Logger = chiller_Logger(self)
###################################################################
## Settings for TDS220
###################################################################
self.oscilloscope = TDS220(defaultIPAddress = '172.22.22.86', defaultTCPPort = 3034)
self.oscilloscopeConnectionDialog = ConnectDialog(self, windowTitle = 'Connection to TDS220')
self.oscilloscopeConnectionDialog.setDevice(self.oscilloscope, 'TDS220_TCPServer_v2_00.py')
self.oscilloscopeConnectionDialog.setMenuActionList([self.ui.actionOscilloscopeControl])
self.oscilloscopeWidget = TDS220_Widget(self, self.oscilloscope)
self.oscilloscope.setWidget(self.oscilloscopeWidget)
self.oscilloscopeWidget.hide()
###################################################################
## Methods related to Coherent Verdi-18
###################################################################
def openVerdiConnection(self):
#print('openVerdiConnection called')
self.verdiConnectionDialog.updateParameterStatus()
#self.verdiConnectionDialog.exec_()
self.verdiConnectionDialog.show()
def openVerdiFrontPanel(self):
self.frontPanelDialog.updateParameterStatus()
#self.frontPanelDialog.exec_()
self.frontPanelDialog.show()
def openVerdiLaserStatus(self):
self.informationDialog.updateLaserStatus()
self.informationDialog.exec_()
def openVerdiDiodeParameters(self):
self.informationDialog.updateDiodeParameters()
self.informationDialog.exec_()
def openVerdiFaultStatus(self):
self.informationDialog.updateFaultStatus()
self.informationDialog.exec_()
def openVerdiServoStatus(self):
self.informationDialog.updateServoStatus()
self.informationDialog.exec_()
def openVerdi_Log_Start(self):
print('Verdi Log Start')
self.verdi_Logger.start_log()
self.ui.actionVerdi_Log_Start.setEnabled(False)
self.ui.actionVerdi_Log_End.setEnabled(True)
def openVerdi_Log_End(self):
print('Verdi Log End')
self.verdi_Logger.end_log()
self.ui.actionVerdi_Log_End.setEnabled(False)
self.ui.actionVerdi_Log_Start.setEnabled(True)
###################################################################
## Methods related to ThermoTek chiller
###################################################################
def openChillerConnection(self):
self.chillerConnectionDialog.updateParameterStatus()
#self.chillerConnectionDialog.exec_()
self.chillerConnectionDialog.show()
def openChillerControlPanel(self):
self.chillerControlDialog.updateParameterStatus()
#self.chillerControlDialog.exec_()
self.chillerControlDialog.show()
def openChiller_Log_Start(self):
print('Chiller Log Start')
self.chiller_Logger.start_log()
self.ui.actionChiller_Log_Start.setEnabled(False)
self.ui.actionChiller_Log_End.setEnabled(True)
def openChiller_Log_End(self):
print('Chiller Log End')
self.chiller_Logger.end_log()
self.ui.actionChiller_Log_End.setEnabled(False)
self.ui.actionChiller_Log_Start.setEnabled(True)
###################################################################
## Methods related to TDS220
###################################################################
def openTDS220_Connection(self):
self.oscilloscopeConnectionDialog.updateParameterStatus()
self.oscilloscopeConnectionDialog.show()
#self.oscilloscopeConnectionDialog.exec_()
def openOscilloscopeControl(self):
self.oscilloscopeWidget.updateParameterStatus()
self.oscilloscopeWidget.show()
###################################################################
## Methods common to all devices
###################################################################
def enableSubMenus(self, menuActionList, enable = True):
for eachAction in menuActionList:
eachAction.setEnabled(enable)
def closeEvent(self, event):
if self.verdi_Logger.log_running():
buttonReply = QtWidgets.QMessageBox.question(self, 'Warning', \
'Logging thread is are still open.' +\
' Do you really want to close the window?', \
QtWidgets.QMessageBox.Yes, QtWidgets.QMessageBox.No)
if buttonReply == QtWidgets.QMessageBox.Yes:
if self.verdi_Logger.log_running():
self.verdi_Logger.end_log()
else:
event.ignore()
return
if (self.verdi.isConnected() or self.chiller.isConnected() \
or self.oscilloscope.isConnected()):
buttonReply = QtWidgets.QMessageBox.question(self, 'Warning', \
'Some of the connections are still open.' +\
' Do you really want to close the window?', \
QtWidgets.QMessageBox.Yes, QtWidgets.QMessageBox.No)
if buttonReply == QtWidgets.QMessageBox.Yes:
if self.verdi.isConnected():
self.verdi.disconnect()
if self.chiller.isConnected():
self.chiller.disconnect()
if self.oscilloscope.isConnected():
self.oscilloscope.disconnect()
else:
event.ignore()
return
QtWidgets.QMainWindow.closeEvent(self, event)
#%%
if __name__ == '__main__':
app = QtWidgets.QApplication.instance()
if app is None:
app = QtWidgets.QApplication([])
MainWindow = MiraControlMainWindow()
#dc = MyDynamicMplCanvas(ui.widget, width=5, height=4, dpi=100)
MainWindow.show()
app.exec_()
sys.exit(app.exec_())