☢️ update 初步更新投料框架

This commit is contained in:
FrankCV2048
2024-11-25 22:35:45 +08:00
parent a9b903bf7b
commit 29d004221f
8 changed files with 465 additions and 37 deletions

10
CU/Catch.py Normal file
View File

@ -0,0 +1,10 @@
class catch_jaw:
def __init__(self, x, y, width, height, angle, color):
pass
def run(self):
pass
def take_bag(self):
return True

View File

@ -32,6 +32,8 @@ class FeedStatus(IntEnum):
class FeedLine:
def __init__(self,id,name,safe_position:Real_Position,broken1_position:Real_Position,broken2_position:Real_Position,shake_position:Real_Position,drop_bag_position:Real_Position):
self.safe_position = safe_position
self.broken1_position = broken1_position
self.broken2_position = broken2_position
@ -68,6 +70,7 @@ class Feeding :
self.init_detection_image()
self.pause = False
self.cRis_photo = CRisOrFall()
pass
def init_detection_image(self):

324
CU/Feeding_C.py Normal file
View File

@ -0,0 +1,324 @@
import logging
import time
import cv2
from PyQt5.QtWidgets import QMessageBox
import Constant
import Expection
from Model.Position import Real_Position, Detection_Position
from enum import Enum, IntEnum
from COM.COM_Robot import RobotClient
from Model.RobotModel import CMDInstructRequest, MoveType
from Util.util_time import CRisOrFall
from Vision.camera_coordinate_dete import Detection
from Util.util_log import log
from Model.RobotModel import Instruction
class FeedStatus(IntEnum):
FNone = 0
FStart = 1
FCheck = 2
FMid = 3
FPhoto = 4
FTake = 5
FBroken1 = 6
FBroken2 =7
FShake = 8
FDropBag = 9
FFinished = 10
class FeedPosition:
def __init__(self,status:FeedStatus,position:Real_Position):
self.status = status
self.position = position
class FeedLine:
def __init__(self, id, name, feed_positions:list):
self.feed_positions = feed_positions
self.pos_index = 0
self.name = name
self.id = id
def get_current_position(self):
pos = self.feed_positions[self.pos_index]
return pos
def get_next_position(self):
pos = self.feed_positions[self.pos_index]
self.pos_index += 1
return pos
def get_take_position(self):
for i in range(len(self.feed_positions)):
if self.feed_positions[i].status == FeedStatus.FTake:
return self.feed_positions[i]
def set_take_position(self,position:Real_Position):
for i in range(len(self.feed_positions)):
if self.feed_positions[i].status == FeedStatus.FTake:
self.feed_positions[i].position = position
class FeedingConfig:
def __init__(self, num: int, feedLine: FeedLine, photo_locs):
self.num = num
self.feedLine = feedLine
self.photo_locs = [self.deal_photo_locs(p) for p in photo_locs]
def deal_photo_locs(self, photo_loc):
position_photo = Real_Position()
position_photo.init_position(photo_loc[0], photo_loc[1], photo_loc[2], photo_loc[3], photo_loc[4], photo_loc[5])
return position_photo
def get_line_info(self):
pass
class Feeding:
def __init__(self, robotClient: RobotClient, detection: Detection):
self.feedConfig = None
self.feedStatus = FeedStatus.FNone
self.robotClient = robotClient
self.detection = detection
self.detection_image = None
self.init_detection_image()
self.pause = False
self.cRis_photo = CRisOrFall()
pass
def init_detection_image(self):
self.detection_image = cv2.imread(Constant.feed_sign_path)
def run(self):
# 获取事件坐标
real_position = Real_Position()
real_position.init_position(self.robotClient.status_model.world_0,
self.robotClient.status_model.world_1,
self.robotClient.status_model.world_2,
self.robotClient.status_model.world_3,
self.robotClient.status_model.world_4,
self.robotClient.status_model.world_5)
# real_position.init_position(0,
# 0,
# 0,
# 0,
# 0,
# 0);
if self.feedConfig == None:
self.feedStatus = FeedStatus.FNone
elif self.feedConfig.num == 0:
self.feedStatus = FeedStatus.FNone
if self.feedStatus == FeedStatus.FNone or self.pause:
return
elif self.feedStatus == FeedStatus.FStart:
log.log_message(logging.INFO, Constant.str_feed_start)
self.feedStatus = FeedStatus.FCheck if self.feedStatus != FeedStatus.FNone else FeedStatus.FNone
pass
elif self.feedStatus == FeedStatus.FCheck:
log.log_message(logging.INFO, Constant.str_feed_check)
# 1, 检查是否是三列
# 2, 检查是否有人
# if self.safe_check_columns() and self.safe_check_person():
# pass
# else:
if self.feedConfig.num != 0:
self.next_target()
# if == 原点 继续判断
# else:
# QMessageBox.information(None, "提示", Constant.str_feed_safe_error_msgbox)
elif self.feedStatus == FeedStatus.FMid:
log.log_message(logging.INFO, Constant.str_feed_mid)
feed_pos = self.feedConfig.feedLine.get_current_position()
if feed_pos.position.compare(real_position):
self.next_target()
elif self.feedStatus == FeedStatus.FPhoto:
log.log_message(logging.INFO, Constant.str_feed_photo)
detect_pos_list = []
if not Constant.Debug:
try:
from Util.util_time import CRisOrFall
if self.cRis_photo.Q(self.error_photo_count >= 5, True):
QMessageBox.information(None, "提示", Constant.str_feed_photo_error_msgbox)
self.error_photo_count = 0
log.log_message(logging.INFO, Constant.str_feed_photo_confirm)
# TODO 返回初始状态
for pos in self.feedConfig.photo_locs:
self.sendTargPosition(pos)
while not pos.compare(real_position): # 可以优化 TODO
if self.feedStatus == FeedStatus.FNone or not self.pause:
return
time.sleep(0.1)
code, img, xyz, uvw, mng = self.detection.get_position() # 检测结果
self.detection_image = img
if xyz != None:
log.log_message(logging.INFO, Constant.str_feed_takePhoto_success)
# dp = Detection_Position().init_position(*xyz, *uvw)
from Trace.handeye_calibration import R_matrix, getPosition
rotation = R_matrix(self.robotClient.status_model.world_0,
self.robotClient.status_model.world_1,
self.robotClient.status_model.world_2 - 10, # TODO 这个10 需要确定
self.robotClient.status_model.world_3,
self.robotClient.status_model.world_4,
self.robotClient.status_model.world_5)
# 黄老师给我的xyz和法向量
target_position, noraml_base = getPosition(*xyz, *uvw, rotation, *mng)
detect_pos_list.append(Real_Position().init_position(*target_position[:3], *noraml_base))
log.log_message(logging.INFO, Constant.str_feed_takePhoto_success)
else:
log.log_message(logging.ERROR, Constant.str_feed_takePhoto_fail + real_position.to_string())
z_diff, max_z_index = (lambda pts: (
max(pts, key=lambda p: p.Z).Z - min(pts, key=lambda p: p.Z).Z,
pts.index(max(pts, key=lambda p: p.Z))
))(detect_pos_list)
if len(self.feedConfig.photo_locs) == 5:
if z_diff < Constant.bag_height and len(
detect_pos_list) == 3: # 第一次检测到没有高度差距开始三列拍照 TODO 保留全部的开关
# 拍照位置从五个变为三个
self.feedConfig.photo_locs = [detect_pos_list[0], detect_pos_list[2], detect_pos_list[4]]
take_position = detect_pos_list[0]
log.log_message(logging.INFO, Constant.str_feed_takePhoto_front_finish)
else:
take_position = detect_pos_list[max_z_index]
log.log_message(logging.INFO, Constant.str_feed_takePhoto_front)
else:
if z_diff < Constant.bag_height:
take_position = detect_pos_list[0]
log.log_message(logging.INFO, Constant.str_feed_takePhoto_new_line)
else:
take_position = detect_pos_list[max_z_index]
log.log_message(logging.INFO, Constant.str_feed_takePhoto_line)
self.feedConfig.feedLine.set_take_position(take_position) ##TODO 检查有没有异常
self.next_target()
except:
log.log_message(logging.ERROR, Constant.str_feed_takePhoto_fail)
self.error_photo_count += 1
else:
self.feedConfig.feedLine.set_take_position(real_position) ##TODO 检查有没有异常
self.next_target()
log.log_message(logging.INFO, Constant.str_feed_takePhoto_move)
elif self.feedStatus == FeedStatus.FTake:
log.log_message(logging.INFO, Constant.str_feed_take)
if self.feedConfig.feedLine.take_position != None and self.feedConfig.feedLine.get_current_position().compare(
real_position):
# 打开吸嘴并返回
self.sendIOControl(self.robotClient.con_ios[0], 1)
self.sendIOControl(self.robotClient.con_ios[1], 1)
self.sendIOControl(self.robotClient.con_ios[2], 1)
# TODO 检测是否通 不然报警
time.sleep(self.robotClient.time_delay_take)
log.log_message(logging.INFO, Constant.str_feed_take_success)
self.next_target()
elif self.feedStatus == FeedStatus.FBroken1:
log.log_message(logging.INFO, Constant.str_feed_broken)
if self.feedConfig.feedLine.get_current_position.compare(real_position):
self.next_target()
elif self.feedStatus == FeedStatus.FBroken2:
log.log_message(logging.INFO, Constant.str_feed_broken)
if self.feedConfig.feedLine.get_current_position.compare(real_position):
self.next_target()
elif self.feedStatus == FeedStatus.FShake:
log.log_message(logging.INFO, Constant.str_feed_shake)
if self.feedConfig.feedLine.get_current_position.compare(real_position):
# TODO 震动方案
time.sleep(self.robotClient.time_delay_shake)
self.next_target()
elif self.feedStatus == FeedStatus.FDropBag:
log.log_message(logging.INFO, Constant.str_feed_drop)
if self.feedConfig.feedLine.get_current_position.compare(real_position):
self.sendIOControl(self.robotClient.con_ios[0], 0)
self.sendIOControl(self.robotClient.con_ios[1], 0)
self.sendIOControl(self.robotClient.con_ios[2], 0)
# TODO 检测是否断 不然报警
time.sleep(self.robotClient.time_delay_put)
self.feedConfig.num = self.feedConfig.num - 1
log.log_message(logging.INFO, f'{Constant.str_feed_feed_num}{self.feedConfig.num}')
if self.feedConfig.num ==0 and self.feedConfig.feedLine.pos_index == 0:
log.log_message(logging.INFO, Constant.str_feed_finish)
self.feedStatus = FeedStatus.FNone
self.init_detection_image()
def send_emergency_sound(self):
self.sendIOControl(Constant.IO_EmergencyPoint, 1)
def send_emergency_stop(self):
self.sendIOControl(Constant.IO_EmergencyPoint, 0)
def sendIOControl(self, IO_bit, IO_Status: int):
IO_command = CMDInstructRequest()
io_instruction = Instruction()
io_instruction.IO = True
io_instruction.io_status = IO_Status
io_instruction.point = IO_bit # {"dsID":"HCRemoteCommand","reqType":"AddRCC","emptyList":"1","instructions":[{"oneshot":"1","action":"200","type":"0","io_status":"1","point":"15","delay":"0"}]}
IO_command.dsID = 'HCRemoteCommand'
IO_command.instructions.append(io_instruction)
self.robotClient.add_sendQuene(IO_command.toString())
log.log_message(logging.INFO, f'{Constant.str_feed_io_control}{IO_bit}{IO_Status}')
pass
def sendTargPosition(self, real_position, move_type: MoveType = MoveType.WORLD, speed=Constant.speed):
position_instruction = Instruction()
position_instruction.speed = speed
position_instruction.m0 = real_position.X
position_instruction.m1 = real_position.Y
position_instruction.m2 = real_position.Z
position_instruction.m3 = real_position.U
position_instruction.m4 = real_position.V
position_instruction.m5 = real_position.W
position_instruction.action = move_type.value
instruction_command = CMDInstructRequest()
instruction_command.instructions.append(position_instruction)
request_command = instruction_command.toString()
log_str = f'移动到位置:{"姿势直线"}' \
f'X:{position_instruction.m0}-' \
f'Y:{position_instruction.m1}-' \
f'Z:{position_instruction.m2}-' \
f'U:{position_instruction.m3}-' \
f'V:{position_instruction.m4}-' \
f'W:{position_instruction.m5}'
try:
log.log_message(logging.INFO, log_str)
except:
print("error")
self.robotClient.add_sendQuene(request_command)
pass
def next_target(self):
feed_pos = self.feedConfig.feedLine.get_next_position()
self.feedStatus = feed_pos.status
self.sendTargPosition(feed_pos.position)
def safe_check_columns(self):
return True
pass
def safe_check_person(self):
return True
pass

