refactor(bioyond_studio): 优化材料缓存加载和参数验证逻辑

改进材料缓存加载逻辑以支持多种材料类型和详细材料处理
更新工作流参数验证中的字段名从key/value改为Key/DisplayValue
移除未使用的merge_workflow_with_parameters方法
添加get_station_info方法获取工作站基础信息
清理实验文件中的注释代码和更新导入路径
This commit is contained in:
ZiWei
2025-10-16 23:58:24 +08:00
parent 398b2dde3f
commit f5753afb7c
5 changed files with 711 additions and 640 deletions

View File

@@ -3,8 +3,8 @@
"""
import json
from reaction_station import BioyondReactionStation
from config import API_CONFIG, WORKFLOW_MAPPINGS, DECK_CONFIG, MATERIAL_TYPE_MAPPINGS
from unilabos.devices.workstation.bioyond_studio.reaction_station import BioyondReactionStation
from unilabos.devices.workstation.bioyond_studio.config import API_CONFIG, WORKFLOW_MAPPINGS, DECK_CONFIG, MATERIAL_TYPE_MAPPINGS
def run_experiment():
@@ -45,7 +45,7 @@ def run_experiment():
assign_material_name="ODA",
time="0",
torque_variation="1",
titrationType="1",
titration_type="1",
temperature=-10
)
@@ -56,14 +56,14 @@ def run_experiment():
assign_material_name="MPDA",
time="5",
torque_variation="2",
titrationType="1",
titration_type="1",
temperature=0
)
# 4. 液体投料-小瓶非滴定
print("4. 添加液体投料-小瓶非滴定,带参数...")
Bioyond.liquid_feeding_vials_non_titration(
volumeFormula="639.5",
volume_formula="639.5",
assign_material_name="SIDA",
titration_type="1",
time="0",
@@ -91,7 +91,7 @@ def run_experiment():
assign_material_name="BTDA1",
temperature=-10.00
)
#二杆样品版90
print("7. 添加固体进料小瓶,带参数...")
Bioyond.solid_feeding_vials(
material_id="3",
@@ -100,7 +100,7 @@ def run_experiment():
assign_material_name="BTDA2",
temperature=25.00
)
#二杆样品版90
print("8. 添加固体进料小瓶,带参数...")
Bioyond.solid_feeding_vials(
material_id="3",
@@ -196,8 +196,8 @@ def run_experiment():
print("\n4. 执行process_and_execute_workflow...")
result = Bioyond.process_and_execute_workflow(
workflow_name="test3_8",
task_name="实验3_8"
workflow_name="test3",
task_name="实验3"
)
# 显示执行结果
@@ -207,9 +207,9 @@ def run_experiment():
result_dict = json.loads(result)
if result_dict.get("success"):
print("任务创建成功!")
print(f"- 工作流: {result_dict.get('workflow', {}).get('name')}")
print(f"- 工作流ID: {result_dict.get('workflow', {}).get('id')}")
print(f"- 任务结果: {result_dict.get('task')}")
# print(f"- 工作流: {result_dict.get('workflow', {}).get('name')}")
# print(f"- 工作流ID: {result_dict.get('workflow', {}).get('id')}")
# print(f"- 任务结果: {result_dict.get('task')}")
else:
print(f"任务创建失败: {result_dict.get('error')}")
except:
@@ -229,166 +229,166 @@ def run_experiment():
return Bioyond
def prepare_materials(bioyond):
"""准备实验材料(可选)"""
# def prepare_materials(bioyond):
# """准备实验材料(可选)"""
# 样品板材料数据定义
material_data_yp_1 = {
"typeId": "3a142339-80de-8f25-6093-1b1b1b6c322e",
"name": "样品板-1",
"unit": "",
"quantity": 1,
"details": [
{
"typeId": "3a14233a-84a3-088d-6676-7cb4acd57c64",
"name": "BPDA-DD-1",
"quantity": 1,
"x": 1,
"y": 1,
"Parameters": "{\"molecular\": 1}"
},
{
"typeId": "3a14233a-84a3-088d-6676-7cb4acd57c64",
"name": "PEPA",
"quantity": 1,
"x": 1,
"y": 2,
"Parameters": "{\"molecular\": 1}"
},
{
"typeId": "3a14233a-84a3-088d-6676-7cb4acd57c64",
"name": "BPDA-DD-2",
"quantity": 1,
"x": 1,
"y": 3,
"Parameters": "{\"molecular\": 1}"
},
{
"typeId": "3a14233a-84a3-088d-6676-7cb4acd57c64",
"name": "BPDA-1",
"quantity": 1,
"x": 2,
"y": 1,
"Parameters": "{\"molecular\": 1}"
},
{
"typeId": "3a14233a-84a3-088d-6676-7cb4acd57c64",
"name": "PMDA",
"quantity": 1,
"x": 2,
"y": 2,
"Parameters": "{\"molecular\": 1}"
},
{
"typeId": "3a14233a-84a3-088d-6676-7cb4acd57c64",
"name": "BPDA-2",
"quantity": 1,
"x": 2,
"y": 3,
"Parameters": "{\"molecular\": 1}"
}
],
"Parameters": "{}"
}
# # 样品板材料数据定义
# material_data_yp_1 = {
# "typeId": "3a142339-80de-8f25-6093-1b1b1b6c322e",
# "name": "样品板-1",
# "unit": "个",
# "quantity": 1,
# "details": [
# {
# "typeId": "3a14233a-84a3-088d-6676-7cb4acd57c64",
# "name": "BPDA-DD-1",
# "quantity": 1,
# "x": 1,
# "y": 1,
# "Parameters": "{\"molecular\": 1}"
# },
# {
# "typeId": "3a14233a-84a3-088d-6676-7cb4acd57c64",
# "name": "PEPA",
# "quantity": 1,
# "x": 1,
# "y": 2,
# "Parameters": "{\"molecular\": 1}"
# },
# {
# "typeId": "3a14233a-84a3-088d-6676-7cb4acd57c64",
# "name": "BPDA-DD-2",
# "quantity": 1,
# "x": 1,
# "y": 3,
# "Parameters": "{\"molecular\": 1}"
# },
# {
# "typeId": "3a14233a-84a3-088d-6676-7cb4acd57c64",
# "name": "BPDA-1",
# "quantity": 1,
# "x": 2,
# "y": 1,
# "Parameters": "{\"molecular\": 1}"
# },
# {
# "typeId": "3a14233a-84a3-088d-6676-7cb4acd57c64",
# "name": "PMDA",
# "quantity": 1,
# "x": 2,
# "y": 2,
# "Parameters": "{\"molecular\": 1}"
# },
# {
# "typeId": "3a14233a-84a3-088d-6676-7cb4acd57c64",
# "name": "BPDA-2",
# "quantity": 1,
# "x": 2,
# "y": 3,
# "Parameters": "{\"molecular\": 1}"
# }
# ],
# "Parameters": "{}"
# }
material_data_yp_2 = {
"typeId": "3a142339-80de-8f25-6093-1b1b1b6c322e",
"name": "样品板-2",
"unit": "",
"quantity": 1,
"details": [
{
"typeId": "3a14233a-84a3-088d-6676-7cb4acd57c64",
"name": "BPDA-DD",
"quantity": 1,
"x": 1,
"y": 1,
"Parameters": "{\"molecular\": 1}"
},
{
"typeId": "3a14233a-84a3-088d-6676-7cb4acd57c64",
"name": "SIDA",
"quantity": 1,
"x": 1,
"y": 2,
"Parameters": "{\"molecular\": 1}"
},
{
"typeId": "3a14233a-84a3-088d-6676-7cb4acd57c64",
"name": "BTDA-1",
"quantity": 1,
"x": 2,
"y": 1,
"Parameters": "{\"molecular\": 1}"
},
{
"typeId": "3a14233a-84a3-088d-6676-7cb4acd57c64",
"name": "BTDA-2",
"quantity": 1,
"x": 2,
"y": 2,
"Parameters": "{\"molecular\": 1}"
},
{
"typeId": "3a14233a-84a3-088d-6676-7cb4acd57c64",
"name": "BTDA-3",
"quantity": 1,
"x": 2,
"y": 3,
"Parameters": "{\"molecular\": 1}"
}
],
"Parameters": "{}"
}
# material_data_yp_2 = {
# "typeId": "3a142339-80de-8f25-6093-1b1b1b6c322e",
# "name": "样品板-2",
# "unit": "个",
# "quantity": 1,
# "details": [
# {
# "typeId": "3a14233a-84a3-088d-6676-7cb4acd57c64",
# "name": "BPDA-DD",
# "quantity": 1,
# "x": 1,
# "y": 1,
# "Parameters": "{\"molecular\": 1}"
# },
# {
# "typeId": "3a14233a-84a3-088d-6676-7cb4acd57c64",
# "name": "SIDA",
# "quantity": 1,
# "x": 1,
# "y": 2,
# "Parameters": "{\"molecular\": 1}"
# },
# {
# "typeId": "3a14233a-84a3-088d-6676-7cb4acd57c64",
# "name": "BTDA-1",
# "quantity": 1,
# "x": 2,
# "y": 1,
# "Parameters": "{\"molecular\": 1}"
# },
# {
# "typeId": "3a14233a-84a3-088d-6676-7cb4acd57c64",
# "name": "BTDA-2",
# "quantity": 1,
# "x": 2,
# "y": 2,
# "Parameters": "{\"molecular\": 1}"
# },
# {
# "typeId": "3a14233a-84a3-088d-6676-7cb4acd57c64",
# "name": "BTDA-3",
# "quantity": 1,
# "x": 2,
# "y": 3,
# "Parameters": "{\"molecular\": 1}"
# }
# ],
# "Parameters": "{}"
# }
# 烧杯材料数据定义
beaker_materials = [
{
"typeId": "3a14233b-f0a9-ba84-eaa9-0d4718b361b6",
"name": "PDA-1",
"unit": "微升",
"quantity": 1,
"parameters": "{\"DeviceMaterialType\":\"NMP\"}"
},
{
"typeId": "3a14233b-f0a9-ba84-eaa9-0d4718b361b6",
"name": "TFDB",
"unit": "微升",
"quantity": 1,
"parameters": "{\"DeviceMaterialType\":\"NMP\"}"
},
{
"typeId": "3a14233b-f0a9-ba84-eaa9-0d4718b361b6",
"name": "ODA",
"unit": "微升",
"quantity": 1,
"parameters": "{\"DeviceMaterialType\":\"NMP\"}"
},
{
"typeId": "3a14233b-f0a9-ba84-eaa9-0d4718b361b6",
"name": "MPDA",
"unit": "微升",
"quantity": 1,
"parameters": "{\"DeviceMaterialType\":\"NMP\"}"
},
{
"typeId": "3a14233b-f0a9-ba84-eaa9-0d4718b361b6",
"name": "PDA-2",
"unit": "微升",
"quantity": 1,
"parameters": "{\"DeviceMaterialType\":\"NMP\"}"
}
]
# # 烧杯材料数据定义
# beaker_materials = [
# {
# "typeId": "3a14233b-f0a9-ba84-eaa9-0d4718b361b6",
# "name": "PDA-1",
# "unit": "微升",
# "quantity": 1,
# "parameters": "{\"DeviceMaterialType\":\"NMP\"}"
# },
# {
# "typeId": "3a14233b-f0a9-ba84-eaa9-0d4718b361b6",
# "name": "TFDB",
# "unit": "微升",
# "quantity": 1,
# "parameters": "{\"DeviceMaterialType\":\"NMP\"}"
# },
# {
# "typeId": "3a14233b-f0a9-ba84-eaa9-0d4718b361b6",
# "name": "ODA",
# "unit": "微升",
# "quantity": 1,
# "parameters": "{\"DeviceMaterialType\":\"NMP\"}"
# },
# {
# "typeId": "3a14233b-f0a9-ba84-eaa9-0d4718b361b6",
# "name": "MPDA",
# "unit": "微升",
# "quantity": 1,
# "parameters": "{\"DeviceMaterialType\":\"NMP\"}"
# },
# {
# "typeId": "3a14233b-f0a9-ba84-eaa9-0d4718b361b6",
# "name": "PDA-2",
# "unit": "微升",
# "quantity": 1,
# "parameters": "{\"DeviceMaterialType\":\"NMP\"}"
# }
# ]
# 如果需要可以在这里调用add_material方法添加材料
# 例如:
# result = bioyond.add_material(json.dumps(material_data_yp_1))
# print(f"添加材料结果: {result}")
# # 如果需要可以在这里调用add_material方法添加材料
# # 例如:
# # result = bioyond.add_material(json.dumps(material_data_yp_1))
# # print(f"添加材料结果: {result}")
return {
"sample_plates": [material_data_yp_1, material_data_yp_2],
"beakers": beaker_materials
}
# return {
# "sample_plates": [material_data_yp_1, material_data_yp_2],
# "beakers": beaker_materials
# }
if __name__ == "__main__":