프로젝트

일반

사용자정보

개정판 9100a182

ID9100a182f75932c56c3e7ed17e674864b681f31b
상위 528fc146
하위 4f1a6030, 680b280c

humkyung 이(가) 6년 이상 전에 추가함

issue #587:
- 객체의 속성을 가져오는 로직 변경

차이점 보기:

DTI_PID/DTI_PID/AppDocData.py
1355 1355
                print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
1356 1356
        finally:
1357 1357
            conn.close()
1358
    
1359

  
1360

  
1361 1358

  
1362 1359
    '''
1363 1360
        @brief      convert inch to metric
......
1548 1545
        @history    humkyung 2018.10.13 load expression
1549 1546
    '''
1550 1547
    def getSymbolAttribute(self, _type):
1548
        from SymbolAttr import SymbolAttr
1549

  
1551 1550
        result = []
1552 1551

  
1553 1552
        try:
......
1562 1561
            cursor.execute(sql, param)
1563 1562
            rows = cursor.fetchall()
1564 1563
            for row in rows:
1565
                result.append((row[0], row[1], row[2], row[3], row[4], row[5], row[6]))
1564
                attr = SymbolAttr()
1565
                attr.UID = row[0]
1566
                attr.Attribute = row[1]
1567
                attr.DisplayAttribute = row[2]
1568
                attr.AttributeType = row[3]
1569
                attr.AttrAt = row[4]
1570
                attr.Expression = row[5]
1571
                result.append(attr)
1566 1572
            # Catch the exception
1567 1573
        except Exception as ex:
1568 1574
            from App import App 
DTI_PID/DTI_PID/ItemDataExportDialog.py
655 655
        for item in items:
656 656
            self.scene_valve_data[str(item.uid)] = item
657 657

  
658
        from QEngineeringInstrumentItem import QEngineeringInstrumentItem
658
        from EngineeringInstrumentItem import Q
659 659
        items = [item for item in self.parent.graphicsView.scene.items() if type(item) is QEngineeringInstrumentItem]
660 660
        for item in items:
661 661
            self.sceneInstData[str(item.uid)] = item.getInstrumentDataList()
DTI_PID/DTI_PID/ItemPropertyTableWidget.py
265 265
                    humkyung 2018.07.05 display connectivity
