개정판 48dae955
issue #1060: 계산식 예외처리
Change-Id: I673ec380de5cba7bd83688cd560afddae5541124
HYTOS/HYTOS/Commands/DefaultCommand.py | ||
---|---|---|
54 | 54 |
|
55 | 55 |
try: |
56 | 56 |
if not self.isCopy: |
57 |
if 'mousePressEvent' == param[0] and event.button() == Qt.MiddleButton:
|
|
57 |
if 'mousePressEvent' == param[0] and event.button() == Qt.RightButton:
|
|
58 | 58 |
self.imageViewer.setDragMode(QGraphicsView.ScrollHandDrag) |
59 | 59 |
QGraphicsView.mousePressEvent(self.imageViewer, QMouseEvent(QEvent.MouseButtonPress, event.pos(), Qt.LeftButton, event.buttons(), Qt.NoModifier)) |
60 |
elif 'mouseReleaseEvent' == param[0] and event.button() == Qt.MiddleButton:
|
|
60 |
elif 'mouseReleaseEvent' == param[0] and event.button() == Qt.RightButton:
|
|
61 | 61 |
try: |
62 | 62 |
self.imageViewer.setDragMode(QGraphicsView.NoDrag) |
63 | 63 |
finally: |
64 | 64 |
QGraphicsView.mouseReleaseEvent(self.imageViewer, QMouseEvent(QEvent.MouseButtonRelease, event.pos(), Qt.LeftButton, event.buttons(), Qt.NoModifier)) |
65 | 65 |
pass |
66 | 66 |
elif 'mousePressEvent' == param[0] and event.button() == Qt.LeftButton: |
67 |
self.imageViewer.setDragMode(QGraphicsView.RubberBandDrag) |
|
68 |
self.startX = scenePos.x() |
|
69 |
self.startY = scenePos.y() |
|
70 |
self._vertices.clear() |
|
71 |
self._vertices.append(param[2]) |
|
72 |
self.isClicked = True |
|
73 |
elif 'mouseReleaseEvent' == param[0] and event.button() == Qt.LeftButton: |
|
67 |
if not self.imageViewer.scene.items(scenePos): |
|
68 |
self.imageViewer.scene.clearSelection() |
|
69 |
self.imageViewer.setDragMode(QGraphicsView.RubberBandDrag) |
|
70 |
self.startX = scenePos.x() |
|
71 |
self.startY = scenePos.y() |
|
72 |
self._vertices.clear() |
|
73 |
self._vertices.append(param[2]) |
|
74 |
self.isClicked = True |
|
75 |
elif self.isClicked and 'mouseReleaseEvent' == param[0] and event.button() == Qt.LeftButton: |
|
74 | 76 |
try: |
75 | 77 |
QGraphicsView.mouseReleaseEvent(self.imageViewer, event) |
76 | 78 |
self._vertices.append(param[2]) |
... | ... | |
185 | 187 |
self.imageViewer.scene.removeItem(self.symbol) |
186 | 188 |
self.symbol = None |
187 | 189 |
self.isCopy = False |
190 |
pass |
|
188 | 191 |
except Exception as ex: |
189 | 192 |
from App import App |
190 | 193 |
from AppDocData import MessageType |
HYTOS/HYTOS/Commands/HydroCalculationCommand.py | ||
---|---|---|
154 | 154 |
loop.discharge_cal(2) |
155 | 155 |
|
156 | 156 |
def execute_second(self, param): |
157 |
try: |
|
158 |
# 라인 계산된 것을 지운다 |
|
159 |
self.del_p_cal() |
|
157 | 160 |
|
158 |
# 라인 계산된 것을 지운다
|
|
159 |
self.del_p_cal()
|
|
161 |
# 펌프 먼저
|
|
162 |
self.search_pump_calc()
|
|
160 | 163 |
|
161 |
# 펌프 먼저
|
|
162 |
self.search_pump_calc()
|
|
164 |
# CV decision
|
|
165 |
self.search_cv_calc()
|
|
163 | 166 |
|
164 |
# CV decision |
|
165 |
self.search_cv_calc() |
|
167 |
# 계산 마무리 |
|
168 |
for loop in self.loops: |
|
169 |
for i in range(1, len(loop.items) - 1, 3): |
|
170 |
loop.suction_p_cal(i) |
|
171 |
loop.final_loss_input() |
|
166 | 172 |
|
167 |
# 계산 마무리 |
|
168 |
for loop in self.loops: |
|
169 |
for i in range(1, len(loop.items) - 1, 3): |
|
170 |
loop.suction_p_cal(i) |
|
171 |
loop.final_loss_input() |
|
173 |
items_count = len(loop.items) |
|
172 | 174 |
|
173 |
items_count = len(loop.items) |
|
175 |
pressure_2 = loop.pressures[loop.items[items_count - 2]] \ |
|
176 |
if loop.pressures[loop.items[items_count - 2]] else 0 |
|
177 |
pressure_1 = loop.pressures[loop.items[items_count - 1]] \ |
|
178 |
if loop.pressures[loop.items[items_count - 1]] else 0 |
|
179 |
pressure_drop_2 = loop.pressure_drops[loop.items[items_count - 2]] \ |
|
180 |
if loop.pressure_drops[loop.items[items_count - 2]] else 0 |
|
181 |
deviation = pressure_2 - pressure_1 - pressure_drop_2 |
|
174 | 182 |
|
175 |
deviation = loop.pressures[loop.items[items_count - 2]] - loop.pressures[loop.items[items_count - 1]] - \
|
|
176 |
loop.pressure_drops[loop.items[items_count - 2]]
|
|
183 |
loop.deviation = deviation
|
|
184 |
self.final_loss_input()
|
|
177 | 185 |
|
178 |
loop.deviation = deviation |
|
179 |
self.final_loss_input() |
|
186 |
self.init_units() |
|
187 |
self.loop_result() |
|
188 |
except Exception as ex: |
|
189 |
from App import App |
|
190 |
from AppDocData import MessageType |
|
180 | 191 |
|
181 |
self.init_units() |
|
182 |
self.loop_result() |
|
192 |
message = f"error occurred({repr(ex)}) in {sys.exc_info()[-1].tb_frame.f_code.co_filename}:" \ |
|
193 |
f"{sys.exc_info()[-1].tb_lineno}" |
|
194 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
|
183 | 195 |
|
184 | 196 |
def execute(self, param): |
185 | 197 |
""" execute hydro calculation """ |
HYTOS/HYTOS/MainWindow.py | ||
---|---|---|
127 | 127 |
self.actionClose.triggered.connect(self.close) |
128 | 128 |
self.actionNew.triggered.connect(self.on_new_drawing) |
129 | 129 |
self.actionOpen.triggered.connect(self.on_open_drawing) |
130 |
self.actionSave.triggered.connect(self.on_save) #self.actionSaveCliked)
|
|
130 |
self.actionSave.triggered.connect(self.on_save) |
|
131 | 131 |
self.actionSave_As.triggered.connect(self.on_save_as) |
132 | 132 |
self.actionUndo.triggered.connect(self.on_undo) |
133 | 133 |
self.actionRedo.triggered.connect(self.on_redo) |
... | ... | |
1925 | 1925 |
|
1926 | 1926 |
def display_loops(self): |
1927 | 1927 |
""" display loops """ |
1928 |
drawing = AppDocData.instance().activeDrawing |
|
1929 |
if drawing is None: return |
|
1928 |
try: |
|
1929 |
drawing = AppDocData.instance().activeDrawing |
|
1930 |
if drawing is None: return |
|
1930 | 1931 |
|
1931 |
loops = drawing.loops |
|
1932 |
if loops: |
|
1933 |
self.tableWidgetLoop.clear() |
|
1934 |
self.tableWidgetLoop.setColumnCount(len(loops) * 5) |
|
1935 |
|
|
1936 |
_col_names = [[loop.name, 'pressure', 'Static\nLine\ndP_Eq', 'El.\nDensity\nEl.', 'Extra'] for loop in |
|
1937 |
loops] |
|
1938 |
col_names = [] |
|
1939 |
for col_name in _col_names: col_names.extend(col_name) |
|
1940 |
self.tableWidgetLoop.setHorizontalHeaderLabels(col_names) |
|
1941 |
self.tableWidgetLoop.horizontalHeader().setVisible(True) |
|
1942 |
|
|
1943 |
max_rows = 0 |
|
1944 |
for col in range(len(loops)): |
|
1945 |
rows = len(loops[col].items) |
|
1946 |
max_rows = max(max_rows, rows) |
|
1947 |
self.tableWidgetLoop.setRowCount(max_rows) |
|
1948 |
|
|
1949 |
for row in range(len(loops[col].items)): |
|
1950 |
item = QTableWidgetItem(str(loops[col].items[row])) |
|
1951 |
item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter) |
|
1952 |
self.tableWidgetLoop.setItem(row, col * 5, item) |
|
1953 |
|
|
1954 |
# display calcuation values |
|
1955 |
for row in range(len(loops[col].items)): |
|
1956 |
if loops[col].items[row] in loops[col].pressures: |
|
1957 |
item = QTableWidgetItem(str(round(loops[col].pressures[loops[col].items[row]], 8))) |
|
1958 |
item.setTextAlignment(Qt.AlignRight | Qt.AlignVCenter) |
|
1959 |
# if not loops[col].pressures[loops[col].items[row]]: item.setBackground(Qt.red) |
|
1960 |
self.tableWidgetLoop.setItem(row, col * 5 + 1, item) |
|
1961 |
|
|
1962 |
if loops[col].items[row] in loops[col].pressure_drops: |
|
1963 |
item = QTableWidgetItem(str(round(loops[col].pressure_drops[loops[col].items[row]], 9))) |
|
1964 |
item.setTextAlignment(Qt.AlignRight | Qt.AlignVCenter) |
|
1965 |
# if not loops[col].pressure_drops[loops[col].items[row]]: item.setBackground(Qt.red) |
|
1966 |
self.tableWidgetLoop.setItem(row, col * 5 + 2, item) |
|
1967 |
|
|
1968 |
if loops[col].items[row] in loops[col].density_elevations: |
|
1969 |
item = QTableWidgetItem(str(round(loops[col].density_elevations[loops[col].items[row]], 8))) |
|
1970 |
item.setTextAlignment(Qt.AlignRight | Qt.AlignVCenter) |
|
1971 |
# if not loops[col].density_elevations[loops[col].items[row]]: item.setBackground(Qt.red) |
|
1972 |
self.tableWidgetLoop.setItem(row, col * 5 + 3, item) |
|
1973 |
|
|
1974 |
if loops[col].items[row] in loops[col].extras: |
|
1975 |
item = QTableWidgetItem(str(loops[col].extras[loops[col].items[row]])) |
|
1976 |
item.setTextAlignment(Qt.AlignRight | Qt.AlignVCenter) |
|
1977 |
# if not loops[col].density_elevations[loops[col].items[row]]: item.setBackground(Qt.red) |
|
1978 |
self.tableWidgetLoop.setItem(row, col * 5 + 4, item) |
|
1979 |
|
|
1980 |
self.tableWidgetLoop.resizeColumnsToContents() |
|
1981 |
self.tableWidgetLoop.resizeRowsToContents() |
|
1932 |
loops = drawing.loops |
|
1933 |
if loops: |
|
1934 |
self.tableWidgetLoop.clear() |
|
1935 |
self.tableWidgetLoop.setColumnCount(len(loops) * 5) |
|
1936 |
|
|
1937 |
_col_names = [[loop.name, 'pressure', 'Static\nLine\ndP_Eq', 'El.\nDensity\nEl.', 'Extra'] for loop in |
|
1938 |
loops] |
|
1939 |
col_names = [] |
|
1940 |
for col_name in _col_names: col_names.extend(col_name) |
|
1941 |
self.tableWidgetLoop.setHorizontalHeaderLabels(col_names) |
|
1942 |
self.tableWidgetLoop.horizontalHeader().setVisible(True) |
|
1943 |
|
|
1944 |
max_rows = 0 |
|
1945 |
for col in range(len(loops)): |
|
1946 |
rows = len(loops[col].items) |
|
1947 |
max_rows = max(max_rows, rows) |
|
1948 |
self.tableWidgetLoop.setRowCount(max_rows) |
|
1949 |
|
|
1950 |
for row in range(len(loops[col].items)): |
|
1951 |
item = QTableWidgetItem(str(loops[col].items[row])) |
|
1952 |
item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter) |
|
1953 |
self.tableWidgetLoop.setItem(row, col * 5, item) |
|
1954 |
|
|
1955 |
# display calculation values |
|
1956 |
for row in range(len(loops[col].items)): |
|
1957 |
if loops[col].items[row] in loops[col].pressures: |
|
1958 |
pressure = loops[col].pressures[loops[col].items[row]] \ |
|
1959 |
if loops[col].pressures[loops[col].items[row]] else 0 |
|
1960 |
item = QTableWidgetItem(str(round(pressure, 8))) |
|
1961 |
item.setTextAlignment(Qt.AlignRight | Qt.AlignVCenter) |
|
1962 |
# if not loops[col].pressures[loops[col].items[row]]: item.setBackground(Qt.red) |
|
1963 |
self.tableWidgetLoop.setItem(row, col * 5 + 1, item) |
|
1964 |
|
|
1965 |
if loops[col].items[row] in loops[col].pressure_drops: |
|
1966 |
item = QTableWidgetItem(str(round(loops[col].pressure_drops[loops[col].items[row]], 9))) |
|
1967 |
item.setTextAlignment(Qt.AlignRight | Qt.AlignVCenter) |
|
1968 |
# if not loops[col].pressure_drops[loops[col].items[row]]: item.setBackground(Qt.red) |
|
1969 |
self.tableWidgetLoop.setItem(row, col * 5 + 2, item) |
|
1970 |
|
|
1971 |
if loops[col].items[row] in loops[col].density_elevations: |
|
1972 |
item = QTableWidgetItem(str(round(loops[col].density_elevations[loops[col].items[row]], 8))) |
|
1973 |
item.setTextAlignment(Qt.AlignRight | Qt.AlignVCenter) |
|
1974 |
# if not loops[col].density_elevations[loops[col].items[row]]: item.setBackground(Qt.red) |
|
1975 |
self.tableWidgetLoop.setItem(row, col * 5 + 3, item) |
|
1976 |
|
|
1977 |
if loops[col].items[row] in loops[col].extras: |
|
1978 |
item = QTableWidgetItem(str(loops[col].extras[loops[col].items[row]])) |
|
1979 |
item.setTextAlignment(Qt.AlignRight | Qt.AlignVCenter) |
|
1980 |
# if not loops[col].density_elevations[loops[col].items[row]]: item.setBackground(Qt.red) |
|
1981 |
self.tableWidgetLoop.setItem(row, col * 5 + 4, item) |
|
1982 |
|
|
1983 |
self.tableWidgetLoop.resizeColumnsToContents() |
|
1984 |
self.tableWidgetLoop.resizeRowsToContents() |
|
1985 |
except Exception as ex: |
|
1986 |
message = f"error occurred({repr(ex)}) in {sys.exc_info()[-1].tb_frame.f_code.co_filename}:" \ |
|
1987 |
f"{sys.exc_info()[-1].tb_lineno}" |
|
1988 |
self.addMessage.emit(MessageType.Error, message) |
|
1982 | 1989 |
|
1983 | 1990 |
''' |
1984 | 1991 |
@brief configuration |
HYTOS/HYTOS/QtImageViewerScene.py | ||
---|---|---|
153 | 153 |
def mousePressEvent(self, event: 'QGraphicsSceneMouseEvent') -> None: |
154 | 154 |
from SymbolSvgItem import SymbolSvgItem |
155 | 155 |
|
156 |
if self.selectedItems() and not (type(self.selectedItems()[0]) is SymbolSvgItem and |
|
157 |
self.selectedItems()[0].get_selected_corner(event.scenePos())): |
|
158 |
self._pressed_position = event.scenePos() |
|
159 |
elif not self.selectedItems() and self.items(event.scenePos()): |
|
160 |
self._pressed_position = event.scenePos() |
|
161 |
|
|
162 |
super(QtImageViewerScene, self).mousePressEvent(event) |
|
156 |
try: |
|
157 |
if self.selectedItems() and not (type(self.selectedItems()[0]) is SymbolSvgItem and |
|
158 |
self.selectedItems()[0].get_selected_corner(event.scenePos())): |
|
159 |
self._pressed_position = event.scenePos() |
|
160 |
elif self.items(event.scenePos()): |
|
161 |
self._pressed_position = event.scenePos() |
|
162 |
|
|
163 |
super(QtImageViewerScene, self).mousePressEvent(event) |
|
164 |
except Exception as ex: |
|
165 |
from App import App |
|
166 |
from AppDocData import MessageType |
|
167 |
|
|
168 |
message = f"error occurred({ex}) in {sys.exc_info()[-1].tb_frame.f_code.co_filename}:" \ |
|
169 |
f"{sys.exc_info()[-1].tb_lineno}" |
|
170 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
|
163 | 171 |
|
164 | 172 |
def mouseReleaseEvent(self, event: 'QGraphicsSceneMouseEvent') -> None: |
165 | 173 |
from MoveCommand import MoveCommand |
HYTOS/HYTOS/Shapes/EngineeringLoopItem.py | ||
---|---|---|
812 | 812 |
self.items[i].data.reynolds = round(mach, 5) |
813 | 813 |
|
814 | 814 |
Ref_baro = self.get_barometric_pressure() |
815 |
press2 = self.pressures[self.items[i + 1]] |
|
815 |
press2 = self.pressures[self.items[i + 1]] if self.pressures[self.items[i + 1]] else 0
|
|
816 | 816 |
|
817 | 817 |
# 'pressure를 k.g.a로 맞춤 |
818 | 818 |
pressure_unit = self.units['Pressure'] |
... | ... | |
1411 | 1411 |
def discharge_vapor_density(self, i): |
1412 | 1412 |
try: |
1413 | 1413 |
Ref_baro = self.get_barometric_pressure() |
1414 |
press2 = self.pressures[self.items[i + 1]] |
|
1414 |
press2 = self.pressures[self.items[i + 1]] if self.pressures[self.items[i + 1]] else 0
|
|
1415 | 1415 |
|
1416 | 1416 |
# '여기에 아래의 p를 이용하여 density를 넣는 항을 만들어줘야함 |
1417 | 1417 |
# 'pressure를 k.g.a로 맞춤 |
HYTOS/HYTOS/Shapes/SymbolSvgItem.py | ||
---|---|---|
1294 | 1294 |
self.setColor('url(#normal)') |
1295 | 1295 |
self.update() |
1296 | 1296 |
|
1297 |
def get_selected_corner(self, pos): |
|
1298 |
toler = 5 * self.scale() |
|
1299 |
|
|
1300 |
corner = self.corners[2] |
|
1301 |
dx = corner.x() - pos.x() |
|
1302 |
dy = corner.y() - pos.y() |
|
1303 |
return math.sqrt(dx * dx + dy * dy) < toler |
|
1304 |
|
|
1297 | 1305 |
def mousePressEvent(self, event): |
1298 | 1306 |
import math |
1299 | 1307 |
|
내보내기 Unified diff