mirror of
https://github.com/dptech-corp/Uni-Lab-OS.git
synced 2025-12-17 13:01:12 +00:00
refactor: rename "station_resource" to "deck"
This commit is contained in:
@@ -41,7 +41,7 @@
|
|||||||
"HydrogenateProtocol",
|
"HydrogenateProtocol",
|
||||||
"RecrystallizeProtocol"
|
"RecrystallizeProtocol"
|
||||||
],
|
],
|
||||||
"station_resource": {
|
"deck": {
|
||||||
"data": {
|
"data": {
|
||||||
"_resource_child_name": "deck",
|
"_resource_child_name": "deck",
|
||||||
"_resource_type": "pylabrobot.resources.opentrons.deck:OTDeck"
|
"_resource_type": "pylabrobot.resources.opentrons.deck:OTDeck"
|
||||||
|
|||||||
@@ -1283,7 +1283,7 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
# 检查序列化后的资源
|
# 检查序列化后的资源
|
||||||
|
|
||||||
json.dump({"nodes": resources, "links": []}, open("button_battery_station_resources_unilab.json", "w"), indent=2)
|
json.dump({"nodes": resources, "links": []}, open("button_battery_decks_unilab.json", "w"), indent=2)
|
||||||
|
|
||||||
|
|
||||||
#print(resources)
|
#print(resources)
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ from unilabos.ros.nodes.presets.workstation import ROS2WorkstationNode
|
|||||||
class CoinCellAssemblyWorkstation(WorkstationBase):
|
class CoinCellAssemblyWorkstation(WorkstationBase):
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
station_resource: CoincellDeck,
|
deck: CoincellDeck,
|
||||||
address: str = "192.168.1.20",
|
address: str = "192.168.1.20",
|
||||||
port: str = "502",
|
port: str = "502",
|
||||||
debug_mode: bool = True,
|
debug_mode: bool = True,
|
||||||
@@ -30,12 +30,12 @@ class CoinCellAssemblyWorkstation(WorkstationBase):
|
|||||||
):
|
):
|
||||||
super().__init__(
|
super().__init__(
|
||||||
#桌子
|
#桌子
|
||||||
station_resource=station_resource,
|
deck=deck,
|
||||||
*args,
|
*args,
|
||||||
**kwargs,
|
**kwargs,
|
||||||
)
|
)
|
||||||
self.debug_mode = debug_mode
|
self.debug_mode = debug_mode
|
||||||
self.station_resource = station_resource
|
self.deck = deck
|
||||||
""" 连接初始化 """
|
""" 连接初始化 """
|
||||||
modbus_client = TCPClient(addr=address, port=port)
|
modbus_client = TCPClient(addr=address, port=port)
|
||||||
print("modbus_client", modbus_client)
|
print("modbus_client", modbus_client)
|
||||||
@@ -74,7 +74,7 @@ class CoinCellAssemblyWorkstation(WorkstationBase):
|
|||||||
self._ros_node = ros_node
|
self._ros_node = ros_node
|
||||||
#self.deck = create_a_coin_cell_deck()
|
#self.deck = create_a_coin_cell_deck()
|
||||||
ROS2DeviceNode.run_async_func(self._ros_node.update_resource, True, **{
|
ROS2DeviceNode.run_async_func(self._ros_node.update_resource, True, **{
|
||||||
"resources": [self.station_resource]
|
"resources": [self.deck]
|
||||||
})
|
})
|
||||||
|
|
||||||
# 批量操作在这里写
|
# 批量操作在这里写
|
||||||
@@ -84,7 +84,7 @@ class CoinCellAssemblyWorkstation(WorkstationBase):
|
|||||||
|
|
||||||
|
|
||||||
async def fill_plate(self):
|
async def fill_plate(self):
|
||||||
plate_1: MaterialPlate = self.station_resource.children[0].children[0]
|
plate_1: MaterialPlate = self.deck.children[0].children[0]
|
||||||
#plate_1
|
#plate_1
|
||||||
return await self._ros_node.update_resource(plate_1)
|
return await self._ros_node.update_resource(plate_1)
|
||||||
|
|
||||||
@@ -341,7 +341,7 @@ class CoinCellAssemblyWorkstation(WorkstationBase):
|
|||||||
def modify_deck_name(self, resource_name: str):
|
def modify_deck_name(self, resource_name: str):
|
||||||
# figure_res = self._ros_node.resource_tracker.figure_resource({"name": resource_name})
|
# figure_res = self._ros_node.resource_tracker.figure_resource({"name": resource_name})
|
||||||
# print(f"!!! figure_res: {type(figure_res)}")
|
# print(f"!!! figure_res: {type(figure_res)}")
|
||||||
self.station_resource.children[1]
|
self.deck.children[1]
|
||||||
return
|
return
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@@ -814,8 +814,8 @@ class CoinCellAssemblyWorkstation(WorkstationBase):
|
|||||||
|
|
||||||
#这里定义物料系统
|
#这里定义物料系统
|
||||||
# TODO:读完再将电池数加一还是进入循环就将电池数加一需要考虑
|
# TODO:读完再将电池数加一还是进入循环就将电池数加一需要考虑
|
||||||
liaopan1 = self.station_resource.get_resource("liaopan1")
|
liaopan1 = self.deck.get_resource("liaopan1")
|
||||||
liaopan4 = self.station_resource.get_resource("liaopan4")
|
liaopan4 = self.deck.get_resource("liaopan4")
|
||||||
jipian1 = liaopan1.children[coin_num_N].children[0]
|
jipian1 = liaopan1.children[coin_num_N].children[0]
|
||||||
jipian4 = liaopan4.children[coin_num_N].children[0]
|
jipian4 = liaopan4.children[coin_num_N].children[0]
|
||||||
#print(jipian1)
|
#print(jipian1)
|
||||||
@@ -828,7 +828,7 @@ class CoinCellAssemblyWorkstation(WorkstationBase):
|
|||||||
battery.assign_child_resource(jipian1, location=None)
|
battery.assign_child_resource(jipian1, location=None)
|
||||||
battery.assign_child_resource(jipian4, location=None)
|
battery.assign_child_resource(jipian4, location=None)
|
||||||
|
|
||||||
zidanjia6 = self.station_resource.get_resource("zi_dan_jia6")
|
zidanjia6 = self.deck.get_resource("zi_dan_jia6")
|
||||||
|
|
||||||
zidanjia6.children[0].assign_child_resource(battery, location=None)
|
zidanjia6.children[0].assign_child_resource(battery, location=None)
|
||||||
|
|
||||||
@@ -878,11 +878,11 @@ class CoinCellAssemblyWorkstation(WorkstationBase):
|
|||||||
|
|
||||||
def fun_wuliao_test(self) -> bool:
|
def fun_wuliao_test(self) -> bool:
|
||||||
#找到data_init中构建的2个物料盘
|
#找到data_init中构建的2个物料盘
|
||||||
#liaopan1 = self.station_resource.get_resource("liaopan1")
|
#liaopan1 = self.deck.get_resource("liaopan1")
|
||||||
#liaopan4 = self.station_resource.get_resource("liaopan4")
|
#liaopan4 = self.deck.get_resource("liaopan4")
|
||||||
#for coin_num_N in range(16):
|
#for coin_num_N in range(16):
|
||||||
# liaopan1 = self.station_resource.get_resource("liaopan1")
|
# liaopan1 = self.deck.get_resource("liaopan1")
|
||||||
# liaopan4 = self.station_resource.get_resource("liaopan4")
|
# liaopan4 = self.deck.get_resource("liaopan4")
|
||||||
# jipian1 = liaopan1.children[coin_num_N].children[0]
|
# jipian1 = liaopan1.children[coin_num_N].children[0]
|
||||||
# jipian4 = liaopan4.children[coin_num_N].children[0]
|
# jipian4 = liaopan4.children[coin_num_N].children[0]
|
||||||
# #print(jipian1)
|
# #print(jipian1)
|
||||||
@@ -895,10 +895,10 @@ class CoinCellAssemblyWorkstation(WorkstationBase):
|
|||||||
# battery.assign_child_resource(jipian1, location=None)
|
# battery.assign_child_resource(jipian1, location=None)
|
||||||
# battery.assign_child_resource(jipian4, location=None)
|
# battery.assign_child_resource(jipian4, location=None)
|
||||||
#
|
#
|
||||||
# zidanjia6 = self.station_resource.get_resource("zi_dan_jia6")
|
# zidanjia6 = self.deck.get_resource("zi_dan_jia6")
|
||||||
# zidanjia6.children[0].assign_child_resource(battery, location=None)
|
# zidanjia6.children[0].assign_child_resource(battery, location=None)
|
||||||
# ROS2DeviceNode.run_async_func(self._ros_node.update_resource, True, **{
|
# ROS2DeviceNode.run_async_func(self._ros_node.update_resource, True, **{
|
||||||
# "resources": [self.station_resource]
|
# "resources": [self.deck]
|
||||||
# })
|
# })
|
||||||
# time.sleep(2)
|
# time.sleep(2)
|
||||||
for i in range(20):
|
for i in range(20):
|
||||||
@@ -1133,7 +1133,7 @@ if __name__ == "__main__":
|
|||||||
##print(jipian2.parent)
|
##print(jipian2.parent)
|
||||||
from unilabos.resources.graphio import resource_ulab_to_plr, convert_resources_to_type
|
from unilabos.resources.graphio import resource_ulab_to_plr, convert_resources_to_type
|
||||||
|
|
||||||
with open("./button_battery_station_resources_unilab.json", "r", encoding="utf-8") as f:
|
with open("./button_battery_decks_unilab.json", "r", encoding="utf-8") as f:
|
||||||
bioyond_resources_unilab = json.load(f)
|
bioyond_resources_unilab = json.load(f)
|
||||||
print(f"成功读取 JSON 文件,包含 {len(bioyond_resources_unilab)} 个资源")
|
print(f"成功读取 JSON 文件,包含 {len(bioyond_resources_unilab)} 个资源")
|
||||||
ulab_resources = convert_resources_to_type(bioyond_resources_unilab, List[PLRResource])
|
ulab_resources = convert_resources_to_type(bioyond_resources_unilab, List[PLRResource])
|
||||||
|
|||||||
@@ -16,9 +16,9 @@
|
|||||||
},
|
},
|
||||||
"config": {
|
"config": {
|
||||||
"debug_mode": false,
|
"debug_mode": false,
|
||||||
"_comment": "protocol_type接外部工站固定写法字段,一般为空,station_resource写法也固定",
|
"_comment": "protocol_type接外部工站固定写法字段,一般为空,deck写法也固定",
|
||||||
"protocol_type": [],
|
"protocol_type": [],
|
||||||
"station_resource": {
|
"deck": {
|
||||||
"data": {
|
"data": {
|
||||||
"_resource_child_name": "coin_cell_deck",
|
"_resource_child_name": "coin_cell_deck",
|
||||||
"_resource_type": "unilabos.devices.workstation.coin_cell_assembly.button_battery_station:CoincellDeck"
|
"_resource_type": "unilabos.devices.workstation.coin_cell_assembly.button_battery_station:CoincellDeck"
|
||||||
|
|||||||
@@ -147,13 +147,13 @@ class WorkstationBase(ABC):
|
|||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
station_resource: PLRResource,
|
deck: PLRResource,
|
||||||
*args,
|
*args,
|
||||||
**kwargs, # 必须有kwargs
|
**kwargs, # 必须有kwargs
|
||||||
):
|
):
|
||||||
# 基本配置
|
# 基本配置
|
||||||
print(station_resource)
|
print(deck)
|
||||||
self.deck_config = station_resource
|
self.deck_config = deck
|
||||||
|
|
||||||
# PLR 物料系统
|
# PLR 物料系统
|
||||||
self.deck: Optional[Deck] = None
|
self.deck: Optional[Deck] = None
|
||||||
@@ -391,5 +391,5 @@ class WorkstationBase(ABC):
|
|||||||
|
|
||||||
|
|
||||||
class ProtocolNode(WorkstationBase):
|
class ProtocolNode(WorkstationBase):
|
||||||
def __init__(self, station_resource: Optional[PLRResource], *args, **kwargs):
|
def __init__(self, deck: Optional[PLRResource], *args, **kwargs):
|
||||||
super().__init__(station_resource, *args, **kwargs)
|
super().__init__(deck, *args, **kwargs)
|
||||||
|
|||||||
@@ -6034,10 +6034,10 @@ workstation:
|
|||||||
init_param_schema:
|
init_param_schema:
|
||||||
config:
|
config:
|
||||||
properties:
|
properties:
|
||||||
station_resource:
|
deck:
|
||||||
type: string
|
type: string
|
||||||
required:
|
required:
|
||||||
- station_resource
|
- deck
|
||||||
type: object
|
type: object
|
||||||
data:
|
data:
|
||||||
properties: {}
|
properties: {}
|
||||||
|
|||||||
@@ -296,14 +296,14 @@ class WorkstationNodeCreator(DeviceClassCreator[T]):
|
|||||||
try:
|
try:
|
||||||
# 创建实例,额外补充一个给protocol node的字段,后面考虑取消
|
# 创建实例,额外补充一个给protocol node的字段,后面考虑取消
|
||||||
data["children"] = self.children
|
data["children"] = self.children
|
||||||
station_resource_dict = data.get("station_resource")
|
deck_dict = data.get("deck")
|
||||||
if station_resource_dict:
|
if deck_dict:
|
||||||
from pylabrobot.resources import Deck, Resource
|
from pylabrobot.resources import Deck, Resource
|
||||||
plrc = PyLabRobotCreator(Deck, self.children, self.resource_tracker)
|
plrc = PyLabRobotCreator(Deck, self.children, self.resource_tracker)
|
||||||
station_resource = plrc.create_instance(station_resource_dict)
|
deck = plrc.create_instance(deck_dict)
|
||||||
data["station_resource"] = station_resource
|
data["deck"] = deck
|
||||||
else:
|
else:
|
||||||
data["station_resource"] = None
|
data["deck"] = None
|
||||||
self.device_instance = super(WorkstationNodeCreator, self).create_instance(data)
|
self.device_instance = super(WorkstationNodeCreator, self).create_instance(data)
|
||||||
self.post_create()
|
self.post_create()
|
||||||
return self.device_instance
|
return self.device_instance
|
||||||
|
|||||||
Reference in New Issue
Block a user