266 266
    '''
267 267
    def initContentsCell(self):
268
        from QEngineeringInstrumentItem import QEngineeringInstrumentItem
268
        from EngineeringInstrumentItem import QEngineeringInstrumentItem
269 269
        
270 270
        self.attrValueList = []
271 271
        self.intCell = []
272 272
        self.stringCell = []
273 273

  
274 274
        if self.symData is not None:
275
            docData = AppDocData.instance()
275 276

  
276 277
            self.setItem(0, 1, QTableWidgetItem(str(self.symData.uid)))
277 278
            self.setItem(1, 1, QTableWidgetItem(self.symData.name))
......
281 282
            self.setItem(5, 1, QTableWidgetItem('{}'.format(self.symData.owner)))
282 283

  
283 284
            row = self.rowCount()
284
            self.setRowCount(row + len(self.symData.getAttributes()) + len(self.symData.connectors))
285
            # display attributes of symbol
286 285
            attrs = self.symData.getAttributes()
286
            self.setRowCount(row + len(attrs) + len(self.symData.connectors))
287
            # display attributes of symbol
287 288
            if attrs is not None:
288
                attrItems = list(attrs.items())
289
                for index in range(len(attrItems)):
290
                    key = attrItems[index][0]
291
                    value = attrItems[index][1]
292
                    keyItem = QTableWidgetItem(key)
289
                for key in attrs.keys():
290
                    value = attrs[key]
291
                    keyItem = QTableWidgetItem(key.Attribute)
293 292
                    keyItem.setBackground(QColor(220, 220, 220))
294
                    docData = AppDocData.instance()
293
                    keyItem.tag = key
295 294
                    valueItem = QTableWidgetItem(str(value))
296
                    if docData.checkAttribute(key):
297
                        attrType = docData.getSymbolAttributeByUID(key)
298
                        if attrType[2] == 'Text Item' or attrType[2] == 'Symbol Item':
299
                            from PyQt5 import QtGui
300
                            icon = QtGui.QIcon()
301
                            icon.addPixmap(QtGui.QPixmap(":/newPrefix/doubleclick.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
302
                            valueItem.setIcon(icon)
303
                        elif attrType[2] == 'Int':
304
                            self.intCell.append(valueItem)
305
                        elif attrType[2] == 'String':
306
                            self.stringCell.append(valueItem)
307

  
308
                        if attrType[2] == 'Text Item':
309
                            textItem = self.findTextItemFromUID(value)
310
                            if textItem is not None:
311
                                valueItem.setText(textItem.text())
312
                        self.attrValueList.append((valueItem, key))
313
                        keyText = docData.getSymbolAttributeByUID(key)
314
                        if keyText is not None:
315
                            keyItem.setText(keyText[1])
316
                            self.setItem(row, 0, keyItem)
317
                    else:
295
                    if key.AttributeType == 'Text Item' or key.AttributeType == 'Symbol Item':
296
                        from PyQt5 import QtGui
297
                        icon = QtGui.QIcon()
298
                        icon.addPixmap(QtGui.QPixmap(":/newPrefix/doubleclick.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
299
                        valueItem.setIcon(icon)
300
                    elif key.AttributeType == 'Int':
301
                        self.intCell.append(valueItem)
302
                    elif key.AttributeType == 'String':
303
                        self.stringCell.append(valueItem)
304

  
305
                    if key.AttributeType == 'Text Item':
306
                        textItem = self.findTextItemFromUID(value)
307
                        if textItem is not None:
308
                            valueItem.setText(textItem.text())
309
                    self.attrValueList.append((valueItem, key))
310
                    keyText = docData.getSymbolAttributeByUID(key.UID)
311
                    if keyText is not None:
312
                        keyItem.setText(keyText[1])
318 313
                        self.setItem(row, 0, keyItem)
319 314

  
320 315
                    if type(self.symData) is QEngineeringSpecBreakItem and (key == 'Up Stream' or key == 'Down Stream'):
DTI_PID/DTI_PID/ItemTreeWidget.py
19 19
from QEngineeringNoteItem import QEngineeringNoteItem
20 20
from EngineeringLineNoTextItem import QEngineeringLineNoTextItem
21 21
from QEngineeringEquipmentItem import QEngineeringEquipmentItem
22
from QEngineeringInstrumentItem import QEngineeringInstrumentItem
22
from EngineeringInstrumentItem import QEngineeringInstrumentItem
23 23
from QEngineeringTrimLineNoTextItem import QEngineeringTrimLineNoTextItem
24 24
from EngineeringUnknownItem import QEngineeringUnknownItem
25 25
from AppDocData import AppDocData
DTI_PID/DTI_PID/MainWindow.py
40 40
from QEngineeringSizeTextItem import QEngineeringSizeTextItem
41 41
from EngineeringUnknownItem import QEngineeringUnknownItem
42 42
from QEngineeringEquipmentItem import QEngineeringEquipmentItem
43
from QEngineeringInstrumentItem import QEngineeringInstrumentItem
43
from EngineeringInstrumentItem import QEngineeringInstrumentItem
44 44
from EngineeringSpecBreakItem import QEngineeringSpecBreakItem
45 45
from AppDocData import *
46 46
import SymbolTreeWidget, SymbolPropertyTableWidget
DTI_PID/DTI_PID/Shapes/EngineeringInstrumentItem.py
1
# coding: utf-8
2
"""
3
This is Engineering Instrument Item module
4
"""
5

  
6
import sys
7
import os
8
import math
9
from PyQt5.QtGui import *
10
from PyQt5.QtCore import *
11
from PyQt5.QtSvg import *
12
from PyQt5.QtWidgets import (QApplication, QGraphicsItem)
13

  
14
from SymbolSvgItem import SymbolSvgItem
15
from EngineeringConnectorItem import QEngineeringConnectorItem
16
from EngineeringTextItem import QEngineeringTextItem
17
from UserInputAttribute import UserInputAttribute
18

  
19
instColumnList = ['UID', 'ITEM_NO', 'SERVICE', 'FLOW_RATE', 'PRESSURE', 'TEMPERATURE', 'TPYE', 'RANGE', 'NOR_LEVEL_MM', 'NOR_LEVEL_PERCENT', 'DEL_PRESS', 'SHUT_OFF', 'LOCATION', 'PNID_NO', 'REV']
20

  
21
class QEngineeringInstrumentItem(SymbolSvgItem):
22
    """
23
    This is Engineering Instrument Item class
24
    """
25
    clicked = pyqtSignal(QGraphicsSvgItem)
26
    #removed = pyqtSignal(QGraphicsItem)
27

  
28
    '''
