mirror of
https://github.com/dptech-corp/Uni-Lab-OS.git
synced 2025-12-17 21:11:12 +00:00
modify devices to use correct executor (sleep, create_task)
This commit is contained in:
@@ -3,6 +3,8 @@ import logging
|
||||
import re
|
||||
from typing import Dict, Any, Optional
|
||||
|
||||
from unilabos.ros.nodes.base_device_node import BaseROS2DeviceNode
|
||||
|
||||
class VirtualSolidDispenser:
|
||||
"""
|
||||
虚拟固体粉末加样器 - 用于处理 Add Protocol 中的固体试剂添加 ⚗️
|
||||
@@ -13,6 +15,8 @@ class VirtualSolidDispenser:
|
||||
- 简单反馈:成功/失败 + 消息 📊
|
||||
"""
|
||||
|
||||
_ros_node: BaseROS2DeviceNode
|
||||
|
||||
def __init__(self, device_id: str = None, config: Dict[str, Any] = None, **kwargs):
|
||||
self.device_id = device_id or "virtual_solid_dispenser"
|
||||
self.config = config or {}
|
||||
@@ -32,6 +36,9 @@ class VirtualSolidDispenser:
|
||||
print(f"⚗️ === 虚拟固体分配器 {self.device_id} 创建成功! === ✨")
|
||||
print(f"📊 设备规格: 最大容量 {self.max_capacity}g | 精度 {self.precision}g 🎯")
|
||||
|
||||
def post_init(self, ros_node: BaseROS2DeviceNode):
|
||||
self._ros_node = ros_node
|
||||
|
||||
async def initialize(self) -> bool:
|
||||
"""初始化固体加样器 🚀"""
|
||||
self.logger.info(f"🔧 初始化固体分配器 {self.device_id} ✨")
|
||||
@@ -263,7 +270,7 @@ class VirtualSolidDispenser:
|
||||
|
||||
for i in range(steps):
|
||||
progress = (i + 1) / steps * 100
|
||||
await asyncio.sleep(step_time)
|
||||
await self._ros_node.sleep(step_time)
|
||||
if i % 2 == 0: # 每隔一步显示进度
|
||||
self.logger.debug(f"📊 加样进度: {progress:.0f}% | {amount_emoji} 正在分配 {reagent}...")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user