添加上料斗、下料斗存在错误信息时(表示付工那边没有连接上重量客户端),状态图标显示没连接,并且重量数据清0

This commit is contained in:
2025-11-17 16:02:46 +08:00
parent ccc794d158
commit cfaf1d5d92
4 changed files with 66 additions and 12 deletions

View File

@ -98,16 +98,28 @@ class MainWindow(QWidget):
def bind_signals(self):
"""绑定TCP信号到弹窗更新函数"""
self.tcp_client.weight_updated.connect(self.update_weight_dialogs) # 绑定更新重量信息的信号槽
# 连接状态信号:更新按钮状态和弹窗图标
# 连接状态信号:更新状态图标
self.tcp_client.connection_status_changed.connect(self.update_connection_status)
# 上料斗重量信息更新失败信号:更新状态图标
self.tcp_client.upper_weight_error.connect(self.upper_weight_status) # 重量信息更新失败信号
# 下料斗重量信息更新失败信号:更新状态图标
self.tcp_client.down_weight_error.connect(self.down_weight_status) # 重量信息更新失败信号
# 启动 TCP 连接
print(f"客户端启动,自动连接服务端{self.tcp_client.tcp_server_host}:{self.tcp_client.tcp_server_port}...")
self.tcp_client._connect_to_server()
def down_weight_status(self, is_error):
"""发送上料斗错误信息,更新连接状态"""
self.weight_dialog2._update_status_icon2(is_error)
def upper_weight_status(self, is_error):
"""发送下料斗错误信息,更新连接状态"""
self.weight_dialog1._update_status_icon2(is_error)
def update_connection_status(self, is_connected):
"""更新连接状态"""
self.weight_dialog1._update_status_icon(is_connected)
self.weight_dialog2._update_status_icon(is_connected)
"""根据服务端是否连接,更新连接状态"""
self.weight_dialog1._update_status_icon1(is_connected)
self.weight_dialog2._update_status_icon1(is_connected)
def update_weight_dialogs(self, data):
"""更新上料斗、下料斗重量显示"""
@ -124,6 +136,6 @@ if __name__ == "__main__":
import sys
app = QApplication([])
window = MainWindow()
# window.show() # 显示主界面
window.showFullScreen() # 全屏显示主界面
window.show() # 显示主界面
# window.showFullScreen() # 全屏显示主界面
sys.exit(app.exec())