update 更新界面更新逻辑,子线程触发代理交于主线程更新

This commit is contained in:
FrankCV2048
2024-12-15 19:54:44 +08:00
parent ccf177273d
commit 2c6539ef51
3 changed files with 24 additions and 17 deletions

View File

@ -1,6 +1,6 @@
import os import os
Debug = False Debug = True
IO_EmergencyPoint = 3 IO_EmergencyPoint = 3
bag_height = 10 # 一袋的高度 bag_height = 10 # 一袋的高度
position_accuracy = 0.1 position_accuracy = 0.1

View File

@ -1,7 +1,7 @@
[Main] [Main]
[Robot_Feed] [Robot_Feed]
ipaddress = 192.168.20.4 ipaddress = 127.0.0.1
port = 502 port = 502
j1_min = -150 j1_min = -150
j1_max = +150 j1_max = +150
@ -47,7 +47,7 @@ photo_v5 = 0.0
photo_w5 = 1.0 photo_w5 = 1.0
linecount = 2 linecount = 2
remain_linename = 1 remain_linename = 1
remain_count = 12 remain_count = 574
io_take_addr = 8 io_take_addr = 8
io_zip_addr = 11 io_zip_addr = 11
io_shake_addr = 12 io_shake_addr = 12
@ -62,12 +62,12 @@ feed_speed = 10
reset_speed = 35 reset_speed = 35
[Origin] [Origin]
x = 1927.155273 x = 7.0
y = 570.19989 y = 50.0
z = 1299.689941 z = 1.0
u = 6.975893 u = 12.0
v = -9.897896 v = 0.0
w = -135.095978 w = 1.0
[Camera_Feed] [Camera_Feed]
ipaddress = 127.0.0.1 ipaddress = 127.0.0.1

23
main.py
View File

@ -1,6 +1,7 @@
import configparser import configparser
import json import json
import logging import logging
import os
import queue import queue
import sys import sys
import threading import threading
@ -47,6 +48,7 @@ from view.ResetView import StopDialog
class MainWindow(QMainWindow, Ui_MainWindow): class MainWindow(QMainWindow, Ui_MainWindow):
updateUI_seting = Signal()
def __init__(self): def __init__(self):
super(MainWindow, self).__init__() super(MainWindow, self).__init__()
self.setupUi(self) self.setupUi(self)
@ -642,6 +644,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self.last_time = time.time() self.last_time = time.time()
self.remain_lineName = self.configReader.get('Robot_Feed', 'remain_lineName') self.remain_lineName = self.configReader.get('Robot_Feed', 'remain_lineName')
self.remain_Count = int(self.configReader.get('Robot_Feed', 'remain_Count')) self.remain_Count = int(self.configReader.get('Robot_Feed', 'remain_Count'))
self.updateUI_seting.connect(self.update_seting_frame)
try: try:
self.robotClient.CreatConnect() self.robotClient.CreatConnect()
except: except:
@ -1365,13 +1368,14 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self.label_date.setText(datetime.now().strftime("%Y-%m-%d")) self.label_date.setText(datetime.now().strftime("%Y-%m-%d"))
self.label_time.setText(datetime.now().strftime("%H:%M:%S")) self.label_time.setText(datetime.now().strftime("%H:%M:%S"))
self.updateUI_Position() self.updateUI_seting.emit()
self.updateUI_label_detection()
self.updateUI_label_status()
self.updateUI_frame_sign(self.feeding.feedStatus)
self.updateUI_IOPanel()
def update_seting_frame(self):
self.updateUI_Position()
self.updateUI_label_detection()
self.updateUI_label_status()
self.updateUI_frame_sign(self.feeding.feedStatus)
self.updateUI_IOPanel()
def updateRobotSeting(self): def updateRobotSeting(self):
self.lineEdit_origin_x.setText(str(self.robotClient.origin_position.X)) self.lineEdit_origin_x.setText(str(self.robotClient.origin_position.X))
@ -1972,7 +1976,10 @@ if __name__ == "__main__":
app = MyApplication(sys.argv) app = MyApplication(sys.argv)
window = MainWindow() window = MainWindow()
window.show() window.show()
sys.excepthook = handle_exception # 你的 PySide 应用程序代码 pass sys.excepthook = handle_exception
sys.exit(app.exec()) try :
sys.exit(app.exec())
except Exception as e:
log.log_message(logging.ERROR, e)