Files
Uni-Lab-OS/unilabos/registry/resources/bioyond/README_RESOURCE_ARCHITECTURE.md
Xuwznln 4c8022ee95 Workstation yb merge dev ready 260113 (#216)
* feat(bioyond): 添加计算实验设计功能,支持化合物配比和滴定比例参数

* feat(bioyond): 添加测量小瓶功能,支持基本参数配置

* feat(bioyond): 添加测量小瓶配置,支持新设备参数

* feat(bioyond): 更新仓库布局和尺寸,支持竖向排列的测量小瓶和试剂存放堆栈

* feat(bioyond): 优化任务创建流程,确保无论成功与否都清理任务队列以避免重复累积

* feat(bioyond): 添加设置反应器温度功能,支持温度范围和异常处理

* feat(bioyond): 调整反应器位置配置,统一坐标格式

* feat(bioyond): 添加调度器启动功能,支持任务队列执行并处理异常

* feat(bioyond): 优化调度器启动功能,添加异常处理并更新相关配置

* feat(opcua): 增强节点ID解析兼容性和数据类型处理

改进节点ID解析逻辑以支持多种格式,包括字符串和数字标识符
添加数据类型转换处理,确保写入值时类型匹配
优化错误提示信息,便于调试节点连接问题

* feat(registry): 新增后处理站的设备配置文件

添加后处理站的YAML配置文件,包含动作映射、状态类型和设备描述

* 添加调度器启动功能,合并物料参数配置,优化物料参数处理逻辑

* 添加从 Bioyond 系统自动同步工作流序列的功能,并更新相关配置

* fix:兼容 BioyondReactionStation 中 workflow_sequence 被重写为 property

* fix:同步工作流序列

* feat: remove commented workflow synchronization from `reaction_station.py`.

* 添加时间约束功能及相关配置

* fix:自动更新物料缓存功能,添加物料时更新缓存并在删除时移除缓存项

* fix:在添加物料时处理字符串和字典返回值,确保正确更新缓存

* fix:更新奔曜错误处理报送为物料变更报送,调整日志记录和响应消息

* feat:添加实验报告简化功能,去除冗余信息并保留关键信息

* feat: 添加任务状态事件发布功能,监控并报告任务运行、超时、完成和错误状态

* fix: 修复添加物料时数据格式错误

* Refactor bioyond_dispensing_station and reaction_station_bioyond YAML configurations

- Removed redundant action value mappings from bioyond_dispensing_station.
- Updated goal properties in bioyond_dispensing_station to use enums for target_stack and other parameters.
- Changed data types for end_point and start_point in reaction_station_bioyond to use string enums (Start, End).
- Simplified descriptions and updated measurement units from μL to mL where applicable.
- Removed unused commands from reaction_station_bioyond to streamline the configuration.

* fix:Change the material unit from μL to mL

* fix:refresh_material_cache

* feat: 动态获取工作流步骤ID,优化工作流配置

* feat: 添加清空服务端所有非核心工作流功能

* fix:修复Bottle类的序列化和反序列化方法

* feat:增强材料缓存更新逻辑,支持处理返回数据中的详细信息

* Add debug log

* feat(workstation): update bioyond config migration and coin cell material search logic

- Migrate bioyond_cell config to JSON structure and remove global variable dependencies
- Implement material search confirmation dialog auto-handling
- Add documentation: 20260113_物料搜寻确认弹窗自动处理功能.md and 20260113_配置迁移修改总结.md

* Refactor module paths for Bioyond devices in YAML configuration files

- Updated the module path for BioyondDispensingStation in bioyond_dispensing_station.yaml to reflect the new directory structure.
- Updated the module path for BioyondReactionStation and BioyondReactor in reaction_station_bioyond.yaml to align with the revised organization of the codebase.

* fix: WareHouse 的不可哈希类型错误,优化父节点去重逻辑

* refactor: Move config from module to instance initialization

* fix: 修正 reaction_station 目录名拼写错误

* feat: Integrate material search logic and cleanup deprecated files

- Update coin_cell_assembly.py with material search dialog handling
- Update YB_warehouses.py with latest warehouse configurations
- Remove outdated documentation and test data files

* Refactor: Use instance attributes for action names and workflow step IDs

* refactor: Split tipbox storage into left and right warehouses

* refactor: Merge tipbox storage left and right into single warehouse

---------

Co-authored-by: ZiWei <131428629+ZiWei09@users.noreply.github.com>
Co-authored-by: Andy6M <xieqiming1132@qq.com>
2026-01-17 15:44:18 +08:00

6.6 KiB
Raw Blame History

UniLabOS 资源注册架构详解

目标受众: 主要开发 unilabos/registry/devices 抽象层的开发者
最后更新: 2026-01-11
维护者: Uni-Lab-OS 开发团队

本文档详细说明 UniLabOS 资源注册系统的架构、资源的完整生命周期,以及如何实现动态物料位置追踪。


📚 目录


核心概念

1. Resources vs Registry

UniLabOS 采用声明式注册模式,将资源的定义Python注册信息YAML分离

┌──────────────────────────────────────────────────────────┐
│          unilabos/resources (Python 实现)                 │
│  - 定义资源的物理属性、行为和创建逻辑                       │
│  - 例如: 瓶子的尺寸、容量、材质                            │
├──────────────────────────────────────────────────────────┤
│       unilabos/registry/resources (YAML 注册表)           │
│  - 声明哪些资源可以被前端使用                              │
│  - 定义资源的分类、图标、初始化参数                         │
└──────────────────────────────────────────────────────────┘

为什么要分离?

  1. 解耦: Python 代码可以定义无限多的资源类,但只有在 YAML 中注册的才能被前端识别
  2. 灵活性: 无需修改 Python 代码,只需修改 YAML 就能添加/移除可用资源
  3. 可扩展性: 第三方开发者可以通过 YAML 注册自己的资源,无需修改核心代码

三层架构详解

UniLabOS 资源系统采用三层架构实现从前端UI到底层硬件的完整映射

架构图

┌─────────────────────────────────────────────────────┐
│  第1层: YAML 注册表 (registry/resources)             │
│  - 告诉系统"哪些资源可用"                             │
│  - 前端通过此层获取可用资源列表                        │
│  - 文件: YB_bottle.yaml, YB_bottle_carriers.yaml    │
├─────────────────────────────────────────────────────┤
│  第2层: Python 实现 (resources/bioyond)              │
│  - 定义资源的具体属性和行为                           │
│  - 创建资源实例的工厂函数                             │
│  - 文件: YB_bottles.py, YB_bottle_carriers.py       │
├─────────────────────────────────────────────────────┤
│  第3层: Hardware/API 集成 (devices/workstation)      │
│  - 连接 Bioyond 系统 API                            │
│  - 同步物料位置和状态                                │
│  - 文件: station.py, bioyond_rpc.py, config.py     │
└─────────────────────────────────────────────────────┘

第1层: YAML 注册表

YB_bottle.yaml - 单个瓶子注册

YB_5ml_fenyeping:
  category:
  - yb3              # 系统分类
  - YB_bottle        # 资源类型
  class:
    module: unilabos.resources.bioyond.YB_bottles:YB_5ml_fenyeping  # Python 函数路径
    type: pylabrobot  # 框架类型
  description: YB_5ml_fenyeping  # 前端显示名称
  handles: []
  icon: ''           # 图标路径
  init_param_schema: {}  # 初始化参数 schema
  registry_type: resource
  version: 1.0.0

作用:

  • 前端通过读取此文件知道有一个叫 "YB_5ml_fenyeping" 的资源
  • 用户拖拽时,系统会调用 YB_bottles:YB_5ml_fenyeping() 创建实例

YB_bottle_carriers.yaml - 载架(容器)注册

YB_5ml_fenyepingban:
  category:
  - yb3
  - YB_bottle_carriers
  class:
    module: unilabos.resources.bioyond.YB_bottle_carriers:YB_5ml_fenyepingban
    type: pylabrobot
  description: YB_5ml_fenyepingban  # 5ml分液瓶板

作用:

  • 载架是容器,里面可以放多个瓶子
  • 例如: YB_5ml_fenyepingban 是一个 4x2 布局的板,可以放 8 个 5ml 瓶子

第2层: Python 实现

YB_bottles.py - 瓶子工厂函数

def YB_5ml_fenyeping(
    name: str,
    diameter: float = 20.0,    # 直径 (mm)
    height: float = 50.0,      # 高度 (mm)
    max_volume: float = 5000.0,  # 最大容量 (μL)
    barcode: str = None,
) -> Bottle:
    \"\"\"创建5ml分液瓶\"\"\"
    return Bottle(
        name=name,
        diameter=diameter,
        height=height,
        max_volume=max_volume,
        barcode=barcode,
        model="YB_5ml_fenyeping",  # ⭐ 与 YAML 中的名称对应
    )

关键点:

  • 函数名 YB_5ml_fenyeping 必须与 YAML 中的 module 路径末尾一致
  • 返回一个 Bottle 对象PyLabRobot 资源类型)
  • model 字段用于在 Bioyond 系统中识别资源类型

详细文档请参考完整版 README


相关文件索引

核心文件

文件 功能 路径
YB_bottle.yaml 瓶子注册表 unilabos/registry/resources/bioyond/
YB_bottle_carriers.yaml 载架注册表 unilabos/registry/resources/bioyond/
deck.yaml Deck注册表 unilabos/registry/resources/bioyond/
YB_bottles.py 瓶子实现 unilabos/resources/bioyond/
YB_bottle_carriers.py 载架实现 unilabos/resources/bioyond/
YB_warehouses.py 仓库实现 unilabos/resources/bioyond/
decks.py Deck布局 unilabos/resources/bioyond/
station.py 物料同步 unilabos/devices/workstation/bioyond_studio/
config.py UUID映射 unilabos/devices/workstation/bioyond_studio/

仓库相关文档


维护者: Uni-Lab-OS 开发团队
最后更新: 2026-01-11