0613更新

main
ZHANGXUXU\95193 1 year ago
parent 6e3c3625fc
commit d0001ef32d

@ -10,6 +10,8 @@ QComboBox#tbcombox{
border: none; border: none;
height: 43px;
padding-left: 5px; padding-left: 5px;
border-radius: 5px; border-radius: 5px;
@ -28,7 +30,7 @@ QComboBox#tbcombox::drop-down{
background-color: #f0f0f0; background-color: #f0f0f0;
width: 15px; width: 20px;
border:none; border:none;
@ -247,8 +249,8 @@ QPushButton#confirmButton, QPushButton#exitButton{
QPushButton#parameBtn{ QPushButton#parameBtn{
border: none; border: none;
/*
width: 54.75px; width: 54.75px; */
height: 40px; height: 40px;
@ -289,6 +291,55 @@ QPushButton#parameBtn:checked{
} }
QPushButton#tbparameBtn{
border: none;
width: 54.75px;
height: 40px;
background-color: #f0f0f0;
/* border-radius: 5px; */
border-top-left-radius: 5px;
border-bottom-left-radius: 5px;
color: #0e0000;
font-family: ".SFNSDisplay-Medium";
font-size: 17px;
font-weight: 520;
}
QPushButton#tbparameBtn:hover{
font: bold;
border: none;
background-color: #007bff;
margin-bottom: -1px;
}
QPushButton#tbparameBtn:checked{
background-color: #007bff;
color: #f7f6f6;
}
QPushButton#startActionBtn:hover{ QPushButton#startActionBtn:hover{
font: bold; font: bold;

Binary file not shown.

Binary file not shown.

