From 0f2555c90c8d7bce040ca934895c9d0ef4e0c7cc Mon Sep 17 00:00:00 2001 From: Xuwznln <18435084+Xuwznln@users.noreply.github.com> Date: Sat, 31 May 2025 00:00:39 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=B3=A8=E5=86=8C=E8=A1=A8=E4=B8=8A?= =?UTF-8?q?=E6=8A=A5handle=E5=92=8Cschema=20(param=20input)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pump_and_valve/solenoid_valve_mock.py | 8 +-- .../pump_and_valve/vacuum_pump_mock.py | 6 +- unilabos/registry/devices/liquid_handler.yaml | 15 +++++ unilabos/registry/devices/pump_and_valve.yaml | 41 ++++++++++-- .../registry/devices/vacuum_and_purge.yaml | 67 +++++++++++++++++++ unilabos/registry/devices/work_station.yaml | 2 +- unilabos/registry/registry.py | 16 ++++- 7 files changed, 139 insertions(+), 16 deletions(-) diff --git a/unilabos/devices/pump_and_valve/solenoid_valve_mock.py b/unilabos/devices/pump_and_valve/solenoid_valve_mock.py index 08820ca0..b6735a3f 100644 --- a/unilabos/devices/pump_and_valve/solenoid_valve_mock.py +++ b/unilabos/devices/pump_and_valve/solenoid_valve_mock.py @@ -5,22 +5,22 @@ class SolenoidValveMock: def __init__(self, port: str = "COM6"): self._status = "Idle" self._valve_position = "OPEN" - + @property def status(self) -> str: return self._status - + @property def valve_position(self) -> str: return self._valve_position def get_valve_position(self) -> str: return self._valve_position - + def set_valve_position(self, position): self._status = "Busy" time.sleep(5) - + self._valve_position = position time.sleep(5) self._status = "Idle" diff --git a/unilabos/devices/pump_and_valve/vacuum_pump_mock.py b/unilabos/devices/pump_and_valve/vacuum_pump_mock.py index 3e330570..96a48426 100644 --- a/unilabos/devices/pump_and_valve/vacuum_pump_mock.py +++ b/unilabos/devices/pump_and_valve/vacuum_pump_mock.py @@ -4,17 +4,17 @@ import time class VacuumPumpMock: def __init__(self, port: str = "COM6"): self._status = "OPEN" - + @property def status(self) -> str: return self._status def get_status(self) -> str: return self._status - + def set_status(self, position): time.sleep(5) - + self._status = position time.sleep(5) diff --git a/unilabos/registry/devices/liquid_handler.yaml b/unilabos/registry/devices/liquid_handler.yaml index 313a8b80..95f06ca6 100644 --- a/unilabos/registry/devices/liquid_handler.yaml +++ b/unilabos/registry/devices/liquid_handler.yaml @@ -245,6 +245,21 @@ liquid_handler: target_vols: target_vols aspiration_flow_rate: aspiration_flow_rate dispense_flow_rates: dispense_flow_rates + handles: + input: + - handler_key: liquid-input + label: Liquid Input + data_type: resource + io_type: target + data_source: handle + data_key: liquid + output: + - handler_key: liquid-output + label: Liquid Output + data_type: resource + io_type: source + data_source: executor + data_key: liquid schema: type: object properties: diff --git a/unilabos/registry/devices/pump_and_valve.yaml b/unilabos/registry/devices/pump_and_valve.yaml index 5fdd8606..fd5dd98e 100644 --- a/unilabos/registry/devices/pump_and_valve.yaml +++ b/unilabos/registry/devices/pump_and_valve.yaml @@ -23,20 +23,51 @@ syringe_pump_with_valve.runze: type: string description: The position of the valve required: - - status - - position - - valve_position + - status + - position + - valve_position additionalProperties: false - solenoid_valve.mock: description: Mock solenoid valve class: module: unilabos.devices.pump_and_valve.solenoid_valve_mock:SolenoidValveMock type: python + status_types: + status: String + valve_position: String + action_value_mappings: + open: + type: EmptyIn + goal: {} + feedback: {} + result: {} + close: + type: EmptyIn + goal: {} + feedback: {} + result: {} + handles: + input: + - handler_key: fluid-input + label: Fluid Input + data_type: fluid + output: + - handler_key: fluid-output + label: Fluid Output + data_type: fluid + init_param_schema: + type: object + properties: + port: + type: string + description: "通信端口" + default: "COM6" + required: + - port solenoid_valve: description: Solenoid valve class: module: unilabos.devices.pump_and_valve.solenoid_valve:SolenoidValve - type: python \ No newline at end of file + type: python diff --git a/unilabos/registry/devices/vacuum_and_purge.yaml b/unilabos/registry/devices/vacuum_and_purge.yaml index 236ceddc..b6108203 100644 --- a/unilabos/registry/devices/vacuum_and_purge.yaml +++ b/unilabos/registry/devices/vacuum_and_purge.yaml @@ -22,9 +22,76 @@ vacuum_pump.mock: string: string feedback: {} result: {} + handles: + input: + - handler_key: fluid-input + label: Fluid Input + data_type: fluid + io_type: target + data_source: handle + data_key: fluid_in + output: + - handler_key: fluid-output + label: Fluid Output + data_type: fluid + io_type: source + data_source: executor + data_key: fluid_out + init_param_schema: + type: object + properties: + port: + type: string + description: "通信端口" + default: "COM6" + required: + - port gas_source.mock: description: Mock gas source class: module: unilabos.devices.pump_and_valve.vacuum_pump_mock:VacuumPumpMock type: python + status_types: + status: String + action_value_mappings: + open: + type: EmptyIn + goal: {} + feedback: {} + result: {} + close: + type: EmptyIn + goal: {} + feedback: {} + result: {} + set_status: + type: StrSingleInput + goal: + string: string + feedback: {} + result: {} + handles: + input: + - handler_key: fluid-input + label: Fluid Input + data_type: fluid + io_type: target + data_source: handle + data_key: fluid_in + output: + - handler_key: fluid-output + label: Fluid Output + data_type: fluid + io_type: source + data_source: executor + data_key: fluid_out + init_param_schema: + type: object + properties: + port: + type: string + description: "通信端口" + default: "COM6" + required: + - port diff --git a/unilabos/registry/devices/work_station.yaml b/unilabos/registry/devices/work_station.yaml index fadfd5ec..d3a37338 100644 --- a/unilabos/registry/devices/work_station.yaml +++ b/unilabos/registry/devices/work_station.yaml @@ -4,4 +4,4 @@ workstation: module: unilabos.ros.nodes.presets.protocol_node:ROS2ProtocolNode type: ros2 schema: - properties: {} \ No newline at end of file + properties: {} diff --git a/unilabos/registry/registry.py b/unilabos/registry/registry.py index c68e0d8d..4cfb7dab 100644 --- a/unilabos/registry/registry.py +++ b/unilabos/registry/registry.py @@ -25,9 +25,7 @@ class Registry: self.ResourceCreateFromOuterEasy = self._replace_type_with_class( "ResourceCreateFromOuterEasy", "host_node", f"动作 create_resource" ) - self.EmptyIn = self._replace_type_with_class( - "EmptyIn", "host_node", f"" - ) + self.EmptyIn = self._replace_type_with_class("EmptyIn", "host_node", f"") self.device_type_registry = {} self.resource_type_registry = {} self._setup_called = False # 跟踪setup是否已调用 @@ -99,6 +97,8 @@ class Registry: }, "icon": "icon_device.webp", "registry_type": "device", + "handles": [], + "init_param_schema": {}, "schema": {"properties": {}, "additionalProperties": False, "type": "object"}, "file_path": "/", } @@ -132,6 +132,12 @@ class Registry: resource_info["description"] = "" if "icon" not in resource_info: resource_info["icon"] = "" + if "icon" not in resource_info: + resource_info["icon"] = "" + if "handles" not in resource_info: + resource_info["handles"] = [] + if "init_param_schema" not in resource_info: + resource_info["init_param_schema"] = {} resource_info["registry_type"] = "resource" self.resource_type_registry.update(data) logger.debug( @@ -194,6 +200,10 @@ class Registry: device_config["description"] = "" if "icon" not in device_config: device_config["icon"] = "" + if "handles" not in device_config: + device_config["handles"] = [] + if "init_param_schema" not in device_config: + device_config["init_param_schema"] = {} device_config["registry_type"] = "device" if "class" in device_config: # 处理状态类型 From 478a85951c29221e926b4f62d50489b533cbbdf0 Mon Sep 17 00:00:00 2001 From: Xuwznln <18435084+Xuwznln@users.noreply.github.com> Date: Sat, 31 May 2025 00:00:55 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dbiomek=E7=BC=BA=E5=B0=91?= =?UTF-8?q?=E7=9A=84=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- unilabos/devices/liquid_handling/biomek.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/unilabos/devices/liquid_handling/biomek.py b/unilabos/devices/liquid_handling/biomek.py index ccca72d1..41812d15 100644 --- a/unilabos/devices/liquid_handling/biomek.py +++ b/unilabos/devices/liquid_handling/biomek.py @@ -30,6 +30,7 @@ class LiquidHandlerBiomek(LiquidHandlerAbstract): protocol_version: str, protocol_author: str, protocol_date: str, + protocol_type: str, none_keys: List[str] = [], ): """ @@ -54,6 +55,7 @@ class LiquidHandlerBiomek(LiquidHandlerAbstract): "version": protocol_version, "author": protocol_author, "date": protocol_date, + "type": protocol_type, }, "labwares": [], "steps": [],