Skip to content

Commit b64de9b

Browse files
committed
refactor: Split tipbox storage into left and right warehouses
1 parent 6f7adce commit b64de9b

File tree

6 files changed

+374
-122
lines changed

6 files changed

+374
-122
lines changed

unilabos/resources/bioyond/YB_warehouses.py

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,11 @@ def bioyond_warehouse_reagent_storage(name: str) -> WareHouse:
8383
category="warehouse",
8484
)
8585

86-
def bioyond_warehouse_tipbox_storage(name: str) -> WareHouse:
87-
"""创建BioYond站内Tip盒堆栈(A01~B03),用于存放枪头盒"""
86+
def bioyond_warehouse_tipbox_storage_left(name: str) -> WareHouse:
87+
"""创建BioYond站内Tip盒堆栈左侧部分(A02~B03),2列2行"""
8888
return warehouse_factory(
8989
name=name,
90-
num_items_x=3, # 3列(01-03)
90+
num_items_x=2, # 2列
9191
num_items_y=2, # 2行(A-B)
9292
num_items_z=1, # 1层
9393
dx=10.0,
@@ -97,7 +97,25 @@ def bioyond_warehouse_tipbox_storage(name: str) -> WareHouse:
9797
item_dy=96.0,
9898
item_dz=120.0,
9999
category="warehouse",
100-
col_offset=0,
100+
col_offset=1, # 从02开始: A02, A03
101+
layout="row-major",
102+
)
103+
104+
def bioyond_warehouse_tipbox_storage_right(name: str) -> WareHouse:
105+
"""创建BioYond站内Tip盒堆栈右侧部分(A01~B01),1列2行"""
106+
return warehouse_factory(
107+
name=name,
108+
num_items_x=1, # 1列
109+
num_items_y=2, # 2行(A-B)
110+
num_items_z=1, # 1层
111+
dx=10.0,
112+
dy=10.0,
113+
dz=10.0,
114+
item_dx=137.0,
115+
item_dy=96.0,
116+
item_dz=120.0,
117+
category="warehouse",
118+
col_offset=0, # 从01开始: A01
101119
layout="row-major",
102120
)
103121

@@ -167,7 +185,7 @@ def bioyond_warehouse_1x4x2(name: str) -> WareHouse:
167185

168186
def bioyond_warehouse_1x2x2(name: str) -> WareHouse:
169187
"""创建BioYond 1x2x2仓库(1列×2行×2层)- 旧版本,已弃用
170-
188+
171189
布局(2层):
172190
层1: A01
173191
B01
@@ -191,7 +209,7 @@ def bioyond_warehouse_1x2x2(name: str) -> WareHouse:
191209

192210
def bioyond_warehouse_2x2x1(name: str) -> WareHouse:
193211
"""创建BioYond 2x2x1仓库(2行×2列×1层)
194-
212+
195213
布局:
196214
A01 | A02
197215
B01 | B02
@@ -246,14 +264,14 @@ def bioyond_warehouse_1x3x3(name: str) -> WareHouse:
246264

247265
def bioyond_warehouse_5x3x1(name: str, row_offset: int = 0) -> WareHouse:
248266
"""创建BioYond 5x3x1仓库(5行×3列×1层)
249-
267+
250268
标准布局(row_offset=0):
251269
A01 | A02 | A03
252270
B01 | B02 | B03
253271
C01 | C02 | C03
254272
D01 | D02 | D03
255273
E01 | E02 | E03
256-
274+
257275
带偏移布局(row_offset=5):
258276
F01 | F02 | F03
259277
G01 | G02 | G03
@@ -281,7 +299,7 @@ def bioyond_warehouse_5x3x1(name: str, row_offset: int = 0) -> WareHouse:
281299

282300
def bioyond_warehouse_3x3x1(name: str) -> WareHouse:
283301
"""创建BioYond 3x3x1仓库(3行×3列×1层)
284-
302+
285303
布局:
286304
A01 | A02 | A03
287305
B01 | B02 | B03

