From f08f3fce2d4e5cd86349e47057505f95fa061398 Mon Sep 17 00:00:00 2001 From: zhangxuxutm <951937200@qq.com> Date: Mon, 11 Sep 2023 14:40:21 +0800 Subject: [PATCH] 0911b --- UI/AreaTabWidget.py | 68 +++++++++++------- UI/MainWindow.py | 6 +- model/ProjectModel/DeviceManage.py | 4 +- .../__pycache__/AreaManage.cpython-310.pyc | Bin 3239 -> 721 bytes 4 files changed, 45 insertions(+), 33 deletions(-) diff --git a/UI/AreaTabWidget.py b/UI/AreaTabWidget.py index 9171781..5c3771a 100644 --- a/UI/AreaTabWidget.py +++ b/UI/AreaTabWidget.py @@ -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] + widgetLists = self.widgetList[index] + for widgetList in widgetLists: + widgetList[0].setText('AAA') + - widgetLists[0].setText('aaa') diff --git a/UI/MainWindow.py b/UI/MainWindow.py index 74d0faf..7defaac 100644 --- a/UI/MainWindow.py +++ b/UI/MainWindow.py @@ -136,9 +136,9 @@ class MainWindow(QMainWindow): def startProtocol(self): - for subWindow in self.subWindows: - areaTabWidget = subWindow.widget().widget().centralWidget() - areaTabWidget.readValue() + for subWindow in self.subWindows: + areaTabWidget = subWindow.widget().widget().centralWidget() + areaTabWidget.readValue() def tran(self, dataType, order): if dataType == 'AI': diff --git a/model/ProjectModel/DeviceManage.py b/model/ProjectModel/DeviceManage.py index 1b2e121..abe2707 100644 --- a/model/ProjectModel/DeviceManage.py +++ b/model/ProjectModel/DeviceManage.py @@ -66,13 +66,11 @@ class Device(): self.outputEndAddress = endAddress - def editArea(self, index, type, order, bytes): + def editArea(self, index, order, bytes): if type in ["DI", "AI"]: - self.inputAreas[index].type = type self.inputAreas[index].order = order self.inputAreas[index].bytes = bytes elif type in ["AO", "DO"]: - self.outputAreas[index].type = type self.outputAreas[index].order = order self.outputAreas[index].bytes = bytes # self.recalculateAddress() diff --git a/model/ProjectModel/__pycache__/AreaManage.cpython-310.pyc b/model/ProjectModel/__pycache__/AreaManage.cpython-310.pyc index 63a9577c800e984a414eb22d01506951dd23ec96..79ddb3d3d0bfd67bd6b37222e5613b070de4c366 100644 GIT binary patch literal 721 zcmYjP!EV$r5VaF0&2F;-aX>;`dR+yX(y900{Qa&5C4P_`sti~@xeI;=oA!397{xp z6I0y#9`)e#q+b(Cu#5RJs6!fJ^a^ppgB!$y4<0?>c!{RrExdykQ*1}8ax*Wq5el3r z6PHyfvb1#Jeeu9K2IwcC1ad{8Af`Tm00Ka`M)15xBkpr@gXpL)68)r_tGUk%in6DbbkG=Xx3NVRhPeMM5d}sarE?P zzI?gLe|`OU`}teGQSEtk*6F-%xsds(YA-}-=Dp+EnHNp57RhF7BgU$xGK@WRT{xZu zUr$_4vWrZ|E~_bO!I&L025)xK*)e19yF&hp#M%_foN%s$)^;o!zO#d~tr6N1v)u@L zSPU7jD{XAhDlU{7?P%T+R*}1NQ@IDw_d!L_+T9o9K01voxzKH656f0cAX&AID^=Bk zK7uir7VZ;Zo_0D}%}$49D@W8m?o1_hlBNA%!06XMILiHVeTBWA`gOR*Z1jAX!V9-R Q9fOKc9q#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