hytos / HYTOS / HYTOS / Equipment.py @ c46ad1e0
이력 | 보기 | 이력해설 | 다운로드 (19.6 KB)
1 |
# -*- coding: utf-8 -*-
|
---|---|
2 |
|
3 |
# Form implementation generated from reading ui file 'ProjectDialog.ui'
|
4 |
#
|
5 |
# Created by: PyQt5 UI code generator 5.6
|
6 |
#
|
7 |
# WARNING! All changes made in this file will be lost!
|
8 |
|
9 |
from PyQt5 import QtCore, QtGui, QtWidgets |
10 |
from PyQt5.QtWidgets import * |
11 |
import os |
12 |
from AppDocData import AppDocData |
13 |
import Equipment_UI |
14 |
import math |
15 |
|
16 |
|
17 |
def is_not_blank(s): |
18 |
return bool(s and s.strip()) |
19 |
|
20 |
|
21 |
class QEquipment(QDialog): |
22 |
def __init__(self): |
23 |
QDialog.__init__(self)
|
24 |
|
25 |
self.ui = Equipment_UI.Ui_EquipmentDialog()
|
26 |
self.ui.setupUi(self) |
27 |
self._item = None |
28 |
|
29 |
self.ui.lineEdit_N1_Pressure.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_N1_Pressure)) |
30 |
self.ui.lineEdit_N2_Pressure.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_N2_Pressure)) |
31 |
self.ui.lineEdit_N3_Pressure.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_N3_Pressure)) |
32 |
self.ui.lineEdit_N4_Pressure.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_N4_Pressure)) |
33 |
self.ui.lineEdit_N5_Pressure.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_N5_Pressure)) |
34 |
self.ui.lineEdit_N6_Pressure.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_N6_Pressure)) |
35 |
self.ui.lineEdit_N7_Pressure.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_N7_Pressure)) |
36 |
self.ui.lineEdit_N8_Pressure.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_N8_Pressure)) |
37 |
self.ui.lineEdit_N9_Pressure.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_N9_Pressure)) |
38 |
self.ui.lineEdit_N10_Pressure.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_N10_Pressure)) |
39 |
self.ui.lineEdit_N11_Pressure.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_N11_Pressure)) |
40 |
self.ui.lineEdit_N12_Pressure.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_N12_Pressure)) |
41 |
|
42 |
self.ui.lineEdit_N1_Elevation.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_N1_Elevation)) |
43 |
self.ui.lineEdit_N2_Elevation.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_N2_Elevation)) |
44 |
self.ui.lineEdit_N3_Elevation.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_N3_Elevation)) |
45 |
self.ui.lineEdit_N4_Elevation.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_N4_Elevation)) |
46 |
self.ui.lineEdit_N5_Elevation.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_N5_Elevation)) |
47 |
self.ui.lineEdit_N6_Elevation.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_N6_Elevation)) |
48 |
self.ui.lineEdit_N7_Elevation.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_N7_Elevation)) |
49 |
self.ui.lineEdit_N8_Elevation.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_N8_Elevation)) |
50 |
self.ui.lineEdit_N9_Elevation.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_N9_Elevation)) |
51 |
self.ui.lineEdit_N10_Elevation.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_N10_Elevation)) |
52 |
self.ui.lineEdit_N11_Elevation.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_N11_Elevation)) |
53 |
self.ui.lineEdit_N12_Elevation.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_N12_Elevation)) |
54 |
|
55 |
self.initialize()
|
56 |
|
57 |
def show_dialog(self, item): |
58 |
self.setWindowFlags(self.windowFlags() & ~QtCore.Qt.WindowContextHelpButtonHint) |
59 |
self._item = item
|
60 |
|
61 |
self.ui.lineEdit_TagNo.setFocus()
|
62 |
self.set_controls()
|
63 |
self.load_data()
|
64 |
|
65 |
return self.exec_() |
66 |
|
67 |
def initialize(self): |
68 |
# To do : 이름으로 Control 찾아오기
|
69 |
self.ui.label_Img_N1.setVisible(False) |
70 |
self.ui.label_Img_N2.setVisible(False) |
71 |
self.ui.label_Img_N3.setVisible(False) |
72 |
self.ui.label_Img_N4.setVisible(False) |
73 |
self.ui.label_Img_N5.setVisible(False) |
74 |
self.ui.label_Img_N6.setVisible(False) |
75 |
self.ui.label_Img_N7.setVisible(False) |
76 |
self.ui.label_Img_N8.setVisible(False) |
77 |
self.ui.label_Img_N9.setVisible(False) |
78 |
self.ui.label_Img_N10.setVisible(False) |
79 |
self.ui.label_Img_N11.setVisible(False) |
80 |
self.ui.label_Img_N12.setVisible(False) |
81 |
|
82 |
self.ui.label_N1.setVisible(False) |
83 |
self.ui.lineEdit_N1_Pressure.setEnabled(False) |
84 |
self.ui.lineEdit_N1_Elevation.setEnabled(False) |
85 |
|
86 |
self.ui.label_N2.setVisible(False) |
87 |
self.ui.lineEdit_N2_Pressure.setEnabled(False) |
88 |
self.ui.lineEdit_N2_Elevation.setEnabled(False) |
89 |
|
90 |
self.ui.label_N3.setVisible(False) |
91 |
self.ui.lineEdit_N3_Pressure.setEnabled(False) |
92 |
self.ui.lineEdit_N3_Elevation.setEnabled(False) |
93 |
|
94 |
self.ui.label_N4.setVisible(False) |
95 |
self.ui.lineEdit_N4_Pressure.setEnabled(False) |
96 |
self.ui.lineEdit_N4_Elevation.setEnabled(False) |
97 |
|
98 |
self.ui.label_N5.setVisible(False) |
99 |
self.ui.lineEdit_N5_Pressure.setEnabled(False) |
100 |
self.ui.lineEdit_N5_Elevation.setEnabled(False) |
101 |
|
102 |
self.ui.label_N6.setVisible(False) |
103 |
self.ui.lineEdit_N6_Pressure.setEnabled(False) |
104 |
self.ui.lineEdit_N6_Elevation.setEnabled(False) |
105 |
|
106 |
self.ui.label_N7.setVisible(False) |
107 |
self.ui.lineEdit_N7_Pressure.setEnabled(False) |
108 |
self.ui.lineEdit_N7_Elevation.setEnabled(False) |
109 |
|
110 |
self.ui.label_N8.setVisible(False) |
111 |
self.ui.lineEdit_N8_Pressure.setEnabled(False) |
112 |
self.ui.lineEdit_N8_Elevation.setEnabled(False) |
113 |
|
114 |
self.ui.label_N9.setVisible(False) |
115 |
self.ui.lineEdit_N9_Pressure.setEnabled(False) |
116 |
self.ui.lineEdit_N9_Elevation.setEnabled(False) |
117 |
|
118 |
self.ui.label_N10.setVisible(False) |
119 |
self.ui.lineEdit_N10_Pressure.setEnabled(False) |
120 |
self.ui.lineEdit_N10_Elevation.setEnabled(False) |
121 |
|
122 |
self.ui.label_N11.setVisible(False) |
123 |
self.ui.lineEdit_N11_Pressure.setEnabled(False) |
124 |
self.ui.lineEdit_N11_Elevation.setEnabled(False) |
125 |
|
126 |
self.ui.label_N12.setVisible(False) |
127 |
self.ui.lineEdit_N12_Pressure.setEnabled(False) |
128 |
self.ui.lineEdit_N12_Elevation.setEnabled(False) |
129 |
|
130 |
def set_controls(self): |
131 |
# To do : 이름으로 Control 찾아오기
|
132 |
for connector in self._item.connectors: |
133 |
index = connector._conn_index |
134 |
if connector.connectedItem:
|
135 |
if index == 1: |
136 |
self.ui.label_Img_N1.setVisible(True) |
137 |
self.ui.label_N1.setVisible(True) |
138 |
self.ui.lineEdit_N1_Pressure.setEnabled(True) |
139 |
self.ui.lineEdit_N1_Elevation.setEnabled(True) |
140 |
elif index == 2: |
141 |
self.ui.label_Img_N2.setVisible(True) |
142 |
self.ui.label_N2.setVisible(True) |
143 |
self.ui.lineEdit_N2_Pressure.setEnabled(True) |
144 |
self.ui.lineEdit_N2_Elevation.setEnabled(True) |
145 |
elif index == 3: |
146 |
self.ui.label_Img_N3.setVisible(True) |
147 |
self.ui.label_N3.setVisible(True) |
148 |
self.ui.lineEdit_N3_Pressure.setEnabled(True) |
149 |
self.ui.lineEdit_N3_Elevation.setEnabled(True) |
150 |
elif index == 4: |
151 |
self.ui.label_Img_N4.setVisible(True) |
152 |
self.ui.label_N4.setVisible(True) |
153 |
self.ui.lineEdit_N4_Pressure.setEnabled(True) |
154 |
self.ui.lineEdit_N4_Elevation.setEnabled(True) |
155 |
elif index == 5: |
156 |
self.ui.label_Img_N5.setVisible(True) |
157 |
self.ui.label_N5.setVisible(True) |
158 |
self.ui.lineEdit_N5_Pressure.setEnabled(True) |
159 |
self.ui.lineEdit_N5_Elevation.setEnabled(True) |
160 |
elif index == 6: |
161 |
self.ui.label_Img_N6.setVisible(True) |
162 |
self.ui.label_N6.setVisible(True) |
163 |
self.ui.lineEdit_N6_Pressure.setEnabled(True) |
164 |
self.ui.lineEdit_N6_Elevation.setEnabled(True) |
165 |
elif index == 7: |
166 |
self.ui.label_Img_N7.setVisible(True) |
167 |
self.ui.label_N7.setVisible(True) |
168 |
self.ui.lineEdit_N7_Pressure.setEnabled(True) |
169 |
self.ui.lineEdit_N7_Elevation.setEnabled(True) |
170 |
elif index == 8: |
171 |
self.ui.label_Img_N8.setVisible(True) |
172 |
self.ui.label_N8.setVisible(True) |
173 |
self.ui.lineEdit_N8_Pressure.setEnabled(True) |
174 |
self.ui.lineEdit_N8_Elevation.setEnabled(True) |
175 |
elif index == 9: |
176 |
self.ui.label_Img_N9.setVisible(True) |
177 |
self.ui.label_N9.setVisible(True) |
178 |
self.ui.lineEdit_N9_Pressure.setEnabled(True) |
179 |
self.ui.lineEdit_N9_Elevation.setEnabled(True) |
180 |
elif index == 10: |
181 |
self.ui.label_Img_N10.setVisible(True) |
182 |
self.ui.label_N10.setVisible(True) |
183 |
self.ui.lineEdit_N10_Pressure.setEnabled(True) |
184 |
self.ui.lineEdit_N10_Elevation.setEnabled(True) |
185 |
elif index == 11: |
186 |
self.ui.label_Img_N11.setVisible(True) |
187 |
self.ui.label_N11.setVisible(True) |
188 |
self.ui.lineEdit_N11_Pressure.setEnabled(True) |
189 |
self.ui.lineEdit_N11_Elevation.setEnabled(True) |
190 |
elif index == 12: |
191 |
self.ui.label_Img_N12.setVisible(True) |
192 |
self.ui.label_N12.setVisible(True) |
193 |
self.ui.lineEdit_N12_Pressure.setEnabled(True) |
194 |
self.ui.lineEdit_N12_Elevation.setEnabled(True) |
195 |
|
196 |
def load_data(self): |
197 |
""" load tag no and nozzle data """
|
198 |
from Drawing import Drawing |
199 |
self.ui.lineEdit_TagNo.setText(self._item.tag_no) |
200 |
|
201 |
appDocData = AppDocData.instance() |
202 |
drawing = appDocData.activeDrawing |
203 |
if drawing:
|
204 |
for attr in drawing.attrs: |
205 |
if attr[0] == 'Units': |
206 |
self.ui.label_PressureUnit.setText('{}(g)'.format(attr[1]['Pressure'])) |
207 |
self.ui.label_ElevationUnit.setText(attr[1]['Length']) |
208 |
|
209 |
for connector in self._item.connectors: |
210 |
index = connector._conn_index |
211 |
if connector.data:
|
212 |
pressure = connector.data.pressure |
213 |
if pressure:
|
214 |
if index == 1: |
215 |
self.ui.lineEdit_N1_Pressure.setText(str(pressure)) |
216 |
elif index == 2: |
217 |
self.ui.lineEdit_N2_Pressure.setText(str(pressure)) |
218 |
elif index == 3: |
219 |
self.ui.lineEdit_N3_Pressure.setText(str(pressure)) |
220 |
elif index == 4: |
221 |
self.ui.lineEdit_N4_Pressure.setText(str(pressure)) |
222 |
elif index == 5: |
223 |
self.ui.lineEdit_N5_Pressure.setText(str(pressure)) |
224 |
elif index == 6: |
225 |
self.ui.lineEdit_N6_Pressure.setText(str(pressure)) |
226 |
elif index == 7: |
227 |
self.ui.lineEdit_N7_Pressure.setText(str(pressure)) |
228 |
elif index == 8: |
229 |
self.ui.lineEdit_N8_Pressure.setText(str(pressure)) |
230 |
elif index == 9: |
231 |
self.ui.lineEdit_N9_Pressure.setText(str(pressure)) |
232 |
elif index == 10: |
233 |
self.ui.lineEdit_N10_Pressure.setText(str(pressure)) |
234 |
elif index == 11: |
235 |
self.ui.lineEdit_N11_Pressure.setText(str(pressure)) |
236 |
elif index == 12: |
237 |
self.ui.lineEdit_N12_Pressure.setText(str(pressure)) |
238 |
|
239 |
elevation = connector.data.elevation |
240 |
if elevation:
|
241 |
if index == 1: |
242 |
self.ui.lineEdit_N1_Elevation.setText(str(elevation)) |
243 |
elif index == 2: |
244 |
self.ui.lineEdit_N2_Elevation.setText(str(elevation)) |
245 |
elif index == 3: |
246 |
self.ui.lineEdit_N3_Elevation.setText(str(elevation)) |
247 |
elif index == 4: |
248 |
self.ui.lineEdit_N4_Elevation.setText(str(elevation)) |
249 |
elif index == 5: |
250 |
self.ui.lineEdit_N5_Elevation.setText(str(elevation)) |
251 |
elif index == 6: |
252 |
self.ui.lineEdit_N6_Elevation.setText(str(elevation)) |
253 |
elif index == 7: |
254 |
self.ui.lineEdit_N7_Elevation.setText(str(elevation)) |
255 |
elif index == 8: |
256 |
self.ui.lineEdit_N8_Elevation.setText(str(elevation)) |
257 |
elif index == 9: |
258 |
self.ui.lineEdit_N9_Elevation.setText(str(elevation)) |
259 |
elif index == 10: |
260 |
self.ui.lineEdit_N10_Elevation.setText(str(elevation)) |
261 |
elif index == 11: |
262 |
self.ui.lineEdit_N11_Elevation.setText(str(elevation)) |
263 |
elif index == 12: |
264 |
self.ui.lineEdit_N12_Elevation.setText(str(elevation)) |
265 |
|
266 |
def accept(self): |
267 |
""" set tag no and nozzle data """
|
268 |
from EngineeringConnectorItem import NozzleData |
269 |
tag_no = self.ui.lineEdit_TagNo.text()
|
270 |
|
271 |
if is_not_blank(tag_no):
|
272 |
self._item.tag_no = tag_no
|
273 |
for connector in self._item.connectors: |
274 |
index = connector._conn_index |
275 |
if not connector.data: |
276 |
connector.data = NozzleData() |
277 |
|
278 |
if index == 1: |
279 |
pressure = self.ui.lineEdit_N1_Pressure.text()
|
280 |
if pressure:
|
281 |
connector.data.pressure = float(pressure)
|
282 |
else:
|
283 |
connector.data.pressure = None
|
284 |
|
285 |
elevation = self.ui.lineEdit_N1_Elevation.text()
|
286 |
if elevation:
|
287 |
connector.data.elevation = float(elevation)
|
288 |
else:
|
289 |
connector.data.elevation = None
|
290 |
elif index == 2: |
291 |
pressure = self.ui.lineEdit_N2_Pressure.text()
|
292 |
if pressure:
|
293 |
connector.data.pressure = float(pressure)
|
294 |
else:
|
295 |
connector.data.pressure = None
|
296 |
|
297 |
elevation = self.ui.lineEdit_N2_Elevation.text()
|
298 |
if elevation:
|
299 |
connector.data.elevation = float(elevation)
|
300 |
else:
|
301 |
connector.data.elevation = None
|
302 |
elif index == 3: |
303 |
pressure = self.ui.lineEdit_N3_Pressure.text()
|
304 |
if pressure:
|
305 |
connector.data.pressure = float(pressure)
|
306 |
else:
|
307 |
connector.data.pressure = None
|
308 |
|
309 |
elevation = self.ui.lineEdit_N3_Elevation.text()
|
310 |
if elevation:
|
311 |
connector.data.elevation = float(elevation)
|
312 |
else:
|
313 |
connector.data.elevation = None
|
314 |
elif index == 4: |
315 |
pressure = self.ui.lineEdit_N4_Pressure.text()
|
316 |
if pressure:
|
317 |
connector.data.pressure = float(pressure)
|
318 |
else:
|
319 |
connector.data.pressure = None
|
320 |
|
321 |
elevation = self.ui.lineEdit_N4_Elevation.text()
|
322 |
if elevation:
|
323 |
connector.data.elevation = float(elevation)
|
324 |
else:
|
325 |
connector.data.elevation = None
|
326 |
elif index == 5: |
327 |
pressure = self.ui.lineEdit_N5_Pressure.text()
|
328 |
if pressure:
|
329 |
connector.data.pressure = float(pressure)
|
330 |
else:
|
331 |
connector.data.pressure = None
|
332 |
|
333 |
elevation = self.ui.lineEdit_N5_Elevation.text()
|
334 |
if elevation:
|
335 |
connector.data.elevation = float(elevation)
|
336 |
else:
|
337 |
connector.data.elevation = None
|
338 |
elif index == 6: |
339 |
pressure = self.ui.lineEdit_N6_Pressure.text()
|
340 |
if pressure:
|
341 |
connector.data.pressure = float(pressure)
|
342 |
else:
|
343 |
connector.data.pressure = None
|
344 |
|
345 |
elevation = self.ui.lineEdit_N6_Elevation.text()
|
346 |
if elevation:
|
347 |
connector.data.elevation = float(elevation)
|
348 |
else:
|
349 |
connector.data.elevation = None
|
350 |
elif index == 7: |
351 |
pressure = self.ui.lineEdit_N7_Pressure.text()
|
352 |
if pressure:
|
353 |
connector.data.pressure = float(pressure)
|
354 |
else:
|
355 |
connector.data.pressure = None
|
356 |
|
357 |
elevation = self.ui.lineEdit_N7_Elevation.text()
|
358 |
if elevation:
|
359 |
connector.data.elevation = float(elevation)
|
360 |
else:
|
361 |
connector.data.elevation = None
|
362 |
elif index == 8: |
363 |
pressure = self.ui.lineEdit_N8_Pressure.text()
|
364 |
if pressure:
|
365 |
connector.data.pressure = float(pressure)
|
366 |
else:
|
367 |
connector.data.pressure = None
|
368 |
|
369 |
elevation = self.ui.lineEdit_N8_Elevation.text()
|
370 |
if elevation:
|
371 |
connector.data.elevation = float(elevation)
|
372 |
else:
|
373 |
connector.data.elevation = None
|
374 |
elif index == 9: |
375 |
pressure = self.ui.lineEdit_N9_Pressure.text()
|
376 |
if pressure:
|
377 |
connector.data.pressure = float(pressure)
|
378 |
else:
|
379 |
connector.data.pressure = None
|
380 |
|
381 |
elevation = self.ui.lineEdit_N9_Elevation.text()
|
382 |
if elevation:
|
383 |
connector.data.elevation = float(elevation)
|
384 |
else:
|
385 |
connector.data.elevation = None
|
386 |
elif index == 10: |
387 |
pressure = self.ui.lineEdit_N10_Pressure.text()
|
388 |
if pressure:
|
389 |
connector.data.pressure = float(pressure)
|
390 |
else:
|
391 |
connector.data.pressure = None
|
392 |
|
393 |
elevation = self.ui.lineEdit_N10_Elevation.text()
|
394 |
if elevation:
|
395 |
connector.data.elevation = float(elevation)
|
396 |
else:
|
397 |
connector.data.elevation = None
|
398 |
elif index == 11: |
399 |
pressure = self.ui.lineEdit_N11_Pressure.text()
|
400 |
if pressure:
|
401 |
connector.data.pressure = float(pressure)
|
402 |
else:
|
403 |
connector.data.pressure = None
|
404 |
|
405 |
elevation = self.ui.lineEdit_N11_Elevation.text()
|
406 |
if elevation:
|
407 |
connector.data.elevation = float(elevation)
|
408 |
else:
|
409 |
connector.data.elevation = None
|
410 |
elif index == 12: |
411 |
pressure = self.ui.lineEdit_N12_Pressure.text()
|
412 |
if pressure:
|
413 |
connector.data.pressure = float(pressure)
|
414 |
else:
|
415 |
connector.data.pressure = None
|
416 |
|
417 |
elevation = self.ui.lineEdit_N12_Elevation.text()
|
418 |
if elevation:
|
419 |
connector.data.elevation = float(elevation)
|
420 |
else:
|
421 |
connector.data.elevation = None
|
422 |
|
423 |
QDialog.accept(self)
|
424 |
else:
|
425 |
QMessageBox.warning(self, self.tr('Notice'), self.tr('Please Input [Tag No.]')) |
426 |
|
427 |
def reject(self): |
428 |
QDialog.reject(self)
|