|
|
|
@ -1,5 +1,6 @@
|
|
|
|
|
import re
|
|
|
|
|
import qtawesome
|
|
|
|
|
from PyQt5.QtGui import QPixmap, QPainter
|
|
|
|
|
from PyQt5.QtCore import Qt
|
|
|
|
|
from PyQt5.QtWidgets import QStyledItemDelegate, QStyle, QComboBox, QMessageBox, QPushButton,QStackedWidget, QLineEdit \
|
|
|
|
|
, QVBoxLayout, QHBoxLayout, QWidget, QLabel, QSplitter, QButtonGroup, QDialog
|
|
|
|
@ -15,6 +16,16 @@ from UI.EditAddressWidget import EditAddressWidget
|
|
|
|
|
|
|
|
|
|
from model.ProjectModel.BlockManage import BlockManage, BlockType, TBType
|
|
|
|
|
|
|
|
|
|
class ShowImage(QWidget):
|
|
|
|
|
def __init__(self, image_path):
|
|
|
|
|
super().__init__()
|
|
|
|
|
self.image_path = image_path
|
|
|
|
|
self.pixmap = QPixmap(self.image_path)
|
|
|
|
|
|
|
|
|
|
def paintEvent(self, event):
|
|
|
|
|
painter = QPainter(self)
|
|
|
|
|
painter.drawPixmap(self.rect(), self.pixmap)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -98,7 +109,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)
|
|
|
|
@ -190,32 +201,32 @@ class BlockParameterManageWidget(QWidget):
|
|
|
|
|
self.deviceAddressEdit.returnPressed.connect(self.loadBlackData)
|
|
|
|
|
self.deviceAddressEdit.setObjectName("deviceAddressEdit")
|
|
|
|
|
|
|
|
|
|
self.confirmBtn = QPushButton('确定')
|
|
|
|
|
self.confirmBtn.setIcon(qtawesome.icon('fa5s.check-circle', color='#1fbb6f'))
|
|
|
|
|
self.confirmBtn = QPushButton('连接设备')
|
|
|
|
|
self.confirmBtn.setIcon(qtawesome.icon('mdi.connection', color='#1fbb6f'))
|
|
|
|
|
self.confirmBtn.clicked.connect(self.loadBlackData)
|
|
|
|
|
self.confirmBtn.setObjectName("parameBtn")
|
|
|
|
|
|
|
|
|
|
self.refershDataBtn = QPushButton('加载数据')
|
|
|
|
|
self.refershDataBtn.setIcon(qtawesome.icon('fa5s.check-circle', color='#1fbb6f'))
|
|
|
|
|
self.refershDataBtn.setIcon(qtawesome.icon('mdi6.reload', color='#1fbb6f'))
|
|
|
|
|
self.refershDataBtn.clicked.connect(self.refreshData)
|
|
|
|
|
self.refershDataBtn.setObjectName("parameBtn")
|
|
|
|
|
|
|
|
|
|
self.deviceAddressSearchBtn = QPushButton('查找')
|
|
|
|
|
self.deviceAddressSearchBtn = QPushButton('搜索站地址')
|
|
|
|
|
self.deviceAddressSearchBtn.setIcon(qtawesome.icon('fa.search', color='#1fbb6f'))
|
|
|
|
|
self.deviceAddressSearchBtn.clicked.connect(self.searchAddress)
|
|
|
|
|
self.deviceAddressSearchBtn.setObjectName("parameBtn")
|
|
|
|
|
|
|
|
|
|
self.editAddressBtn = QPushButton('修改站地址')
|
|
|
|
|
self.editAddressBtn.setIcon(qtawesome.icon('fa.search', color='#1fbb6f'))
|
|
|
|
|
self.editAddressBtn.setIcon(qtawesome.icon('fa.edit', color='#1fbb6f'))
|
|
|
|
|
self.editAddressBtn.clicked.connect(self.editAddress)
|
|
|
|
|
self.editAddressBtn.setObjectName("parameBtn")
|
|
|
|
|
|
|
|
|
|
self.settingLayout.addWidget(self.deviceAddressLabel, 1)
|
|
|
|
|
self.settingLayout.addWidget(self.deviceAddressEdit, 1)
|
|
|
|
|
self.settingLayout.addWidget(self.confirmBtn, 1)
|
|
|
|
|
self.settingLayout.addWidget(self.refershDataBtn, 1)
|
|
|
|
|
self.settingLayout.addWidget(self.deviceAddressSearchBtn, 1)
|
|
|
|
|
self.settingLayout.addWidget(self.editAddressBtn, 1)
|
|
|
|
|
self.settingLayout.addWidget(self.refershDataBtn, 1)
|
|
|
|
|
# self.settingLayout.addLayout(self.blockLayout)
|
|
|
|
|
|
|
|
|
|
self.splitter = QSplitter()
|
|
|
|
@ -223,7 +234,7 @@ class BlockParameterManageWidget(QWidget):
|
|
|
|
|
|
|
|
|
|
self.mainlayout.addLayout(self.settingLayout,1)
|
|
|
|
|
|
|
|
|
|
self.widget = QWidget()
|
|
|
|
|
self.widget = ShowImage('Static/pict.png')
|
|
|
|
|
self.mainlayout.addWidget(self.widget, 20)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -237,7 +248,7 @@ class BlockParameterManageWidget(QWidget):
|
|
|
|
|
pattern = re.compile(r'^(?:[1-9]|[1-9][0-9]|1[0-1][0-9]|12[0-6])$')
|
|
|
|
|
match = pattern.match(address)
|
|
|
|
|
if not match:
|
|
|
|
|
QMessageBox.warning(self, '提示', '请输入1 - 126。')
|
|
|
|
|
QMessageBox.warning(self, '提示', '请输入2 - 126。')
|
|
|
|
|
return
|
|
|
|
|
if self.initUIstat:
|
|
|
|
|
try:
|
|
|
|
@ -320,16 +331,8 @@ class BlockParameterManageWidget(QWidget):
|
|
|
|
|
newAddress = int(self.editAddressWidget.editAddressEdit.text())
|
|
|
|
|
self.blockManage.DPV1Master.editDevAddress(oldAddress, newAddress)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# if self.initUIstat:
|
|
|
|
|
# reply = QMessageBox.question(self.parent(),
|
|
|
|
|
# '警告',
|
|
|
|
|
# "请先连接设备",
|
|
|
|
|
# QMessageBox.Yes)
|
|
|
|
|
# return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def searchAddress(self):
|
|
|
|
|
self.searchAddressWidget = SearchAddressWidget(self.deviceAddressEdit)
|
|
|
|
|