mirror of
https://github.com/dptech-corp/Uni-Lab-OS.git
synced 2026-02-07 07:25:15 +00:00
Add set_liquid example.
This commit is contained in:
@@ -9278,7 +9278,13 @@ liquid_handler.prcxi:
|
|||||||
z: 0.0
|
z: 0.0
|
||||||
sample_id: ''
|
sample_id: ''
|
||||||
type: ''
|
type: ''
|
||||||
handles: {}
|
handles:
|
||||||
|
input:
|
||||||
|
- data_key: wells
|
||||||
|
data_source: handle
|
||||||
|
data_type: resource
|
||||||
|
handler_key: input_wells
|
||||||
|
label: InputWells
|
||||||
placeholder_keys:
|
placeholder_keys:
|
||||||
wells: unilabos_resources
|
wells: unilabos_resources
|
||||||
result: {}
|
result: {}
|
||||||
|
|||||||
@@ -127,14 +127,14 @@ class Registry:
|
|||||||
"data_type": "resource",
|
"data_type": "resource",
|
||||||
"label": "Labware",
|
"label": "Labware",
|
||||||
"data_source": "executor",
|
"data_source": "executor",
|
||||||
"data_key": "created_resource_tree",
|
"data_key": "created_resource_tree.@flatten",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"handler_key": "liquid_slots",
|
"handler_key": "liquid_slots",
|
||||||
"data_type": "resource",
|
"data_type": "resource",
|
||||||
"label": "LiquidSlots",
|
"label": "LiquidSlots",
|
||||||
"data_source": "executor",
|
"data_source": "executor",
|
||||||
"data_key": "liquid_input_resource_tree",
|
"data_key": "liquid_input_resource_tree.@flatten",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"handler_key": "materials",
|
"handler_key": "materials",
|
||||||
|
|||||||
@@ -159,10 +159,14 @@ _msg_converter: Dict[Type, Any] = {
|
|||||||
else Pose()
|
else Pose()
|
||||||
),
|
),
|
||||||
config=json.dumps(x.get("config", {})),
|
config=json.dumps(x.get("config", {})),
|
||||||
data=json.dumps(x.get("data", {})),
|
data=json.dumps(obtain_data_with_uuid(x)),
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def obtain_data_with_uuid(x: dict):
|
||||||
|
data = x.get("data", {})
|
||||||
|
data["unilabos_uuid"] = x.get("uuid", None)
|
||||||
|
return data
|
||||||
|
|
||||||
def json_or_yaml_loads(data: str) -> Any:
|
def json_or_yaml_loads(data: str) -> Any:
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -430,8 +430,10 @@ class BaseROS2DeviceNode(Node, Generic[T]):
|
|||||||
})
|
})
|
||||||
tree_response: SerialCommand.Response = await client.call_async(request)
|
tree_response: SerialCommand.Response = await client.call_async(request)
|
||||||
uuid_maps = json.loads(tree_response.response)
|
uuid_maps = json.loads(tree_response.response)
|
||||||
self.resource_tracker.loop_update_uuid(input_resources, uuid_maps)
|
plr_instances = rts.to_plr_resources()
|
||||||
rts: ResourceTreeSet = ResourceTreeSet.from_raw_dict_list(input_resources)
|
for plr_instance in plr_instances:
|
||||||
|
self.resource_tracker.loop_update_uuid(plr_instance, uuid_maps)
|
||||||
|
rts: ResourceTreeSet = ResourceTreeSet.from_plr_resources(plr_instances)
|
||||||
self.lab_logger().info(f"Resource tree added. UUID mapping: {len(uuid_maps)} nodes")
|
self.lab_logger().info(f"Resource tree added. UUID mapping: {len(uuid_maps)} nodes")
|
||||||
final_response = {
|
final_response = {
|
||||||
"created_resource_tree": rts.dump(),
|
"created_resource_tree": rts.dump(),
|
||||||
@@ -461,7 +463,7 @@ class BaseROS2DeviceNode(Node, Generic[T]):
|
|||||||
return res
|
return res
|
||||||
try:
|
try:
|
||||||
if len(rts.root_nodes) == 1 and parent_resource is not None:
|
if len(rts.root_nodes) == 1 and parent_resource is not None:
|
||||||
plr_instance = rts.to_plr_resources()[0]
|
plr_instance = plr_instances[0]
|
||||||
if isinstance(plr_instance, Plate):
|
if isinstance(plr_instance, Plate):
|
||||||
empty_liquid_info_in: List[Tuple[Optional[str], float]] = [(None, 0)] * plr_instance.num_items
|
empty_liquid_info_in: List[Tuple[Optional[str], float]] = [(None, 0)] * plr_instance.num_items
|
||||||
if len(ADD_LIQUID_TYPE) == 1 and len(LIQUID_VOLUME) == 1 and len(LIQUID_INPUT_SLOT) > 1:
|
if len(ADD_LIQUID_TYPE) == 1 and len(LIQUID_VOLUME) == 1 and len(LIQUID_INPUT_SLOT) > 1:
|
||||||
@@ -1281,9 +1283,14 @@ class BaseROS2DeviceNode(Node, Generic[T]):
|
|||||||
# 批量查询资源
|
# 批量查询资源
|
||||||
queried_resources = []
|
queried_resources = []
|
||||||
for resource_data in resource_inputs:
|
for resource_data in resource_inputs:
|
||||||
plr_resource = await self.get_resource_with_dir(
|
unilabos_uuid = resource_data.get("data", {}).get("unilabos_uuid")
|
||||||
resource_id=resource_data["id"], with_children=True
|
if unilabos_uuid is None:
|
||||||
)
|
plr_resource = await self.get_resource_with_dir(
|
||||||
|
resource_id=resource_data["id"], with_children=True
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
resource_tree = await self.get_resource([unilabos_uuid])
|
||||||
|
plr_resource = resource_tree.to_plr_resources()[0]
|
||||||
if "sample_id" in resource_data:
|
if "sample_id" in resource_data:
|
||||||
plr_resource.unilabos_extra["sample_uuid"] = resource_data["sample_id"]
|
plr_resource.unilabos_extra["sample_uuid"] = resource_data["sample_id"]
|
||||||
queried_resources.append(plr_resource)
|
queried_resources.append(plr_resource)
|
||||||
@@ -1423,7 +1430,7 @@ class BaseROS2DeviceNode(Node, Generic[T]):
|
|||||||
for r in rs:
|
for r in rs:
|
||||||
res = self.resource_tracker.parent_resource(r) # 获取 resource 对象
|
res = self.resource_tracker.parent_resource(r) # 获取 resource 对象
|
||||||
else:
|
else:
|
||||||
res = self.resource_tracker.parent_resource(r)
|
res = self.resource_tracker.parent_resource(rs)
|
||||||
if id(res) not in seen:
|
if id(res) not in seen:
|
||||||
seen.add(id(res))
|
seen.add(id(res))
|
||||||
unique_resources.append(res)
|
unique_resources.append(res)
|
||||||
|
|||||||
@@ -1244,7 +1244,7 @@ class HostNode(BaseROS2DeviceNode):
|
|||||||
data = json.loads(request.command)
|
data = json.loads(request.command)
|
||||||
if "uuid" in data and data["uuid"] is not None:
|
if "uuid" in data and data["uuid"] is not None:
|
||||||
http_req = http_client.resource_tree_get([data["uuid"]], data["with_children"])
|
http_req = http_client.resource_tree_get([data["uuid"]], data["with_children"])
|
||||||
elif "id" in data and data["id"].startswith("/"):
|
elif "id" in data:
|
||||||
http_req = http_client.resource_get(data["id"], data["with_children"])
|
http_req = http_client.resource_get(data["id"], data["with_children"])
|
||||||
else:
|
else:
|
||||||
raise ValueError("没有使用正确的物料 id 或 uuid")
|
raise ValueError("没有使用正确的物料 id 或 uuid")
|
||||||
@@ -1463,7 +1463,7 @@ class HostNode(BaseROS2DeviceNode):
|
|||||||
if resource is None:
|
if resource is None:
|
||||||
resource = RegularContainer("test_resource传入None")
|
resource = RegularContainer("test_resource传入None")
|
||||||
return {
|
return {
|
||||||
"resources": ResourceTreeSet.from_plr_resources([resource, *resources]).dump(),
|
"resources": ResourceTreeSet.from_plr_resources([resource, *resources], known_newly_created=True).dump(),
|
||||||
"devices": [device, *devices],
|
"devices": [device, *devices],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user