mirror of
https://github.com/dptech-corp/Uni-Lab-OS.git
synced 2025-12-17 13:01:12 +00:00
refactor: ProtocolNode→WorkstationNode
This commit is contained in:
@@ -267,40 +267,40 @@ class PyLabRobotCreator(DeviceClassCreator[T]):
|
||||
ROS2DeviceNode.run_async_func(getattr(self.device_instance, "setup")).add_done_callback(done_cb)
|
||||
|
||||
|
||||
class ProtocolNodeCreator(DeviceClassCreator[T]):
|
||||
class WorkstationNodeCreator(DeviceClassCreator[T]):
|
||||
"""
|
||||
ProtocolNode设备类创建器
|
||||
WorkstationNode设备类创建器
|
||||
|
||||
这个类提供了针对ProtocolNode设备类的实例创建方法,处理children参数。
|
||||
这个类提供了针对WorkstationNode设备类的实例创建方法,处理children参数。
|
||||
"""
|
||||
|
||||
def __init__(self, cls: Type[T], children: Dict[str, Any], resource_tracker: DeviceNodeResourceTracker):
|
||||
"""
|
||||
初始化ProtocolNode设备类创建器
|
||||
初始化WorkstationNode设备类创建器
|
||||
|
||||
Args:
|
||||
cls: ProtocolNode设备类
|
||||
cls: WorkstationNode设备类
|
||||
children: 子资源字典,用于资源替换
|
||||
"""
|
||||
super().__init__(cls, children, resource_tracker)
|
||||
|
||||
def create_instance(self, data: Dict[str, Any]) -> T:
|
||||
"""
|
||||
从数据创建ProtocolNode设备实例
|
||||
从数据创建WorkstationNode设备实例
|
||||
|
||||
Args:
|
||||
data: 用于创建实例的数据
|
||||
|
||||
Returns:
|
||||
ProtocolNode设备类实例
|
||||
WorkstationNode设备类实例
|
||||
"""
|
||||
try:
|
||||
# 创建实例,额外补充一个给protocol node的字段,后面考虑取消
|
||||
data["children"] = self.children
|
||||
self.device_instance = super(ProtocolNodeCreator, self).create_instance(data)
|
||||
self.device_instance = super(WorkstationNodeCreator, self).create_instance(data)
|
||||
self.post_create()
|
||||
return self.device_instance
|
||||
except Exception as e:
|
||||
logger.error(f"ProtocolNode创建实例失败: {e}")
|
||||
logger.error(f"ProtocolNode创建实例堆栈: {traceback.format_exc()}")
|
||||
logger.error(f"WorkstationNode创建实例失败: {e}")
|
||||
logger.error(f"WorkstationNode创建实例堆栈: {traceback.format_exc()}")
|
||||
raise
|
||||
|
||||
Reference in New Issue
Block a user