|
|
@ -27,7 +27,7 @@ class AreaTabWidget(QMainWindow):
|
|
|
|
widgetList[1].setCurrentIndex(order)
|
|
|
|
widgetList[1].setCurrentIndex(order)
|
|
|
|
widgetList[2].setText(channelBytes)
|
|
|
|
widgetList[2].setText(channelBytes)
|
|
|
|
|
|
|
|
|
|
|
|
self.addAreaWidget(widgetList)
|
|
|
|
self.addAreaWidget(widgetList, loacl = False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def addAreaTab(self):
|
|
|
|
def addAreaTab(self):
|
|
|
@ -89,17 +89,18 @@ class AreaTabWidget(QMainWindow):
|
|
|
|
|
|
|
|
|
|
|
|
if index != -1:
|
|
|
|
if index != -1:
|
|
|
|
self.areaTabWidget.removeTab(index)
|
|
|
|
self.areaTabWidget.removeTab(index)
|
|
|
|
|
|
|
|
del self.widgetList[index]
|
|
|
|
Device.delAreas(deviceName, index)
|
|
|
|
Device.delAreas(deviceName, index)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def addAreaWidget(self, widgetList):
|
|
|
|
def addAreaWidget(self, widgetList, loacl = True):
|
|
|
|
dataType = widgetList[0].currentText()
|
|
|
|
dataType = widgetList[0].currentText()
|
|
|
|
order = self.dataTypeTranslate(widgetList[1].currentText())
|
|
|
|
order = self.dataTypeTranslate(widgetList[1].currentText())
|
|
|
|
byteLineEdit = widgetList[2].text()
|
|
|
|
byteLineEdit = widgetList[2].text()
|
|
|
|
areaLayout = widgetList[3]
|
|
|
|
areaLayout = widgetList[3]
|
|
|
|
deviceName = self.areaTabWidget.parent().parent().parent().parent().parent().windowTitle()
|
|
|
|
deviceName = self.areaTabWidget.parent().parent().parent().parent().parent().windowTitle()
|
|
|
|
|
|
|
|
widgetList = []
|
|
|
|
|
|
|
|
|
|
|
|
while areaLayout.count():
|
|
|
|
while areaLayout.count():
|
|
|
|
item = areaLayout.takeAt(0)
|
|
|
|
item = areaLayout.takeAt(0)
|
|
|
@ -112,72 +113,88 @@ class AreaTabWidget(QMainWindow):
|
|
|
|
QMessageBox.warning(self, '警告', '请输入字节长度。')
|
|
|
|
QMessageBox.warning(self, '警告', '请输入字节长度。')
|
|
|
|
|
|
|
|
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
# for i in range(3):
|
|
|
|
|
|
|
|
# widgetList[i].setEnabled(False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if dataType in ['AI', 'AO']:
|
|
|
|
if dataType in ['AI', 'AO']:
|
|
|
|
|
|
|
|
|
|
|
|
areaLabel = QLabel(dataType + str(1) + ": " + byteLineEdit + 'Byte' )
|
|
|
|
areaLabel = QLabel(dataType + str(1) + ": " + byteLineEdit + 'Byte' )
|
|
|
|
areaLabel2 =QLabel('0')
|
|
|
|
areaLabel2 =QLabel('0')
|
|
|
|
areaLineEdit = QLineEdit('0')
|
|
|
|
|
|
|
|
editbtn = QPushButton('强制')
|
|
|
|
if '主站' in deviceName and dataType == 'AI' or ('从站' in deviceName and dataType == 'AO'):
|
|
|
|
|
|
|
|
areaLayout.addWidget(areaLabel, 0, 0)
|
|
|
|
areaLayout.addWidget(areaLabel, 0, 0)
|
|
|
|
areaLayout.addWidget(areaLabel2, 0, 1)
|
|
|
|
areaLayout.addWidget(areaLabel2, 0, 1 )
|
|
|
|
areaLayout.addItem(self.horizontalSpacer, 0, 4)
|
|
|
|
areaLayout.addWidget(areaLineEdit, 0, 2 )
|
|
|
|
self.widgetList.append([areaLabel2, areaLayout])
|
|
|
|
areaLayout.addWidget(editbtn, 0, 3)
|
|
|
|
elif '主站' in deviceName and dataType == 'AO' or ('从站' in deviceName and dataType == 'AI'):
|
|
|
|
areaLayout.addItem(self.horizontalSpacer, 0, 4)
|
|
|
|
areaLineEdit = QLineEdit('0')
|
|
|
|
editbtn.clicked.connect(lambda checked, btn=editbtn: self.wirteValue(btn))
|
|
|
|
editbtn = QPushButton('强制')
|
|
|
|
self.widgetList.append([areaLabel2, areaLineEdit, editbtn, areaLayout])
|
|
|
|
areaLayout.addWidget(areaLabel, 0, 0)
|
|
|
|
# else:
|
|
|
|
areaLayout.addWidget(areaLabel2, 0, 1 )
|
|
|
|
# areaLabel = QLabel(dataType + str(i + 1) + ": " + byteLineEdit + 'Byte')
|
|
|
|
areaLayout.addWidget(areaLineEdit, 0, 2 )
|
|
|
|
# areaLabel2 = QLabel('0')
|
|
|
|
areaLayout.addWidget(editbtn, 0, 3)
|
|
|
|
# areaLineEdit = QLineEdit('0')
|
|
|
|
areaLayout.addItem(self.horizontalSpacer, 0, 4)
|
|
|
|
# editbtn = QPushButton('强制')
|
|
|
|
editbtn.clicked.connect(lambda checked, btn=editbtn: self.wirteValue(btn))
|
|
|
|
#
|
|
|
|
self.widgetList.append([areaLabel2, areaLineEdit, editbtn, areaLayout])
|
|
|
|
# areaLayout.addWidget(areaLabel, i // 2, i % 2 + 4)
|
|
|
|
|
|
|
|
# areaLayout.addWidget(areaLabel2, i // 2, i % 2 + 6)
|
|
|
|
|
|
|
|
# areaLayout.addWidget(areaLineEdit, i // 2, i % 2 + 6)
|
|
|
|
|
|
|
|
# areaLayout.addWidget(editbtn, i // 2, i % 2 + 7)
|
|
|
|
|
|
|
|
# editbtn.clicked.connect(lambda checked, btn=editbtn: self.forceEdit(btn))
|
|
|
|
|
|
|
|
# self.widgetList.append([areaLabel2, areaLineEdit, editbtn])
|
|
|
|
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
channelNumber = int(byteLineEdit) * 8
|
|
|
|
channelNumber = int(byteLineEdit) * 8
|
|
|
|
for i in range(int(channelNumber)):
|
|
|
|
if '主站' in deviceName and dataType == 'DI' or (
|
|
|
|
if i % 2 == 0:
|
|
|
|
'从站' in deviceName and dataType == 'DO'):
|
|
|
|
areaLabel = QLabel(dataType + str(i + 1 ) + ": " + byteLineEdit + 'Byte' )
|
|
|
|
for i in range(int(channelNumber)):
|
|
|
|
areaLabel2 =QLabel('0')
|
|
|
|
if i % 2 == 0:
|
|
|
|
areaLineEdit = QLineEdit('0')
|
|
|
|
areaLabel = QLabel(dataType + str(i + 1) + ": " + byteLineEdit + 'Byte')
|
|
|
|
editbtn = QPushButton('强制')
|
|
|
|
areaLabel2 = QLabel('0')
|
|
|
|
|
|
|
|
areaLayout.addWidget(areaLabel, i // 2, i % 2)
|
|
|
|
areaLayout.addWidget(areaLabel, i//2, i % 2)
|
|
|
|
areaLayout.addWidget(areaLabel2, i // 2, i % 2 + 1)
|
|
|
|
areaLayout.addWidget(areaLabel2, i//2, i % 2 + 1 )
|
|
|
|
widgetList.append([areaLabel2, areaLayout])
|
|
|
|
areaLayout.addWidget(areaLineEdit, i//2, i % 2 + 2 )
|
|
|
|
|
|
|
|
areaLayout.addWidget(editbtn, i // 2, i % 2 + 3)
|
|
|
|
else:
|
|
|
|
editbtn.clicked.connect(lambda checked, btn=editbtn: self.wirteValue(btn))
|
|
|
|
areaLabel = QLabel(dataType + str(i + 1) + ": " + byteLineEdit + 'Byte')
|
|
|
|
self.widgetList.append([areaLabel2, areaLineEdit, editbtn])
|
|
|
|
areaLabel2 = QLabel('0')
|
|
|
|
else:
|
|
|
|
areaLayout.addWidget(areaLabel, i // 2, i % 2 + 2)
|
|
|
|
areaLabel = QLabel(dataType + str(i + 1) + ": " + byteLineEdit + 'Byte')
|
|
|
|
areaLayout.addWidget(areaLabel2, i // 2, i % 2 + 3)
|
|
|
|
areaLabel2 = QLabel('0')
|
|
|
|
widgetList.append([areaLabel2, areaLayout])
|
|
|
|
areaLineEdit = QLineEdit('0')
|
|
|
|
self.widgetList.append(widgetList)
|
|
|
|
editbtn = QPushButton('强制')
|
|
|
|
if '主站' in deviceName and dataType == 'DO' or (
|
|
|
|
|
|
|
|
'从站' in deviceName and dataType == 'DI'):
|
|
|
|
areaLayout.addWidget(areaLabel, i // 2, i % 2 + 4)
|
|
|
|
for i in range(int(channelNumber)):
|
|
|
|
areaLayout.addWidget(areaLabel2, i // 2, i % 2 + 5)
|
|
|
|
if i % 2 == 0:
|
|
|
|
areaLayout.addWidget(areaLineEdit, i // 2, i % 2 + 6)
|
|
|
|
areaLabel = QLabel(dataType + str(i + 1) + ": " + byteLineEdit + 'Byte')
|
|
|
|
areaLayout.addWidget(editbtn, i // 2, i % 2 + 7)
|
|
|
|
areaLabel2 = QLabel('0')
|
|
|
|
editbtn.clicked.connect(lambda checked, btn=editbtn: self.wirteValue(btn))
|
|
|
|
areaLineEdit = QLineEdit('0')
|
|
|
|
|
|
|
|
editbtn = QPushButton('强制')
|
|
|
|
self.widgetList.append([areaLabel2, areaLineEdit, editbtn])
|
|
|
|
|
|
|
|
|
|
|
|
areaLayout.addWidget(areaLabel, i // 2, i % 2)
|
|
|
|
|
|
|
|
areaLayout.addWidget(areaLabel2, i // 2, i % 2 + 1)
|
|
|
|
|
|
|
|
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])
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
areaLabel = QLabel(dataType + str(i + 1) + ": " + byteLineEdit + 'Byte')
|
|
|
|
|
|
|
|
areaLabel2 = QLabel('0')
|
|
|
|
|
|
|
|
areaLineEdit = QLineEdit('0')
|
|
|
|
|
|
|
|
editbtn = QPushButton('强制')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
areaLayout.addWidget(areaLabel, i // 2, i % 2 + 4)
|
|
|
|
|
|
|
|
areaLayout.addWidget(areaLabel2, i // 2, i % 2 + 5)
|
|
|
|
|
|
|
|
areaLayout.addWidget(areaLineEdit, i // 2, i % 2 + 6)
|
|
|
|
|
|
|
|
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)
|
|
|
|
areaLayout.addItem(self.verticalSpacer, int(byteLineEdit) * 8 ,0)
|
|
|
|
areaLayout.addItem(self.verticalSpacer, int(byteLineEdit) * 8 ,0)
|
|
|
|
|
|
|
|
|
|
|
|
index = self.areaTabWidget.currentIndex() + 1
|
|
|
|
index = self.areaTabWidget.currentIndex() + 1
|
|
|
|
areaId = DevicesManange.getAreaID(deviceName)
|
|
|
|
areaId = DevicesManange.getAreaID(deviceName)
|
|
|
|
|
|
|
|
if areaId is not None and index in areaId:
|
|
|
|
|
|
|
|
if loacl:
|
|
|
|
|
|
|
|
print(index)
|
|
|
|
|
|
|
|
del self.widgetList[index - 1]
|
|
|
|
|
|
|
|
DevicesManange.updataAreas(dataType, order, byteLineEdit, deviceName, index)
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
DevicesManange.addAreas(dataType, order, byteLineEdit, deviceName)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if index in areaId:
|
|
|
|
|
|
|
|
DevicesManange.updataAreas(dataType, order, byteLineEdit, deviceName, index)
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
DevicesManange.addAreas(dataType, order, byteLineEdit, deviceName)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -188,9 +205,12 @@ class AreaTabWidget(QMainWindow):
|
|
|
|
def wirteValue(self, editBtn):
|
|
|
|
def wirteValue(self, editBtn):
|
|
|
|
deviceName = self.areaTabWidget.parent().parent().parent().parent().parent().windowTitle()
|
|
|
|
deviceName = self.areaTabWidget.parent().parent().parent().parent().parent().windowTitle()
|
|
|
|
index = self.areaTabWidget.currentIndex()
|
|
|
|
index = self.areaTabWidget.currentIndex()
|
|
|
|
|
|
|
|
tabwidget = self.areaTabWidget.currentWidget()
|
|
|
|
|
|
|
|
|
|
|
|
for widget in self.widgetList:
|
|
|
|
for widget in self.widgetList:
|
|
|
|
if editBtn in widget:
|
|
|
|
if editBtn in widget:
|
|
|
|
value = widget[1].text()
|
|
|
|
value = widget[1].text()
|
|
|
|
|
|
|
|
|
|
|
|
print(deviceName, index, value)
|
|
|
|
print(deviceName, index, value)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -198,6 +218,7 @@ class AreaTabWidget(QMainWindow):
|
|
|
|
deviceList = []
|
|
|
|
deviceList = []
|
|
|
|
areaIdList = []
|
|
|
|
areaIdList = []
|
|
|
|
devices = DevicesManange.getAllDevice()
|
|
|
|
devices = DevicesManange.getAllDevice()
|
|
|
|
|
|
|
|
|
|
|
|
for device in devices:
|
|
|
|
for device in devices:
|
|
|
|
deviceName = device[0]
|
|
|
|
deviceName = device[0]
|
|
|
|
areas = device[3]
|
|
|
|
areas = device[3]
|
|
|
@ -207,7 +228,20 @@ class AreaTabWidget(QMainWindow):
|
|
|
|
areaId = area["id"]
|
|
|
|
areaId = area["id"]
|
|
|
|
areaIdList.append(areaId)
|
|
|
|
areaIdList.append(areaId)
|
|
|
|
deviceList.append([deviceName, areaIdList])
|
|
|
|
deviceList.append([deviceName, areaIdList])
|
|
|
|
print(deviceList)
|
|
|
|
index = self.areaTabWidget.currentIndex()
|
|
|
|
|
|
|
|
print(self.widgetList,'fff')
|
|
|
|
|
|
|
|
if len(self.widgetList) > 0:
|
|
|
|
|
|
|
|
if isinstance(self.widgetList[index][0], list):
|
|
|
|
|
|
|
|
widgetLists = self.widgetList[index]
|
|
|
|
|
|
|
|
for widgetList in widgetLists:
|
|
|
|
|
|
|
|
widgetList[0].setText('bbb')
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
widgetLists = self.widgetList[index]
|
|
|
|
|
|
|
|
print(widgetLists)
|
|
|
|
|
|
|
|
widgetLists[0].setText('aaa')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
if __name__ == '__main__':
|
|
|
|
app = QApplication(sys.argv)
|
|
|
|
app = QApplication(sys.argv)
|
|
|
|