개정판 e41d63f8
issue #000: hmb saving test
Change-Id: I0b4974337d913a7f20bed5d40989535b35255156
DTI_PID/DTI_PID/AppDocData.py | ||
---|---|---|
36 | 36 |
@author humkyung |
37 | 37 |
@date 2018.04.24 |
38 | 38 |
''' |
39 |
|
|
40 | 39 |
def sizeValue(self): |
41 | 40 |
return self.inchStr if 'Inch' == self.sizeUnit else self.metricStr |
42 | 41 |
|
... | ... | |
82 | 81 |
self._activeDrawing = None |
83 | 82 |
#self._hmbTable = None |
84 | 83 |
self._hmbColors = {} |
84 |
self._hmbData = None |
|
85 | 85 |
self._streamLineListModelDatas = [] |
86 | 86 |
self._titleBlockProperties = None |
87 | 87 |
self.needReOpening = None |
... | ... | |
167 | 167 |
self._activeDrawing = None |
168 | 168 |
#self._hmbTable = None |
169 | 169 |
self._hmbColors = {} |
170 |
self._hmbData = None |
|
170 | 171 |
self._streamLineListModelDatas = [] |
171 | 172 |
self._titleBlockProperties = None |
172 | 173 |
|
... | ... | |
2483 | 2484 |
self._attributeByType = {} |
2484 | 2485 |
CodeTable.clearTables() |
2485 | 2486 |
|
2486 |
@staticmethod |
|
2487 | 2487 |
def save_hmb_data(hmb_list: list): |
2488 | 2488 |
import uuid |
2489 | 2489 |
|
... | ... | |
2522 | 2522 |
params = (str(uuid.uuid4()), list_uids[index], hmb.uid, data.value, data.value_min, data.value_max) |
2523 | 2523 |
cursor.execute(sql, params) |
2524 | 2524 |
index = index + 1 |
2525 |
|
|
2526 |
self._hmbData = None |
|
2525 | 2527 |
|
2526 | 2528 |
except Exception as ex: |
2527 | 2529 |
# Roll back any change if something goes wrong |
... | ... | |
2532 | 2534 |
f"{sys.exc_info()[-1].tb_lineno}" |
2533 | 2535 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
2534 | 2536 |
|
2535 |
@staticmethod |
|
2536 |
def get_hmb_data(file_path: str): |
|
2537 |
def get_hmb_data(self, file_path: str): |
|
2537 | 2538 |
"""get hmb data from pap database if file_path is given otherwise get hmb data from id2 database""" |
2538 | 2539 |
|
2539 | 2540 |
from HMBTable import HMBData |
2540 | 2541 |
|
2541 | 2542 |
if not file_path: |
2542 |
app_doc_data = AppDocData.instance() |
|
2543 |
with app_doc_data.project.database.connect() as conn: |
|
2544 |
try: |
|
2545 |
cursor = conn.cursor() |
|
2546 |
sql = f"SELECT v.Value, v.Value_Min, v.Value_Max, r.Name, r.Unit, r.[index], r.[Type], s.Stream_No, s.[From], s.[To], s.UID, s.[Type] as Phase FROM " \ |
|
2547 |
f"HMB_VALUE v " \ |
|
2548 |
f"INNER JOIN HMB_LIST r ON v.HMB_LIST_UID=r.UID " \ |
|
2549 |
f"INNER JOIN Stream_No s ON v.Stream_No_UID=s.UID " \ |
|
2550 |
f"ORDER BY s.stream_no" |
|
2551 |
cursor.execute(sql) |
|
2552 |
rows = cursor.fetchall() |
|
2553 |
|
|
2554 |
hmbs = HMBData.from_row(rows) |
|
2555 |
return hmbs |
|
2556 |
except Exception as ex: |
|
2557 |
# Roll back any change if something goes wrong |
|
2558 |
conn.rollback() |
|
2559 |
|
|
2560 |
from App import App |
|
2561 |
message = f"error occurred({repr(ex)}) in {sys.exc_info()[-1].tb_frame.f_code.co_filename}:" \ |
|
2562 |
f"{sys.exc_info()[-1].tb_lineno}" |
|
2563 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
|
2543 |
if self._hmbData is None: |
|
2544 |
app_doc_data = AppDocData.instance() |
|
2545 |
with app_doc_data.project.database.connect() as conn: |
|
2546 |
try: |
|
2547 |
cursor = conn.cursor() |
|
2548 |
sql = f"SELECT v.Value, v.Value_Min, v.Value_Max, r.Name, r.Unit, r.[index], r.[Type], s.Stream_No, s.[From], s.[To], s.UID, s.[Type] as Phase FROM " \ |
|
2549 |
f"HMB_VALUE v " \ |
|
2550 |
f"INNER JOIN HMB_LIST r ON v.HMB_LIST_UID=r.UID " \ |
|
2551 |
f"INNER JOIN Stream_No s ON v.Stream_No_UID=s.UID " \ |
|
2552 |
f"ORDER BY s.stream_no" |
|
2553 |
cursor.execute(sql) |
|
2554 |
rows = cursor.fetchall() |
|
2555 |
|
|
2556 |
hmbs = HMBData.from_row(rows) |
|
2557 |
return hmbs |
|
2558 |
except Exception as ex: |
|
2559 |
# Roll back any change if something goes wrong |
|
2560 |
conn.rollback() |
|
2561 |
|
|
2562 |
from App import App |
|
2563 |
message = f"error occurred({repr(ex)}) in {sys.exc_info()[-1].tb_frame.f_code.co_filename}:" \ |
|
2564 |
f"{sys.exc_info()[-1].tb_lineno}" |
|
2565 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
|
2566 |
else: |
|
2567 |
return self._hmbData |
|
2564 | 2568 |
else: |
2565 | 2569 |
with sqlite3.connect(file_path) as conn: |
2566 | 2570 |
try: |
내보내기 Unified diff