什么是物的抽象模型?
更新时间:2018-03-29 17:41:58
现实世界是由真实存在的物理设备所组成的,我们可以将这些设备称之为“物”。物联网的目的则是能够将现实世界中的万“物”通过网络连接在一起,并将其数字化成云端的服务或者资源,通过整合各类服务资源实现智能化。因此,在物联网所构建的数字世界里,我们首先需要对“物”有一个清晰、统一的定义,用于描述“物”具体能做什么,能够提供什么样的服务和资源。ICA联盟从产品层面对“物”进行了功能建模,定义出统一的“物的抽象模型”以及“物的描述语言(TSL,Things Specification Language)”
物的抽象模型
物的抽象模型是对“设备是什么”、“设备能做什么”的一种描述,包括有:物的状态、物的档案信息、物的功能定义。
图1. 物的抽象模型
物的状态
Status
|
设备在线/离线、激活/未激活的状态。
|
|
物的档案信息
Profile
|
设备身份详情的静态描述,包含设备身份标识和设备描述信息。
|
|
物的功能定义
Functionality
|
属性
Property
|
属性是指设备运行时可持续存在的状态,例如电源开关,空调的目标温度,灯的亮度等,是一个可以持续存在的状态。属性支持get和set,应用系统可发起对属性的读取和设置请求。
|
服务
Service
|
服务是设备能够被远程调用而去执行的动作、指令,通常需要花费一定时间执行,例如设备复位、重启,修改密码等。服务包含"输入参数"和"输出参数",输入参数是指物在执行某一动作时需要的指令信息,输出参数是指物在完成某一动作后需要反馈的状态信息。
|
|
事件
Event
|
事件是指在某种情况下物主动上报的信息,这类信息是无法通过查询物的属性而获知的。相比于属性状态,事件一般而言包含设备需要及时被外部感知和处理的通知信息,可包含多个输出参数,如某项任务完成的信息或者设备发生故障/告警时的温度等,事件可以被订阅和推送。
|
物的描述语言TSL
ICA数据标准平台会采用JSON Schema定义,自动生成物模型的描述代码(JSON格式),我们称之为“物的描述语言”(TSL, Things Specification Language)。在ICA数据标准平台上,成员可以随时参看和下载已正式发布“物模板”的TSL代码文档。
下面以“灯”的物模板进行示例说明:
TSL示例
{
"categoryId": 1,
"categoryName": "智能生活",
"contributorId": 44,
"description": "这是一个智能灯",
"eventDTOList": [
{
"base": false,
"baseEventId": 517,
"contributorId": 44,
"eventType": "FAULT",
"featureState": "APPROVED",
"gmtCreate": 1519788920000,
"gmtModified": "2018-02-28 11:35:20",
"id": 519,
"identifier": "Error",
"name": "故障上报",
"outputData": [
{
"baseFlag": true,
"childDataType": "ENUM",
"dataSpecList": [
{
"dataType": "ENUM",
"gmtCreate": 1519788920000,
"gmtModified": 1519788920000,
"id": 4108,
"isDeleted": 0,
"value": "0",
"valueName": "恢复正常"
}
],
"direction": "PARAM_OUTPUT",
"gmtCreate": 1519788920000,
"gmtModified": 1519788920000,
"id": 2441,
"identifier": "ErrorCode",
"isDeleted": 0,
"name": "故障代码",
"paraOrder": 0,
"required": true
}
],
"required": true,
"resourceType": "EVENT",
"thingTemplateId": 671,
"version": "1.0",
"versionId": 0
}
],
"featureState": "APPROVED",
"gmtCreate": 1519788746000,
"gmtModified": "2018-03-08 10:27:46",
"id": 671,
"identifier": "Light",
"name": "灯",
"propertyDTOList": [
{
"accessMode": "READ_WRITE",
"base": false,
"basePropertyId": 1572,
"contributorId": 44,
"dataType": "INT",
"featureState": "APPROVED",
"gmtCreate": 1519788764000,
"gmtModified": "2018-02-28 11:32:44",
"id": 1575,
"identifier": "ColorTemperature",
"max": "6500",
"min": "2700",
"name": "冷暖色温",
"required": false,
"resourceType": "PROPERTY",
"thingTemplateId": 671,
"unit": "K",
"unitName": "",
"unitType": 2,
"version": "1.0",
"versionId": 0
},
{
"accessMode": "READ_WRITE",
"base": false,
"basePropertyId": 1573,
"contributorId": 44,
"dataType": "INT",
"featureState": "APPROVED",
"gmtCreate": 1519788774000,
"gmtModified": "2018-02-28 11:32:54",
"id": 1576,
"identifier": "Brightness",
"max": "100",
"min": "0",
"name": "明暗度",
"required": false,
"resourceType": "PROPERTY",
"thingTemplateId": 671,
"unit": "%",
"unitName": "",
"unitType": 36,
"version": "1.0",
"versionId": 0
},
{
"accessMode": "READ_WRITE",
"base": false,
"basePropertyId": 1569,
"contributorId": 44,
"dataType": "STRUCT",
"featureState": "APPROVED",
"gmtCreate": 1519788785000,
"gmtModified": "2018-02-28 11:33:05",
"id": 1577,
"identifier": "HSVColor",
"name": "HSV颜色",
"required": false,
"resourceType": "PROPERTY",
"structSpecDTOList": [
{
"childDataType": "INT",
"dataSpec": {
"dataType": "INT",
"gmtCreate": 1519788785000,
"gmtModified": 1519788785000,
"id": 3089,
"identifier": "Hue",
"isDeleted": 0,
"max": "360",
"min": "0",
"name": "色调",
"unit": "°",
"unitName": "度",
"unitType": 9
},
"identifier": "Hue",
"name": "色调"
},
{
"childDataType": "INT",
"dataSpec": {
"dataType": "INT",
"gmtCreate": 1519788785000,
"gmtModified": 1519788785000,
"id": 3090,
"identifier": "Saturation",
"isDeleted": 0,
"max": "100",
"min": "0",
"name": "饱和度",
"unit": "%",
"unitName": "百分比",
"unitType": 36
},
"identifier": "Saturation",
"name": "饱和度"
},
{
"childDataType": "INT",
"dataSpec": {
"dataType": "INT",
"gmtCreate": 1519788785000,
"gmtModified": 1519788785000,
"id": 3091,
"identifier": "Value",
"isDeleted": 0,
"max": "100",
"min": "0",
"name": "明度",
"unit": "%",
"unitName": "百分比",
"unitType": 36
},
"identifier": "Value",
"name": "明度"
}
],
"thingTemplateId": 671,
"version": "1.0",
"versionId": 0
},
{
"accessMode": "READ_WRITE",
"base": false,
"basePropertyId": 1570,
"contributorId": 44,
"dataType": "STRUCT",
"featureState": "APPROVED",
"gmtCreate": 1519788793000,
"gmtModified": "2018-02-28 11:33:13",
"id": 1578,
"identifier": "HSLColor",
"name": "HSL颜色",
"required": false,
"resourceType": "PROPERTY",
"structSpecDTOList": [
{
"childDataType": "INT",
"dataSpec": {
"dataType": "INT",
"gmtCreate": 1519788793000,
"gmtModified": 1519788793000,
"id": 3092,
"identifier": "Hue",
"isDeleted": 0,
"max": "360",
"min": "0",
"name": "色调",
"unit": "°",
"unitName": "度",
"unitType": 9
},
"identifier": "Hue",
"name": "色调"
},
{
"childDataType": "INT",
"dataSpec": {
"dataType": "INT",
"gmtCreate": 1519788793000,
"gmtModified": 1519788793000,
"id": 3093,
"identifier": "Saturation",
"isDeleted": 0,
"max": "100",
"min": "0",
"name": "饱和度",
"unit": "%",
"unitName": "百分比",
"unitType": 36
},
"identifier": "Saturation",
"name": "饱和度"
},
{
"childDataType": "INT",
"dataSpec": {
"dataType": "INT",
"gmtCreate": 1519788793000,
"gmtModified": 1519788793000,
"id": 3094,
"identifier": "Lightness",
"isDeleted": 0,
"max": "100",
"min": "0",
"name": "亮度",
"unit": "%",
"unitName": "百分比",
"unitType": 36
},
"identifier": "Lightness",
"name": "亮度"
}
],
"thingTemplateId": 671,
"version": "1.0",
"versionId": 0
},
{
"accessMode": "READ_WRITE",
"base": false,
"basePropertyId": 1571,
"contributorId": 44,
"dataType": "STRUCT",
"featureState": "APPROVED",
"gmtCreate": 1519788799000,
"gmtModified": "2018-02-28 11:33:19",
"id": 1579,
"identifier": "RGBColor",
"name": "RGB颜色",
"required": false,
"resourceType": "PROPERTY",
"structSpecDTOList": [
{
"childDataType": "INT",
"dataSpec": {
"dataType": "INT",
"gmtCreate": 1519788799000,
"gmtModified": 1519788799000,
"id": 3095,
"identifier": "Red",
"isDeleted": 0,
"max": "255",
"min": "0",
"name": "红色",
"unit": "",
"unitName": "无",
"unitType": 44
},
"identifier": "Red",
"name": "红色"
},
{
"childDataType": "INT",
"dataSpec": {
"dataType": "INT",
"gmtCreate": 1519788799000,
"gmtModified": 1519788799000,
"id": 3096,
"identifier": "Green",
"isDeleted": 0,
"max": "255",
"min": "0",
"name": "绿色",
"unit": "",
"unitName": "无",
"unitType": 44
},
"identifier": "Green",
"name": "绿色"
},
{
"childDataType": "INT",
"dataSpec": {
"dataType": "INT",
"gmtCreate": 1519788799000,
"gmtModified": 1519788799000,
"id": 3097,
"identifier": "Blue",
"isDeleted": 0,
"max": "255",
"min": "0",
"name": "蓝色",
"unit": "",
"unitName": "无",
"unitType": 44
},
"identifier": "Blue",
"name": "蓝色"
}
],
"thingTemplateId": 671,
"version": "1.0",
"versionId": 0
},
{
"accessMode": "READ_WRITE",
"base": false,
"basePropertyId": 1548,
"contributorId": 44,
"dataType": "BOOL",
"description": "",
"enumSpecDTOList": [
{
"dataType": "BOOL",
"gmtCreate": 1519788822000,
"gmtModified": 1519788822000,
"id": 4098,
"isDeleted": 0,
"value": "0",
"valueName": "关闭"
},
{
"dataType": "BOOL",
"gmtCreate": 1519788822000,
"gmtModified": 1519788822000,
"id": 4099,
"isDeleted": 0,
"value": "1",
"valueName": "开启"
}
],
"featureState": "APPROVED",
"gmtCreate": 1519788822000,
"gmtModified": "2018-02-28 11:33:42",
"id": 1580,
"identifier": "LightSwitch",
"name": "主灯开关",
"required": true,
"resourceType": "PROPERTY",
"thingTemplateId": 671,
"version": "1.0",
"versionId": 0
},
{
"accessMode": "READ_WRITE",
"base": false,
"basePropertyId": 1548,
"contributorId": 44,
"dataType": "BOOL",
"description": "",
"enumSpecDTOList": [
{
"dataType": "BOOL",
"gmtCreate": 1519788847000,
"gmtModified": 1519788847000,
"id": 4100,
"isDeleted": 0,
"value": "0",
"valueName": "关闭"
},
{
"dataType": "BOOL",
"gmtCreate": 1519788847000,
"gmtModified": 1519788847000,
"id": 4101,
"isDeleted": 0,
"value": "1",
"valueName": "开启"
}
],
"featureState": "APPROVED",
"gmtCreate": 1519788847000,
"gmtModified": "2018-02-28 11:34:07",
"id": 1581,
"identifier": "NightLightSwitch",
"name": "夜灯开关",
"required": false,
"resourceType": "PROPERTY",
"thingTemplateId": 671,
"version": "1.0",
"versionId": 0
},
{
"accessMode": "READ_WRITE",
"base": false,
"basePropertyId": 1574,
"contributorId": 44,
"dataType": "ENUM",
"enumSpecDTOList": [
{
"dataType": "ENUM",
"gmtCreate": 1519788867000,
"gmtModified": 1519788867000,
"id": 4102,
"isDeleted": 0,
"name": "",
"value": "0",
"valueName": "手动"
},
{
"dataType": "ENUM",
"gmtCreate": 1519788867000,
"gmtModified": 1519788867000,
"id": 4103,
"isDeleted": 0,
"value": "1",
"valueName": "阅读"
},
{
"dataType": "ENUM",
"gmtCreate": 1519788867000,
"gmtModified": 1519788867000,
"id": 4104,
"isDeleted": 0,
"value": "2",
"valueName": "影院"
},
{
"dataType": "ENUM",
"gmtCreate": 1519788867000,
"gmtModified": 1519788867000,
"id": 4105,
"isDeleted": 0,
"value": "3",
"valueName": "夜灯"
},
{
"dataType": "ENUM",
"gmtCreate": 1519788867000,
"gmtModified": 1519788867000,
"id": 4106,
"isDeleted": 0,
"value": "4",
"valueName": "生活"
},
{
"dataType": "ENUM",
"gmtCreate": 1519788867000,
"gmtModified": 1519788867000,
"id": 4107,
"isDeleted": 0,
"value": "5",
"valueName": "柔和"
}
],
"featureState": "APPROVED",
"gmtCreate": 1519788867000,
"gmtModified": "2018-02-28 11:34:27",
"id": 1582,
"identifier": "LightWorkMode",
"name": "工作模式",
"required": false,
"resourceType": "PROPERTY",
"thingTemplateId": 671,
"version": "1.0",
"versionId": 0
}
],
"serviceDTOList": [
{
"base": false,
"baseServiceId": 585,
"contributorId": 44,
"featureState": "APPROVED",
"gmtCreate": 1519788882000,
"gmtModified": "2018-02-28 11:35:04",
"id": 586,
"identifier": "ToggleLightSwitch",
"inputParams": [],
"name": "翻转主灯开关",
"outputParams": [],
"required": false,
"resourceType": "SERVICE",
"thingTemplateId": 671,
"version": "1.0",
"versionId": 0
}
],
"version": "1.0",
"versionId": 0,
"versions": [
"1.0"
]
}