Skip to content

物模型说明文档 ​

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

属性 ​

一个属性的描述

参数名数据类型是否必须描述
identifierString是属性标识
nameString是属性名称
dataTypeObject是属性的数据类型
accessModeString是访问权限
descString是描述
accessMode
1 = "可读"
2 = "可写"
3 = "读写"

dataType

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

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

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

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

例如描述三原色

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

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

json
{
	"type": "bool",
	"specs": {
		"1": "true",
		"0": "false"
	}
}
  • 字符串
json
type = ["text"]
[specs]
length = ""
参数名数据类型是否必须备注
lengthString否字符串最大长度

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

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

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

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

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

json
{
	"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 = {}}

事件 ​

一个事件的描述

参数名数据类型是否必须备注
identifierString是事件标识
nameString是事件名称
descString否事件描述
typeString是事件类型
outputDataArray是输出参数

type

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

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

json
{
	"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"
                }
            }
        }
    ]
}

服务 ​

一个设备服务的描述

参数名数据类型是否必须备注
identifierString是服务标识
nameString是服务名称
descString否服务描述
callTypeString是服务调用类型
inputDataArray否服务入参
outputDataArray否服务出参

callType

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

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

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