mirror of
https://github.com/dptech-corp/Uni-Lab-OS.git
synced 2026-02-04 13:25:13 +00:00
Add set_liquid example.
This commit is contained in:
@@ -9278,7 +9278,13 @@ liquid_handler.prcxi:
|
||||
z: 0.0
|
||||
sample_id: ''
|
||||
type: ''
|
||||
handles: {}
|
||||
handles:
|
||||
input:
|
||||
- data_key: wells
|
||||
data_source: handle
|
||||
data_type: resource
|
||||
handler_key: input_wells
|
||||
label: InputWells
|
||||
placeholder_keys:
|
||||
wells: unilabos_resources
|
||||
result: {}
|
||||
|
||||
@@ -127,14 +127,14 @@ class Registry:
|
||||
"data_type": "resource",
|
||||
"label": "Labware",
|
||||
"data_source": "executor",
|
||||
"data_key": "created_resource_tree",
|
||||
"data_key": "created_resource_tree.@flatten",
|
||||
},
|
||||
{
|
||||
"handler_key": "liquid_slots",
|
||||
"data_type": "resource",
|
||||
"label": "LiquidSlots",
|
||||
"data_source": "executor",
|
||||
"data_key": "liquid_input_resource_tree",
|
||||
"data_key": "liquid_input_resource_tree.@flatten",
|
||||
},
|
||||
{
|
||||
"handler_key": "materials",
|
||||
|
||||
@@ -159,10 +159,14 @@ _msg_converter: Dict[Type, Any] = {
|
||||
else Pose()
|
||||
),
|
||||
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:
|
||||
try:
|
||||
|
||||
@@ -430,8 +430,10 @@ class BaseROS2DeviceNode(Node, Generic[T]):
|
||||
})
|
||||
tree_response: SerialCommand.Response = await client.call_async(request)
|
||||
uuid_maps = json.loads(tree_response.response)
|
||||
self.resource_tracker.loop_update_uuid(input_resources, uuid_maps)
|
||||
rts: ResourceTreeSet = ResourceTreeSet.from_raw_dict_list(input_resources)
|
||||
plr_instances = rts.to_plr_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")
|
||||
final_response = {
|
||||
"created_resource_tree": rts.dump(),
|
||||
@@ -461,7 +463,7 @@ class BaseROS2DeviceNode(Node, Generic[T]):
|
||||
return res
|
||||
try:
|
||||
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):
|
||||
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:
|
||||
@@ -1281,9 +1283,14 @@ class BaseROS2DeviceNode(Node, Generic[T]):
|
||||
# 批量查询资源
|
||||
queried_resources = []
|
||||
for resource_data in resource_inputs:
|
||||
plr_resource = await self.get_resource_with_dir(
|
||||
resource_id=resource_data["id"], with_children=True
|
||||
)
|
||||
unilabos_uuid = resource_data.get("data", {}).get("unilabos_uuid")
|
||||
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:
|
||||
plr_resource.unilabos_extra["sample_uuid"] = resource_data["sample_id"]
|
||||
queried_resources.append(plr_resource)
|
||||
@@ -1423,7 +1430,7 @@ class BaseROS2DeviceNode(Node, Generic[T]):
|
||||
for r in rs:
|
||||
res = self.resource_tracker.parent_resource(r) # 获取 resource 对象
|
||||
else:
|
||||
res = self.resource_tracker.parent_resource(r)
|
||||
res = self.resource_tracker.parent_resource(rs)
|
||||
if id(res) not in seen:
|
||||
seen.add(id(res))
|
||||
unique_resources.append(res)
|
||||
|
||||
@@ -1244,7 +1244,7 @@ class HostNode(BaseROS2DeviceNode):
|
||||
data = json.loads(request.command)
|
||||
if "uuid" in data and data["uuid"] is not None:
|
||||
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"])
|
||||
else:
|
||||
raise ValueError("没有使用正确的物料 id 或 uuid")
|
||||
@@ -1463,7 +1463,7 @@ class HostNode(BaseROS2DeviceNode):
|
||||
if resource is None:
|
||||
resource = RegularContainer("test_resource传入None")
|
||||
return {
|
||||
"resources": ResourceTreeSet.from_plr_resources([resource, *resources]).dump(),
|
||||
"resources": ResourceTreeSet.from_plr_resources([resource, *resources], known_newly_created=True).dump(),
|
||||
"devices": [device, *devices],
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user