View File

@ -27,6 +27,7 @@ str_feed_stop = '投料停止'
str_feed_feed = '移动到投料位置'
str_feed_mid = '移动到中位位置'
str_feed_safe = '移动到安全位置'
str_feed_safe_middle = '移动到安全中位位置'
str_feed_takePhoto = '拍照'
str_feed_broken = '移动到破袋位置'
str_feed_broken_bag = '划袋'
@ -50,6 +51,8 @@ str_feed_zip_bag = '移动到压缩袋位置'
str_feed_photo_error_msgbox = '请重新摆放料带后再关闭此窗口'
str_feed_photo_confirm = '确认摆好'
str_feed_io_control = '发送IO控制: '
str_feed_safe_error_msgbox = '未在安全位置,请先复位!'
str_feed_shake = '摇摆'
str_sys_start = '进入系统'
str_sys_exit = '退出系统'
str_sys_switch_tool = '切换到工具坐标'

View File

@ -907,7 +907,7 @@ background-color: rgb(13, 17, 40);</string>
</sizepolicy>
</property>
<property name="currentIndex">
<number>0</number>
<number>5</number>
</property>
<widget class="QWidget" name="page_3">
<layout class="QVBoxLayout" name="verticalLayout_7" stretch="1">
@ -4752,6 +4752,35 @@ font: 10pt &quot;楷体&quot;;
</item>
</layout>
</widget>
<widget class="QWidget" name="page_8">
<layout class="QVBoxLayout" name="verticalLayout_22">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QFrame" name="frame_16">
<property name="frameShape">
<enum>QFrame::Shape::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Shadow::Raised</enum>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>

