mirror of
https://github.com/dptech-corp/Uni-Lab-OS.git
synced 2025-12-17 13:01:12 +00:00
add: prcxi res
fix: startup slow
This commit is contained in:
@@ -222,7 +222,7 @@ def main():
|
|||||||
print_unilab_banner(args_dict)
|
print_unilab_banner(args_dict)
|
||||||
|
|
||||||
# 注册表
|
# 注册表
|
||||||
build_registry(args_dict["registry_path"])
|
build_registry(args_dict["registry_path"], False, args_dict["upload_registry"])
|
||||||
if args_dict["graph"] is None:
|
if args_dict["graph"] is None:
|
||||||
request_startup_json = http_client.request_startup_json()
|
request_startup_json = http_client.request_startup_json()
|
||||||
if not request_startup_json:
|
if not request_startup_json:
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ def main():
|
|||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
load_config_from_file(args.config)
|
load_config_from_file(args.config)
|
||||||
# 构建注册表
|
# 构建注册表
|
||||||
build_registry(args.registry, args.complete_registry)
|
build_registry(args.registry, args.complete_registry, True)
|
||||||
from unilabos.app.mq import mqtt_client
|
from unilabos.app.mq import mqtt_client
|
||||||
|
|
||||||
# 连接mqtt
|
# 连接mqtt
|
||||||
|
|||||||
44
unilabos/devices/liquid_handling/prcxi/prcxi_res.py
Normal file
44
unilabos/devices/liquid_handling/prcxi/prcxi_res.py
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
import collections
|
||||||
|
|
||||||
|
from pylabrobot.resources import opentrons_96_tiprack_10ul
|
||||||
|
from pylabrobot.resources.opentrons.plates import corning_96_wellplate_360ul_flat, nest_96_wellplate_2ml_deep
|
||||||
|
|
||||||
|
from unilabos.devices.liquid_handling.prcxi.prcxi import PRCXI9300Container, PRCXI9300Trash
|
||||||
|
|
||||||
|
|
||||||
|
def get_well_container(name: str) -> PRCXI9300Container:
|
||||||
|
well_containers = corning_96_wellplate_360ul_flat(name).serialize()
|
||||||
|
plate = PRCXI9300Container(name=name, size_x=50, size_y=50, size_z=10, category="plate",
|
||||||
|
ordering=collections.OrderedDict())
|
||||||
|
plate_serialized = plate.serialize()
|
||||||
|
well_containers.update({k: v for k, v in plate_serialized.items() if k not in ["children"]})
|
||||||
|
new_plate: PRCXI9300Container = PRCXI9300Container.deserialize(well_containers)
|
||||||
|
return new_plate
|
||||||
|
|
||||||
|
def get_tip_rack(name: str) -> PRCXI9300Container:
|
||||||
|
tip_racks = opentrons_96_tiprack_10ul("name").serialize()
|
||||||
|
tip_rack = PRCXI9300Container(name=name, size_x=50, size_y=50, size_z=10, category="tip_rack",
|
||||||
|
ordering=collections.OrderedDict())
|
||||||
|
tip_rack_serialized = tip_rack.serialize()
|
||||||
|
tip_racks.update({k: v for k, v in tip_rack_serialized.items() if k not in ["children"]})
|
||||||
|
new_tip_rack: PRCXI9300Container = PRCXI9300Container.deserialize(tip_racks)
|
||||||
|
return new_tip_rack
|
||||||
|
|
||||||
|
def prcxi_96_wellplate_360ul_flat(name: str):
|
||||||
|
return get_well_container(name)
|
||||||
|
|
||||||
|
def prcxi_opentrons_96_tiprack_10ul(name: str):
|
||||||
|
return get_tip_rack(name)
|
||||||
|
|
||||||
|
def prcxi_trash(name: str = None):
|
||||||
|
return PRCXI9300Trash(name="trash", size_x=50, size_y=50, size_z=10, category="trash")
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
# Example usage
|
||||||
|
test_plate = prcxi_96_wellplate_360ul_flat("test_plate")
|
||||||
|
test_rack = prcxi_opentrons_96_tiprack_10ul("test_rack")
|
||||||
|
tash = prcxi_trash("trash")
|
||||||
|
print(test_plate)
|
||||||
|
print(test_rack)
|
||||||
|
print(tash)
|
||||||
|
# Output will be a dictionary representation of the PRCXI9300Container with well details
|
||||||
@@ -53,7 +53,7 @@ class Registry:
|
|||||||
# 其他状态变量
|
# 其他状态变量
|
||||||
# self.is_host_mode = False # 移至BasicConfig中
|
# self.is_host_mode = False # 移至BasicConfig中
|
||||||
|
|
||||||
def setup(self, complete_registry=False):
|
def setup(self, complete_registry=False, upload_registry=False):
|
||||||
# 检查是否已调用过setup
|
# 检查是否已调用过setup
|
||||||
if self._setup_called:
|
if self._setup_called:
|
||||||
logger.critical("[UniLab Registry] setup方法已被调用过,不允许多次调用")
|
logger.critical("[UniLab Registry] setup方法已被调用过,不允许多次调用")
|
||||||
@@ -160,14 +160,14 @@ class Registry:
|
|||||||
sys.path.append(str(sys_path))
|
sys.path.append(str(sys_path))
|
||||||
self.load_device_types(path, complete_registry)
|
self.load_device_types(path, complete_registry)
|
||||||
if BasicConfig.enable_resource_load:
|
if BasicConfig.enable_resource_load:
|
||||||
self.load_resource_types(path, complete_registry)
|
self.load_resource_types(path, complete_registry, upload_registry)
|
||||||
else:
|
else:
|
||||||
logger.warning("跳过了资源注册表加载!")
|
logger.warning("跳过了资源注册表加载!")
|
||||||
logger.info("[UniLab Registry] 注册表设置完成")
|
logger.info("[UniLab Registry] 注册表设置完成")
|
||||||
# 标记setup已被调用
|
# 标记setup已被调用
|
||||||
self._setup_called = True
|
self._setup_called = True
|
||||||
|
|
||||||
def load_resource_types(self, path: os.PathLike, complete_registry: bool):
|
def load_resource_types(self, path: os.PathLike, complete_registry: bool, upload_registry: bool):
|
||||||
abs_path = Path(path).absolute()
|
abs_path = Path(path).absolute()
|
||||||
resource_path = abs_path / "resources"
|
resource_path = abs_path / "resources"
|
||||||
files = list(resource_path.glob("*/*.yaml"))
|
files = list(resource_path.glob("*/*.yaml"))
|
||||||
@@ -194,7 +194,12 @@ class Registry:
|
|||||||
resource_info["handles"] = []
|
resource_info["handles"] = []
|
||||||
if "init_param_schema" not in resource_info:
|
if "init_param_schema" not in resource_info:
|
||||||
resource_info["init_param_schema"] = {}
|
resource_info["init_param_schema"] = {}
|
||||||
if complete_registry:
|
if "config_info" in resource_info:
|
||||||
|
del resource_info["config_info"]
|
||||||
|
if "file_path" in resource_info:
|
||||||
|
del resource_info["file_path"]
|
||||||
|
complete_data[resource_id] = copy.deepcopy(dict(sorted(resource_info.items())))
|
||||||
|
if upload_registry:
|
||||||
class_info = resource_info.get("class", {})
|
class_info = resource_info.get("class", {})
|
||||||
if len(class_info) and "module" in class_info:
|
if len(class_info) and "module" in class_info:
|
||||||
if class_info.get("type") == "pylabrobot":
|
if class_info.get("type") == "pylabrobot":
|
||||||
@@ -205,7 +210,6 @@ class Registry:
|
|||||||
res_instance = res_class(res_class.__name__)
|
res_instance = res_class(res_class.__name__)
|
||||||
res_ulr = tree_to_list([resource_plr_to_ulab(res_instance)])
|
res_ulr = tree_to_list([resource_plr_to_ulab(res_instance)])
|
||||||
resource_info["config_info"] = res_ulr
|
resource_info["config_info"] = res_ulr
|
||||||
complete_data[resource_id] = copy.deepcopy(dict(sorted(resource_info.items()))) # 稍后dump到文件
|
|
||||||
resource_info["registry_type"] = "resource"
|
resource_info["registry_type"] = "resource"
|
||||||
resource_info["file_path"] = str(file.absolute()).replace("\\", "/")
|
resource_info["file_path"] = str(file.absolute()).replace("\\", "/")
|
||||||
complete_data = dict(sorted(complete_data.items()))
|
complete_data = dict(sorted(complete_data.items()))
|
||||||
@@ -629,7 +633,7 @@ class Registry:
|
|||||||
lab_registry = Registry()
|
lab_registry = Registry()
|
||||||
|
|
||||||
|
|
||||||
def build_registry(registry_paths=None, complete_registry=False):
|
def build_registry(registry_paths=None, complete_registry=False, upload_registry=False):
|
||||||
"""
|
"""
|
||||||
构建或获取Registry单例实例
|
构建或获取Registry单例实例
|
||||||
|
|
||||||
@@ -653,6 +657,6 @@ def build_registry(registry_paths=None, complete_registry=False):
|
|||||||
lab_registry.registry_paths.append(path)
|
lab_registry.registry_paths.append(path)
|
||||||
|
|
||||||
# 初始化注册表
|
# 初始化注册表
|
||||||
lab_registry.setup(complete_registry)
|
lab_registry.setup(complete_registry, upload_registry)
|
||||||
|
|
||||||
return lab_registry
|
return lab_registry
|
||||||
|
|||||||
@@ -4,9 +4,7 @@ hplc_plate:
|
|||||||
class:
|
class:
|
||||||
module: unilabos.devices.resource_container.container:PlateContainer
|
module: unilabos.devices.resource_container.container:PlateContainer
|
||||||
type: python
|
type: python
|
||||||
config_info: []
|
|
||||||
description: HPLC板
|
description: HPLC板
|
||||||
file_path: C:/Users/10230/PycharmProjects/Uni-Lab-OS/unilabos/registry/resources/common/resource_container.yaml
|
|
||||||
handles: []
|
handles: []
|
||||||
icon: ''
|
icon: ''
|
||||||
init_param_schema: {}
|
init_param_schema: {}
|
||||||
@@ -28,9 +26,7 @@ plate_96_high:
|
|||||||
class:
|
class:
|
||||||
module: unilabos.devices.resource_container.container:PlateContainer
|
module: unilabos.devices.resource_container.container:PlateContainer
|
||||||
type: python
|
type: python
|
||||||
config_info: []
|
|
||||||
description: 96孔板
|
description: 96孔板
|
||||||
file_path: C:/Users/10230/PycharmProjects/Uni-Lab-OS/unilabos/registry/resources/common/resource_container.yaml
|
|
||||||
handles: []
|
handles: []
|
||||||
icon: ''
|
icon: ''
|
||||||
init_param_schema: {}
|
init_param_schema: {}
|
||||||
@@ -52,9 +48,7 @@ tiprack_96_high:
|
|||||||
class:
|
class:
|
||||||
module: unilabos.devices.resource_container.container:TipRackContainer
|
module: unilabos.devices.resource_container.container:TipRackContainer
|
||||||
type: python
|
type: python
|
||||||
config_info: []
|
|
||||||
description: 96孔板
|
description: 96孔板
|
||||||
file_path: C:/Users/10230/PycharmProjects/Uni-Lab-OS/unilabos/registry/resources/common/resource_container.yaml
|
|
||||||
handles: []
|
handles: []
|
||||||
icon: ''
|
icon: ''
|
||||||
init_param_schema: {}
|
init_param_schema: {}
|
||||||
|
|||||||
@@ -4,9 +4,7 @@ OTDeck:
|
|||||||
class:
|
class:
|
||||||
module: pylabrobot.resources.opentrons.deck:OTDeck
|
module: pylabrobot.resources.opentrons.deck:OTDeck
|
||||||
type: pylabrobot
|
type: pylabrobot
|
||||||
config_info: []
|
|
||||||
description: Opentrons deck
|
description: Opentrons deck
|
||||||
file_path: C:/Users/10230/PycharmProjects/Uni-Lab-OS/unilabos/registry/resources/opentrons/deck.yaml
|
|
||||||
handles: []
|
handles: []
|
||||||
icon: ''
|
icon: ''
|
||||||
init_param_schema: {}
|
init_param_schema: {}
|
||||||
@@ -21,9 +19,7 @@ hplc_station:
|
|||||||
class:
|
class:
|
||||||
module: unilabos.devices.resource_container.container:DeckContainer
|
module: unilabos.devices.resource_container.container:DeckContainer
|
||||||
type: python
|
type: python
|
||||||
config_info: []
|
|
||||||
description: hplc_station deck
|
description: hplc_station deck
|
||||||
file_path: C:/Users/10230/PycharmProjects/Uni-Lab-OS/unilabos/registry/resources/opentrons/deck.yaml
|
|
||||||
handles: []
|
handles: []
|
||||||
icon: ''
|
icon: ''
|
||||||
init_param_schema: {}
|
init_param_schema: {}
|
||||||
|
|||||||
@@ -4,34 +4,7 @@ Opentrons_96_adapter_Vb:
|
|||||||
class:
|
class:
|
||||||
module: pylabrobot.resources.opentrons.plate_adapters:Opentrons_96_adapter_Vb
|
module: pylabrobot.resources.opentrons.plate_adapters:Opentrons_96_adapter_Vb
|
||||||
type: pylabrobot
|
type: pylabrobot
|
||||||
config_info:
|
|
||||||
- children: []
|
|
||||||
class: ''
|
|
||||||
config:
|
|
||||||
barcode: null
|
|
||||||
category: plate_adapter
|
|
||||||
model: Opentrons_96_adapter_Vb
|
|
||||||
rotation:
|
|
||||||
type: Rotation
|
|
||||||
x: 0
|
|
||||||
y: 0
|
|
||||||
z: 0
|
|
||||||
size_x: 127.76
|
|
||||||
size_y: 85.48
|
|
||||||
size_z: 18.55
|
|
||||||
type: PlateAdapter
|
|
||||||
data: {}
|
|
||||||
id: Opentrons_96_adapter_Vb
|
|
||||||
name: Opentrons_96_adapter_Vb
|
|
||||||
parent: null
|
|
||||||
position:
|
|
||||||
x: 0
|
|
||||||
y: 0
|
|
||||||
z: 0
|
|
||||||
sample_id: null
|
|
||||||
type: container
|
|
||||||
description: Opentrons 96 adapter Vb
|
description: Opentrons 96 adapter Vb
|
||||||
file_path: C:/Users/10230/PycharmProjects/Uni-Lab-OS/unilabos/registry/resources/opentrons/plate_adapters.yaml
|
|
||||||
handles: []
|
handles: []
|
||||||
icon: ''
|
icon: ''
|
||||||
init_param_schema: {}
|
init_param_schema: {}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -4,9 +4,7 @@ container:
|
|||||||
class:
|
class:
|
||||||
module: unilabos.resources.container:RegularContainer
|
module: unilabos.resources.container:RegularContainer
|
||||||
type: unilabos
|
type: unilabos
|
||||||
config_info: []
|
|
||||||
description: regular organic container
|
description: regular organic container
|
||||||
file_path: C:/Users/10230/PycharmProjects/Uni-Lab-OS/unilabos/registry/resources/organic/container.yaml
|
|
||||||
handles:
|
handles:
|
||||||
- data_key: fluid_in
|
- data_key: fluid_in
|
||||||
data_source: handle
|
data_source: handle
|
||||||
|
|||||||
12
unilabos/registry/resources/prcxi/plates.yaml
Normal file
12
unilabos/registry/resources/prcxi/plates.yaml
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
prcxi_96_wellplate_360ul_flat:
|
||||||
|
category:
|
||||||
|
- plates
|
||||||
|
class:
|
||||||
|
module: unilabos.devices.liquid_handling.prcxi.prcxi_res:prcxi_96_wellplate_360ul_flat
|
||||||
|
type: pylabrobot
|
||||||
|
description: prcxi_96_wellplate_360ul_flat
|
||||||
|
handles: []
|
||||||
|
icon: ''
|
||||||
|
init_param_schema: {}
|
||||||
|
registry_type: resource
|
||||||
|
version: 1.0.0
|
||||||
12
unilabos/registry/resources/prcxi/tip_racks.yaml
Normal file
12
unilabos/registry/resources/prcxi/tip_racks.yaml
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
prcxi_opentrons_96_tiprack_10ul:
|
||||||
|
category:
|
||||||
|
- tip_racks
|
||||||
|
class:
|
||||||
|
module: unilabos.devices.liquid_handling.prcxi.prcxi_res:prcxi_opentrons_96_tiprack_10ul
|
||||||
|
type: pylabrobot
|
||||||
|
description: prcxi_opentrons_96_tiprack_10ul
|
||||||
|
handles: []
|
||||||
|
icon: ''
|
||||||
|
init_param_schema: {}
|
||||||
|
registry_type: resource
|
||||||
|
version: 1.0.0
|
||||||
12
unilabos/registry/resources/prcxi/trash.yaml
Normal file
12
unilabos/registry/resources/prcxi/trash.yaml
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
prcxi_trash:
|
||||||
|
category:
|
||||||
|
- trash
|
||||||
|
class:
|
||||||
|
module: unilabos.devices.liquid_handling.prcxi.prcxi_res:prcxi_trash
|
||||||
|
type: pylabrobot
|
||||||
|
description: prcxi_trash
|
||||||
|
handles: []
|
||||||
|
icon: ''
|
||||||
|
init_param_schema: {}
|
||||||
|
registry_type: resource
|
||||||
|
version: 1.0.0
|
||||||
@@ -5,7 +5,7 @@ import threading
|
|||||||
import time
|
import time
|
||||||
import traceback
|
import traceback
|
||||||
import uuid
|
import uuid
|
||||||
from typing import Optional, Dict, Any, List, ClassVar, Set
|
from typing import Optional, Dict, Any, List, ClassVar, Set, Union
|
||||||
|
|
||||||
from action_msgs.msg import GoalStatus
|
from action_msgs.msg import GoalStatus
|
||||||
from geometry_msgs.msg import Point
|
from geometry_msgs.msg import Point
|
||||||
@@ -352,7 +352,7 @@ class HostNode(BaseROS2DeviceNode):
|
|||||||
|
|
||||||
def create_resource_detailed(
|
def create_resource_detailed(
|
||||||
self,
|
self,
|
||||||
resources: list["Resource"],
|
resources: list[Union[list["Resource"], "Resource"]],
|
||||||
device_ids: list[str],
|
device_ids: list[str],
|
||||||
bind_parent_ids: list[str],
|
bind_parent_ids: list[str],
|
||||||
bind_locations: list[Point],
|
bind_locations: list[Point],
|
||||||
@@ -426,7 +426,9 @@ class HostNode(BaseROS2DeviceNode):
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
init_new_res = initialize_resource(res_creation_input) # flatten的格式
|
init_new_res = initialize_resource(res_creation_input) # flatten的格式
|
||||||
resources = init_new_res # initialize_resource已经返回list[dict]
|
if len(init_new_res) > 1: # 一个物料,多个子节点
|
||||||
|
init_new_res = [init_new_res]
|
||||||
|
resources: List[Resource] | List[List[Resource]] = init_new_res # initialize_resource已经返回list[dict]
|
||||||
device_ids = [device_id]
|
device_ids = [device_id]
|
||||||
bind_parent_id = [parent]
|
bind_parent_id = [parent]
|
||||||
bind_location = [bind_locations]
|
bind_location = [bind_locations]
|
||||||
@@ -823,7 +825,7 @@ class HostNode(BaseROS2DeviceNode):
|
|||||||
self.lab_logger().info(f"[Host Node-Resource] Add request completed, success: {success}")
|
self.lab_logger().info(f"[Host Node-Resource] Add request completed, success: {success}")
|
||||||
return response
|
return response
|
||||||
|
|
||||||
def _resource_get_callback(self, request, response):
|
def _resource_get_callback(self, request: ResourceGet.Request, response: ResourceGet.Response):
|
||||||
"""
|
"""
|
||||||
获取资源回调
|
获取资源回调
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user