diff --git a/CU/Feeding.py b/CU/Feeding.py index f1986a0..d732aab 100644 --- a/CU/Feeding.py +++ b/CU/Feeding.py @@ -110,7 +110,7 @@ class Feeding(): elif self.feedStatus == FeedStatus.FPhoto: log.log_message(logging.INFO, Constant.str_feed_photo) if self.feedConfig.feedLine.photo_position.compare(real_position): - code, img, xyz, uvw = self.detection.get_position() #检测结果 + code, img, xyz, uvw, mng = self.detection.get_position() #检测结果 log.log_message(logging.INFO, Constant.str_feed_takePhoto) self.detection_image = img if xyz!=None: @@ -125,8 +125,7 @@ class Feeding(): self.robotClient.status_model.world_5) # 黄老师给我的xyz和法向量 - - target_position, noraml_base = getPosition(*xyz, *uvw,rotation) + target_position, noraml_base = getPosition(*xyz, *uvw,rotation,*mng) log.log_message(logging.INFO, Constant.str_feed_covert_success) self.feedConfig.feedLine.take_position = Real_Position().init_position(*target_position[:3],*noraml_base) self.feedStatus = FeedStatus.FTake diff --git a/Image/log.svg b/Image/log.svg new file mode 100644 index 0000000..0057d6a --- /dev/null +++ b/Image/log.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Image/waring.svg b/Image/waring.svg new file mode 100644 index 0000000..e5de601 --- /dev/null +++ b/Image/waring.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/MainRecources.qrc b/MainRecources.qrc index e1a1c6a..9e8f264 100644 --- a/MainRecources.qrc +++ b/MainRecources.qrc @@ -1,5 +1,7 @@ + Image/log.svg + Image/waring.svg Image/backgroud_head_btn.jpg Image/wait.png Image/1.png diff --git a/MainWin.ui b/MainWin.ui index c9b1f9d..19a11ed 100644 --- a/MainWin.ui +++ b/MainWin.ui @@ -1271,8 +1271,14 @@ border-image: None; - border:None; -background-color: rgb(13, 17, 40); + + +QTabBar::tab { + background: #191E36; + padding: 10px; +border:None; + color:#ffffff +} @@ -1295,7 +1301,8 @@ background-color: rgb(13, 17, 40); - + + :/main/Image/log.svg:/main/Image/log.svg 日志 @@ -1323,7 +1330,8 @@ background-color: rgb(13, 17, 40); - + + :/main/Image/waring.svg:/main/Image/waring.svg 报警 @@ -1345,7 +1353,12 @@ background-color: rgb(13, 17, 40); 0 - + + + +color: rgb(255, 0, 0); + + @@ -4589,7 +4602,7 @@ QSlider::sub-page:horizontal - + color: rgb(255, 255, 255); diff --git a/MvSDKLog/CamCtrl_00.log b/MvSDKLog/CamCtrl_00.log index baaa3ac..fd8d943 100644 --- a/MvSDKLog/CamCtrl_00.log +++ b/MvSDKLog/CamCtrl_00.log @@ -5392,3 +5392,33 @@ Warning 2024-10-23 23:01:10:0614 DevID:Virtual USB3 Vision Source-Line:MvCamer Warning 2024-10-23 23:01:10:0614 DevID:Virtual USB3 Vision Source-Line:MvCameraControl.dll(GenTLManager.cpp-L0996) ProcessName:python.exe(16200) Description:[GetInterfaceInfos]TLGetInterfaceInfo[INTERFACE_INFO_VERSION] failed, Ret[0x80000001] Warning 2024-10-23 23:01:10:0614 DevID:Virtual USB3 Vision Source-Line:MvCameraControl.dll(GenTLManager.cpp-L1000) ProcessName:python.exe(16200) Description:[GetInterfaceInfos]TLGetInterfaceInfo[INTERFACE_INFO_MANUFACTURER] failed, Ret[0x80000001] Warning 2024-10-23 23:01:10:0614 DevID:Virtual USB3 Vision Source-Line:MvCameraControl.dll(GenTLManager.cpp-L1004) ProcessName:python.exe(16200) Description:[GetInterfaceInfos]TLGetInterfaceInfo[INTERFACE_INFO_USER_DEFINED_NAME] failed, Ret[0x80000001] +Error 2024-10-24 21:56:18:0181 DevID: Source-Line:MvCameraControl.dll(OtherLoadLibrary.cpp-L0709) ProcessName:python.exe(13356) Description:[LoadSRAllFunctions]hSRModule is NULL, Ret[0x8000000c] +Warning 2024-10-24 21:56:18:0189 DevID: Source-Line:MvCameraControl.dll(GenTLLoadLibraryEx.cpp-L0345) ProcessName:python.exe(13356) Description:[LoadCtiLibInter]MV_GCSetConfigIntValue is NULL, CTI path[D:\environment\envs\UICreater\lib\site-packages\MvProducerVIR.dll] +Warning 2024-10-24 21:56:18:0195 DevID:Virtual GigE Vision Source-Line:MvCameraControl.dll(GenTLManager.cpp-L0992) ProcessName:python.exe(13356) Description:[GetInterfaceInfos]TLGetInterfaceInfo[INTERFACE_INFO_MODEL] failed, Ret[0x80000001] +Warning 2024-10-24 21:56:18:0195 DevID:Virtual GigE Vision Source-Line:MvCameraControl.dll(GenTLManager.cpp-L0996) ProcessName:python.exe(13356) Description:[GetInterfaceInfos]TLGetInterfaceInfo[INTERFACE_INFO_VERSION] failed, Ret[0x80000001] +Warning 2024-10-24 21:56:18:0195 DevID:Virtual GigE Vision Source-Line:MvCameraControl.dll(GenTLManager.cpp-L1000) ProcessName:python.exe(13356) Description:[GetInterfaceInfos]TLGetInterfaceInfo[INTERFACE_INFO_MANUFACTURER] failed, Ret[0x80000001] +Warning 2024-10-24 21:56:18:0195 DevID:Virtual GigE Vision Source-Line:MvCameraControl.dll(GenTLManager.cpp-L1004) ProcessName:python.exe(13356) Description:[GetInterfaceInfos]TLGetInterfaceInfo[INTERFACE_INFO_USER_DEFINED_NAME] failed, Ret[0x80000001] +Warning 2024-10-24 21:56:18:0195 DevID:Virtual USB3 Vision Source-Line:MvCameraControl.dll(GenTLManager.cpp-L0992) ProcessName:python.exe(13356) Description:[GetInterfaceInfos]TLGetInterfaceInfo[INTERFACE_INFO_MODEL] failed, Ret[0x80000001] +Warning 2024-10-24 21:56:18:0195 DevID:Virtual USB3 Vision Source-Line:MvCameraControl.dll(GenTLManager.cpp-L0996) ProcessName:python.exe(13356) Description:[GetInterfaceInfos]TLGetInterfaceInfo[INTERFACE_INFO_VERSION] failed, Ret[0x80000001] +Warning 2024-10-24 21:56:18:0195 DevID:Virtual USB3 Vision Source-Line:MvCameraControl.dll(GenTLManager.cpp-L1000) ProcessName:python.exe(13356) Description:[GetInterfaceInfos]TLGetInterfaceInfo[INTERFACE_INFO_MANUFACTURER] failed, Ret[0x80000001] +Warning 2024-10-24 21:56:18:0195 DevID:Virtual USB3 Vision Source-Line:MvCameraControl.dll(GenTLManager.cpp-L1004) ProcessName:python.exe(13356) Description:[GetInterfaceInfos]TLGetInterfaceInfo[INTERFACE_INFO_USER_DEFINED_NAME] failed, Ret[0x80000001] +Error 2024-10-24 21:58:15:0065 DevID: Source-Line:MvCameraControl.dll(OtherLoadLibrary.cpp-L0709) ProcessName:python.exe(12040) Description:[LoadSRAllFunctions]hSRModule is NULL, Ret[0x8000000c] +Warning 2024-10-24 21:58:15:0066 DevID: Source-Line:MvCameraControl.dll(GenTLLoadLibraryEx.cpp-L0345) ProcessName:python.exe(12040) Description:[LoadCtiLibInter]MV_GCSetConfigIntValue is NULL, CTI path[D:\environment\envs\UICreater\lib\site-packages\MvProducerVIR.dll] +Warning 2024-10-24 21:58:15:0069 DevID:Virtual GigE Vision Source-Line:MvCameraControl.dll(GenTLManager.cpp-L0992) ProcessName:python.exe(12040) Description:[GetInterfaceInfos]TLGetInterfaceInfo[INTERFACE_INFO_MODEL] failed, Ret[0x80000001] +Warning 2024-10-24 21:58:15:0069 DevID:Virtual GigE Vision Source-Line:MvCameraControl.dll(GenTLManager.cpp-L0996) ProcessName:python.exe(12040) Description:[GetInterfaceInfos]TLGetInterfaceInfo[INTERFACE_INFO_VERSION] failed, Ret[0x80000001] +Warning 2024-10-24 21:58:15:0069 DevID:Virtual GigE Vision Source-Line:MvCameraControl.dll(GenTLManager.cpp-L1000) ProcessName:python.exe(12040) Description:[GetInterfaceInfos]TLGetInterfaceInfo[INTERFACE_INFO_MANUFACTURER] failed, Ret[0x80000001] +Warning 2024-10-24 21:58:15:0069 DevID:Virtual GigE Vision Source-Line:MvCameraControl.dll(GenTLManager.cpp-L1004) ProcessName:python.exe(12040) Description:[GetInterfaceInfos]TLGetInterfaceInfo[INTERFACE_INFO_USER_DEFINED_NAME] failed, Ret[0x80000001] +Warning 2024-10-24 21:58:15:0069 DevID:Virtual USB3 Vision Source-Line:MvCameraControl.dll(GenTLManager.cpp-L0992) ProcessName:python.exe(12040) Description:[GetInterfaceInfos]TLGetInterfaceInfo[INTERFACE_INFO_MODEL] failed, Ret[0x80000001] +Warning 2024-10-24 21:58:15:0069 DevID:Virtual USB3 Vision Source-Line:MvCameraControl.dll(GenTLManager.cpp-L0996) ProcessName:python.exe(12040) Description:[GetInterfaceInfos]TLGetInterfaceInfo[INTERFACE_INFO_VERSION] failed, Ret[0x80000001] +Warning 2024-10-24 21:58:15:0069 DevID:Virtual USB3 Vision Source-Line:MvCameraControl.dll(GenTLManager.cpp-L1000) ProcessName:python.exe(12040) Description:[GetInterfaceInfos]TLGetInterfaceInfo[INTERFACE_INFO_MANUFACTURER] failed, Ret[0x80000001] +Warning 2024-10-24 21:58:15:0069 DevID:Virtual USB3 Vision Source-Line:MvCameraControl.dll(GenTLManager.cpp-L1004) ProcessName:python.exe(12040) Description:[GetInterfaceInfos]TLGetInterfaceInfo[INTERFACE_INFO_USER_DEFINED_NAME] failed, Ret[0x80000001] +Error 2024-10-24 22:02:02:0205 DevID: Source-Line:MvCameraControl.dll(OtherLoadLibrary.cpp-L0709) ProcessName:python.exe(15216) Description:[LoadSRAllFunctions]hSRModule is NULL, Ret[0x8000000c] +Warning 2024-10-24 22:02:02:0207 DevID: Source-Line:MvCameraControl.dll(GenTLLoadLibraryEx.cpp-L0345) ProcessName:python.exe(15216) Description:[LoadCtiLibInter]MV_GCSetConfigIntValue is NULL, CTI path[D:\environment\envs\UICreater\lib\site-packages\MvProducerVIR.dll] +Warning 2024-10-24 22:02:02:0209 DevID:Virtual GigE Vision Source-Line:MvCameraControl.dll(GenTLManager.cpp-L0992) ProcessName:python.exe(15216) Description:[GetInterfaceInfos]TLGetInterfaceInfo[INTERFACE_INFO_MODEL] failed, Ret[0x80000001] +Warning 2024-10-24 22:02:02:0209 DevID:Virtual GigE Vision Source-Line:MvCameraControl.dll(GenTLManager.cpp-L0996) ProcessName:python.exe(15216) Description:[GetInterfaceInfos]TLGetInterfaceInfo[INTERFACE_INFO_VERSION] failed, Ret[0x80000001] +Warning 2024-10-24 22:02:02:0209 DevID:Virtual GigE Vision Source-Line:MvCameraControl.dll(GenTLManager.cpp-L1000) ProcessName:python.exe(15216) Description:[GetInterfaceInfos]TLGetInterfaceInfo[INTERFACE_INFO_MANUFACTURER] failed, Ret[0x80000001] +Warning 2024-10-24 22:02:02:0209 DevID:Virtual GigE Vision Source-Line:MvCameraControl.dll(GenTLManager.cpp-L1004) ProcessName:python.exe(15216) Description:[GetInterfaceInfos]TLGetInterfaceInfo[INTERFACE_INFO_USER_DEFINED_NAME] failed, Ret[0x80000001] +Warning 2024-10-24 22:02:02:0209 DevID:Virtual USB3 Vision Source-Line:MvCameraControl.dll(GenTLManager.cpp-L0992) ProcessName:python.exe(15216) Description:[GetInterfaceInfos]TLGetInterfaceInfo[INTERFACE_INFO_MODEL] failed, Ret[0x80000001] +Warning 2024-10-24 22:02:02:0209 DevID:Virtual USB3 Vision Source-Line:MvCameraControl.dll(GenTLManager.cpp-L0996) ProcessName:python.exe(15216) Description:[GetInterfaceInfos]TLGetInterfaceInfo[INTERFACE_INFO_VERSION] failed, Ret[0x80000001] +Warning 2024-10-24 22:02:02:0209 DevID:Virtual USB3 Vision Source-Line:MvCameraControl.dll(GenTLManager.cpp-L1000) ProcessName:python.exe(15216) Description:[GetInterfaceInfos]TLGetInterfaceInfo[INTERFACE_INFO_MANUFACTURER] failed, Ret[0x80000001] +Warning 2024-10-24 22:02:02:0209 DevID:Virtual USB3 Vision Source-Line:MvCameraControl.dll(GenTLManager.cpp-L1004) ProcessName:python.exe(15216) Description:[GetInterfaceInfos]TLGetInterfaceInfo[INTERFACE_INFO_USER_DEFINED_NAME] failed, Ret[0x80000001] diff --git a/Util/util_time.py b/Util/util_time.py new file mode 100644 index 0000000..0d49290 --- /dev/null +++ b/Util/util_time.py @@ -0,0 +1,142 @@ +import time + +class MyTimer: + + @staticmethod + def gMyGetTickCount(): + ts = time.time() + return int(ts * 1000) # Convert to milliseconds + +# CTon class equivalent in Python +class CTon: + def __init__(self): + self.m_unET = 0 + self.m_bLastI = False + self.m_bIn = False + self.m_bPause = False + self.m_bOver = True + self.m_unPT = 0 + self.m_unStartTime = 0 + self.m_unPauseET = 0 + + def GetET(self): + if self.m_bIn: + nET = self.m_unPT + (self.m_unStartTime - MyTimer.gMyGetTickCount()) + return max(nET, 0) + else: + return 0 + + def SetReset(self): + self.m_bIn = False + self.m_bLastI = False + self.m_bPause = False + + def SetPause(self, value): + if self.m_bIn: + self.m_bPause = value + if self.m_bPause: + self.m_unPauseET = MyTimer.gMyGetTickCount() - self.m_unStartTime + + def SetOver(self, value): + self.m_bOver = value + + def GetStartTime(self): + return self.m_unStartTime + + def Q(self, value_i, value_pt): + self.m_bIn = value_i + self.m_unPT = value_pt + un_tick = MyTimer.gMyGetTickCount() + + if self.m_bOver and self.m_bIn: + self.m_unStartTime = un_tick - self.m_unPT + self.m_bOver = False + + if self.m_bPause and self.m_bIn: + self.m_unStartTime = un_tick - self.m_unPauseET + + if self.m_bIn != self.m_bLastI: + self.m_bLastI = self.m_bIn + if self.m_bIn: + self.m_unStartTime = un_tick + self.m_bPause = False + + return self.m_bIn and (un_tick >= (self.m_unStartTime + self.m_unPT)) + +# CClockPulse class equivalent in Python +class CClockPulse: + def __init__(self): + self.m_bFirstOut = True + self.m_bTonAOut = False + self.m_bTonBOut = False + self.m_cTonA = CTon() + self.m_cTonB = CTon() + + def Q(self, value_i, run_time, stop_time): + if self.m_bFirstOut: + self.m_bTonAOut = self.m_cTonA.Q(not self.m_bTonBOut and value_i, run_time) + self.m_bTonBOut = self.m_cTonB.Q(self.m_bTonAOut and value_i, stop_time) + return not self.m_bTonAOut and value_i + else: + self.m_bTonAOut = self.m_cTonA.Q(not self.m_bTonBOut and value_i, stop_time) + self.m_bTonBOut = self.m_cTonB.Q(self.m_bTonAOut and value_i, run_time) + return self.m_bTonAOut and value_i + +# CDelayOut class equivalent in Python +class CDelayOut: + def __init__(self): + self.m_cOutTon = CTon() + self.m_cmWaitTon = CTon() + + def Reset(self): + self.m_cOutTon.SetReset() + self.m_cmWaitTon.SetReset() + + def Q(self, value_i, wait_time, out_time): + if self.m_cmWaitTon.Q(value_i, wait_time): + if self.m_cOutTon.Q(True, out_time): + self.m_cOutTon.SetReset() + self.m_cmWaitTon.SetReset() + value_i = False + return False + return True + return False + +# CRisOrFall class equivalent in Python +class CRisOrFall: + def __init__(self): + self.m_bTemp = False + + def Q(self, value_i, ris_or_fall): + result = False + if value_i != self.m_bTemp: + if ris_or_fall and value_i: # Rising edge + result = True + if not ris_or_fall and not value_i: # Falling edge + result = True + self.m_bTemp = value_i + return result + +# CTof class equivalent in Python +class CTof: + def __init__(self): + self.m_cDelayTon = CTon() + self.m_bValue = False + self.m_cRis = CRisOrFall() + + def SetReset(self): + self.m_bValue = False + self.m_cDelayTon.SetReset() + + def Q(self, value_i, delay_time): + if self.m_cRis.Q(value_i, False): + self.m_cDelayTon.SetReset() + self.m_bValue = True + if self.m_cDelayTon.Q(self.m_bValue, delay_time): + self.m_bValue = False + self.m_cDelayTon.SetReset() + return value_i or self.m_bValue + +# Utility function +def gGetNowTime(): + return int(time.time()) diff --git a/main.py b/main.py index 5c72640..99e5ca2 100644 --- a/main.py +++ b/main.py @@ -8,7 +8,7 @@ from multiprocessing import Process from PyQt5.uic.properties import QtWidgets from PySide6 import QtCore from PySide6.QtCore import QThread, Signal, Slot, QObject, QEvent -from PySide6.QtGui import QIntValidator, QStandardItemModel, QStandardItem, Qt, QMovie +from PySide6.QtGui import QIntValidator, QStandardItemModel, QStandardItem, Qt, QMovie, QIcon from PySide6.QtWidgets import QApplication, QMainWindow, QPushButton, QLabel, QHeaderView, QTableWidget, \ QTableWidgetItem, QWidget, QHBoxLayout, QAbstractItemView, QMessageBox, QSizePolicy from datetime import datetime @@ -30,6 +30,7 @@ from Model.Position import Real_Position, Detection_Position from threading import Thread from CU.Command import Status from Util.util_log import log +from Vision.detect_person import DetectionPerson from ui_MainWin import Ui_MainWindow @@ -43,6 +44,7 @@ class MainWindow(QMainWindow, Ui_MainWindow): self.init_Run() self.init_robot_info() self.init_FeedLine() + self.start_Runing() # self.init_log() @@ -192,6 +194,7 @@ class MainWindow(QMainWindow, Ui_MainWindow): self.feedLine_dict = {} self.command_quene = Queue() self.main_threading = None + self.detection_person = DetectionPerson() self.configReader.read(Constant.set_ini) ip = self.configReader.get('Robot_Feed', 'IPAddress') @@ -709,11 +712,16 @@ class MainWindow(QMainWindow, Ui_MainWindow): def send_pauseFeed_button_click(self): if self.pushButton_pauseFeed.text() == '暂停': + + icon9 = QIcon(QIcon.fromTheme(QIcon.ThemeIcon.SystemReboot)) + self.pushButton_pauseFeed.setIcon(icon9) self.pushButton_pauseFeed.setText('继续') log.log_message(logging.INFO, Constant.str_feed_pause) self.send_pause_command(True) self.feeding.pause = True else: + icon9 = QIcon(QIcon.fromTheme(QIcon.ThemeIcon.MediaPlaybackPause)) + self.pushButton_pauseFeed.setIcon(icon9) self.pushButton_pauseFeed.setText('暂停') self.send_pause_command(False) log.log_message(logging.INFO, Constant.str_feed_continue) @@ -806,6 +814,7 @@ class MainWindow(QMainWindow, Ui_MainWindow): if self.feeding.feedStatus != FeedStatus.FNone: self.horizontalSlider_feedingNum.setValue( self.horizontalSlider_feedingNum.maximum() - self.feeding.feedConfig.num) + self.label_remain_num.setText(str(self.feeding.feedConfig.num)) else: self.set_run_status_button(False) if self.feeding.feedStatus == FeedStatus.FNone: @@ -813,11 +822,12 @@ class MainWindow(QMainWindow, Ui_MainWindow): else: self.stackedWidget_num.setCurrentIndex(1) - # if self.feeding.feedConfig.num==2: - # self.feeding.pause=True - # self.send_pause_command(True) - # self.show_messagebox_of_person() - # log.log_message(logging.ERROR, '人员进入安全区') + has_person,_ = self.detection_person.get_person(None) + if has_person: + self.feeding.pause=True + self.send_pause_command(True) + self.show_messagebox_of_person() + log.log_message(logging.ERROR, '人员进入安全区') self.label_date.setText(datetime.now().strftime("%Y-%m-%d")) self.label_time.setText(datetime.now().strftime("%H:%M:%S")) @@ -952,14 +962,16 @@ class MainWindow(QMainWindow, Ui_MainWindow): def set_run_status_button(self, isRuning: bool): self.pushButton_pauseFeed.setText("暂停") - if isRuning: - self.pushButton_pauseFeed.show() - self.pushButton_stopFeed.show() - self.pushButton_startFeed.hide() - else: - self.pushButton_pauseFeed.hide() - self.pushButton_stopFeed.hide() - self.pushButton_startFeed.show() + + + # if isRuning: + # self.pushButton_pauseFeed.show() + # self.pushButton_stopFeed.show() + # self.pushButton_startFeed.hide() + # else: + # self.pushButton_pauseFeed.hide() + # self.pushButton_stopFeed.hide() + # self.pushButton_startFeed.show() def send_clear_auto_command(self): clear_command = CMDInstructRequest() diff --git a/ui_MainWin.py b/ui_MainWin.py index 7187b4f..84e4bd3 100644 --- a/ui_MainWin.py +++ b/ui_MainWin.py @@ -2935,11 +2935,11 @@ class Ui_MainWindow(object): self.horizontalLayout_12.addWidget(self.label_6) - self.label_7 = QLabel(self.frame_24) - self.label_7.setObjectName(u"label_7") - self.label_7.setStyleSheet(u"color: rgb(255, 255, 255);") + self.label_remain_num = QLabel(self.frame_24) + self.label_remain_num.setObjectName(u"label_remain_num") + self.label_remain_num.setStyleSheet(u"color: rgb(255, 255, 255);") - self.horizontalLayout_12.addWidget(self.label_7) + self.horizontalLayout_12.addWidget(self.label_remain_num) self.horizontalLayout_12.setStretch(0, 1) self.horizontalLayout_12.setStretch(1, 5) @@ -3127,6 +3127,6 @@ class Ui_MainWindow(object): self.label_4.setText(QCoreApplication.translate("MainWindow", u"\u76ee\u6807\u888b\u6570\uff1a", None)) self.label_maxNum.setText(QCoreApplication.translate("MainWindow", u"10", None)) self.label_6.setText(QCoreApplication.translate("MainWindow", u"\u5269\u4f59\u888b\u6570\uff1a", None)) - self.label_7.setText(QCoreApplication.translate("MainWindow", u"1", None)) + self.label_remain_num.setText(QCoreApplication.translate("MainWindow", u"1", None)) # retranslateUi