|
|
|
@ -88,22 +88,34 @@ class AreaTabWidget(QMainWindow):
|
|
|
|
|
deviceName = self.areaTabWidget.parent().parent().parent().parent().parent().windowTitle()
|
|
|
|
|
index = self.areaTabWidget.currentIndex()
|
|
|
|
|
|
|
|
|
|
alldevices = DevicesManange.getAllDevice()
|
|
|
|
|
for device in alldevices:
|
|
|
|
|
if deviceName in device:
|
|
|
|
|
areas = device[3]
|
|
|
|
|
if areas is not None:
|
|
|
|
|
areas = json.loads(areas)
|
|
|
|
|
area = areas[index]
|
|
|
|
|
type = area["type"]
|
|
|
|
|
print(area, type,'ssss')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if index != -1:
|
|
|
|
|
self.areaTabWidget.removeTab(index)
|
|
|
|
|
del self.widgetList[index]
|
|
|
|
|
Device.delAreas(deviceName, index)
|
|
|
|
|
self.mainwindow.devicesManange.getDevice(deviceName).delArea(index)
|
|
|
|
|
self.mainwindow.devicesManange.getDevice(deviceName).delArea(index, type)
|
|
|
|
|
self.mainwindow.devicesManange.recalculateAddress()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def addAreaWidget(self, widgetList, loacl = True, init = False):
|
|
|
|
|
dataType = widgetList[0].currentText()
|
|
|
|
|
print(widgetList)
|
|
|
|
|
order = self.dataTypeTranslate(widgetList[1].currentText())
|
|
|
|
|
byteLineEdit = widgetList[2].text()
|
|
|
|
|
areaLayout = widgetList[3]
|
|
|
|
|
deviceName = self.areaTabWidget.parent().parent().parent().parent().parent().windowTitle()
|
|
|
|
|
widgetList = []
|
|
|
|
|
widgetLists = []
|
|
|
|
|
|
|
|
|
|
while areaLayout.count():
|
|
|
|
|
item = areaLayout.takeAt(0)
|
|
|
|
@ -116,7 +128,7 @@ class AreaTabWidget(QMainWindow):
|
|
|
|
|
QMessageBox.warning(self, '警告', '请输入字节长度。')
|
|
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
|
|
widgetList[0].setEnabled(False)
|
|
|
|
|
if dataType in ['AI', 'AO']:
|
|
|
|
|
areaLabel = QLabel(dataType + str(1) + ": " + byteLineEdit + 'Byte' )
|
|
|
|
|
areaLabel2 =QLabel('0')
|
|
|
|
@ -125,7 +137,8 @@ class AreaTabWidget(QMainWindow):
|
|
|
|
|
areaLayout.addWidget(areaLabel, 0, 0)
|
|
|
|
|
areaLayout.addWidget(areaLabel2, 0, 1)
|
|
|
|
|
areaLayout.addItem(self.horizontalSpacer, 0, 4)
|
|
|
|
|
self.widgetList.append([areaLabel2, areaLayout])
|
|
|
|
|
widgetLists.append([areaLabel2, areaLayout])
|
|
|
|
|
|
|
|
|
|
elif '主站' in deviceName and dataType == 'AO' or ('从站' in deviceName and dataType == 'AI'):
|
|
|
|
|
areaLineEdit = QLineEdit('0')
|
|
|
|
|
editbtn = QPushButton('强制')
|
|
|
|
@ -135,7 +148,8 @@ class AreaTabWidget(QMainWindow):
|
|
|
|
|
areaLayout.addWidget(editbtn, 0, 3)
|
|
|
|
|
areaLayout.addItem(self.horizontalSpacer, 0, 4)
|
|
|
|
|
editbtn.clicked.connect(lambda checked, btn=editbtn: self.wirteValue(btn))
|
|
|
|
|
self.widgetList.append([areaLabel2, areaLineEdit, editbtn, areaLayout])
|
|
|
|
|
widgetLists.append([areaLabel2, areaLineEdit, editbtn, areaLayout])
|
|
|
|
|
self.widgetList.append(widgetLists)
|
|
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
channelNumber = int(byteLineEdit) * 8
|
|
|
|
@ -147,15 +161,15 @@ class AreaTabWidget(QMainWindow):
|
|
|
|
|
areaLabel2 = QLabel('0')
|
|
|
|
|
areaLayout.addWidget(areaLabel, i // 2, i % 2)
|
|
|
|
|
areaLayout.addWidget(areaLabel2, i // 2, i % 2 + 1)
|
|
|
|
|
widgetList.append([areaLabel2, areaLayout])
|
|
|
|
|
widgetLists.append([areaLabel2, areaLayout])
|
|
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
areaLabel = QLabel(dataType + str(i + 1) + ": " + byteLineEdit + 'Byte')
|
|
|
|
|
areaLabel2 = QLabel('0')
|
|
|
|
|
areaLayout.addWidget(areaLabel, i // 2, i % 2 + 2)
|
|
|
|
|
areaLayout.addWidget(areaLabel2, i // 2, i % 2 + 3)
|
|
|
|
|
widgetList.append([areaLabel2, areaLayout])
|
|
|
|
|
self.widgetList.append(widgetList)
|
|
|
|
|
widgetLists.append([areaLabel2, areaLayout])
|
|
|
|
|
self.widgetList.append(widgetLists)
|
|
|
|
|
if '主站' in deviceName and dataType == 'DO' or (
|
|
|
|
|
'从站' in deviceName and dataType == 'DI'):
|
|
|
|
|
for i in range(int(channelNumber)):
|
|
|
|
@ -170,7 +184,7 @@ class AreaTabWidget(QMainWindow):
|
|
|
|
|
areaLayout.addWidget(areaLineEdit, i // 2, i % 2 + 2)
|
|
|
|
|
areaLayout.addWidget(editbtn, i // 2, i % 2 + 3)
|
|
|
|
|
editbtn.clicked.connect(lambda checked, btn=editbtn: self.wirteValue(btn))
|
|
|
|
|
widgetList.append([areaLabel2, areaLineEdit, editbtn])
|
|
|
|
|
widgetLists.append([areaLabel2, areaLineEdit, editbtn])
|
|
|
|
|
else:
|
|
|
|
|
areaLabel = QLabel(dataType + str(i + 1) + ": " + byteLineEdit + 'Byte')
|
|
|
|
|
areaLabel2 = QLabel('0')
|
|
|
|
@ -183,15 +197,15 @@ class AreaTabWidget(QMainWindow):
|
|
|
|
|
areaLayout.addWidget(editbtn, i // 2, i % 2 + 7)
|
|
|
|
|
editbtn.clicked.connect(lambda checked, btn=editbtn: self.wirteValue(btn))
|
|
|
|
|
|
|
|
|
|
widgetList.append([areaLabel2, areaLineEdit, editbtn])
|
|
|
|
|
self.widgetList.append(widgetList)
|
|
|
|
|
widgetLists.append([areaLabel2, areaLineEdit, editbtn])
|
|
|
|
|
self.widgetList.append(widgetLists)
|
|
|
|
|
areaLayout.addItem(self.verticalSpacer, int(byteLineEdit) * 8 ,0)
|
|
|
|
|
|
|
|
|
|
index = self.areaTabWidget.currentIndex() + 1
|
|
|
|
|
areaId = DevicesManange.getAreaID(deviceName)
|
|
|
|
|
if areaId is not None and index in areaId:
|
|
|
|
|
if loacl:
|
|
|
|
|
print(index)
|
|
|
|
|
|
|
|
|
|
del self.widgetList[index - 1]
|
|
|
|
|
if init:
|
|
|
|
|
return
|
|
|
|
@ -214,13 +228,16 @@ class AreaTabWidget(QMainWindow):
|
|
|
|
|
def wirteValue(self, editBtn):
|
|
|
|
|
deviceName = self.areaTabWidget.parent().parent().parent().parent().parent().windowTitle()
|
|
|
|
|
index = self.areaTabWidget.currentIndex()
|
|
|
|
|
tabwidget = self.areaTabWidget.currentWidget()
|
|
|
|
|
valueList = []
|
|
|
|
|
|
|
|
|
|
if len(self.widgetList) > 0:
|
|
|
|
|
for widgetLists in self.widgetList:
|
|
|
|
|
for widgetList in widgetLists:
|
|
|
|
|
if isinstance(widgetList[1], QLineEdit):
|
|
|
|
|
valueList.append(int(widgetList[1].text()))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for widget in self.widgetList:
|
|
|
|
|
if editBtn in widget:
|
|
|
|
|
value = widget[1].text()
|
|
|
|
|
|
|
|
|
|
print(deviceName, index, value)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def readValue(self):
|
|
|
|
@ -238,18 +255,15 @@ class AreaTabWidget(QMainWindow):
|
|
|
|
|
areaIdList.append(areaId)
|
|
|
|
|
deviceList.append([deviceName, areaIdList])
|
|
|
|
|
index = self.areaTabWidget.currentIndex()
|
|
|
|
|
print(self.widgetList,'fff')
|
|
|
|
|
i = 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if len(self.widgetList) > 0:
|
|
|
|
|
if isinstance(self.widgetList[index][0], list):
|
|
|
|
|
widgetLists = self.widgetList[index]
|
|
|
|
|
for widgetList in widgetLists:
|
|
|
|
|
widgetList[0].setText(str(i))
|
|
|
|
|
i += 1
|
|
|
|
|
else:
|
|
|
|
|
widgetLists = self.widgetList[index]
|
|
|
|
|
widgetList[0].setText('AAA')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
widgetLists[0].setText('aaa')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|