mirror of
https://github.com/dptech-corp/Uni-Lab-OS.git
synced 2025-12-17 13:01:12 +00:00
Fix workstation resource not tracking
This commit is contained in:
@@ -171,7 +171,6 @@ class WorkstationBase(ABC):
|
||||
def post_init(self, ros_node: ROS2WorkstationNode) -> None:
|
||||
# 初始化物料系统
|
||||
self._ros_node = ros_node
|
||||
self._ros_node.update_resource([self.deck])
|
||||
|
||||
def _build_resource_mappings(self, deck: Deck):
|
||||
"""递归构建资源映射"""
|
||||
|
||||
@@ -1037,13 +1037,19 @@ class DeviceNodeResourceTracker(object):
|
||||
) -> List[Tuple[Any, Any]]:
|
||||
res_list = []
|
||||
# print(resource, target_resource_cls_type, identifier_key, compare_value)
|
||||
children = getattr(resource, "children", [])
|
||||
children = []
|
||||
if not isinstance(resource, dict):
|
||||
children = getattr(resource, "children", [])
|
||||
else:
|
||||
children = resource.get("children")
|
||||
if children is not None:
|
||||
children = list(children.values()) if isinstance(children, dict) else children
|
||||
for child in children:
|
||||
res_list.extend(
|
||||
self.loop_find_resource(child, target_resource_cls_type, identifier_key, compare_value, resource)
|
||||
)
|
||||
if issubclass(type(resource), target_resource_cls_type):
|
||||
if target_resource_cls_type == dict:
|
||||
if type(resource) == dict:
|
||||
# 对于字典类型,直接检查 identifier_key
|
||||
if identifier_key in resource:
|
||||
if resource[identifier_key] == compare_value:
|
||||
|
||||
@@ -336,6 +336,9 @@ class WorkstationNodeCreator(DeviceClassCreator[T]):
|
||||
try:
|
||||
# 创建实例,额外补充一个给protocol node的字段,后面考虑取消
|
||||
data["children"] = self.children
|
||||
for material_id, child in self.children.items():
|
||||
if child["type"] != "device":
|
||||
self.resource_tracker.add_resource(self.children[material_id])
|
||||
deck_dict = data.get("deck")
|
||||
if deck_dict:
|
||||
from pylabrobot.resources import Deck, Resource
|
||||
|
||||
Reference in New Issue
Block a user