mirror of
https://github.com/dptech-corp/Uni-Lab-OS.git
synced 2025-12-17 13:01:12 +00:00
Update regular container method
This commit is contained in:
@@ -170,7 +170,10 @@
|
||||
"z": 0
|
||||
},
|
||||
"config": {
|
||||
"max_volume": 1000.0
|
||||
"max_volume": 1000.0,
|
||||
"size_x": 200,
|
||||
"size_y": 150,
|
||||
"size_z": 0
|
||||
},
|
||||
"data": {
|
||||
"liquids": [
|
||||
@@ -194,7 +197,10 @@
|
||||
"z": 0
|
||||
},
|
||||
"config": {
|
||||
"max_volume": 1000.0
|
||||
"max_volume": 1000.0,
|
||||
"size_x": 200,
|
||||
"size_y": 150,
|
||||
"size_z": 0
|
||||
},
|
||||
"data": {
|
||||
"liquids": [
|
||||
@@ -218,7 +224,10 @@
|
||||
"z": 0
|
||||
},
|
||||
"config": {
|
||||
"max_volume": 1000.0
|
||||
"max_volume": 1000.0,
|
||||
"size_x": 300,
|
||||
"size_y": 150,
|
||||
"size_z": 0
|
||||
},
|
||||
"data": {
|
||||
"liquids": [
|
||||
@@ -242,7 +251,10 @@
|
||||
"z": 0
|
||||
},
|
||||
"config": {
|
||||
"max_volume": 1000.0
|
||||
"max_volume": 1000.0,
|
||||
"size_x": 900,
|
||||
"size_y": 150,
|
||||
"size_z": 0
|
||||
},
|
||||
"data": {
|
||||
"liquids": [
|
||||
@@ -266,7 +278,10 @@
|
||||
"z": 0
|
||||
},
|
||||
"config": {
|
||||
"max_volume": 1000.0
|
||||
"max_volume": 1000.0,
|
||||
"size_x": 950,
|
||||
"size_y": 150,
|
||||
"size_z": 0
|
||||
},
|
||||
"data": {
|
||||
"liquids": [
|
||||
@@ -419,7 +434,10 @@
|
||||
"z": 0
|
||||
},
|
||||
"config": {
|
||||
"max_volume": 2000.0
|
||||
"max_volume": 2000.0,
|
||||
"size_x": 500,
|
||||
"size_y": 400,
|
||||
"size_z": 0
|
||||
},
|
||||
"data": {
|
||||
"liquids": [
|
||||
@@ -439,7 +457,10 @@
|
||||
"z": 0
|
||||
},
|
||||
"config": {
|
||||
"max_volume": 2000.0
|
||||
"max_volume": 2000.0,
|
||||
"size_x": 1100,
|
||||
"size_y": 500,
|
||||
"size_z": 0
|
||||
},
|
||||
"data": {
|
||||
"liquids": [
|
||||
@@ -649,7 +670,10 @@
|
||||
"z": 0
|
||||
},
|
||||
"config": {
|
||||
"max_volume": 250.0
|
||||
"max_volume": 250.0,
|
||||
"size_x": 900,
|
||||
"size_y": 500,
|
||||
"size_z": 0
|
||||
},
|
||||
"data": {
|
||||
"liquids": [
|
||||
@@ -669,7 +693,10 @@
|
||||
"z": 0
|
||||
},
|
||||
"config": {
|
||||
"max_volume": 250.0
|
||||
"max_volume": 250.0,
|
||||
"size_x": 950,
|
||||
"size_y": 500,
|
||||
"size_z": 0
|
||||
},
|
||||
"data": {
|
||||
"liquids": [
|
||||
@@ -689,7 +716,10 @@
|
||||
"z": 0
|
||||
},
|
||||
"config": {
|
||||
"max_volume": 250.0
|
||||
"max_volume": 250.0,
|
||||
"size_x": 1050,
|
||||
"size_y": 500,
|
||||
"size_z": 0
|
||||
},
|
||||
"data": {
|
||||
"liquids": [
|
||||
@@ -733,6 +763,9 @@
|
||||
},
|
||||
"config": {
|
||||
"max_volume": 500.0,
|
||||
"size_x": 550,
|
||||
"size_y": 250,
|
||||
"size_z": 0,
|
||||
"reagent": "sodium_chloride",
|
||||
"physical_state": "solid"
|
||||
},
|
||||
@@ -756,6 +789,9 @@
|
||||
},
|
||||
"config": {
|
||||
"volume": 500.0,
|
||||
"size_x": 600,
|
||||
"size_y": 250,
|
||||
"size_z": 0,
|
||||
"reagent": "sodium_carbonate",
|
||||
"physical_state": "solid"
|
||||
},
|
||||
@@ -779,6 +815,9 @@
|
||||
},
|
||||
"config": {
|
||||
"volume": 500.0,
|
||||
"size_x": 650,
|
||||
"size_y": 250,
|
||||
"size_z": 0,
|
||||
"reagent": "magnesium_chloride",
|
||||
"physical_state": "solid"
|
||||
},
|
||||
|
||||
@@ -3,7 +3,7 @@ container:
|
||||
- container
|
||||
class:
|
||||
module: unilabos.resources.container:RegularContainer
|
||||
type: unilabos
|
||||
type: pylabrobot
|
||||
description: regular organic container
|
||||
handles:
|
||||
- data_key: fluid_in
|
||||
|
||||
@@ -1,67 +1,73 @@
|
||||
import json
|
||||
|
||||
from pylabrobot.resources import Container
|
||||
from unilabos_msgs.msg import Resource
|
||||
|
||||
from unilabos.ros.msgs.message_converter import convert_from_ros_msg
|
||||
|
||||
|
||||
class RegularContainer(object):
|
||||
# 第一个参数必须是id传入
|
||||
# noinspection PyShadowingBuiltins
|
||||
def __init__(self, id: str):
|
||||
self.id = id
|
||||
self.ulr_resource = Resource()
|
||||
self._data = None
|
||||
class RegularContainer(Container):
|
||||
pass
|
||||
|
||||
@property
|
||||
def ulr_resource_data(self):
|
||||
if self._data is None:
|
||||
self._data = json.loads(self.ulr_resource.data) if self.ulr_resource.data else {}
|
||||
return self._data
|
||||
|
||||
@ulr_resource_data.setter
|
||||
def ulr_resource_data(self, value: dict):
|
||||
self._data = value
|
||||
self.ulr_resource.data = json.dumps(self._data)
|
||||
|
||||
@property
|
||||
def liquid_type(self):
|
||||
return self.ulr_resource_data.get("liquid_type", None)
|
||||
|
||||
@liquid_type.setter
|
||||
def liquid_type(self, value: str):
|
||||
if value is not None:
|
||||
self.ulr_resource_data["liquid_type"] = value
|
||||
else:
|
||||
self.ulr_resource_data.pop("liquid_type", None)
|
||||
|
||||
@property
|
||||
def liquid_volume(self):
|
||||
return self.ulr_resource_data.get("liquid_volume", None)
|
||||
|
||||
@liquid_volume.setter
|
||||
def liquid_volume(self, value: float):
|
||||
if value is not None:
|
||||
self.ulr_resource_data["liquid_volume"] = value
|
||||
else:
|
||||
self.ulr_resource_data.pop("liquid_volume", None)
|
||||
|
||||
def get_ulr_resource(self) -> Resource:
|
||||
"""
|
||||
获取UlrResource对象
|
||||
:return: UlrResource对象
|
||||
"""
|
||||
self.ulr_resource_data = self.ulr_resource_data # 确保数据被更新
|
||||
return self.ulr_resource
|
||||
|
||||
def get_ulr_resource_as_dict(self) -> Resource:
|
||||
"""
|
||||
获取UlrResource对象
|
||||
:return: UlrResource对象
|
||||
"""
|
||||
to_dict = convert_from_ros_msg(self.get_ulr_resource())
|
||||
to_dict["type"] = "container"
|
||||
return to_dict
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.id}"
|
||||
#
|
||||
# class RegularContainer(object):
|
||||
# # 第一个参数必须是id传入
|
||||
# # noinspection PyShadowingBuiltins
|
||||
# def __init__(self, id: str):
|
||||
# self.id = id
|
||||
# self.ulr_resource = Resource()
|
||||
# self._data = None
|
||||
#
|
||||
# @property
|
||||
# def ulr_resource_data(self):
|
||||
# if self._data is None:
|
||||
# self._data = json.loads(self.ulr_resource.data) if self.ulr_resource.data else {}
|
||||
# return self._data
|
||||
#
|
||||
# @ulr_resource_data.setter
|
||||
# def ulr_resource_data(self, value: dict):
|
||||
# self._data = value
|
||||
# self.ulr_resource.data = json.dumps(self._data)
|
||||
#
|
||||
# @property
|
||||
# def liquid_type(self):
|
||||
# return self.ulr_resource_data.get("liquid_type", None)
|
||||
#
|
||||
# @liquid_type.setter
|
||||
# def liquid_type(self, value: str):
|
||||
# if value is not None:
|
||||
# self.ulr_resource_data["liquid_type"] = value
|
||||
# else:
|
||||
# self.ulr_resource_data.pop("liquid_type", None)
|
||||
#
|
||||
# @property
|
||||
# def liquid_volume(self):
|
||||
# return self.ulr_resource_data.get("liquid_volume", None)
|
||||
#
|
||||
# @liquid_volume.setter
|
||||
# def liquid_volume(self, value: float):
|
||||
# if value is not None:
|
||||
# self.ulr_resource_data["liquid_volume"] = value
|
||||
# else:
|
||||
# self.ulr_resource_data.pop("liquid_volume", None)
|
||||
#
|
||||
# def get_ulr_resource(self) -> Resource:
|
||||
# """
|
||||
# 获取UlrResource对象
|
||||
# :return: UlrResource对象
|
||||
# """
|
||||
# self.ulr_resource_data = self.ulr_resource_data # 确保数据被更新
|
||||
# return self.ulr_resource
|
||||
#
|
||||
# def get_ulr_resource_as_dict(self) -> Resource:
|
||||
# """
|
||||
# 获取UlrResource对象
|
||||
# :return: UlrResource对象
|
||||
# """
|
||||
# to_dict = convert_from_ros_msg(self.get_ulr_resource())
|
||||
# to_dict["type"] = "container"
|
||||
# return to_dict
|
||||
#
|
||||
# def __str__(self):
|
||||
# return f"{self.id}"
|
||||
@@ -781,6 +781,7 @@ def initialize_resource(resource_config: dict, resource_type: Any = None) -> Uni
|
||||
else:
|
||||
r = resource_plr
|
||||
elif resource_class_config["type"] == "unilabos":
|
||||
raise ValueError(f"No more support for unilabos Resource class {resource_class_config}")
|
||||
res_instance: RegularContainer = RESOURCE(id=resource_config["name"])
|
||||
res_instance.ulr_resource = convert_to_ros_msg(
|
||||
Resource, {k: v for k, v in resource_config.items() if k != "class"}
|
||||
|
||||
Reference in New Issue
Block a user