@ -1,5 +1,7 @@
from ast import match_case
from tkinter.ttk import Combobox from tkinter.ttk import Combobox
from numpy import mat
import qtawesome import qtawesome
from PyQt5.QtCore import Qt from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QStyledItemDelegate, QStyle, QComboBox, QMessageBox, QPushButton,QStackedWidget, QLineEdit, QVBoxLayout, QHBoxLayout, QWidget, QLabel, QSplitter, QButtonGroup from PyQt5.QtWidgets import QStyledItemDelegate, QStyle, QComboBox, QMessageBox, QPushButton,QStackedWidget, QLineEdit, QVBoxLayout, QHBoxLayout, QWidget, QLabel, QSplitter, QButtonGroup
@ -28,7 +30,8 @@ class TbCombox(QComboBox):
def initUI(self): def initUI(self):
# 创建ComboBox # 创建ComboBox
self.addItems(["选项很长很长很长", "选项2", "选项3"]) self.addItems(["压力转换块 ", "温度转换块", "物位转换块", "流量转换块"])
self.setEditable(True) # 设置为可编辑以应用样式表隐藏文本 self.setEditable(True) # 设置为可编辑以应用样式表隐藏文本
self.setObjectName('tbcombox') self.setObjectName('tbcombox')
# 设置样式隐藏文本 # 设置样式隐藏文本
@ -44,8 +47,8 @@ class TbCombox(QComboBox):
self.setFixedSize(30, 40) self.setFixedSize(30, 40)
# 确保下拉列表宽度适应最长项 # 确保下拉列表宽度适应最长项
max_width = max(self.fontMetrics().width(self.itemText(i)) for i in range(self.count())) # max_width = max(self.fontMetrics().width(self.itemText(i)) for i in range(self.count()))
self.view().setMinimumWidth(max_width) self.view().setMinimumWidth(100)
@ -55,6 +58,7 @@ class DynamicAddBlock(QHBoxLayout):
self.blocklist = blocklist self.blocklist = blocklist
self.buttonlist = [] self.buttonlist = []
self.blockViewlist = [] self.blockViewlist = []
self.tbList = ['PressureTranslationBlock', 'TemperatureTranslationBlock', 'LevelTranslationBlock', 'FlowTranslationBlock'] #存放四个转换块
self.initUI() self.initUI()
def initUI(self): def initUI(self):
@ -66,12 +70,12 @@ class DynamicAddBlock(QHBoxLayout):
pblockBtn = QPushButton('物理块') pblockBtn = QPushButton('物理块')
pblockBtn.setCheckable(True) pblockBtn.setCheckable(True)
pblockBtn.setFixedSize(90, 43) # pblockBtn.setFixedSize(90, 43)
pblockBtn.setObjectName("parameBtn") pblockBtn.setObjectName("parameBtn")
pblockBtn.setIcon(qtawesome.icon('fa.th-large', color='#1fbb6f')) pblockBtn.setIcon(qtawesome.icon('fa.th-large', color='#1fbb6f'))
# pblockBtn.setCheckable(True) # pblockBtn.setCheckable(True)
pblockBtn.clicked.connect(lambda _, pbbtn = pblockBtn: self.switchParameterWidget(pbbtn)) pblockBtn.clicked.connect(lambda _, pbbtn = pblockBtn: self.switchParameterWidget(pbbtn))
self.addWidget(pblockBtn) self.addWidget(pblockBtn, 3)
self.buttonlist.append(pblockBtn) self.buttonlist.append(pblockBtn)
physicalBlockView = ParmView(PhysicalBlock) physicalBlockView = ParmView(PhysicalBlock)
self.blockViewlist.append(physicalBlockView) self.blockViewlist.append(physicalBlockView)
@ -82,12 +86,12 @@ class DynamicAddBlock(QHBoxLayout):
for i in range(fbNumber): for i in range(fbNumber):
fblockBtn = QPushButton('功能块' + str(i + 1)) fblockBtn = QPushButton('功能块' + str(i + 1))
fblockBtn.setFixedSize(90, 43) # fblockBtn.setFixedSize(90, 43)
fblockBtn.setCheckable(True) fblockBtn.setCheckable(True)
fblockBtn.setObjectName("parameBtn") fblockBtn.setObjectName("parameBtn")
fblockBtn.setIcon(qtawesome.icon('fa.th-large', color='#1fbb6f')) fblockBtn.setIcon(qtawesome.icon('fa.th-large', color='#1fbb6f'))
fblockBtn.clicked.connect(lambda _, fbbtn = fblockBtn: self.switchParameterWidget(fbbtn)) fblockBtn.clicked.connect(lambda _, fbbtn = fblockBtn: self.switchParameterWidget(fbbtn))
self.addWidget(fblockBtn) self.addWidget(fblockBtn, 3)
self.buttonlist.append(fblockBtn) self.buttonlist.append(fblockBtn)
aiFunctionBlockView = ParmView(AIFunctionBlock) aiFunctionBlockView = ParmView(AIFunctionBlock)
self.blockViewlist.append(aiFunctionBlockView) self.blockViewlist.append(aiFunctionBlockView)
@ -99,44 +103,46 @@ class DynamicAddBlock(QHBoxLayout):
tbwidget.setLayout(tblayout) tbwidget.setLayout(tblayout)
tbcombox = TbCombox() tbcombox = TbCombox()
tbcombox.setCurrentIndex(0)
tblockBtn = QPushButton('转换块' + str(i + 1)) tblockBtn = QPushButton('压力转换块' + str(i + 1))
tblockBtn.setObjectName("parameBtn") tblockBtn.setObjectName("tbparameBtn")
tblockBtn.setFixedSize(90, 43) # tblockBtn.setFixedSize(130, 43)
tblockBtn.setCheckable(True) tblockBtn.setCheckable(True)
tblockBtn.setIcon(qtawesome.icon('fa.th-large', color='#1fbb6f')) tblockBtn.setIcon(qtawesome.icon('fa.th-large', color='#1fbb6f'))
tblockBtn.clicked.connect(lambda _, tbbtn = tblockBtn: self.switchParameterWidget(tbbtn)) # tblockBtn.clicked.connect(lambda _, tbbtn = tblockBtn: self.switchParameterWidget(tbbtn))
tbcombox.currentIndexChanged.connect(lambda index, combox = tbcombox, tbbtn = tblockBtn : self.chooseTbtype(index, combox, tbbtn)) tblockBtn.clicked.connect(lambda _, combox = tbcombox, tbbtn = tblockBtn : self.switchTbtype(combox.currentIndex(), combox, tbbtn))
tbcombox.currentIndexChanged.connect(lambda index, combox = tbcombox, tbbtn = tblockBtn : self.switchTbtype(index, combox, tbbtn))
tblayout.addWidget(tblockBtn)
tblayout.addWidget(tbcombox) tblayout.addWidget(tblockBtn, 6)
self.addWidget(tbwidget) tblayout.addWidget(tbcombox, 1)
tblayout.setSpacing(0)
self.addWidget(tbwidget, 5)
self.buttonlist.append(tblockBtn) self.buttonlist.append(tblockBtn)
pressureTBlockView = ParmView(PressureTranslationBlock) for tb in self.tbList:
self.blockViewlist.append(pressureTBlockView) tbBlockView = ParmView(globals()[tb])
self.blockViewlist.append(tbBlockView)
self.parameterButtonGroup = QButtonGroup() self.parameterButtonGroup = QButtonGroup()
self.parameterButtonGroup.setExclusive(True) self.parameterButtonGroup.setExclusive(True)
for button in self.buttonlist: for button in self.buttonlist:
self.parameterButtonGroup.addButton(button) self.parameterButtonGroup.addButton(button)
self.parameStackWidget = QStackedWidget() self.parameStackWidget = QStackedWidget()
for view in self.blockViewlist: for view in self.blockViewlist:
self.parameStackWidget.addWidget(view) self.parameStackWidget.addWidget(view)
def switchParameterWidget(self, buttonType): def switchTbtype(self, index, combox, button):
print(buttonType)
for index , button in enumerate(self.buttonlist):
if button == buttonType:
self.parameStackWidget.setCurrentIndex(index)
def chooseTbtype(self, index, combox, button):
tbType = combox.itemText(index) tbType = combox.itemText(index)
button.setText(tbType) buttonNumber = button.text()[-1:]
button.setText(tbType + str(buttonNumber))
if button.isChecked():
stackIndex = (int(self.blocklist[0]) + int(self.blocklist[1]) + index) + (int(buttonNumber) - 1) * 4
self.parameStackWidget.setCurrentIndex(stackIndex)
class BlockParameterManageWidget(QWidget): class BlockParameterManageWidget(QWidget):
@ -209,11 +215,11 @@ class BlockParameterManageWidget(QWidget):
self.loadingDataWidget.loadData() self.loadingDataWidget.loadData()
self.settingLayout.addLayout(self.blockLayout) self.settingLayout.addLayout(self.blockLayout, 7)
self.settingLayout.addWidget(QSplitter(), 18) self.settingLayout.addWidget(QSplitter(), 11)
self.mainlayout.addWidget(self.blockLayout.parameStackWidget, 20) self.mainlayout.addWidget(self.blockLayout.parameStackWidget, 20)
model = self.blockLayout.parameStackWidget.currentWidget().model model = self.blockLayout.parameStackWidget.currentWidget().model
model.updateColumn(5, '查询中...') model.updateColumn(5, '查询中sdadadsda\r\nsdasdsasasad\r\nasdsadsad...')
else: else:
reply = QMessageBox.question(self.parent(), reply = QMessageBox.question(self.parent(),
'警告', '警告',

@ -18,6 +18,6 @@ class Client(object):
else: else:
self.deviceDB = SqliteDatabase(dbPath) self.deviceDB = SqliteDatabase(dbPath)
client_proxy.initialize(self.deviceDB) client_proxy.initialize(self.deviceDB)
modelsArr = [DeviceDB, PressureTranslationBlock, PhysicalBlock, AIFunctionBlock] modelsArr = [DeviceDB, PressureTranslationBlock, PhysicalBlock, AIFunctionBlock, TemperatureTranslationBlock, LevelTranslationBlock, FlowTranslationBlock, UnitTable]
self.deviceDB.connect() self.deviceDB.connect()
self.deviceDB.create_tables(modelsArr, safe = True) self.deviceDB.create_tables(modelsArr, safe = True)

@ -86,4 +86,72 @@ class AIFunctionBlock(PressureTranslationBlock):
description = CharField() description = CharField()
createTime = CharField() createTime = CharField()
class TemperatureTranslationBlock(PressureTranslationBlock):
index = CharField()
paramName = CharField()
objectType = CharField()
dataType = CharField()
saveType = CharField()
dataSize = CharField()
accessType = CharField()
transferType = CharField()
description = CharField()
createTime = CharField()
class LevelTranslationBlock(PressureTranslationBlock):
index = CharField()
paramName = CharField()
objectType = CharField()
dataType = CharField()
saveType = CharField()
dataSize = CharField()
accessType = CharField()
transferType = CharField()
description = CharField()
createTime = CharField()
class FlowTranslationBlock(PressureTranslationBlock):
index = CharField()
paramName = CharField()
objectType = CharField()
dataType = CharField()
saveType = CharField()
dataSize = CharField()
accessType = CharField()
transferType = CharField()
description = CharField()
createTime = CharField()
class UnitTable(BaseModel):
unitValue = CharField()
unitSymbol = CharField()
description = CharField()
createTime = CharField()
# 查询设备是否存在
@classmethod
def getallParame(cls):
devices = cls.get_all()
if devices is 'error':
return
l = []
for x in devices:
l.append([x.unitValue, x.unitSymbol, x.description])
return l
@classmethod
def getByValue(cls, unitValue):
try:
return cls.get(cls.unitValue == str(unitValue))
except Exception as e:
return
def addParame(self, unitValue, unitSymbol, description):
self.unitValue = unitValue
self.unitSymbol = unitSymbol
self.description = description
self.createTime = datetime.datetime.strftime(datetime.datetime.now(), '%Y-%m-%d %H:%M:%S')
# print(self.createTime)
self.save()

@ -4,11 +4,12 @@ import pandas as pd
class InitParameterDB(): class InitParameterDB():
def __init__(self) -> None: def __init__(self) -> None:
self.writeParameter() self.writeParameter()
self.writeUnitParameter()
def writeParameter(self) -> None: def writeParameter(self) -> None:
blockNames = pd.ExcelFile('static/PA块信息表.xlsx').sheet_names blockNames = pd.ExcelFile('static/PA块信息表.xlsx').sheet_names
for blockName in blockNames: for blockName in blockNames:
parameters = pd.read_excel('static/PA块信息表.xlsx', sheet_name=str(blockName)) parameters = pd.read_excel('static/PA块信息表.xlsx', sheet_name = str(blockName))
for index, row in parameters.iterrows(): for index, row in parameters.iterrows():
parameter = row.values parameter = row.values
@ -17,3 +18,10 @@ class InitParameterDB():
clsblockName.addParame(index = parameter[0], paramName = parameter[1], objectType = parameter[2], dataType = parameter[3], clsblockName.addParame(index = parameter[0], paramName = parameter[1], objectType = parameter[2], dataType = parameter[3],
saveType = parameter[4], dataSize = parameter[5], accessType = parameter[6], transferType = parameter[7], description = parameter[8]) saveType = parameter[4], dataSize = parameter[5], accessType = parameter[6], transferType = parameter[7], description = parameter[8])
def writeUnitParameter(self):
parameters = pd.read_excel('static/UnitTable.xlsx', sheet_name = 'UnitTable')
for index, row in parameters.iterrows():
parameter = row.values
clsblockName = UnitTable()
if not clsblockName.getByValue(parameter[0]):
clsblockName.addParame(unitValue = parameter[0], unitSymbol = parameter[1], description = parameter[2])
Loading…
Cancel
Save