main
zcwBit 1 year ago
parent 9dde7437bb
commit 7797fb03c6

@ -4,6 +4,20 @@ QComboBox#dataTypeCombox, QComboBox#orderCombox{
}
QComboBox#modeCombox{
background-color: #f0f0f0;
border: none;
height: 43px;
font-size: 40px;
}
QComboBox#tbcombox{
background-color: #f0f0f0;
@ -17,10 +31,30 @@ QComboBox#tbcombox{
border-radius: 5px;
margin-left: -10px;
font-size: 20px;
}
QComboBox#modeCombox::drop-down{
image: url(Static/down.png);
subcontrol-origin: padding;
subcontrol-position: top right;
background-color: #f0f0f0;
width: 20px;
border:none;
border-radius: 5px;
}
QComboBox#tbcombox::drop-down{
image: url(Static/down.png);
@ -308,7 +342,7 @@ QPushButton#tbparameBtn{
border: none;
width: 54.75px;
width: 140.75px;
height: 40px;
@ -381,6 +415,8 @@ QPushButton#refreshButton{
border: none;
size: 100px;
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -49,7 +49,7 @@ class TbCombox(QComboBox):
def initUI(self):
# 创建ComboBox
self.addItems(["压力转换块 ", "温度转换块", "物位转换块", "流量转换块"])
self.addItems(["压力转换块", "温度转换块", "物位转换块", "流量转换块"])
self.setEditable(True) # 设置为可编辑以应用样式表隐藏文本
self.setObjectName('tbcombox')

@ -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),bar1137).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):

@ -43,6 +43,7 @@ class ParmView(QTableView):
self.dbModel = dbModel
self.blcokIndex = blcokIndex
self.blockType = blockType
self.allUnitList = UnitTable.getAbleUint()
self.setHeader()
self.setupUi()
self.setData()

@ -145,7 +145,7 @@ class EditAddressWidget(QDialog):
# print(index)
def addCheckItem(self):
self.GSDData = GsdParser.parseGsdFiles('C:\\Users\\zcw\\Desktop\\海南profibus\\现场仪表GSD')
self.GSDData = GsdParser.parseGsdFiles()
# deviceTypeCombox
for GSDDict in self.GSDData:
self.deviceTypeCombox.addItem(GSDDict['modelName'])

@ -4,7 +4,8 @@ import re
class GsdParser:
@classmethod
def parseGsdFiles(cls, folderPath):
def parseGsdFiles(cls):
folderPath = 'D:\\EnTalk PROFIBUS Manager\\GSD'
gsdData = []
for filename in os.listdir(folderPath):
if filename.lower().endswith('.gsd'):

@ -37,7 +37,7 @@ class Parm():
return self.unpackValue(value)
def writeParm(self, values):
print(*values)
# print(*values)
valueByte = self.packValue(values)
result = self.DPV1Master.writeParm(address = self.address, slot = self.slot, index = self.realIndex, length = self.size, valueByte = valueByte)

@ -137,13 +137,16 @@ class DPV1Master():
def editDevAddress(self, oldAddress, newAddress, identNumer):
oldAddressHex = oldAddress.to_bytes(length=1, byteorder='little')
newAddressHex = newAddress.to_bytes(1, byteorder='little')
idHighHex = identNumer[:2].to_bytes(1, byteorder='little')
idLowHex = identNumer[2:].to_bytes(1, byteorder='little')
# print(identNumer)
idHighHex = int(identNumer[:2], 16).to_bytes(1, byteorder='little')
idLowHex = int(identNumer[2:], 16).to_bytes(1, byteorder='little')
editAddressStream = b'\x03' + oldAddressHex + b'\x00'+ newAddressHex + b'\x00' + idHighHex + b'\x00' + idLowHex
editAddressDate = struct.unpack('>hh', editAddressStream)
# print(editAddressStream)
editAddressDate = struct.unpack('>hhhh', editAddressStream)
# print(editAddressDate)
self.writeMultipleRegister(1, 750, self.resetData)
self.writeMultipleRegister(1, 750, editAddressDate)
time.sleep(0.3)
time.sleep(0.4)
value = self.readHoldingRegisters(1, 750, 2)
if value[0] == 57344:
result = '修改错误'

@ -147,30 +147,41 @@ class UnitTable(BaseModel):
unitValue = CharField()
unitSymbol = CharField()
description = CharField()
state = CharField()
createTime = CharField()
# 查询设备是否存在
@classmethod
def getallParame(cls):
devices = cls.get_all()
if devices is 'error':
return
def getByValue(cls, unitValue):
try:
return cls.get(cls.unitValue == str(unitValue))
except Exception as e:
return
@classmethod
def getAbleUint(cls):
units = cls.select().where(cls.state == '1')
# print(units,444)
l = []
for x in devices:
l.append([x.unitValue, x.unitSymbol, x.description])
for unit in units:
l.append([unit.unitValue, unit.unitSymbol])
return l
@classmethod
def getByValue(cls, unitValue):
def getUnitSymbolByUnitValue(cls, unitValue):
try:
return cls.get(cls.unitValue == str(unitValue))
unit = cls.get(cls.unitValue == unitValue)
return unit.unitSymbol
except Exception as e:
return
# print(e)
return
# print(units,444)
def addParame(self, unitValue, unitSymbol, description):
def addParame(self, unitValue, unitSymbol, description, state):
self.unitValue = unitValue
self.unitSymbol = unitSymbol
self.description = description
self.state = state
self.createTime = datetime.datetime.strftime(datetime.datetime.now(), '%Y-%m-%d %H:%M:%S')
# print(self.createTime)
self.save()

@ -22,6 +22,8 @@ class InitParameterDB():
parameters = pd.read_excel('static/UnitTable.xlsx', sheet_name = 'UnitTable')
for index, row in parameters.iterrows():
parameter = row.values
clsblockName = UnitTable()
clsblockName = UnitTable()
if not clsblockName.getByValue(parameter[0]):
clsblockName.addParame(unitValue = parameter[0], unitSymbol = parameter[1], description = parameter[2])
clsblockName.addParame(unitValue = parameter[0], unitSymbol = parameter[1], description = parameter[2], state = parameter[3])
# print(UnitTable.getAbleUint())
Loading…
Cancel
Save