From 4d98e1c46c8149cb28e616295e10377b85d757ad Mon Sep 17 00:00:00 2001 From: Xuwznln <18435084+Xuwznln@users.noreply.github.com> Date: Thu, 24 Jul 2025 12:10:37 +0800 Subject: [PATCH] =?UTF-8?q?=E7=89=A9=E6=96=99=E6=B7=BB=E5=8A=A0=E5=A4=B1?= =?UTF-8?q?=E8=B4=A5=E5=BA=94=E8=AF=A5=E7=9B=B4=E6=8E=A5raise=20ValueError?= =?UTF-8?q?=EF=BC=8C=E4=B8=8D=E8=A6=81=E7=AD=89=E5=BE=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- unilabos/registry/devices/liquid_handler.yaml | 2 +- unilabos/registry/registry.py | 2 +- unilabos/ros/nodes/presets/host_node.py | 11 ++++++++++- unilabos/ros/nodes/presets/protocol_node.py | 2 ++ 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/unilabos/registry/devices/liquid_handler.yaml b/unilabos/registry/devices/liquid_handler.yaml index 7e6e781..a901959 100644 --- a/unilabos/registry/devices/liquid_handler.yaml +++ b/unilabos/registry/devices/liquid_handler.yaml @@ -4388,11 +4388,11 @@ liquid_handler: deck: type: string simulator: + default: false type: boolean required: - backend - deck - - simulator type: object data: properties: {} diff --git a/unilabos/registry/registry.py b/unilabos/registry/registry.py index d7b292c..18916a2 100644 --- a/unilabos/registry/registry.py +++ b/unilabos/registry/registry.py @@ -110,7 +110,7 @@ class Registry: "placeholder_keys": { "res_id": "unilabos_resources", # 将当前实验室的全部物料id作为下拉框可选择 "device_id": "unilabos_devices", # 将当前实验室的全部设备id作为下拉框可选择 - "parent": "unilabos_resources", # 将当前实验室的全部物料id作为下拉框可选择 + "parent": "unilabos_nodes", # 将当前实验室的设备/物料作为下拉框可选择 }, }, "test_latency": { diff --git a/unilabos/ros/nodes/presets/host_node.py b/unilabos/ros/nodes/presets/host_node.py index 8356563..eb5c2bb 100644 --- a/unilabos/ros/nodes/presets/host_node.py +++ b/unilabos/ros/nodes/presets/host_node.py @@ -364,7 +364,16 @@ class HostNode(BaseROS2DeviceNode): resources, device_ids, bind_parent_ids, bind_locations, other_calling_params ): # 这里要求device_id传入必须是edge_device_id - namespace = "/devices/" + device_id + if device_id not in self.devices_names: + self.lab_logger().error(f"[Host Node] Device {device_id} not found in devices_names. Create resource failed.") + raise ValueError(f"[Host Node] Device {device_id} not found in devices_names. Create resource failed.") + + device_key = f"{self.devices_names[device_id]}/{device_id}" + if device_key not in self._online_devices: + self.lab_logger().error(f"[Host Node] Device {device_key} is offline. Create resource failed.") + raise ValueError(f"[Host Node] Device {device_key} is offline. Create resource failed.") + + namespace = self.devices_names[device_id] srv_address = f"/srv{namespace}/append_resource" sclient = self.create_client(SerialCommand, srv_address) sclient.wait_for_service() diff --git a/unilabos/ros/nodes/presets/protocol_node.py b/unilabos/ros/nodes/presets/protocol_node.py index 33fa0d7..6f491c7 100644 --- a/unilabos/ros/nodes/presets/protocol_node.py +++ b/unilabos/ros/nodes/presets/protocol_node.py @@ -112,6 +112,8 @@ class ROS2ProtocolNode(BaseROS2DeviceNode): f"添加了{write}方法(来源:{name} {communicate_hardware_info['read']})" ) + self.lab_logger().info(f"ROS2ProtocolNode {device_id} initialized with protocols: {self.protocol_names}") + def _setup_protocol_names(self, protocol_type): # 处理协议类型 if isinstance(protocol_type, str):