View File

@ -9083,3 +9083,43 @@ Warning 2024-11-07 20:21:59:0564 DevID:Virtual USB3 Vision Source-Line:MvCamer
Warning 2024-11-07 20:21:59:0564 DevID:Virtual USB3 Vision Source-Line:MvCameraControl.dll(GenTLManager.cpp-L0996) ProcessName:python.exe(16148) Description:[GetInterfaceInfos]TLGetInterfaceInfo[INTERFACE_INFO_VERSION] failed, Ret[0x80000001]
Warning 2024-11-07 20:21:59:0564 DevID:Virtual USB3 Vision Source-Line:MvCameraControl.dll(GenTLManager.cpp-L1000) ProcessName:python.exe(16148) Description:[GetInterfaceInfos]TLGetInterfaceInfo[INTERFACE_INFO_MANUFACTURER] failed, Ret[0x80000001]
Warning 2024-11-07 20:21:59:0564 DevID:Virtual USB3 Vision Source-Line:MvCameraControl.dll(GenTLManager.cpp-L1004) ProcessName:python.exe(16148) Description:[GetInterfaceInfos]TLGetInterfaceInfo[INTERFACE_INFO_USER_DEFINED_NAME] failed, Ret[0x80000001]
Error 2024-11-07 20:27:31:0198 DevID: Source-Line:MvCameraControl.dll(OtherLoadLibrary.cpp-L0709) ProcessName:python.exe(16960) Description:[LoadSRAllFunctions]hSRModule is NULL, Ret[0x8000000c]
Warning 2024-11-07 20:27:31:0201 DevID: Source-Line:MvCameraControl.dll(GenTLLoadLibraryEx.cpp-L0345) ProcessName:python.exe(16960) Description:[LoadCtiLibInter]MV_GCSetConfigIntValue is NULL, CTI path[D:\environment\envs\UICreater\lib\site-packages\MvProducerVIR.dll]
Warning 2024-11-07 20:27:31:0202 DevID:Virtual GigE Vision Source-Line:MvCameraControl.dll(GenTLManager.cpp-L0992) ProcessName:python.exe(16960) Description:[GetInterfaceInfos]TLGetInterfaceInfo[INTERFACE_INFO_MODEL] failed, Ret[0x80000001]
Warning 2024-11-07 20:27:31:0202 DevID:Virtual GigE Vision Source-Line:MvCameraControl.dll(GenTLManager.cpp-L0996) ProcessName:python.exe(16960) Description:[GetInterfaceInfos]TLGetInterfaceInfo[INTERFACE_INFO_VERSION] failed, Ret[0x80000001]
Warning 2024-11-07 20:27:31:0202 DevID:Virtual GigE Vision Source-Line:MvCameraControl.dll(GenTLManager.cpp-L1000) ProcessName:python.exe(16960) Description:[GetInterfaceInfos]TLGetInterfaceInfo[INTERFACE_INFO_MANUFACTURER] failed, Ret[0x80000001]
Warning 2024-11-07 20:27:31:0202 DevID:Virtual GigE Vision Source-Line:MvCameraControl.dll(GenTLManager.cpp-L1004) ProcessName:python.exe(16960) Description:[GetInterfaceInfos]TLGetInterfaceInfo[INTERFACE_INFO_USER_DEFINED_NAME] failed, Ret[0x80000001]
Warning 2024-11-07 20:27:31:0202 DevID:Virtual USB3 Vision Source-Line:MvCameraControl.dll(GenTLManager.cpp-L0992) ProcessName:python.exe(16960) Description:[GetInterfaceInfos]TLGetInterfaceInfo[INTERFACE_INFO_MODEL] failed, Ret[0x80000001]
Warning 2024-11-07 20:27:31:0202 DevID:Virtual USB3 Vision Source-Line:MvCameraControl.dll(GenTLManager.cpp-L0996) ProcessName:python.exe(16960) Description:[GetInterfaceInfos]TLGetInterfaceInfo[INTERFACE_INFO_VERSION] failed, Ret[0x80000001]
Warning 2024-11-07 20:27:31:0202 DevID:Virtual USB3 Vision Source-Line:MvCameraControl.dll(GenTLManager.cpp-L1000) ProcessName:python.exe(16960) Description:[GetInterfaceInfos]TLGetInterfaceInfo[INTERFACE_INFO_MANUFACTURER] failed, Ret[0x80000001]
Warning 2024-11-07 20:27:31:0202 DevID:Virtual USB3 Vision Source-Line:MvCameraControl.dll(GenTLManager.cpp-L1004) ProcessName:python.exe(16960) Description:[GetInterfaceInfos]TLGetInterfaceInfo[INTERFACE_INFO_USER_DEFINED_NAME] failed, Ret[0x80000001]
Error 2024-11-21 19:43:31:0867 DevID: Source-Line:MvCameraControl.dll(OtherLoadLibrary.cpp-L0709) ProcessName:python.exe(23792) Description:[LoadSRAllFunctions]hSRModule is NULL, Ret[0x8000000c]
Warning 2024-11-21 19:43:31:0876 DevID: Source-Line:MvCameraControl.dll(GenTLLoadLibraryEx.cpp-L0345) ProcessName:python.exe(23792) Description:[LoadCtiLibInter]MV_GCSetConfigIntValue is NULL, CTI path[D:\environment\envs\UICreater\lib\site-packages\MvProducerVIR.dll]
Warning 2024-11-21 19:43:31:0882 DevID:Virtual GigE Vision Source-Line:MvCameraControl.dll(GenTLManager.cpp-L0992) ProcessName:python.exe(23792) Description:[GetInterfaceInfos]TLGetInterfaceInfo[INTERFACE_INFO_MODEL] failed, Ret[0x80000001]
Warning 2024-11-21 19:43:31:0882 DevID:Virtual GigE Vision Source-Line:MvCameraControl.dll(GenTLManager.cpp-L0996) ProcessName:python.exe(23792) Description:[GetInterfaceInfos]TLGetInterfaceInfo[INTERFACE_INFO_VERSION] failed, Ret[0x80000001]
Warning 2024-11-21 19:43:31:0883 DevID:Virtual GigE Vision Source-Line:MvCameraControl.dll(GenTLManager.cpp-L1000) ProcessName:python.exe(23792) Description:[GetInterfaceInfos]TLGetInterfaceInfo[INTERFACE_INFO_MANUFACTURER] failed, Ret[0x80000001]
Warning 2024-11-21 19:43:31:0883 DevID:Virtual GigE Vision Source-Line:MvCameraControl.dll(GenTLManager.cpp-L1004) ProcessName:python.exe(23792) Description:[GetInterfaceInfos]TLGetInterfaceInfo[INTERFACE_INFO_USER_DEFINED_NAME] failed, Ret[0x80000001]
Warning 2024-11-21 19:43:31:0883 DevID:Virtual USB3 Vision Source-Line:MvCameraControl.dll(GenTLManager.cpp-L0992) ProcessName:python.exe(23792) Description:[GetInterfaceInfos]TLGetInterfaceInfo[INTERFACE_INFO_MODEL] failed, Ret[0x80000001]
Warning 2024-11-21 19:43:31:0883 DevID:Virtual USB3 Vision Source-Line:MvCameraControl.dll(GenTLManager.cpp-L0996) ProcessName:python.exe(23792) Description:[GetInterfaceInfos]TLGetInterfaceInfo[INTERFACE_INFO_VERSION] failed, Ret[0x80000001]
Warning 2024-11-21 19:43:31:0883 DevID:Virtual USB3 Vision Source-Line:MvCameraControl.dll(GenTLManager.cpp-L1000) ProcessName:python.exe(23792) Description:[GetInterfaceInfos]TLGetInterfaceInfo[INTERFACE_INFO_MANUFACTURER] failed, Ret[0x80000001]
Warning 2024-11-21 19:43:31:0883 DevID:Virtual USB3 Vision Source-Line:MvCameraControl.dll(GenTLManager.cpp-L1004) ProcessName:python.exe(23792) Description:[GetInterfaceInfos]TLGetInterfaceInfo[INTERFACE_INFO_USER_DEFINED_NAME] failed, Ret[0x80000001]
Error 2024-11-21 19:44:16:0341 DevID: Source-Line:MvCameraControl.dll(OtherLoadLibrary.cpp-L0709) ProcessName:python.exe(21116) Description:[LoadSRAllFunctions]hSRModule is NULL, Ret[0x8000000c]
Warning 2024-11-21 19:44:16:0343 DevID: Source-Line:MvCameraControl.dll(GenTLLoadLibraryEx.cpp-L0345) ProcessName:python.exe(21116) Description:[LoadCtiLibInter]MV_GCSetConfigIntValue is NULL, CTI path[D:\environment\envs\UICreater\lib\site-packages\MvProducerVIR.dll]
Warning 2024-11-21 19:44:16:0344 DevID:Virtual GigE Vision Source-Line:MvCameraControl.dll(GenTLManager.cpp-L0992) ProcessName:python.exe(21116) Description:[GetInterfaceInfos]TLGetInterfaceInfo[INTERFACE_INFO_MODEL] failed, Ret[0x80000001]
Warning 2024-11-21 19:44:16:0344 DevID:Virtual GigE Vision Source-Line:MvCameraControl.dll(GenTLManager.cpp-L0996) ProcessName:python.exe(21116) Description:[GetInterfaceInfos]TLGetInterfaceInfo[INTERFACE_INFO_VERSION] failed, Ret[0x80000001]
Warning 2024-11-21 19:44:16:0344 DevID:Virtual GigE Vision Source-Line:MvCameraControl.dll(GenTLManager.cpp-L1000) ProcessName:python.exe(21116) Description:[GetInterfaceInfos]TLGetInterfaceInfo[INTERFACE_INFO_MANUFACTURER] failed, Ret[0x80000001]
Warning 2024-11-21 19:44:16:0344 DevID:Virtual GigE Vision Source-Line:MvCameraControl.dll(GenTLManager.cpp-L1004) ProcessName:python.exe(21116) Description:[GetInterfaceInfos]TLGetInterfaceInfo[INTERFACE_INFO_USER_DEFINED_NAME] failed, Ret[0x80000001]
Warning 2024-11-21 19:44:16:0344 DevID:Virtual USB3 Vision Source-Line:MvCameraControl.dll(GenTLManager.cpp-L0992) ProcessName:python.exe(21116) Description:[GetInterfaceInfos]TLGetInterfaceInfo[INTERFACE_INFO_MODEL] failed, Ret[0x80000001]
Warning 2024-11-21 19:44:16:0344 DevID:Virtual USB3 Vision Source-Line:MvCameraControl.dll(GenTLManager.cpp-L0996) ProcessName:python.exe(21116) Description:[GetInterfaceInfos]TLGetInterfaceInfo[INTERFACE_INFO_VERSION] failed, Ret[0x80000001]
Warning 2024-11-21 19:44:16:0344 DevID:Virtual USB3 Vision Source-Line:MvCameraControl.dll(GenTLManager.cpp-L1000) ProcessName:python.exe(21116) Description:[GetInterfaceInfos]TLGetInterfaceInfo[INTERFACE_INFO_MANUFACTURER] failed, Ret[0x80000001]
Warning 2024-11-21 19:44:16:0344 DevID:Virtual USB3 Vision Source-Line:MvCameraControl.dll(GenTLManager.cpp-L1004) ProcessName:python.exe(21116) Description:[GetInterfaceInfos]TLGetInterfaceInfo[INTERFACE_INFO_USER_DEFINED_NAME] failed, Ret[0x80000001]
Error 2024-11-21 20:52:26:0047 DevID: Source-Line:MvCameraControl.dll(OtherLoadLibrary.cpp-L0709) ProcessName:python.exe(15072) Description:[LoadSRAllFunctions]hSRModule is NULL, Ret[0x8000000c]
Warning 2024-11-21 20:52:26:0052 DevID: Source-Line:MvCameraControl.dll(GenTLLoadLibraryEx.cpp-L0345) ProcessName:python.exe(15072) Description:[LoadCtiLibInter]MV_GCSetConfigIntValue is NULL, CTI path[D:\environment\envs\UICreater\lib\site-packages\MvProducerVIR.dll]
Warning 2024-11-21 20:52:26:0056 DevID:Virtual GigE Vision Source-Line:MvCameraControl.dll(GenTLManager.cpp-L0992) ProcessName:python.exe(15072) Description:[GetInterfaceInfos]TLGetInterfaceInfo[INTERFACE_INFO_MODEL] failed, Ret[0x80000001]
Warning 2024-11-21 20:52:26:0056 DevID:Virtual GigE Vision Source-Line:MvCameraControl.dll(GenTLManager.cpp-L0996) ProcessName:python.exe(15072) Description:[GetInterfaceInfos]TLGetInterfaceInfo[INTERFACE_INFO_VERSION] failed, Ret[0x80000001]
Warning 2024-11-21 20:52:26:0056 DevID:Virtual GigE Vision Source-Line:MvCameraControl.dll(GenTLManager.cpp-L1000) ProcessName:python.exe(15072) Description:[GetInterfaceInfos]TLGetInterfaceInfo[INTERFACE_INFO_MANUFACTURER] failed, Ret[0x80000001]
Warning 2024-11-21 20:52:26:0056 DevID:Virtual GigE Vision Source-Line:MvCameraControl.dll(GenTLManager.cpp-L1004) ProcessName:python.exe(15072) Description:[GetInterfaceInfos]TLGetInterfaceInfo[INTERFACE_INFO_USER_DEFINED_NAME] failed, Ret[0x80000001]
Warning 2024-11-21 20:52:26:0056 DevID:Virtual USB3 Vision Source-Line:MvCameraControl.dll(GenTLManager.cpp-L0992) ProcessName:python.exe(15072) Description:[GetInterfaceInfos]TLGetInterfaceInfo[INTERFACE_INFO_MODEL] failed, Ret[0x80000001]
Warning 2024-11-21 20:52:26:0056 DevID:Virtual USB3 Vision Source-Line:MvCameraControl.dll(GenTLManager.cpp-L0996) ProcessName:python.exe(15072) Description:[GetInterfaceInfos]TLGetInterfaceInfo[INTERFACE_INFO_VERSION] failed, Ret[0x80000001]
Warning 2024-11-21 20:52:26:0056 DevID:Virtual USB3 Vision Source-Line:MvCameraControl.dll(GenTLManager.cpp-L1000) ProcessName:python.exe(15072) Description:[GetInterfaceInfos]TLGetInterfaceInfo[INTERFACE_INFO_MANUFACTURER] failed, Ret[0x80000001]
Warning 2024-11-21 20:52:26:0056 DevID:Virtual USB3 Vision Source-Line:MvCameraControl.dll(GenTLManager.cpp-L1004) ProcessName:python.exe(15072) Description:[GetInterfaceInfos]TLGetInterfaceInfo[INTERFACE_INFO_USER_DEFINED_NAME] failed, Ret[0x80000001]

