프로젝트

일반

사용자정보

개정판 bd2f10bf

IDbd2f10bfa53ef6802e10d1cf1912f6a745e019fd
상위 5e500fed
하위 b6b7f59f, 236ae276

함의성이(가) 3년 이상 전에 추가함

fix opc relation

Change-Id: I298d286e4cbb49ae1c22f205da96c3d8fc49b0e1

차이점 보기:

DTI_PID/DTI_PID/AppDocData.py
3030 3030

  
3031 3031
    def get_opcs(self):
3032 3032
        """ get opc in project """
3033
        configs = self.getConfigs('PSN', 'Symbols')
3034
        target = configs[0].value if configs else 'ALL'
3035

  
3033 3036
        with self.project.database.connect() as conn:
3034 3037
            try:
3035 3038
                # Get a cursor object
3036 3039
                cursor = conn.cursor() if self.project.database.db_type == 'SQLite' else conn.cursor(as_dict=True)
3037 3040

  
3038
                sql = "select (select Name from Drawings where UID=a.Drawings_UID) as Drawing," \
3039
                      "(select Value from Components where UID=a.Owner) as [Line No]," \
3040
                      "(select Name from Symbol where a.Symbol_UID=UID) as Symbol," \
3041
                      "UID as OPC from Components a " \
3042
                      "where Symbol_UID in (select UID from Symbol where SymbolType_UID in " \
3043
                      "(select UID from SymbolType where Type='Instrument OPC''s' or Type='Piping OPC''s'))"
3041
                if target == "ALL" or target == '':
3042
                    sql = "select (select Name from Drawings where UID=a.Drawings_UID) as Drawing," \
3043
                        "(select Value from Components where UID=a.Owner) as [Line No]," \
3044
                        "(select Name from Symbol where a.Symbol_UID=UID) as Symbol," \
3045
                        "(select stuff((select ',' + convert(NVARCHAR(10),[index]) from [Points] where Connected = a.UID for XML PAth('')),1,1,'')) as [Index]," \
3046
                        "UID as OPC from Components a " \
3047
                        "where Symbol_UID in (select UID from Symbol where SymbolType_UID in " \
3048
                        "(select UID from SymbolType where Type='Instrument OPC''s' or Type='Piping OPC''s'))"
3049
                else:
3050
                    sql = "select (select Name from Drawings where UID=a.Drawings_UID) as Drawing," \
3051
                        "(select Value from Components where UID=a.Owner) as [Line No]," \
3052
                        "(select Name from Symbol where a.Symbol_UID=UID) as Symbol," \
3053
                        "(select stuff((select ',' + convert(NVARCHAR(10),[index]) from [Points] where Connected = a.UID for XML PAth('')),1,1,'')) as [Index]," \
3054
                        "UID as OPC from Components a " \
3055
                        "where Symbol_UID in (" + target + ")"
3056

  
3044 3057
                cursor.execute(sql)
3045 3058
                return cursor.fetchall()
3046 3059
                # Catch the exception
DTI_PID/DTI_PID/OPCRelationDialog.py
7 7
from PyQt5.QtCore import *
8 8
from PyQt5.QtGui import *
9 9
from PyQt5.QtWidgets import *
10
from AppDocData import AppDocData, MessageType
10
from AppDocData import AppDocData, MessageType, Config
11 11
from EngineeringLineNoTextItem import QEngineeringLineNoTextItem
12 12

  
13 13
sys.path.insert(0, os.path.dirname(os.path.realpath(__file__)) + '\\UI')
......
23 23
        self._opcs = None
24 24
        self.target = None
25 25
        self.delimiter = '"'
26
        self.error = False
26 27

  
27 28
        self.ui = OPCRelation_UI.Ui_OPCRelationDialog()
28 29
        self.ui.setupUi(self)
......
32 33
        self.ui.tableWidgetTarget.itemDoubleClicked.connect(self.on_target_item_double_clicked)
33 34
        self.ui.pushButtonAutoFill.clicked.connect(self.on_auto_fill_clicked)
34 35
        self.ui.pushButtonLineNoAttr.clicked.connect(self.on_line_no_target_clicked)
36
        self.ui.pushButtonSymbol.clicked.connect(self.on_symbol_target_clicked)
35 37
        self.init_table_widget()
