From bb15b38860b5523bf741247a8f44f342ad8b428f Mon Sep 17 00:00:00 2001 From: "ADMINISTRATOR\\Administrator" <951937200@qq.com> Date: Sat, 16 Mar 2024 18:11:29 +0800 Subject: [PATCH] =?UTF-8?q?0316=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Static/Area.qss | 50 ++++++++++++++++++++++++++++++++-- UI/AreaTabWidget.py | 3 +- UI/MainWindow.py | 1 + UI/RightAreaWidget.py | 7 +++-- protocol/ModBus/TCPMaster.py | 1 - utils/DBModels/DeviceModels.py | 4 +-- 6 files changed, 57 insertions(+), 9 deletions(-) diff --git a/Static/Area.qss b/Static/Area.qss index 0d6d4a5..d9d5961 100644 --- a/Static/Area.qss +++ b/Static/Area.qss @@ -21,7 +21,7 @@ QPushButton#okBtn:hover, QPushButton#delAreaBtn:hover { } -QPushButton#wirteDIDOforceBtn { +QPushButton#wirteDIDOforceBtn{ font-size: 16px; @@ -33,8 +33,19 @@ QPushButton#wirteDIDOforceBtn { padding-bottom: 5px; + border: 1px solid black; + + border-radius: 5px; + } +QPushButton#wirteDIDOforceBtn:hover{ + + font: bold; + +} + + QPushButton#forceBtn { font-size: 22px; @@ -47,6 +58,20 @@ QPushButton#forceBtn { padding-bottom: 5px; + border: 1px solid black; + + border-radius: 5px; + +/* background-color: #328ffc;*/ + + +} + +QPushButton#forceBtn:hover{ + + + font: bold; + } @@ -163,6 +188,14 @@ QLineEdit#byteLineEdit{ font-size: 20px; + border-top: none; + + border-left: none; + + border-right: none; + + border-bottom: 2px solid gary; + } @@ -182,6 +215,13 @@ QLineEdit#wirteDIDOareaLineEdit { font-size: 16px; + border-top: none; + + border-left: none; + + border-right: none; + + border-bottom: 2px solid gary; } @@ -196,7 +236,7 @@ QLineEdit#areaLineEdit { border-right: none; - border-bottom: 1px solid gary; + border-bottom: 2px solid gary; } @@ -205,7 +245,11 @@ QLineEdit#areaLineEdit { QComboBox#dataTypeCombox, QComboBox#orderCombox{ - font-size: 20px; + font-size: 20px; + +/* border: 1px solid black;*/ + +/* border-radius: 5px;*/ } diff --git a/UI/AreaTabWidget.py b/UI/AreaTabWidget.py index 24c83f0..a513aa8 100644 --- a/UI/AreaTabWidget.py +++ b/UI/AreaTabWidget.py @@ -9,7 +9,8 @@ from PyQt5.QtWidgets import QApplication, QMainWindow, QTabWidget, QWidget, QVBo QHBoxLayout, QComboBox, QLineEdit, QSpacerItem, QSizePolicy, QGridLayout, QMessageBox, QSplitter, QFrame from PyQt5.QtGui import QIcon -from PyQt5.QtCore import QSize +from PyQt5.QtCore import QSize, Qt + from model.ProjectModel.DeviceManage import Device, DevicesManange from UI.RightAreaWidget import RightAreaWidgets diff --git a/UI/MainWindow.py b/UI/MainWindow.py index 7b45eef..4b1efb7 100644 --- a/UI/MainWindow.py +++ b/UI/MainWindow.py @@ -119,6 +119,7 @@ class MainWindow(QWidget): def startProtocol(self): if self.startProtocolBtn.isChecked(): + self.devicesManange.connect() self.startProtocolBtn.setText('停止通讯') self.startProtocolBtn.setIcon(QIcon('Static/pause.png')) self.startProtocolBtn.setIconSize(QSize(22, 22)) diff --git a/UI/RightAreaWidget.py b/UI/RightAreaWidget.py index e645a87..af8e5ae 100644 --- a/UI/RightAreaWidget.py +++ b/UI/RightAreaWidget.py @@ -1,7 +1,9 @@ +import re from PyQt5.QtWidgets import QApplication, QMainWindow, QTabWidget, QWidget, QVBoxLayout, QLabel, QPushButton, QLayout, \ QHBoxLayout, QComboBox, QLineEdit, QSpacerItem, QSizePolicy, QGridLayout, QMessageBox, QSplitter, QFrame -import re +from PyQt5.QtCore import Qt + class forceButton(QPushButton): def __init__(self, number = None, valueLabel = None, valueEdit = None): super().__init__() @@ -95,6 +97,7 @@ class RightAreaWidgets(QWidget): areaValueLabel.setObjectName('wirteDIDOareaValueLabel') areaLineEdit.setObjectName('wirteDIDOareaLineEdit') areaLineEdit.setFixedSize(30, 27) + areaLineEdit.setAlignment(Qt.AlignHCenter) forceBtn.setObjectName('wirteDIDOforceBtn') if self.deviceName[-2:] + self.dataType in ['主站DI','从站DO']: @@ -111,7 +114,7 @@ class RightAreaWidgets(QWidget): def wirteAreaLineEditValue(self,dataTypeAndModel, valueLabel, number, value): if dataTypeAndModel in ['主站AO','从站AI']: - pattern = re.compile(r'^\d+(\.\d+)?$') + pattern = re.compile(r'-?\d*\.?\d+') match = pattern.match(value) if not match: QMessageBox.warning(self, '提示', '请输入数字。') diff --git a/protocol/ModBus/TCPMaster.py b/protocol/ModBus/TCPMaster.py index 0da1ded..e9c575e 100644 --- a/protocol/ModBus/TCPMaster.py +++ b/protocol/ModBus/TCPMaster.py @@ -22,7 +22,6 @@ class TcpMaster(): try: self.master.execute(slaveId, cst.WRITE_MULTIPLE_REGISTERS, starting_address = address, output_value=outputValue) except Exception as e: - print(e) return 'error' diff --git a/utils/DBModels/DeviceModels.py b/utils/DBModels/DeviceModels.py index dd39eba..90f14a4 100644 --- a/utils/DBModels/DeviceModels.py +++ b/utils/DBModels/DeviceModels.py @@ -35,7 +35,7 @@ class DeviceDB(BaseModel): try: return cls.get(cls.deviceName == str(deviceName)) except Exception as e: - return print(e) + return # 删除设备 @@ -46,7 +46,7 @@ class DeviceDB(BaseModel): query.execute() return 'ok' except Exception as e: - return e + return # 添加设备