개정판 08955797
issue #1048 : 화면/네뉴/툴바 개발
Change-Id: I1b89f30441c774d71581ea4125ce639240e419b6
HYTOS/HYTOS/Compressor.py | ||
---|---|---|
14 | 14 |
import math |
15 | 15 |
|
16 | 16 |
|
17 |
def is_float(s): |
|
18 |
try: |
|
19 |
if s: |
|
20 |
float(s) |
|
21 |
return True |
|
22 |
else: |
|
23 |
return False |
|
24 |
except ValueError: |
|
25 |
return False |
|
26 |
|
|
27 |
|
|
28 |
def is_blank(s): |
|
29 |
return not (s and s.strip()) |
|
30 |
|
|
31 |
|
|
17 | 32 |
def is_not_blank(s): |
18 | 33 |
return bool(s and s.strip()) |
19 | 34 |
|
20 | 35 |
|
36 |
def convert_to_fixed_point(value): |
|
37 |
if is_float(str(value)): |
|
38 |
tokens = f"{float(value):.10f}".split('.') |
|
39 |
if len(tokens) == 2: |
|
40 |
# 소수점 아래가 있을 경우 소수점 아래의 trailing zero를 제거한다. |
|
41 |
if is_blank(tokens[1].rstrip('0')): |
|
42 |
return tokens[0] |
|
43 |
else: |
|
44 |
tokens[1] = tokens[1].rstrip('0') |
|
45 |
return '.'.join(tokens) |
|
46 |
else: |
|
47 |
return tokens[0] |
|
48 |
else: |
|
49 |
return value |
|
50 |
|
|
51 |
|
|
21 | 52 |
class QCompressor(QDialog): |
22 | 53 |
def __init__(self): |
23 | 54 |
QDialog.__init__(self) |
... | ... | |
95 | 126 |
index = connector._conn_index |
96 | 127 |
if connector.data: |
97 | 128 |
pressure = connector.data.pressure |
98 |
if pressure: |
|
129 |
if pressure is not None:
|
|
99 | 130 |
if index == 1: |
100 |
self.ui.lineEdit_Dis_Pressure.setText(str(pressure))
|
|
131 |
self.ui.lineEdit_Dis_Pressure.setText(str(convert_to_fixed_point(pressure)))
|
|
101 | 132 |
elif index == 2: |
102 |
self.ui.lineEdit_Suc_Pressure.setText(str(pressure))
|
|
133 |
self.ui.lineEdit_Suc_Pressure.setText(str(convert_to_fixed_point(pressure)))
|
|
103 | 134 |
|
104 | 135 |
elevation = connector.data.elevation |
105 |
if elevation: |
|
136 |
if elevation is not None:
|
|
106 | 137 |
if index == 1: |
107 |
self.ui.lineEdit_Dis_Elevation.setText(str(elevation))
|
|
138 |
self.ui.lineEdit_Dis_Elevation.setText(str(convert_to_fixed_point(elevation)))
|
|
108 | 139 |
elif index == 2: |
109 |
self.ui.lineEdit_Suc_Elevation.setText(str(elevation))
|
|
140 |
self.ui.lineEdit_Suc_Elevation.setText(str(convert_to_fixed_point(elevation)))
|
|
110 | 141 |
|
111 | 142 |
def accept(self): |
112 | 143 |
""" set tag no and nozzle data """ |
... | ... | |
121 | 152 |
connector.data = NozzleData() |
122 | 153 |
|
123 | 154 |
if index == 1: |
124 |
pressure = self.ui.lineEdit_Dis_Pressure.text() |
|
125 |
if pressure: |
|
126 |
connector.data.pressure = float(pressure) |
|
127 |
else: |
|
128 |
connector.data.pressure = None |
|
129 |
|
|
130 |
elevation = self.ui.lineEdit_Dis_Elevation.text() |
|
131 |
if elevation: |
|
132 |
connector.data.elevation = float(elevation) |
|
133 |
else: |
|
134 |
connector.data.elevation = None |
|
155 |
if self.ui.lineEdit_Dis_Pressure.isEnabled(): |
|
156 |
pressure = self.ui.lineEdit_Dis_Pressure.text() |
|
157 |
if pressure: |
|
158 |
connector.data.pressure = float(pressure) |
|
159 |
else: |
|
160 |
connector.data.pressure = 0 |
|
161 |
|
|
162 |
if self.ui.lineEdit_Dis_Elevation.isEnabled(): |
|
163 |
elevation = self.ui.lineEdit_Dis_Elevation.text() |
|
164 |
if elevation: |
|
165 |
connector.data.elevation = float(elevation) |
|
166 |
else: |
|
167 |
connector.data.elevation = 0 |
|
135 | 168 |
elif index == 2: |
136 |
pressure = self.ui.lineEdit_Suc_Pressure.text() |
|
137 |
if pressure: |
|
138 |
connector.data.pressure = float(pressure) |
|
139 |
else: |
|
140 |
connector.data.pressure = None |
|
141 |
|
|
142 |
elevation = self.ui.lineEdit_Suc_Elevation.text() |
|
143 |
if elevation: |
|
144 |
connector.data.elevation = float(elevation) |
|
145 |
else: |
|
146 |
connector.data.elevation = None |
|
169 |
if self.ui.lineEdit_Suc_Pressure.isEnabled(): |
|
170 |
pressure = self.ui.lineEdit_Suc_Pressure.text() |
|
171 |
if pressure: |
|
172 |
connector.data.pressure = float(pressure) |
|
173 |
else: |
|
174 |
connector.data.pressure = 0 |
|
175 |
|
|
176 |
if self.ui.lineEdit_Suc_Elevation.isEnabled(): |
|
177 |
elevation = self.ui.lineEdit_Suc_Elevation.text() |
|
178 |
if elevation: |
|
179 |
connector.data.elevation = float(elevation) |
|
180 |
else: |
|
181 |
connector.data.elevation = 0 |
|
147 | 182 |
|
148 | 183 |
QDialog.accept(self) |
149 | 184 |
else: |
150 |
QMessageBox.warning(self, self.tr('Notice'), self.tr('Please Input [Tag No.]'))
|
|
185 |
QMessageBox.information(self, self.tr('Information'), self.tr('Please Input [Tag No.]'))
|
|
151 | 186 |
|
152 | 187 |
def reject(self): |
153 | 188 |
QDialog.reject(self) |
내보내기 Unified diff