개정판 dd71563c
opc
Change-Id: Ic90a4355883652d76dd225d33c8e9f5b879ad340
DTI_PID/DTI_PID/OPCRelationDialog.py | ||
---|---|---|
88 | 88 |
|
89 | 89 |
row += 1 |
90 | 90 |
|
91 |
self.on_auto_fill_clicked(for_data_check=True) |
|
92 |
|
|
91 | 93 |
self.ui.tableWidgetTarget.setColumnCount(4) |
92 | 94 |
self.ui.tableWidgetTarget.setHorizontalHeaderLabels([self.tr('Drawing'), self.tr('Line No'), self.tr('Symbol'), self.tr('OPC')]) |
93 | 95 |
self.ui.tableWidgetTarget.horizontalHeaderItem(0).setSizeHint(QSize(25, 25)) |
94 | 96 |
self.ui.tableWidgetTarget.verticalHeader().hide() |
95 | 97 |
self.ui.tableWidgetTarget.horizontalHeader().setStretchLastSection(True) |
96 | 98 |
|
99 |
def check_opc_data(self): |
|
100 |
# check 1:N, N:1 error |
|
101 |
opc_counts = {} |
|
102 |
for row in range(self.ui.tableWidgetSource.rowCount()): |
|
103 |
item = self.ui.tableWidgetSource.item(row, 6) |
|
104 |
opc_uid = item.text() |
|
105 |
if not opc_uid: |
|
106 |
continue |
|
107 |
if opc_uid not in opc_counts: |
|
108 |
opc_counts[opc_uid] = [1, row] |
|
109 |
else: |
|
110 |
opc_counts[opc_uid][0] = opc_counts[opc_uid][0] + 1 |
|
111 |
opc_counts[opc_uid].append(row) |
|
112 |
|
|
113 |
for opc_uid, info in opc_counts.items(): |
|
114 |
if info[0] == 1: |
|
115 |
continue |
|
116 |
|
|
117 |
for row in info[1:]: |
|
118 |
item = self.ui.tableWidgetSource.item(row, 4) |
|
119 |
item.setText('') if item else self.ui.tableWidgetSource.setItem(row, 4, QTableWidgetItem('')) |
|
120 |
item = self.ui.tableWidgetSource.item(row, 5) |
|
121 |
item.setText('') if item else self.ui.tableWidgetSource.setItem(row, 5, QTableWidgetItem('')) |
|
122 |
item = self.ui.tableWidgetSource.item(row, 6) |
|
123 |
item.setText('') if item else self.ui.tableWidgetSource.setItem(row, 6, QTableWidgetItem('')) |
|
124 |
|
|
97 | 125 |
def parse_line_no_for_opc(self): |
98 | 126 |
# create line no item code from createTextItem |
99 | 127 |
from Configs import LineNoConfig |
... | ... | |
215 | 243 |
keys = configs[0].value if configs else '' |
216 | 244 |
self.target = keys.split(',') if keys else [] |
217 | 245 |
|
218 |
def on_auto_fill_clicked(self): |
|
246 |
def on_auto_fill_clicked(self, for_data_check=False):
|
|
219 | 247 |
""" fill target opc if only one line no exists """ |
220 | 248 |
if self.error: |
221 | 249 |
QMessageBox.about(self, self.tr('Error'), self.tr('Please check OPC data.')) |
... | ... | |
230 | 258 |
and opc['Drawing'] != drawing and self.compare_line_no(line_no_item, opc['tag']) \ |
231 | 259 |
and opc['Index'] != symbol_connection_index] |
232 | 260 |
if not opcs or len(opcs) > 1: |
233 |
item = self.ui.tableWidgetSource.item(row, 4) |
|
234 |
item.setText('') if item else self.ui.tableWidgetSource.setItem(row, 4, QTableWidgetItem('')) |
|
235 |
item = self.ui.tableWidgetSource.item(row, 5) |
|
236 |
item.setText('') if item else self.ui.tableWidgetSource.setItem(row, 5, QTableWidgetItem('')) |
|
237 |
item = self.ui.tableWidgetSource.item(row, 6) |
|
238 |
item.setText('') if item else self.ui.tableWidgetSource.setItem(row, 6, QTableWidgetItem('')) |
|
261 |
if not for_data_check: |
|
262 |
item = self.ui.tableWidgetSource.item(row, 4) |
|
263 |
item.setText('') if item else self.ui.tableWidgetSource.setItem(row, 4, QTableWidgetItem('')) |
|
264 |
item = self.ui.tableWidgetSource.item(row, 5) |
|
265 |
item.setText('') if item else self.ui.tableWidgetSource.setItem(row, 5, QTableWidgetItem('')) |
|
266 |
item = self.ui.tableWidgetSource.item(row, 6) |
|
267 |
item.setText('') if item else self.ui.tableWidgetSource.setItem(row, 6, QTableWidgetItem('')) |
|
239 | 268 |
if len(opcs) > 1: |
269 |
item = self.ui.tableWidgetSource.item(row, 6) |
|
240 | 270 |
if not hasattr(item, 'tag'): |
241 | 271 |
item.setBackground(Qt.yellow) |
242 |
elif len(opcs) == 1: |
|
272 |
elif len(opcs) == 1 and not for_data_check:
|
|
243 | 273 |
item = QTableWidgetItem(opcs[0]['Drawing']) |
244 | 274 |
item.setFlags(Qt.ItemIsEnabled) |
245 | 275 |
self.ui.tableWidgetSource.setItem(row, 4, item) |
... | ... | |
250 | 280 |
item.setFlags(Qt.ItemIsEnabled) |
251 | 281 |
self.ui.tableWidgetSource.setItem(row, 6, item) |
252 | 282 |
|
253 |
# check 1:N, N:1 error |
|
254 |
opc_counts = {} |
|
255 |
for row in range(self.ui.tableWidgetSource.rowCount()): |
|
256 |
item = self.ui.tableWidgetSource.item(row, 6) |
|
257 |
opc_uid = item.text() |
|
258 |
if not opc_uid: |
|
259 |
continue |
|
260 |
if opc_uid not in opc_counts: |
|
261 |
opc_counts[opc_uid] = [1, row] |
|
262 |
else: |
|
263 |
opc_counts[opc_uid][0] = opc_counts[opc_uid][0] + 1 |
|
264 |
opc_counts[opc_uid].append(row) |
|
265 |
|
|
266 |
for opc_uid, info in opc_counts.items(): |
|
267 |
if info[0] == 1: |
|
268 |
continue |
|
269 |
|
|
270 |
for row in info[1:]: |
|
271 |
item = self.ui.tableWidgetSource.item(row, 4) |
|
272 |
item.setText('') if item else self.ui.tableWidgetSource.setItem(row, 4, QTableWidgetItem('')) |
|
273 |
item = self.ui.tableWidgetSource.item(row, 5) |
|
274 |
item.setText('') if item else self.ui.tableWidgetSource.setItem(row, 5, QTableWidgetItem('')) |
|
275 |
item = self.ui.tableWidgetSource.item(row, 6) |
|
276 |
item.setText('') if item else self.ui.tableWidgetSource.setItem(row, 6, QTableWidgetItem('')) |
|
283 |
if not for_data_check: |
|
284 |
self.check_opc_data() |
|
277 | 285 |
|
278 | 286 |
def on_target_item_double_clicked(self, item): |
279 | 287 |
""" assign target opc with double clicked item """ |
내보내기 Unified diff