36 38

  
37 39
    def init_table_widget(self):
......
59 61
            self.ui.tableWidgetSource.setItem(row, 0, item)
60 62
            item = QTableWidgetItem(opc['Line No'])
61 63
            item.setFlags(Qt.ItemIsEnabled)
64
            item.tag = opc['Index']
62 65
            self.ui.tableWidgetSource.setItem(row, 1, item)
63 66
            item = QTableWidgetItem(opc['Symbol'])
64 67
            item.setFlags(Qt.ItemIsEnabled)
......
77 80
            item = QTableWidgetItem(matches[0]['To_OPC_UID'] if matches else '')
78 81
            item.setFlags(Qt.ItemIsEnabled)
79 82
            self.ui.tableWidgetSource.setItem(row, 6, item)
83

  
84
            if opc['Index'] and len(opc['Index'].split(',')) != 1:
85
                item.setText('Error')
86
                self.error = True
87

  
80 88
            row += 1
81 89

  
82 90
        self.ui.tableWidgetTarget.setColumnCount(4)
......
89 97
        # create line no item code from createTextItem
90 98
        from Configs import LineNoConfig
91 99
        import csv
100

  
101
        '''
102
        app_doc_data = AppDocData.instance()
103
        configs = app_doc_data.getConfigs('PSN', 'Symbols')
104
        target = configs[0].value if configs else 'ALL'
105

  
106
        if self._opcs and target != 'ALL':
107
            target = target.split(',')
108
            self._opcs = [opc for opc in self._opcs if str(opc['Symbol_ID']) in target]
109
        '''
92 110
        
93 111
        for opc in self._opcs:
94 112
            opc['tag'] = None
......
121 139

  
122 140
        drawing = self.ui.tableWidgetSource.item(current.row(), 0).text()
123 141
        line_no_item = self.ui.tableWidgetSource.item(current.row(), 0).tag
142
        symbol_connection_index = self.ui.tableWidgetSource.item(current.row(), 1).tag
124 143
        item = self.ui.tableWidgetSource.item(current.row(), 5)
125
        target_opc = item.text() if item else None
126 144
        self.ui.tableWidgetTarget.setRowCount(0)
127 145
        if self._opcs:
128 146
            opcs = [opc for opc in self._opcs if line_no_item and opc['tag'] and line_no_item is not opc['tag'] \
129
                                                and opc['Drawing'] != drawing and self.compare_line_no(line_no_item, opc['tag'])]
147
                                                and opc['Drawing'] != drawing and self.compare_line_no(line_no_item, opc['tag']) \
148
                                                    and opc['Index'] != symbol_connection_index]
130 149
            self.ui.tableWidgetTarget.setRowCount(len(opcs))
131 150
            row = 0
132 151
            for opc in opcs:
......
151 170
        dialog = PSNLineNoAttrTargetDialog(self)
152 171
        (isAccept) = dialog.showDialog()
153 172

  
173
    def on_symbol_target_clicked(self):
174
        from SymbolAttrTargetDialog import SymbolAttrTargetDialog
175

  
176
        app_doc_data = AppDocData.instance()
177
        configs = app_doc_data.getConfigs('PSN', 'Symbols')
178
        target = configs[0].value if configs else 'ALL'
179

  
180
        symbolType = ["Instrument OPC's", "Piping OPC's"]
181

  
182
        dialog = SymbolAttrTargetDialog(self, symbolType, target)
183
        (isAccept, target) = dialog.showDialog()
184

  
185
        if isAccept:
186
            configs = []
187
            configs.append(Config('PSN', 'Symbols', target))
188
            app_doc_data.saveConfigs(configs)
189

  
154 190
    def compare_line_no(self, lineNo1, lineNo2):
155 191
        """ return true if line no same"""
156 192
        
......
180 216

  
181 217
    def on_auto_fill_clicked(self):
182 218
        """ fill target opc if only one line no exists """
219
        if self.error:
220
            QMessageBox.about(self, self.tr('Error'), self.tr('Please check OPC data.'))
221

  
183 222
        self.load_line_no_keys()
184 223

  
185 224
        for row in range(self.ui.tableWidgetSource.rowCount()):
186 225
            drawing = self.ui.tableWidgetSource.item(row, 0).text()
