米厂码垛修改

This commit is contained in:
2025-09-10 09:16:57 +08:00
parent 2f45c4c38f
commit 65dde435c8
47 changed files with 11258 additions and 10485 deletions

65
.gitignore vendored
View File

@ -1 +1,64 @@
**/__pycache__/
# Python
**/__pycache__/
*.py[cod]
*$py.class
# IDEs and editors
.idea/
.vscode/
*.suo
# *.ntvs*
# *.njsproj
# # *.sln
# *.sw?
# OS generated files
# .DS_Store
# .DS_Store?
# ._*
# .Spotlight-V100
# .Trashes
# ehthumbs.db
# Thumbs.db
# Logs
log/
*.log
*.log.*
# Temporary files
# *.tmp
# *.temp
# .cache/
# Test coverage
# .coverage
# .coverage.*
# coverage.xml
# Debug
# *.pyc
# *.pyd
# *.so
# *.dll
# *.exe
# Runtime data
# pids
# *.pid
# *.seed
# *.pid.lock
# Project specific
# test.py
# test2.py
# test3.py
# test6.py
# TEST3.py
# workflow_test.py
# MvFGSdkLog/
# MvSDKLog/
# Trace/com_pose.txt
# Trace/com_pose2.txt

View File

@ -43,7 +43,7 @@ class TCPClient:
except Exception as e:
self.error_count += 1
if self.error_count> 5:
print("Error: TCPClient is not connected")
print("Error: 机械臂控制程序中TCPClient is not connected")
log.log_message(logging.ERROR,Constant.str_tcp_connect_no_reply)
try:
self.CreatConnect()
@ -51,7 +51,7 @@ class TCPClient:
except OSError as e1:
if e1.errno == 10056:
self.client_socket.close()
print("Error: TCPClient is not connected_1")
print("Error: 机械臂控制程序中TCPClient is not connected_1")
log.log_message(logging.ERROR,Constant.str_tcp_connect_error)
except Exception as e2:
print(e2)

58
CU/CsvToIni.py Normal file
View File

@ -0,0 +1,58 @@
import csv
def format_value(val):
"""格式化值整数保持原样小数保留3位"""
try:
num_val = float(val)
if num_val.is_integer():
return int(num_val)
return round(num_val, 3)
except ValueError:
return val
def csv_to_ini(csv_file, ini_file):
"""
将CSV文件转换为INI格式
:param csv_file: 输入的CSV文件路径
:param ini_file: 输出的INI文件路径
"""
try:
with open(csv_file, 'r', newline='', encoding='utf-8') as csv_input:
# 读取CSV文件
reader = csv.DictReader(csv_input)
# 确定所需字段
required_fields = ['name', 'x', 'y', 'z', 'u', 'v', 'w',
'id', 'order', 'lineid', 'status', 'linetype']
with open(ini_file, 'w', encoding='utf-8') as ini_output:
# 处理每一行数据
for row in reader:
# 检查是否所有必需字段都存在
if not all(field in row for field in required_fields):
missing = [field for field in required_fields if field not in row]
print(f"警告: 行 {reader.line_num} 缺少字段 {', '.join(missing)},跳过该行")
continue
# 写入section头
ini_output.write(f"[{row['name']}]\n")
# 写入数值字段
for field in required_fields[1:]: # 跳过name字段
formatted = format_value(row[field])
ini_output.write(f"{field} = {formatted}\n")
# 区块间添加空行
ini_output.write("\n")
print(f"转换成功INI文件已保存至: {ini_file}")
except Exception as e:
print(f"处理过程中出错: {str(e)}")
if __name__ == "__main__":
# 在此输入您的文件路径
input_csv = "D:/aa.csv" # 替换为实际CSV文件路径
output_ini = "D:/output.ini" # 输出的INI文件路径
csv_to_ini(input_csv, output_ini)

View File

