update 更新一键投料,优化设置文字,添加平滑,假装解决闪退
This commit is contained in:
45
main.py
45
main.py
@ -10,6 +10,7 @@ import traceback
|
||||
|
||||
import PySide6
|
||||
import cv2
|
||||
import numpy as np
|
||||
from PyQt5.uic.properties import QtWidgets
|
||||
from PySide6 import QtCore
|
||||
from PySide6.QtCore import QThread, Signal, Slot, QObject, QEvent, QTimer
|
||||
@ -449,7 +450,9 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
||||
combox.addItem("初始化点", 2)
|
||||
combox.addItem("中间点", 3)
|
||||
combox.addItem("相机/待抓点",4)
|
||||
combox.addItem("抓取前点", 3)
|
||||
combox.addItem("抓取",5)
|
||||
combox.addItem("抓取后点", 3)
|
||||
combox.addItem("破带点1",6)
|
||||
combox.addItem("破带点2",7)
|
||||
combox.addItem("震动点",8)
|
||||
@ -563,7 +566,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
||||
self.pushButton_leftmenu_baseSeting.clicked.connect(lambda _, index=3: self.send_click_change_stackView(index))
|
||||
self.pushButton_leftmenu_posDebug.clicked.connect(lambda _, index=4: self.send_click_change_stackView(index))
|
||||
self.pushButton_exit.clicked.connect(self.send_exit_button_click)
|
||||
|
||||
self.pushButton_onekeyfeed.clicked.connect(self.send_onekeyfeed_button_click)
|
||||
|
||||
int_validator = QIntValidator(0, 100, self.lineEdit_num)
|
||||
self.lineEdit_num.setValidator(int_validator)
|
||||
@ -582,14 +585,13 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
||||
def init_Run(self):
|
||||
self.robotClient = None
|
||||
self.configReader = configparser.ConfigParser()
|
||||
self.detection =Detection() #TODO 关闭图像
|
||||
#TODO 关闭图像
|
||||
self.command_position_quene = Queue()
|
||||
self.status_address = DataAddress()
|
||||
self.feedLine_dict = {}
|
||||
self.command_quene = Queue()
|
||||
self.main_threading = None
|
||||
self.detection_person = None # DetectionPerson()
|
||||
self.cton_take_no_photo = CRisOrFall()
|
||||
self.index = 1
|
||||
|
||||
self.configReader.read(Constant.set_ini)
|
||||
@ -638,9 +640,10 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
||||
self.robotClient.feed_speed = feed_speed
|
||||
self.robotClient.reset_speed = reset_speed
|
||||
self.robotClient.max_angle_interval = max_angle_interval
|
||||
self.feeding = Feeding(self.robotClient, self.detection) # 临时
|
||||
self.feeding = Feeding(self.robotClient) # 临时
|
||||
self.feeding.need_origin_signal.connect(self.show_infomessage_box)
|
||||
self.feeding.take_no_photo_sigal.emit(self.show_no_photo_message_box)
|
||||
self.feeding.take_no_photo_sigal.connect(self.show_no_photo_message_box)
|
||||
self.feeding.update_detect_image.connect(self.updateUI_label_detection)
|
||||
self.last_time = time.time()
|
||||
self.remain_lineName = self.configReader.get('Robot_Feed', 'remain_lineName')
|
||||
self.remain_Count = int(self.configReader.get('Robot_Feed', 'remain_Count'))
|
||||
@ -899,6 +902,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
||||
# self.stackedWidget_num.setCurrentIndex(1)
|
||||
self.set_run_status_button(True)
|
||||
self.feeding.pause = False
|
||||
self.feeding.onekey = False
|
||||
log.log_message(logging.INFO, f'{self.feedLine_dict[line_head].name}:{Constant.str_feed_start}')
|
||||
|
||||
def send_num_button_click(self):
|
||||
@ -1318,8 +1322,8 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
||||
try:
|
||||
self.feeding.run()
|
||||
self.feeding.run_reset()
|
||||
except:
|
||||
print(Error_Code.SYS_NONEPoint)
|
||||
except Exception as e:
|
||||
log.log_message(logging.ERROR, e)
|
||||
|
||||
|
||||
# pass #主线程
|
||||
@ -1371,7 +1375,6 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
||||
|
||||
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()
|
||||
@ -1386,6 +1389,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
||||
|
||||
@Slot()
|
||||
def show_no_photo_message_box(self):
|
||||
print("显示弹窗图片")
|
||||
self.feeding.pause = True
|
||||
self.send_pause_command(pause=1)
|
||||
msg_box_person = QMessageBox()
|
||||
@ -1412,8 +1416,10 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
||||
except Exception as e:
|
||||
log.log_message(logging.ERROR, Constant.str_sys_log_IO_error)
|
||||
pass
|
||||
def updateUI_label_detection(self):
|
||||
backgroud_img = Util.util_pic.cv2_to_qpixmap(self.feeding.detection_image)
|
||||
@Slot()
|
||||
def updateUI_label_detection(self,img:np.ndarray):
|
||||
img_copy = np.copy(img)
|
||||
backgroud_img = Util.util_pic.cv2_to_qpixmap(img_copy)
|
||||
if backgroud_img == None:
|
||||
return
|
||||
backgroud_img = backgroud_img.scaled(self.label_showDetection.size().width(),self.label_showDetection.size().height(), Qt.AspectRatioMode.IgnoreAspectRatio,Qt.TransformationMode.SmoothTransformation)
|
||||
@ -1892,6 +1898,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
||||
self.lineEdit_timedelay_shake.setText(str(self.robotClient.time_delay_shake))
|
||||
|
||||
def show_infomessage_box(self,message):
|
||||
print('显示弹窗')
|
||||
msg_box = QMessageBox(self)
|
||||
msg_box.setWindowTitle("提示")
|
||||
msg_box.setText(message)
|
||||
@ -1908,6 +1915,18 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
||||
if index == 3:
|
||||
self.updateUI_Base_Set()
|
||||
|
||||
def send_onekeyfeed_button_click(self):
|
||||
# if self.feeding.feedStatus != FeedStatus.FNone:
|
||||
# self.show_infomessage_box("正在执行")
|
||||
# return
|
||||
|
||||
self.horizontalSlider_feedingNum.setMaximum(999)
|
||||
self.label_maxNum.setText(str(999))
|
||||
self.horizontalSlider_feedingNum.setValue(0)
|
||||
|
||||
self.send_startFeed_button_click()
|
||||
self.feeding.onekey = True
|
||||
|
||||
def send_exit_button_click(self):
|
||||
self.closeEvent(None)
|
||||
QApplication.quit()
|
||||
@ -1935,9 +1954,9 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
||||
|
||||
def closeEvent(self, event):
|
||||
self.record_remain_num()
|
||||
self.feeding.is_detected = False
|
||||
self.feeding.detect_thread.join()
|
||||
self.detection.release()
|
||||
# self.feeding.is_detected = False
|
||||
# self.feeding.detect_thread.join()
|
||||
self.feeding.close_feed()
|
||||
self.thread_signal = False
|
||||
self.robotClient.close()
|
||||
log.log_message(logging.INFO, Constant.str_sys_exit)
|
||||
|
||||
Reference in New Issue
Block a user