|
|
|
@ -11,6 +11,7 @@ QComboBox, QStyledItemDelegate, QVBoxLayout, QSplitter
|
|
|
|
|
from UI.LoadingDataWidget import LoadingDataWidget
|
|
|
|
|
from UI.ObjectTypeEditlayout import ObjectTypeEditlayout
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
from utils import Globals
|
|
|
|
|
|
|
|
|
|
class VarTableModel(QAbstractTableModel):
|
|
|
|
@ -131,7 +132,6 @@ class VarTableModel(QAbstractTableModel):
|
|
|
|
|
self.table.proxy.invalidate()
|
|
|
|
|
|
|
|
|
|
def updateValue(self, valueList):
|
|
|
|
|
print(len(valueList), len(self.datas))
|
|
|
|
|
for index, value in enumerate(valueList):
|
|
|
|
|
self.datas[index][5] = value
|
|
|
|
|
self.table.proxy.invalidate()
|
|
|
|
@ -180,18 +180,29 @@ class VarButtonDelegate(QItemDelegate):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if objectType == 'TARGET_MODE':
|
|
|
|
|
combox = QComboBox()
|
|
|
|
|
combox.setObjectName('modeCombox')
|
|
|
|
|
combox.addItems(["非服务", "手动初始化", "本地超驰", '手动', '自动', '级联', '远程级联', '远程输出'])
|
|
|
|
|
combox.setCurrentIndex(-1)
|
|
|
|
|
combox.currentIndexChanged.connect(lambda index : self.startAction(modelIndex = index))
|
|
|
|
|
combox.currentIndexChanged.connect(lambda index: self.startAction(modelIndex = index))
|
|
|
|
|
boxLayout.addWidget(combox, 10)
|
|
|
|
|
boxLayout.addWidget(refreshButton,1)
|
|
|
|
|
combox.index = [index.row(), index.column()]
|
|
|
|
|
|
|
|
|
|
elif objectType == 'SENSOR_UNIT':
|
|
|
|
|
comboxUnit = QComboBox()
|
|
|
|
|
comboxUnit.setObjectName('modeCombox')
|
|
|
|
|
comboxUnit.addItems(["kPa", "bar", "psi", 'inHg'])
|
|
|
|
|
comboxUnit.setCurrentIndex(-1)
|
|
|
|
|
comboxUnit.currentIndexChanged.connect(lambda index, comboxUnit = comboxUnit : self.startAction(modelIndex = index, comboxUnit = comboxUnit))
|
|
|
|
|
boxLayout.addWidget(comboxUnit, 10)
|
|
|
|
|
boxLayout.addWidget(refreshButton,1)
|
|
|
|
|
comboxUnit.index = [index.row(), index.column()]
|
|
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
boxLayout.addLayout(editlineLayout)
|
|
|
|
|
boxLayout.addLayout(editlineLayout)
|
|
|
|
|
startActionBtn.clicked.connect(lambda: self.startAction(objectTypeEditlayout = editlineLayout))
|
|
|
|
|
boxLayout.addWidget(startActionBtn)
|
|
|
|
|
boxLayout.addWidget(refreshButton)
|
|
|
|
@ -209,49 +220,68 @@ class VarButtonDelegate(QItemDelegate):
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def startAction(self, objectTypeEditlayout = None, modelIndex = None):
|
|
|
|
|
def startAction(self, objectTypeEditlayout = None, modelIndex = None, comboxUnit = None):
|
|
|
|
|
sender = self.sender()
|
|
|
|
|
blockView = self.parent()
|
|
|
|
|
model = blockView.model
|
|
|
|
|
blockType = blockView.blockType
|
|
|
|
|
blockIndex = blockView.blcokIndex
|
|
|
|
|
parmIndex = model.datas[sender.index[0]][0]
|
|
|
|
|
|
|
|
|
|
blockManage = Globals.getValue('blockManage')
|
|
|
|
|
|
|
|
|
|
if modelIndex or str(modelIndex) == '0' :
|
|
|
|
|
values = modelIndex
|
|
|
|
|
self.refreshData(modelIndex)
|
|
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
parmIndex = model.datas[sender.index[0]][0]
|
|
|
|
|
values = objectTypeEditlayout.getEditlineValue()
|
|
|
|
|
# if not values:
|
|
|
|
|
# reply = QMessageBox.question(self.parent(),
|
|
|
|
|
# '警告',
|
|
|
|
|
# "请输入强制值或数字",
|
|
|
|
|
# QMessageBox.Yes)
|
|
|
|
|
# return
|
|
|
|
|
|
|
|
|
|
# for value in values:
|
|
|
|
|
# # print(value)
|
|
|
|
|
# pattern = re.compile(r'[^0-9\.-]+')
|
|
|
|
|
# if not value or re.findall(pattern, str(value)):
|
|
|
|
|
# reply = QMessageBox.question(self.parent(),
|
|
|
|
|
# '警告',
|
|
|
|
|
# "请输入强制值或数字",
|
|
|
|
|
# QMessageBox.Yes)
|
|
|
|
|
# return
|
|
|
|
|
res = blockManage.writeParmValue(blockType, blockIndex, parmIndex, values)
|
|
|
|
|
self.refreshData()
|
|
|
|
|
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')
|
|
|
|
|
|
|
|
|
|
#修改操作模式
|
|
|
|
|
else:
|
|
|
|
|
if modelIndex or str(modelIndex) == '0' :
|
|
|
|
|
|
|
|
|
|
values.append(str(modelIndex))
|
|
|
|
|
#正常修改其他值
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
|
|
values = objectTypeEditlayout.getEditlineValue()
|
|
|
|
|
dataType = model.datas[sender.index[0]][3]
|
|
|
|
|
if not values:
|
|
|
|
|
reply = QMessageBox.question(self.parent(),
|
|
|
|
|
'警告',
|
|
|
|
|
"请输入强制值",
|
|
|
|
|
QMessageBox.Yes)
|
|
|
|
|
return
|
|
|
|
|
match dataType:
|
|
|
|
|
case "Float":
|
|
|
|
|
for value in values:
|
|
|
|
|
pattern = re.compile(r'[^0-9\.-]+')
|
|
|
|
|
if not value or re.findall(pattern, str(value)):
|
|
|
|
|
reply = QMessageBox.question(self.parent(),
|
|
|
|
|
'警告',
|
|
|
|
|
"请输入强制值或数字",
|
|
|
|
|
QMessageBox.Yes)
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
res = blockManage.writeParmValue(blockType, blockIndex, parmIndex, values)
|
|
|
|
|
self.refreshData()
|
|
|
|
|
|
|
|
|
|
def refreshData(self, modelIndex = None):
|
|
|
|
|
def refreshData(self):
|
|
|
|
|
sender = self.sender()
|
|
|
|
|
blockView = self.parent()
|
|
|
|
|
model = blockView.model
|
|
|
|
|
parmIndex = model.datas[sender.index[0]][0]
|
|
|
|
|
|
|
|
|
|
blockType = blockView.blockType
|
|
|
|
|
blockIndex = blockView.blcokIndex
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# print(blockName, blcokIndex, index)
|
|
|
|
|
blockManage = Globals.getValue('blockManage')
|
|
|
|
|
value = blockManage.getBlockParmValue(blockType, blockIndex, parmIndex)
|
|
|
|
|