unilabos/resources/bioyond/decks.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
bioyond_warehouse_1x8x4,
1919
bioyond_warehouse_reagent_storage,
2020
# bioyond_warehouse_liquid_preparation,
21-
bioyond_warehouse_tipbox_storage, # 新增:Tip盒堆栈
21+
bioyond_warehouse_tipbox_storage_left, # 新增:Tip盒堆栈(左)
22+
bioyond_warehouse_tipbox_storage_right, # 新增:Tip盒堆栈(右)
2223
bioyond_warehouse_density_vial,
2324
)
2425

@@ -47,16 +48,17 @@ def setup(self) -> None:
4748
"堆栈1右": bioyond_warehouse_1x4x4_right("堆栈1右"), # 右侧堆栈: A05~D08
4849
"站内试剂存放堆栈": bioyond_warehouse_reagent_storage("站内试剂存放堆栈"), # A01~A02
4950
# "移液站内10%分装液体准备仓库": bioyond_warehouse_liquid_preparation("移液站内10%分装液体准备仓库"), # A01~B04
50-
"站内Tip盒堆栈": bioyond_warehouse_tipbox_storage("站内Tip盒堆栈"), # A01~B03, 存放枪头盒.
51+
"站内Tip盒堆栈(左)": bioyond_warehouse_tipbox_storage_left("站内Tip盒堆栈(左)"), # A02~B03
52+
"站内Tip盒堆栈(右)": bioyond_warehouse_tipbox_storage_right("站内Tip盒堆栈(右)"), # A01~B01
5153
"测量小瓶仓库(测密度)": bioyond_warehouse_density_vial("测量小瓶仓库(测密度)"), # A01~B03
5254
}
5355
self.warehouse_locations = {
54-
"堆栈1左": Coordinate(-200.0, 450.0, 0.0), # 左侧位置
55-
"堆栈1右": Coordinate(2350.0, 450.0, 0.0), # 右侧位置
56-
"站内试剂存放堆栈": Coordinate(730.0, 390.0, 0.0),
57-
# "移液站内10%分装液体准备仓库": Coordinate(1200.0, 600.0, 0.0),
58-
"站内Tip盒堆栈": Coordinate(300.0, 150.0, 0.0),
59-
"测量小瓶仓库(测密度)": Coordinate(940.0, 530.0, 0.0),
56+
"堆栈1左": Coordinate(-200.0, 400.0, 0.0), # 左侧位置
57+
"堆栈1右": Coordinate(2350.0, 400.0, 0.0), # 右侧位置
58+
"站内试剂存放堆栈": Coordinate(640.0, 400.0, 0.0),
59+
"站内Tip盒堆栈(左)": Coordinate(300.0, 100.0, 0.0),
60+
"站内Tip盒堆栈(右)": Coordinate(2250.0, 100.0, 0.0), # 向右偏移 2 * item_dx (137.0)
61+
"测量小瓶仓库(测密度)": Coordinate(1000.0, 530.0, 0.0),
6062
}
6163

6264
for warehouse_name, warehouse in self.warehouses.items():
@@ -89,9 +91,9 @@ def setup(self) -> None:
8991
"溶液堆栈": bioyond_warehouse_1x4x4("溶液堆栈"), # 4行×4列 (A01-D04)
9092
}
9193
self.warehouse_locations = {
92-
"粉末堆栈": Coordinate(0.0, 450.0, 0.0),
93-
"试剂堆栈": Coordinate(1850.0, 200.0, 0.0),
94-
"溶液堆栈": Coordinate(2500.0, 450.0, 0.0),
94+
"粉末堆栈": Coordinate(-200.0, 400.0, 0.0),
95+
"试剂堆栈": Coordinate(1750.0, 160.0, 0.0),
96+
"溶液堆栈": Coordinate(2350.0, 400.0, 0.0),
9597
}
9698

