第65章 DeviceAdapter
1. DeviceAdapter
DeviceAdapter 是 SATE 中专门负责连接设备环境的 Adapter。
上一章已经定义:
Renderer
↓
Rendered Result
↓
Adapter
↓
External Environment
当目标环境是 Device 时:
Expression
↓
Template
↓
DeviceRenderer
↓
Device Data
↓
DeviceAdapter
↓
Device
DeviceAdapter 的核心职责是:
- 识别目标设备
- 检查设备状态
- 接收 Device Command
- 建立设备连接
- 发送命令
- 接收设备响应
- 形成 Device Response
- 返回 AdapterResult
它本身不负责:
感知
认知
理解
推理
决策
学习
记忆
因此:
Decision
= 决定做什么
Action
= 执行什么行动
Device Command
= 给设备什么命令
DeviceAdapter
= 把命令连接并传递给设备
核心结构:
DeviceAdapter
{
device
connection
command
response
state
}
2. LightAdapter
LightAdapter 是面向灯光设备的 Adapter。
例如系统已经决定:
Decision
{
target: "Light_A",
action: "TURN_ON"
}
形成 Action:
Action
{
type: "DEVICE_CONTROL",
target: "Light_A",
method: "turnOn"
}
然后形成 Device Command:
DeviceCommand
{
device_id: "Light_A",
command: "POWER",
value: "ON"
}
LightAdapter 将命令转换成灯光设备能够识别的形式:
LightAdapter
↓
Light_A
↓
POWER=ON
设备响应:
LightResponse
{
device_id: "Light_A",
state: "ON"
}
然后形成:
AdapterResult
{
state: "SUCCESS",
success: true,
output: {
device_id: "Light_A",
state: "ON"
}
}
完整流程:
Decision
↓
Action
↓
Device Command
↓
LightAdapter
↓
Light
↓
Device Response
↓
AdapterResult
LightAdapter 只负责灯光设备连接与命令传递。
3. MotorAdapter
MotorAdapter 用于连接电机或运动执行设备。
例如:
Action
{
target: "Motor_A",
method: "rotate",
parameters: {
direction: "FORWARD",
speed: 50
}
}
转换为:
DeviceCommand
{
device_id: "Motor_A",
command: "ROTATE",
parameters: {
direction: "FORWARD",
speed: 50
}
}
MotorAdapter:
MotorAdapter
↓
Motor_A
设备执行以后返回:
DeviceResponse
{
device_id: "Motor_A",
state: "RUNNING",
speed: 50,
direction: "FORWARD"
}
最终:
MotorAdapter
↓
AdapterResult
例如:
AdapterResult
{
state: "SUCCESS",
success: true,
output: {
state: "RUNNING",
speed: 50
}
}
MotorAdapter 可以处理:
START
STOP
FORWARD
REVERSE
ROTATE
SPEED
POSITION
但具体命令取决于实际电机接口。
4. SensorAdapter
SensorAdapter 与前面几类 Adapter 有一个重要区别。
LightAdapter、MotorAdapter 主要表现为:
系统 → 设备
而 SensorAdapter 更多是:
设备 → 系统
例如温度传感器:
Sensor_A
↓
Temperature = 25
↓
SensorAdapter
↓
System
SensorAdapter 接收到:
SensorResponse
{
device_id: "Sensor_A",
type: "TEMPERATURE",
value: 25,
unit: "C",
state: "ACTIVE"
}
然后可以形成系统能够处理的结构:
Device Data
{
object: "Sensor_A",
property: "temperature",
value: 25,
unit: "C"
}
之后是否进入:
Perception
↓
Cognition
↓
Memory
↓
Reasoning
由系统自己的认知流程决定。
因此:
SensorAdapter
≠ PerceptionEngine
SensorAdapter 只是:
把传感器产生的数据连接并传递给系统。
真正的感知发生在后面的 Perception 系统。
完整关系:
Sensor
↓
SensorAdapter
↓
Sensor Data
↓
Perception
↓
Elements
↓
Objects
↓
Cognition
这样就不会把 Adapter 和 Perception 混在一起。
5. RobotAdapter
RobotAdapter 用于连接机器人系统。
机器人通常不是单一设备,而是多个设备与执行机构的组合。
例如:
Robot_A
├── Camera
├── Sensor
├── Motor
├── Arm
├── Gripper
└── Controller
RobotAdapter 可以作为机器人整体的外部连接层。
例如:
DeviceCommand
{
device_id: "Robot_A",
command: "MOVE",
parameters: {
direction: "FORWARD",
distance: 100
}
}
RobotAdapter:
RobotAdapter
↓
Robot Controller
↓
Robot
返回:
DeviceResponse
{
device_id: "Robot_A",
command: "MOVE",
state: "COMPLETED",
position: {
x: 100,
y: 0
}
}
RobotAdapter 还可以连接:
MOVE
STOP
ROTATE
GRAB
RELEASE
POSITION
STATUS
但 RobotAdapter 本身不决定:
机器人为什么移动?
应该移动到哪里?
是否应该抓取?
这些属于:
Cognition
Reasoning
Decision
Behavior
Action
RobotAdapter 只是把已经确定的行动连接到机器人。
6. MachineAdapter
MachineAdapter 用于连接更加复杂的机器或工业设备。
例如:
Machine_A
├── Controller
├── Motor
├── Sensor
├── Temperature
├── Pressure
└── Production Unit
系统形成:
DeviceCommand
{
device_id: "Machine_A",
command: "START",
parameters: {
mode: "NORMAL"
}
}
MachineAdapter:
MachineAdapter
↓
Machine Controller
↓
Machine_A
设备响应:
DeviceResponse
{
device_id: "Machine_A",
state: "RUNNING",
mode: "NORMAL"
}
也可以处理机器状态:
STOPPED
READY
RUNNING
PAUSED
ERROR
MAINTENANCE
MachineAdapter 的核心任务仍然是:
Command
↓
Connection
↓
Machine
↓
Response
而不是自己进行机器状态认知。
例如:
MachineResponse
state = ERROR
进入系统以后:
Device Response
↓
Perception
↓
Cognition
↓
Understanding
↓
Reasoning
↓
Decision
这样可以形成完整的闭环。
7. Device Command
Device Command 是系统发送给设备的结构化命令。
基本结构:
DeviceCommand
{
id
device_id
type
command
parameters
timestamp
state
}
例如:
DeviceCommand
{
id: 1001,
device_id: "Light_A",
type: "CONTROL",
command: "POWER",
parameters: {
value: "ON"
},
timestamp: "2026-09-12 18:00:00",
state: "READY"
}
不同设备可以拥有不同 Command。
Light
POWER ON
POWER OFF
BRIGHTNESS 50
Motor
START
STOP
SPEED 50
FORWARD
REVERSE
Sensor
通常主要接收:
READ
STATUS
CONFIG
Robot
MOVE
STOP
GRAB
RELEASE
POSITION
Machine
START
STOP
PAUSE
RESET
STATUS
因此:
DeviceCommand
↓
Device Type
↓
Device-specific Command
Device Command 必须经过基本验证:
1. device_id 是否存在
2. command 是否支持
3. parameters 是否完整
4. 参数类型是否正确
5. 设备是否允许执行
6. 设备连接是否有效
例如:
IF Device.state = "OFFLINE"
THEN Command.state = "REJECTED"
这属于设备执行条件检查,而不是认知推理。
8. Device Response
Device Response 是设备执行 Command 后返回的结果。
基本结构:
DeviceResponse
{
id
device_id
command_id
state
output
error
timestamp
}
成功:
DeviceResponse
{
id: 2001,
device_id: "Light_A",
command_id: 1001,
state: "SUCCESS",
output: {
power: "ON"
},
error: null
}
失败:
DeviceResponse
{
id: 2002,
device_id: "Motor_A",
command_id: 1002,
state: "FAILED",
output: null,
error: {
code: "DEVICE_OFFLINE",
message: "Device is offline"
}
}
完整过程:
DeviceCommand
↓
DeviceAdapter
↓
Device
↓
Device Execution
↓
DeviceResponse
↓
AdapterResult
例如:
DeviceCommand
{
device_id: "Light_A",
command: "POWER",
value: "ON"
}
经过:
LightAdapter
设备返回:
DeviceResponse
{
device_id: "Light_A",
state: "ON"
}
Adapter 最终返回:
AdapterResult
{
state: "SUCCESS",
success: true,
output: {
device_id: "Light_A",
state: "ON"
}
}
DeviceAdapter 完整模型
第65章可以形成统一的 DeviceAdapter 架构:
ICAI
↓
Decision
↓
Behavior
↓
Action
↓
Device Command
↓
DeviceAdapter
↓
┌──────────┬─────────┬─────────┬─────────┐
↓ ↓ ↓ ↓ ↓
Light Motor Sensor Robot Machine
↓ ↓ ↓ ↓ ↓
└──────────┴─────────┴─────────┴─────────┘
↓
Device Response
↓
AdapterResult
↓
System / Perception
不同 Adapter 的定位:
LightAdapter
= 灯光设备连接
MotorAdapter
= 电机设备连接
SensorAdapter
= 传感器数据连接
RobotAdapter
= 机器人系统连接
MachineAdapter
= 机器系统连接
而整个 DeviceAdapter:
Device Command
↓
DeviceAdapter
↓
Device
↓
Device Response
核心定义
DeviceAdapter 是 SATE 与设备环境之间的连接组件,用于接收结构化 Device Command,将命令传递给目标设备,并接收 Device Response,形成可供系统继续处理的 AdapterResult。
最终形成:
Decision
↓
Behavior
↓
Action
↓
Device Command
↓
DeviceAdapter
↓
Device
↓
Device Response
↓
AdapterResult
↓
Perception / Cognition / Memory
这里尤其要保持三个层次:
DeviceRenderer
= 把结果表现成设备可识别的形式
DeviceAdapter
= 把表现结果连接到设备
Device
= 真正执行设备操作
因此:
DeviceAdapter 是“系统与设备之间的桥梁”,而不是设备本身,也不是 ICAI 的认知与决策引擎。