|
|
|
@ -1,19 +1,22 @@
|
|
|
|
|
import imp
|
|
|
|
|
import time
|
|
|
|
|
from operator import imod
|
|
|
|
|
import typing
|
|
|
|
|
import re
|
|
|
|
|
# from matplotlib.pyplot import box
|
|
|
|
|
import qtawesome
|
|
|
|
|
from PyQt5 import QtGui,QtCore,QtWidgets
|
|
|
|
|
from PyQt5.QtCore import QAbstractTableModel, QModelIndex, Qt, QVariant, QSize
|
|
|
|
|
from PyQt5.QtCore import QAbstractTableModel, QModelIndex, Qt, QVariant, QSize, QTimer
|
|
|
|
|
from PyQt5.QtWidgets import QItemDelegate, QHBoxLayout, QWidget, QPushButton, QMessageBox, QLineEdit, \
|
|
|
|
|
QComboBox, QStyledItemDelegate, QVBoxLayout, QSplitter
|
|
|
|
|
|
|
|
|
|
from UI.LoadingDataWidget import LoadingDataWidget
|
|
|
|
|
from UI.ObjectTypeEditlayout import ObjectTypeEditlayout
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
from utils import Globals
|
|
|
|
|
|
|
|
|
|
from utils.DBModels.DeviceParModels import *
|
|
|
|
|
|
|
|
|
|
class VarTableModel(QAbstractTableModel):
|
|
|
|
|
''' 变量表模型类'''
|
|
|
|
|
def __init__(self, header, data: list, table = None):
|
|
|
|
@ -48,6 +51,9 @@ class VarTableModel(QAbstractTableModel):
|
|
|
|
|
print("列索引超出范围")
|
|
|
|
|
return
|
|
|
|
|
# for row in range(self.rowCount()):
|
|
|
|
|
if self.datas[row][2] in ['SENSOR_UNIT']:
|
|
|
|
|
unit = UnitTable.getUnitSymbolByUnitValue(value)
|
|
|
|
|
value = unit if unit else value
|
|
|
|
|
self.datas[row][6] = value
|
|
|
|
|
self.table.proxy.invalidate()
|
|
|
|
|
# self.layoutChanged.emit() # 通知视图数据已更改
|
|
|
|
@ -163,6 +169,7 @@ class VarButtonDelegate(QItemDelegate):
|
|
|
|
|
refreshButton.setObjectName("refreshButton")
|
|
|
|
|
refreshButton.clicked.connect(self.refreshData)
|
|
|
|
|
refreshButton.index = [index.row(), index.column()]
|
|
|
|
|
refreshButton.setIconSize(QSize(50,50))
|
|
|
|
|
|
|
|
|
|
readORwirte = self.parent().model.datas[index.row()][5]
|
|
|
|
|
if 'w' not in readORwirte:
|
|
|
|
@ -194,8 +201,10 @@ class VarButtonDelegate(QItemDelegate):
|
|
|
|
|
elif objectType == 'SENSOR_UNIT':
|
|
|
|
|
comboxUnit = QComboBox()
|
|
|
|
|
comboxUnit.setObjectName('modeCombox')
|
|
|
|
|
comboxUnit.addItems(["kPa", "bar", "psi", 'inHg'])
|
|
|
|
|
comboxUnit.setCurrentIndex(-1)
|
|
|
|
|
comboxUnit.addItem('下拉选择')
|
|
|
|
|
comboxUnit.addItems([x[1] for x in self.parent().allUnitList])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
comboxUnit.currentIndexChanged.connect(lambda index, comboxUnit = comboxUnit : self.startAction(modelIndex = index, comboxUnit = comboxUnit))
|
|
|
|
|
boxLayout.addWidget(comboxUnit, 10)
|
|
|
|
|
boxLayout.addWidget(refreshButton,1)
|
|
|
|
@ -207,8 +216,11 @@ class VarButtonDelegate(QItemDelegate):
|
|
|
|
|
boxLayout.addWidget(startActionBtn)
|
|
|
|
|
boxLayout.addWidget(refreshButton)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
startActionBtn.setObjectName('startActionBtn')
|
|
|
|
|
startActionBtn.setIconSize(QSize(50,50))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
boxLayout.setContentsMargins(0, 0, 0, 0)
|
|
|
|
|
widget = QWidget()
|
|
|
|
@ -231,16 +243,11 @@ class VarButtonDelegate(QItemDelegate):
|
|
|
|
|
values = []
|
|
|
|
|
#修改单位
|
|
|
|
|
if comboxUnit:
|
|
|
|
|
match str(modelIndex):
|
|
|
|
|
case '0':
|
|
|
|
|
values.append('1133')
|
|
|
|
|
case '1':
|
|
|
|
|
values.append('1137') #kPa(1133),bar(1137).psi(1141),inHg(1155)
|
|
|
|
|
case '2':
|
|
|
|
|
values.append('1141')
|
|
|
|
|
case '3':
|
|
|
|
|
values.append('1155')
|
|
|
|
|
|
|
|
|
|
if modelIndex == 0:
|
|
|
|
|
return
|
|
|
|
|
else:
|
|
|
|
|
values = [self.parent().allUnitList[modelIndex - 1][0]]
|
|
|
|
|
# print(values)
|
|
|
|
|
#修改操作模式
|
|
|
|
|
else:
|
|
|
|
|
if modelIndex or str(modelIndex) == '0' :
|
|
|
|
@ -268,8 +275,9 @@ class VarButtonDelegate(QItemDelegate):
|
|
|
|
|
"请输入强制值或数字",
|
|
|
|
|
QMessageBox.Yes)
|
|
|
|
|
return
|
|
|
|
|
print(values,555)
|
|
|
|
|
# print(values,555)
|
|
|
|
|
res = blockManage.writeParmValue(blockType, blockIndex, parmIndex, values)
|
|
|
|
|
time.sleep(0.4)
|
|
|
|
|
self.refreshData()
|
|
|
|
|
|
|
|
|
|
def refreshData(self):
|
|
|
|
|