187 226
            line_no_item = self.ui.tableWidgetSource.item(row, 0).tag
227
            symbol_connection_index = self.ui.tableWidgetSource.item(row, 1).tag
188 228
            opcs = [opc for opc in self._opcs if line_no_item and opc['tag'] and line_no_item is not opc['tag'] \
189
                                                and opc['Drawing'] != drawing and self.compare_line_no(line_no_item, opc['tag'])]
229
                                                and opc['Drawing'] != drawing and self.compare_line_no(line_no_item, opc['tag']) \
230
                                                    and opc['Index'] != symbol_connection_index]
190 231
            if not opcs:
191 232
                item = self.ui.tableWidgetSource.item(row, 4)
192 233
                item.setText('') if item else self.ui.tableWidgetSource.setItem(row, 4, QTableWidgetItem(''))
......
252 293
        """ save sql information to database """
253 294
        from AppDocData import AppDocData
254 295

  
296
        if self.error:
297
            QMessageBox.about(self, self.tr('Error'), self.tr('Please check OPC data.'))
298

  
255 299
        try:
256 300
            QApplication.setOverrideCursor(Qt.WaitCursor)
257 301

  
DTI_PID/DTI_PID/UI/OPCRelation.ui
49 49
      </spacer>
50 50
     </item>
51 51
     <item>
52
      <widget class="QPushButton" name="pushButtonSymbol">
53
       <property name="text">
54
        <string>Symbol Setting</string>
55
       </property>
56
      </widget>
57
     </item>
58
     <item>
52 59
      <widget class="QPushButton" name="pushButtonLineNoAttr">
53 60
       <property name="text">
54 61
        <string>Line No. Key Setting</string>
DTI_PID/DTI_PID/UI/OPCRelation_UI.py
1 1
# -*- coding: utf-8 -*-
2 2

  
3
# Form implementation generated from reading ui file '.\UI\OPCRelation.ui'
3
# Form implementation generated from reading ui file './UI/OPCRelation.ui'
4 4
#
5
# Created by: PyQt5 UI code generator 5.15.4
5
# Created by: PyQt5 UI code generator 5.9.2
6 6
#
7
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
8
# run again.  Do not edit this file unless you know what you are doing.
9

  
7
# WARNING! All changes made in this file will be lost!
10 8

  
11 9
from PyQt5 import QtCore, QtGui, QtWidgets
12 10

  
13

  
14 11
class Ui_OPCRelationDialog(object):
15 12
    def setupUi(self, OPCRelationDialog):
16 13
        OPCRelationDialog.setObjectName("OPCRelationDialog")
......
27 24
        self.horizontalLayout.addWidget(self.pushButtonAutoFill)
28 25
        spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
29 26
        self.horizontalLayout.addItem(spacerItem)
27
        self.pushButtonSymbol = QtWidgets.QPushButton(OPCRelationDialog)
28
        self.pushButtonSymbol.setObjectName("pushButtonSymbol")
29
        self.horizontalLayout.addWidget(self.pushButtonSymbol)
30 30
        self.pushButtonLineNoAttr = QtWidgets.QPushButton(OPCRelationDialog)
31 31
        self.pushButtonLineNoAttr.setObjectName("pushButtonLineNoAttr")
32 32
        self.horizontalLayout.addWidget(self.pushButtonLineNoAttr)
......
81 81
        _translate = QtCore.QCoreApplication.translate
82 82
        OPCRelationDialog.setWindowTitle(_translate("OPCRelationDialog", "OPC Relation"))
83 83
        self.pushButtonAutoFill.setText(_translate("OPCRelationDialog", "Auto Fill"))
84
        self.pushButtonSymbol.setText(_translate("OPCRelationDialog", "Symbol Setting"))
84 85
        self.pushButtonLineNoAttr.setText(_translate("OPCRelationDialog", "Line No. Key Setting"))
85 86
        self.tableWidgetSource.setSortingEnabled(True)
86 87
        self.tableWidgetTarget.setSortingEnabled(True)
......
94 95
    ui.setupUi(OPCRelationDialog)
95 96
    OPCRelationDialog.show()
96 97
    sys.exit(app.exec_())
98

  

내보내기 Unified diff

클립보드 이미지 추가 (최대 크기: 500 MB)