---
name: "SmartDeviceModel.getDpSchema"
mode: "api"
versionRequirements:
  - { name: "@ray-js/panel-sdk", version: "1.0.0" }
---

## SmartDeviceModel.getDpSchema

> [VERSION] @ray-js/panel-sdk >= 1.0.0

### 描述

获取智能设备 DP Schema（功能点描述）映射表

### 参数

无


### 返回值

类型: `Record<string, DpSchema>`

功能点模型映射对象，key 为功能点 code，value 包含 attr、mode、property、type 等

### 引用对象

##### `interface` DpSchema

| 属性 | 类型 | 描述 |
| --- | --- | --- |
| `attr` | `number` | 功能点属性标位，用于扩展功能点的附加能力标识 |
| `canTrigger` | `boolean` | 是否可作为自动化触发条件 |
| `code` | `string` | 功能点标识码，如 switch |
| `defaultRecommend` | `boolean` | 是否为默认推荐的功能点 |
| `editPermission` | `boolean` | 是否具有编辑权限 |
| `executable` | `boolean` | 是否可执行下发 |
| `extContent` | `string` | 功能点扩展内容，通常为 JSON 字符串 |
| `iconname` | `string` | 功能点图标名称 |
| `id` | `string \| number` | 功能点 ID |
| `mode` | `"rw" \| "ro" \| "wr"` | 功能点模式类型 rw: 可下发可上报（可读可写） ro: 只可上报（仅可读） wr: 只可下发（仅可写） |
| `name` | `string` | 功能点名称，一般用于语音等场景 |
| `property` | `Object` | 功能点属性 |
| `type` | `"raw" \| "obj"` | 功能点数据类型大类：raw 为原始字节流，obj 为结构化对象 |

##### `type` DpSchema.property

| 属性 | 类型 | 描述 |
| --- | --- | --- |
| `type` | `"string" \| "bool" \| "value" \| "enum" \| "bitmap" \| "raw"` | 功能点类型 |
| `range` | `string[] \| string[]` | 枚举值范围，type = enum 时才存在 |
| `label` | `string[] \| string[]` | 故障型标签列表，type = bitmap 时才存在 |
| `maxlen` | `number` | 故障型最大长度，type = bitmap 时才存在 |
| `unit` | `string` | 数值型单位，type = value 时才存在 |
| `min` | `number` | 数值型最小值，type = value 时才存在 |
| `max` | `number` | 数值型最大值，type = value 时才存在 |
| `scale` | `number` | 数值型精度，type = value 时才存在 |
| `step` | `number` | 数值型步长，type = value 时才存在 |


### 示例代码

#### 示例

```typescript
const dpSchema = device.getDpSchema();
console.log(dpSchema.switch_led.property.type); // 'bool'

// 返回值示例（key 为功能点 code）：
// {
//   power: {
//     code: 'power', id: 1, name: '开关', mode: 'rw', type: 'obj',
//     property: { type: 'bool' }
//   },
//   mode: {
//     code: 'mode', id: 3, name: '清扫模式', mode: 'rw', type: 'obj',
//     property: { type: 'enum', range: ['standby', 'random', 'smart', 'wall_follow', ...] }
//   }
// }
```
