개정판 62fd5ea0
issue #1053: - 기기의 데이타를 입력하고 로딩한다(AirFinCooler, Filter에 적용)
- Nozzles 테이블에서 UID 칼럼 제거
Change-Id: I4c92670e0812d3bfc68dad83a2b4fe5a6f9b2c1c
HYTOS/HYTOS/AirFinCooler.py | ||
---|---|---|
41 | 41 |
self.ui.label_Img.setVisible(True) |
42 | 42 |
|
43 | 43 |
def load_data(self): |
44 |
""" display tag no and nozzle data """
|
|
44 |
""" load tag no and nozzle data """
|
|
45 | 45 |
from Drawing import Drawing |
46 | 46 |
|
47 | 47 |
app_doc_data = AppDocData.instance() |
... | ... | |
54 | 54 |
|
55 | 55 |
matches = [connector.nozzle_data for connector in self._item.connectors if connector.nozzle_data] |
56 | 56 |
if matches: |
57 |
self.ui.lineEdit_Pressure.setText(matches[0].pressure)
|
|
58 |
self.ui.lineEdit_Elevation.setText(matches[0].elevation)
|
|
57 |
self.ui.lineEdit_Pressure.setText(str(matches[0].pressure))
|
|
58 |
self.ui.lineEdit_Elevation.setText(str(matches[0].elevation))
|
|
59 | 59 |
|
60 | 60 |
def accept(self): |
61 | 61 |
""" set tag no and nozzle data """ |
... | ... | |
63 | 63 |
|
64 | 64 |
for connector in self._item.connectors: |
65 | 65 |
if not connector.nozzle_data: connector.nozzle_data = NozzleData() |
66 |
connector.nozzle_data.pressure = self.ui.lineEdit_Pressure.text()
|
|
67 |
connector.nozzle_data.elevation = self.ui.lineEdit_Elevation.text()
|
|
66 |
connector.nozzle_data.pressure = float(self.ui.lineEdit_Pressure.text())
|
|
67 |
connector.nozzle_data.elevation = float(self.ui.lineEdit_Elevation.text())
|
|
68 | 68 |
|
69 | 69 |
QDialog.accept(self) |
70 | 70 |
|
HYTOS/HYTOS/AppDocData.py | ||
---|---|---|
2979 | 2979 |
# Roll back any change if something goes wrong |
2980 | 2980 |
conn.rollback() |
2981 | 2981 |
|
2982 |
print(sql) |
|
2983 | 2982 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
2983 |
print(message) |
|
2984 |
print(sql) |
|
2984 | 2985 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
2985 | 2986 |
finally: |
2986 | 2987 |
# Close the db connection |
... | ... | |
3016 | 3017 |
# Close the db connection |
3017 | 3018 |
conn.close() |
3018 | 3019 |
|
3019 |
''' |
|
3020 |
@brief set instrumnet data list |
|
3021 |
@author kyoyho |
|
3022 |
@date 2018.08.14 |
|
3023 |
''' |
|
3024 |
def setInstrumentDataList(self, dataList): |
|
3025 |
try: |
|
3026 |
# Creates or opens a file called mydb with a SQLite3 DB |
|
3027 |
dbPath = os.path.join(self.getCurrentProject().getDbFilePath(), AppDocData.DATABASE) |
|
3028 |
conn = sqlite3.connect(dbPath) |
|
3029 |
# Get a cursor object |
|
3030 |
cursor = conn.cursor() |
|
3031 |
|
|
3032 |
for data in dataList: |
|
3033 |
sql = "insert or replace into INSTRUMENT_DATA_LIST(UID, ITEM_NO, SERVICE, FLOW_RATE, PRESSURE, TEMPERATURE, TPYE, RANGE, NOR_LEVEL_MM, NOR_LEVEL_PERCENT, DEL_PRESS, SHUT_OFF, LOCATION, PNID_NO, REV) values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" |
|
3034 |
param = tuple(data) |
|
3035 |
cursor.execute(sql, param) |
|
3036 |
conn.commit() |
|
3037 |
|
|
3038 |
# Catch the exception |
|
3039 |
except Exception as ex: |
|
3040 |
# Roll back any change if something goes wrong |
|
3041 |
conn.rollback() |
|
3042 |
from App import App |
|
3043 |
|
|
3044 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
|
3045 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
|
3046 |
finally: |
|
3047 |
# Close the db connection |
|
3048 |
conn.close() |
|
3049 |
|
|
3050 |
''' |
|
3051 |
@brief set Note data list |
|
3052 |
@author kyoyho |
|
3053 |
@date 2018.10.10 |
|
3054 |
''' |
|
3055 |
def setNoteDataList(self, dataList): |
|
3056 |
try: |
|
3057 |
# Creates or opens a file called mydb with a SQLite3 DB |
|
3058 |
dbPath = os.path.join(self.getCurrentProject().getDbFilePath(), AppDocData.DATABASE) |
|
3059 |
conn = sqlite3.connect(dbPath) |
|
3060 |
# Get a cursor object |
|
3061 |
cursor = conn.cursor() |
|
3062 |
|
|
3063 |
for data in dataList: |
|
3064 |
sql = "insert or replace into NOTE_DATA_LIST(UID, NOTE_NO, DESCRIPTION, PNID_NO) values(?, ?, ?, ?)" |
|
3065 |
param = tuple(data) |
|
3066 |
cursor.execute(sql, param) |
|
3067 |
conn.commit() |
|
3068 |
|
|
3069 |
# Catch the exception |
|
3070 |
except Exception as ex: |
|
3071 |
# Roll back any change if something goes wrong |
|
3072 |
conn.rollback() |
|
3073 |
from App import App |
|
3074 |
|
|
3075 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
|
3076 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
|
3077 |
finally: |
|
3078 |
# Close the db connection |
|
3079 |
conn.close() |
|
3080 |
|
|
3081 | 3020 |
""" |
3082 | 3021 |
@brief exists drawing |
3083 | 3022 |
@author yeonjin |
... | ... | |
3327 | 3266 |
|
3328 | 3267 |
return ComponentList |
3329 | 3268 |
|
3269 |
def get_nozzle_data(self, uid): |
|
3270 |
""" get nozzle data of given uid """ |
|
3271 |
from EngineeringConnectorItem import NozzleData |
|
3272 |
|
|
3273 |
res = None |
|
3274 |
db_path = os.path.join(self.getCurrentProject().getDbFilePath(), AppDocData.DATABASE) |
|
3275 |
conn = sqlite3.connect(db_path) |
|
3276 |
with conn: |
|
3277 |
conn.row_factory = sqlite3.Row |
|
3278 |
cursor = conn.cursor() |
|
3279 |
sql = 'select Pressure, Elevation from Nozzles where Points_UID=?' |
|
3280 |
param = (uid, ) |
|
3281 |
cursor.execute(sql, param) |
|
3282 |
rows = cursor.fetchall() |
|
3283 |
if rows: |
|
3284 |
res = NozzleData() |
|
3285 |
res.pressure = float(rows[0]['Pressure']) |
|
3286 |
res.elevation = float(rows[0]['Elevation']) |
|
3287 |
|
|
3288 |
return res |
|
3330 | 3289 |
|
3331 | 3290 |
def getDrawingsUnitsByDrawingUID(self, uid): |
3332 | 3291 |
unitsList = [] |
HYTOS/HYTOS/Filter.py | ||
---|---|---|
20 | 20 |
|
21 | 21 |
self.ui = Filter_UI.Ui_FilterDialog() |
22 | 22 |
self.ui.setupUi(self) |
23 |
self.ui.lineEdit_Pressure.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_Pressure)) |
|
24 |
self.ui.lineEdit_Elevation.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_Elevation)) |
|
23 | 25 |
self.initialize() |
24 | 26 |
|
25 | 27 |
def showDialog(self, item): |
26 | 28 |
self.setWindowFlags(self.windowFlags() & ~QtCore.Qt.WindowContextHelpButtonHint) |
29 |
self._item = item |
|
27 | 30 |
|
28 | 31 |
self.ui.lineEdit_TagNo.setFocus() |
29 | 32 |
self.set_controls(item) |
30 |
self.load_units()
|
|
33 |
self.load_data()
|
|
31 | 34 |
|
32 | 35 |
self.exec_() |
33 | 36 |
|
... | ... | |
37 | 40 |
def set_controls(self, item): |
38 | 41 |
self.ui.label_Img.setVisible(True) |
39 | 42 |
|
40 |
def load_units(self): |
|
43 |
def load_data(self): |
|
44 |
""" load tag no and nozzle data """ |
|
41 | 45 |
from Drawing import Drawing |
42 | 46 |
|
43 |
appDocData = AppDocData.instance()
|
|
44 |
drawing = appDocData.activeDrawing
|
|
47 |
app_doc_data = AppDocData.instance()
|
|
48 |
drawing = app_doc_data.activeDrawing
|
|
45 | 49 |
if drawing: |
46 | 50 |
for attr in drawing.attrs: |
47 | 51 |
if attr[0] == 'Units': |
48 | 52 |
self.ui.label_PressureUnit.setText(attr[1]['Pressure']) |
49 | 53 |
self.ui.label_ElevationUnit.setText(attr[1]['Length']) |
50 |
|
|
54 |
|
|
55 |
matches = [connector.nozzle_data for connector in self._item.connectors if connector.nozzle_data] |
|
56 |
if matches: |
|
57 |
self.ui.lineEdit_Pressure.setText(str(matches[0].pressure)) |
|
58 |
self.ui.lineEdit_Elevation.setText(str(matches[0].elevation)) |
|
51 | 59 |
|
52 | 60 |
def accept(self): |
61 |
""" set tag no and nozzle data """ |
|
62 |
from EngineeringConnectorItem import NozzleData |
|
63 |
|
|
64 |
for connector in self._item.connectors: |
|
65 |
if not connector.nozzle_data: connector.nozzle_data = NozzleData() |
|
66 |
connector.nozzle_data.pressure = float(self.ui.lineEdit_Pressure.text()) |
|
67 |
connector.nozzle_data.elevation = float(self.ui.lineEdit_Elevation.text()) |
|
68 |
|
|
53 | 69 |
QDialog.accept(self) |
54 | 70 |
|
55 | 71 |
def reject(self): |
HYTOS/HYTOS/Shapes/EngineeringConnectorItem.py | ||
---|---|---|
464 | 464 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
465 | 465 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
466 | 466 |
|
467 |
@staticmethod |
|
468 |
def fromXml(node): |
|
469 |
""" generate connector instance from xml node """ |
|
470 |
|
|
471 |
attr = QEngineeringConnectorItem() |
|
472 |
|
|
473 |
return attr |
|
474 |
|
|
475 |
def toXml(self): |
|
476 |
""" generate xml code for connector """ |
|
477 |
import uuid |
|
478 |
from xml.etree.ElementTree import Element, SubElement, dump, ElementTree |
|
479 |
|
|
480 |
try: |
|
481 |
node = Element('CONNECTOR') |
|
482 |
node.attrib['UID'] = str(self.uid) |
|
483 |
node.attrib['CONNECTED_AT'] = str(self._connected_at) |
|
484 |
connectedItemNode = Element('CONNECTEDITEM') |
|
485 |
connectedItemNode.text = str(self.connectedItem.uid) if self.connectedItem and not type(self.connectedItem) is uuid.UUID else 'None' |
|
486 |
connectPointNode = Element('CONNECTPOINT') |
|
487 |
connectPointNode.text = str(self.connectPoint[0]) + ',' + str(self.connectPoint[1]) |
|
488 |
sceneConnectPointNode = Element('SCENECONNECTPOINT') |
|
489 |
sceneConnectPointNode.text = str(self.sceneConnectPoint[0]) + ',' + str(self.sceneConnectPoint[1]) |
|
490 |
|
|
491 |
node.append(connectedItemNode) |
|
492 |
node.append(connectPointNode) |
|
493 |
node.append(sceneConnectPointNode) |
|
494 |
except Exception as ex: |
|
495 |
from App import App |
|
496 |
from AppDocData import MessageType |
|
497 |
|
|
498 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
|
499 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
|
500 |
return None |
|
501 |
|
|
502 |
return node |
|
503 |
|
|
504 | 467 |
def toSql(self, index): |
505 | 468 |
""" generate sql string to save connectors to database """ |
469 |
res = [] |
|
470 |
|
|
506 | 471 |
cols = ['UID', 'Components_UID', '[Index]', 'X', 'Y'] |
507 | 472 |
values = ['?', '?', '?', '?', '?'] |
508 | 473 |
|
509 | 474 |
param = [str(self.uid), str(self.parent.uid), index, self.center()[0], self.center()[1]] |
510 | 475 |
sql = 'insert or replace into Points({}) values({})'.format(','.join(cols), ','.join(values)) |
476 |
res.append((sql, tuple(param))) |
|
511 | 477 |
|
512 |
return (sql, tuple(param)) |
|
478 |
cols = ['Points_UID', 'Pressure', 'Elevation'] |
|
479 |
values = ['?', '?', '?'] |
|
480 |
if self.nozzle_data: |
|
481 |
param = [str(self.uid), float(self.nozzle_data.pressure), float(self.nozzle_data.elevation)] |
|
482 |
sql = 'insert or replace into Nozzles({}) values({})'.format(','.join(cols), ','.join(values)) |
|
483 |
res.append((sql, tuple(param))) |
|
484 |
|
|
485 |
return res |
|
513 | 486 |
|
514 | 487 |
''' |
515 | 488 |
@brief The class transfer pyqtSignal Event. Cause Subclass of QGraphicsRectItem can't use pyqtSignal |
HYTOS/HYTOS/Shapes/SymbolSvgItem.py | ||
---|---|---|
212 | 212 |
# save connectors to database |
213 | 213 |
index = 1 |
214 | 214 |
for connector in self.connectors: |
215 |
res.append(connector.toSql(index))
|
|
215 |
res.extend(connector.toSql(index))
|
|
216 | 216 |
index += 1 |
217 | 217 |
# up to here |
218 | 218 |
|
... | ... | |
276 | 276 |
self.connectors[index].symbol_idx = symbol_idx |
277 | 277 |
self.connectors[index].setPos((x, y)) |
278 | 278 |
self.connectors[index].connectPoint = (x, y) |
279 |
#self.connectors[index].sceneConnectPoint = (connPts[index][0], connPts[index][1]) if len(connPts[index]) == 2 else \ |
|
280 |
# (connPts[index][1], connPts[index][2]) if len(connPts[index]) == 3 else \ |
|
281 |
# (connPts[index][1], connPts[index][2]) if len(connPts[index]) == 4 else None |
|
282 | 279 |
|
283 | 280 |
|
284 | 281 |
tooltip = '<b>{}</b><br>{}={}'.format(str(self.uid), self.type, self.name) |
... | ... | |
1098 | 1095 |
@date 2018.07.26 |
1099 | 1096 |
''' |
1100 | 1097 |
def setConnector(self, uid, index=None): |
1098 |
from AppDocData import AppDocData |
|
1099 |
|
|
1100 |
app_doc_data = AppDocData.instance() |
|
1101 | 1101 |
connector = QEngineeringConnectorItem(uid, parent=self, index=index) |
1102 |
connector.nozzle_data = app_doc_data.get_nozzle_data(uid) |
|
1102 | 1103 |
connector.setParentItem(self) |
1103 | 1104 |
self.connectors.append(connector) |
1104 | 1105 |
|
내보내기 Unified diff