main
parent 8011d136cd
commit b042f6662b

@ -530,7 +530,7 @@ QLineEdit#deviceMesEdit{
QLineEdit#deviceAddressEdit, QLineEdit#parameEditline{ QLineEdit#deviceAddressEdit, QLineEdit#parameEditline{
font-size: 16px; font-size: 25px;
border-top: none; border-top: none;

Binary file not shown.

Binary file not shown.

@ -187,6 +187,7 @@ class BlockParameterManageWidget(QWidget):
self.deviceAddressLabel = QLabel('从站地址') self.deviceAddressLabel = QLabel('从站地址')
self.deviceAddressLabel.setObjectName('deviceAddressLabel') self.deviceAddressLabel.setObjectName('deviceAddressLabel')
self.deviceAddressEdit = QLineEdit() self.deviceAddressEdit = QLineEdit()
self.deviceAddressEdit.returnPressed.connect(self.loadBlackData)
self.deviceAddressEdit.setObjectName("deviceAddressEdit") self.deviceAddressEdit.setObjectName("deviceAddressEdit")
self.confirmBtn = QPushButton('确定') self.confirmBtn = QPushButton('确定')
@ -233,10 +234,10 @@ class BlockParameterManageWidget(QWidget):
address = self.deviceAddressEdit.text() address = self.deviceAddressEdit.text()
# print(address) # print(address)
if address: if address:
pattern = re.compile(r'^(?:[1-9]|[1-9][0-9]|1[0-1][0-9]|12[0-5])$') pattern = re.compile(r'^(?:[1-9]|[1-9][0-9]|1[0-1][0-9]|12[0-6])$')
match = pattern.match(address) match = pattern.match(address)
if not match: if not match:
QMessageBox.warning(self, '提示', '请输入1 - 125') QMessageBox.warning(self, '提示', '请输入1 - 126')
return return
if self.initUIstat: if self.initUIstat:
try: try:
@ -304,18 +305,19 @@ class BlockParameterManageWidget(QWidget):
def editAddress(self): def editAddress(self):
if self.initUIstat: # if self.initUIstat:
reply = QMessageBox.question(self.parent(), # reply = QMessageBox.question(self.parent(),
'警告', # '警告',
"请先连接设备", # "请先连接设备",
QMessageBox.Yes) # QMessageBox.Yes)
return # return
oldAddress = self.blockManage.address # oldAddress = int(self.blockManage.address)
oldAddress = 106
self.editAddressWidget = EditAddressWidget(oldAddress) self.editAddressWidget = EditAddressWidget(oldAddress)
if self.editAddressWidget.exec_() == QDialog.Accepted: if self.editAddressWidget.exec_() == QDialog.Accepted:
newAddress = self.editAddressWidget.editAddressEdit.text() newAddress = int(self.editAddressWidget.editAddressEdit.text())
self.blockManage.DPV1Master.editDevAddress(oldAddress, newAddress) self.blockManage.DPV1Master.editDevAddress(oldAddress, newAddress)

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

@ -52,6 +52,7 @@ class BlockManage():
def __init__(self, address = None): def __init__(self, address = None):
self.address = address self.address = address
if address: if address:
# pass
self.initBlocks() self.initBlocks()
@property @property
@ -140,6 +141,7 @@ class BlockManage():
return block return block
def getBlockNums(self): def getBlockNums(self):
# return [1,1,1]
return [len(self.blockDict[BlockType.PB]), len(self.blockDict[BlockType.TB]), len(self.blockDict[BlockType.FB])] return [len(self.blockDict[BlockType.PB]), len(self.blockDict[BlockType.TB]), len(self.blockDict[BlockType.FB])]
@classmethod @classmethod
@ -197,6 +199,19 @@ class Block():
def getTBType(self): def getTBType(self):
return return
def getParmIndex(self, blockType, paramName):
match blockType:
case "BlockType.PB":
PhysicalBlock.getIndex(paramName)
case "BlockType.FB":
AIFunctionBlock.getIndex(paramName)
case "BlockType.TB":
pass
if __name__ == '__main__': if __name__ == '__main__':
b = BlockManage(address = 55) b = BlockManage(address = 55)

@ -123,7 +123,6 @@ class Parm():
return displayStr return displayStr
def unpackDS32(self, value): def unpackDS32(self, value):
print(value)
reserved = self.unpackU8(value[0:1]) reserved = self.unpackU8(value[0:1])
blockObject = self.unpackU8(value[1:2]) blockObject = self.unpackU8(value[1:2])
parentClass = self.unpackU8(value[2:3]) parentClass = self.unpackU8(value[2:3])

@ -130,9 +130,9 @@ class DPV1Master():
return False return False
def editDevAddress(self, oldAddress, newAddress): def editDevAddress(self, oldAddress, newAddress):
oldAddressHex = int(oldAddress).to_bytes(1, byteorder='little') oldAddressHex = oldAddress.to_bytes(length=1, byteorder='little')
newAddressHex = int(newAddress).to_bytes(1, byteorder='little') newAddressHex = newAddress.to_bytes(1, byteorder='little')
editAddressStream = b'\x03' + oldAddressHex + newAddressHex + b'\x00' editAddressStream = b'\x03' + oldAddressHex + b'\x00'+ newAddressHex
editAddressDate = struct.unpack('>hh', editAddressStream) editAddressDate = struct.unpack('>hh', editAddressStream)
self.writeMultipleRegister(1, 750, self.resetData) self.writeMultipleRegister(1, 750, self.resetData)
self.writeMultipleRegister(1, 750, editAddressDate) self.writeMultipleRegister(1, 750, editAddressDate)

@ -43,6 +43,14 @@ class PressureTranslationBlock(BaseModel):
except Exception as e: except Exception as e:
return return
@classmethod
def getIndex(cls):
params = cls.get_all()
if params is 'error':
return
return params.index
def addParame(self, index, paramName, objectType, dataType, saveType, dataSize, accessType, transferType, description): def addParame(self, index, paramName, objectType, dataType, saveType, dataSize, accessType, transferType, description):
self.index = index self.index = index
self.paramName = paramName self.paramName = paramName
@ -60,6 +68,7 @@ class PressureTranslationBlock(BaseModel):
class PhysicalBlock(PressureTranslationBlock): class PhysicalBlock(PressureTranslationBlock):
index = CharField() index = CharField()
paramName = CharField() paramName = CharField()

Loading…
Cancel
Save