From 82d9ef6bf788c3cee97ca6bba1d7a7cd211d34ec Mon Sep 17 00:00:00 2001 From: Junhan Chang Date: Wed, 27 Aug 2025 15:19:58 +0800 Subject: [PATCH] uncompleted refactor --- unilabos/registry/devices/work_station.yaml | 2 +- unilabos/ros/nodes/base_device_node.py | 14 +++++++------- .../{protocol_node.py => workstation_node.py} | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) rename unilabos/ros/nodes/presets/{protocol_node.py => workstation_node.py} (99%) diff --git a/unilabos/registry/devices/work_station.yaml b/unilabos/registry/devices/work_station.yaml index c96c68a6..0524252f 100644 --- a/unilabos/registry/devices/work_station.yaml +++ b/unilabos/registry/devices/work_station.yaml @@ -6112,7 +6112,7 @@ workstation: title: initialize_device参数 type: object type: UniLabJsonCommand - module: unilabos.ros.nodes.presets.protocol_node:ROS2WorkstationNode + module: unilabos.ros.nodes.presets.workstation_node:ROS2WorkstationNode status_types: {} type: ros2 config_info: [] diff --git a/unilabos/ros/nodes/base_device_node.py b/unilabos/ros/nodes/base_device_node.py index f88c27d1..ebe59236 100644 --- a/unilabos/ros/nodes/base_device_node.py +++ b/unilabos/ros/nodes/base_device_node.py @@ -958,19 +958,19 @@ class ROS2DeviceNode: driver_class, children=children, resource_tracker=self.resource_tracker ) else: - from unilabos.ros.nodes.presets.protocol_node import ROS2WorkstationNode - from unilabos.devices.work_station.workstation_base import WorkstationBase + from unilabos.ros.nodes.presets.workstation_node import ROS2WorkstationNode + from unilabos.devices.workstation.workstation_base import WorkstationBase # 检查是否是WorkstationBase的子类且包含设备子节点 if issubclass(self._driver_class, WorkstationBase) and has_device_children: # WorkstationBase + 设备子节点 -> 使用WorkstationNode作为ros_instance - self._use_protocol_node_ros = True + self._use_workstation_node_ros = True self._driver_creator = DeviceClassCreator(driver_class, children=children, resource_tracker=self.resource_tracker) elif issubclass(self._driver_class, ROS2WorkstationNode): # 是WorkstationNode的子节点,就要调用WorkstationNodeCreator - self._use_protocol_node_ros = False + self._use_workstation_node_ros = False self._driver_creator = WorkstationNodeCreator(driver_class, children=children, resource_tracker=self.resource_tracker) else: - self._use_protocol_node_ros = False + self._use_workstation_node_ros = False self._driver_creator = DeviceClassCreator(driver_class, children=children, resource_tracker=self.resource_tracker) if driver_is_ros: @@ -984,9 +984,9 @@ class ROS2DeviceNode: # 创建ROS2节点 if driver_is_ros: self._ros_node = self._driver_instance # type: ignore - elif hasattr(self, '_use_protocol_node_ros') and self._use_protocol_node_ros: + elif hasattr(self, '_use_workstation_node_ros') and self._use_workstation_node_ros: # WorkstationBase + 设备子节点 -> 创建ROS2WorkstationNode作为ros_instance - from unilabos.ros.nodes.presets.protocol_node import ROS2WorkstationNode + from unilabos.ros.nodes.presets.workstation_node import ROS2WorkstationNode # 从children提取设备协议类型 protocol_types = set() diff --git a/unilabos/ros/nodes/presets/protocol_node.py b/unilabos/ros/nodes/presets/workstation_node.py similarity index 99% rename from unilabos/ros/nodes/presets/protocol_node.py rename to unilabos/ros/nodes/presets/workstation_node.py index c8c338c3..49c9e223 100644 --- a/unilabos/ros/nodes/presets/protocol_node.py +++ b/unilabos/ros/nodes/presets/workstation_node.py @@ -100,7 +100,7 @@ class ROS2WorkstationNode(BaseROS2DeviceNode): def _setup_workstation_integration(self): """设置工作站集成 - 统一设备处理模式""" # 1. 建立协议节点引用 - self.workstation_instance.set_protocol_node(self) + self.workstation_instance.set_workstation_node(self) self.lab_logger().info(f"ROS2WorkstationNode {self.device_id} 与工作站实例 {type(self.workstation_instance).__name__} 集成完成")