From b9ddee8f2cb2c9595a241752a87ceac8b47c4470 Mon Sep 17 00:00:00 2001 From: ZiWei <131428629+ZiWei09@users.noreply.github.com> Date: Tue, 28 Oct 2025 00:12:33 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=B6=B2=E4=BD=93=E6=8A=95?= =?UTF-8?q?=E6=96=99=E6=96=B9=E6=B3=95=EF=BC=8C=E6=94=AF=E6=8C=81=E9=80=9A?= =?UTF-8?q?=E8=BF=87=E6=BA=B6=E5=89=82=E4=BF=A1=E6=81=AF=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E8=AE=A1=E7=AE=97=E4=BD=93=E7=A7=AF=EF=BC=8C=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?solvents=E5=8F=82=E6=95=B0=E5=B9=B6=E6=9B=B4=E6=96=B0=E6=96=87?= =?UTF-8?q?=E6=A1=A3=E6=8F=8F=E8=BF=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bioyond_studio/reaction_station.py | 34 ++++++++++++++- .../devices/reaction_station_bioyond.yaml | 43 ++++++++++++------- 2 files changed, 59 insertions(+), 18 deletions(-) diff --git a/unilabos/devices/workstation/bioyond_studio/reaction_station.py b/unilabos/devices/workstation/bioyond_studio/reaction_station.py index f7cb0f8d..d35427d2 100644 --- a/unilabos/devices/workstation/bioyond_studio/reaction_station.py +++ b/unilabos/devices/workstation/bioyond_studio/reaction_station.py @@ -208,7 +208,8 @@ class BioyondReactionStation(BioyondWorkstation): def liquid_feeding_solvents( self, assign_material_name: str, - volume: str, + volume: str = None, + solvents = None, titration_type: str = "1", time: str = "360", torque_variation: int = 2, @@ -218,12 +219,41 @@ class BioyondReactionStation(BioyondWorkstation): Args: assign_material_name: 物料名称 - volume: 分液量(μL) + volume: 分液量(μL),直接指定体积(可选,如果提供solvents则自动计算) + solvents: 溶剂信息的字典或JSON字符串(可选),格式如下: + { + "additional_solvent": 33.55092503597727, # 溶剂体积(mL) + "total_liquid_volume": 48.00916988195499 + } + 如果提供solvents,则从中提取additional_solvent并转换为μL titration_type: 是否滴定(1=否, 2=是) time: 观察时间(分钟) torque_variation: 是否观察(int类型, 1=否, 2=是) temperature: 温度设定(°C) """ + # 处理 volume 参数:优先使用直接传入的 volume,否则从 solvents 中提取 + if volume is None and solvents is not None: + # 参数类型转换:如果是字符串则解析为字典 + if isinstance(solvents, str): + try: + solvents = json.loads(solvents) + except json.JSONDecodeError as e: + raise ValueError(f"solvents参数JSON解析失败: {str(e)}") + + # 参数验证 + if not isinstance(solvents, dict): + raise ValueError("solvents 必须是字典类型或有效的JSON字符串") + + # 提取 additional_solvent 值 + additional_solvent = solvents.get("additional_solvent") + if additional_solvent is None: + raise ValueError("solvents 中没有找到 additional_solvent 字段") + + # 转换为微升(μL) - 从毫升(mL)转换 + volume = str(float(additional_solvent) * 1000) + elif volume is None: + raise ValueError("必须提供 volume 或 solvents 参数之一") + self.append_to_workflow_sequence('{"web_workflow_name": "Liquid_feeding_solvents"}') material_id = self.hardware_interface._get_material_id_by_name(assign_material_name) if material_id is None: diff --git a/unilabos/registry/devices/reaction_station_bioyond.yaml b/unilabos/registry/devices/reaction_station_bioyond.yaml index f8719e57..68007cb3 100644 --- a/unilabos/registry/devices/reaction_station_bioyond.yaml +++ b/unilabos/registry/devices/reaction_station_bioyond.yaml @@ -120,6 +120,7 @@ reaction_station.bioyond: feedback: {} goal: assign_material_name: assign_material_name + solvents: solvents temperature: temperature time: time titration_type: titration_type @@ -127,15 +128,23 @@ reaction_station.bioyond: volume: volume goal_default: assign_material_name: '' - temperature: '' - time: '' - titration_type: '' - torque_variation: '' + solvents: '' + temperature: '25.00' + time: '360' + titration_type: '1' + torque_variation: '2' volume: '' - handles: {} + handles: + input: + - data_key: solvents + data_source: handle + data_type: object + handler_key: solvents + io_type: source + label: Solvents Data From Calculation Node result: {} schema: - description: 液体投料-溶剂 + description: 液体投料-溶剂。可以直接提供volume(μL),或通过solvents对象自动从additional_solvent(mL)计算volume。 properties: feedback: {} goal: @@ -143,28 +152,30 @@ reaction_station.bioyond: assign_material_name: description: 物料名称 type: string + solvents: + description: '溶剂信息对象(可选),包含: additional_solvent(溶剂体积mL), total_liquid_volume(总液体体积mL)。如果提供,将自动计算volume' + type: string temperature: - description: 温度设定(°C) + default: '25.00' + description: 温度设定(°C),默认25.00 type: string time: - description: 观察时间(分钟) + default: '360' + description: 观察时间(分钟),默认360 type: string titration_type: - description: 是否滴定(1=否, 2=是) + default: '1' + description: 是否滴定(1=否, 2=是),默认1 type: string torque_variation: - description: 是否观察 (1=否, 2=是) + default: '2' + description: 是否观察 (1=否, 2=是),默认2 type: string volume: - description: 分液公式(μL) + description: 分液量(μL)。可直接提供,或通过solvents参数自动计算 type: string required: - - volume - assign_material_name - - time - - torque_variation - - titration_type - - temperature type: object result: {} required: