米厂码垛修改
This commit is contained in:
57
CU/drop.py
57
CU/drop.py
@ -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")
|
||||
|
||||
Reference in New Issue
Block a user