29
    '''
30
    def __init__(self, path, uid=None):
31
        SymbolSvgItem.__init__(self, path, uid)
32

  
33
        self._measuredVairableCode = None
34
        self._typeModifier = None
35
        self._tagSeqNo = None
36
        self._tagSuffix = None
37
        self._texts = []    # contains text items
38
        self._symbols = []  # contains symbol items
39

  
40
    '''
41
        @brief  getter of measured variable code
42
        @author humkyung
43
        @date   2018.05.06
44
    '''
45
    @property
46
    def measuredVariableCode(self):
47
        return self._measuredVairableCode
48

  
49
    '''
50
        @brief  setter of measured variable code
51
        @author humkyung
52
        @date   2018.05.06
53
    '''
54
    @measuredVariableCode.setter
55
    def measuredVariableCode(self, value):
56
        self._measuredVairableCode = value
57

  
58
    '''
59
        @brief  getter of type modifier
60
        @author humkyung
61
        @date   2018.05.06
62
    '''
63
    @property
64
    def typeModifier(self):
65
        return self._typeModifier
66
    
67
    '''
68
        @brief  setter of type modifier
69
        @author humkyung
70
        @date   2018.05.06
71
    '''
72
    @typeModifier.setter
73
    def typeModifier(self, value):
74
        self._typeModifier = value
75
    
76
    '''
77
        @brief  getter of tag seq no
78
        @author humkyung
79
        @date   2018.05.06
80
    '''
81
    @property
82
    def tagSeqNo(self):
83
        return self._tagSeqNo
84
    
85
    '''
86
        @brief  setter of tag seq no
87
        @author humkyung
88
        @date   2018.05.06
89
    '''
90
    @tagSeqNo.setter
91
    def tagSeqNo(self, value):
92
        self._tagSeqNo = value
93

  
94
    '''
95
        @brief  getter of tag suffix
96
        @author humkyung
97
        @date   2018.05.06
98
    '''
99
    @property
100
    def tagSuffix(self):
101
        return self._tagSuffix
102

  
103
    '''
104
        @brief  setter of tag suffix
105
        @author humkyung
106
        @date   2018.05.06
107
    '''
108
    @tagSuffix.setter
109
    def tagSuffix(self, value):
110
        self._tagSuffix = value
111

  
112
    '''
113
        @brief  connect attribute
114
        @author humkyung
115
        @date   2018.05.06
116
    '''
117
    def connectAttribute(self, attributes):
118
        self._texts.clear()
119
        self._symbols.clear()
120

  
121
        rect = self.sceneBoundingRect()
122
        for attr in attributes:
123
            if rect.contains(attr.center()):
124
                if issubclass(type(attr), QEngineeringTextItem):
125
                    self._texts.append(attr)
126
                elif issubclass(type(attr), SymbolSvgItem):
127
                    self._symbols.append(attr)
128

  
129
        self._texts = sorted(self._texts, key=lambda attr: attr.loc[1])    # sort by y coordinate
130

  
131
    '''
