第66章 Device Object
Device Object 是 ICAI 对现实设备、机器、终端或可执行设备进行结构化描述的对象模型。
在前一章中,DeviceAdapter 解决的是“系统如何连接设备”。本章进一步解决:
系统究竟如何认识一个 Device?
因此,Device Object 不是设备本身,而是 ICAI 内部对设备形成的结构化对象。
核心关系:
Device
├── Identity
├── State
├── Property
├── Method
├── Ability
├── Command
└── Response
完整过程:
Device Object
↓
Identity / Property / State
↓
Ability / Method
↓
Command
↓
DeviceAdapter
↓
Physical Device
↓
Response
↓
Device Object Update
1. Device 定义
Device 是能够被 ICAI 识别、描述、连接、控制或获取状态信息的设备对象。
Device 可以是:
- 灯
- 电机
- 传感器
- 摄像设备
- 机器人
- 工业机器
- 门锁
- 空调
- 服务器
- 网络终端
- 控制器
- 其他可连接设备
Device 的核心不是“硬件名称”,而是一个完整的对象结构。
例如:
Device
{
id: "Light_A",
type: "Light",
name: "Room Light",
state: "OFF",
properties: {
brightness: 80,
voltage: 220
},
methods: [
"powerOn",
"powerOff",
"setBrightness"
],
abilities: [
"PowerControl",
"BrightnessControl"
]
}
这里:
Light_A
是 Device Object 的身份标识。
而:
brightness = 80
是属性。
powerOn()
是方法。
PowerControl
是能力。
因此:
Device 是对象,Property 是对象特征,Method 是对象操作,Ability 是对象能够完成的功能。
2. Device Identity
Device Identity 用于确定一个设备“是谁”。
如果系统无法确定设备身份,就无法可靠地执行后续的状态读取、属性读取、方法调用和命令发送。
基本结构:
DeviceIdentity
{
id
type
name
model
serial
manufacturer
address
protocol
}
例如:
DeviceIdentity
{
id: "Motor_A",
type: "Motor",
name: "Main Motor",
model: "M-100",
serial: "SN10001",
manufacturer: "Factory_A",
address: "192.168.1.20",
protocol: "TCP"
}
Identity 的核心作用
识别设备
↓
确定设备对象
↓
确定连接目标
↓
确定支持的方法
↓
确定可以发送的命令
Device Identity 与普通名称不同。
例如:
name = "Motor"
只能说明它叫 Motor。
而:
id = "Motor_A"
才能作为系统内部对象的唯一标识。
因此:
Name ≠ Identity
3. Device State
Device State 表示设备当前处于什么状态。
例如:
OFF
ON
READY
RUNNING
PAUSED
STOPPED
ERROR
MAINTENANCE
DISCONNECTED
UNKNOWN
Device State 可以根据具体设备定义。
例如电机:
Motor_A.state = RUNNING
灯:
Light_A.state = ON
工业设备:
Machine_A.state = MAINTENANCE
State 与 Property 的区别
例如:
Motor_A
{
state: RUNNING,
speed: 1500,
temperature: 45
}
其中:
state = RUNNING
表示设备当前状态。
而:
speed = 1500
temperature = 45
属于设备属性。
因此:
Device State = 当前状态
Device Property = 对象特征/数据
状态也可能由属性和规则计算得到。
例如:
IF speed > 0
THEN state = RUNNING
4. Device Property
Device Property 描述设备的具体特征、参数和当前数据。
例如:
Light_A
{
brightness: 80,
voltage: 220,
power: 40
}
电机:
Motor_A
{
speed: 1500,
direction: "FORWARD",
temperature: 45
}
传感器:
Sensor_A
{
temperature: 25.6,
humidity: 60,
battery: 90
}
Property 可以具有类型:
STRING
INTEGER
FLOAT
BOOLEAN
DATE
TIME
DATETIME
ENUM
RANGE
OBJECT
ARRAY
STATE
例如:
Property
{
name: "speed",
value: 1500,
type: "INTEGER",
unit: "RPM",
writable: true
}
这里:
speed
是属性名称;
1500
是属性值;
INTEGER
是数据类型;
RPM
是单位。
5. Device Method
Device Method 表示 Device Object 可以执行的具体操作。
例如:
Light_A
可能具有:
powerOn()
powerOff()
setBrightness()
电机:
start()
stop()
rotate()
setSpeed()
机器人:
move()
stop()
grab()
release()
一个 Method 可以定义为:
DeviceMethod
{
name
parameters
return_type
state
}
例如:
DeviceMethod
{
name: "setSpeed",
parameters: {
speed: INTEGER
},
return_type: "DeviceResponse",
state: "ACTIVE"
}
调用:
Motor_A.setSpeed(1500)
并不是直接等于物理设备执行。
完整过程应该是:
Method
↓
Action
↓
Device Command
↓
DeviceAdapter
↓
Motor
因此:
Method 是对象层定义的操作方式,Command 是发送给设备执行层的具体命令。
6. Device Ability
Device Ability 表示一个 Device 能够完成什么功能。
例如:
Light_A
可以具有:
PowerControl
BrightnessControl
电机:
Motor_A
可以具有:
StartStop
SpeedControl
DirectionControl
机器人:
Robot_A
可以具有:
Move
Grab
Release
PositionControl
Ability 与 Method 不完全相同。
例如:
Ability:
SpeedControl
表示:
这个设备具有速度控制能力。
而:
Method:
setSpeed()
表示:
通过什么对象操作实现速度控制。
所以:
Ability = 能做什么
Method = 怎么操作
Command = 发送什么具体命令
三者形成:
Ability
↓
Method
↓
Command
7. Device Command
Device Command 是系统发送给 Device 的具体执行指令。
基本结构:
DeviceCommand
{
id
device_id
type
command
parameters
timestamp
state
}
例如:
DeviceCommand
{
id: "CMD_1001",
device_id: "Light_A",
type: "CONTROL",
command: "POWER_ON",
parameters: {},
timestamp: "2026-09-12 18:00:00",
state: "READY"
}
发送过程:
Action
↓
Device Command
↓
DeviceAdapter
↓
Light_A
例如控制灯:
Action
{
target: "Light_A",
method: "powerOn"
}
转换:
DeviceCommand
{
device_id: "Light_A",
command: "POWER_ON"
}
然后:
DeviceAdapter
↓
Light_A
真正执行。
Command 不是 Action
两者必须区分:
Action
是 ICAI 内部的执行操作。
DeviceCommand
是面向具体设备的执行指令。
因此:
Action → DeviceCommand → Device
8. Device Response
Device Response 是设备执行 Command 后返回的信息。
基本结构:
DeviceResponse
{
id
device_id
command_id
state
output
error
timestamp
}
例如:
DeviceResponse
{
id: "RES_1001",
device_id: "Light_A",
command_id: "CMD_1001",
state: "SUCCESS",
output: {
power: "ON"
},
error: null,
timestamp: "2026-09-12 18:00:01"
}
如果执行失败:
DeviceResponse
{
id: "RES_1002",
device_id: "Light_A",
command_id: "CMD_1002",
state: "FAILED",
output: null,
error: {
code: "DEVICE_OFFLINE",
message: "Device is disconnected"
}
}
Response 可以进一步进入:
Device Response
↓
AdapterResult
↓
Perception
↓
Cognition
↓
Memory
这样 ICAI 就能够知道:
命令是否执行、设备发生了什么变化、执行结果是什么。
9. Device Object 示例
下面建立一个完整的电机 Device Object。
Device
{
id: "Motor_A",
identity:
{
type: "Motor",
name: "Main Motor",
model: "M-100",
serial: "SN10001",
address: "192.168.1.20",
protocol: "TCP"
},
state: "READY",
properties:
{
speed: 0,
direction: "STOP",
temperature: 35,
voltage: 220
},
methods:
[
"start",
"stop",
"setSpeed",
"setDirection"
],
abilities:
[
"StartStop",
"SpeedControl",
"DirectionControl"
]
}
系统需要启动电机:
第一步:识别 Device
device_id = Motor_A
第二步:读取 State
state = READY
第三步:确认 Ability
StartStop = available
SpeedControl = available
第四步:选择 Method
start()
第五步:形成 Command
DeviceCommand
{
id: "CMD_2001",
device_id: "Motor_A",
command: "START",
parameters: {}
}
第六步:DeviceAdapter 发送
DeviceCommand
↓
DeviceAdapter
↓
Motor_A
第七步:设备返回
DeviceResponse
{
device_id: "Motor_A",
command_id: "CMD_2001",
state: "SUCCESS",
output:
{
state: "RUNNING",
speed: 0
}
}
第八步:更新 Device Object
Motor_A.state = RUNNING
随后设备可能继续返回:
speed = 1500
temperature = 42
direction = FORWARD
Device Object 更新为:
Device
{
id: "Motor_A",
state: "RUNNING",
properties:
{
speed: 1500,
direction: "FORWARD",
temperature: 42,
voltage: 220
}
}
Device Object 完整结构
可以将本章形成一个统一模型:
Device Object
│
├── Identity
│ ├── ID
│ ├── Type
│ ├── Name
│ ├── Model
│ ├── Serial
│ ├── Address
│ └── Protocol
│
├── State
│ ├── READY
│ ├── RUNNING
│ ├── STOPPED
│ ├── ERROR
│ └── ...
│
├── Property
│ ├── Value
│ ├── Type
│ ├── Unit
│ └── Writable
│
├── Method
│ ├── Name
│ ├── Parameters
│ └── Return
│
├── Ability
│ ├── Function
│ └── Availability
│
├── Command
│ ├── Device ID
│ ├── Command
│ └── Parameters
│
└── Response
├── Command ID
├── State
├── Output
└── Error
Device Object 与前面章节的关系
Device Object
│
├── Identity
├── State
├── Property
├── Method
└── Ability
│
↓
Action
↓
Device Command
↓
DeviceAdapter
↓
Device
↓
Device Response
↓
AdapterResult
↓
Perception / Memory
这里形成一个非常重要的闭环:
认识设备
↓
判断设备状态
↓
确定设备能力
↓
选择设备方法
↓
形成设备命令
↓
执行设备命令
↓
获得设备响应
↓
更新设备对象
本章核心定义
Device Object 是 ICAI 对设备进行结构化表示的对象模型,由 Identity、State、Property、Method、Ability、Command 和 Response 等部分组成,用于描述设备是谁、当前是什么状态、具有哪些属性、能够做什么、如何操作以及执行后产生什么结果。
最终边界:
Device Object ≠ Physical Device
Device Object ≠ DeviceAdapter
Device Object ≠ Device Command
Device Object ≠ Device Response
它们分别属于:
Device Object → 系统内部的设备认知对象
DeviceAdapter → 系统与设备之间的连接机制
Device Command → 发给设备的具体指令
Device Response → 设备返回的执行结果
Physical Device → 现实中的实际设备
因此,第66章完成的是 ICAI 的 Device 对象模型,而第65章的 DeviceAdapter 则负责这个对象与真实设备之间的实际连接。