|
|
|
|
@ -1,9 +1,9 @@
|
|
|
|
|
import re
|
|
|
|
|
import qtawesome
|
|
|
|
|
from PyQt5.QtGui import QPixmap, QPainter
|
|
|
|
|
from PyQt5.QtGui import QPixmap, QPainter, QIcon
|
|
|
|
|
from PyQt5.QtCore import Qt
|
|
|
|
|
from PyQt5.QtWidgets import QStyledItemDelegate, QStyle, QComboBox, QMessageBox, QPushButton,QStackedWidget, QLineEdit \
|
|
|
|
|
, QVBoxLayout, QHBoxLayout, QWidget, QLabel, QSplitter, QButtonGroup, QDialog
|
|
|
|
|
, QVBoxLayout, QHBoxLayout, QWidget, QLabel, QSplitter, QButtonGroup, QDialog, QRadioButton
|
|
|
|
|
from utils.DBModels.DeviceParModels import *
|
|
|
|
|
from UI.BlockParameterView import ParmView
|
|
|
|
|
from UI.SearchAddressWidget import SearchAddressWidget
|
|
|
|
|
@ -42,6 +42,7 @@ class HideTextDelegate(QStyledItemDelegate):
|
|
|
|
|
class TbCombox(QComboBox):
|
|
|
|
|
def __init__(self):
|
|
|
|
|
super().__init__()
|
|
|
|
|
# self.tbType = tbType
|
|
|
|
|
self.initUI()
|
|
|
|
|
|
|
|
|
|
def initUI(self):
|
|
|
|
|
@ -70,11 +71,12 @@ class TbCombox(QComboBox):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class DynamicAddBlock(QHBoxLayout):
|
|
|
|
|
def __init__(self, blocklist):
|
|
|
|
|
def __init__(self, blocklist, TbtypeList):
|
|
|
|
|
super().__init__()
|
|
|
|
|
self.blocklist = blocklist
|
|
|
|
|
self.buttonlist = []
|
|
|
|
|
self.blockViewlist = []
|
|
|
|
|
self.tbtypeList = TbtypeList #存放转换块的各种类型
|
|
|
|
|
self.tbList = ['PressureTranslationBlock', 'TemperatureTranslationBlock', 'LevelTranslationBlock', 'FlowTranslationBlock'] #存放四个转换块
|
|
|
|
|
self.enumList = [TBType.pressureTB, TBType.tempTB, TBType.levelTB, TBType.flowTB]
|
|
|
|
|
self.initUI()
|
|
|
|
|
@ -114,13 +116,27 @@ class DynamicAddBlock(QHBoxLayout):
|
|
|
|
|
aiFunctionBlockView = ParmView(AIFunctionBlock, i, BlockType.FB)
|
|
|
|
|
self.blockViewlist.append(aiFunctionBlockView)
|
|
|
|
|
|
|
|
|
|
for i in range(tbNumber):
|
|
|
|
|
for i, tbType in zip(range(tbNumber), self.tbtypeList):
|
|
|
|
|
tbwidget = QWidget()
|
|
|
|
|
tbwidget.setObjectName('tbwidget')
|
|
|
|
|
tblayout = QHBoxLayout()
|
|
|
|
|
|
|
|
|
|
tbwidget.setLayout(tblayout)
|
|
|
|
|
tbcombox = TbCombox()
|
|
|
|
|
match tbType:
|
|
|
|
|
case TBType.pressureTB:
|
|
|
|
|
tbcombox.setCurrentIndex(0)
|
|
|
|
|
tblockBtn = QPushButton(tbcombox.currentText() + str(i + 1))
|
|
|
|
|
case TBType.tempTB:
|
|
|
|
|
tbcombox.setCurrentIndex(1)
|
|
|
|
|
tblockBtn = QPushButton(tbcombox.currentText() + str(i + 1))
|
|
|
|
|
case TBType.levelTB:
|
|
|
|
|
tbcombox.setCurrentIndex(2)
|
|
|
|
|
tblockBtn = QPushButton(tbcombox.currentText() + str(i + 1))
|
|
|
|
|
case TBType.flowTB:
|
|
|
|
|
tbcombox.setCurrentIndex(3)
|
|
|
|
|
tblockBtn = QPushButton(tbcombox.currentText() + str(i + 1))
|
|
|
|
|
|
|
|
|
|
tbcombox.setCurrentIndex(0)
|
|
|
|
|
tblockBtn = QPushButton('压力转换块' + str(i + 1))
|
|
|
|
|
tblockBtn.setObjectName("tbparameBtn")
|
|
|
|
|
@ -188,12 +204,22 @@ class BlockParameterManageWidget(QWidget):
|
|
|
|
|
def __init__(self):
|
|
|
|
|
super().__init__()
|
|
|
|
|
self.initUI()
|
|
|
|
|
self._isPa = True
|
|
|
|
|
self.initUIstat = True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def initUI(self):
|
|
|
|
|
self.mainlayout = QVBoxLayout()
|
|
|
|
|
|
|
|
|
|
self.proTypeLabel = QLabel('PA协议')
|
|
|
|
|
self.proTypeLabel.setAlignment(Qt.AlignVCenter | Qt.AlignRight)
|
|
|
|
|
self.proTypeLabel.setObjectName('proTypeLabel')
|
|
|
|
|
|
|
|
|
|
self.proTypeRadioBtn = QRadioButton()
|
|
|
|
|
self.proTypeRadioBtn.setObjectName('proTypeRadioBtn')
|
|
|
|
|
self.proTypeRadioBtn.toggled.connect(self.changeProType)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.settingLayout = QHBoxLayout()
|
|
|
|
|
self.deviceAddressLabel = QLabel('从站地址')
|
|
|
|
|
self.deviceAddressLabel.setObjectName('deviceAddressLabel')
|
|
|
|
|
@ -221,6 +247,8 @@ class BlockParameterManageWidget(QWidget):
|
|
|
|
|
self.editAddressBtn.clicked.connect(self.editAddress)
|
|
|
|
|
self.editAddressBtn.setObjectName("parameBtn")
|
|
|
|
|
|
|
|
|
|
self.settingLayout.addWidget(self.proTypeLabel, 1)
|
|
|
|
|
self.settingLayout.addWidget(self.proTypeRadioBtn, 1)
|
|
|
|
|
self.settingLayout.addWidget(self.deviceAddressLabel, 1)
|
|
|
|
|
self.settingLayout.addWidget(self.deviceAddressEdit, 1)
|
|
|
|
|
self.settingLayout.addWidget(self.confirmBtn, 1)
|
|
|
|
|
@ -228,6 +256,7 @@ class BlockParameterManageWidget(QWidget):
|
|
|
|
|
self.settingLayout.addWidget(self.editAddressBtn, 1)
|
|
|
|
|
self.settingLayout.addWidget(self.refershDataBtn, 1)
|
|
|
|
|
# self.settingLayout.addLayout(self.blockLayout)
|
|
|
|
|
# self.settingLayout.setSpacing(5)
|
|
|
|
|
|
|
|
|
|
self.splitter = QSplitter()
|
|
|
|
|
self.settingLayout.addWidget(self.splitter, 18)
|
|
|
|
|
@ -252,7 +281,9 @@ class BlockParameterManageWidget(QWidget):
|
|
|
|
|
return
|
|
|
|
|
if self.initUIstat:
|
|
|
|
|
try:
|
|
|
|
|
self.blockManage = BlockManage(int(address))
|
|
|
|
|
|
|
|
|
|
self.blockManage = BlockManage(self._isPa, int(address))
|
|
|
|
|
|
|
|
|
|
except Exception as e:
|
|
|
|
|
reply = QMessageBox.question(self.parent(),
|
|
|
|
|
'警告',
|
|
|
|
|
@ -264,7 +295,7 @@ class BlockParameterManageWidget(QWidget):
|
|
|
|
|
self.splitter = QSplitter()
|
|
|
|
|
Globals.setValue('blockManage', self.blockManage)
|
|
|
|
|
blocklist = self.blockManage.getBlockNums()
|
|
|
|
|
self.blockLayout = DynamicAddBlock(blocklist)
|
|
|
|
|
self.blockLayout = DynamicAddBlock(blocklist, self.blockManage.TBTypeList)
|
|
|
|
|
self.settingLayout.addLayout(self.blockLayout, 7)
|
|
|
|
|
self.settingLayout.addWidget(self.splitter, 11)
|
|
|
|
|
self.mainlayout.addWidget(self.blockLayout.parameStackWidget, 20)
|
|
|
|
|
@ -283,7 +314,8 @@ class BlockParameterManageWidget(QWidget):
|
|
|
|
|
self.splitter.deleteLater()
|
|
|
|
|
self.splitter = QSplitter()
|
|
|
|
|
blocklist = self.blockManage.getBlockNums()
|
|
|
|
|
self.blockLayout = DynamicAddBlock(blocklist)
|
|
|
|
|
TbtypeList = self.blockManage.TBTypeList
|
|
|
|
|
self.blockLayout = DynamicAddBlock(blocklist, TbtypeList)
|
|
|
|
|
self.settingLayout.addLayout(self.blockLayout, 7)
|
|
|
|
|
self.settingLayout.addWidget(self.splitter, 11)
|
|
|
|
|
self.mainlayout.addWidget(self.blockLayout.parameStackWidget, 20)
|
|
|
|
|
@ -316,12 +348,12 @@ class BlockParameterManageWidget(QWidget):
|
|
|
|
|
|
|
|
|
|
def editAddress(self):
|
|
|
|
|
|
|
|
|
|
# if self.initUIstat:
|
|
|
|
|
# reply = QMessageBox.question(self.parent(),
|
|
|
|
|
# '警告',
|
|
|
|
|
# "请先连接设备",
|
|
|
|
|
# QMessageBox.Yes)
|
|
|
|
|
# return
|
|
|
|
|
if self.initUIstat:
|
|
|
|
|
reply = QMessageBox.question(self.parent(),
|
|
|
|
|
'警告',
|
|
|
|
|
"请先连接设备",
|
|
|
|
|
QMessageBox.Yes)
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
oldAddress = int(self.blockManage.address)
|
|
|
|
|
|
|
|
|
|
@ -329,7 +361,14 @@ class BlockParameterManageWidget(QWidget):
|
|
|
|
|
if self.editAddressWidget.exec_() == QDialog.Accepted:
|
|
|
|
|
|
|
|
|
|
newAddress = int(self.editAddressWidget.editAddressEdit.text())
|
|
|
|
|
self.blockManage.DPV1Master.editDevAddress(oldAddress, newAddress)
|
|
|
|
|
|
|
|
|
|
result =self.blockManage.DPV1Master.editDevAddress(oldAddress, newAddress)
|
|
|
|
|
|
|
|
|
|
reply = QMessageBox.question(self.parent(),
|
|
|
|
|
'提示',
|
|
|
|
|
result,
|
|
|
|
|
QMessageBox.Yes)
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -338,5 +377,27 @@ class BlockParameterManageWidget(QWidget):
|
|
|
|
|
self.searchAddressWidget = SearchAddressWidget(self.deviceAddressEdit)
|
|
|
|
|
self.searchAddressWidget.show()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def changeProType(self):
|
|
|
|
|
if self.proTypeRadioBtn.isChecked():
|
|
|
|
|
self.proTypeLabel.setText('DP协议')
|
|
|
|
|
self._isPa = False
|
|
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
self.proTypeLabel.setText('PA协议')
|
|
|
|
|
self._isPa = True
|
|
|
|
|
|
|
|
|
|
self.clearLayout()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def clearLayout(self):
|
|
|
|
|
if self.initUIstat:
|
|
|
|
|
return
|
|
|
|
|
else:
|
|
|
|
|
self.blockLayout.deleteLater()
|
|
|
|
|
self.splitter.deleteLater()
|
|
|
|
|
self.splitter = QSplitter()
|
|
|
|
|
self.widget = ShowImage('Static/pict.png')
|
|
|
|
|
self.mainlayout.addWidget(self.widget, 20)
|
|
|
|
|
self.settingLayout.addWidget(self.splitter,18)
|
|
|
|
|
self.initUIstat = True
|