132
        @brief      get attributes
133
        @author     humkyung
134
        @date       2018.06.14
135
    '''
136
    def getAttributes(self):
137
        _attrs = {}
138
        try:
139
            from AppDocData import AppDocData
140
            from EngineeringTextItem import QEngineeringTextItem
141

  
142
            # 해당 Type의 attribute setting
143
            docData = AppDocData.instance()
144
            symbolAttrs = docData.getSymbolAttribute(self.type)
145
            for attr in symbolAttrs:
146
                if attr.AttributeType == 'Text Item':
147
                    at = int(attr.AttrAt)
148
                    if len(self._texts) > at:
149
                        item = self._texts[at]
150
                        _attrs[attr] = eval(attr.Expression) if attr.Expression else ''
151
                    else:
152
                        _attrs[attr] = ''
153
                elif attr.AttributeType == 'Symbol Item':
154
                    at = int(attr.AttrAt)
155
                    if len(self._symbols) > at:
156
                        item = self._symbols[at]
157
                        _attrs[attr] = eval(attr.Expression) if attr.Expression else ''
158
                    else:
159
                        _attrs[attr] = ''
160
                else:
161
                    _attrs[attr] = ''#self.attrs[attr[1]] if attr[1] in self.attrs.keys() else ''
162
        except Exception as ex:
163
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
164
        
165
        return _attrs
166

  
167
    '''
168
        @brief  generate xml code for attribute
169
        @author humkyung
170
        @date   2018.05.06
171
    '''
172
    def toXmlAsAttribute(self, parentNode):
173
        from xml.etree.ElementTree import Element, SubElement, dump, ElementTree
174

  
175
        try:
176
            attrNode = Element('ATTRIBUTE')
177

  
178
            uidNode = Element('UID')
179
            uidNode.text = str(self.uid)
180
            attrNode.append(uidNode)
181

  
182
            nameNode = Element('NAME')
183
            nameNode.text = 'Measured Variable Code'
184
            attrNode.append(nameNode)
185

  
186
            valueNode = Element('VALUE')
187
            valueNode.text = self.measuredVariableCode
188
            attrNode.append(valueNode)
189

  
190
            parentNode.append(attrNode) 
191
        except Exception as ex:
192
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
193

  
194
        try:
195
            attrNode = Element('ATTRIBUTE')
196

  
197
            uidNode = Element('UID')
198
            uidNode.text = str(self.uid)
199
            attrNode.append(uidNode)
200

  
201
            nameNode = Element('NAME')
202
            nameNode.text = 'Type Modifier'
203
            attrNode.append(nameNode)
204

  
205
            valueNode = Element('VALUE')
206
            valueNode.text = self.typeModifier
207
            attrNode.append(valueNode)
208

  
209
            parentNode.append(attrNode) 
210
        except Exception as ex:
211
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
212

  
213
        try:
214
            attrNode = Element('ATTRIBUTE')
215

  
216
            uidNode = Element('UID')
217
            uidNode.text = str(self.uid)
218
            attrNode.append(uidNode)
219

  
220
            nameNode = Element('NAME')
221
            nameNode.text = 'Tag Seq No'
222
            attrNode.append(nameNode)
223

  
224
            valueNode = Element('VALUE')
225
            valueNode.text = self.tagSeqNo
226
            attrNode.append(valueNode)
227

  
228
            parentNode.append(attrNode) 
229
        except Exception as ex:
230
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
231

  
232
        try:
233
            attrNode = Element('ATTRIBUTE')
234

  
235
            uidNode = Element('UID')
236
            uidNode.text = str(self.uid)
237
            attrNode.append(uidNode)
238

  
239
            nameNode = Element('NAME')
240
            nameNode.text = 'Tag Suffix'
241
            attrNode.append(nameNode)
242

  
243
            valueNode = Element('VALUE')
244
            valueNode.text = self.tagSuffix
245
            attrNode.append(valueNode)
246

  
247
            parentNode.append(attrNode) 
248
        except Exception as ex:
249
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
250

  
251
    '''