9799
for warehouse_name, warehouse in self.warehouses.items():

unilabos/resources/bioyond/warehouses.py

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,11 @@ def bioyond_warehouse_reagent_storage(name: str) -> WareHouse:
9797
layout="vertical-col-major", # ⭐ 竖向warehouse专用布局
9898
)
9999

100-
def bioyond_warehouse_tipbox_storage(name: str) -> WareHouse:
101-
"""创建BioYond站内Tip盒堆栈(A01~B03),用于存放枪头盒"""
100+
def bioyond_warehouse_tipbox_storage_left(name: str) -> WareHouse:
101+
"""创建BioYond站内Tip盒堆栈左侧部分(A02~B03),2列2行"""
102102
return warehouse_factory(
103103
name=name,
104-
num_items_x=3, # 3列(01-03)
104+
num_items_x=2, # 2列
105105
num_items_y=2, # 2行(A-B)
106106
num_items_z=1, # 1层
107107
dx=10.0,
@@ -111,7 +111,25 @@ def bioyond_warehouse_tipbox_storage(name: str) -> WareHouse:
111111
item_dy=96.0,
112112
item_dz=120.0,
113113
category="warehouse",
114-
col_offset=0,
114+
col_offset=1, # 从02开始: A02, A03
115+
layout="row-major",
116+
)
117+
118+
def bioyond_warehouse_tipbox_storage_right(name: str) -> WareHouse:
119+
"""创建BioYond站内Tip盒堆栈右侧部分(A01~B01),1列2行"""
120+
return warehouse_factory(
121+
name=name,
122+
num_items_x=1, # 1列
123+
num_items_y=2, # 2行(A-B)
124+
num_items_z=1, # 1层
125+
dx=10.0,
126+
dy=10.0,
127+
dz=10.0,
128+
item_dx=137.0,
129+
item_dy=96.0,
130+
item_dz=120.0,
131+
category="warehouse",
132+
col_offset=0, # 从01开始: A01
115133
layout="row-major",
116134
)
117135

