> ## Documentation Index
> Fetch the complete documentation index at: https://automationlaboratoryprotocol.mimedal.cn/llms.txt
> Use this file to discover all available pages before exploring further.

# 绑定

> 把验证后的函数调用绑定到可用设备、操作和参数

## 模块作用

技能匹配读取合格设备技能库，根据方法需要的函数、容器状态、参数范围和设备可用性选择设备。ALL 不定义没有验证依据的通用匹配分数；绑定结果只表达已匹配步骤和无法绑定步骤。

## 输入

```text theme={null}
已通过仿真的代码式方法
函数式技能签名
设备编码和名称
设备技能、请求分类及参数约束
当前设备可用状态
```

### 输入示例

```json theme={null}
{
  "method_call": {
    "namespace": "Liquid_Handling_Station_1ml_V2",
    "function": "add_liquid_with_material",
    "arguments": {
      "container_type": "离心瓶",
      "container_count": 2,
      "container_ids": [1],
      "dispensing_plan": [{"原液瓶编号": 1, "加液体积": 0.5}]
    }
  },
  "capability": {
    "device_id": "2002186824385539",
    "revision": "12",
    "command_id": "add_liquid_with_material",
    "request_class": "invoke",
    "detail_level": "full",
    "available": true
  }
}
```

| 输入字段                       | 作用                    |
| -------------------------- | --------------------- |
| `method_call.namespace`    | 指定函数所属设备能力空间          |
| `method_call.function`     | 指定要绑定的函数名称            |
| `method_call.arguments`    | 提供已经通过仿真的实参           |
| `capability.device_id`     | 指定实际接收调用的设备           |
| `capability.revision`      | 确保绑定目标仍是验证过的能力版本      |
| `capability.command_id`    | 建立函数到 FSP 指令的确定映射     |
| `capability.request_class` | 决定下发入口和安全校验级别         |
| `capability.detail_level`  | 必须为 `full`，摘要不能用于绑定执行 |
| `capability.available`     | 防止把步骤绑定到当前不可用设备       |

## 参数展开

执行计划可以保存紧凑参数，但绑定器下发 FSP 前必须按技能定义补齐所有必需参数。补齐只能使用技能中声明的默认值或确定性派生规则，不能由模型猜测。

| 操作                         | 紧凑输入                  | 确定性展开                                                                |
| -------------------------- | --------------------- | -------------------------------------------------------------------- |
| `open_caps`                | `container_ids=[1,2]` | `open_cap_bottle_ids=[{"bottle_id":1},{"bottle_id":2}]`；`keep_cap=1` |
| `close_caps`               | `container_ids=[1,2]` | `close_cap_bottle_ids=[{"bottle_id":1},{"bottle_id":2}]`             |
| `add_liquid_with_material` | 原液瓶编号与加液体积            | 展开为 `sample_bottle_id` 和完整 `source_bottle` 对象                        |

展开后的开盖调用示例：

```json theme={null}
{
  "device_id": "2002186824385539",
  "command_id": "open_caps",
  "arguments": {
    "container_type": "离心瓶",
    "container_count": 2,
    "container_ids": [1, 2],
    "open_cap_bottle_ids": [{"bottle_id": 1}, {"bottle_id": 2}],
    "keep_cap": 1
  },
  "expected_revision": "7"
}
```

## 匹配依据

每个方法调用必须能够在合格设备技能库中找到：

```text theme={null}
设备 namespace
函数名称
request_class
参数名称和类型
初始状态
状态更新
返回值
异常和约束
```

## 绑定输出

绑定器把结果写入最终 JSON：

```json theme={null}
{
  "step_number": 1,
  "id": "2002186824385539",
  "device_name": "移液平台_1ml_V2",
  "command_id": "open_caps",
  "request_class": "invoke",
  "operation": "开盖",
  "parameters": {
    "container_type": "离心瓶",
    "container_count": 2,
    "container_ids": [1, 2]
  }
}
```

加液步骤使用能力定义中的参数结构：

```json theme={null}
{
  "step_number": 2,
  "id": "2002186824385539",
  "device_name": "移液平台_1ml_V2",
  "command_id": "add_liquid_with_material",
  "request_class": "invoke",
  "operation": "加液_物料绑定",
  "parameters": {
    "container_type": "离心瓶",
    "container_count": 2,
    "container_ids": [1],
    "dispensing_plan": [
      {
        "原液瓶编号": 1,
        "加液体积": 0.5
      }
    ]
  }
}
```

## 路径输出

设备间关系使用 `path` 字段：

```json theme={null}
{
  "开始节点id": ["移液平台_1ml_V20节点id"],
  "移液平台_1ml_V20节点id": ["紫外可见光谱仪_V10节点id"],
  "紫外可见光谱仪_V10节点id": ["结束节点id"]
}
```

## 无法绑定

无法识别或无法绑定的步骤写入 `unknown_steps`，并保留原始步骤、失败原因和缺少的技能详情。存在未知步骤时，执行计划不得进入物理执行。