252
        @brief      save inst Data
253
        @author     kyouho
254
        @date       2018.08.16
255
    '''
256
    def saveInstData(self):
257
        try:
258
            from AppDocData import AppDocData
259

  
260
            docData = AppDocData.instance()
261
            docData.setInstrumentDataList([self.getInstrumentDataList()])
262
        except Exception as ex:
263
            return str(self.uid)
264
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
265

  
266
    '''
267
        @brief      return inst Data List
268
        @author     kyouho
269
        @date       2018.08.14
270
    '''
271
    def getInstrumentDataList(self):
272
        dataList = []
273
        try:
274
            from AppDocData import AppDocData
275

  
276
            global instColumnList
277

  
278
            docData = AppDocData.instance()
279
            attrs = self.attrs
280

  
281
            for index in range(len(instColumnList)):
282
                dataList.append('')
283

  
284
            dataList[0] = str(self.uid)
285
            dataList[13] = docData.imgName
286

  
287
            for attr in attrs:
288
                attrInfo = docData.getSymbolAttributeByUID(attr.attribute)
289
                attrName = attrInfo[0]
290
                if instColumnList.count(attrName):
291
                    colIndex = instColumnList.index(attrName)
292
                    
293
                    if type(attr) is UserInputAttribute:
294
                        dataList[colIndex] = attr.text if attr.text is not None else ''
295
                    elif type(attr) is QEngineeringTextItem:
296
                        dataList[colIndex] = attr.text()
297
                    else:
298
                        dataList[colIndex] = attr.uid
299

  
300
        except Exception as ex:
301
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
302

  
303
        return dataList
304

  
DTI_PID/DTI_PID/Shapes/EngineeringLineItem.py
833 833
        @date   2018.07.05
834 834
    '''
835 835
    def updateLineType(self):
836
        from QEngineeringInstrumentItem import QEngineeringInstrumentItem
836
        from EngineeringInstrumentItem import QEngineeringInstrumentItem
837 837

  
838 838
        if len(self.connectors) == 2:
839 839
            lines = [item.connectedItem for item in self.connectors if item.connectedItem is not None and type(item.connectedItem) is QEngineeringLineItem]
DTI_PID/DTI_PID/Shapes/EngineeringSpecBreakItem.py
33 33
    '''
34 34
    def getAttributes(self):
35 35
        from EngineeringTextItem import QEngineeringTextItem
36
        from QEngineeringInstrumentItem import QEngineeringInstrumentItem
36
        from EngineeringInstrumentItem import QEngineeringInstrumentItem
37 37
        from EngineeringSpecBreakItem import QEngineeringSpecBreakItem
38 38
        attrs = {}
39 39
        
DTI_PID/DTI_PID/Shapes/QEngineeringInstrumentItem.py
1
# coding: utf-8
2

  
3
import sys
4
import os
5
import math
6
from PyQt5.QtGui import *
7
from PyQt5.QtCore import *
8
from PyQt5.QtSvg import *
9
from PyQt5.QtWidgets import (QApplication, QGraphicsItem)
10

  
11
from SymbolSvgItem import SymbolSvgItem
12
from EngineeringConnectorItem import QEngineeringConnectorItem
13
from EngineeringTextItem import QEngineeringTextItem
14
from UserInputAttribute import UserInputAttribute
15

  
16
instColumnList = ['UID', 'ITEM_NO', 'SERVICE', 'FLOW_RATE', 'PRESSURE', 'TEMPERATURE', 'TPYE', 'RANGE', 'NOR_LEVEL_MM', 'NOR_LEVEL_PERCENT', 'DEL_PRESS', 'SHUT_OFF', 'LOCATION', 'PNID_NO', 'REV']
17

  
18
class QEngineeringInstrumentItem(SymbolSvgItem):
19
    clicked = pyqtSignal(QGraphicsSvgItem)
20
    #removed = pyqtSignal(QGraphicsItem)
21

  
22
    '''
