Skip to content

物模型说明文档

物模型描述设备的基本功能。设备与物联网平台交互的数据有上行的属性和事件数据,下行的服务数据。属性和事件数据用于设备主动上报感知消息供应用程序使用,服务数据用于应用程序给设备下发控制指令。

属性

一个属性的描述

参数名 数据类型 是否必须 描述
identifier String 属性标识
name String 属性名称
dataType Object 属性的数据类型
accessMode String 访问权限
desc String 描述
accessMode
1 = "可读"
2 = "可写"
3 = "读写"

dataType

参数名 数据类型 是否必须 描述
type String 类型
specs Object 类型元数据
  • 数字型
type = ["int|float|double"]

[specs]
min = ""
max = ""
unit = ""
unitName = ""
step = ""
参数名 数据类型 是否必须 描述
min String 最小值
max String 最大值
unit String 单位
unitName String 单位名称
step String 步长

例如描述一个设备按钮的点击次数

{
    "type": "int",
    "specs" :{
        "min": "0",
        "max": "100",
        "unit": "ci",
        "unitName": "次",
        "step": "1"
    }
}
  • 枚举型
type = ["enum"]
[specs]
{key} = {value}

例如描述三原色

{
    "type": "enum",
    "specs": {
        "RED": "红色",
        "YELLOW": "黄色",
        "BLUE": "蓝色"
    }
}
  • 布尔值
type = ["bool"]
[specs]
1 = "true"
0 = "false"

例如描述一个设备的开关状态

{
    "type": "bool",
    "specs": {
        "1": "true",
        "0": "false"
    }
}
  • 字符串
type = ["text"]
[specs]
length = ""

参数名 数据类型 是否必须 备注
length String 字符串最大长度

例如描述一个设备输出的告警信息

{
    "type": "text",
    "specs": {
        "length": "2048"
    }
}
  • 日期
type = ["date"]
[specs]

例如描述一个设备启动日期

{
    "type": "date",
    "specs": {}
}
  • 结构型
type = ["struct"]
[[specs]]
identifier = ""
name = ""
dataType = { "type" = "", specs = {} }

例如描述一个测温设备的测温记录

{
    "type": "struct",
    "specs": [
        {
            "identifier": "deviceId",
            "name": "设备ID",
            "dataType": {
                "type": "text",
                "specs": {
                    "length": "30"
                }
            }
        },
        {
            "identifier": "gender",
            "name": "性别",
            "dataType": {
                "type": "bool",
                "specs": {
                    "1": "男",
                    "0": "女"
                }
            }
        },
        {
            "identifier": "temperature",
            "name": "体温",
            "dataType": {
                "type": "float",
                "specs": {
                    "min": "30.0",
                    "max": "40.0",
                    "unit": "℃",
                    "unitName": "摄氏度",
                    "step": ""
                }
            }
        },
        {
            "identifier": "pick_date",
            "name": "采集日期",
            "dataType": {
                "type": "date",
                "specs": {}
            }
        }
    ]
}
  • 数组型
type = ["array"]
[specs]
size = ""
item = {"type" = "", specs = {}}

事件

一个事件的描述

参数名 数据类型 是否必须 备注
identifier String 事件标识
name String 事件名称
desc String 事件描述
type String 事件类型
outputData Array 输出参数

type

"info" = "消息"
"warn" = "告警"
"error" = "错误"

例如描述一个温度过高告警事件

{
    "identifier": "ht_event",
    "name": "温度过高告警事件",
    "desc": "",
    "type": "warn",
    "outputData":[
        {
            "identifier": "temperature",
            "name": "温度",
            "dataType": {
                "type": "float",
                "specs": {
                    "min": "",
                    "max": "",
                    "unit": "",
                    "unitName": "",
                    "step": ""
                }
            }
        },
        {
            "identifier": "phoneNumber",
            "name": "手机号",
            "dataType": {
                "type": "text",
                "specs": {
                    "length": "40"
                }
            }
        }
    ]
}

服务

一个设备服务的描述

参数名 数据类型 是否必须 备注
identifier String 服务标识
name String 服务名称
desc String 服务描述
callType String 服务调用类型
inputData Array 服务入参
outputData Array 服务出参

callType

2 = "同步 sync"
1 = "异步 async"

例如描述一个设备的开关服务

{
    "identifier": "switch",
    "name": "开关服务",
    "desc": "打开或关闭设备",
    "callType": "1",
    "inputData": [
        {
            "identifier": "flag",
            "name": "开关标识",
            "dataType": {
                "type": "bool",
                "specs": {
                    "1": "开",
                    "0": "关"
                }
            }
        }
    ],
    "outputData": []
}