diff --git a/unilabos/devices/workstation/bioyond_studio/bioyond_cell/2025092701.xlsx b/unilabos/devices/workstation/bioyond_studio/bioyond_cell/2025092701.xlsx index 4147095e..9d069619 100644 Binary files a/unilabos/devices/workstation/bioyond_studio/bioyond_cell/2025092701.xlsx and b/unilabos/devices/workstation/bioyond_studio/bioyond_cell/2025092701.xlsx differ diff --git a/unilabos/devices/workstation/bioyond_studio/bioyond_cell/bioyond_cell_workstation.py b/unilabos/devices/workstation/bioyond_studio/bioyond_cell/bioyond_cell_workstation.py index ee825791..4b27572c 100644 --- a/unilabos/devices/workstation/bioyond_studio/bioyond_cell/bioyond_cell_workstation.py +++ b/unilabos/devices/workstation/bioyond_studio/bioyond_cell/bioyond_cell_workstation.py @@ -3,6 +3,7 @@ from cgi import print_arguments from doctest import debug from typing import Dict, Any, List, Optional import requests +from pylabrobot.resources.resource import Resource as ResourcePLR from pathlib import Path import pandas as pd import time @@ -254,7 +255,7 @@ class BioyondCellWorkstation(BioyondWorkstation): def auto_feeding4to3( self, # ★ 修改点:默认模板路径 - xlsx_path: Optional[str] = "C:/ML/GitHub/Uni-Lab-OS/unilabos/devices/workstation/bioyond_studio/bioyond_cell/material_template.xlsx", + xlsx_path: Optional[str] = "/Users/sml/work/Unilab/Uni-Lab-OS/unilabos/devices/workstation/bioyond_studio/bioyond_cell/material_template.xlsx", # ---------------- WH4 - 加样头面 (Z=1, 12个点位) ---------------- WH4_x1_y1_z1_1_materialName: str = "", WH4_x1_y1_z1_1_quantity: float = 0.0, WH4_x2_y1_z1_2_materialName: str = "", WH4_x2_y1_z1_2_quantity: float = 0.0, @@ -306,7 +307,7 @@ class BioyondCellWorkstation(BioyondWorkstation): # ---------- 模式 1: Excel 导入 ---------- if xlsx_path: - path = Path(xlsx_path) + path = Path(__file__).parent / Path(xlsx_path) if path.exists(): # ★ 修改点:路径存在才加载 try: df = pd.read_excel(path, sheet_name=0, header=None, engine="openpyxl") @@ -471,14 +472,23 @@ class BioyondCellWorkstation(BioyondWorkstation): - totalMass 自动计算为所有物料质量之和 - createTime 缺失或为空时自动填充为当前日期(YYYY/M/D) """ - path = Path(xlsx_path) + default_path = Path("/Users/sml/work/Unilab/Uni-Lab-OS/unilabos/devices/workstation/bioyond_studio/bioyond_cell/2025092701.xlsx") + path = Path(xlsx_path) if xlsx_path else default_path + print(f"[create_orders] 使用 Excel 路径: {path}") + if path != default_path: + print("[create_orders] 来源: 调用方传入自定义路径") + else: + print("[create_orders] 来源: 使用默认模板路径") + if not path.exists(): + print(f"[create_orders] ⚠️ Excel 文件不存在: {path}") raise FileNotFoundError(f"未找到 Excel 文件:{path}") try: df = pd.read_excel(path, sheet_name=0, engine="openpyxl") except Exception as e: raise RuntimeError(f"读取 Excel 失败:{e}") + print(f"[create_orders] Excel 读取成功,行数: {len(df)}, 列: {list(df.columns)}") # 列名容错:返回可选列名,找不到则返回 None def _pick(col_names: List[str]) -> Optional[str]: @@ -495,9 +505,20 @@ class BioyondCellWorkstation(BioyondWorkstation): col_pouch = _pick(["软包组装分液体积", "pouchCellInfo"]) col_cond = _pick(["电导测试分液体积", "conductivityInfo"]) col_cond_cnt = _pick(["电导测试分液瓶数", "conductivityBottleCount"]) + print("[create_orders] 列匹配结果:", { + "order_name": col_order_name, + "create_time": col_create_time, + "bottle_type": col_bottle_type, + "mix_time": col_mix_time, + "load": col_load, + "pouch": col_pouch, + "conductivity": col_cond, + "conductivity_bottle_count": col_cond_cnt, + }) # 物料列:所有以 (g) 结尾 material_cols = [c for c in df.columns if isinstance(c, str) and c.endswith("(g)")] + print(f"[create_orders] 识别到的物料列: {material_cols}") if not material_cols: raise KeyError("未发现任何以“(g)”结尾的物料列,请检查表头。") @@ -545,6 +566,9 @@ class BioyondCellWorkstation(BioyondWorkstation): if mass > 0: mats.append({"name": mcol.replace("(g)", ""), "mass": mass}) total_mass += mass + else: + if mass < 0: + print(f"[create_orders] 第 {idx+1} 行物料 {mcol} 数值为负数: {mass}") order_data = { "batchId": batch_id, @@ -559,11 +583,22 @@ class BioyondCellWorkstation(BioyondWorkstation): "materialInfos": mats, "totalMass": round(total_mass, 4) # 自动汇总 } + print(f"[create_orders] 第 {idx+1} 行解析结果: orderName={order_data['orderName']}, " + f"loadShedding={order_data['loadSheddingInfo']}, pouchCell={order_data['pouchCellInfo']}, " + f"conductivity={order_data['conductivityInfo']}, totalMass={order_data['totalMass']}, " + f"material_count={len(mats)}") + + if order_data["totalMass"] <= 0: + print(f"[create_orders] ⚠️ 第 {idx+1} 行总质量 <= 0,可能导致 LIMS 校验失败") + if not mats: + print(f"[create_orders] ⚠️ 第 {idx+1} 行未找到有效物料") + orders.append(order_data) + print(f"[create_orders] 即将提交订单数量: {len(orders)}") response = self._post_lims("/api/lims/order/orders", orders) - print(response) + print(f"[create_orders] 接口返回: {response}") # 等待任务报送成功 data_list = response.get("data", []) if data_list: @@ -1014,7 +1049,35 @@ class BioyondCellWorkstation(BioyondWorkstation): "create_result": create_result, "inbound_result": inbound_result, } + def resource_tree_transfer(self, old_parent: ResourcePLR, plr_resource: ResourcePLR, parent_resource: ResourcePLR): + # ROS2DeviceNode.run_async_func(self._ros_node.resource_tree_transfer, True, **{ + # "old_parent": old_parent, + # "plr_resource": plr_resource, + # "parent_resource": parent_resource, + # }) + print("resource_tree_transfer", plr_resource, parent_resource) + if hasattr(plr_resource, "unilabos_extra") and plr_resource.unilabos_extra: + if "update_resource_site" in plr_resource.unilabos_extra: + site = plr_resource.unilabos_extra["update_resource_site"] + plr_model = plr_resource.model + board_type = None + for key, (moudle_name,moudle_uuid) in MATERIAL_TYPE_MAPPINGS.items(): + if plr_model == moudle_name: + board_type = key + break + if board_type is None: + pass + bottle1 = plr_resource.children[0] + bottle_moudle = bottle1.model + bottle_type = None + for key, (moudle_name, moudle_uuid) in MATERIAL_TYPE_MAPPINGS.items(): + if bottle_moudle == moudle_name: + bottle_type = key + break + self.create_sample(plr_resource.name, board_type,bottle_type,site) + return + self.lab_logger().warning(f"无库位的上料,不处理,{plr_resource} 挂载到 {parent_resource}") def create_sample( self, diff --git a/unilabos/devices/workstation/bioyond_studio/config.py b/unilabos/devices/workstation/bioyond_studio/config.py index b594125b..adb2d720 100644 --- a/unilabos/devices/workstation/bioyond_studio/config.py +++ b/unilabos/devices/workstation/bioyond_studio/config.py @@ -8,8 +8,8 @@ import os # BioyondCellWorkstation 默认配置(包含所有必需参数) API_CONFIG = { # API 连接配置 - # "api_host": os.getenv("BIOYOND_API_HOST", "http://172.21.32.65:44389"),#实机 - "api_host": os.getenv("BIOYOND_API_HOST", "http://172.16.10.169:44388"),# 仿真机 + # "api_host": os.getenv("BIOYOND_API_HOST", "http://172.16.1.143:44389"),#实机 + "api_host": os.getenv("BIOYOND_API_HOST", "http://172.16.7.149:44388"),# 仿真机 "api_key": os.getenv("BIOYOND_API_KEY", "8A819E5C"), "timeout": int(os.getenv("BIOYOND_TIMEOUT", "30")), @@ -17,7 +17,7 @@ API_CONFIG = { "report_token": os.getenv("BIOYOND_REPORT_TOKEN", "CHANGE_ME_TOKEN"), # HTTP 服务配置 - "HTTP_host": os.getenv("BIOYOND_HTTP_HOST", "172.21.32.115"), # HTTP服务监听地址,监听计算机飞连ip地址 + "HTTP_host": os.getenv("BIOYOND_HTTP_HOST", "172.16.2.140"), # HTTP服务监听地址,监听计算机飞连ip地址 "HTTP_port": int(os.getenv("BIOYOND_HTTP_PORT", "8080")), "debug_mode": False,# 调试模式 } diff --git a/unilabos/devices/workstation/bioyond_studio/station.py b/unilabos/devices/workstation/bioyond_studio/station.py index d6fe4870..44f9cf19 100644 --- a/unilabos/devices/workstation/bioyond_studio/station.py +++ b/unilabos/devices/workstation/bioyond_studio/station.py @@ -177,7 +177,18 @@ class BioyondWorkstation(WorkstationBase): ROS2DeviceNode.run_async_func(self._ros_node.update_resource, True, **{ "resources": [self.deck] }) - + def resource_tree_transfer(self, old_parent: ResourcePLR, plr_resource: ResourcePLR, parent_resource: ResourcePLR): + # ROS2DeviceNode.run_async_func(self._ros_node.resource_tree_transfer, True, **{ + # "old_parent": old_parent, + # "plr_resource": plr_resource, + # "parent_resource": parent_resource, + # }) + print("resource_tree_transfer", plr_resource, parent_resource) + if hasattr(plr_resource, "unilabos_data") and plr_resource.unilabos_data: + if "update_resource_site" in plr_resource.unilabos_data: + site = plr_resource.unilabos_data["update_resource_site"] + return + self.lab_logger().warning(f"无库位的上料,不处理,{plr_resource} 挂载到 {parent_resource}") def transfer_resource_to_another(self, resource: List[ResourceSlot], mount_resource: List[ResourceSlot], sites: List[str], mount_device_id: DeviceSlot): ROS2DeviceNode.run_async_func(self._ros_node.transfer_resource_to_another, True, **{ "plr_resources": resource, diff --git a/unilabos/devices/workstation/coin_cell_assembly.zip b/unilabos/devices/workstation/coin_cell_assembly.zip deleted file mode 100644 index b95b7f4a..00000000 Binary files a/unilabos/devices/workstation/coin_cell_assembly.zip and /dev/null differ diff --git a/unilabos/devices/workstation/coin_cell_assembly/coin_cell_assembly.py b/unilabos/devices/workstation/coin_cell_assembly/coin_cell_assembly.py index 76570638..b8acb874 100644 --- a/unilabos/devices/workstation/coin_cell_assembly/coin_cell_assembly.py +++ b/unilabos/devices/workstation/coin_cell_assembly/coin_cell_assembly.py @@ -112,7 +112,7 @@ class CoinCellAssemblyWorkstation(WorkstationBase): def __init__( self, deck: Deck=None, - address: str = "172.21.33.176", + address: str = "172.16.28.102", port: str = "502", debug_mode: bool = False, *args, @@ -165,7 +165,7 @@ class CoinCellAssemblyWorkstation(WorkstationBase): print("测试模式,跳过连接") """ 工站的配置 """ - self.nodes = BaseClient.load_csv(os.path.join(os.path.dirname(__file__), 'coin_cell_assembly_a.csv')) + self.nodes = BaseClient.load_csv(os.path.join(os.path.dirname(__file__), 'coin_cell_assembly_1105.csv')) self.client = modbus_client.register_node_list(self.nodes) self.success = False self.allow_data_read = False #允许读取函数运行标志位 @@ -906,7 +906,7 @@ class CoinCellAssemblyWorkstation(WorkstationBase): return self.success - def func_allpack_cmd(self, elec_num, elec_use_num, elec_vol:int=50, assembly_type:int=7, assembly_pressure:int=4200, file_path: str="C:\\Users\\67484\\Desktop") -> bool: + def func_allpack_cmd(self, elec_num, elec_use_num, elec_vol:int=50, assembly_type:int=7, assembly_pressure:int=4200, file_path: str="/Users/sml/work") -> bool: elec_num, elec_use_num, elec_vol, assembly_type, assembly_pressure = int(elec_num), int(elec_use_num), int(elec_vol), int(assembly_type), int(assembly_pressure) summary_csv_file = os.path.join(file_path, "duandian.csv") # 如果断点文件存在,先读取之前的进度 diff --git a/unilabos/devices/workstation/coin_cell_assembly/coin_cell_assembly_1105.csv b/unilabos/devices/workstation/coin_cell_assembly/coin_cell_assembly_1105.csv new file mode 100644 index 00000000..3f7b357f --- /dev/null +++ b/unilabos/devices/workstation/coin_cell_assembly/coin_cell_assembly_1105.csv @@ -0,0 +1,64 @@ +Name,DataType,InitValue,Comment,Attribute,DeviceType,Address, +COIL_SYS_START_CMD,BOOL,,,,coil,9010, +COIL_SYS_STOP_CMD,BOOL,,,,coil,9020, +COIL_SYS_RESET_CMD,BOOL,,,,coil,9030, +COIL_SYS_HAND_CMD,BOOL,,,,coil,9040, +COIL_SYS_AUTO_CMD,BOOL,,,,coil,9050, +COIL_SYS_INIT_CMD,BOOL,,,,coil,9060, +COIL_UNILAB_SEND_MSG_SUCC_CMD,BOOL,,,,coil,9700, +COIL_UNILAB_REC_MSG_SUCC_CMD,BOOL,,,,coil,9710,unilab_rec_msg_succ_cmd +COIL_SYS_START_STATUS,BOOL,,,,coil,9210, +COIL_SYS_STOP_STATUS,BOOL,,,,coil,9220, +COIL_SYS_RESET_STATUS,BOOL,,,,coil,9230, +COIL_SYS_HAND_STATUS,BOOL,,,,coil,9240, +COIL_SYS_AUTO_STATUS,BOOL,,,,coil,9250, +COIL_SYS_INIT_STATUS,BOOL,,,,coil,9260, +COIL_REQUEST_REC_MSG_STATUS,BOOL,,,,coil,9500, +COIL_REQUEST_SEND_MSG_STATUS,BOOL,,,,coil,9510,request_send_msg_status +REG_MSG_ELECTROLYTE_USE_NUM,INT16,,,,hold_register,17000, +REG_MSG_ELECTROLYTE_NUM,INT16,,,,hold_register,17002,unilab_send_msg_electrolyte_num +REG_MSG_ELECTROLYTE_VOLUME,INT16,,,,hold_register,17004,unilab_send_msg_electrolyte_vol +REG_MSG_ASSEMBLY_TYPE,INT16,,,,hold_register,17006,unilab_send_msg_assembly_type +REG_MSG_ASSEMBLY_PRESSURE,INT16,,,,hold_register,17008,unilab_send_msg_assembly_pressure +REG_DATA_ASSEMBLY_COIN_CELL_NUM,INT16,,,,hold_register,16000,data_assembly_coin_cell_num +REG_DATA_OPEN_CIRCUIT_VOLTAGE,FLOAT32,,,,hold_register,16002,data_open_circuit_voltage +REG_DATA_AXIS_X_POS,FLOAT32,,,,hold_register,16004, +REG_DATA_AXIS_Y_POS,FLOAT32,,,,hold_register,16006, +REG_DATA_AXIS_Z_POS,FLOAT32,,,,hold_register,16008, +REG_DATA_POLE_WEIGHT,FLOAT32,,,,hold_register,16010,data_pole_weight +REG_DATA_ASSEMBLY_PER_TIME,FLOAT32,,,,hold_register,16012,data_assembly_time +REG_DATA_ASSEMBLY_PRESSURE,INT16,,,,hold_register,16014,data_assembly_pressure +REG_DATA_ELECTROLYTE_VOLUME,INT16,,,,hold_register,16016,data_electrolyte_volume +REG_DATA_COIN_NUM,INT16,,,,hold_register,16018,data_coin_num +REG_DATA_ELECTROLYTE_CODE,STRING,,,,hold_register,16020,data_electrolyte_code() +REG_DATA_COIN_CELL_CODE,STRING,,,,hold_register,16030,data_coin_cell_code() +REG_DATA_STACK_VISON_CODE,STRING,,,,hold_register,18004,data_stack_vision_code() +REG_DATA_GLOVE_BOX_PRESSURE,FLOAT32,,,,hold_register,16050,data_glove_box_pressure +REG_DATA_GLOVE_BOX_WATER_CONTENT,FLOAT32,,,,hold_register,16052,data_glove_box_water_content +REG_DATA_GLOVE_BOX_O2_CONTENT,FLOAT32,,,,hold_register,16054,data_glove_box_o2_content +UNILAB_SEND_ELECTROLYTE_BOTTLE_NUM,BOOL,,,,coil,9720, +UNILAB_RECE_ELECTROLYTE_BOTTLE_NUM,BOOL,,,,coil,9520, +REG_MSG_ELECTROLYTE_NUM_USED,INT16,,,,hold_register,17496, +REG_DATA_ELECTROLYTE_USE_NUM,INT16,,,,hold_register,16000, +UNILAB_SEND_FINISHED_CMD,BOOL,,,,coil,9730, +UNILAB_RECE_FINISHED_CMD,BOOL,,,,coil,9530, +REG_DATA_ASSEMBLY_TYPE,INT16,,,,hold_register,16018,ASSEMBLY_TYPE7or8 +COIL_ALUMINUM_FOIL,BOOL,,使用铝箔垫,,coil,9340, +REG_MSG_NE_PLATE_MATRIX,INT16,,负极片矩阵点位,,hold_register,17440, +REG_MSG_SEPARATOR_PLATE_MATRIX,INT16,,隔膜矩阵点位,,hold_register,17450, +REG_MSG_TIP_BOX_MATRIX,INT16,,移液枪头矩阵点位,,hold_register,17480, +REG_MSG_NE_PLATE_NUM,INT16,,负极片盘数,,hold_register,17443, +REG_MSG_SEPARATOR_PLATE_NUM,INT16,,隔膜盘数,,hold_register,17453, +REG_MSG_PRESS_MODE,BOOL,,压制模式(false:压力检测模式,True:距离模式),,coil,9360,电池压制模式 +,,,,,,, +,BOOL,,视觉对位(false:使用,true:忽略),,coil,9300,视觉对位 +,BOOL,,复检(false:使用,true:忽略),,coil,9310,视觉复检 +,BOOL,,手套箱_左仓(false:使用,true:忽略),,coil,9320,手套箱左仓 +,BOOL,,手套箱_右仓(false:使用,true:忽略),,coil,9420,手套箱右仓 +,BOOL,,真空检知(false:使用,true:忽略),,coil,9350,真空检知 +,BOOL,,电解液添加模式(false:单次滴液,true:二次滴液),,coil,9370,滴液模式 +,BOOL,,正极片称重(false:使用,true:忽略),,coil,9380,正极片称重 +,BOOL,,正负极片组装方式(false:正装,true:倒装),,coil,9390,正负极反装 +,BOOL,,压制清洁(false:使用,true:忽略),,coil,9400,压制清洁 +,BOOL,,物料盘摆盘方式(false:水平摆盘,true:堆叠摆盘),,coil,9410,负极片摆盘方式 +REG_MSG_BATTERY_CLEAN_IGNORE,BOOL,,忽略电池清洁(false:使用,true:忽略),,coil,9460, diff --git a/unilabos/resources/bioyond/YB_bottle_carriers.py b/unilabos/resources/bioyond/YB_bottle_carriers.py index 01d64c52..5284f0af 100644 --- a/unilabos/resources/bioyond/YB_bottle_carriers.py +++ b/unilabos/resources/bioyond/YB_bottle_carriers.py @@ -355,7 +355,7 @@ def YB_6x5ml_DispensingVialCarrier(name: str) -> BottleCarrier: size_y=carrier_size_y, size_z=carrier_size_z, sites=sites, - model="6x5ml_DispensingVialCarrier", + model="YB_6x5ml_DispensingVialCarrier", ) carrier.num_items_x = 4 carrier.num_items_y = 2 @@ -554,7 +554,7 @@ def YB_jia_yang_tou_da_1X1_carrier(name: str) -> BottleCarrier: size_y=carrier_size_y, size_z=carrier_size_z, sites=sites, - model="6x_LargeDispenseHeadCarrier", + model="YB_6x_LargeDispenseHeadCarrier", ) carrier.num_items_x = 1 carrier.num_items_y = 1 diff --git a/unilabos/resources/bioyond/YB_bottles.py b/unilabos/resources/bioyond/YB_bottles.py index 8ebdb415..432383ec 100644 --- a/unilabos/resources/bioyond/YB_bottles.py +++ b/unilabos/resources/bioyond/YB_bottles.py @@ -87,7 +87,7 @@ def YB_fen_ye_5ml_Bottle( height=height, max_volume=max_volume, barcode=barcode, - model="Separation_Bottle_5ml", + model="YB_fen_ye_5ml_Bottle", ) """20ml分液瓶"""