23
    '''
24
    def __init__(self, path, uid=None):
25
        SymbolSvgItem.__init__(self, path, uid)
26

  
27
        self._measuredVairableCode = None
28
        self._typeModifier = None
29
        self._tagSeqNo = None
30
        self._tagSuffix = None
31

  
32
    '''
33
        @brief  getter of measured variable code
34
        @author humkyung
35
        @date   2018.05.06
36
    '''
37
    @property
38
    def measuredVariableCode(self):
39
        return self._measuredVairableCode
40

  
41
    '''
42
        @brief  setter of measured variable code
43
        @author humkyung
44
        @date   2018.05.06
45
    '''
46
    @measuredVariableCode.setter
47
    def measuredVariableCode(self, value):
48
        self._measuredVairableCode = value
49

  
50
    '''
51
        @brief  getter of type modifier
52
        @author humkyung
53
        @date   2018.05.06
54
    '''
55
    @property
56
    def typeModifier(self):
57
        return self._typeModifier
58
    
59
    '''
60
        @brief  setter of type modifier
61
        @author humkyung
62
        @date   2018.05.06
63
    '''
64
    @typeModifier.setter
65
    def typeModifier(self, value):
66
        self._typeModifier = value
67
    
68
    '''
69
        @brief  getter of tag seq no
70
        @author humkyung
71
        @date   2018.05.06
72
    '''
73
    @property
74
    def tagSeqNo(self):
75
        return self._tagSeqNo
76
    
77
    '''
78
        @brief  setter of tag seq no
79
        @author humkyung
80
        @date   2018.05.06
81
    '''
82
    @tagSeqNo.setter
83
    def tagSeqNo(self, value):
84
        self._tagSeqNo = value
85

  
86
    '''
87
        @brief  getter of tag suffix
88
        @author humkyung
89
        @date   2018.05.06
90
    '''
91
    @property
92
    def tagSuffix(self):
93
        return self._tagSuffix
94

  
95
    '''
96
        @brief  setter of tag suffix
97
        @author humkyung
98
        @date   2018.05.06
99
    '''
100
    @tagSuffix.setter
101
    def tagSuffix(self, value):
102
        self._tagSuffix = value
103

  
104
    '''
105
        @brief  connect attribute
106
        @author humkyung
107
        @date   2018.05.06
108
    '''
109
    def connectAttribute(self, attributes):
110
        from AppDocData import AppDocData
111

  
112
        self.attrs.clear()
113

  
114
        rect = self.sceneBoundingRect()
115
        for attr in attributes:
116
            if rect.contains(attr.center()):
117
                self.attrs.append(attr)
118

  
119
        self.attrs = sorted(self.attrs, key=lambda attr: attr.loc[1])    # sort by y coordinate
120
        attrs = [attr.text() for attr in self.attrs]        # will be used in eval function's parameter
121

  
122
        docData = AppDocData.instance()
123
        try:
124
            self.measuredVariableCode = ''
125
            configs = docData.getConfigs('Instrument Tag No Rule', 'Measured Variable Code')
126
            self.measuredVariableCode = eval(configs[0].value) if configs else ''
127
        except Exception as ex:
128
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
129

  
130
        try:
131
            self.typeModifier = ''
132
            configs = docData.getConfigs('Instrument Tag No Rule', 'Type Modifier')
133
            self.typeModifier = eval(configs[0].value) if configs else ''
134
        except Exception as ex:
135
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
136

  
137
        try:
138
            self.tagSeqNo = ''
139
            configs = docData.getConfigs('Instrument Tag No Rule', 'Tag Seq No')
140
            self.tagSeqNo = eval(configs[0].value) if configs else ''
141
        except Exception as ex:
142
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
143

  
144
        try:
145
            self.tagSuffix = ''
146
            configs = docData.getConfigs('Instrument Tag No Rule', 'Tag Suffix')
147
            self.tagSuffix = eval(configs[0].value) if configs else ''
148
        except Exception as ex:
149
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
150
    
151
    '''