@ -1,6 +1,7 @@
import socket
import binascii
import time
import Constant
# 网络继电器的 IP 和端
HOST = '192.168.0.18'
@ -24,6 +25,8 @@ valve_commands = {
# 将十六进制字符串转换为字节数据并发送
def send_command(command):
if Constant.DebugPosition:
return True
byte_data = binascii.unhexlify(command)
# 创建套接字并连接到继电器
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:

View File

@ -1,4 +1,5 @@
import copy
from dis import stack_effect
import logging
import random
import threading
@ -51,9 +52,13 @@ class FeedStatus(IntEnum):
FStartReverse = 13
class LineType(Enum):
#直线
Straight = 0
#曲线中间点
CureMid = 2
#曲线终点
CureEnd = 3
#关节(自由路径)
WORLD = 4
@ -69,19 +74,25 @@ class FeedPosition:
self.position = position
class FeedLine:
def __init__(self, id, name, feed_positions:list):
def __init__(self, id, name, feed_positions:list,remain_count:int):
self.feed_positions = copy.deepcopy(feed_positions)
self.feeding2end_pos_index = 0
self.origin2start_pos_index = 0
self.start2take_pos_index = 0
self.name = name
self.id = id
self.drop_manager = DropPositionManager("CU/drop.ini")
# 初始化各个阶段的位置列表
self.feeding_to_end = []
# --- 新增:用于存储从 ini 文件读取的多个投料点坐标 ---
# 这个列表将在加载 ini 时填充 [[x1,y1,z1,u1,v1,w1], [x2,y2,z2,u2,v2,w2], ...]
self.drop_point_list = []
self.current_index = 1
#读取码垛点位置
self.current_index = remain_count+1
#记录feed_positions当前扔包点索引
self.current_dropbag_index=0
def get_current_index(self):
return self.current_index
@ -198,6 +209,8 @@ class FeedLine:
path = []
while True:
#current_index,当前扔包点id
#drop.ini定义point1,point2,current_index对应后面的数字
pos_model = self.drop_manager.get_next_drop_position(
self.id,
self.current_index
@ -217,12 +230,13 @@ class FeedLine:
if self.feed_positions[i].status == FeedStatus.FPhoto.value:
index_take = i
# 开始插入动态扔包点,按照 动态扔包中间点,扔包点,动态复位点的顺序
for i in range(len(self.feed_positions)):
if self.feed_positions[i].status == FeedStatus.FDropBag.value:
index_drop = i
# LineID = self.id
#开始插入动态扔包点,按照 动态扔包中间点,扔包点,动态复位点的顺序
#记录feed_positions扔包点初始位置,后续动态增加路径仍从此获取
if self.current_dropbag_index==0:
for i in range(len(self.feed_positions)):
if self.feed_positions[i].status == FeedStatus.FDropBag.value:
self.current_dropbag_index = i
break
# 开始插入动态扔包中间点
@ -230,16 +244,16 @@ class FeedLine:
# 开始插入复位中间点
test_path = self.get_drop_path()
# test_path = self.get_drop_path()
self.origin_to_start = self.feed_positions[: index_start+1]
self.start_to_take = self.feed_positions[index_start:index_take+1]
# 将总list的drop部分替换为动态路径
self.feed_positions = self.feed_positions[:index_drop] + test_path
self.feeding_to_end = self.feed_positions[index_take:index_drop]
print(self.feed_positions)
# self.feed_positions = self.feed_positions[:index_drop] + test_path
# self.feeding_to_end = self.feed_positions[index_take:index_drop]
self.feeding_to_end = self.feed_positions[index_take:]
# print(self.feed_positions)
# for i in range(len(self.feeding_to_end)): #插入动态中间点
# if self.feeding_to_end[i].status == FeedStatus.FTake.value:
@ -252,15 +266,32 @@ class FeedLine:
# self.feeding_to_end.insert(i+2, after_position_model)
# break
def set_feeding_to_end(self):
for i in range(len(self.feed_positions)):
if self.feed_positions[i].status == FeedStatus.FPhoto.value:
index_take = i
break
# 开始插入动态扔包点,按照 动态扔包中间点,扔包点,动态复位点的顺序
# for i in range(len(self.feed_positions)):
# if self.feed_positions[i].status == FeedStatus.FDropBag.value:
# index_drop = i
# break
index_drop=self.current_dropbag_index
test_path = self.get_drop_path()
self.current_index+=1
# 将总list的drop部分替换为动态路径
self.feed_positions = self.feed_positions[:index_drop] + test_path
# self.feeding_to_end = self.feed_positions[index_take:index_drop]
self.feeding_to_end = self.feed_positions[index_take:index_drop]+test_path
class FeedingConfig:
def __init__(self, num: int, feedLine: FeedLine, photo_locs):
def __init__(self, num: int, feedLine: FeedLine, photo_locs,remain_count:int):
#需码垛数量如50或30
self.num = num
#已经码垛数量
self.remain_count=remain_count
self.feedLine = feedLine
self.photo_locs = [self.deal_photo_locs(p) for p in photo_locs]
@ -279,6 +310,8 @@ class Feeding(QObject):
take_no_photo_sigal = Signal()
update_detect_image = Signal(np.ndarray)
log_signal = Signal(int,str)
#码垛完成通知
stack_finish_signal=Signal()
def __init__(self, robotClient: RobotClient):
super().__init__()
self.feedConfig = None
@ -326,7 +359,8 @@ class Feeding(QObject):
def close_feed(self):
self.is_detected = False
self.detect_thread.join()
self.detect.detection.release()
if self.detect.detection:
self.detect.detection.release()
def run_detect(self):
while self.is_detected:
@ -337,13 +371,19 @@ class Feeding(QObject):
self.catch.run()
# 获取事件坐标
real_position = Real_Position()
real_position.init_position(self.robotClient.status_model.world_0,
real_position.init_position_joint_and_world(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)
self.robotClient.status_model.world_5,
self.robotClient.status_model.axis_0,
self.robotClient.status_model.axis_1,
self.robotClient.status_model.axis_2,
self.robotClient.status_model.axis_3,
self.robotClient.status_model.axis_4,
self.robotClient.status_model.axis_5
)
# real_position.init_position(0,
# 0,
# 0,
@ -359,8 +399,9 @@ class Feeding(QObject):
if self.feedConfig == None:
self.feedStatus = FeedStatus.FNone
if self.feedConfig !=None and self.feedConfig.num == 0 and self.is_reverse and self.robotClient.origin_position.compare(real_position,is_action=True):
#
if self.feedConfig !=None and self.is_reverse and real_position.compare(self.robotClient.origin_position,is_action=True):
self.feedStatus = FeedStatus.FNone
self.is_reverse = False
self.log_signal.emit(logging.INFO, Constant.str_feed_reverse)
@ -386,7 +427,7 @@ class Feeding(QObject):
else:
self.feed_Mid_Status = FeedMidStatus.FMid_Take
if self.feedConfig.feedLine.start_to_take[0].get_position().compare(real_position):
if real_position.compare(self.feedConfig.feedLine.start_to_take[0].get_position()):
self.next_position(self.is_reverse)
elif self.feedStatus == FeedStatus.FStart:
@ -394,7 +435,7 @@ class Feeding(QObject):
self.relay_controller.open(conveyor2=True)#开电机
#self.sensor2_thread = threading.Thread(target=self.relay_controller.handle_sensor2, daemon=True)#线程2的开始但是在那里设置结束呢
#self.sensor2_thread.start()
if not self.robotClient.origin_position.compare(real_position,is_action=True) and not self.is_reverse:
if not real_position.compare(self.robotClient.origin_position,is_action=True) and not self.is_reverse:
# QMessageBox.information(None, "提示", Constant.str_feed_start_error) # Fuck 引起异常
self.log_signal.emit(logging.ERROR, Constant.str_feed_start_error)
self.need_origin_signal.emit(Constant.str_feed_start_error)
@ -412,7 +453,7 @@ class Feeding(QObject):
elif self.feedStatus == FeedStatus.FMid:
feed_pos = self.get_current_position(self.is_reverse)
if feed_pos.get_position().compare(real_position):
if real_position.compare(feed_pos.get_position()):
self.log_signal.emit(logging.INFO, Constant.str_feed_mid)
self.next_position(self.is_reverse)
# 增加计数器逻辑
@ -428,18 +469,26 @@ class Feeding(QObject):
#self.catch.catch_status = CatchStatus.CTake
elif self.feedStatus == FeedStatus.FPhoto:
if self.feedConfig.num == 0:
#码垛的数量和配置的数量一致时
if self.feedConfig.remain_count >=self.feedConfig.num:
#关闭,暂停
self.log_signal.emit(logging.INFO, Constant.str_feed_finish)
self.is_reverse = True
self.feed_Mid_Status = FeedMidStatus.FMid_Take
self.feedConfig.feedLine.start2take_pos_index = len(self.feedConfig.feedLine.start_to_take) - 2
self.feedConfig.feedLine.origin2start_pos_index = len(self.feedConfig.feedLine.origin_to_start) - 2
#码垛数量重置
self.feedConfig.remain_count=0
self.next_position(self.is_reverse)
#码垛完成信号通知
self.stack_finish_signal.emit()
self.log_signal.emit(logging.INFO, Constant.str_feed_photo)
return
if not Constant.Debug:
self.log_signal.emit(logging.INFO, Constant.str_feed_takePhoto)
if(self.feed_Mid_Status == FeedMidStatus.FMid_Feed):
self.feedConfig.feedLine.set_feeding_to_end()
self.feed_Mid_Status = FeedMidStatus.FMid_Feed
self.log_signal.emit(logging.INFO, Constant.str_feed_takePhoto_success)
self.feedConfig.feedLine.set_take_position(self.detect.detect_position, 0)
@ -456,10 +505,9 @@ class Feeding(QObject):
else:
self.log_signal.emit(logging.INFO, "⏳ 等待传感器2料包信号...")
time.sleep(1) # 每秒检查一次
self.next_position()
self.log_signal.emit(logging.INFO, Constant.str_sys_runing2)
# self.feedStatus = FeedStatus.FTake
elif self.feedStatus == FeedStatus.FTake:
@ -468,7 +516,7 @@ class Feeding(QObject):
if not take_position or not take_position.get_position():
self.log_signal.emit(logging.ERROR, Constant.str_feed_takePhoto_fail)
return
if not take_position.get_position().compare(real_position, is_action=True):
if not real_position.compare(take_position.get_position(), is_action=True):
self.log_signal.emit(logging.INFO, "机器人尚未到达抓料点位")
return
self.log_signal.emit(logging.INFO, "机器人已到达抓料点位")
@ -500,21 +548,19 @@ class Feeding(QObject):
elif self.feedStatus == FeedStatus.FBroken1:
if self.get_current_position().get_position().compare(real_position):
if real_position.compare(self.get_current_position().get_position()):
self.log_signal.emit(logging.INFO, Constant.str_feed_broken)
self.next_position()
elif self.feedStatus == FeedStatus.FDropMid:
if self.get_current_position().get_position().compare(real_position):
self.log_signal.emit(logging.INFO, Constant.str_feed_broken)
self.next_position()
else:
if real_position.compare(self.get_current_position().get_position(),is_action=True):
self.log_signal.emit(logging.INFO, Constant.str_feed_drop_mid)
self.next_position()
elif self.feedStatus == FeedStatus.FShake:
if self.get_current_position().get_position().compare(real_position,is_action=True):
if real_position.compare(self.get_current_position().get_position(),is_action=True):
# TODO 震动方案
self.log_signal.emit(logging.INFO, Constant.str_feed_shake)
if self.catch.catch_status == CatchStatus.CNone:
@ -537,13 +583,14 @@ class Feeding(QObject):
# get_current_position() 会根据 self.feed_Mid_Status (应为 FMid_Feed)
# 调用 feedLine.get_current_feed_position(),从 feeding_to_end 列表获取
# 由 feeding2end_pos_index 指向的点。
if self.get_current_position().get_position().compare(real_position, is_action=True):
if real_position.compare(self.get_current_position().get_position(),is_action=True):
# 2. 记录日志:已到达投料点
#if not self.sensor2_ready:
#self.log_signal.emit(logging.INFO, "抓取完成,重新启动 conveyor2")
#self.relay_controller.open(conveyor2=True)
self.log_signal.emit(logging.INFO, Constant.str_feed_drop)
# 3. 与 Catch 模块进行状态交互来驱动投料动作
# a. 初始状态 (CNone): 触发投料动作
@ -567,15 +614,21 @@ class Feeding(QObject):
# (后续增加) 视觉确认: 拍照确认袋子已放置
# self.detection.get_position(...)
# self.feedConfig.feedLine.set_take_position(...)
# 4. 更新业务逻辑:减少剩余袋数
self.feedConfig.num = self.feedConfig.num - 1
self.log_signal.emit(logging.INFO, f'{Constant.str_feed_feed_num}{self.feedConfig.num}')
# 码垛数量增加
self.feedConfig.remain_count = self.feedConfig.remain_count + 1
# self.feedConfig.num = self.feedConfig.num - 1
self.log_signal.emit(logging.INFO, f'{Constant.str_feed_feed_num}{self.feedConfig.remain_count}')
# 5. *** 关键步骤 ***: 移动到路径中的下一个点
# next_position() 会根据当前的 feed_Mid_Status (FMid_Feed)
# 调用 next_Feed()。
self.next_position()
elif self.feedStatus == FeedStatus.FDropReset:
self.next_position()
elif self.feedStatus == FeedStatus.FDropReset:
if real_position.compare(self.get_current_position().get_position()):
self.log_signal.emit(logging.INFO, Constant.str_feed_drop_reset)
self.next_position()
elif self.feedStatus == None:
print(self.feedStatus)
@ -583,12 +636,18 @@ class Feeding(QObject):
def run_reset(self):
real_position = Real_Position()
real_position.init_position(self.robotClient.status_model.world_0,
real_position.init_position_joint_and_world(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)
self.robotClient.status_model.world_5,
self.robotClient.status_model.axis_0,
self.robotClient.status_model.axis_1,
self.robotClient.status_model.axis_2,
self.robotClient.status_model.axis_3,
self.robotClient.status_model.axis_4,
self.robotClient.status_model.axis_5)
if self.reset_status == ResetStatus.RNone:
return
@ -601,7 +660,7 @@ class Feeding(QObject):
self.pos_near_index = -1
self.reversed_positions = []
for index, pos_model in enumerate(self.feedConfig.feedLine.feed_positions):
if pos_model.get_position().compare(real_position,is_action=True):
if real_position.compare(pos_model.get_position(),is_action=True):
self.pos_index = index
break
@ -639,6 +698,11 @@ class Feeding(QObject):
real_position1=pos_model1.get_position(), speed=self.robotClient.reset_speed)
self.current_position = pos_model1
self.reverse_index = self.reverse_index + 2
elif pos_model.lineType==LineType.WORLD.value:
#关节移动
self.sendTargPosition(real_position=pos_model.get_position(), speed=self.robotClient.reset_speed,move_type=MoveType.AXIS)
self.current_position = pos_model
self.reverse_index = self.reverse_index + 1
else:
self.sendTargPosition(real_position=pos_model.get_position(), speed=self.robotClient.reset_speed)
self.current_position = pos_model
@ -654,12 +718,18 @@ class Feeding(QObject):
self.run_reverse = True
real_position = Real_Position()
real_position.init_position(self.robotClient.status_model.world_0,
real_position.init_position_joint_and_world(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)
self.robotClient.status_model.world_5,
self.robotClient.status_model.axis_0,
self.robotClient.status_model.axis_1,
self.robotClient.status_model.axis_2,
self.robotClient.status_model.axis_3,
self.robotClient.status_model.axis_4,
self.robotClient.status_model.axis_5)
if self.feedConfig == None: return
start_index = -1
# for index in range(len(self.feedConfig.feedLine.positions)):
@ -669,7 +739,7 @@ class Feeding(QObject):
pos_near_index = -1
reversed_positions = []
for index, pos_model in enumerate(self.feedConfig.feedLine.feed_positions):
if pos_model.get_position().compare(real_position):
if real_position.compare(pos_model.get_position()):
pos_index = index
break
@ -769,9 +839,8 @@ class Feeding(QObject):
try:
print('fuck1',log_str)
self.log_signal.emit(logging.INFO, log_str)
print('fuck2',log_str)
print(log_str)
except:
return
print(request_command)
@ -843,8 +912,8 @@ class Feeding(QObject):
self.sendTargPosition(real_position=feed_pos.get_position(), move_type=MoveType.Cure, real_position1=feed_pos1.get_position(),speed=self.robotClient.feed_speed)
elif feed_pos.lineType == LineType.WORLD.value:
# 暂时不考虑世界坐标到关节坐标的转换,强行不判断接近
feed_pos1 = self.feedConfig.feedLine.get_next_feed_position(reverse)
self.feedStatus = FeedStatus(feed_pos1.status) if self.feedStatus != FeedStatus.FNone else FeedStatus.FNone
# feed_pos1 = self.feedConfig.feedLine.get_next_feed_position(reverse)
# self.feedStatus = FeedStatus(feed_pos1.status) if self.feedStatus != FeedStatus.FNone else FeedStatus.FNone
self.sendTargPosition(real_position=feed_pos.get_position(), speed=self.robotClient.feed_speed,
move_type=MoveType.AXIS)

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

922
CU/drop copy.ini Normal file
View File

@ -0,0 +1,922 @@
[DropLine1]
id = 1
name = 50kg码垛路径
current_index = 22
[DropLine2]
id = 2
name = 35kg码垛路径
current_index = 0
[DropMidPoint1-1]
x = 15.3
y = -84
z = -91.0
u = 2.145
v = 0
w = 0
id = 1
order = 0
lineid = 1
status = 7
linetype = 4
[DropMidPoint1-2]
x = 15.3
y = -184
z = -91.0
u = 2.145
v = 0
w = 0
id = 1
order = 0
lineid = 1
status = 7
linetype = 4
[DropMidPoint1-3]
x = 15.3
y = -284
z = -91.0
u = 2.145
v = 0
w = 0
id = 1
order = 0
lineid = 1
status = 7
linetype = 4
[DropPoints1]
x = 15.3
y = -384
z = -91.0
u = 2.145
v = 0
w = 0
id = 1
order = 1
lineid = 1
status = 9
linetype = 4
[ResetPoint1-3]
x = 15.3
y = -684
z = -91.0
u = 2.145
v = 0
w = 0
id = 1
order = 0
lineid = 1
status = 10
linetype = 4
[ResetPoint1-2]
x = 15.3
y = -584
z = -91.0
u = 2.145
v = 0
w = 0
id = 1
order = 0
lineid = 1
status = 10
linetype = 4
[ResetPoint1-1]
x = 15.3
y = -484
z = -91.0
u = 2.145
v = 0
w = 0
id = 1
order = 0
lineid = 1
status = 10
linetype = 4
[DropMidPoint2-1]
x = 5.7
y = -84
z = -91.0
u = 2.145
v = 0
w = 0
id = 2
order = 0
lineid = 1
status = 7
linetype = 4
[DropMidPoint2-2]
x = 5.7
y = -184
z = -91.0
u = 2.145
v = 0
w = 0
id = 2
order = 0
lineid = 1
status = 7
linetype = 4
[DropMidPoint2-3]
x = 5.7
y = -284
z = -91.0
u = 2.145
v = 0
w = 0
id = 2
order = 0
lineid = 1
status = 7
linetype = 4
[DropPoints2]
x = 5.7
y = -384
z = -91.0
u = 2.145
v = 0
w = 0
id = 2
order = 1
lineid = 1
status = 9
linetype = 4
[ResetPoint2-3]
x = 5.7
y = -684
z = -91.0
u = 2.145
v = 0
w = 0
id = 2
order = 0
lineid = 1
status = 10
linetype = 4
[ResetPoint2-2]
x = 5.7
y = -584
z = -91.0
u = 2.145
v = 0
w = 0
id = 2
order = 0
lineid = 1
status = 10
linetype = 4
[ResetPoint2-1]
x = 5.7
y = -484
z = -91.0
u = 2.145
v = 0
w = 0
id = 2
order = 0
lineid = 1
status = 10
linetype = 4
[DropMidPoint3-1]
x = 7.2
y = -84
z = -91.0
u = 2.145
v = 0
w = 0
id = 1
order = 0
lineid = 1
status = 7
linetype = 4
action =
[DropMidPoint3-2]
x = 7.2
y = -184
z = -91.0
u = 2.145
v = 0
w = 0
id = 1
order = 0
lineid = 1
status = 7
linetype = 4
[DropMidPoint3-3]
x = 7.2
y = -284
z = -91.0
u = 2.145
v = 0
w = 0
id = 1
order = 0
lineid = 1
status = 7
linetype = 4
[DropPoints3]
x = 7.2
y = -384
z = -91.0
u = 2.145
v = 0
w = 0
id = 1
order = 1
lineid = 1
status = 9
linetype = 4
[ResetPoint3-3]
x = 7.2
y = -684
z = -91.0
u = 2.145
v = 0
w = 0
id = 1
order = 0
lineid = 1
status = 10
linetype = 4
[ResetPoint3-2]
x = 7.2
y = -584
z = -91.0
u = 2.145
v = 0
w = 0
id = 1
order = 0
lineid = 1
status = 10
linetype = 4
[ResetPoint3-1]
x = 7.2
y = -484
z = -91.0
u = 2.145
v = 0
w = 0
id = 1
order = 0
lineid = 1
status = 10
linetype = 4
[DropMidPoint4-1]
x = 7.3
y = -84
z = -91.0
u = 2.145
v = 0
w = 0
id = 2
order = 0
lineid = 1
status = 7
linetype = 4
[DropMidPoint4-2]
x = 7.3
y = -184
z = -91.0
u = 2.145
v = 0
w = 0
id = 2
order = 0
lineid = 1
status = 7
linetype = 4
[DropMidPoint4-3]
x = 7.3
y = -284
z = -91.0
u = 2.145
v = 0
w = 0
id = 2
order = 0
lineid = 1
status = 7
linetype = 4
[DropPoints4]
x = 7.3
y = -384
z = -91.0
u = 2.145
v = 0
w = 0
id = 2
order = 1
lineid = 1
status = 9
linetype = 4
[ResetPoint4-3]
x = 7.3
y = -684
z = -91.0
u = 2.145
v = 0
w = 0
id = 2
order = 0
lineid = 1
status = 10
linetype = 4
[ResetPoint4-2]
x = 7.3
y = -584
z = -91.0
u = 2.145
v = 0
w = 0
id = 2
order = 0
lineid = 1
status = 10
linetype = 4
[ResetPoint4-1]
x = 7.3
y = -484
z = -91.0
u = 2.145
v = 0
w = 0
id = 2
order = 0
lineid = 1
status = 10
linetype = 4
[DropMidPoint5-1]
x = 15.3
y = -84
z = -91.0
u = 2.145
v = 0
w = 0
id = 1
order = 0
lineid = 1
status = 7
linetype = 4
[DropMidPoint5-2]
x = 15.3
y = -184
z = -91.0
u = 2.145
v = 0
w = 0
id = 1
order = 0
lineid = 1
status = 7
linetype = 4
[DropMidPoint5-3]
x = 15.3
y = -284
z = -91.0
u = 2.145
v = 0
w = 0
id = 1
order = 0
lineid = 1
status = 7
linetype = 4
[DropPoints5]
x = 15.3
y = -384
z = -91.0
u = 2.145
v = 0
w = 0
id = 1
order = 1
lineid = 1
status = 9
linetype = 4
[ResetPoint5-3]
x = 15.3
y = -684
z = -91.0
u = 2.145
v = 0
w = 0
id = 1
order = 0
lineid = 1
status = 10
linetype = 4
[ResetPoint5-2]
x = 15.3
y = -584
z = -91.0
u = 2.145
v = 0
w = 0
id = 1
order = 0
lineid = 1
status = 10
linetype = 4
[ResetPoint5-1]
x = 15.3
y = -484
z = -91.0
u = 2.145
v = 0
w = 0
id = 1
order = 0
lineid = 1
status = 10
linetype = 4
[DropMidPoint6-1]
x = 5.7
y = -84
z = -91.0
u = 2.145
v = 0
w = 0
id = 2
order = 0
lineid = 1
status = 7
linetype = 4
[DropMidPoint6-2]
x = 5.7
y = -184
z = -91.0
u = 2.145
v = 0
w = 0
id = 2
order = 0
lineid = 1
status = 7
linetype = 4
[DropMidPoint6-3]
x = 5.7
y = -284
z = -91.0
u = 2.145
v = 0
w = 0
id = 2
order = 0
lineid = 1
status = 7
linetype = 4
[DropPoints6]
x = 5.7
y = -384
z = -91.0
u = 2.145
v = 0
w = 0
id = 2
order = 1
lineid = 1
status = 9
linetype = 4
[ResetPoint6-3]
x = 5.7
y = -684
z = -91.0
u = 2.145
v = 0
w = 0
id = 2
order = 0
lineid = 1
status = 10
linetype = 4
[ResetPoint6-2]
x = 5.7
y = -584
z = -91.0
u = 2.145
v = 0
w = 0
id = 2
order = 0
lineid = 1
status = 10
linetype = 4
[ResetPoint6-1]
x = 5.7
y = -484
z = -91.0
u = 2.145
v = 0
w = 0
id = 2
order = 0
lineid = 1
status = 10
linetype = 4
[DropMidPoint7-1]
x = 7.2
y = -84
z = -91.0
u = 2.145
v = 0
w = 0
id = 1
order = 0
lineid = 1
status = 7
linetype = 4
action =
[DropMidPoint7-2]
x = 7.2
y = -184
z = -91.0
u = 2.145
v = 0
w = 0
id = 1
order = 0
lineid = 1
status = 7
linetype = 4
[DropMidPoint7-3]
x = 7.2
y = -284
z = -91.0
u = 2.145
v = 0
w = 0
id = 1
order = 0
lineid = 1
status = 7
linetype = 4
[DropPoints7]
x = 7.2
y = -384
z = -91.0
u = 2.145
v = 0
w = 0
id = 1
order = 1
lineid = 1
status = 9
linetype = 4
[ResetPoint7-3]
x = 7.2
y = -684
z = -91.0
u = 2.145
v = 0
w = 0
id = 1
order = 0
lineid = 1
status = 10
linetype = 4
[ResetPoint7-2]
x = 7.2
y = -584
z = -91.0
u = 2.145
v = 0
w = 0
id = 1
order = 0
lineid = 1
status = 10
linetype = 4
[ResetPoint7-1]
x = 7.2
y = -484
z = -91.0
u = 2.145
v = 0
w = 0
id = 1
order = 0
lineid = 1
status = 10
linetype = 4
[DropMidPoint8-1]
x = 7.3
y = -84
z = -91.0
u = 2.145
v = 0
w = 0
id = 2
order = 0
lineid = 1
status = 7
linetype = 4
[DropMidPoint8-2]
x = 7.3
y = -184
z = -91.0
u = 2.145
v = 0
w = 0
id = 2
order = 0
lineid = 1
status = 7
linetype = 4
[DropMidPoint8-3]
x = 7.3
y = -284
z = -91.0
u = 2.145
v = 0
w = 0
id = 2
order = 0
lineid = 1
status = 7
linetype = 4
[DropPoints8]
x = 7.3
y = -384
z = -91.0
u = 2.145
v = 0
w = 0
id = 2
order = 1
lineid = 1
status = 9
linetype = 4
[ResetPoint8-3]
x = 7.3
y = -684
z = -91.0
u = 2.145
v = 0
w = 0
id = 2
order = 0
lineid = 1
status = 10
linetype = 4
[ResetPoint8-2]
x = 7.3
y = -584
z = -91.0
u = 2.145
v = 0
w = 0
id = 2
order = 0
lineid = 1
status = 10
linetype = 4
[ResetPoint8-1]
x = 7.3
y = -484
z = -91.0
u = 2.145
v = 0
w = 0
id = 2
order = 0
lineid = 1
status = 10
linetype = 4
[DropMidPoint9-1]
x = 15.3
y = -84
z = -91.0
u = 2.145
v = 0
w = 0
id = 1
order = 0
lineid = 1
status = 7
linetype = 4
[DropMidPoint9-2]
x = 15.3
y = -184
z = -91.0
u = 2.145
v = 0
w = 0
id = 1
order = 0
lineid = 1
status = 7
linetype = 4
[DropMidPoint9-3]
x = 15.3
y = -284
z = -91.0
u = 2.145
v = 0
w = 0
id = 1
order = 0
lineid = 1
status = 7
linetype = 4
[DropPoints9]
x = 15.3
y = -384
z = -91.0
u = 2.145
v = 0
w = 0
id = 1
order = 1
lineid = 1
status = 9
linetype = 4
[ResetPoint9-3]
x = 15.3
y = -684
z = -91.0
u = 2.145
v = 0
w = 0
id = 1
order = 0
lineid = 1
status = 10
linetype = 4
[ResetPoint9-2]
x = 15.3
y = -584
z = -91.0
u = 2.145
v = 0
w = 0
id = 1
order = 0
lineid = 1
status = 10
linetype = 4
[ResetPoint9-1]
x = 15.3
y = -484
z = -91.0
u = 2.145
v = 0
w = 0
id = 1
order = 0
lineid = 1
status = 10
linetype = 4
[DropMidPoint10-1]
x = 5.7
y = -84
z = -91.0
u = 2.145
v = 0
w = 0
id = 2
order = 0
lineid = 1
status = 7
linetype = 4
[DropMidPoint10-2]
x = 5.7
y = -184
z = -91.0
u = 2.145
v = 0
w = 0
id = 2
order = 0
lineid = 1
status = 7
linetype = 4
[DropMidPoint10-3]
x = 5.7
y = -284
z = -91.0
u = 2.145
v = 0
w = 0
id = 2
order = 0
lineid = 1
status = 7
linetype = 4
[DropPoints10]
x = 5.7
y = -384
z = -91.0
u = 2.145
v = 0
w = 0
id = 2
order = 1
lineid = 1
status = 9
linetype = 4
[ResetPoint10-3]
x = 5.7
y = -684
z = -91.0
u = 2.145
v = 0
w = 0
id = 2
order = 0
lineid = 1
status = 10
linetype = 4
[ResetPoint10-2]
x = 5.7
y = -584
z = -91.0
u = 2.145
v = 0
w = 0
id = 2
order = 0
lineid = 1
status = 10
linetype = 4
[ResetPoint10-1]
x = 5.7
y = -484
z = -91.0
u = 2.145
v = 0
w = 0
id = 2
order = 0
lineid = 1
status = 10
linetype = 4

View File

@ -9,366 +9,456 @@ name = 35kg码垛路径
current_index = 0
[DropMidPoint1-1]
x = 15.3
y = -84
z = -91.0
u = 2.145
x = -21.648
y = -20
z = 98.003
u = -225.353
v = 0
w = 0
id = 1
order = 0
lineid = 1
status = 7
linetype = 0
linetype = 4
[DropMidPoint1-2]
x = 15.3
y = -184
z = -91.0
u = 2.145
x = -21.648
y = -20
z = 98.003
u = -225.353
v = 0
w = 0
id = 1
order = 0
lineid = 1
status = 7
linetype = 0
linetype = 4
[DropMidPoint1-3]
x = 15.3
y = -284
z = -91.0
u = 2.145
x = -21.648
y = -20
z = 98.003
u = -225.353
v = 0
w = 0
id = 1
order = 0
lineid = 1
status = 7
linetype = 0
linetype = 4
[DropPoints1]
x = 15.3
y = -384
z = -91.0
u = 2.145
x = -92.53
y = -450
z = 118.729
u = -174.68
v = 0
w = 0
id = 1
order = 1
lineid = 1
status = 9
linetype = 0
linetype = 4
[ResetPoint1-3]
x = 15.3
y = -684
z = -91.0
u = 2.145
x = -44.431
y = -189.009
z = -80.5
u = 51.386
v = 0
w = 0
id = 1
order = 0
lineid = 1
status = 11
linetype = 0
status = 10
linetype = 4
[ResetPoint1-2]
x = 15.3
y = -584
z = -91.0
u = 2.145
x = -44.431
y = -189.009
z = -80.5
u = 51.386
v = 0
w = 0
id = 1
order = 0
lineid = 1
status = 11
linetype = 0
status = 10
linetype = 4
[ResetPoint1-1]
x = 15.3
y = -484
z = -91.0
u = 2.145
x = -44.431
y = -189.009
z = -80.5
u = 51.386
v = 0
w = 0
id = 1
order = 0
lineid = 1
status = 11
linetype = 0
status = 10
linetype = 4
[DropMidPoint2-1]
x = 1379.783
y = -403.215
z = -200.0
u = 18.350
v = -0.985981
w = -125.710434
id = 2
x = -21.648
y = -20
z = 98.003
u = -225.353
v = 0
w = 0
id = 1
order = 0
lineid = 1
status = 7
linetype = 0
linetype = 4
[DropMidPoint2-2]
x = 1379.783
y = -403.215
z = -250.0
u = 18.350
v = -0.985981
w = -125.710434
id = 2
x = -21.648
y = -20
z = 98.003
u = -225.353
v = 0
w = 0
id = 1
order = 0
lineid = 1
status = 7
linetype = 0
linetype = 4
[DropMidPoint2-3]
x = 1379.783
y = -403.215
z = -300.0
u = 18.350
v = -0.985981
w = -125.710434
id = 2
x = -21.648
y = -20
z = 98.003
u = -225.353
v = 0
w = 0
id = 1
order = 0
lineid = 1
status = 7
linetype = 0
linetype = 4
[DropPoints2]
x = 1379.783
y = -403.215
z = -334.279
u = 18.350
v = -0.985981
w = -125.710434
id = 2
x = -20.149
y = -450
z = 105.28
u = -233.612
v = 0
w = 0
id = 1
order = 1
lineid = 1
status = 9
linetype = 0
linetype = 4
[ResetPoint2-3]
x = 1379.783
y = -403.215
z = -366.0
u = 18.350
v = -0.985981
w = -125.710434
id = 2
x = -44.431
y = -189.009
z = -80.5
u = 51.386
v = 0
w = 0
id = 1
order = 0
lineid = 1
status = 11
linetype = 0
status = 10
linetype = 4
[ResetPoint2-2]
x = 1379.783
y = -403.215
z = -466.0
u = 18.350
v = -0.985981
w = -125.710434
id = 2
x = -44.431
y = -189.009
z = -80.5
u = 51.386
v = 0
w = 0
id = 1
order = 0
lineid = 1
status = 11
linetype = 0
status = 10
linetype = 4
[ResetPoint2-1]
x = 1379.783
y = -403.215
z = -566.0
u = 18.350
v = -0.985981
w = -125.710434
id = 2
x = -44.431
y = -189.009
z = -80.5
u = 51.386
v = 0
w = 0
id = 1
order = 0
lineid = 1
status = 11
linetype = 0
status = 10
linetype = 4
[DropMidPoint3-1]
x = 1379.783
y = -403.215
z = -500.0
u = 18.350
v = -0.985981
w = -125.710434
x = -21.648
y = -20
z = 98.003
u = -225.353
v = 0
w = 0
id = 1
order = 0
lineid = 1
status = 7
linetype = 0
action =
linetype = 4
[DropMidPoint3-2]
x = 1379.783
y = -403.215
z = -400.0
u = 18.350
v = -0.985981
w = -125.710434
x = -21.648
y = -20
z = 98.003
u = -225.353
v = 0
w = 0
id = 1
order = 0
lineid = 1
status = 7
linetype = 0
linetype = 4
[DropMidPoint3-3]
x = 1379.783
y = -403.215
z = -300.0
u = 18.350
v = -0.985981
w = -125.710434
x = -21.648
y = -20
z = 98.003
u = -225.353
v = 0
w = 0
id = 1
order = 0
lineid = 1
status = 7
linetype = 0
linetype = 4
[DropPoints3]
x = 1379.783
y = -403.215
z = -334.279
u = 18.350
v = -0.985981
w = -125.710434
x = -61.092
y = -450
z = 123.624
u = -211.012
v = 0
w = 0
id = 1
order = 1
lineid = 1
status = 9
linetype = 0
linetype = 4
[ResetPoint3-3]
x = 1379.783
y = -403.215
z = -200.0
u = 18.350
v = -0.985981
w = -125.710434
x = -44.431
y = -189.009
z = -80.5
u = 51.386
v = 0
w = 0
id = 1
order = 0
lineid = 1
status = 11
linetype = 0
status = 10
linetype = 4
[ResetPoint3-2]
x = 1379.783
y = -403.215
z = -100.0
u = 18.350
v = -0.985981
w = -125.710434
x = -44.431
y = -189.009
z = -80.5
u = 51.386
v = 0
w = 0
id = 1
order = 0
lineid = 1
status = 11
linetype = 0
status = 10
linetype = 4
[ResetPoint3-1]
x = 1379.783
y = -403.215
z = -50.0
u = 18.350
v = -0.985981
w = -125.710434
x = -44.431
y = -189.009
z = -80.5
u = 51.386
v = 0
w = 0
id = 1
order = 0
lineid = 1
status = 11
linetype = 0
status = 10
linetype = 4
[DropMidPoint4-1]
x = 1379.783
y = -403.215
z = -200.0
u = 18.350
v = -0.985981
w = -125.710434
id = 2
x = -21.648
y = -20
z = 98.003
u = -225.353
v = 0
w = 0
id = 1
order = 0
lineid = 1
status = 7
linetype = 0
linetype = 4
[DropMidPoint4-2]
x = 1379.783
y = -403.215
z = -250.0
u = 18.350
v = -0.985981
w = -125.710434
id = 2
x = -21.648
y = -20
z = 98.003
u = -225.353
v = 0
w = 0
id = 1
order = 0
lineid = 1
status = 7
linetype = 0
linetype = 4
[DropMidPoint4-3]
x = 1379.783
y = -403.215
z = -300.0
u = 18.350
v = -0.985981
w = -125.710434
id = 2
x = -21.648
y = -20
z = 98.003
u = -225.353
v = 0
w = 0
id = 1
order = 0
lineid = 1
status = 7
linetype = 0
linetype = 4
[DropPoints4]
x = 1379.783
y = -403.215
z = -334.279
u = 18.350
v = -0.985981
w = -125.710434
id = 2
x = -37.169
y = -450
z = 49.085
u = -70.397
v = 0
w = 0
id = 1
order = 1
lineid = 1
status = 9
linetype = 0
linetype = 4
[ResetPoint4-3]
x = 1379.783
y = -403.215
z = -366.0
u = 18.350
v = -0.985981
w = -125.710434
id = 2
x = -44.431
y = -189.009
z = -80.5
u = 51.386
v = 0
w = 0
id = 1
order = 0
lineid = 1
status = 11
linetype = 0
status = 10
linetype = 4
[ResetPoint4-2]
x = 1379.783
y = -403.215
z = -466.0
u = 18.350
v = -0.985981
w = -125.710434
id = 2
x = -44.431
y = -189.009
z = -80.5
u = 51.386
v = 0
w = 0
id = 1
order = 0
lineid = 1
status = 11
linetype = 0
status = 10
linetype = 4
[ResetPoint4-1]
x = 1379.783
y = -403.215
z = -566.0
u = 18.350
v = -0.985981
w = -125.710434
id = 2
x = -44.431
y = -189.009
z = -80.5
u = 51.386
v = 0
w = 0
id = 1
order = 0
lineid = 1
status = 11
linetype = 0
status = 10
linetype = 4
[DropMidPoint5-1]
x = -21.648
y = -20
z = 98.003
u = -225.353
v = 0
w = 0
id = 1
order = 0
lineid = 1
status = 7
linetype = 4
[DropMidPoint5-2]
x = -21.648
y = -20
z = 98.003
u = -225.353
v = 0
w = 0
id = 1
order = 0
lineid = 1
status = 7
linetype = 4
[DropMidPoint5-3]
x = -21.648
y = -20
z = 98.003
u = -225.353
v = 0
w = 0
id = 1
order = 0
lineid = 1
status = 7
linetype = 4
[DropPoints5]
x = 2.48
y = -450
z = 33.293
u = -274.256
v = 0
w = 0
id = 1
order = 1
lineid = 1
status = 9
linetype = 4
[ResetPoint5-3]
x = -44.431
y = -189.009
z = -80.5
u = 51.386
v = 0
w = 0
id = 1
order = 0
lineid = 1
status = 10
linetype = 4
[ResetPoint5-2]
x = -44.431
y = -189.009
z = -80.5
u = 51.386
v = 0
w = 0
id = 1
order = 0
lineid = 1
status = 10
linetype = 4
[ResetPoint5-1]
x = -44.431
y = -189.009
z = -80.5
u = 51.386
v = 0
w = 0
id = 1
order = 0
lineid = 1
status = 10
linetype = 4

View File

@ -1,62 +0,0 @@
[DropLine1]
id = 1
name = 50kg码垛路径
current_index = 68
[DropLine2]
id = 2
name = 35kg码垛路径
current_index = 0
[DropPoints1]
x = 1067.078247
y = -919.529846
z = -189.15361
u = -97.082031
v = -0.985981
w = -125.710434
id = 3
order = 0
lineid = 1
status = 9
linetype = 0
[DropPoints2]
x = -187.124695
y = -1400.483765
z = -839.763611
u = -97.082031
v = -0.985981
w = -125.710434
id = 3
order = 1
lineid = 1
status = 9
linetype = 0
[DropPoints3]
x = 1069.078247
y = -919.529846
z = -500.15361
u = -97.082031
v = -0.985981
w = -125.710434
id = 3
order = 2
lineid = 1
status = 9
linetype = 0
[DropPoints4]
x = -187.124695
y = -1400.483765
z = -839.763611
u = -97.082031
v = -0.985981
w = -125.710434
id = 3
order = 3
lineid = 1
status = 9
linetype = 0

View File

@ -1,5 +1,4 @@
# File: drop_position_manager.py
from ast import mod
import configparser
import os
from typing import Optional
@ -19,11 +18,14 @@ class DropPositionManager:
self._current_path: list = [] # 当前路径点列表
self._current_index: int = 0 # 当前路径中的索引
def _load_config(self):
"""加载配置文件"""
if not os.path.exists(self.config_path):
raise FileNotFoundError(f"配置文件不存在: {self.config_path}")
self.config.read(self.config_path, encoding='utf-8')
def get_next_drop_position(self, lineid: int, point: int) -> Optional[PositionModel]:
"""
获取指定 lineid 和 point 的下一个路径点。
@ -53,7 +55,8 @@ class DropPositionManager:
return None
def _load_point_path(self, lineid: int, point_id: int):
"""加载指定 lineid 和 point_id 的完整路径"""
"""加载指定 lineid 和 point_id 的完整路径
(点集合dropmidpoint、droppoint、resetpoint)"""
self._current_path = []
# 检查是否存在 DropPoints{point_id}
@ -99,31 +102,33 @@ class DropPositionManager:
# 3. 组装路径
# a. DropMidPoint
for _, pos in mid_points:
model = PositionModel()
model.init_position(pos)
model.status = 7 # FMid
model.lineType = 4 # WORLD
self._current_path.append(model)
# model = PositionModel()
# model.init_position(pos)
# model.status = 7 # FMid
# model.lineType = 4 # WORLD
self._current_path.append(pos)
# b. DropPoints
main_model = PositionModel()
main_model.init_position(drop_pos)
main_model.status = 9 # FDropBag
main_model.lineType = 4
self._current_path.append(main_model)
# main_model = PositionModel()
# main_model.init_position(drop_pos)
# main_model.status = 9 # FDropBag
# main_model.lineType = 4
self._current_path.append(drop_pos)
# c. ResetPoint
for _, pos in reset_points:
model = PositionModel()
model.init_position(pos)
model.status = 11 # FReverse
model.lineType = 4
self._current_path.append(model)
# model = PositionModel()
# model.init_position(pos)
# model.status = 10 # FReverse
# model.lineType = 4
self._current_path.append(pos)
print(f"✅ 已加载 DropLine{lineid} 中 DropPoints{point_id} 的路径,共 {len(self._current_path)} 个点")
def _read_position_from_section(self, section: str) -> Real_Position:
def _read_position_from_section(self, section: str) -> PositionModel:
"""从配置文件的 section 中读取位置信息"""
model = PositionModel()
pos = Real_Position()
pos.X = self.config.getfloat(section, "x")
pos.Y = self.config.getfloat(section, "y")
@ -131,7 +136,14 @@ class DropPositionManager:
pos.U = self.config.getfloat(section, "u")
pos.V = self.config.getfloat(section, "v")
pos.W = self.config.getfloat(section, "w")
return pos
model.init_position(pos)
model.lineType=self.config.getint(section, "linetype")
model.status=self.config.getint(section, "status")
return model
def _get_point_debug_info(manager, pos, model):
config = manager.config
@ -169,7 +181,8 @@ def _get_point_debug_info(manager, pos, model):
# 测试
if __name__ == "__main__":
manager = DropPositionManager("drop.ini")
# manager = DropPositionManager("drop.ini")
manager = DropPositionManager()
lineid = 1
print(f"\n🔁 测试:通过 point 参数切换路径集合\n")

View File

@ -1,5 +1,5 @@
[positions]
0 = -569.543396, -1299.659543, -1069.931256, -151.12764, 0.258, 0.258
1 = -569.543396, -1299.659543, -1069.931256, -151.12764, 0.258, 0.258
2 = -569.543396, -1299.659543, -1069.931256, -151.12764, 0.258, 0.258
3 = -569.543396, -1299.659543, -1069.931256, -151.12764, 0.258, 0.258
0 = -263.082245, -1305.589478, -1203.596436, -149.786407, 0.258, 0.258
1 = -263.082245, -1305.589478, -1203.596436, -149.786407, 0.258, 0.258
2 = -263.082245, -1305.589478, -1203.596436, -149.786407, 0.258, 0.258
3 = -263.082245, -1305.589478, -1203.596436, -149.786407, 0.258, 0.258

View File

@ -7,23 +7,23 @@ id = 2
name = 反应釜2
[Position3]
x = 1882.882568
y = 786.492737
z = 1203.552246
u = 11.403661
v = -0.985981
w = -125.710434
x = -44.431778
y = -189.009613
z = -80.500801
u = 51.386665
v = 999.0
w = 999.0
id = 3
order = 0
lineid = 2
status = 3
linetype = 0
linetype = 4
[Position1]
x = -569.528625
y = -1299.985718
z = -413.431213
u = -151.127274
x = -263.075714
y = -1305.59082
z = -824.99884
u = -149.785645
v = 0.0
w = -0.0
id = 1
@ -33,10 +33,10 @@ status = 3
linetype = 0
[Position12]
x = -569.524475
y = -1299.973877
z = -825.314453
u = -151.126846
x = -263.082245
y = -1305.589478
z = -825.0
u = -149.786407
v = 0.0
w = -0.0
id = 12
@ -46,17 +46,17 @@ status = 3
linetype = 0
[Position6]
x = 1425.824829
y = 952.627869
z = 1364.459839
u = -5.591513
v = -38.629269
w = -114.406639
x = -21.648384
y = -20.0
z = 98.003319
u = -225.353333
v = 2.0
w = 2222.0
id = 6
order = 1
lineid = 2
status = 2
linetype = 0
status = 3
linetype = 4
[Position13]
x = 19.228468
@ -72,10 +72,10 @@ status = 3
linetype = 0
[Position14]
x = -569.531006
y = -1299.971069
z = -825.315613
u = -150.0
x = -263.082245
y = -1305.589478
z = -825.0
u = -149.786407
v = 0.0
w = -0.0
id = 14
@ -137,10 +137,10 @@ status = 9
linetype = 0
[Position7]
x = -569.522156
y = -1299.988647
z = -413.430023
u = -151.126541
x = -263.075714
y = -1305.59082
z = -824.99884
u = -149.785645
v = 0.0
w = -0.0
id = 7
@ -162,3 +162,315 @@ lineid = 1
status = 3
linetype = 0
[Position9]
x = -99.042
y = -1202.396484
z = 123.274
u = -172.734
v = 1.0
w = 1.0
id = 9
order = 3
lineid = 2
status = 3
linetype = 4
[Position10]
x = 992.553
y = 179.308
z = -1202.361
u = -148.482
v = 3.0
w = 3.0
id = 10
order = 2
lineid = 2
status = 3
linetype = 0
[Position11]
x = 1792.553
y = -270.692
z = -1202.361
u = -58.482
v = 4.0
w = 4.0
id = 11
order = 4
lineid = 2
status = 3
linetype = 0
[Position16]
x = 1792.553
y = 629.308
z = -1202.361
u = -238.482
v = 5.0
w = 5.0
id = 16
order = 5
lineid = 2
status = 3
linetype = 0
[Position17]
x = 1642.553
y = -420.692
z = -1000.0
u = 31.518
v = 6.0
w = 6.0
id = 17
order = 6
lineid = 2
status = 3
linetype = 0
[Position18]
x = 1672.553
y = 779.308
z = -1000.0
u = 31.518
v = 7.0
w = 7.0
id = 18
order = 7
lineid = 2
status = 3
linetype = 0
[Position19]
x = 1672.553
y = 179.308
z = -1000.0
u = 31.518
v = 8.0
w = 8.0
id = 19
order = 8
lineid = 2
status = 3
linetype = 0
[Position20]
x = 842.553
y = -330.692
z = -1000.0
u = -58.482
v = 9.0
w = 9.0
id = 20
order = 9
lineid = 2
status = 3
linetype = 0
[Position22]
x = 842.553
y = 679.308
z = -1000.0
u = -238.482
v = 10.0
w = 10.0
id = 22
order = 10
lineid = 2
status = 3
linetype = 0
[Position21]
x = 942.553
y = -420.692
z = -800.0
u = -148.482
v = 11.0
w = 11.0
id = 21
order = 11
lineid = 2
status = 3
linetype = 0
[Position24]
x = 942.553
y = 779.308
z = -800.0
u = -148.482
v = 12.0
w = 12.0
id = 24
order = 12
lineid = 2
status = 3
linetype = 0
[Position26]
x = 942.553
y = 179.308
z = -800.0
u = -148.482
v = 13.0
w = 13.0
id = 26
order = 13
lineid = 2
status = 3
linetype = 0
[Position25]
x = 1792.553
y = -320.692
z = -800.0
u = -58.482
v = 14.0
w = 14.0
id = 25
order = 14
lineid = 2
status = 3
linetype = 0
[Position23]
x = 1792.553
y = 669.308
z = -800.0
u = -238.482
v = 15.0
w = 15.0
id = 23
order = 15
lineid = 2
status = 3
linetype = 0
[Position27]
x = 1692.553
y = -420.692
z = -600.0
u = 31.518
v = 16.0
w = 16.0
id = 27
order = 16
lineid = 2
status = 3
linetype = 0
[Position28]
x = 1632.553
y = 779.308
z = -600.0
u = 31.518
v = 17.0
w = 17.0
id = 28
order = 17
lineid = 2
status = 3
linetype = 0
[Position29]
x = 1692.553
y = 179.308
z = -600.0
u = 31.518
v = 18.0
w = 18.0
id = 29
order = 18
lineid = 2
status = 3
linetype = 0
[Position30]
x = 842.553
y = -330.692
z = -600.0
u = -58.482
v = 19.0
w = 19.0
id = 30
order = 19
lineid = 2
status = 3
linetype = 0
[Position31]
x = 842.553
y = 749.308
z = -600.0
u = -238.482
v = 20.0
w = 20.0
id = 31
order = 20
lineid = 2
status = 3
linetype = 0
[Position32]
x = 942.553
y = -420.692
z = -400.0
u = -148.482
v = 21.0
w = 21.0
id = 32
order = 21
lineid = 2
status = 3
linetype = 0
[Position34]
x = 942.553
y = 779.308
z = -400.0
u = -148.482
v = 22.0
w = 22.0
id = 34
order = 22
lineid = 2
status = 3
linetype = 0
[Position36]
x = 942.553
y = 179.308
z = -400.0
u = -148.482
v = 23.0
w = 23.0
id = 36
order = 23
lineid = 2
status = 3
linetype = 0
[Position35]
x = 1792.553
y = -320.692
z = -400.0
u = -58.482
v = 24.0
w = 24.0
id = 35
order = 24
lineid = 2
status = 3
linetype = 0
[Position33]
x = 1792.553
y = 679.308
z = -400.0
u = -238.482
v = 25.0
w = 25.0
id = 33
order = 25
lineid = 2
status = 3
linetype = 0

View File

@ -2,7 +2,8 @@ import os
# 调试变量
Debug = False # 控制不加图像的Fphoto False是不加
Debug1 = True # 打印很多日志节点
Debug1 = False # 打印很多日志节点
DebugPosition = False # 调试位置,关闭机器人和传感器及判断
# Debug2 = False
feedStatus = True #feedStatus的状态打印
@ -45,7 +46,10 @@ str_feed_safe_middle = '移动到安全中位位置'
str_feed_takePhoto = '拍照'
str_feed_broken = '移动到破袋位置'
str_feed_broken_bag = '划袋'
str_feed_drop = '移动扔空袋'
str_feed_drop = '移动到扔袋位置'
str_feed_drop_mid = '移动到码垛中间点位置'
str_feed_drop_reset = '移动到码垛复位位置'
str_feed_broken = '移动到破袋位置'
str_feed_takePhoto_fail = '识别图像失败'
str_feed_takePhoto_success = '识别图像成功'
str_feed_takePhoto_new_line = '新的一排袋识别'
@ -60,7 +64,7 @@ str_feed_none = '无'
str_feed_finish = '投料结束'
str_feed_take_success = '抓料成功'
str_feed_take_fail = '抓料失败'
str_feed_feed_num = '剩余投料次数'
str_feed_feed_num = '已码垛数量'
str_feed_zip_bag = '移动到压缩袋位置'
str_feed_photo_error_msgbox = '请重新摆放料带后再关闭此窗口'
str_feed_photo_confirm = '确认摆好'

View File

@ -7,6 +7,7 @@ import threading
import logging
from PySide6.QtCore import Signal, QObject
import numpy as np
import Constant
class RelayController:
@ -21,7 +22,8 @@ class RelayController:
self.sensor1_error_delay = 1.0 # SENSOR1 出错时延时(秒)
self.sensor1_post_action_delay = 0.2 # SENSOR1 每次循环后延时(秒)
self.sensor2_loop_delay = 0.5 # SENSOR2 线程轮询间隔(秒)
self.sensor2_loop_delay = 0.1 # SENSOR2 线程轮询间隔(秒)
# self.sensor2_loop_delay = 0.5 # SENSOR2 线程轮询间隔(秒)
self.sensor2_error_delay = 0.5 # SENSOR2 出错时延时(秒)
self.sensor2_post_action_delay = 0.2 # SENSOR2 每次循环后延时(秒)
# ===================== 全局动作延时参数 =====================
@ -42,6 +44,7 @@ class RelayController:
self.CONVEYOR1 = 'conveyor1'
self.PUSHER = 'pusher'
self.CONVEYOR2 = 'conveyor2'
self.CONVEYOR2_REVERSE = 'conveyor2_reverse'
self.CLAMP = 'clamp'
self.PUSHER1 = 'pusher1'
self.SENSOR1 = 'sensor1'
@ -50,11 +53,18 @@ class RelayController:
self.valve_commands = {
self.CONVEYOR1: {'open': '00000000000601050000FF00', 'close': '000000000006010500000000'},
self.PUSHER: {'open': '00000000000601050001FF00', 'close': '000000000006010500010000'},
#滚筒2000 0012正转2000 0022 2001变频器频率调整 2000正反转。
self.CONVEYOR2: {'open': '000100000006020620000012', 'close': '000100000006020620000001'},
#DO4
self.CLAMP: {'open': '00000000000601050003FF00', 'close': '000000000006010500030000'},
self.PUSHER1: {'open': '00000000000601050004FF00', 'close': '000000000006010500040000'}
#DO5
self.PUSHER1: {'open': '00000000000601050004FF00', 'close': '000000000006010500040000'},
self.CONVEYOR2_REVERSE: {'open': '000100000006020620000022', 'close': '000100000006020620000001'}
}
#devices:读取继点器的状态
#sensors 传感器的状态 D12
self.read_status_command = {
'devices': '000000000006010100000008',
'sensors': '000000000006010200000008'
@ -66,6 +76,7 @@ class RelayController:
self.CONVEYOR2: 2,
self.CLAMP: 3,
self.PUSHER1: 4,
self.CONVEYOR2_REVERSE: 5
}
self.sensor_bit_map = {
@ -79,6 +90,7 @@ class RelayController:
self.CONVEYOR2: "传送带2",
self.CLAMP: "机械臂夹爪",
self.PUSHER1: "推板关",
self.CONVEYOR2_REVERSE: "传送带2反转"
}
self.sensor_name_map = {
@ -102,6 +114,8 @@ class RelayController:
# ===================== 基础通信方法 =====================
def send_command(self, command_hex, retry_count=2, source='unknown'):
if Constant.DebugPosition:
return True
byte_data = binascii.unhexlify(command_hex)
for attempt in range(retry_count):
try:
@ -119,19 +133,21 @@ class RelayController:
#print(f"[通信响应] {hex_response}")
return response
except Exception as e:
print(f"通信错误 ({source}): {e}, 尝试重连... ({attempt + 1}/{retry_count})")
print(f"网络继电器通信错误 ({source}): {e}, 尝试重连... ({attempt + 1}/{retry_count})")
time.sleep(5)
self.trigger_alarm()
return None
def trigger_alarm(self):
print("警告:连续多次通信失败,请检查设备连接!")
print("警告:网络继电器连续多次通信失败,请检查设备连接!")
# ===================== 状态读取方法 =====================
def get_all_device_status(self, command_type='devices'):
if Constant.DebugPosition:
return {self.SENSOR2:True}
command = self.read_status_command.get(command_type)
if not command:
print(f"未知的读取类型: {command_type}")
print(f"未知的网络继电器读取类型: {command_type}")
return {}
source = 'sensor' if command_type == 'sensors' else 'device'
@ -147,7 +163,7 @@ class RelayController:
for key, bit_index in bit_map.items():
status_dict[key] = status_bin[bit_index] == '1'
else:
print(f"[{command_type}] 读取状态失败或响应无效")
print(f"网络继电器[{command_type}] 读取状态失败或响应无效")
return status_dict
@ -229,7 +245,9 @@ class RelayController:
return False
# ===================== 动作控制方法 =====================
def open(self, conveyor1=False, pusher=False, conveyor2=False, clamp=False, pusher1=False):
def open(self, conveyor1=False, pusher=False, conveyor2=False, clamp=False, pusher1=False, conveyor2_reverse=False):
if Constant.DebugPosition:
return
status = self.get_all_device_status()
if conveyor1 and not status.get(self.CONVEYOR1, False):
self.send_command(self.valve_commands[self.CONVEYOR1]['open'])
@ -246,8 +264,11 @@ class RelayController:
if pusher1 and not status.get(self.PUSHER1, False):
self.send_command(self.valve_commands[self.PUSHER1]['open'])
time.sleep(self.delay_pusher)
if conveyor2_reverse:
self.send_command(self.valve_commands[self.CONVEYOR2_REVERSE]['open'])
time.sleep(self.delay_conveyor)
def close(self, conveyor1=False, pusher=False, conveyor2=False, clamp=False, pusher1=False):
def close(self, conveyor1=False, pusher=False, conveyor2=False, clamp=False, pusher1=False, conveyor2_reverse=False):
if conveyor1:
self.send_command(self.valve_commands[self.CONVEYOR1]['close'])
time.sleep(self.delay_conveyor)
@ -263,6 +284,9 @@ class RelayController:
if pusher1:
self.send_command(self.valve_commands[self.PUSHER1]['close'])
time.sleep(self.delay_pusher)
if conveyor2_reverse:
self.send_command(self.valve_commands[self.CONVEYOR2_REVERSE]['close'])
time.sleep(self.delay_conveyor)
# ===================== 传感器处理线程 =====================
def handle_sensor1(self):
@ -314,7 +338,7 @@ class RelayController:
self.motor_stopped_by_sensor2 = True
self.sensor2_ready = True
else:
if self.sensor2_ready and self.motor_stopped_by_sensor2:
if self.sensor2_ready: #and self.motor_stopped_by_sensor2:
self.open(conveyor2=True)
self.motor_stopped_by_sensor2 = False
self.sensor2_ready = False
@ -346,6 +370,18 @@ class RelayController:
if self._sensor2_thread:
self._sensor2_thread.join()
print("传感器线程已终止。")
def stop_sensor(self,sensor1_thread,sensor2_thread):
if not self._running:
print("线程未在运行")
return
print("停止传感器线程")
self._running = False
if sensor1_thread and sensor1_thread.is_alive():
sensor1_thread.join()
if sensor2_thread and sensor2_thread.is_alive():
sensor2_thread.join()
print("传感器线程已终止。")
def start_sensor1_only(self):
if self._running:

Binary file not shown.

View File

@ -1,5 +1,7 @@
from EMV import RelayController
import time
import threading
relay_controller = RelayController() # 实例化控制器
@ -18,6 +20,10 @@ def test_device(device_name, action):
'open': lambda: relay_controller.open(conveyor2=True),
'close': lambda: relay_controller.close(conveyor2=True)
},
'conveyor2_reverse': {
'open': lambda: relay_controller.open(conveyor2_reverse=True),
'close': lambda: relay_controller.close(conveyor2_reverse=True)
},
'pusher': {
'open': lambda: relay_controller.open(pusher=True),
'close': lambda: relay_controller.close(pusher=True)
@ -60,7 +66,7 @@ if __name__ == "__main__":
#test_device('conveyor2', 'open')
#test_device('conveyor2', 'close')
'''
test_device('conveyor2', 'close')
test_device('D', 'close')
sensors = relay_controller.get_all_device_status('sensors')
sensor2_value = sensors.get(relay_controller.SENSOR2, False)
print(sensor2_value)
@ -74,4 +80,33 @@ if __name__ == "__main__":
# 已完成测试
#test_device('clamp', 'open')
test_device('clamp', 'close')
# test_device('clamp', 'close')
# test_device('conveyor2', 'close')
# sensors = relay_controller.get_all_device_status()
# print(sensors)
# time.sleep(3)
# test_device('conveyor2', 'open')
# test_device('conveyor2_reverse', 'open')
# time.sleep(3)
# test_device('conveyor2', 'open')
# test_device('conveyor2', 'close')
# sensors = relay_controller.get_all_device_status('sensors')
# sensor2_value = sensors.get(relay_controller.SENSOR2, False)
# relay_controller._running=True
# relay_controller.handle_sensor2()
test_device('conveyor2', 'close')
while True:
if relay_controller.is_valid_sensor_status_1('sensor2'):
test_device('conveyor2', 'close')
time.sleep(4)
test_device('conveyor2_reverse', 'open')
time.sleep(3)
test_device('conveyor2', 'open')
print('aaaaa')

View File

@ -6,6 +6,98 @@
from PySide6 import QtCore
qt_resource_data = b"\
\x00\x00\x05\x96\
<\
?xml version=\x221.\
0\x22 standalone=\x22n\
o\x22?><!DOCTYPE sv\
g PUBLIC \x22-//W3C\
//DTD SVG 1.1//E\
N\x22 \x22http://www.w\
3.org/Graphics/S\
VG/1.1/DTD/svg11\
.dtd\x22><svg t=\x2217\
29780484640\x22 cla\
ss=\x22icon\x22 viewBo\
x=\x220 0 1024 1024\
\x22 version=\x221.1\x22 \
xmlns=\x22http://ww\
w.w3.org/2000/sv\
g\x22 p-id=\x224318\x22 x\
mlns:xlink=\x22http\
://www.w3.org/19\
99/xlink\x22 width=\
\x22200\x22 height=\x2220\
0\x22><path d=\x22M768\
512v320c0 11.73\
3333-9.6 21.3333\
33-21.333333 21.\
333333H277.33333\
3c-11.733333 0-2\
1.333333-9.6-21.\
333333-21.333333\
V512c0-141.22666\
7 114.773333-256\
256-256s256 114\
.773333 256 256z\
M917.333333 938.\
666667H106.66666\
7a21.333333 21.3\
33333 0 1 1 0-42\
.666667h810.6666\
66a21.333333 21.\
333333 0 1 1 0 4\
2.666667zM512 21\
3.333333a21.3333\
33 21.333333 0 0\
1-21.333333-21.\
333333V106.66666\
7a21.333333 21.3\
33333 0 1 1 42.6\
66666 0v85.33333\
3a21.333333 21.3\
33333 0 0 1-21.3\
33333 21.333333z\
M192 533.333333H\
106.666667a21.33\
3333 21.333333 0\
1 1 0-42.666666\
h85.333333a21.33\
3333 21.333333 0\
1 1 0 42.666666\
zM917.333333 533\
.333333h-85.3333\
33a21.333333 21.\
333333 0 1 1 0-4\
2.666666h85.3333\
33a21.333333 21.\
333333 0 1 1 0 4\
2.666666zM747.09\
3333 298.24a21.3\
12 21.312 0 0 1-\
15.082666-36.416\
l51.648-51.648a2\
1.312 21.312 0 1\
1 30.165333 30.\
165333l-51.648 5\
1.648a21.248 21.\
248 0 0 1-15.082\
667 6.250667zM27\
6.906667 298.24c\
-5.461333 0-10.9\
22667-2.090667-1\
5.104-6.250667l-\
51.626667-51.648\
a21.333333 21.33\
3333 0 0 1 30.18\
6667-30.165333l5\
1.626666 51.648a\
21.333333 21.333\
333 0 0 1-15.082\
666 36.416z\x22 p-i\
d=\x224319\x22 fill=\x22#\
ffffff\x22></path><\
/svg>\
\x00\x03\x0eK\
\xff\
\xd8\xff\xe0\x00\x10JFIF\x00\x01\x01\x00\x00\x01\x00\
@ -12525,6 +12617,175 @@ H\xa6\xa2\xcd\xf6y\x0a\xcc3\xdc\xb5\xd0\xd5Ro\xe9\
\x85\xbd\xca\xec%R\x94\xc7i=f\x19\xeeV\xad\xb5\
K\x85;\xbcy\x16\x15x\xe5\xbdq\xd4\xf4\x9a\xdfk\
\xbeUw\x91\x0b%\xd1\x1f\xff\xd9\
\x00\x00\x0ah\
<\
?xml version=\x221.\
0\x22 standalone=\x22n\
o\x22?><!DOCTYPE sv\
g PUBLIC \x22-//W3C\
//DTD SVG 1.1//E\
N\x22 \x22http://www.w\
3.org/Graphics/S\
VG/1.1/DTD/svg11\
.dtd\x22><svg t=\x2217\
29780516602\x22 cla\
ss=\x22icon\x22 viewBo\
x=\x220 0 1024 1024\
\x22 version=\x221.1\x22 \
xmlns=\x22http://ww\
w.w3.org/2000/sv\
g\x22 p-id=\x225417\x22 x\
mlns:xlink=\x22http\
://www.w3.org/19\
99/xlink\x22 width=\
\x22200\x22 height=\x2220\
0\x22><path d=\x22M960\
512c0-59.5-40.9\
-109.7-96.1-124v\
68.6c-9.4-5.5-20\
.4-8.6-32-8.6-35\
.3 0-64.1 28.7-6\
4.1 64s28.7 64 6\
4.1 64c11.7 0 22\
.6-3.1 32-8.6V63\
6c-10.2 2.6-21 4\
.1-32 4.1-70.7 0\
-128.1-57.4-128.\
1-128s57.5-128 1\
28.1-128c11.1 0 \
21.8 1.4 32 4V19\
2c0-52.9-41.8-96\
-93.1-96H221.2c-\
51.3 0-93.1 43.1\
-93.1 96v159.5h1\
28.1v64H128.1V35\
2H64v64h64.1v191\
.5h128.1v64H127.\
1V608H64v64h64.1\
v160c0 52.9 41.8\
96 93.1 96h549.\
6c51.3 0 93.1-43\
.1 93.1-96V635.9\
C919.1 621.7 960\
571.5 960 512zM\
320.3 288h384.4v\
64H320.3v-64z m0\
192h318.4v64H32\
0.3v-64z m384.4 \
256H320.3v-64h38\
4.4v64z m164.4-2\
76z m4.9 3.9l-0.\
1-0.1s0.1 0 0.1 \
0.1zM869.1 564z \
m4.9-3.9l-0.1 0.\
1s0.1 0 0.1-0.1z\
m21.9-45.2c0-1 \
0.1-1.9 0.1-2.9s\
0-2-0.1-2.9c0 1 \
0.1 1.9 0.1 2.9s\
-0.1 2-0.1 2.9z \
m-17.7 41.2l0.3-\
0.3-0.3 0.3z m1.\
6-1.7l0.1-0.1-0.\
1 0.1z m2.3-2.8c\
0.2-0.2 0.3-0.4 \
0.5-0.6-0.2 0.2-\
0.3 0.4-0.5 0.6z\
m1.5-1.9c0.2-0.\
2 0.4-0.5 0.5-0.\
7-0.2 0.2-0.3 0.\
4-0.5 0.7z m2-2.\
9c0.2-0.3 0.4-0.\
6 0.6-1-0.2 0.4-\
0.4 0.7-0.6 1z m\
1.3-2.2c0.3-0.4 \
0.5-0.9 0.8-1.4-\
0.2 0.5-0.5 1-0.\
8 1.4z m1.7-2.9c\
0.2-0.5 0.5-0.9 \
0.7-1.4-0.2 0.5-\
0.5 0.9-0.7 1.4z\
m1.2-2.5c0.3-0.\
6 0.6-1.3 0.9-1.\
9-0.3 0.7-0.6 1.\
3-0.9 1.9z m1.3-\
2.9c0.2-0.6 0.5-\
1.2 0.7-1.8-0.2 \
0.6-0.4 1.2-0.7 \
1.8z m1.1-2.8c0.\
3-0.8 0.5-1.6 0.\
8-2.4-0.3 0.9-0.\
5 1.7-0.8 2.4z m\
1-2.9c0.2-0.7 0.\
4-1.5 0.6-2.2-0.\
2 0.8-0.4 1.5-0.\
6 2.2z m0.8-3c0.\
2-0.9 0.4-1.8 0.\
6-2.6-0.2 0.8-0.\
4 1.7-0.6 2.6z m\
0.7-2.9c0.2-0.8 \
0.3-1.7 0.5-2.5-\
0.2 0.8-0.4 1.6-\
0.5 2.5z m0.5-3.\
3c0.1-0.9 0.3-1.\
9 0.4-2.8-0.1 0.\
9-0.2 1.8-0.4 2.\
8z m0.4-3c0.1-0.\
9 0.2-1.9 0.2-2.\
8 0 1-0.1 1.9-0.\
2 2.8z m-17.4-50\
.5l0.3 0.3-0.3-0\
.3z m1.6 1.7l0.1\
0.1-0.1-0.1z m2\
.3 2.8c0.2 0.2 0\
.3 0.4 0.5 0.6-0\
.2-0.2-0.3-0.4-0\
.5-0.6z m1.5 1.9\
c0.2 0.2 0.4 0.5\
0.5 0.7-0.2-0.2\
-0.3-0.4-0.5-0.7\
z m2 2.9c0.2 0.3\
0.4 0.7 0.6 1-0\
.2-0.4-0.4-0.7-0\
.6-1z m1.3 2.2c0\
.3 0.4 0.5 0.9 0\
.8 1.4-0.2-0.5-0\
.5-1-0.8-1.4z m1\
.7 2.9c0.2 0.5 0\
.5 0.9 0.7 1.4-0\
.2-0.5-0.5-0.9-0\
.7-1.4z m1.2 2.5\
c0.3 0.6 0.6 1.3\
0.9 1.9-0.3-0.7\
-0.6-1.3-0.9-1.9\
z m1.3 2.9c0.2 0\
.6 0.5 1.2 0.7 1\
.8-0.2-0.6-0.4-1\
.2-0.7-1.8z m1.1\
2.8c0.3 0.8 0.5\
1.6 0.8 2.4-0.3\
-0.9-0.5-1.7-0.8\
-2.4z m1 2.9c0.2\
0.7 0.4 1.5 0.6\
2.2-0.2-0.8-0.4\
-1.5-0.6-2.2z m0\
.8 3c0.2 0.9 0.4\
1.8 0.6 2.6-0.2\
-0.8-0.4-1.7-0.6\
-2.6z m0.7 2.9c0\
.2 0.8 0.3 1.7 0\
.5 2.5-0.2-0.8-0\
.4-1.6-0.5-2.5z \
m0.5 3.3c0.1 0.9\
0.3 1.9 0.4 2.8\
-0.1-0.9-0.2-1.8\
-0.4-2.8z m0.4 3\
c0.1 0.9 0.2 1.9\
0.2 2.8 0-1-0.1\
-1.9-0.2-2.8z\x22 f\
ill=\x22#ffffff\x22 p-\
id=\x225418\x22></path\
></svg>\
\x00\x00\x10\xf9\
\x89\
PNG\x0d\x0a\x1a\x0a\x00\x00\x00\x0dIHDR\x00\
@ -101785,11 +102046,19 @@ qt_resource_name = b"\
\x00P7\xd5\
\x00I\
\x00m\x00a\x00g\x00e\
\x00\x0a\
\x00I\xeb\xe7\
\x00w\
\x00a\x00r\x00i\x00n\x00g\x00.\x00s\x00v\x00g\
\x00 \
\x00\xe9\x97'\
\x00b\
\x00a\x00c\x00k\x00g\x00r\x00o\x00u\x00d\x00_\x00l\x00e\x00f\x00t\x00M\x00e\x00n\
\x00u\x00_\x00b\x00t\x00n\x00_\x00c\x00h\x00i\x00l\x00d\x00.\x00j\x00p\x00g\
\x00\x07\
\x03ZZ'\
\x00l\
\x00o\x00g\x00.\x00s\x00v\x00g\
\x00\x0d\
\x09\xb8\x00\x07\
\x00t\
@ -101840,30 +102109,34 @@ qt_resource_struct = b"\
\x00\x00\x00\x00\x00\x00\x00\x00\
\x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x02\
\x00\x00\x00\x00\x00\x00\x00\x00\
\x00\x00\x00\x0e\x00\x02\x00\x00\x00\x0b\x00\x00\x00\x03\
\x00\x00\x00\x0e\x00\x02\x00\x00\x00\x0d\x00\x00\x00\x03\
\x00\x00\x00\x00\x00\x00\x00\x00\
\x00\x00\x00\x84\x00\x00\x00\x00\x00\x01\x00\x03\x1fL\
\x00\x00\x01\x91\xe6\x01\x9d\x05\
\x00\x00\x00\xb2\x00\x00\x00\x00\x00\x01\x00\x03/R\
\x00\x00\x01\x99\x12e\xfc\xa2\
\x00\x00\x00\x1e\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\
\x00\x00\x01\x92\xa9R\xad\xa2\
\x00\x00\x00\xb6\x00\x00\x00\x00\x00\x01\x00\x0fV\xa9\
\x00\x00\x01\x92\xaa\x82\x14\xcd\
\x00\x00\x01\x8e\x00\x00\x00\x00\x00\x01\x00\x18\xbf\xdc\
\x00\x00\x01\x92\x95\xc7\xa8~\
\x00\x00\x01Z\x00\x00\x00\x00\x00\x01\x00\x16\xc0\x9d\
\x00\x00\x01\x92\xa9\xda\x17V\
\x00\x00\x01x\x00\x00\x00\x00\x00\x01\x00\x16\xc7R\
\x00\x00\x01\x91\xe6,[9\
\x00\x00\x00\xe8\x00\x00\x00\x00\x00\x01\x00\x0f\xc3\xa1\
\x00\x00\x01\x92\xa94K\x99\
\x00\x00\x00d\x00\x00\x00\x00\x00\x01\x00\x03\x0eO\
\x00\x00\x01\x92\x95\x7fi\xc5\
\x00\x00\x00\x94\x00\x00\x00\x00\x00\x01\x00\x0fL\xa7\
\x00\x00\x01\x92\xaaA6\xc5\
\x00\x00\x01\xa8\x00\x00\x00\x00\x00\x01\x00\x18\xc4\xba\
\x00\x00\x01\x92\x95\xc9\x85\xad\
\x00\x00\x01\x22\x00\x00\x00\x00\x00\x01\x00\x16\xae\x01\
\x00\x00\x01\x92\xa97\x06\xaa\
\x00\x00\x01\x99\x12e\xfc\xbd\
\x00\x00\x008\x00\x00\x00\x00\x00\x01\x00\x00\x05\x9a\
\x00\x00\x01\x99\x12e\xfc\xb2\
\x00\x00\x00~\x00\x00\x00\x00\x00\x01\x00\x03\x13\xe9\
\x00\x00\x01\x99\x12e\xfc\xb5\
\x00\x00\x00\xe4\x00\x00\x00\x00\x00\x01\x00\x0ff\xaf\
\x00\x00\x01\x99\x12e\xfc\xa4\
\x00\x00\x01\xbc\x00\x00\x00\x00\x00\x01\x00\x18\xcf\xe2\
\x00\x00\x01\x99\x12e\xfc\xb7\
\x00\x00\x01\x88\x00\x00\x00\x00\x00\x01\x00\x16\xd0\xa3\
\x00\x00\x01\x99\x12e\xfc\xb2\
\x00\x00\x01\xa6\x00\x00\x00\x00\x00\x01\x00\x16\xd7X\
\x00\x00\x01\x99\x12e\xfc\xbc\
\x00\x00\x01\x16\x00\x00\x00\x00\x00\x01\x00\x0f\xd3\xa7\
\x00\x00\x01\x99\x12e\xfc\xad\
\x00\x00\x00\x92\x00\x00\x00\x00\x00\x01\x00\x03\x1eU\
\x00\x00\x01\x99\x12e\xfc\xb9\
\x00\x00\x00\xc2\x00\x00\x00\x00\x00\x01\x00\x0f\x5c\xad\
\x00\x00\x01\x99\x12e\xfc\xb5\
\x00\x00\x01\xd6\x00\x00\x00\x00\x00\x01\x00\x18\xd4\xc0\
\x00\x00\x01\x99\x12e\xfc\xb5\
\x00\x00\x01P\x00\x00\x00\x00\x00\x01\x00\x16\xbe\x07\
\x00\x00\x01\x99\x12e\xfc\xb4\
"
def qInitResources():

View File

@ -74,6 +74,8 @@ class PositionModel:
self.lineType = config_reader.getint(self.section, 'lineType')
def get_position(self):
real_pos = Real_Position()
#初始化类型
real_pos.position_type = self.lineType
real_pos.init_position(self.X, self.Y, self.Z, self.U, self.V, self.W)
if real_pos.X == -9999:
return None

View File

@ -2,6 +2,7 @@ import math
from Constant import position_accuracy_command
from Constant import position_accuracy_action
from Constant import DebugPosition
class Position:
def __init__(self):
self.X = 0.0
@ -10,18 +11,36 @@ class Position:
self.U = 0.0
self.V = 0.0
self.W = 0.0
self.Axis_0 = 0.0
self.Axis_1 = 0.0
self.Axis_2 = 0.0
self.Axis_3 = 0.0
self.Axis_4 = 0.0
self.Axis_5 = 0.0
#点位类型 1世界坐标(默认4关节坐标
self.position_type =1
self.a = 0.0
self.b = 0.0
self.c = 0.0
def compare(self,position,is_action=False):
# distance = math.sqrt((self.X-position.X)**2+
# (self.Y-position.Y)**2+
# (self.Z - position.Z)**2+
# (self.U - position.U)**2+
# (self.V - position.V)**2+
# (self.W - position.W) ** 2)
if DebugPosition:
return True
#点位类型 1世界坐标(默认4关节坐标
if(position.position_type==4):
return self._compare_joint(position,is_action)
else:
return self._compare_world(position,is_action)
def _compare_world(self,position,is_action=False):
"""
世界坐标比较
:param position:
:return:精度内TRUE,否则为FALSE
"""
distance = math.sqrt((self.X - position.X) ** 2 +
(self.Y - position.Y) ** 2 +
(self.Z - position.Z) ** 2 )
@ -30,6 +49,20 @@ class Position:
else:
return False
def _compare_joint(self,position,is_action=False):
"""
关节坐标比较
:param position:
:return:精度内TRUE,否则为FALSE
"""
distance = math.sqrt((self.Axis_0 - position.X) ** 2 +
(self.Axis_1 - position.Y) ** 2 +
(self.Axis_2 - position.Z) ** 2 +
(self.Axis_3 - position.U) ** 2 )
if distance<=(position_accuracy_action if is_action else position_accuracy_command):
return True
else:
return False
# def compare(self,position):
# if self.X-position.X<position_accuracy and \
@ -83,6 +116,16 @@ class Real_Position(Position):
self.W = W
return self
def init_position_joint_and_world(self, X, Y, Z, U, V, W,Axis_0,Axis_1,Axis_2,Axis_3,Axis_4,Axis_5):
self.init_position(X,Y,Z,U,V,W)
self.Axis_0 = Axis_0
self.Axis_1 = Axis_1
self.Axis_2 = Axis_2
self.Axis_3 = Axis_3
self.Axis_4 = Axis_4
self.Axis_5 = Axis_5
return self
# def init_position(self, position):
# return self.init_position(position.X,position.Y,position.Z,position.U,position.V,position.W)

View File

@ -47,7 +47,7 @@ photo_v5 = 0.0
photo_w5 = 1.0
linecount = 2
remain_linename = 1
remain_count = 40
remain_count = 0
io_take_addr = 8
io_zip_addr = 11
io_shake_addr = 12
@ -64,10 +64,10 @@ feed_speed = 100
reset_speed = 100
[Origin]
x = -828.689758
y = -1146.968872
z = -77.084404
u = -90.137154
x = 19.236227
y = -1531.263794
z = -189.009613
u = -73.545906
v = 0.0
w = -0.0

View File

@ -49,7 +49,7 @@ class Logger(QObject):
text_edit_handler_warning.setFormatter(formatter_warning)
self.logger_textEdit_warning.addHandler(text_edit_handler_warning)
handler = TimedRotatingFileHandler(file_path, when='D', interval=1, backupCount=30)
handler = TimedRotatingFileHandler(file_path, when='D', interval=1, backupCount=30,encoding='utf-8')
handler.suffix = "%Y-%m-%d"
formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s', datefmt='%Y-%m-%d %H:%M:%S')
handler.setFormatter(formatter)

Binary file not shown.

Binary file not shown.

18827
log/log.log

File diff suppressed because it is too large Load Diff

187
main.py
View File

@ -490,7 +490,8 @@ class MainWindow(QMainWindow, Ui_MainWindow):
combox_lineType.addItem("直线",0)
combox_lineType.addItem("曲线中间点",2)
combox_lineType.addItem("曲线终点",3)
combox_lineType.addItem("自由路径",4)
#自由路径修改成关节坐标
combox_lineType.addItem("关节",4)
combox_lineType.setCurrentIndex(combox_lineType.findData(position_model.lineType))
combox_lineType.currentIndexChanged.connect(self.send_table_position_status_changed)
self.tableWidget_line_positions.setCellWidget(row_i, 7, combox_lineType)
@ -719,6 +720,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self.feeding.take_no_photo_sigal.connect(self.show_no_photo_message_box)
self.feeding.update_detect_image.connect(self.updateUI_label_detection)
self.feeding.log_signal.connect(self.log_message)
self.feeding.stack_finish_signal.connect(self.stack_finish)
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'))
@ -897,10 +899,12 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self.main_UI_threading = Thread(target=self.updateUI)
self.detect_person_thread = Thread(target=self.run_detect_persion)
self.main_threading.start()
self.robot_connect_threading.start()
if not Constant.DebugPosition:
self.robot_connect_threading.start()
self.main_UI_threading.start()
self.detect_person_thread.start()
pass
def check_continue(self):
if self.remain_Count!=0:
for key in self.feedLine_dict.keys():
@ -915,7 +919,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
cancel_button = remain_messageBox.addButton("取消", PySide6.QtWidgets.QMessageBox.ButtonRole.RejectRole)
result = remain_messageBox.exec()
if remain_messageBox.clickedButton() == cancel_button:
self.remain_Count = 0
# self.remain_Count = 0
return
self.configReader.read(Constant.feedLine_set_file, encoding='utf-8')
line_name = self.configReader.get(key, 'name')
@ -970,7 +974,8 @@ class MainWindow(QMainWindow, Ui_MainWindow):
num = self.horizontalSlider_feedingNum.maximum()
line_head = self.comboBox_lineIndex.currentData()
self.command_quene.put(FeedCommand(FeedingConfig(num, FeedLine(self.feedLine_dict[line_head].id,self.feedLine_dict[line_head].name,self.feedLine_dict[line_head].positions), self.feeding.robotClient.photo_locs[:])))
num=5 #先默认30包码垛
self.command_quene.put(FeedCommand(FeedingConfig(num, FeedLine(self.feedLine_dict[line_head].id,self.feedLine_dict[line_head].name,self.feedLine_dict[line_head].positions,self.remain_Count), self.feeding.robotClient.photo_locs[:],self.remain_Count)))
# self.stackedWidget_num.setCurrentIndex(1)
self.set_run_status_button(True)
self.feeding.pause = False
@ -1273,19 +1278,31 @@ class MainWindow(QMainWindow, Ui_MainWindow):
#safe_position = self.feedLine_dict[line_head].safe_position
# self.send_position_command(safe_position.X, safe_position.Y, safe_position.Z, safe_position.U, safe_position.V, safe_position.W,move_type=MoveType.WORLD)
if self.remain_lineName != '':
line_head = f'{Constant.feedLine_set_section}{self.remain_lineName}'
return_positions = copy.deepcopy(self.feedLine_dict[line_head].positions)
position_origin = PositionModel()
position_origin.init_position(self.robotClient.origin_position)
position_origin.status = 1
return_positions.insert(0,position_origin)
if self.feedLine_dict.keys().__contains__(line_head):
self.feeding.feedConfig= FeedingConfig(0, FeedLine(self.feedLine_dict[line_head].id, self.feedLine_dict[line_head].name,
return_positions),
self.feeding.robotClient.photo_locs[:])
if self.feeding.feedConfig:
#改变路径后的值进行复位
__current_feed_config=self.feeding.feedConfig
# __current_lineid=__current_feed_config.feedLine.id
# __current_linename=__current_feed_config.feedLine.name
# __current_position=
# self.feeding.feedConfig= FeedingConfig(0, FeedLine(__current_lineid, __current_linename,
# __current_feed_config.feedLine.positions,0),
# self.feeding.robotClient.photo_locs[:],0)
else:
log.log_message(logging.ERROR, Constant.str_feed_reset_no_line_error)
return
#用配置的路径进行复位
line_head = f'{Constant.feedLine_set_section}{self.remain_lineName}'
return_positions = copy.deepcopy(self.feedLine_dict[line_head].positions)
position_origin = PositionModel()
position_origin.init_position(self.robotClient.origin_position)
position_origin.status = 1
return_positions.insert(0,position_origin)
if self.feedLine_dict.keys().__contains__(line_head):
self.feeding.feedConfig= FeedingConfig(0, FeedLine(self.feedLine_dict[line_head].id, self.feedLine_dict[line_head].name,
return_positions,self.remain_Count),
self.feeding.robotClient.photo_locs[:],self.remain_Count)
else:
log.log_message(logging.ERROR, Constant.str_feed_reset_no_line_error)
return
self.feeding.reset_status = ResetStatus.RStart
# dialog_reset = StopDialog()
# dialog_reset.stop_thread_signal.connect(self.stop_reset_thread)
@ -1377,64 +1394,66 @@ class MainWindow(QMainWindow, Ui_MainWindow):
# 主线程的逻辑就是 feeding.run() 接口和错误状态处理
while self.thread_signal:
time.sleep(0.1)
if Constant.feedStatus: #feedStatus的状态打印
current_status = self.feeding.feedStatus
is_paused = self.feeding.pause
if not Constant.DebugPosition:
if Constant.feedStatus: #feedStatus的状态打印
current_status = self.feeding.feedStatus
is_paused = self.feeding.pause
# 只有当状态或暂停标志发生变化时才打印
if (current_status != self.last_status_printed or
is_paused != self.last_pause_printed):
print(f"[调试] 当前 feedStatus: {current_status}, 是否暂停: {is_paused}")
self.last_status_printed = current_status
self.last_pause_printed = is_paused
# 只有当状态或暂停标志发生变化时才打印
if (current_status != self.last_status_printed or
is_paused != self.last_pause_printed):
print(f"[调试] 当前 feedStatus: {current_status}, 是否暂停: {is_paused}")
self.last_status_printed = current_status
self.last_pause_printed = is_paused
# 获取状态和控制标志
current_feed_status = self.feeding.feedStatus
is_running = (current_feed_status == FeedStatus.FStart) and (not self.feeding.pause) #加上未暂停
is_stopped = ( # 以下情况应关闭传感器
current_feed_status in [FeedStatus.FFinished, FeedStatus.FNone, FeedStatus.FReverse,
FeedStatus.FStartReverse]
or self.feeding.pause # 暂停时也视为“停止”
)
# 启动条件:处于 FStart 且未暂停,且线程未运行
if is_running and self.sensor_thread is None:
try:
self.relay_controller._running = True
self.sensor_thread = threading.Thread(
target=self.relay_controller.handle_sensor1,
name="Sensor1MonitorThread",
daemon=True
)
self.sensor_thread.start()
self.sensor2_thread = threading.Thread(
target=self.relay_controller.handle_sensor2,
daemon=True)
self.sensor2_thread.start()
print("🟢 传感器1监控线程已启动开始投料")
print("🟢 传感器2监控线程已启动关闭滚筒")
except Exception as e:
log.log_message(logging.ERROR, f"启动传感器线程失败: {e}")
# 获取状态和控制标志
current_feed_status = self.feeding.feedStatus
is_running = (current_feed_status == FeedStatus.FStart) and (not self.feeding.pause) #加上未暂停
is_stopped = ( # 以下情况应关闭传感器
current_feed_status in [FeedStatus.FFinished, FeedStatus.FNone, FeedStatus.FReverse,
FeedStatus.FStartReverse]
or self.feeding.pause # 暂停时也视为“停止”
)
# 启动条件:处于 FStart 且未暂停,且线程未运行
if is_running and self.sensor_thread is None:
try:
self.relay_controller._running = True
self.sensor_thread = threading.Thread(
target=self.relay_controller.handle_sensor1,
name="Sensor1MonitorThread",
daemon=True
)
self.sensor_thread.start()
self.sensor2_thread = threading.Thread(
target=self.relay_controller.handle_sensor2,
daemon=True)
self.sensor2_thread.start()
print("🟢 传感器1监控线程已启动开始投料")
print("🟢 传感器2监控线程已启动关闭滚筒")
except Exception as e:
log.log_message(logging.ERROR, f"启动传感器线程失败: {e}")
# 关闭条件:暂停、完成、回退等状态
if is_stopped and self.sensor_thread is not None:
try:
self.relay_controller._running = False
if self.sensor_thread.is_alive():
self.sensor_thread.join(timeout=1)
print("🛑 传感器监控线程已关闭(暂停/完成/回退)")
self.relay_controller.close(conveyor2=True)
except Exception as e:
log.log_message(logging.ERROR, f"关闭传感器线程异常: {e}")
finally:
self.sensor_thread = None
# 关闭条件:暂停、完成、回退等状态
if is_stopped and self.sensor_thread is not None:
try:
self.relay_controller._running = False
if self.sensor_thread.is_alive():
self.sensor_thread.join(timeout=1)
print("🛑 传感器监控线程已关闭(暂停/完成/回退)")
self.relay_controller.close(conveyor2=True)
except Exception as e:
log.log_message(logging.ERROR, f"关闭传感器线程异常: {e}")
finally:
self.sensor_thread = None
# 如果你也有 handle_sensor2 线程,也可以在这里关闭
# 如果你也有 handle_sensor2 线程,也可以在这里关闭
# 处理命令队列
if not self.command_quene.empty():
command = self.command_quene.get()
if isinstance(command, FeedCommand) and command.status == Status.Prepareing:
if self.feeding.feedStatus == FeedStatus.FNone:
#插入起始点set.ini中配置的点
position_origin = PositionModel()
position_origin.init_position(self.robotClient.origin_position)
position_origin.status = 1
@ -1493,7 +1512,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self.set_label_status_style(False)
if self.feeding.feedStatus != FeedStatus.FNone:
self.horizontalSlider_feedingNum.setValue(
self.horizontalSlider_feedingNum.maximum() - self.feeding.feedConfig.num)
self.feeding.feedConfig.remain_count)
# self.label_remain_num.setText(str(self.feeding.feedConfig.num))
else:
self.set_run_status_button(False)
@ -1501,7 +1520,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
#修改点1这里修改显示剩余袋数的逻辑
#原来的逻辑是显示剩余袋数self.label_remain_num.setText(self.feeding.feedConfig.num))
#我改成了目标袋数减剩余袋数就是已经投料的袋数self.label_remain_num.setText(str(self.horizontalSlider_feedingNum.maximum()-self.feeding.feedConfig.num))
self.label_remain_num.setText(str(self.horizontalSlider_feedingNum.maximum()-self.feeding.feedConfig.num))
self.label_remain_num.setText(str(self.feeding.feedConfig.remain_count))
if self.feeding.feedStatus == FeedStatus.FNone:
self.stackedWidget_num.setCurrentIndex(0)
else:
@ -1542,6 +1561,23 @@ class MainWindow(QMainWindow, Ui_MainWindow):
if msg_box_person.clickedButton() == cancel_button:
return
# self.show_infomessage_box("")
def stack_finish(self):
"""
码垛完成处理
"""
# self.feeding.feedConfig.remain_count=0
# self.closeEvent(None)
self.send_pause_command(True)
self.feeding.pause = True
msg_box_finish = QMessageBox()
msg_box_finish.setIcon(QMessageBox.Icon.Warning)
msg_box_finish.setText("码码完成")
msg_box_finish.setWindowTitle("提示")
msg_box_finish.addButton("确定", QMessageBox.AcceptRole)
result=msg_box_finish.exec()
def updateUI_IOPanel(self):
try:
@ -1762,7 +1798,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
def send_emergency_alarm_command(self):
self.feeding.feedStatus = FeedStatus.FNone
self.feeding.pause = True #暂停,停止滚去等
stop_command = CMDRequest()
stop_command.cmdData.append("actionStop")
stop_command.cmdData.append("1")
@ -2081,9 +2117,10 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self.feeding.onekey = True
def send_exit_button_click(self):
self.closeEvent(None)
QApplication.quit()
sys.exit(app.exec())
self.close()
# self.closeEvent(None)
# QApplication.quit()
# sys.exit(app.exec())
def send_click_sysmeuExpand(self):
self.frame_sys_seting.setVisible(not self.frame_sys_seting.isVisible())
@ -2102,17 +2139,23 @@ class MainWindow(QMainWindow, Ui_MainWindow):
def showEvent(self, event):
super().showEvent(event)
QTimer.singleShot(2000, self.check_continue)
# QTimer.singleShot(2000, self.check_continue)
def closeEvent(self, event):
#关闭窗口事件
self.record_remain_num()
# self.feeding.is_detected = False
# self.feeding.detect_thread.join()
self.feeding.close_feed()
self.thread_signal = False
self.robotClient.close()
if self.relay_controller:
self.relay_controller.stop_sensor(self.sensor_thread,self.sensor2_thread)
# self.relay_controller.close(conveyor2=True)
log.log_message(logging.INFO, Constant.str_sys_exit)
#显示接受关闭事件
event.accept()
#记录投料袋数
def record_remain_num(self):
@ -2120,7 +2163,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self.configReader = configparser.ConfigParser()
self.configReader.read(Constant.set_ini)
self.configReader.set('Robot_Feed', 'remain_linename', str(self.feeding.feedConfig.feedLine.id))
self.configReader.set('Robot_Feed', 'remain_count', str(self.feeding.feedConfig.num))
self.configReader.set('Robot_Feed', 'remain_count', str(self.feeding.feedConfig.remain_count))
self.configReader.write(open(Constant.set_ini, 'w', encoding='utf-8'))
except:
log.log_message(logging.ERROR, Constant.str_sys_log_feedNum)

View File

@ -4260,7 +4260,7 @@ qt_resource_struct = b"\
\x00\x00\x00\x0a\x00\x02\x00\x00\x00\x01\x00\x00\x00\x03\
\x00\x00\x00\x00\x00\x00\x00\x00\
\x00\x00\x00\x1a\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\
\x00\x00\x01\x91\x9e?\xe3\x5c\
\x00\x00\x01\x99\x12e\xfc\xb9\
"
def qInitResources():