|
|
|
@ -49,7 +49,7 @@ class TbCombox(QComboBox):
|
|
|
|
|
def initUI(self):
|
|
|
|
|
# 创建ComboBox
|
|
|
|
|
|
|
|
|
|
self.addItems(["压力转换块", "温度转换块", "物位转换块", "流量转换块"])
|
|
|
|
|
self.addItems(["压力转换块", "温度转换块", "物位转换块", "流量转换块", 'WIKA液位计'])
|
|
|
|
|
|
|
|
|
|
self.setEditable(True) # 设置为可编辑以应用样式表隐藏文本
|
|
|
|
|
self.setObjectName('tbcombox')
|
|
|
|
@ -79,8 +79,8 @@ class DynamicAddBlock(QHBoxLayout):
|
|
|
|
|
self.blockViewlist = []
|
|
|
|
|
self.tbtypeList = TbtypeList #存放转换块的各种类型
|
|
|
|
|
# print(self.tbtypeList)
|
|
|
|
|
self.tbList = ['PressureTranslationBlock', 'TemperatureTranslationBlock', 'LevelTranslationBlock', 'FlowTranslationBlock'] #存放四个转换块
|
|
|
|
|
self.enumList = [TBType.pressureTB, TBType.tempTB, TBType.levelTB, TBType.flowTB]
|
|
|
|
|
self.tbList = ['PressureTranslationBlock', 'TemperatureTranslationBlock', 'LevelTranslationBlock', 'FlowTranslationBlock', 'WiKaLevelTranslationBlock'] #存放四个转换块
|
|
|
|
|
self.enumList = [TBType.pressureTB, TBType.tempTB, TBType.levelTB, TBType.flowTB, TBType.wikaLevelTB]
|
|
|
|
|
self.initUI()
|
|
|
|
|
|
|
|
|
|
def initUI(self):
|
|
|
|
@ -88,6 +88,7 @@ class DynamicAddBlock(QHBoxLayout):
|
|
|
|
|
tbNumber = self.blocklist[1]
|
|
|
|
|
fbNumber = self.blocklist[2]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for i in range(pbNumber):
|
|
|
|
|
pblockBtn = QPushButton('物理块')
|
|
|
|
|
|
|
|
|
@ -113,7 +114,7 @@ class DynamicAddBlock(QHBoxLayout):
|
|
|
|
|
fblockBtn.setObjectName("parameBtn")
|
|
|
|
|
fblockBtn.setIcon(qtawesome.icon('fa.th-large', color='#1fbb6f'))
|
|
|
|
|
fblockBtn.clicked.connect(lambda _, fbbtn = fblockBtn: self.switchParameterWidget(fbbtn))
|
|
|
|
|
# self.addWidget(fblockBtn, 3)
|
|
|
|
|
self.addWidget(fblockBtn, 3)
|
|
|
|
|
self.buttonlist.append(fblockBtn)
|
|
|
|
|
aiFunctionBlockView = ParmView(AIFunctionBlock, i, BlockType.FB)
|
|
|
|
|
self.blockViewlist.append(aiFunctionBlockView)
|
|
|
|
@ -141,6 +142,13 @@ class DynamicAddBlock(QHBoxLayout):
|
|
|
|
|
tbcombox.setCurrentIndex(3)
|
|
|
|
|
tblockBtn = QPushButton(tbcombox.currentText() + str(i + 1))
|
|
|
|
|
|
|
|
|
|
case None:
|
|
|
|
|
tbcombox.setCurrentIndex(4)
|
|
|
|
|
tblockBtn = QPushButton(tbcombox.currentText() + str(i + 1))
|
|
|
|
|
print(1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# tbcombox.setCurrentIndex(0)
|
|
|
|
|
# tblockBtn = QPushButton('压力转换块' + str(i + 1))
|
|
|
|
|
tblockBtn.setObjectName("tbparameBtn")
|
|
|
|
@ -160,6 +168,7 @@ class DynamicAddBlock(QHBoxLayout):
|
|
|
|
|
tbBlockView = ParmView(globals()[tb], i, enum)
|
|
|
|
|
self.blockViewlist.append(tbBlockView)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.parameterButtonGroup = QButtonGroup()
|
|
|
|
|
self.parameterButtonGroup.setExclusive(True)
|
|
|
|
|
for button in self.buttonlist:
|
|
|
|
@ -181,8 +190,8 @@ class DynamicAddBlock(QHBoxLayout):
|
|
|
|
|
buttonNumber = button.text()[-1]
|
|
|
|
|
button.setText(tbType + str(buttonNumber))
|
|
|
|
|
if button.isChecked():
|
|
|
|
|
stackIndex = (int(self.blocklist[0]) + int(self.blocklist[2]) + index) + (int(buttonNumber) - 1) * 4
|
|
|
|
|
|
|
|
|
|
stackIndex = (int(self.blocklist[0]) + int(self.blocklist[2]) + index) + (int(buttonNumber) - 1) * 5
|
|
|
|
|
print(stackIndex)
|
|
|
|
|
self.parameStackWidget.setCurrentIndex(stackIndex)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -276,46 +285,62 @@ class BlockParameterManageWidget(QWidget):
|
|
|
|
|
self.setLayout(self.mainlayout)
|
|
|
|
|
|
|
|
|
|
def loadBlackData(self):
|
|
|
|
|
address = self.deviceAddressEdit.text()
|
|
|
|
|
# print(address)
|
|
|
|
|
if address:
|
|
|
|
|
pattern = re.compile(r'^(?:[1-9]|[1-9][0-9]|1[0-1][0-9]|12[0-7])$')
|
|
|
|
|
match = pattern.match(address)
|
|
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
reply = QMessageBox.question(self.parent(),
|
|
|
|
|
'警告',
|
|
|
|
|
"请输入从站地址",
|
|
|
|
|
QMessageBox.Yes)
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
if not match:
|
|
|
|
|
QMessageBox.warning(self, '提示', '请输入2 - 127。')
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
if self.initUIstat:
|
|
|
|
|
address = self.deviceAddressEdit.text()
|
|
|
|
|
# print(address)
|
|
|
|
|
if address:
|
|
|
|
|
pattern = re.compile(r'^(?:[1-9]|[1-9][0-9]|1[0-1][0-9]|12[0-7])$')
|
|
|
|
|
match = pattern.match(address)
|
|
|
|
|
if not match:
|
|
|
|
|
QMessageBox.warning(self, '提示', '请输入2 - 127。')
|
|
|
|
|
return
|
|
|
|
|
if self.initUIstat:
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
|
|
self.blockManage = BlockManage(self._isPa, int(address))
|
|
|
|
|
|
|
|
|
|
except Exception as e:
|
|
|
|
|
reply = QMessageBox.question(self.parent(),
|
|
|
|
|
'警告',
|
|
|
|
|
f"发生错误: {e}",
|
|
|
|
|
QMessageBox.Yes)
|
|
|
|
|
return
|
|
|
|
|
self.splitter.deleteLater()
|
|
|
|
|
self.widget.deleteLater()
|
|
|
|
|
self.splitter = QSplitter()
|
|
|
|
|
Globals.setValue('blockManage', self.blockManage)
|
|
|
|
|
blocklist = self.blockManage.getBlockNums()
|
|
|
|
|
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)
|
|
|
|
|
self.initUIstat = False
|
|
|
|
|
else:
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
|
|
self.blockManage = BlockManage(self._isPa, int(address))
|
|
|
|
|
|
|
|
|
|
except Exception as e:
|
|
|
|
|
reply = QMessageBox.question(self.parent(),
|
|
|
|
|
'警告',
|
|
|
|
|
"请输入从站地址",
|
|
|
|
|
QMessageBox.Yes)
|
|
|
|
|
'警告',
|
|
|
|
|
f"发生错误: {e}",
|
|
|
|
|
QMessageBox.Yes)
|
|
|
|
|
return
|
|
|
|
|
self.splitter.deleteLater()
|
|
|
|
|
self.widget.deleteLater()
|
|
|
|
|
self.splitter = QSplitter()
|
|
|
|
|
Globals.setValue('blockManage', self.blockManage)
|
|
|
|
|
blocklist = self.blockManage.getBlockNums()
|
|
|
|
|
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)
|
|
|
|
|
self.initUIstat = False
|
|
|
|
|
self.recordAddress = address #记录链接成功的站地址
|
|
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
reply = QMessageBox.question(self, '确定', '确定更换站地址吗?',
|
|
|
|
|
QMessageBox.Yes | QMessageBox.No, QMessageBox.No)
|
|
|
|
|
if reply == QMessageBox.Yes:
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
|
|
self.blockManage = BlockManage(self._isPa, int(address))
|
|
|
|
|
|
|
|
|
|
except Exception as e:
|
|
|
|
|
reply = QMessageBox.question(self.parent(),
|
|
|
|
|
'警告',
|
|
|
|
|
f"发生错误: {e}",
|
|
|
|
|
QMessageBox.Yes)
|
|
|
|
|
self.deviceAddressEdit.setText(self.recordAddress)
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
self.blockLayout.deleteLater()
|
|
|
|
|
self.splitter.deleteLater()
|
|
|
|
|
self.splitter = QSplitter()
|
|
|
|
@ -326,6 +351,7 @@ class BlockParameterManageWidget(QWidget):
|
|
|
|
|
self.settingLayout.addLayout(self.blockLayout, 7)
|
|
|
|
|
self.settingLayout.addWidget(self.splitter, 11)
|
|
|
|
|
self.mainlayout.addWidget(self.blockLayout.parameStackWidget, 20)
|
|
|
|
|
self.recordAddress = address #记录链接成功的站地址
|
|
|
|
|
else:
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|