152
        @brief      get attributes
153
        @author     humkyung
154
        @date       2018.06.14
155
    '''
156
    def getAttributes(self):
157
        attrs = {}
158
        try:
159
            from AppDocData import AppDocData
160
            from EngineeringTextItem import QEngineeringTextItem
161

  
162
            attrs['Measured Variable Code'] = self.measuredVariableCode
163
            attrs['Type Modifier'] = self.typeModifier
164
            attrs['Tag Seq No'] = self.tagSeqNo
165
            attrs['Tag Suffix'] = self.tagSuffix
166

  
167
            # 해당 Type의 attribute setting
168
            docData = AppDocData.instance()
169
            symbolAttrs = docData.getSymbolAttribute(self.type)
170
            for attr in symbolAttrs:
171
                attrs[attr[0]] = ''
172

  
173
            for attr in self.attrs:
174
                if type(attr) is QEngineeringTextItem or issubclass(type(attr), SymbolSvgItem):
175
                    attrs[attr.attribute] = attr.uid
176
                elif type(attr) is UserInputAttribute:
177
                    attrs[attr.attribute] = attr.text
178
        except Exception as ex:
179
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
180
        
181
        return attrs
182

  
183
    '''
184
        @brief  generate xml code for attribute
185
        @author humkyung
186
        @date   2018.05.06
187
    '''
188
    def toXmlAsAttribute(self, parentNode):
189
        from xml.etree.ElementTree import Element, SubElement, dump, ElementTree
190

  
191
        try:
192
            attrNode = Element('ATTRIBUTE')
193

  
194
            uidNode = Element('UID')
195
            uidNode.text = str(self.uid)
196
            attrNode.append(uidNode)
197

  
198
            nameNode = Element('NAME')
199
            nameNode.text = 'Measured Variable Code'
200
            attrNode.append(nameNode)
201

  
202
            valueNode = Element('VALUE')
203
            valueNode.text = self.measuredVariableCode
204
            attrNode.append(valueNode)
205

  
206
            parentNode.append(attrNode) 
207
        except Exception as ex:
208
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
209

  
210
        try:
211
            attrNode = Element('ATTRIBUTE')
212

  
213
            uidNode = Element('UID')
214
            uidNode.text = str(self.uid)
215
            attrNode.append(uidNode)
216

  
217
            nameNode = Element('NAME')
218
            nameNode.text = 'Type Modifier'
219
            attrNode.append(nameNode)
220

  
221
            valueNode = Element('VALUE')
222
            valueNode.text = self.typeModifier
223
            attrNode.append(valueNode)
224

  
225
            parentNode.append(attrNode) 
226
        except Exception as ex:
227
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
228

  
229
        try:
230
            attrNode = Element('ATTRIBUTE')
231

  
232
            uidNode = Element('UID')
233
            uidNode.text = str(self.uid)
234
            attrNode.append(uidNode)
235

  
236
            nameNode = Element('NAME')
237
            nameNode.text = 'Tag Seq No'
238
            attrNode.append(nameNode)
239

  
240
            valueNode = Element('VALUE')
241
            valueNode.text = self.tagSeqNo
242
            attrNode.append(valueNode)
243

  
244
            parentNode.append(attrNode) 
245
        except Exception as ex:
246
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
247

  
248
        try:
249
            attrNode = Element('ATTRIBUTE')
250

  
251
            uidNode = Element('UID')
252
            uidNode.text = str(self.uid)
253
            attrNode.append(uidNode)
254

  
255
            nameNode = Element('NAME')
256
            nameNode.text = 'Tag Suffix'
257
            attrNode.append(nameNode)
258

  
259
            valueNode = Element('VALUE')
260
            valueNode.text = self.tagSuffix
261
            attrNode.append(valueNode)
262

  
263
            parentNode.append(attrNode) 
264
        except Exception as ex:
265
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
266

  
267
    '''
