개정판 9feba8ce
issue #1060: 저장시 Output Loop 창의 계산 결과도 함계 저장한다
Change-Id: If69ec97fb7f2676e296d3f19501d8aed219144f0
HYTOS/HYTOS/AppDocData.py | ||
---|---|---|
33 | 33 |
elif type(source) is QPixmap: |
34 | 34 |
self.source = Image.fromqpixmap(source) |
35 | 35 | |
36 |
''' |
|
37 |
@history 2018.05.18 Jeongwoo When Parameter [rect] is None, return whole image |
|
38 |
''' |
|
39 | ||
40 |
def getPyImageOnRect(self, rect=None): |
|
41 |
if rect is not None: |
|
42 |
return self.source.copy().crop((rect.left(), rect.top(), rect.right(), rect.bottom())) |
|
43 |
else: |
|
44 |
return self.source.copy() |
|
45 | ||
46 |
def getQImageOnRect(self, rect=None): |
|
47 |
image = ImageQt(self.getPyImageOnRect(rect)) |
|
48 |
return image.convertToFormat(QImage.Format_RGBA8888) |
|
49 | ||
50 | 36 | |
51 | 37 |
class Config: |
52 | 38 |
def __init__(self, section, key, value): |
... | ... | |
74 | 60 | |
75 | 61 |
self._imgFilePath = None |
76 | 62 |
self.imgName = None |
77 |
self.imgWidth = 0 |
|
78 |
self.imgHeight = 0 |
|
79 |
self._OCRData = None |
|
80 | 63 | |
81 |
self._areas = []
|
|
64 |
self.outputs = [] # store calculation outputs
|
|
82 | 65 |
self.equipments = [] |
83 | 66 |
self.lineNos = [] |
84 | 67 |
self.lines = [] |
... | ... | |
122 | 105 |
def clear(self): |
123 | 106 |
self._imgFilePath = None |
124 | 107 |
self.imgName = None |
125 |
self.imgWidth = 0 |
|
126 |
self.imgHeight = 0 |
|
127 | 108 | |
128 |
self._areas.clear() |
|
129 | 109 |
self.equipments.clear() |
130 | 110 |
self.lineNos.clear() |
131 | 111 |
self.lines.clear() |
... | ... | |
1330 | 1310 | |
1331 | 1311 |
return res |
1332 | 1312 | |
1333 |
''' |
|
1334 |
@brief save to database |
|
1335 |
@author yjkim |
|
1336 |
@date 2019.08.28 |
|
1337 |
''' |
|
1338 | ||
1339 | 1313 |
def saveToDatabase(self, items, show_progress=None): |
1340 | 1314 |
""" save given items to database """ |
1341 | 1315 | |
... | ... | |
1343 | 1317 |
for item in items: |
1344 | 1318 |
queries.append(item.toSql()) |
1345 | 1319 | |
1320 |
"""store sql query string for output""" |
|
1321 |
for output in self.outputs: |
|
1322 |
queries.append(output.to_sql()) |
|
1323 |
"""up to here""" |
|
1324 | ||
1346 | 1325 |
with sqlite3.connect(self.activeDrawing.path, isolation_level=None) as conn: |
1347 | 1326 |
conn.execute('PRAGMA foreign_keys = ON') |
1348 | 1327 |
try: |
... | ... | |
1376 | 1355 |
# Roll back any change if something goes wrong |
1377 | 1356 |
conn.rollback() |
1378 | 1357 | |
1379 |
message = 'error occurred({}) in {}:{}'.format(repr(ex), sys.exc_info()[-1].tb_frame.f_code.co_filename,
|
|
1380 |
sys.exc_info()[-1].tb_lineno)
|
|
1358 |
message = f"error occurred({repr(ex)}) in {sys.exc_info()[-1].tb_frame.f_code.co_filename}:" \
|
|
1359 |
f"{sys.exc_info()[-1].tb_lineno}"
|
|
1381 | 1360 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
1382 | 1361 |
finally: |
1383 | 1362 |
if show_progress: |
HYTOS/HYTOS/MainWindow.py | ||
---|---|---|
509 | 509 |
self.tableWidgetDeviation.setColumnCount(0) |
510 | 510 |
self.tableWidgetDeviation.setRowCount(0) |
511 | 511 | |
512 |
app_doc_data = AppDocData.instance() |
|
513 |
app_doc_data.outputs.clear() |
|
514 | ||
512 | 515 |
def clear_loop(self): |
513 | 516 |
self.tableWidgetLoop.setColumnCount(0) |
514 | 517 | |
... | ... | |
837 | 840 |
QMessageBox.information(self, self.tr("Information"), self.tr("Save completed successfully.")) |
838 | 841 | |
839 | 842 |
except Exception as ex: |
840 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
|
|
841 |
sys.exc_info()[-1].tb_lineno)
|
|
843 |
message = f"error occurred({repr(ex)}) in {sys.exc_info()[-1].tb_frame.f_code.co_filename}:" \
|
|
844 |
f"{sys.exc_info()[-1].tb_lineno}"
|
|
842 | 845 |
self.addMessage.emit(MessageType.Error, message) |
843 | 846 | |
844 | 847 |
def on_save(self): |
... | ... | |
1371 | 1374 |
self.progress.setValue(self.progress.maximum()) |
1372 | 1375 |
self.progress.hide() |
1373 | 1376 |
except Exception as ex: |
1374 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
|
|
1375 |
sys.exc_info()[-1].tb_lineno)
|
|
1377 |
message = f"error occurred({repr(ex)}) in {sys.exc_info()[-1].tb_frame.f_code.co_filename}:" \
|
|
1378 |
f"{sys.exc_info()[-1].tb_lineno}"
|
|
1376 | 1379 |
self.addMessage.emit(MessageType.Error, message) |
1377 | 1380 | |
1378 | 1381 |
def generate_report(self): |
... | ... | |
2015 | 2018 | |
2016 | 2019 |
def display_output(self): |
2017 | 2020 |
from HydroCalculationCommand import HydroCalculationCommand |
2021 |
from Outputs import Output |
|
2018 | 2022 | |
2019 | 2023 |
try: |
2020 | 2024 |
""" display output """ |
2021 |
drawing = AppDocData.instance().activeDrawing |
|
2025 |
app_doc_data = AppDocData.instance() |
|
2026 |
drawing = app_doc_data.activeDrawing |
|
2022 | 2027 |
if drawing is None: |
2023 | 2028 |
return |
2024 | 2029 | |
... | ... | |
2099 | 2104 |
names.append(name) |
2100 | 2105 |
attr = item.parent.attribute |
2101 | 2106 |
if len(attr) > 0: |
2107 |
"""store calculation output for pump""" |
|
2108 |
output = Output() |
|
2109 |
output.components_uid = str(item.uid) |
|
2110 |
output.suctp = round(attr['Suct.P'], 3) |
|
2111 |
output.discp = round(attr['Disc.P'], 3) |
|
2112 |
output.diffp = round(attr['Diff.P'], 3) |
|
2113 |
output.head = round(attr['Head'], 3) |
|
2114 |
output.npsha = round(attr['NPSHa'], 3) |
|
2115 |
output.vapp = attr['Vap. P'] |
|
2116 |
output.hhp = round(attr['HHP'], 3) |
|
2117 |
app_doc_data.outputs.append(output) |
|
2118 |
"""up to here""" |
|
2119 | ||
2102 | 2120 |
self.add_data(self.tableWidgetOutput, attr['Tag_No'], None, None, True, True) |
2103 |
self.add_data(self.tableWidgetOutput, 'Suct.P :', round(attr['Suct.P'], 3),
|
|
2121 |
self.add_data(self.tableWidgetOutput, 'Suct.P :', output.suctp,
|
|
2104 | 2122 |
'{}.g'.format(units['Pressure'])) |
2105 |
self.add_data(self.tableWidgetOutput, 'Disc.P :', round(attr['Disc.P'], 3),
|
|
2123 |
self.add_data(self.tableWidgetOutput, 'Disc.P :', output.discp,
|
|
2106 | 2124 |
'{}.g'.format(units['Pressure'])) |
2107 |
self.add_data(self.tableWidgetOutput, 'Diff.P :', round(attr['Diff.P'], 3),
|
|
2125 |
self.add_data(self.tableWidgetOutput, 'Diff.P :', output.diffp,
|
|
2108 | 2126 |
units['Pressure']) |
2109 |
self.add_data(self.tableWidgetOutput, 'Head :', round(attr['Head'], 3), units['Length'])
|
|
2110 |
self.add_data(self.tableWidgetOutput, 'NPSHa :', round(attr['NPSHa'], 3), units['Length'])
|
|
2111 |
self.add_data(self.tableWidgetOutput, 'Vap. P :', attr['Vap. P'],
|
|
2127 |
self.add_data(self.tableWidgetOutput, 'Head :', output.head, units['Length'])
|
|
2128 |
self.add_data(self.tableWidgetOutput, 'NPSHa :', output.npsha, units['Length'])
|
|
2129 |
self.add_data(self.tableWidgetOutput, 'Vap. P :', output.vapp,
|
|
2112 | 2130 |
'{}.a'.format(units['Pressure'])) |
2113 |
self.add_data(self.tableWidgetOutput, 'HHP :', round(attr['HHP'], 3), units['Power']) |
|
2131 |
self.add_data(self.tableWidgetOutput, 'HHP :', output.hhp, units['Power']) |
|
2132 | ||
2114 | 2133 | |
2115 | 2134 |
# Compressor |
2116 | 2135 |
for loop in loops: |
... | ... | |
2125 | 2144 | |
2126 | 2145 |
attr = item.parent.attribute |
2127 | 2146 |
if len(attr) > 0: |
2147 |
"""store calculation output for compressor""" |
|
2148 |
output = Output() |
|
2149 |
output.components_uid = str(item.uid) |
|
2150 |
output.suctp = round(attr['Suct.P'], 3) |
|
2151 |
output.discp = round(attr['Disc.P'], 3) |
|
2152 |
output.diffp = round(attr['Diff.P'], 3) |
|
2153 |
output.hhp = round(attr['HHP'], 3) |
|
2154 |
app_doc_data.outputs.append(output) |
|
2155 |
"""up to here""" |
|
2156 | ||
2128 | 2157 |
self.add_data(self.tableWidgetOutput, attr['Tag_No'], None, None, True, True) |
2129 |
self.add_data(self.tableWidgetOutput, 'Suct.P :', round(attr['Suct.P'], 3),
|
|
2158 |
self.add_data(self.tableWidgetOutput, 'Suct.P :', output.suctp,
|
|
2130 | 2159 |
'{}.g'.format(units['Pressure'])) |
2131 |
self.add_data(self.tableWidgetOutput, 'Disc.P :', round(attr['Disc.P'], 3),
|
|
2160 |
self.add_data(self.tableWidgetOutput, 'Disc.P :', output.discp,
|
|
2132 | 2161 |
'{}.g'.format(units['Pressure'])) |
2133 |
self.add_data(self.tableWidgetOutput, 'Diff.P :', round(attr['Diff.P'], 3),
|
|
2162 |
self.add_data(self.tableWidgetOutput, 'Diff.P :', output.diffp,
|
|
2134 | 2163 |
units['Pressure']) |
2135 |
self.add_data(self.tableWidgetOutput, 'HHP :', round(attr['HHP'], 3), units['Power'])
|
|
2164 |
self.add_data(self.tableWidgetOutput, 'HHP :', output.hhp, units['Power'])
|
|
2136 | 2165 | |
2137 | 2166 |
# Control Valve |
2138 | 2167 |
for loop in loops: |
... | ... | |
2147 | 2176 | |
2148 | 2177 |
attr = item.parent.attribute |
2149 | 2178 |
if len(attr) > 0: |
2179 |
"""store calculation output for control valve""" |
|
2180 |
output = Output() |
|
2181 |
output.components_uid = str(item.uid) |
|
2182 |
output.suctp = round(attr['Suct.P'], 3) |
|
2183 |
output.discp = round(attr['Disc.P'], 3) |
|
2184 |
output.diffp = round(attr['Diff.P'], 3) |
|
2185 |
output.dpratio = round(attr['dP Ratio'] * 100, 2) |
|
2186 |
app_doc_data.outputs.append(output) |
|
2187 |
"""up to here""" |
|
2188 | ||
2150 | 2189 |
self.add_data(self.tableWidgetOutput, attr['Tag_No'], None, None, True, True) |
2151 |
self.add_data(self.tableWidgetOutput, 'Inlet P :', round(attr['Suct.P'], 3),
|
|
2190 |
self.add_data(self.tableWidgetOutput, 'Inlet P :', output.discp,
|
|
2152 | 2191 |
'{}.g'.format(units['Pressure'])) |
2153 |
self.add_data(self.tableWidgetOutput, 'Outlet P :', round(attr['Disc.P'], 3),
|
|
2192 |
self.add_data(self.tableWidgetOutput, 'Outlet P :', output.discp,
|
|
2154 | 2193 |
'{}.g'.format(units['Pressure'])) |
2155 |
self.add_data(self.tableWidgetOutput, 'Diff.P :', round(attr['Diff.P'], 3),
|
|
2194 |
self.add_data(self.tableWidgetOutput, 'Diff.P :', output.diffp,
|
|
2156 | 2195 |
units['Pressure']) |
2157 |
self.add_data(self.tableWidgetOutput, 'dP Ratio :', round(attr['dP Ratio'] * 100, 2), '%')
|
|
2196 |
self.add_data(self.tableWidgetOutput, 'dP Ratio :', output.dpratio, '%')
|
|
2158 | 2197 |
except Exception as ex: |
2159 |
message = 'error occurred({}) in {}:{}'.format(repr(ex), sys.exc_info()[-1].tb_frame.f_code.co_filename,
|
|
2160 |
sys.exc_info()[-1].tb_lineno)
|
|
2198 |
message = f"error occurred({repr(ex)}) in {sys.exc_info()[-1].tb_frame.f_code.co_filename}:" \
|
|
2199 |
f"{sys.exc_info()[-1].tb_lineno}"
|
|
2161 | 2200 |
self.addMessage.emit(MessageType.Error, message) |
2162 | 2201 | |
2163 | 2202 |
def display_loops(self): |
HYTOS/HYTOS/MainWindow_UI.py | ||
---|---|---|
2 | 2 | |
3 | 3 |
# Form implementation generated from reading ui file '.\UI\MainWindow.ui' |
4 | 4 |
# |
5 |
# Created by: PyQt5 UI code generator 5.13.0
|
|
5 |
# Created by: PyQt5 UI code generator 5.13.1
|
|
6 | 6 |
# |
7 | 7 |
# WARNING! All changes made in this file will be lost! |
8 | 8 | |
... | ... | |
21 | 21 |
MainWindow.setFont(font) |
22 | 22 |
MainWindow.setWindowTitle("") |
23 | 23 |
icon = QtGui.QIcon() |
24 |
icon.addPixmap(QtGui.QPixmap(":/images/hydraulic calculation.svg"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
|
24 |
icon.addPixmap(QtGui.QPixmap(":/images/HYTOS.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
|
25 | 25 |
MainWindow.setWindowIcon(icon) |
26 | 26 |
self.centralwidget = QtWidgets.QWidget(MainWindow) |
27 | 27 |
self.centralwidget.setObjectName("centralwidget") |
HYTOS/HYTOS/OptionsDialog.py | ||
---|---|---|
1 | 1 |
# coding: utf-8 |
2 |
""" This is Configuratio dialog module """ |
|
2 |
""" This is Configuration dialog module """
|
|
3 | 3 | |
4 | 4 |
import os |
5 | 5 |
import sys |
HYTOS/HYTOS/Outputs.py | ||
---|---|---|
1 |
# coding: utf-8 |
|
2 |
""" This is Outputs module """ |
|
3 | ||
4 | ||
5 |
class Output: |
|
6 |
"""Output class""" |
|
7 | ||
8 |
def __init__(self): |
|
9 |
self.components_uid = None |
|
10 |
self.suctp = None |
|
11 |
self.discp = None |
|
12 |
self.diffp = None |
|
13 |
self.head = None |
|
14 |
self.npsha = None |
|
15 |
self.vapp = None |
|
16 |
self.hhp = None |
|
17 |
self.dpratio = None |
|
18 | ||
19 |
def to_sql(self) -> list: |
|
20 |
"""generate sql string for output""" |
|
21 |
res = [] |
|
22 | ||
23 |
cols, param = ['Components_UID'], [str(self.components_uid)] |
|
24 | ||
25 |
if self.suctp is not None: |
|
26 |
cols.append('SuctP') |
|
27 |
param.append(self.suctp) |
|
28 | ||
29 |
if self.discp is not None: |
|
30 |
cols.append('DiscP') |
|
31 |
param.append(self.discp) |
|
32 | ||
33 |
if self.diffp is not None: |
|
34 |
cols.append('DiffP') |
|
35 |
param.append(self.diffp) |
|
36 | ||
37 |
if self.head is not None: |
|
38 |
cols.append('Head') |
|
39 |
param.append(self.head) |
|
40 | ||
41 |
if self.npsha is not None: |
|
42 |
cols.append('NPSHa') |
|
43 |
param.append(self.npsha) |
|
44 | ||
45 |
if self.vapp is not None: |
|
46 |
cols.append('VapP') |
|
47 |
param.append(self.vapp) |
|
48 | ||
49 |
if self.hhp is not None: |
|
50 |
cols.append('HHP') |
|
51 |
param.append(self.hhp) |
|
52 | ||
53 |
if self.dpratio is not None: |
|
54 |
cols.append('dpRatio') |
|
55 |
param.append(self.dpratio) |
|
56 | ||
57 |
values = ['?' for col in cols] |
|
58 | ||
59 |
sql = f"insert or replace into Outputs({','.join(cols)}) values({','.join(values)})" |
|
60 |
res.append((sql, tuple(param))) |
|
61 | ||
62 |
return res |
|
63 |
HYTOS/HYTOS/Scripts/update_database.sql | ||
---|---|---|
1 |
CREATE TABLE IF NOT EXISTS Outputs ( |
|
2 |
Components_UID VARCHAR (37) PRIMARY KEY |
|
3 |
REFERENCES Components (UID) ON DELETE CASCADE, |
|
4 |
SuctP REAL, |
|
5 |
DiscP REAL, |
|
6 |
DiffP REAL, |
|
7 |
Head REAL, |
|
8 |
NPSHa REAL, |
|
9 |
VapP REAL, |
|
10 |
HHP REAL, |
|
11 |
dpRatio REAL |
|
12 |
); |
|
13 | ||
1 | 14 |
insert or replace into SymbolType(UID,Category,Type) values('8502d693-2e13-422f-b81a-67edf19dc07d', 'Callout', 'Callout'); |
2 | 15 |
insert or replace into Symbols(UID,Name,Display_Name,SymbolType_UID,OriginalPoint) values('c288afbb-2612-4b8e-9932-2a84815cfa4e', 'Callout', 'Callout','8502d693-2e13-422f-b81a-67edf19dc07d', '0,0,0,0'); |
3 | 16 |
insert or replace into Symbols(UID,Name,Display_Name,SymbolType_UID,OriginalPoint) values('22384e9d-74d7-4639-b500-73ac6285ff8a', 'Dimension', 'Dimension', '8502d693-2e13-422f-b81a-67edf19dc07d', '0,0,0,0'); |
HYTOS/HYTOS/UI/MainWindow.ui | ||
---|---|---|
21 | 21 |
<string notr="true"/> |
22 | 22 |
</property> |
23 | 23 |
<property name="windowIcon"> |
24 |
<iconset> |
|
25 |
<normaloff>:/images/hydraulic calculation.svg</normaloff>:/images/hydraulic calculation.svg</iconset>
|
|
24 |
<iconset resource="../res/Resource.qrc">
|
|
25 |
<normaloff>:/images/HYTOS.png</normaloff>:/images/HYTOS.png</iconset>
|
|
26 | 26 |
</property> |
27 | 27 |
<widget class="QWidget" name="centralwidget"> |
28 | 28 |
<layout class="QGridLayout" name="gridLayout"> |
... | ... | |
797 | 797 |
</action> |
798 | 798 |
<action name="actionHelp"> |
799 | 799 |
<property name="icon"> |
800 |
<iconset resource="../res/Resource.qrc">
|
|
800 |
<iconset> |
|
801 | 801 |
<normaloff>:/images/Help.svg</normaloff>:/images/Help.svg</iconset> |
802 | 802 |
</property> |
803 | 803 |
<property name="text"> |
내보내기 Unified diff