From bef69db3b6a10ccf87fe73e5e7464f68fa8ccd39 Mon Sep 17 00:00:00 2001 From: dijkstra402 Date: Tue, 2 Dec 2025 15:42:07 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E5=89=8D=E7=AB=AF=E7=89=A9?= =?UTF-8?q?=E6=96=99=E6=98=BE=E7=A4=BA=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bioyond_cell/bioyond_cell_workstation.py | 25 ++++++++++++++++--- unilabos/resources/graphio.py | 11 +++++--- 2 files changed, 29 insertions(+), 7 deletions(-) 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 e1a94d2d..fbf7b874 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 @@ -24,6 +24,18 @@ from unilabos.utils.log import logger from unilabos.registry.registry import lab_registry from unilabos.ros.nodes.base_device_node import ROS2DeviceNode + +class device(BIOYOND_YB_Deck): + + @classmethod + def deserialize(cls, data, allow_marshal=False): # type: ignore[override] + patched = dict(data) + if patched.get("type") == "device": + patched["type"] = "Deck" + if patched.get("category") == "device": + patched["category"] = "deck" + return super().deserialize(patched, allow_marshal=allow_marshal) + def _iso_local_now_ms() -> str: # 文档要求:到毫秒 + Z,例如 2025-08-15T05:43:22.814Z dt = datetime.now() @@ -409,7 +421,8 @@ class BioyondCellWorkstation(BioyondWorkstation): result = self.wait_for_order_finish(order_code) return { "api_response": response, - "order_finish": result + "order_finish": result, + "items": items, } @@ -1337,7 +1350,7 @@ class BioyondCellWorkstation(BioyondWorkstation): return result.return_info return result - def run_feeding_stage(self) -> Dict[str, List[Dict[str, Any]]]: + def run_feeding_stage(self) -> Dict[str, Any]: self.create_sample( board_type="配液瓶(小)板", bottle_type="配液瓶(小)", @@ -1353,11 +1366,15 @@ class BioyondCellWorkstation(BioyondWorkstation): warehouse_name="手动堆栈" ) self.scheduler_start() - self.auto_feeding4to3( + feeding_task = self.auto_feeding4to3( xlsx_path="/Users/sml/work/Unilab/Uni-Lab-OS/unilabos/devices/workstation/bioyond_studio/bioyond_cell/material_template.xlsx" ) feeding_materials = self._fetch_bioyond_materials() - return {"feeding_materials": feeding_materials} + return { + "feeding_materials": feeding_materials, + "feeding_items": feeding_task.get("items", []), + "feeding_task": feeding_task, + } def run_liquid_preparation_stage( self, diff --git a/unilabos/resources/graphio.py b/unilabos/resources/graphio.py index a6c2f30b..3d55468c 100644 --- a/unilabos/resources/graphio.py +++ b/unilabos/resources/graphio.py @@ -674,10 +674,15 @@ def resource_bioyond_to_plr(bioyond_materials: list[dict], type_mapping: Dict[st for loc in material.get("locations", []): if hasattr(deck, "warehouses") and loc.get("whName") in deck.warehouses: warehouse = deck.warehouses[loc["whName"]] + num_x = getattr(warehouse, "num_items_x", 0) or 0 + num_y = getattr(warehouse, "num_items_y", 0) or 0 + num_z = getattr(warehouse, "num_items_z", 0) or 0 + if num_x <= 0 or num_y <= 0 or num_z <= 0: + continue idx = ( - (loc.get("y", 0) - 1) * warehouse.num_items_x * warehouse.num_items_y - + (loc.get("x", 0) - 1) * warehouse.num_items_x - + (loc.get("z", 0) - 1) + (loc.get("z", 0) - 1) * num_x * num_y + + (loc.get("y", 0) - 1) * num_x + + (loc.get("x", 0) - 1) ) if 0 <= idx < warehouse.capacity: if warehouse[idx] is None or isinstance(warehouse[idx], ResourceHolder):