|
|
|
@ -21,8 +21,8 @@ class AreaTabWidget(QMainWindow):
|
|
|
|
|
# 设置主窗口的中心部分为 QTabWidget
|
|
|
|
|
self.setCentralWidget(self.areaTabWidget)
|
|
|
|
|
|
|
|
|
|
def initAreaTab(self, dataType, order, channelBytes, deviceName = False):
|
|
|
|
|
widgetList = self.addAreaTab(deviceName)
|
|
|
|
|
def initAreaTab(self, dataType, order, channelBytes):
|
|
|
|
|
widgetList = self.addAreaTab()
|
|
|
|
|
widgetList[0].setCurrentIndex(dataType)
|
|
|
|
|
widgetList[1].setCurrentIndex(order)
|
|
|
|
|
widgetList[2].setText(channelBytes)
|
|
|
|
@ -30,7 +30,7 @@ class AreaTabWidget(QMainWindow):
|
|
|
|
|
self.addAreaWidget(widgetList)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def addAreaTab(self, deviceName):
|
|
|
|
|
def addAreaTab(self):
|
|
|
|
|
areaTabWidget = QWidget()
|
|
|
|
|
|
|
|
|
|
tabIndex = self.areaTabWidget.count()
|
|
|
|
@ -78,16 +78,15 @@ class AreaTabWidget(QMainWindow):
|
|
|
|
|
|
|
|
|
|
delAreaBtn.clicked.connect(self.removeAreaTab)
|
|
|
|
|
|
|
|
|
|
widgetList.extend([dataTypeCombox, orderCombox, byteLineEdit, areaLayout, deviceName])
|
|
|
|
|
widgetList.extend([dataTypeCombox, orderCombox, byteLineEdit, areaLayout])
|
|
|
|
|
areaTabWidget.setLayout(mainLayout)
|
|
|
|
|
|
|
|
|
|
return widgetList
|
|
|
|
|
|
|
|
|
|
def removeAreaTab(self):
|
|
|
|
|
# 获取 QTabWidget 并从中删除标签页
|
|
|
|
|
deviceName = self.areaTabWidget.parent().parent().parent().parent().parent().windowTitle()
|
|
|
|
|
index = self.areaTabWidget.currentIndex()
|
|
|
|
|
print(index)
|
|
|
|
|
|
|
|
|
|
if index != -1:
|
|
|
|
|
self.areaTabWidget.removeTab(index)
|
|
|
|
|
|
|
|
|
@ -100,16 +99,21 @@ class AreaTabWidget(QMainWindow):
|
|
|
|
|
order = self.dataTypeTranslate(widgetList[1].currentText())
|
|
|
|
|
byteLineEdit = widgetList[2].text()
|
|
|
|
|
areaLayout = widgetList[3]
|
|
|
|
|
deviceName = widgetList[4]
|
|
|
|
|
deviceName = self.areaTabWidget.parent().parent().parent().parent().parent().windowTitle()
|
|
|
|
|
|
|
|
|
|
while areaLayout.count():
|
|
|
|
|
item = areaLayout.takeAt(0)
|
|
|
|
|
widget = item.widget()
|
|
|
|
|
if widget:
|
|
|
|
|
widget.setParent(None)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if len(byteLineEdit) == 0:
|
|
|
|
|
QMessageBox.warning(self, '警告', '请输入字节长度。')
|
|
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
for i in range(3):
|
|
|
|
|
widgetList[i].setEnabled(False)
|
|
|
|
|
# for i in range(3):
|
|
|
|
|
# widgetList[i].setEnabled(False)
|
|
|
|
|
|
|
|
|
|
if dataType in ['AI', 'AO']:
|
|
|
|
|
|
|
|
|
@ -166,8 +170,16 @@ class AreaTabWidget(QMainWindow):
|
|
|
|
|
|
|
|
|
|
self.widgetList.append([areaLabel2, areaLineEdit, editbtn])
|
|
|
|
|
areaLayout.addItem(self.verticalSpacer, int(byteLineEdit) * 8 ,0)
|
|
|
|
|
if deviceName:
|
|
|
|
|
DevicesManange.addAreas(dataType, order, byteLineEdit, deviceName)
|
|
|
|
|
|
|
|
|
|
index = self.areaTabWidget.currentIndex() + 1
|
|
|
|
|
areaId = DevicesManange.getAreaID(deviceName)
|
|
|
|
|
|
|
|
|
|
if index in areaId:
|
|
|
|
|
DevicesManange.updataAreas(dataType, order, byteLineEdit, deviceName, index)
|
|
|
|
|
else:
|
|
|
|
|
DevicesManange.addAreas(dataType, order, byteLineEdit, deviceName)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def dataTypeTranslate(self, order):
|
|
|
|
|
self.dataTypeDict = {'不转换': 'ABCD', '字节转换': 'DCBA', '字转换': 'CDAB', '字内转换': 'BADC'}
|
|
|
|
|