View File

@ -47,7 +47,7 @@ photo_v5 = 0.0
photo_w5 = 1.0
linecount = 2
remain_linename = 1
remain_count = 477
remain_count = 0
solenoid_valve1_addr = 3
solenoid_valve2_addr = 2
solenoid_valve3_addr = 10

View File

@ -1,42 +1,61 @@
import sys
import time
from PySide6.QtWidgets import (
QApplication, QWidget, QHBoxLayout, QVBoxLayout, QPushButton,
QLineEdit, QLabel, QGroupBox, QSpacerItem, QSizePolicy
)
from PySide6.QtGui import QIcon
from PySide6.QtCore import Qt
from PySide6.QtCore import QThread, Signal, Slot
from PySide6.QtWidgets import QMainWindow, QApplication, QLineEdit
from ui_untitled import Ui_MainWindow
class WorkerThread(QThread):
# 定义一个信号,用于在计数完成后发送结果到主线程
result_signal = Signal(int)
finished = Signal()
def run(self):
count = 0
for i in range(1, 11):
count += i
time.sleep(1) # 模拟耗时操作
self.result_signal.emit(count)
# 发射信号
self.finished.emit()
class MainWindow(QMainWindow, Ui_MainWindow):
class OptimizedUI(QWidget):
def __init__(self):
super(MainWindow, self).__init__()
self.setupUi(self)
#self.line = QLineEdit("设置")
super().__init__()
# self.btn_1.clicked.connect(self.start_count)
self.setWindowTitle("UI Optimization")
self.setFixedSize(600, 150)
self.init_ui()
# 创建并启动后台线程
def init_ui(self):
# 主布局
main_layout = QHBoxLayout(self)
main_layout.setSpacing(10)
# 1. 坐标输入框组
coord_group = QGroupBox("坐标")
coord_layout = QVBoxLayout()
for _ in range(2): # 两行坐标输入
row_layout = QHBoxLayout()
for label in ["x", "y", "z"]:
row_layout.addWidget(QLineEdit(), 1)
coord_layout.addLayout(row_layout)
coord_group.setLayout(coord_layout)
if __name__ == '__main__':
# 2. 功能按钮组
button_layout = QVBoxLayout()
get_btn = QPushButton("获取位置")
save_btn = QPushButton("保存位置")
for btn in [get_btn, save_btn]:
btn.setStyleSheet("background-color: #a8e6cf; border-radius: 5px;")
button_layout.addWidget(btn)
# 3. 右侧操作按钮
add_point_btn = QPushButton("添加中间点")
add_point_btn.setIcon(QIcon.fromTheme("list-add"))
add_point_btn.setStyleSheet("background-color: #61c0bf; border-radius: 5px; color: white;")
dropdown_btn = QPushButton("")
dropdown_btn.setFixedWidth(30)
right_layout = QHBoxLayout()
right_layout.addWidget(add_point_btn)
right_layout.addWidget(dropdown_btn)
# 添加控件到主布局
main_layout.addWidget(QPushButton("破碎点"), 1)
main_layout.addWidget(coord_group, 3)
main_layout.addLayout(button_layout, 2)
main_layout.addLayout(right_layout, 2)
if __name__ == "__main__":
import sys
app = QApplication(sys.argv)
win = MainWindow()
win.show()
app.exec()
window = OptimizedUI()
window.show()
sys.exit(app.exec())