|
|
|
@ -10,7 +10,7 @@ from utils.DBModels.DeviceParModels import *
|
|
|
|
|
from utils import Globals
|
|
|
|
|
from UI.LoadingDataWidget import LoadingDataWidget
|
|
|
|
|
|
|
|
|
|
from model.ProjectModel.BlockManage import BlockManage, BlockType
|
|
|
|
|
from model.ProjectModel.BlockManage import BlockManage, BlockType, TBType
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -61,7 +61,7 @@ class DynamicAddBlock(QHBoxLayout):
|
|
|
|
|
self.buttonlist = []
|
|
|
|
|
self.blockViewlist = []
|
|
|
|
|
self.tbList = ['PressureTranslationBlock', 'TemperatureTranslationBlock', 'LevelTranslationBlock', 'FlowTranslationBlock'] #存放四个转换块
|
|
|
|
|
self.enumList = [BlockType.TB.pressureTB, BlockType.TB.tempTB, BlockType.TB.levelTB, BlockType.TB.flowTB]
|
|
|
|
|
self.enumList = [TBType.pressureTB, TBType.tempTB, TBType.levelTB, TBType.flowTB]
|
|
|
|
|
self.initUI()
|
|
|
|
|
|
|
|
|
|
def initUI(self):
|
|
|
|
@ -150,7 +150,24 @@ class DynamicAddBlock(QHBoxLayout):
|
|
|
|
|
self.parameStackWidget.setCurrentIndex(stackIndex)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def deleteLater(self):
|
|
|
|
|
while self.count():
|
|
|
|
|
item = self.takeAt(0)
|
|
|
|
|
widget = item.widget()
|
|
|
|
|
if widget:
|
|
|
|
|
widget.deleteLater()
|
|
|
|
|
layout = item.layout()
|
|
|
|
|
if layout:
|
|
|
|
|
layout.deleteLater()
|
|
|
|
|
|
|
|
|
|
if self.parameStackWidget:
|
|
|
|
|
while self.parameStackWidget.count():
|
|
|
|
|
widget = self.parameStackWidget.widget(0)
|
|
|
|
|
self.parameStackWidget.removeWidget(widget)
|
|
|
|
|
widget.deleteLater()
|
|
|
|
|
self.parameStackWidget.deleteLater()
|
|
|
|
|
|
|
|
|
|
super().deleteLater()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class BlockParameterManageWidget(QWidget):
|
|
|
|
@ -162,7 +179,7 @@ class BlockParameterManageWidget(QWidget):
|
|
|
|
|
|
|
|
|
|
def initUI(self):
|
|
|
|
|
self.mainlayout = QVBoxLayout()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.settingLayout = QHBoxLayout()
|
|
|
|
|
self.deviceAddressLabel = QLabel('从站地址')
|
|
|
|
|
self.deviceAddressLabel.setObjectName('deviceAddressLabel')
|
|
|
|
@ -203,33 +220,56 @@ 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-5])$')
|
|
|
|
|
match = pattern.match(address)
|
|
|
|
|
if not match:
|
|
|
|
|
QMessageBox.warning(self, '提示', '请输入1 - 125。')
|
|
|
|
|
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-5])$')
|
|
|
|
|
match = pattern.match(address)
|
|
|
|
|
if not match:
|
|
|
|
|
QMessageBox.warning(self, '提示', '请输入1 - 125。')
|
|
|
|
|
return
|
|
|
|
|
if self.initUIstat:
|
|
|
|
|
self.splitter.deleteLater()
|
|
|
|
|
self.widget.deleteLater()
|
|
|
|
|
self.splitter = QSplitter()
|
|
|
|
|
self.blockManage = BlockManage(int(address))
|
|
|
|
|
Globals.setValue('blockManage', self.blockManage)
|
|
|
|
|
blocklist = self.blockManage.getBlockNums()
|
|
|
|
|
self.blockLayout = DynamicAddBlock(blocklist)
|
|
|
|
|
self.settingLayout.addLayout(self.blockLayout, 7)
|
|
|
|
|
self.settingLayout.addWidget(self.splitter, 11)
|
|
|
|
|
self.mainlayout.addWidget(self.blockLayout.parameStackWidget, 20)
|
|
|
|
|
self.initUIstat = False
|
|
|
|
|
else:
|
|
|
|
|
reply = QMessageBox.question(self.parent(),
|
|
|
|
|
'警告',
|
|
|
|
|
"请输入从站地址",
|
|
|
|
|
QMessageBox.Yes)
|
|
|
|
|
return
|
|
|
|
|
if self.initUIstat:
|
|
|
|
|
else:
|
|
|
|
|
reply = QMessageBox.question(self, '确定', '确定更换站地址吗?',
|
|
|
|
|
QMessageBox.Yes | QMessageBox.No, QMessageBox.No)
|
|
|
|
|
if reply == QMessageBox.Yes:
|
|
|
|
|
self.blockLayout.deleteLater()
|
|
|
|
|
self.splitter.deleteLater()
|
|
|
|
|
self.widget.deleteLater()
|
|
|
|
|
self.blockManage = BlockManage(int(address))
|
|
|
|
|
Globals.setValue('blockManage', self.blockManage)
|
|
|
|
|
self.splitter = QSplitter()
|
|
|
|
|
blocklist = self.blockManage.getBlockNums()
|
|
|
|
|
self.blockLayout = DynamicAddBlock(blocklist)
|
|
|
|
|
self.settingLayout.addLayout(self.blockLayout, 7)
|
|
|
|
|
self.settingLayout.addWidget(QSplitter(), 11)
|
|
|
|
|
self.settingLayout.addWidget(self.splitter, 11)
|
|
|
|
|
self.mainlayout.addWidget(self.blockLayout.parameStackWidget, 20)
|
|
|
|
|
self.initUIstat = False
|
|
|
|
|
else:
|
|
|
|
|
reply = QMessageBox.question(self.parent(),
|
|
|
|
|
'警告',
|
|
|
|
|
"请输入从站地址",
|
|
|
|
|
QMessageBox.Yes)
|
|
|
|
|
return
|
|
|
|
|
else:
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
def refreshData(self):
|
|
|
|
|
if self.initUIstat:
|
|
|
|
|
reply = QMessageBox.question(self.parent(),
|
|
|
|
|
'警告',
|
|
|
|
|
"请先连接设备",
|
|
|
|
|
QMessageBox.Yes)
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
self.loadingDataWidget = LoadingDataWidget()
|
|
|
|
|
self.loadingDataWidget.loadData()
|
|
|
|
|
blockView = self.blockLayout.parameStackWidget.currentWidget()
|
|
|
|
@ -237,8 +277,8 @@ class BlockParameterManageWidget(QWidget):
|
|
|
|
|
model = blockView.model
|
|
|
|
|
model.updateColumn(5, '查询中sdadadsda\r\nsdasdsasasad\r\nasdsadsad...')
|
|
|
|
|
blockName = blockView.blockType
|
|
|
|
|
blcoknumber = blockView.blcoknumber + 1
|
|
|
|
|
print(blockName, blcoknumber)
|
|
|
|
|
blcokIndex = blockView.blcokIndex
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|