unilabos/resources/graphio.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -811,6 +811,15 @@ def resource_bioyond_to_plr(bioyond_materials: list[dict], type_mapping: Dict[st
811811
logger.warning(f"物料 {material['name']} 的列号 x={x_val} 超出范围,无法映射到堆栈1左或堆栈1右")
812812
continue
813813

814+
# 特殊处理: Bioyond的"站内Tip盒堆栈"也需要进行拆分映射
815+
if wh_name == "站内Tip盒堆栈":
816+
y_val = loc.get("y", 1)
817+
if y_val == 1:
818+
wh_name = "站内Tip盒堆栈(右)"
819+
elif y_val in [2, 3]:
820+
wh_name = "站内Tip盒堆栈(左)"
821+
y = y - 1 # 调整列号,因为左侧仓库对应的 Bioyond y=2 实际上是它的第1列
822+
814823
if hasattr(deck, "warehouses") and wh_name in deck.warehouses:
815824
warehouse = deck.warehouses[wh_name]
816825
logger.debug(f"[Warehouse匹配] 找到warehouse: {wh_name} (容量: {warehouse.capacity}, 行×列: {warehouse.num_items_x}×{warehouse.num_items_y})")
@@ -837,7 +846,7 @@ def resource_bioyond_to_plr(bioyond_materials: list[dict], type_mapping: Dict[st
837846
row_idx = y - 1 # Bioyond的y(01,02,03) → row索引(0,1,2)
838847
layer_idx = z - 1
839848

840-
idx = layer_idx * (warehouse.num_items_x * warehouse.num_items_y) + row_idx * warehouse.num_items_x + col_idx
849+
idx = layer_idx * (warehouse.num_items_x * warehouse.num_items_y) + row_idx * warehouse.num_items_y + col_idx
841850
logger.debug(f"🔍 竖向warehouse {wh_name}: Bioyond(x={x},y={y},z={z}) → warehouse(col={col_idx},row={row_idx},layer={layer_idx}) → idx={idx}, capacity={warehouse.capacity}")
842851

843852
# 普通横向warehouse的处理

unilabos/test/experiments/dispensing_station_bioyond.json

Lines changed: 114 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -9,49 +9,125 @@
99
"parent": null,
1010
"type": "device",
1111
"class": "bioyond_dispensing_station",
12+
"position": {
13+
"x": 0,
14+
"y": 0,
15+
"z": 0
16+
},
1217
"config": {
13-
"config": {
14-
"api_key": "DE9BDDA0",
15-
"api_host": "http://192.168.1.200:44388",
16-
"material_type_mappings": {
17-
"BIOYOND_PolymerStation_1FlaskCarrier": [
18-
"烧杯",
19-
"3a14196b-24f2-ca49-9081-0cab8021bf1a"
20-
],
21-
"BIOYOND_PolymerStation_1BottleCarrier": [
22-
"试剂瓶",
23-
"3a14196b-8bcf-a460-4f74-23f21ca79e72"
24-
],
25-
"BIOYOND_PolymerStation_6StockCarrier": [
26-
"分装板",
27-
"3a14196e-5dfe-6e21-0c79-fe2036d052c4"
28-
],
29-
"BIOYOND_PolymerStation_Liquid_Vial": [
30-
"10%分装小瓶",
31-
"3a14196c-76be-2279-4e22-7310d69aed68"
32-
],
33-
"BIOYOND_PolymerStation_Solid_Vial": [
34-
"90%分装小瓶",
35-
"3a14196c-cdcf-088d-dc7d-5cf38f0ad9ea"
36-
],
37-
"BIOYOND_PolymerStation_8StockCarrier": [
38-
"样品板",
39-
"3a14196e-b7a0-a5da-1931-35f3000281e9"
40-
],
41-
"BIOYOND_PolymerStation_Solid_Stock": [
42-
"样品瓶",
43-
"3a14196a-cf7d-8aea-48d8-b9662c7dba94"
44-
]
18+
"api_key": "YOUR_API_KEY",
19+
"api_host": "http://your-api-host:port",
20+
"material_type_mappings": {
21+
"BIOYOND_PolymerStation_1FlaskCarrier": [
22+
"烧杯",
23+
"uuid-placeholder-flask"
24+
],
25+
"BIOYOND_PolymerStation_1BottleCarrier": [
26+
"试剂瓶",
27+
"uuid-placeholder-bottle"
28+
],
29+
"BIOYOND_PolymerStation_6StockCarrier": [
30+
"分装板",
31+
"uuid-placeholder-stock-6"
32+
],
33+
"BIOYOND_PolymerStation_Liquid_Vial": [
34+
"10%分装小瓶",
35+
"uuid-placeholder-liquid-vial"
36+
],
37+
"BIOYOND_PolymerStation_Solid_Vial": [
38+
"90%分装小瓶",
39+
"uuid-placeholder-solid-vial"
40+
],
41+
"BIOYOND_PolymerStation_8StockCarrier": [
42+
"样品板",
43+
"uuid-placeholder-stock-8"
44+
],
45+
"BIOYOND_PolymerStation_Solid_Stock": [
46+
"样品瓶",
47+
"uuid-placeholder-solid-stock"
48+
]
49+
},
50+
"warehouse_mapping": {
51+
"粉末堆栈": {
52+
"uuid": "uuid-placeholder-powder-stack",
53+
"site_uuids": {
54+
"A01": "uuid-placeholder-powder-A01",
55+
"A02": "uuid-placeholder-powder-A02",
56+
"A03": "uuid-placeholder-powder-A03",
57+
"A04": "uuid-placeholder-powder-A04",
58+
"B01": "uuid-placeholder-powder-B01",
59+
"B02": "uuid-placeholder-powder-B02",
60+
"B03": "uuid-placeholder-powder-B03",
61+
"B04": "uuid-placeholder-powder-B04",
62+
"C01": "uuid-placeholder-powder-C01",
63+
"C02": "uuid-placeholder-powder-C02",
64+
"C03": "uuid-placeholder-powder-C03",
65+
"C04": "uuid-placeholder-powder-C04",
66+
"D01": "uuid-placeholder-powder-D01",
67+
"D02": "uuid-placeholder-powder-D02",
68+
"D03": "uuid-placeholder-powder-D03",
69+
"D04": "uuid-placeholder-powder-D04"
70+
}
71+
},
72+
"溶液堆栈": {
73+
"uuid": "uuid-placeholder-liquid-stack",
74+
"site_uuids": {
75+
"A01": "uuid-placeholder-liquid-A01",
76+
"A02": "uuid-placeholder-liquid-A02",
77+
"A03": "uuid-placeholder-liquid-A03",
78+
"A04": "uuid-placeholder-liquid-A04",
79+
"B01": "uuid-placeholder-liquid-B01",
80+
"B02": "uuid-placeholder-liquid-B02",
81+
"B03": "uuid-placeholder-liquid-B03",
82+
"B04": "uuid-placeholder-liquid-B04",
83+
"C01": "uuid-placeholder-liquid-C01",
84+
"C02": "uuid-placeholder-liquid-C02",
85+
"C03": "uuid-placeholder-liquid-C03",
86+
"C04": "uuid-placeholder-liquid-C04",
87+
"D01": "uuid-placeholder-liquid-D01",
88+
"D02": "uuid-placeholder-liquid-D02",
89+
"D03": "uuid-placeholder-liquid-D03",
90+
"D04": "uuid-placeholder-liquid-D04"
91+
}
92+
},
93+
"试剂堆栈": {
94+
"uuid": "uuid-placeholder-reagent-stack",
95+
"site_uuids": {
96+
"A01": "uuid-placeholder-reagent-A01",
97+
"A02": "uuid-placeholder-reagent-A02",
98+
"A03": "uuid-placeholder-reagent-A03",
99+
"A04": "uuid-placeholder-reagent-A04",
100+
"B01": "uuid-placeholder-reagent-B01",
101+
"B02": "uuid-placeholder-reagent-B02",
102+
"B03": "uuid-placeholder-reagent-B03",
103+
"B04": "uuid-placeholder-reagent-B04"
104+
}
45105
}
46106
},
47-
"deck": {
48-
"data": {
49-
"_resource_child_name": "Bioyond_Dispensing_Deck",
50-
"_resource_type": "unilabos.resources.bioyond.decks:BIOYOND_PolymerPreparationStation_Deck"
107+
"http_service_config": {
108+
"http_service_host": "127.0.0.1",
109+
"http_service_port": 8080
110+
},
111+
"material_default_parameters": {
112+
"NMP": {
113+
"unit": "毫升",
114+
"density": "1.03",
115+
"densityUnit": "g/mL",
116+
"description": "N-甲基吡咯烷酮 (N-Methyl-2-pyrrolidone)"
51117
}
52118
},
53-
"protocol_type": []
119+
"material_type_parameters": {}
120+
},
121+
"deck": {
122+
"data": {
123+
"_resource_child_name": "Bioyond_Dispensing_Deck",
124+
"_resource_type": "unilabos.resources.bioyond.decks:BIOYOND_PolymerPreparationStation_Deck"
125+
}
54126
},
127+
"size_x": 2700.0,
128+
"size_y": 1080.0,
129+
"size_z": 1500.0,
130+
"protocol_type": [],
55131
"data": {}
56132
},
57133
{
@@ -80,4 +156,4 @@
80156
"data": {}
81157
}
82158
]
83-
}
159+
}

0 commit comments

Comments
 (0)