hytos / DTI_PID / DTI_PID / AppDocData.py @ d1a02244
이력 | 보기 | 이력해설 | 다운로드 (79.2 KB)
1 |
# coding: utf-8
|
---|---|
2 | |
3 |
import sys |
4 |
import os |
5 |
import sqlite3 |
6 |
import datetime |
7 |
from PIL import PngImagePlugin, JpegImagePlugin |
8 |
from PIL import Image |
9 |
from PIL.ImageQt import ImageQt |
10 | |
11 |
try:
|
12 |
from PyQt5.QtCore import * |
13 |
from PyQt5.QtGui import * |
14 |
from PyQt5 import QtWidgets |
15 |
except ImportError: |
16 |
from PyQt4.QtCore import * |
17 |
from PyQt4.QtGui import * |
18 |
import numpy as np |
19 |
from enum import Enum |
20 | |
21 |
from SingletonInstance import SingletonInstane |
22 |
import Project |
23 |
import SymbolBase |
24 |
import symbol |
25 |
from EquipmentData import EquipmentData |
26 | |
27 |
class Source: |
28 |
def __init__(self, source): |
29 |
if type(source) is np.ndarray: |
30 |
self.source = Image.fromarray(source)
|
31 |
elif type(source) is PngImagePlugin.PngImageFile or type(source) is JpegImagePlugin.JpegImageFile: |
32 |
self.source = source
|
33 |
elif type(source) is QImage: |
34 |
self.source = Image.fromqimage(source)
|
35 |
elif type(source) is QPixmap: |
36 |
self.source = Image.fromqpixmap(source)
|
37 |
|
38 |
'''
|
39 |
@history 2018.05.18 Jeongwoo When Parameter [rect] is None, return whole image
|
40 |
'''
|
41 |
def getPyImageOnRect(self, rect = None): |
42 |
if rect is not None: |
43 |
return self.source.copy().crop((rect.left(), rect.top(), rect.right(), rect.bottom())) |
44 |
else:
|
45 |
return self.source.copy() |
46 | |
47 |
def getQImageOnRect(self, rect = None): |
48 |
image = ImageQt(self.getPyImageOnRect(rect))
|
49 |
return image.convertToFormat(QImage.Format_RGBA8888)
|
50 | |
51 |
class Area: |
52 |
def __init__(self): |
53 |
self.name = None |
54 |
self.x = None |
55 |
self.y = None |
56 |
self.width = None |
57 |
self.height = None |
58 |
|
59 |
'''
|
60 |
@brief parse area
|
61 |
@author humkyung
|
62 |
@date 2018.06.29
|
63 |
'''
|
64 |
def parse(self, strArea): |
65 |
import re |
66 | |
67 |
found = re.findall('\d+', strArea)
|
68 |
if len(found) == 4: |
69 |
self.x = int(found[0]) |
70 |
self.y = int(found[1]) |
71 |
self.width = int(found[2]) |
72 |
self.height = int(found[3]) |
73 | |
74 |
'''
|
75 |
@brief to string
|
76 |
@author humkyung
|
77 |
@date 2018.06.30
|
78 |
'''
|
79 |
def toString(self): |
80 |
return '({},{}),({},{})'.format(self.x, self.y, self.width, self.height) |
81 |
|
82 |
'''
|
83 |
@brief clone an object
|
84 |
'''
|
85 |
def clone(self): |
86 |
clone = Area() |
87 |
clone.x = self.x
|
88 |
clone.y = self.y
|
89 |
clone.width = self.width
|
90 |
clone.height = self.height
|
91 | |
92 |
class Config: |
93 |
def __init__(self, section, key, value): |
94 |
self.section = section
|
95 |
self.key = key
|
96 |
self.value = value
|
97 | |
98 |
class NominalPipeSize: |
99 |
def __init__(self, code, metric, inch, inchStr, metricStr): |
100 |
self.code = code
|
101 |
self.metric = metric
|
102 |
self.inch = inch
|
103 |
self.inchStr = inchStr
|
104 |
self.metricStr = metricStr
|
105 |
self.sizeUnit = 'Metric' |
106 | |
107 |
'''
|
108 |
@brief return size value string
|
109 |
@author humkyung
|
110 |
@date 2018.04.24
|
111 |
'''
|
112 |
def sizeValue(self): |
113 |
return self.inchStr if 'Inch' == self.sizeUnit else self.metricStr |
114 | |
115 |
'''
|
116 |
@brief Pipe color class
|
117 |
'''
|
118 |
class Color: |
119 |
def __init__(self, index, red, green, blue): |
120 |
self.index = index
|
121 |
self.red = red
|
122 |
self.green = green
|
123 |
self.blue = blue
|
124 | |
125 |
'''
|
126 |
@brief MessageType
|
127 |
@author humkyung
|
128 |
@date 2018.07.31
|
129 |
'''
|
130 |
class MessageType(Enum): |
131 |
Normal = 1
|
132 |
Error = 2
|
133 | |
134 |
class AppDocData(SingletonInstane): |
135 |
def __init__(self): |
136 |
self._imgFilePath = None |
137 |
self.imgName = None |
138 |
self.imgWidth = 0 |
139 |
self.imgHeight = 0 |
140 |
self._imgSrc = None |
141 | |
142 |
self._areas = []
|
143 |
self.equipments = []
|
144 |
#self.equipmentDataList = []
|
145 |
self.lineNos = []
|
146 |
self.lines = []
|
147 |
self.symbols = []
|
148 |
self._colors = None |
149 |
self._lineTypes = None |
150 |
self._lineTypeConfigs = None |
151 |
self._activeDrawing = None |
152 |
self._hmbTable = None |
153 | |
154 |
'''
|
155 |
@brief Get DB file path in ProgramData
|
156 |
@author Jeongwoo
|
157 |
@date 2018.06.27
|
158 |
@history 2018.06.29 Jeongwoo Change method to get template db path
|
159 |
'''
|
160 |
def getTemplateDbPath(self): |
161 |
path = os.path.join(os.getenv('ALLUSERSPROFILE'), 'Digital PID') |
162 |
templateDbPath = os.path.join(path, 'Template.db')
|
163 |
return templateDbPath
|
164 | |
165 |
'''
|
166 |
@brief getter of colors
|
167 |
@author humkyung
|
168 |
@date 2018.06.18
|
169 |
'''
|
170 |
@property
|
171 |
def colors(self): |
172 |
if self._colors is None: |
173 |
self._colors = []
|
174 |
try:
|
175 |
dbPath = os.path.join(self.getCurrentProject().getDbFilePath() , 'ITI_PID.db') |
176 | |
177 |
conn = sqlite3.connect(dbPath) |
178 |
cursor = conn.cursor() |
179 |
sql = 'SELECT UID,RED,GREEN,BLUE FROM Colors'
|
180 |
cursor.execute(sql) |
181 |
rows = cursor.fetchall() |
182 |
for row in rows: |
183 |
self._colors.append(Color(int(row[0]), int(row[1]), int(row[2]), int(row[3]))) |
184 |
# Catch the exception
|
185 |
except Exception as ex: |
186 |
# Roll back any change if something goes wrong
|
187 |
conn.rollback() |
188 | |
189 |
from App import App |
190 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
191 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
192 |
finally:
|
193 |
conn.close() |
194 | |
195 |
return self._colors |
196 | |
197 |
'''
|
198 |
@brief setter of colors
|
199 |
@author humkyung
|
200 |
@date 2018.06.18
|
201 |
'''
|
202 |
@colors.setter
|
203 |
def colors(self, value): |
204 |
self._colors = value
|
205 | |
206 |
'''
|
207 |
@brief set image file path
|
208 |
@author humkyung
|
209 |
@date 2018.07.30
|
210 |
'''
|
211 |
def setImgFilePath(self, path): |
212 |
self._imgFilePath = path
|
213 |
self.imgName = os.path.splitext(os.path.basename(self._imgFilePath))[0] |
214 | |
215 |
'''
|
216 |
@brief getter of imgSrc
|
217 |
@author humkyung
|
218 |
@date 2018.07.30
|
219 |
'''
|
220 |
@property
|
221 |
def imgSrc(self): |
222 |
import cv2 |
223 | |
224 |
if self._imgSrc is None and self._imgFilePath is not None and os.path.isfile(self._imgFilePath): |
225 |
self._imgSrc = cv2.cvtColor(cv2.imread(self._imgFilePath), cv2.COLOR_BGR2GRAY) |
226 |
blur = cv2.GaussianBlur(self._imgSrc , (5,5),0) |
227 |
self._imgSrc = cv2.threshold(self._imgSrc , 0, 255, cv2.THRESH_BINARY+cv2.THRESH_OTSU)[1] |
228 |
|
229 |
return self._imgSrc |
230 | |
231 |
'''
|
232 |
@brief setter of imgSrc
|
233 |
@author humkyung
|
234 |
@date 2018.07.30
|
235 |
'''
|
236 |
@imgSrc.setter
|
237 |
def imgSrc(self, value): |
238 |
self._imgSrc = value
|
239 | |
240 |
'''
|
241 |
@brief reset imgSrc
|
242 |
@author humkyung
|
243 |
@date 2018.07.30
|
244 |
'''
|
245 |
def resetImgSrc(self): |
246 |
self._imgSrc = None |
247 | |
248 |
'''
|
249 |
@brief getter of line type configs
|
250 |
@author humkyung
|
251 |
@date 2018.06.28
|
252 |
'''
|
253 |
@property
|
254 |
def lineTypeConfigs(self): |
255 |
from PyQt5.QtCore import Qt |
256 | |
257 |
if self._lineTypeConfigs is None: |
258 |
self._lineTypeConfigs = []
|
259 | |
260 |
styleMap = [('SolidLine', Qt.SolidLine), ('DashLine', Qt.DashLine), ('DotLine', Qt.DotLine), ('DashDotLine', Qt.DashDotLine), |
261 |
('DashDotDotLine', Qt.DashDotDotLine), ('CustomDashLine', Qt.CustomDashLine)] |
262 | |
263 |
configs = self.getConfigs('LineTypes') |
264 |
for config in configs: |
265 |
width, _style = config.value.split(',')
|
266 |
matches = [param for param in styleMap if param[0] == _style] |
267 |
style = matches[0][1] if matches else Qt.SolidLine |
268 |
self._lineTypeConfigs.append((config.key, int(width), style)) |
269 |
|
270 |
return self._lineTypeConfigs |
271 | |
272 |
'''
|
273 |
@brief setter of line type configs
|
274 |
@author humkyung
|
275 |
@date 2018.06.28
|
276 |
'''
|
277 |
@lineTypeConfigs.setter
|
278 |
def lineTypeConfigs(self, value): |
279 |
self._lineTypeConfigs = value
|
280 | |
281 |
'''
|
282 |
@brief getter of hmb table
|
283 |
@author humkyung
|
284 |
@date 2018.07.16
|
285 |
'''
|
286 |
@property
|
287 |
def hmbTable(self): |
288 |
from HMBTable import HMBTable |
289 | |
290 |
if self._hmbTable is None: |
291 |
self._hmbTable = HMBTable()
|
292 |
self._hmbTable.loadData()
|
293 |
|
294 |
return self._hmbTable |
295 | |
296 |
'''
|
297 |
@brief setter of hmb table
|
298 |
@author humkyung
|
299 |
@date 2018.07.16
|
300 |
'''
|
301 |
@hmbTable.setter
|
302 |
def hmbTable(self, value): |
303 |
self._hmbTable = value
|
304 | |
305 |
'''
|
306 |
@brief get line type config of given line type
|
307 |
@author humkyung
|
308 |
@date 2018.06.28
|
309 |
'''
|
310 |
def getLineTypeConfig(self, lineType): |
311 |
from PyQt5.QtCore import Qt |
312 | |
313 |
matches = [config for config in self.lineTypeConfigs if config[0] == lineType] |
314 |
return matches[0] if matches else (lineType, 5, Qt.SolidLine) |
315 | |
316 |
def setCurrentPidSource(self, image): |
317 |
self.imgWidth, self.imgHeight = image.size |
318 | |
319 |
self.currentPidSource = Source(image)
|
320 | |
321 |
def getCurrentPidSource(self): |
322 |
return self.currentPidSource |
323 | |
324 |
'''
|
325 |
@brief Check if Exist data or not, Moved from SG_DbHelper
|
326 |
@author Jeongwoo
|
327 |
@date 2018.05.03
|
328 |
'''
|
329 |
def isExistData(self, fieldName, data): |
330 |
rows = None
|
331 |
try:
|
332 |
dbPath = os.path.join(self.getCurrentProject().getDbFilePath(), "ITI_PID.db") |
333 | |
334 |
conn = sqlite3.connect(dbPath) |
335 |
cursor = conn.cursor() |
336 |
sql = ""
|
337 |
if isinstance(data, str): |
338 |
sql = "SELECT * FROM Symbol WHERE " + fieldName + " = '"+ data +"'" |
339 |
else:
|
340 |
sql = "SELECT * FROM Symbol WHERE " + fieldName + " = "+ str(data) +"" |
341 |
cursor.execute(sql) |
342 |
rows = cursor.fetchall() |
343 |
# Catch the exception
|
344 |
except Exception as ex: |
345 |
# Roll back any change if something goes wrong
|
346 |
conn.rollback() |
347 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
348 |
finally:
|
349 |
conn.close() |
350 |
if rows is not None and len(rows) > 0: |
351 |
return True |
352 |
else:
|
353 |
return False |
354 | |
355 |
'''
|
356 |
@brief Check if exist file name or not, Moved from SG_DbHelper
|
357 |
@author Jeongwoo
|
358 |
@date 2018.05.03
|
359 |
'''
|
360 |
def isExistFileName(self, name): |
361 |
rows = None
|
362 |
try:
|
363 |
dbPath = os.path.join(self.getCurrentProject().getDbFilePath(), "ITI_PID.db") |
364 |
conn = sqlite3.connect(dbPath) |
365 |
cursor = conn.cursor() |
366 |
sql = "SELECT * FROM Symbol WHERE name = '"+ name +"'" |
367 |
cursor.execute(sql) |
368 |
rows = cursor.fetchall() |
369 |
# Catch the exception
|
370 |
except Exception as ex: |
371 |
# Roll back any change if something goes wrong
|
372 |
conn.rollback() |
373 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
374 |
finally:
|
375 |
conn.close() |
376 |
if rows is not None and len(rows) > 0: |
377 |
return True |
378 |
else:
|
379 |
return False |
380 | |
381 |
'''
|
382 |
@brief Insert new symbol into Symbol Table, Moved from SG_DbHelper
|
383 |
@author Jeongwoo
|
384 |
@date 2018.05.03
|
385 |
'''
|
386 |
def insertSymbol(self, symbol): |
387 |
isAdded = False
|
388 |
try:
|
389 |
dbPath = os.path.join(self.getCurrentProject().getDbFilePath(), 'ITI_PID.db') |
390 |
conn = sqlite3.connect(dbPath) |
391 |
|
392 |
INSERT_SYMBOL_SQL = '''
|
393 |
INSERT INTO Symbol(name, type, threshold, minMatchPoint, isDetectOrigin, rotationCount, ocrOption, isContainChild, originalPoint, connectionPoint, baseSymbol, additionalSymbol, isExceptDetect, hasInstrumentLabel)
|
394 |
VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);
|
395 |
'''
|
396 | |
397 |
cursor = conn.cursor() |
398 |
query = ( symbol.getName(), symbol.getType(), symbol.getThreshold() |
399 |
, symbol.getMinMatchCount(), symbol.getIsDetectOnOrigin(), symbol.getRotationCount() |
400 |
, symbol.getOcrOption(), symbol.getIsContainChild() |
401 |
, symbol.getOriginalPoint(), symbol.getConnectionPoint() |
402 |
, symbol.getBaseSymbol(), symbol.getAdditionalSymbol(), symbol.getIsExceptDetect(), symbol.getHasInstrumentLabel()) |
403 |
cursor.execute(INSERT_SYMBOL_SQL, query) |
404 |
conn.commit() |
405 |
isAdded = True
|
406 |
# Catch the exception
|
407 |
except Exception as ex: |
408 |
# Roll back any change if something goes wrong
|
409 |
conn.rollback() |
410 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
411 |
finally:
|
412 |
conn.close() |
413 |
return (isAdded, symbol.getType(), symbol.getName(), symbol.getPath())
|
414 | |
415 |
'''
|
416 |
@brief Update symbol in Symbol Table, Moved from SG_DbHelper
|
417 |
@author Jeongwoo
|
418 |
@date 2018.05.03
|
419 |
'''
|
420 |
def updateSymbol(self, symbol): |
421 |
isUpdated = False
|
422 |
try:
|
423 |
dbPath = os.path.join(self.getCurrentProject().getDbFilePath(), 'ITI_PID.db') |
424 |
conn = sqlite3.connect(dbPath) |
425 |
|
426 |
UPDATE_SYMBOL_SQL = '''
|
427 |
UPDATE Symbol
|
428 |
SET
|
429 |
name = ?, type = ?, threshold = ?, minMatchPoint = ?, isDetectOrigin = ?,
|
430 |
rotationCount = ?, ocrOption = ?, isContainChild = ?, originalPoint = ?, connectionPoint = ?,
|
431 |
baseSymbol = ?, additionalSymbol = ?, isExceptDetect = ?, hasInstrumentLabel = ?
|
432 |
WHERE uid = ?
|
433 |
'''
|
434 |
|
435 |
cursor = conn.cursor() |
436 |
query = (symbol.getName(), symbol.getType(), symbol.getThreshold() |
437 |
, symbol.getMinMatchCount(), symbol.getIsDetectOnOrigin(), symbol.getRotationCount() |
438 |
, symbol.getOcrOption(), symbol.getIsContainChild() |
439 |
, symbol.getOriginalPoint(), symbol.getConnectionPoint() |
440 |
, symbol.getBaseSymbol(), symbol.getAdditionalSymbol(), symbol.getIsExceptDetect(), symbol.getHasInstrumentLabel(), symbol.getUid()) |
441 |
cursor.execute(UPDATE_SYMBOL_SQL, query) |
442 |
conn.commit() |
443 |
isUpdated = True
|
444 |
# Catch the exception
|
445 |
except Exception as ex: |
446 |
# Roll back any change if something goes wrong
|
447 |
conn.rollback() |
448 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
449 |
finally:
|
450 |
conn.close() |
451 |
return (isUpdated, symbol.getType(), symbol.getName(), symbol.getPath())
|
452 | |
453 |
'''
|
454 |
@brief Get Detecting Target Symbol List (Field 'isExceptDetect' == False(0))
|
455 |
@author Jeongwoo
|
456 |
@date 18.04.24
|
457 |
@history humkyung 2018.06.28 select symbol order by threshold descending
|
458 |
'''
|
459 |
def getTargetSymbolList(self): |
460 |
targetSymbolList = [] |
461 | |
462 |
try:
|
463 |
dbPath = os.path.join(self.getCurrentProject().getDbFilePath(), "ITI_PID.db") |
464 | |
465 |
conn = sqlite3.connect(dbPath) |
466 |
cursor = conn.cursor() |
467 |
sql = 'SELECT * FROM Symbol WHERE isExceptDetect = 0 order by threshold desc'
|
468 |
try:
|
469 |
cursor.execute(sql) |
470 |
rows = cursor.fetchall() |
471 |
for row in rows: |
472 |
sym = symbol.SymbolBase(row[1], row[2], row[3], row[4], row[5], row[6], row[7], row[8], row[9], row[10], row[11], row[12], row[13], row[14], row[0]) ## uid is last item |
473 |
targetSymbolList.append(sym) |
474 |
except Exception as ex: |
475 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
476 |
finally:
|
477 |
conn.close() |
478 | |
479 |
return targetSymbolList
|
480 | |
481 |
'''
|
482 |
@brief build application database
|
483 |
@author humkyung
|
484 |
@date 2018.04.20
|
485 |
'''
|
486 |
def buildAppDatabase(self): |
487 |
try:
|
488 |
path = os.path.join(os.getenv('ALLUSERSPROFILE'), 'Digital PID') |
489 |
appDatabaseFilePath = os.path.join(path, 'App.db')
|
490 | |
491 |
# Creates or opens a file called mydb with a SQLite3 DB
|
492 |
conn = sqlite3.connect(appDatabaseFilePath) |
493 |
# Get a cursor object
|
494 |
cursor = conn.cursor() |
495 | |
496 |
sqlFiles = ['App.Configuration.sql', 'App.Styles.sql'] |
497 |
for sqlFile in sqlFiles: |
498 |
filePath = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'Scripts', sqlFile)
|
499 |
try:
|
500 |
file = QFile(filePath) |
501 |
file.open(QFile.ReadOnly)
|
502 |
sql = file.readAll()
|
503 |
sql = str(sql, encoding='utf8') |
504 |
cursor.executescript(sql) |
505 |
finally:
|
506 |
file.close()
|
507 |
conn.commit() |
508 |
# Catch the exception
|
509 |
except Exception as ex: |
510 |
# Roll back any change if something goes wrong
|
511 |
conn.rollback() |
512 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
513 |
finally:
|
514 |
# Close the db connection
|
515 |
conn.close() |
516 | |
517 |
'''
|
518 |
@brief load app style
|
519 |
@author humkyung
|
520 |
@date 2018.04.20
|
521 |
'''
|
522 |
def loadAppStyle(self): |
523 |
style = 'Fusion'
|
524 | |
525 |
path = os.path.join(os.getenv('ALLUSERSPROFILE'), 'Digital PID') |
526 |
if not os.path.exists(path): os.makedirs(path) |
527 | |
528 |
self.buildAppDatabase()
|
529 |
try:
|
530 |
appDatabaseFilePath = os.path.join(path, 'App.db')
|
531 |
# Creates or opens a file called mydb with a SQLite3 DB
|
532 |
conn = sqlite3.connect(appDatabaseFilePath) |
533 |
# Get a cursor object
|
534 |
cursor = conn.cursor() |
535 | |
536 |
sql = "select Value from Configuration where Section='App' and Key='Style'"
|
537 |
cursor.execute(sql) |
538 |
rows = cursor.fetchall() |
539 |
style = rows[0][0] if 1 == len(rows) else 'Fusion' |
540 |
# Catch the exception
|
541 |
except Exception as ex: |
542 |
# Roll back any change if something goes wrong
|
543 |
conn.rollback() |
544 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
545 |
finally:
|
546 |
# Close the db connection
|
547 |
conn.close() |
548 | |
549 |
return style
|
550 | |
551 |
'''
|
552 |
@brief load app styles and then return a list
|
553 |
@author humkyung
|
554 |
@date 2018.04.20
|
555 |
'''
|
556 |
def loadAppStyles(self): |
557 |
styles = [] |
558 | |
559 |
try:
|
560 |
self.buildAppDatabase()
|
561 | |
562 |
path = os.path.join(os.getenv('ALLUSERSPROFILE'), 'Digital PID') |
563 |
appDatabaseFilePath = os.path.join(path, 'App.db')
|
564 | |
565 |
# Creates or opens a file called mydb with a SQLite3 DB
|
566 |
conn = sqlite3.connect(appDatabaseFilePath) |
567 |
# Get a cursor object
|
568 |
cursor = conn.cursor() |
569 | |
570 |
sql = 'select UID,Value from Styles'
|
571 |
cursor.execute(sql) |
572 |
rows = cursor.fetchall() |
573 |
for row in rows: styles.append(row[1]) |
574 |
if 0 == len(rows): rows.append('fusion') |
575 |
# Catch the exception
|
576 |
except Exception as ex: |
577 |
# Roll back any change if something goes wrong
|
578 |
conn.rollback() |
579 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
580 |
finally:
|
581 |
# Close the db connection
|
582 |
conn.close() |
583 | |
584 |
return styles
|
585 | |
586 |
'''
|
587 |
@brief Set current Project
|
588 |
@history 2018.06.27 Jeongwoo If DB file is not, copy DB file from ProgramData
|
589 |
'''
|
590 |
def setCurrentProject(self, project): |
591 |
self.project = project
|
592 |
self.makeChildDir()
|
593 |
try:
|
594 |
# Creates or opens a file called mydb with a SQLite3 DB
|
595 |
dbPath = os.path.join(self.getCurrentProject().getDbFilePath() , "ITI_PID.db") |
596 |
|
597 |
if not os.path.isfile(dbPath): |
598 |
templatePath = self.getTemplateDbPath()
|
599 |
templateFile = QFile(templatePath) |
600 |
templateFile.copy(dbPath) |
601 |
else:
|
602 |
try:
|
603 |
conn = sqlite3.connect(dbPath) |
604 |
# Get a cursor object
|
605 |
cursor = conn.cursor() |
606 | |
607 |
fileNames = os.listdir(os.path.join(os.path.dirname(os.path.realpath(__file__)), 'Scripts'))
|
608 |
for fileName in fileNames: |
609 |
if fileName.endswith(".sql") and (1 == len(os.path.splitext(fileName)[0].split('.'))): |
610 |
try:
|
611 |
file = QFile(os.path.join(os.path.dirname(os.path.realpath(__file__)), 'Scripts', fileName))
|
612 |
file.open(QFile.ReadOnly)
|
613 |
sql = file.readAll()
|
614 |
sql = str(sql, encoding='utf8') |
615 |
cursor.executescript(sql) |
616 |
finally:
|
617 |
file.close()
|
618 |
conn.commit() |
619 |
except Exception as ex: |
620 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
621 |
finally:
|
622 |
conn.close() |
623 |
# Catch the exception
|
624 |
except Exception as ex: |
625 |
# Roll back any change if something goes wrong
|
626 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
627 |
finally:
|
628 |
pass
|
629 | |
630 |
'''
|
631 |
@brief Make Directory
|
632 |
@author Jeongwoo
|
633 |
@date 18.05.08
|
634 |
@history humkyung 2018.06.19 make 'Tile' directory
|
635 |
humkyung 2018.07.09 make drawing folder if not exists
|
636 |
'''
|
637 |
def makeChildDir(self): |
638 |
project = AppDocData.instance().getCurrentProject() |
639 |
dbDir = project.getDbFilePath() |
640 |
if not os.path.exists(dbDir): |
641 |
os.makedirs(dbDir) |
642 |
imgDir = project.getImageFilePath() |
643 |
if not os.path.exists(imgDir): |
644 |
os.makedirs(imgDir) |
645 |
svgDir = project.getSvgFilePath() |
646 |
if not os.path.exists(svgDir): |
647 |
os.makedirs(svgDir) |
648 |
outputDir = project.getOutputPath() |
649 |
if not os.path.exists(outputDir): |
650 |
os.makedirs(outputDir) |
651 |
tempDir = project.getTempPath() |
652 |
if not os.path.exists(tempDir): |
653 |
os.makedirs(tempDir) |
654 |
drawingPath = project.getDrawingFilePath() |
655 |
if not os.path.exists(drawingPath): |
656 |
os.makedirs(drawingPath) |
657 |
|
658 |
path = os.path.join(tempDir, 'Tile')
|
659 |
if not os.path.exists(path): |
660 |
os.makedirs(path) |
661 | |
662 |
'''
|
663 |
@brief Get current Project
|
664 |
'''
|
665 |
def getCurrentProject(self): |
666 |
return self.project |
667 | |
668 |
'''
|
669 |
@brief return project database path
|
670 |
@history humkyung 2018.04.19 return Project.db in Program Data folder instead of PROJECT_DB_PATH variable
|
671 |
'''
|
672 |
def getPrjDatabasePath(self): |
673 |
path = os.path.join(os.getenv('ALLUSERSPROFILE'), 'Digital PID') |
674 |
if not os.path.exists(path): os.makedirs(path) |
675 | |
676 |
prjDatabaseFilePath = os.path.join(path, 'Project.db')
|
677 |
try:
|
678 |
# Creates or opens a file called mydb with a SQLite3 DB
|
679 |
conn = sqlite3.connect(prjDatabaseFilePath) |
680 |
# Get a cursor object
|
681 |
cursor = conn.cursor() |
682 | |
683 |
filePath = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'Scripts', 'Project.Projects.sql') |
684 |
try:
|
685 |
file = QFile(filePath) |
686 |
file.open(QFile.ReadOnly)
|
687 |
sql = file.readAll()
|
688 |
sql = str(sql, encoding='utf8') |
689 |
cursor.executescript(sql) |
690 |
finally:
|
691 |
file.close()
|
692 |
conn.commit() |
693 |
# Catch the exception
|
694 |
except Exception as ex: |
695 |
# Roll back any change if something goes wrong
|
696 |
conn.rollback() |
697 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
698 |
finally:
|
699 |
# Close the db connection
|
700 |
conn.close() |
701 |
|
702 |
return prjDatabaseFilePath
|
703 | |
704 |
'''
|
705 |
@brief return line properties
|
706 |
@author humkyung
|
707 |
@date 2018.04.09
|
708 |
'''
|
709 |
def getLineProperties(self): |
710 |
res = [] |
711 |
try:
|
712 |
# Creates or opens a file called mydb with a SQLite3 DB
|
713 |
dbPath = os.path.join(self.getCurrentProject().getDbFilePath(), 'ITI_PID.db') |
714 |
db = sqlite3.connect(dbPath) |
715 |
# Get a cursor object
|
716 |
cursor = db.cursor() |
717 | |
718 |
sql = "select Name from LineProperties order by Name"
|
719 |
cursor.execute(sql) |
720 |
rows = cursor.fetchall() |
721 |
for row in rows: |
722 |
res.append(row[0])
|
723 |
# Catch the exception
|
724 |
except Exception as ex: |
725 |
# Roll back any change if something goes wrong
|
726 |
db.rollback() |
727 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
728 |
finally:
|
729 |
# Close the db connection
|
730 |
db.close() |
731 | |
732 |
return res
|
733 | |
734 |
'''
|
735 |
@brief return line types
|
736 |
@author humkyung
|
737 |
@date 2018.06.27
|
738 |
'''
|
739 |
def getLineTypes(self): |
740 |
res = [] |
741 |
try:
|
742 |
# Creates or opens a file called mydb with a SQLite3 DB
|
743 |
dbPath = os.path.join(self.getCurrentProject().getDbFilePath(), 'ITI_PID.db') |
744 |
db = sqlite3.connect(dbPath) |
745 |
# Get a cursor object
|
746 |
cursor = db.cursor() |
747 | |
748 |
sql = "select Name from LineTypes order by Name"
|
749 |
cursor.execute(sql) |
750 |
rows = cursor.fetchall() |
751 |
for row in rows: |
752 |
res.append(row[0])
|
753 |
# Catch the exception
|
754 |
except Exception as ex: |
755 |
# Roll back any change if something goes wrong
|
756 |
db.rollback() |
757 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
758 |
finally:
|
759 |
# Close the db connection
|
760 |
db.close() |
761 | |
762 |
return res
|
763 | |
764 |
'''
|
765 |
@brief Insert New Project Info
|
766 |
@author Jeongwoo
|
767 |
@date 2018.04.06
|
768 |
@history humkyung 2018.04.19 use getPrjDatabasePath function instead of PROJECT_DB_PATH variable
|
769 |
'''
|
770 |
def insertProjectInfo(self, dir): |
771 |
try:
|
772 |
prjDatabaseFilePath = self.getPrjDatabasePath()
|
773 |
conn = sqlite3.connect(prjDatabaseFilePath) |
774 |
folderName = dir.split('/')[-1] |
775 |
if folderName:
|
776 |
nowDate = datetime.datetime.now().strftime('%Y.%m.%d %H:%M')
|
777 |
sql = "INSERT INTO Projects(Name, Path, CreatedDate, UpdatedDate) VALUES('" + folderName + "', '" + dir + "', '" + nowDate + "', '" + nowDate + "')" |
778 |
cur = conn.cursor() |
779 |
cur.execute(sql) |
780 |
conn.commit() |
781 |
else:
|
782 |
print("Empty folder name")
|
783 |
except Exception as ex: |
784 |
# Roll back any change if something goes wrong
|
785 |
conn.rollback() |
786 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
787 |
finally:
|
788 |
conn.close() |
789 | |
790 |
'''
|
791 |
@brief Update Project UpdatedDate Field
|
792 |
@author Jeongwoo
|
793 |
@date 2018.04.06
|
794 |
@history humkyung 2018.04.19 use getPrjDatabasePath function instead of PROJECT_DB_PATH variable
|
795 |
'''
|
796 |
def updateProjectUpdatedDate(self, id): |
797 |
try:
|
798 |
prjDatabaseFilePath = self.getPrjDatabasePath()
|
799 |
conn = sqlite3.connect(prjDatabaseFilePath) |
800 |
nowDate = datetime.datetime.now().strftime('%Y.%m.%d %H:%M')
|
801 |
sql = '''
|
802 |
UPDATE Projects
|
803 |
SET UpdatedDate = ?
|
804 |
WHERE Id = ?
|
805 |
'''
|
806 |
cur = conn.cursor() |
807 |
cur.execute(sql, (nowDate, id))
|
808 |
conn.commit() |
809 |
except Exception as ex: |
810 |
# Roll back any change if something goes wrong
|
811 |
conn.rollback() |
812 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
813 |
finally:
|
814 |
conn.close() |
815 | |
816 |
'''
|
817 |
@brief get project list from database
|
818 |
@history humkyung 2018.04.18 add only project which's project exists
|
819 |
'''
|
820 |
def getProjectList(self): |
821 |
from Project import Project |
822 | |
823 |
projectList = [] |
824 | |
825 |
try:
|
826 |
conn = sqlite3.connect(self.getPrjDatabasePath())
|
827 |
cursor = conn.cursor() |
828 |
sql = 'SELECT id,name,path,createddate,updateddate FROM Projects ORDER BY UpdatedDate DESC'
|
829 |
try:
|
830 |
cursor.execute(sql) |
831 |
rows = cursor.fetchall() |
832 |
for row in rows: |
833 |
if os.path.isdir(row[2]): # check if folder exists |
834 |
projectList.append(Project(row[0], row[1], row[2], row[3], row[4])) |
835 |
except Exception as ex: |
836 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
837 |
finally:
|
838 |
conn.close() |
839 | |
840 |
return projectList
|
841 | |
842 |
'''
|
843 |
@brief get sliding window size
|
844 |
@author humkyung
|
845 |
'''
|
846 |
def getSlidingWindowSize(self): |
847 |
res = [10,10] |
848 |
try:
|
849 |
configs = self.getConfigs('Sliding Window') |
850 |
for config in configs: |
851 |
if config.key == 'Width': |
852 |
res[0] = int(config.value) |
853 |
elif config.key == 'Height': |
854 |
res[1] = int(config.value) |
855 |
# Catch the exception
|
856 |
except Exception as ex: |
857 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
858 |
|
859 |
return res
|
860 | |
861 |
'''
|
862 |
@brief get line no configuration
|
863 |
@author humkyung
|
864 |
@date 2018.04.16
|
865 |
'''
|
866 |
def getLineNoConfiguration(self): |
867 |
res = None
|
868 |
try:
|
869 |
# Creates or opens a file called mydb with a SQLite3 DB
|
870 |
dbPath = os.path.join(self.getCurrentProject().getDbFilePath(), 'ITI_PID.db') |
871 |
conn = sqlite3.connect(dbPath) |
872 |
# Get a cursor object
|
873 |
cursor = conn.cursor() |
874 | |
875 |
delimiter = None
|
876 |
sql = "select * from configuration where section='Line No' and key='Delimiter"
|
877 |
cursor.execute(sql) |
878 |
rows = cursor.fetchall() |
879 |
if len(rows) == 1: |
880 |
delimiter = rows[0][2] |
881 | |
882 |
if delimiter is not None: |
883 |
sql = "select * from configuration where section='Line No' and key='Configuration'"
|
884 |
cursor.execute(sql) |
885 |
rows = cursor.fetchall() |
886 |
if len(rows) == 1: |
887 |
res = rows[0][2].split(delimiter) |
888 |
# Catch the exception
|
889 |
except Exception as ex: |
890 |
# Roll back any change if something goes wrong
|
891 |
conn.rollback() |
892 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
893 |
finally:
|
894 |
# Close the db connection
|
895 |
conn.close() |
896 |
|
897 |
return res
|
898 | |
899 |
'''
|
900 |
@brief get area list
|
901 |
@author humkyung
|
902 |
'''
|
903 |
def getAreaList(self): |
904 |
if len(self._areas) == 0: |
905 |
try:
|
906 |
# Creates or opens a file called mydb with a SQLite3 DB
|
907 |
dbPath = self.getCurrentProject().getDbFilePath() + "/ITI_PID.db" |
908 |
conn = sqlite3.connect(dbPath) |
909 |
# Get a cursor object
|
910 |
cursor = conn.cursor() |
911 | |
912 |
sql = "select * from configuration where section='Area'"
|
913 |
cursor.execute(sql) |
914 |
rows = cursor.fetchall() |
915 |
for row in rows: |
916 |
area = Area() |
917 |
area.name = row[1]
|
918 |
area.parse(row[2])
|
919 |
self._areas.append(area)
|
920 |
# Catch the exception
|
921 |
except Exception as ex: |
922 |
# Roll back any change if something goes wrong
|
923 |
conn.rollback() |
924 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
925 |
finally:
|
926 |
# Close the db connection
|
927 |
conn.close() |
928 |
|
929 |
return self._areas |
930 | |
931 |
'''
|
932 |
@brief get area of given name
|
933 |
@author humkyung
|
934 |
@date 2018.04.07
|
935 |
'''
|
936 |
def getArea(self, name): |
937 |
areas = self.getAreaList()
|
938 |
matches = [area for area in areas if area.name==name] |
939 |
if 1 == len(matches): return matches[0] |
940 | |
941 |
return None |
942 | |
943 |
'''
|
944 |
@brief get configurations
|
945 |
@author humkyung
|
946 |
@date 2018.04.16
|
947 |
@history kyouho 2018.07.09 change query method
|
948 |
'''
|
949 |
def getConfigs(self, section, key=None): |
950 |
res = [] |
951 | |
952 |
try:
|
953 |
# Creates or opens a file called mydb with a SQLite3 DB
|
954 |
dbPath = os.path.join(self.getCurrentProject().getDbFilePath(), 'ITI_PID.db') |
955 |
conn = sqlite3.connect(dbPath) |
956 |
# Get a cursor object
|
957 |
cursor = conn.cursor() |
958 | |
959 |
if key is not None: |
960 |
sql = "select * from configuration where section=? and key=?"
|
961 |
param = (section, key) |
962 |
else:
|
963 |
sql = "select * from configuration where section=?"
|
964 |
param = (section,) |
965 | |
966 |
cursor.execute(sql, param) |
967 |
rows = cursor.fetchall() |
968 |
for row in rows: |
969 |
res.append(Config(row[0], row[1], row[2])) |
970 |
# Catch the exception
|
971 |
except Exception as ex: |
972 |
# Roll back any change if something goes wrong
|
973 |
conn.rollback() |
974 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
975 |
finally:
|
976 |
# Close the db connection
|
977 |
conn.close() |
978 | |
979 |
return res
|
980 | |
981 |
'''
|
982 |
@brief save configurations
|
983 |
@author humkyung
|
984 |
@date 2018.04.16
|
985 |
@history humkyung 2018.07.03 replace ' with " if value has '
|
986 |
kyouho 2018.07.09 change query method
|
987 |
'''
|
988 |
def saveConfigs(self, configs): |
989 |
try:
|
990 |
# Creates or opens a file called mydb with a SQLite3 DB
|
991 |
dbPath = os.path.join(self.getCurrentProject().getDbFilePath(), "ITI_PID.db") |
992 |
conn = sqlite3.connect(dbPath) |
993 |
# Get a cursor object
|
994 |
cursor = conn.cursor() |
995 | |
996 |
for config in configs: |
997 |
value = config.value |
998 |
if type(value) is str and "'" in value: |
999 |
value = value.replace("'", "''") |
1000 | |
1001 |
sql = "insert or replace into configuration values(?,?,?)"
|
1002 |
param = (config.section, config.key, value) |
1003 | |
1004 |
cursor.execute(sql, param) |
1005 |
conn.commit() |
1006 |
# Catch the exception
|
1007 |
except Exception as ex: |
1008 |
# Roll back any change if something goes wrong
|
1009 |
conn.rollback() |
1010 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
1011 |
finally:
|
1012 |
# Close the db connection
|
1013 |
conn.close() |
1014 | |
1015 |
'''
|
1016 |
@brief delete configurations
|
1017 |
@author humkyung
|
1018 |
@date 2018.06.29
|
1019 |
'''
|
1020 |
def deleteConfigs(self, section, key=None): |
1021 |
try:
|
1022 |
# Creates or opens a file called mydb with a SQLite3 DB
|
1023 |
dbPath = os.path.join(self.getCurrentProject().getDbFilePath(), "ITI_PID.db") |
1024 |
conn = sqlite3.connect(dbPath) |
1025 |
# Get a cursor object
|
1026 |
cursor = conn.cursor() |
1027 | |
1028 |
if key is not None: |
1029 |
sql = "delete from configuration where section='{}' and key='{}'".format(section, key)
|
1030 |
else:
|
1031 |
sql = "delete from configuration where section='{}'".format(section)
|
1032 |
cursor.execute(sql) |
1033 | |
1034 |
conn.commit() |
1035 |
# Catch the exception
|
1036 |
except Exception as ex: |
1037 |
# Roll back any change if something goes wrong
|
1038 |
conn.rollback() |
1039 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
1040 |
finally:
|
1041 |
# Close the db connection
|
1042 |
conn.close() |
1043 | |
1044 |
'''
|
1045 |
@brief set area list
|
1046 |
@history humkyung 2018.05.18 round area coordinate and dimension before saving
|
1047 |
'''
|
1048 |
def setAreaList(self, areas): |
1049 |
for area in areas: |
1050 |
matches = [x for x in self._areas if x.name==area.name] |
1051 |
if 1 == len(matches): |
1052 |
matches[0].x = area.x
|
1053 |
matches[0].y = area.y
|
1054 |
matches[0].width = area.width
|
1055 |
matches[0].height = area.height
|
1056 |
elif 0 == len(matches): |
1057 |
self._areas.append(area)
|
1058 | |
1059 |
try:
|
1060 |
# Creates or opens a file called mydb with a SQLite3 DB
|
1061 |
dbPath = os.path.join(self.getCurrentProject().getDbFilePath(), "ITI_PID.db") |
1062 |
conn = sqlite3.connect(dbPath) |
1063 |
# Get a cursor object
|
1064 |
cursor = conn.cursor() |
1065 | |
1066 |
for area in self._areas: |
1067 |
sql = "insert or replace into configuration values('Area','{}','({},{}),({},{})')".format(area.name, round(area.x), round(area.y), round(area.width), round(area.height)) |
1068 |
cursor.execute(sql) |
1069 | |
1070 |
conn.commit() |
1071 |
# Catch the exception
|
1072 |
except Exception as ex: |
1073 |
# Roll back any change if something goes wrong
|
1074 |
conn.rollback() |
1075 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
1076 |
finally:
|
1077 |
# Close the db connection
|
1078 |
conn.close() |
1079 |
|
1080 |
'''
|
1081 |
@brief get symbol name list
|
1082 |
'''
|
1083 |
def getSymbolNameList(self): |
1084 |
symbolNametList = [] |
1085 | |
1086 |
try:
|
1087 |
dbPath = self.getCurrentProject().getDbFilePath() + "/ITI_PID.db" |
1088 | |
1089 |
conn = sqlite3.connect(dbPath) |
1090 |
cursor = conn.cursor() |
1091 |
sql = 'SELECT * FROM SymbolName'
|
1092 |
try:
|
1093 |
cursor.execute(sql) |
1094 |
rows = cursor.fetchall() |
1095 |
for row in rows: |
1096 |
symbolNametList.append(row[2]) # Name String |
1097 |
except Exception as ex: |
1098 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
1099 |
finally:
|
1100 |
conn.close() |
1101 | |
1102 |
return symbolNametList
|
1103 | |
1104 |
'''
|
1105 |
@brief get symbol name list by symbol Type
|
1106 |
@author Jeongwoo
|
1107 |
@date 18.04.06
|
1108 |
@history .
|
1109 |
'''
|
1110 |
def getSymbolNameListByType(self, type): |
1111 |
symbolNametList = [] |
1112 | |
1113 |
try:
|
1114 |
dbPath = self.getCurrentProject().getDbFilePath() + "/ITI_PID.db" |
1115 | |
1116 |
conn = sqlite3.connect(dbPath) |
1117 |
cursor = conn.cursor() |
1118 |
sql = ''
|
1119 |
if type is not None: |
1120 |
sql = 'SELECT * FROM SymbolName WHERE type = "' + type + '"' |
1121 |
try:
|
1122 |
cursor.execute(sql) |
1123 |
rows = cursor.fetchall() |
1124 |
for row in rows: |
1125 |
symbolNametList.append(row[2]) # Name String |
1126 |
except Exception as ex: |
1127 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
1128 |
finally:
|
1129 |
conn.close() |
1130 | |
1131 |
return symbolNametList
|
1132 | |
1133 |
'''
|
1134 |
@brief delete added symbol data
|
1135 |
'''
|
1136 |
def deleteSymbol(self, fileName): |
1137 |
ret = False
|
1138 |
try:
|
1139 |
dbPath = self.getCurrentProject().getPath() + "/db/ITI_PID.db" |
1140 |
conn = sqlite3.connect(dbPath) |
1141 |
cursor = conn.cursor() |
1142 |
sql = "DELETE FROM Symbol WHERE name = ?"
|
1143 |
try:
|
1144 |
cursor.execute(sql, (fileName,)) |
1145 |
conn.commit() |
1146 |
ret = True
|
1147 |
except Exception as ex: |
1148 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
1149 |
ret = False
|
1150 |
finally:
|
1151 |
conn.close() |
1152 |
return (ret, fileName)
|
1153 |
|
1154 |
'''
|
1155 |
@brief get symbol name
|
1156 |
@history 18.04.24 Jeongwoo Add isExceptDetect Field
|
1157 |
'''
|
1158 |
def getSymbolByQuery(self, fieldName, param): |
1159 |
ret = None
|
1160 | |
1161 |
try:
|
1162 |
dbPath = self.getCurrentProject().getDbFilePath() + "/ITI_PID.db" |
1163 |
conn = sqlite3.connect(dbPath) |
1164 |
cursor = conn.cursor() |
1165 |
sql = 'SELECT * FROM Symbol WHERE ' + fieldName + ' = "' + param + '"' |
1166 |
try:
|
1167 |
cursor.execute(sql) |
1168 |
rows = cursor.fetchall() |
1169 |
if rows is not None and len(rows) > 0: |
1170 |
symbolTuple = rows[0]
|
1171 |
ret = symbol.SymbolBase(symbolTuple[1], symbolTuple[2], symbolTuple[3] |
1172 |
, symbolTuple[4], symbolTuple[5], symbolTuple[6], symbolTuple[7], symbolTuple[8] |
1173 |
, symbolTuple[9], symbolTuple[10], symbolTuple[11], symbolTuple[12], symbolTuple[13], symbolTuple[14], symbolTuple[0]) ## uid is last item |
1174 |
#ret = symbol.SymbolBase(symbolTuple[1], symbolTuple[2], symbolTuple[3], symbolTuple[4]
|
1175 |
# , symbolTuple[5], symbolTuple[6], symbolTuple[7], symbolTuple[8], symbolTuple[9]
|
1176 |
# , symbolTuple[10], symbolTuple[11], symbolTuple[12], symbolTuple[13], symbolTuple[14], symbolTuple[0]) ## uid is last item
|
1177 |
except Exception as ex: |
1178 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
1179 |
finally:
|
1180 |
conn.close() |
1181 | |
1182 |
return ret
|
1183 | |
1184 |
'''
|
1185 |
@brief get symbol name list
|
1186 |
@history 18.04.24 Jeongwoo Add isExceptDetect Field
|
1187 |
'''
|
1188 |
def getSymbolListByQuery(self, fieldName=None, param=None): |
1189 |
ret = [] |
1190 | |
1191 |
try:
|
1192 |
dbPath = os.path.join(self.getCurrentProject().getDbFilePath(), 'ITI_PID.db') |
1193 |
conn = sqlite3.connect(dbPath) |
1194 |
cursor = conn.cursor() |
1195 |
if fieldName is not None and param is not None: |
1196 |
sql = 'SELECT * FROM Symbol WHERE ' + fieldName + ' = "' + param + '"' |
1197 |
else:
|
1198 |
sql = 'SELECT * FROM Symbol'
|
1199 |
try:
|
1200 |
cursor.execute(sql) |
1201 |
rows = cursor.fetchall() |
1202 |
if rows is not None and len(rows) > 0: |
1203 |
for symbolTuple in rows: |
1204 |
sym = symbol.SymbolBase(symbolTuple[1], symbolTuple[2], symbolTuple[3], symbolTuple[4] |
1205 |
, symbolTuple[5], symbolTuple[6], symbolTuple[7], symbolTuple[8], symbolTuple[9] |
1206 |
, symbolTuple[10], symbolTuple[11], symbolTuple[12], symbolTuple[13], symbolTuple[14], symbolTuple[0]) ## uid is last item |
1207 |
ret.append(sym) |
1208 |
except Exception as ex: |
1209 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
1210 |
finally:
|
1211 |
conn.close() |
1212 | |
1213 |
return ret
|
1214 | |
1215 |
'''
|
1216 |
@brief get NominalDiameter
|
1217 |
@author humkyung
|
1218 |
@date 2018.04.20
|
1219 |
@history humkyung 2018.04.24 read MetricStr column and set size unit
|
1220 |
kyouho 2018.07.04 forCheckLineNumber get only inch or metric
|
1221 |
kyouho 2018.07.16 edit query order by code
|
1222 |
'''
|
1223 |
def getNomialPipeSizeData(self, forCheckLineNumber = False, orderStr = "CODE"): |
1224 |
res = [] |
1225 |
try:
|
1226 |
configs = self.getConfigs('Line No', 'Size Unit') |
1227 |
sizeUnit = configs[0].value if 1 == len(configs) else 'Metric' |
1228 | |
1229 |
# Creates or opens a file called mydb with a SQLite3 DB
|
1230 |
dbPath = os.path.join(self.getCurrentProject().getDbFilePath(), 'ITI_PID.db') |
1231 |
conn = sqlite3.connect(dbPath) |
1232 |
# Get a cursor object
|
1233 |
cursor = conn.cursor() |
1234 | |
1235 |
sql = "select Code,Metric,Inch,InchStr,MetricStr from NominalDiameter ORDER BY {} ASC".format(orderStr)
|
1236 |
cursor.execute(sql) |
1237 |
rows = cursor.fetchall() |
1238 |
for row in rows: |
1239 |
pipeSize = NominalPipeSize(row[0], float(row[1]) if row[1] is not None else None, float(row[2]) if row[2] is not None else None, row[3], row[4]) |
1240 |
pipeSize.sizeUnit = sizeUnit |
1241 |
if forCheckLineNumber:
|
1242 |
if sizeUnit == 'Inch' and pipeSize.inchStr: |
1243 |
res.append(pipeSize.inchStr) |
1244 |
elif sizeUnit == 'Metric' and pipeSize.metricStr: |
1245 |
res.append(pipeSize.metricStr) |
1246 |
else:
|
1247 |
res.append(pipeSize) |
1248 |
|
1249 |
# Catch the exception
|
1250 |
except Exception as ex: |
1251 |
# Roll back any change if something goes wrong
|
1252 |
conn.rollback() |
1253 |
|
1254 |
from App import App |
1255 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
1256 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
1257 |
finally:
|
1258 |
# Close the db connection
|
1259 |
conn.close() |
1260 | |
1261 |
return res
|
1262 | |
1263 |
'''
|
1264 |
@brief insert NominalDiameter table
|
1265 |
@author kyouho
|
1266 |
@date 2018.07.16
|
1267 |
'''
|
1268 |
def insertNomialPipeSize(self, pipeSizes): |
1269 |
try:
|
1270 |
# Creates or opens a file called mydb with a SQLite3 DB
|
1271 |
dbPath = os.path.join(self.getCurrentProject().getDbFilePath(), 'ITI_PID.db') |
1272 |
conn = sqlite3.connect(dbPath) |
1273 |
# Get a cursor object
|
1274 |
cursor = conn.cursor() |
1275 |
sql = "INSERT INTO NominalDiameter(Code, Metric, Inch, InchStr, MetricStr) VALUES(?,?,?,?,?)"
|
1276 |
for pipeSize in pipeSizes: |
1277 |
param = (pipeSize.code, pipeSize.metric, pipeSize.inch, pipeSize.inchStr, pipeSize.metricStr) |
1278 |
cursor.execute(sql, param) |
1279 |
conn.commit() |
1280 |
# Catch the exception
|
1281 |
except Exception as ex: |
1282 |
# Roll back any change if something goes wrong
|
1283 |
conn.rollback() |
1284 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
1285 |
finally:
|
1286 |
# Close the db connection
|
1287 |
conn.close() |
1288 | |
1289 | |
1290 |
'''
|
1291 |
@brief delete NominalDiameter table
|
1292 |
@author kyouho
|
1293 |
@date 2018.07.16
|
1294 |
'''
|
1295 |
def deleteNomialPipeSize(self): |
1296 |
try:
|
1297 |
dbPath = self.getCurrentProject().getPath() + "/db/ITI_PID.db" |
1298 |
conn = sqlite3.connect(dbPath) |
1299 |
cursor = conn.cursor() |
1300 |
sql = "DELETE FROM NominalDiameter"
|
1301 |
try:
|
1302 |
cursor.execute(sql) |
1303 |
conn.commit() |
1304 |
except Exception as ex: |
1305 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
1306 |
finally:
|
1307 |
conn.close() |
1308 |
|
1309 | |
1310 | |
1311 | |
1312 |
'''
|
1313 |
@brief convert inch to metric
|
1314 |
@author kyouho
|
1315 |
@date 2018.07.09
|
1316 |
'''
|
1317 |
def convertInchToMetric(self, inch): |
1318 |
result = ''
|
1319 |
try:
|
1320 |
# Creates or opens a file called mydb with a SQLite3 DB
|
1321 |
dbPath = os.path.join(self.getCurrentProject().getDbFilePath(), 'ITI_PID.db') |
1322 |
conn = sqlite3.connect(dbPath) |
1323 |
# Get a cursor object
|
1324 |
cursor = conn.cursor() |
1325 |
|
1326 |
sql = "select MetricStr from NominalDiameter WHERE InchStr = ?"
|
1327 |
param = (inch,) |
1328 |
cursor.execute(sql, param) |
1329 |
rows = cursor.fetchall() |
1330 | |
1331 |
if rows:
|
1332 |
result = rows[0][0] |
1333 |
# Catch the exception
|
1334 |
except Exception as ex: |
1335 |
# Roll back any change if something goes wrong
|
1336 |
conn.rollback() |
1337 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
1338 |
finally:
|
1339 |
# Close the db connection
|
1340 |
conn.close() |
1341 | |
1342 |
return result
|
1343 | |
1344 |
'''
|
1345 |
@brief get Color MaxUID
|
1346 |
@author kyouho
|
1347 |
@date 2018.07.03
|
1348 |
'''
|
1349 |
def getMaxColorUID(self): |
1350 |
result = 0
|
1351 | |
1352 |
try:
|
1353 |
# Creates or opens a file called mydb with a SQLite3 DB
|
1354 |
dbPath = os.path.join(self.getCurrentProject().getDbFilePath(), 'ITI_PID.db') |
1355 |
conn = sqlite3.connect(dbPath) |
1356 |
# Get a cursor object
|
1357 |
cursor = conn.cursor() |
1358 | |
1359 |
sql = "select MAX(UID) from Colors"
|
1360 |
cursor.execute(sql) |
1361 |
rows = cursor.fetchall() |
1362 | |
1363 |
result = rows[0][0] |
1364 |
# Catch the exception
|
1365 |
except Exception as ex: |
1366 |
# Roll back any change if something goes wrong
|
1367 |
conn.rollback() |
1368 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
1369 |
finally:
|
1370 |
# Close the db connection
|
1371 |
conn.close() |
1372 | |
1373 |
return result
|
1374 | |
1375 |
'''
|
1376 |
@brief insert Color property
|
1377 |
@author kyouho
|
1378 |
@date 2018.07.09
|
1379 |
'''
|
1380 |
def setPropertyColor(self, _color): |
1381 |
try:
|
1382 |
# Creates or opens a file called mydb with a SQLite3 DB
|
1383 |
dbPath = os.path.join(self.getCurrentProject().getDbFilePath(), 'ITI_PID.db') |
1384 |
conn = sqlite3.connect(dbPath) |
1385 |
# Get a cursor object
|
1386 |
cursor = conn.cursor() |
1387 |
sql = "INSERT INTO Colors(UID, RED, GREEN, BLUE, PROPERTY, VALUE) VALUES(?,?,?,?,?,?)"
|
1388 |
param = (_color.index, _color.red, _color.green, _color.blue, _color._property, _color.value) |
1389 |
cursor.execute(sql, param) |
1390 |
conn.commit() |
1391 |
# Catch the exception
|
1392 |
except Exception as ex: |
1393 |
# Roll back any change if something goes wrong
|
1394 |
conn.rollback() |
1395 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
1396 |
finally:
|
1397 |
# Close the db connection
|
1398 |
conn.close() |
1399 | |
1400 |
'''
|
1401 |
@brief delete Color property
|
1402 |
@author kyouho
|
1403 |
@date 2018.07.09
|
1404 |
'''
|
1405 |
def deletePropertyColor(self, property): |
1406 |
try:
|
1407 |
# Creates or opens a file called mydb with a SQLite3 DB
|
1408 |
dbPath = os.path.join(self.getCurrentProject().getDbFilePath(), 'ITI_PID.db') |
1409 |
conn = sqlite3.connect(dbPath) |
1410 |
# Get a cursor object
|
1411 |
cursor = conn.cursor() |
1412 | |
1413 |
sql = "DELETE FROM Colors WHERE PROPERTY = '{}'".format(property) |
1414 |
cursor.execute(sql) |
1415 |
conn.commit() |
1416 |
# Catch the exception
|
1417 |
except Exception as ex: |
1418 |
# Roll back any change if something goes wrong
|
1419 |
conn.rollback() |
1420 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
1421 |
finally:
|
1422 |
# Close the db connection
|
1423 |
conn.close() |
1424 | |
1425 |
'''
|
1426 |
@brief get Fluid Code
|
1427 |
@author kyouho
|
1428 |
@date 2018.07.03
|
1429 |
@history kyouho 2018.07.04 kyouho 2018.07.04 forCheckLineNumber get only code
|
1430 |
'''
|
1431 |
def getFluidCodeData(self, forCheckLineNumber = False): |
1432 |
from FluidCodeData import FluidCodeData |
1433 |
result = [] |
1434 | |
1435 |
try:
|
1436 |
# Creates or opens a file called mydb with a SQLite3 DB
|
1437 |
dbPath = os.path.join(self.getCurrentProject().getDbFilePath(), 'ITI_PID.db') |
1438 |
conn = sqlite3.connect(dbPath) |
1439 |
# Get a cursor object
|
1440 |
cursor = conn.cursor() |
1441 | |
1442 |
sql = 'select uid, code, description from FluidCode order by length(code) DESC'
|
1443 |
cursor.execute(sql) |
1444 |
rows = cursor.fetchall() |
1445 |
for row in rows: |
1446 |
data = FluidCodeData(row[0], row[1], row[2]) |
1447 |
if forCheckLineNumber:
|
1448 |
result.append(data.code) |
1449 |
else:
|
1450 |
result.append(data) |
1451 |
# Catch the exception
|
1452 |
except Exception as ex: |
1453 |
# Roll back any change if something goes wrong
|
1454 |
conn.rollback() |
1455 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
1456 |
finally:
|
1457 |
# Close the db connection
|
1458 |
conn.close() |
1459 | |
1460 |
return result
|
1461 | |
1462 |
'''
|
1463 |
@brief get Symbol Attribute
|
1464 |
@author kyouho
|
1465 |
@date 2018.07.18
|
1466 |
'''
|
1467 |
def checkAttribute(self, attr): |
1468 |
try:
|
1469 |
# Creates or opens a file called mydb with a SQLite3 DB
|
1470 |
dbPath = os.path.join(self.getCurrentProject().getDbFilePath(), 'ITI_PID.db') |
1471 |
conn = sqlite3.connect(dbPath) |
1472 |
# Get a cursor object
|
1473 |
cursor = conn.cursor() |
1474 | |
1475 |
sql = 'select attribute from SymbolAttribute where Attribute = ?'
|
1476 |
param = (attr,) |
1477 |
cursor.execute(sql, param) |
1478 |
rows = cursor.fetchall() |
1479 |
if len(rows): |
1480 |
return True |
1481 |
else:
|
1482 |
return False |
1483 |
# Catch the exception
|
1484 |
except Exception as ex: |
1485 |
# Roll back any change if something goes wrong
|
1486 |
conn.rollback() |
1487 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
1488 |
finally:
|
1489 |
# Close the db connection
|
1490 |
conn.close() |
1491 | |
1492 |
return False |
1493 | |
1494 |
'''
|
1495 |
@brief get Symbol Attribute
|
1496 |
@author kyouho
|
1497 |
@date 2018.07.18
|
1498 |
'''
|
1499 |
def getSymbolAttribute(self, _type): |
1500 |
result = [] |
1501 | |
1502 |
try:
|
1503 |
# Creates or opens a file called mydb with a SQLite3 DB
|
1504 |
dbPath = os.path.join(self.getCurrentProject().getDbFilePath(), 'ITI_PID.db') |
1505 |
conn = sqlite3.connect(dbPath) |
1506 |
# Get a cursor object
|
1507 |
cursor = conn.cursor() |
1508 | |
1509 |
sql = 'select a.attribute from SymbolAttribute a inner join SymbolType t on a.SymbolType = t.id and t.type = ? order by attribute'
|
1510 |
param = (_type,) |
1511 |
cursor.execute(sql, param) |
1512 |
rows = cursor.fetchall() |
1513 |
for row in rows: |
1514 |
result.append(row[0])
|
1515 |
# Catch the exception
|
1516 |
except Exception as ex: |
1517 |
# Roll back any change if something goes wrong
|
1518 |
conn.rollback() |
1519 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
1520 |
finally:
|
1521 |
# Close the db connection
|
1522 |
conn.close() |
1523 | |
1524 |
return result
|
1525 | |
1526 |
'''
|
1527 |
@brief save symbol attributes
|
1528 |
@author humkyung
|
1529 |
@date 2018.08.14
|
1530 |
'''
|
1531 |
def saveSymbolAttributes(self, type, attrs): |
1532 |
try:
|
1533 |
# Creates or opens a file called mydb with a SQLite3 DB
|
1534 |
dbPath = os.path.join(self.getCurrentProject().getDbFilePath(), 'ITI_PID.db') |
1535 |
conn = sqlite3.connect(dbPath) |
1536 |
# Get a cursor object
|
1537 |
cursor = conn.cursor() |
1538 | |
1539 |
sql = 'delete from SymbolAttribute where SymbolType = ?'
|
1540 |
param = (type,)
|
1541 |
cursor.execute(sql, param) |
1542 | |
1543 |
for attr in attrs: |
1544 |
sql = 'insert into SymbolAttribute(SymbolType, Attribute) values(?,?)'
|
1545 |
param = (type, attr)
|
1546 |
cursor.execute(sql, param) |
1547 | |
1548 |
conn.commit() |
1549 |
# Catch the exception
|
1550 |
except Exception as ex: |
1551 |
# Roll back any change if something goes wrong
|
1552 |
conn.rollback() |
1553 |
|
1554 |
from App import App |
1555 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
1556 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
1557 |
finally:
|
1558 |
# Close the db connection
|
1559 |
conn.close() |
1560 | |
1561 |
'''
|
1562 |
@brief get Code Table Data
|
1563 |
@author kyouho
|
1564 |
@date 2018.07.10
|
1565 |
'''
|
1566 |
def getCodeTable(self, property, forCheckLineNumber = False): |
1567 |
result = [] |
1568 |
try:
|
1569 |
# Creates or opens a file called mydb with a SQLite3 DB
|
1570 |
dbPath = os.path.join(self.getCurrentProject().getDbFilePath(), 'ITI_PID.db') |
1571 |
conn = sqlite3.connect(dbPath) |
1572 |
# Get a cursor object
|
1573 |
cursor = conn.cursor() |
1574 | |
1575 |
sql = 'select uid, code, description from {} order by length(code) DESC'.format(property) |
1576 |
cursor.execute(sql) |
1577 |
rows = cursor.fetchall() |
1578 |
for row in rows: |
1579 |
if forCheckLineNumber:
|
1580 |
data = row[1]
|
1581 |
else:
|
1582 |
data = (row[0], row[1], row[2]) |
1583 |
result.append(data) |
1584 |
# Catch the exception
|
1585 |
except Exception as ex: |
1586 |
# Roll back any change if something goes wrong
|
1587 |
conn.rollback() |
1588 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
1589 |
finally:
|
1590 |
# Close the db connection
|
1591 |
conn.close() |
1592 | |
1593 |
return result
|
1594 | |
1595 |
'''
|
1596 |
@brief Set Common Code Data
|
1597 |
@author kyouho
|
1598 |
@date 2018.07.12
|
1599 |
'''
|
1600 |
def setCommonCodeData(self, tableName, datas): |
1601 |
try:
|
1602 |
# Creates or opens a file called mydb with a SQLite3 DB
|
1603 |
dbPath = os.path.join(self.getCurrentProject().getDbFilePath(), 'ITI_PID.db') |
1604 |
conn = sqlite3.connect(dbPath) |
1605 |
# Get a cursor object
|
1606 |
cursor = conn.cursor() |
1607 | |
1608 |
for data in datas: |
1609 |
uid = data[0]
|
1610 |
if not uid: |
1611 |
sql = "insert or replace into {}(UID, CODE, DESCRIPTION) values(lower(hex(randomblob(16))), ?, ?)".format(tableName)
|
1612 |
param = (data[1], data[2]) |
1613 |
else:
|
1614 |
sql = "update {} SET CODE=?, DESCRIPTION=? WHERE UID = ?".format(tableName)
|
1615 |
param = (data[1], data[2], data[0]) |
1616 |
cursor.execute(sql, param) |
1617 | |
1618 |
conn.commit() |
1619 |
|
1620 |
# Catch the exception
|
1621 |
except Exception as ex: |
1622 |
# Roll back any change if something goes wrong
|
1623 |
conn.rollback() |
1624 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
1625 |
finally:
|
1626 |
# Close the db connection
|
1627 |
conn.close() |
1628 | |
1629 |
'''
|
1630 |
@brief Set Common Code Data
|
1631 |
@author kyouho
|
1632 |
@date 2018.07.12
|
1633 |
'''
|
1634 |
def deleteCommonCodeData(self, datas): |
1635 |
try:
|
1636 |
# Creates or opens a file called mydb with a SQLite3 DB
|
1637 |
dbPath = os.path.join(self.getCurrentProject().getDbFilePath(), 'ITI_PID.db') |
1638 |
conn = sqlite3.connect(dbPath) |
1639 |
# Get a cursor object
|
1640 |
cursor = conn.cursor() |
1641 | |
1642 |
for data in datas: |
1643 |
uid = data[0]
|
1644 |
tableName = data[1]
|
1645 | |
1646 |
if uid:
|
1647 |
sql = "delete from {} where UID = ?".format(tableName)
|
1648 |
param = (uid,) |
1649 |
cursor.execute(sql, param) |
1650 | |
1651 |
cursor.execute(sql, param) |
1652 | |
1653 |
conn.commit() |
1654 |
|
1655 |
# Catch the exception
|
1656 |
except Exception as ex: |
1657 |
# Roll back any change if something goes wrong
|
1658 |
conn.rollback() |
1659 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
1660 |
finally:
|
1661 |
# Close the db connection
|
1662 |
conn.close() |
1663 | |
1664 |
'''
|
1665 |
@brief delete data list
|
1666 |
@author kyouho
|
1667 |
@date 2018.08.16
|
1668 |
'''
|
1669 |
def deleteDataList(self, tableName, UID): |
1670 |
try:
|
1671 |
# Creates or opens a file called mydb with a SQLite3 DB
|
1672 |
dbPath = os.path.join(self.getCurrentProject().getDbFilePath(), 'ITI_PID.db') |
1673 |
conn = sqlite3.connect(dbPath) |
1674 |
# Get a cursor object
|
1675 |
cursor = conn.cursor() |
1676 | |
1677 |
sql = 'delete from {} where UID = {}'.format(tableName, UID)
|
1678 |
|
1679 |
cursor.execute(sql) |
1680 | |
1681 |
conn.commit() |
1682 | |
1683 |
# Catch the exception
|
1684 |
except Exception as ex: |
1685 |
# Roll back any change if something goes wrong
|
1686 |
conn.rollback() |
1687 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
1688 |
finally:
|
1689 |
# Close the db connection
|
1690 |
conn.close() |
1691 | |
1692 | |
1693 |
'''
|
1694 |
@brief get line documentName list
|
1695 |
@author kyouho
|
1696 |
@date 2018.08.13
|
1697 |
'''
|
1698 |
def getLineDocumentNameList(self): |
1699 |
result = [] |
1700 | |
1701 |
try:
|
1702 |
# Creates or opens a file called mydb with a SQLite3 DB
|
1703 |
dbPath = os.path.join(self.getCurrentProject().getDbFilePath(), 'ITI_PID.db') |
1704 |
conn = sqlite3.connect(dbPath) |
1705 |
# Get a cursor object
|
1706 |
cursor = conn.cursor() |
1707 | |
1708 |
sql = 'select DISTINCT(PNID_NO) from LINE_DATA_LIST'
|
1709 | |
1710 |
cursor.execute(sql) |
1711 |
rows = cursor.fetchall() |
1712 |
for row in rows: |
1713 |
result.append(row[0])
|
1714 |
# Catch the exception
|
1715 |
except Exception as ex: |
1716 |
# Roll back any change if something goes wrong
|
1717 |
conn.rollback() |
1718 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
1719 |
finally:
|
1720 |
# Close the db connection
|
1721 |
conn.close() |
1722 | |
1723 |
return result
|
1724 | |
1725 |
'''
|
1726 |
@brief get line documentName list
|
1727 |
@author kyouho
|
1728 |
@date 2018.08.14
|
1729 |
'''
|
1730 |
def getEquipDocumentNameList(self): |
1731 |
result = [] |
1732 | |
1733 |
try:
|
1734 |
# Creates or opens a file called mydb with a SQLite3 DB
|
1735 |
dbPath = os.path.join(self.getCurrentProject().getDbFilePath(), 'ITI_PID.db') |
1736 |
conn = sqlite3.connect(dbPath) |
1737 |
# Get a cursor object
|
1738 |
cursor = conn.cursor() |
1739 | |
1740 |
sql = 'select DISTINCT(PNID_NO) from EQUIPMENT_DATA_LIST'
|
1741 | |
1742 |
cursor.execute(sql) |
1743 |
rows = cursor.fetchall() |
1744 |
for row in rows: |
1745 |
result.append(row[0])
|
1746 |
# Catch the exception
|
1747 |
except Exception as ex: |
1748 |
# Roll back any change if something goes wrong
|
1749 |
conn.rollback() |
1750 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
1751 |
finally:
|
1752 |
# Close the db connection
|
1753 |
conn.close() |
1754 | |
1755 |
return result
|
1756 | |
1757 | |
1758 |
'''
|
1759 |
@brief get line data list
|
1760 |
@author kyouho
|
1761 |
@date 2018.08.13
|
1762 |
'''
|
1763 |
def getLineDataList(self, docName = None): |
1764 |
result = [] |
1765 | |
1766 |
try:
|
1767 |
# Creates or opens a file called mydb with a SQLite3 DB
|
1768 |
dbPath = os.path.join(self.getCurrentProject().getDbFilePath(), 'ITI_PID.db') |
1769 |
conn = sqlite3.connect(dbPath) |
1770 |
# Get a cursor object
|
1771 |
cursor = conn.cursor() |
1772 | |
1773 |
sql = 'select UID, LINE_SIZE, LINE_SYMBOL, LINE_NO, LINE_CLASS, LINE_ROUTING_FROM, LINE_ROUTING_TO, SERVICE_FLUID, SERVICE_DENSITY, SERVICE_STATE, OPERATION_CONDITION_TEMP, OPERATION_CONDITION_PRESS, DESIGN_CONDITION_TEMP, DESIGN_CONDITION_PRESS, TEST_CONDITION_TEMP, TEST_CONDITION_PRESS, INSUL_CODE, PAINT_CODE, NDE_CODE, PWHT, PNID_NO from LINE_DATA_LIST'
|
1774 |
if docName is not None: |
1775 |
sql += " where PNID_NO = '{}'".format(docName)
|
1776 | |
1777 |
cursor.execute(sql) |
1778 |
#columnName = list(map(lambda x: x[0].upper(), cursor.description))
|
1779 |
rows = cursor.fetchall() |
1780 |
for row in rows: |
1781 |
data = [] |
1782 |
for index in range(len(cursor.description)): |
1783 |
data.append(row[index]) |
1784 |
result.append(data) |
1785 |
# Catch the exception
|
1786 |
except Exception as ex: |
1787 |
# Roll back any change if something goes wrong
|
1788 |
conn.rollback() |
1789 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
1790 |
finally:
|
1791 |
# Close the db connection
|
1792 |
conn.close() |
1793 | |
1794 |
return result
|
1795 | |
1796 |
'''
|
1797 |
@brief set line data list
|
1798 |
@author kyouho
|
1799 |
@date 2018.08.13
|
1800 |
'''
|
1801 |
def setLineDataList(self, dataLists): |
1802 |
try:
|
1803 |
# Creates or opens a file called mydb with a SQLite3 DB
|
1804 |
dbPath = os.path.join(self.getCurrentProject().getDbFilePath(), 'ITI_PID.db') |
1805 |
conn = sqlite3.connect(dbPath) |
1806 |
# Get a cursor object
|
1807 |
cursor = conn.cursor() |
1808 |
|
1809 |
for data in dataLists: |
1810 |
sql = "insert or replace into LINE_DATA_LIST(UID, LINE_SIZE, LINE_SYMBOL, LINE_NO, LINE_CLASS, LINE_ROUTING_FROM, LINE_ROUTING_TO, SERVICE_FLUID, SERVICE_DENSITY, SERVICE_STATE, OPERATION_CONDITION_TEMP, OPERATION_CONDITION_PRESS, DESIGN_CONDITION_TEMP, DESIGN_CONDITION_PRESS, TEST_CONDITION_TEMP, TEST_CONDITION_PRESS, INSUL_CODE, PAINT_CODE, NDE_CODE, PWHT, PNID_NO) values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
|
1811 |
param = tuple(data)
|
1812 |
cursor.execute(sql, param) |
1813 | |
1814 |
conn.commit() |
1815 | |
1816 |
# Catch the exception
|
1817 |
except Exception as ex: |
1818 |
# Roll back any change if something goes wrong
|
1819 |
conn.rollback() |
1820 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
1821 |
finally:
|
1822 |
# Close the db connection
|
1823 |
conn.close() |
1824 | |
1825 |
'''
|
1826 |
@brief delete line data list
|
1827 |
@author kyouho
|
1828 |
@date 2018.08.13
|
1829 |
'''
|
1830 |
def deleteLineDataList(self, removeUID): |
1831 |
try:
|
1832 |
# Creates or opens a file called mydb with a SQLite3 DB
|
1833 |
dbPath = os.path.join(self.getCurrentProject().getDbFilePath(), 'ITI_PID.db') |
1834 |
conn = sqlite3.connect(dbPath) |
1835 |
# Get a cursor object
|
1836 |
cursor = conn.cursor() |
1837 |
|
1838 |
for uid in removeUID: |
1839 |
sql = "delete from LINE_DATA_LIST where uid = '{}'".format(uid)
|
1840 |
cursor.execute(sql) |
1841 | |
1842 |
conn.commit() |
1843 | |
1844 |
# Catch the exception
|
1845 |
except Exception as ex: |
1846 |
# Roll back any change if something goes wrong
|
1847 |
conn.rollback() |
1848 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
1849 |
finally:
|
1850 |
# Close the db connection
|
1851 |
conn.close() |
1852 | |
1853 |
'''
|
1854 |
@brief delete line data list
|
1855 |
@author kyouho
|
1856 |
@date 2018.08.13
|
1857 |
'''
|
1858 |
def deleteLineDataList_LineNo(self, removeUID): |
1859 |
try:
|
1860 |
# Creates or opens a file called mydb with a SQLite3 DB
|
1861 |
dbPath = os.path.join(self.getCurrentProject().getDbFilePath(), 'ITI_PID.db') |
1862 |
conn = sqlite3.connect(dbPath) |
1863 |
# Get a cursor object
|
1864 |
cursor = conn.cursor() |
1865 |
|
1866 |
for uid in removeUID: |
1867 |
sql = "delete from LINE_DATA_LIST where LINE_NO = ?"
|
1868 |
param = (uid,) |
1869 |
cursor.execute(sql, param) |
1870 | |
1871 |
conn.commit() |
1872 | |
1873 |
# Catch the exception
|
1874 |
except Exception as ex: |
1875 |
# Roll back any change if something goes wrong
|
1876 |
conn.rollback() |
1877 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
1878 |
finally:
|
1879 |
# Close the db connection
|
1880 |
conn.close() |
1881 | |
1882 |
'''
|
1883 |
@brief delete equip data list
|
1884 |
@author kyouho
|
1885 |
@date 2018.08.14
|
1886 |
'''
|
1887 |
def deleteEquipDataList(self, removeUID): |
1888 |
try:
|
1889 |
# Creates or opens a file called mydb with a SQLite3 DB
|
1890 |
dbPath = os.path.join(self.getCurrentProject().getDbFilePath(), 'ITI_PID.db') |
1891 |
conn = sqlite3.connect(dbPath) |
1892 |
# Get a cursor object
|
1893 |
cursor = conn.cursor() |
1894 |
|
1895 |
for uid in removeUID: |
1896 |
sql = "delete from EQUIPMENT_DATA_LIST where uid = '{}'".format(uid)
|
1897 |
cursor.execute(sql) |
1898 | |
1899 |
conn.commit() |
1900 | |
1901 |
# Catch the exception
|
1902 |
except Exception as ex: |
1903 |
# Roll back any change if something goes wrong
|
1904 |
conn.rollback() |
1905 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
1906 |
finally:
|
1907 |
# Close the db connection
|
1908 |
conn.close() |
1909 | |
1910 |
'''
|
1911 |
@brief delete inst data list
|
1912 |
@author kyouho
|
1913 |
@date 2018.08.14
|
1914 |
'''
|
1915 |
def deleteInstDataList(self, removeUID): |
1916 |
try:
|
1917 |
# Creates or opens a file called mydb with a SQLite3 DB
|
1918 |
dbPath = os.path.join(self.getCurrentProject().getDbFilePath(), 'ITI_PID.db') |
1919 |
conn = sqlite3.connect(dbPath) |
1920 |
# Get a cursor object
|
1921 |
cursor = conn.cursor() |
1922 |
|
1923 |
for uid in removeUID: |
1924 |
sql = "delete from INSTRUMENT_DATA_LIST where uid = '{}'".format(uid)
|
1925 |
cursor.execute(sql) |
1926 | |
1927 |
conn.commit() |
1928 | |
1929 |
# Catch the exception
|
1930 |
except Exception as ex: |
1931 |
# Roll back any change if something goes wrong
|
1932 |
conn.rollback() |
1933 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
1934 |
finally:
|
1935 |
# Close the db connection
|
1936 |
conn.close() |
1937 | |
1938 |
'''
|
1939 |
@brief get equipment data list
|
1940 |
@author humkyung
|
1941 |
@date 2018.05.03
|
1942 |
'''
|
1943 |
def getEquipmentDataList(self, docName = None): |
1944 |
result = [] |
1945 |
try:
|
1946 |
# Creates or opens a file called mydb with a SQLite3 DB
|
1947 |
dbPath = os.path.join(self.getCurrentProject().getDbFilePath(), 'ITI_PID.db') |
1948 |
conn = sqlite3.connect(dbPath) |
1949 |
# Get a cursor object
|
1950 |
cursor = conn.cursor() |
1951 | |
1952 |
sql = 'select UID, ITEM_NO, SERVICE, NO_REQ, FLUID, DESC_OF_PART, OPERATION_CONDITION_TEMP, OPERATION_CONDITION_PRESS, DESIGN_CONDITION_TEMP, DESIGN_CONDITION_PRESS, MATERIAL, WEIGHT, POWER, INSULATION, PNID_NO, REV from EQUIPMENT_DATA_LIST'
|
1953 |
if docName is not None: |
1954 |
sql += " where PNID_NO = '{}'".format(docName)
|
1955 | |
1956 |
cursor.execute(sql) |
1957 |
rows = cursor.fetchall() |
1958 |
for row in rows: |
1959 |
data = [] |
1960 |
for index in range(len(cursor.description)): |
1961 |
data.append(row[index]) |
1962 |
result.append(data) |
1963 |
# Catch the exception
|
1964 |
except Exception as ex: |
1965 |
# Roll back any change if something goes wrong
|
1966 |
conn.rollback() |
1967 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
1968 |
finally:
|
1969 |
# Close the db connection
|
1970 |
conn.close() |
1971 | |
1972 |
return result
|
1973 | |
1974 |
'''
|
1975 |
@brief get instrument data list
|
1976 |
@author kyouho
|
1977 |
@date 2018.08.14
|
1978 |
'''
|
1979 |
def getInstrumentDataList(self, docName = None): |
1980 |
result = [] |
1981 |
try:
|
1982 |
# Creates or opens a file called mydb with a SQLite3 DB
|
1983 |
dbPath = os.path.join(self.getCurrentProject().getDbFilePath(), 'ITI_PID.db') |
1984 |
conn = sqlite3.connect(dbPath) |
1985 |
# Get a cursor object
|
1986 |
cursor = conn.cursor() |
1987 | |
1988 |
sql = 'select UID, ITEM_NO, SERVICE, FLOW_RATE, PRESSURE, TEMPERATURE, TPYE, RANGE, NOR_LEVEL_MM, NOR_LEVEL_PERCENT, DEL_PRESS, SHUT_OFF, LOCATION, PNID_NO, REV from INSTRUMENT_DATA_LIST'
|
1989 |
if docName is not None: |
1990 |
sql += " where PNID_NO = '{}'".format(docName)
|
1991 | |
1992 |
cursor.execute(sql) |
1993 |
rows = cursor.fetchall() |
1994 |
for row in rows: |
1995 |
data = [] |
1996 |
for index in range(len(cursor.description)): |
1997 |
data.append(row[index]) |
1998 |
result.append(data) |
1999 |
# Catch the exception
|
2000 |
except Exception as ex: |
2001 |
# Roll back any change if something goes wrong
|
2002 |
conn.rollback() |
2003 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
2004 |
finally:
|
2005 |
# Close the db connection
|
2006 |
conn.close() |
2007 | |
2008 |
return result
|
2009 | |
2010 |
'''
|
2011 |
@brief set equipment data list
|
2012 |
@author humkyung
|
2013 |
@date 2018.05.03
|
2014 |
'''
|
2015 |
def setEquipmentDataList(self, dataList): |
2016 |
try:
|
2017 |
# Creates or opens a file called mydb with a SQLite3 DB
|
2018 |
dbPath = os.path.join(self.getCurrentProject().getDbFilePath(), 'ITI_PID.db') |
2019 |
conn = sqlite3.connect(dbPath) |
2020 |
# Get a cursor object
|
2021 |
cursor = conn.cursor() |
2022 | |
2023 |
for data in dataList: |
2024 |
sql = "insert or replace into EQUIPMENT_DATA_LIST(UID, ITEM_NO, SERVICE, NO_REQ, FLUID, DESC_OF_PART, OPERATION_CONDITION_TEMP, OPERATION_CONDITION_PRESS, DESIGN_CONDITION_TEMP, DESIGN_CONDITION_PRESS, MATERIAL, WEIGHT, POWER, INSULATION, PNID_NO, REV) values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
|
2025 |
param = tuple(data)
|
2026 |
cursor.execute(sql, param) |
2027 |
conn.commit() |
2028 |
# Catch the exception
|
2029 |
except Exception as ex: |
2030 |
# Roll back any change if something goes wrong
|
2031 |
conn.rollback() |
2032 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
2033 |
finally:
|
2034 |
# Close the db connection
|
2035 |
conn.close() |
2036 | |
2037 |
'''
|
2038 |
@brief set instrumnet data list
|
2039 |
@author kyoyho
|
2040 |
@date 2018.08.14
|
2041 |
'''
|
2042 |
def setInstrumentDataList(self, dataList): |
2043 |
try:
|
2044 |
# Creates or opens a file called mydb with a SQLite3 DB
|
2045 |
dbPath = os.path.join(self.getCurrentProject().getDbFilePath(), 'ITI_PID.db') |
2046 |
conn = sqlite3.connect(dbPath) |
2047 |
# Get a cursor object
|
2048 |
cursor = conn.cursor() |
2049 | |
2050 |
for data in dataList: |
2051 |
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(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
|
2052 |
param = tuple(data)
|
2053 |
cursor.execute(sql, param) |
2054 |
conn.commit() |
2055 | |
2056 |
# Catch the exception
|
2057 |
except Exception as ex: |
2058 |
# Roll back any change if something goes wrong
|
2059 |
conn.rollback() |
2060 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
2061 |
finally:
|
2062 |
# Close the db connection
|
2063 |
conn.close() |
2064 | |
2065 |
'''
|
2066 |
@brief get IsOriginDetect ComboBox Items
|
2067 |
'''
|
2068 |
def getIsOriginDetectComboBoxItems(self): |
2069 |
return [("원본 도면", 0), ("텍스트 제거 도면", 1)] |
2070 | |
2071 |
'''
|
2072 |
@brief get IsOriginDetect ComboBox Items
|
2073 |
'''
|
2074 |
def getOcrOptionComboBoxItems(self): |
2075 |
return [("OCR 미적용", 0), ("일반 심볼", 1), ("Instrument 계통", 2)] |
2076 |
|
2077 |
'''
|
2078 |
@brief Return Symbol Type Items
|
2079 |
@author Jeongwoo
|
2080 |
@date 18.04.20
|
2081 |
@history 18.05.08 Jeongwoo type index changed
|
2082 |
'''
|
2083 |
def getSymbolTypeList(self): |
2084 |
symbolTypeList = [] |
2085 | |
2086 |
try:
|
2087 |
dbPath = os.path.join(self.getCurrentProject().getDbFilePath(), 'ITI_PID.db') |
2088 | |
2089 |
conn = sqlite3.connect(dbPath) |
2090 |
cursor = conn.cursor() |
2091 |
sql = 'SELECT * FROM SymbolType ORDER BY type ASC'
|
2092 |
try:
|
2093 |
cursor.execute(sql) |
2094 |
rows = cursor.fetchall() |
2095 |
for row in rows: |
2096 |
symbolTypeList.append((row[0], row[1], row[2])) # UID, category, type |
2097 |
except Exception as ex: |
2098 |
from App import App |
2099 | |
2100 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
2101 |
App.mainWin().addMessage(MessageType.Error, message) |
2102 |
finally:
|
2103 |
conn.close() |
2104 | |
2105 |
return symbolTypeList
|
2106 | |
2107 |
'''
|
2108 |
@brief Get Symbol Category by Symbol Type
|
2109 |
@author Jeongwoo
|
2110 |
@date 2018.05.09
|
2111 |
'''
|
2112 |
def getSymbolCategoryByType(self, type): |
2113 |
category = None
|
2114 |
try:
|
2115 |
dbPath = os.path.join(self.getCurrentProject().getDbFilePath(), "ITI_PID.db") |
2116 |
conn = sqlite3.connect(dbPath) |
2117 |
cursor = conn.cursor() |
2118 |
sql = 'SELECT category FROM SymbolType WHERE type = "' + type + '"' |
2119 |
cursor.execute(sql) |
2120 |
rows = cursor.fetchall() |
2121 |
if rows is not None and len(rows) > 0: |
2122 |
category = rows[0][0] |
2123 |
except Exception as ex: |
2124 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
2125 |
finally:
|
2126 |
conn.close() |
2127 | |
2128 |
return category
|
2129 | |
2130 |
'''
|
2131 |
@brief Check Symbol Type is included in 'Equipment' Category
|
2132 |
@author Jeongwoo
|
2133 |
@date 2018.05.09
|
2134 |
'''
|
2135 |
def isEquipmentType(self, type): |
2136 |
category = self.getSymbolCategoryByType(type) |
2137 |
return (category is not None and category == 'Equipment') |
2138 | |
2139 |
'''
|
2140 |
@brief Return Symbol Type Items with "None"
|
2141 |
@author Jeongwoo
|
2142 |
@date 18.04.06
|
2143 |
@history Seperate SymbolTypeList and "None"
|
2144 |
'''
|
2145 |
def getSymbolTypeComboBoxItems(self): |
2146 |
symbolTypeList = self.getSymbolTypeList()
|
2147 |
symbolTypeList.insert(0, ('None', 'None', 'None')) |
2148 | |
2149 |
return symbolTypeList
|
2150 | |
2151 |
'''
|
2152 |
@brief get Base Symbol ComboBox Items
|
2153 |
'''
|
2154 |
def getBaseSymbolComboBoxItems(self, type = None): |
2155 |
bsymbolNameList = self.getSymbolNameListByType(type) |
2156 |
bsymbolNameList.sort() |
2157 |
bsymbolNameList.insert(0, "None") |
2158 |
return bsymbolNameList
|
2159 | |
2160 |
'''
|
2161 |
@brief get Additional Symbol ComboBox Items
|
2162 |
'''
|
2163 |
def getAdditionalSymbolComboBoxItems(self): |
2164 |
asymbolNameList = self.getSymbolNameList()
|
2165 |
asymbolNameList.sort() |
2166 |
asymbolNameList.insert(0, "None") |
2167 |
return asymbolNameList
|
2168 | |
2169 |
'''
|
2170 |
@brief get Additional Symbol's default direction ComboBox Items
|
2171 |
'''
|
2172 |
def getDefaultSymbolDirectionComboBoxItems(self): |
2173 |
return [("UP", 0), ("DOWN", 2), ("LEFT", 3), ("RIGHT", 1)] |
2174 |
|
2175 |
'''
|
2176 |
@brief getter of activeDrawing
|
2177 |
@author humkyung
|
2178 |
@date 2018.07.07
|
2179 |
'''
|
2180 |
@property
|
2181 |
def activeDrawing(self): |
2182 |
return self._activeDrawing |
2183 | |
2184 |
'''
|
2185 |
@brief setter of activeDrawing
|
2186 |
@author humkyung
|
2187 |
@date 2018.07.07
|
2188 |
'''
|
2189 |
@activeDrawing.setter
|
2190 |
def activeDrawing(self, value): |
2191 |
self._activeDrawing = value
|