268
        @brief      save inst Data
269
        @author     kyouho
270
        @date       2018.08.16
271
    '''
272
    def saveInstData(self):
273
        try:
274
            from AppDocData import AppDocData
275

  
276
            docData = AppDocData.instance()
277
            docData.setInstrumentDataList([self.getInstrumentDataList()])
278
        except Exception as ex:
279
            return str(self.uid)
280
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
281

  
282
    '''
283
        @brief      return inst Data List
284
        @author     kyouho
285
        @date       2018.08.14
286
    '''
287
    def getInstrumentDataList(self):
288
        dataList = []
289
        try:
290
            from AppDocData import AppDocData
291

  
292
            global instColumnList
293

  
294
            docData = AppDocData.instance()
295
            attrs = self.attrs
296

  
297
            for index in range(len(instColumnList)):
298
                dataList.append('')
299

  
300
            dataList[0] = str(self.uid)
301
            dataList[13] = docData.imgName
302

  
303
            for attr in attrs:
304
                attrInfo = docData.getSymbolAttributeByUID(attr.attribute)
305
                attrName = attrInfo[0]
306
                if instColumnList.count(attrName):
307
                    colIndex = instColumnList.index(attrName)
308
                    
309
                    if type(attr) is UserInputAttribute:
310
                        dataList[colIndex] = attr.text if attr.text is not None else ''
311
                    elif type(attr) is QEngineeringTextItem:
312
                        dataList[colIndex] = attr.text()
313
                    else:
314
                        dataList[colIndex] = attr.uid
315

  
316
        except Exception as ex:
317
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
318

  
319
        return dataList
320

  
DTI_PID/DTI_PID/Shapes/SymbolSvgItem.py
513 513
    '''
514 514
    def getConnectedLabel(self, worker):
515 515
        import math
516
        from QEngineeringInstrumentItem import QEngineeringInstrumentItem
516
        from EngineeringInstrumentItem import QEngineeringInstrumentItem
517 517

  
518 518
        findSymbols = [symbol for symbol in worker.graphicsView.scene.items() if type(symbol) is QEngineeringInstrumentItem]
519 519

  
......
538 538
    '''
539 539
    def getAttributes(self):
540 540
        from EngineeringTextItem import QEngineeringTextItem
541
        from QEngineeringInstrumentItem import QEngineeringInstrumentItem
541
        from EngineeringInstrumentItem import QEngineeringInstrumentItem
542 542
        _attrs = {}
543 543
        
544 544
        # 해당 Type의 attribute setting
......
805 805
    def createItem(type, path, uid=None):
806 806
        from QEngineeringOPCItem import QEngineeringOPCItem
807 807
        from QEngineeringEquipmentItem import QEngineeringEquipmentItem
808
        from QEngineeringInstrumentItem import QEngineeringInstrumentItem
808
        from EngineeringInstrumentItem import QEngineeringInstrumentItem
809 809
        from EngineeringNozzleItem import QEngineeringNozzleItem
810 810
        from EngineeringSpecBreakItem import QEngineeringSpecBreakItem
811 811
        from AppDocData import AppDocData
DTI_PID/DTI_PID/SymbolAttr.py
1
# coding: utf-8
2
"""
3
    This is Symbol Attribute module
4
"""
5

  
6
class SymbolAttr:
7
    def __init__(self):
8
        self.UID = None
9
        self.Attribute = None
10
        self.DisplayAttribute = None
11
        self.AttributeType = None
12
        self.AttrAt = None
13
        self.Expression = None

내보내기 Unified diff