更新液体投料方法,支持通过溶剂信息自动计算体积,添加solvents参数并更新文档描述

This commit is contained in:
ZiWei
2025-10-28 00:12:33 +08:00
parent a0c5095304
commit b9ddee8f2c
2 changed files with 59 additions and 18 deletions

View File

@@ -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:

View File

@@ -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: