物模型TSL

设备平台通过定义一种物的描述JSON文件来描述产品的功能,称为TSL(Thing Specification Language),物模型TSL文件格式为JSON。本文介绍物模型TSL文件中JSON字段及其详细说明。

为了完整展示TSL的结构,以下示例中包含所有参数,不代表实际使用中可能出现的组合。参数后的文字为参数说明,非参数值。各参数的使用场景,请参见参数说明。

{
    "schema": "物模型结构定义的访问URL。",
    "profile": {
           "productId": "当前产品的productId",
           "productVersion": "产品物模型版本",
           "moduleIdentifier": "模块标识符"
    },
    "properties": [
        {
            "identifier": "属性唯一标识符(物模型模块下唯一)。",
            "name": "属性名称",
            "desc": "事件描述。",
            "nid": "数字标识符(物模型模块下唯一)",
            "accessMode": "属性读写类型:读(r)、写(w)、上报(rp)。",
            "dataType": {
                "type": "属性类型: int32、float、bool、enum、string、timestamp、array、struct(下面使用"specs":[{}]描述包含的对象)",
                "specs": {
                    "min": "参数最小值(int32、float类型特有)。",
                    "max": "参数最大值(int32、float类型特有)。",
                    "unit": "属性单位(int32、float类型特有)。",
                    "init": "初始化值(int32、float类型特有)。",
                    "step": "步长(int32、float类型特有)。",
                    "size": "数组元素的个数,最大512(array类型特有)。",
                    "maxLength": "数据长度(text类型特有)。",
                    "0": "0的值(bool类型特有)。",
                    "1": "1的值(bool类型特有)。",
                    "item": {
                        "type": "数组元素的类型(array类型特有)。"
                    },
                    "specs": {
                       "type":"结构体类型的子元素类型(struct类型特有)"
                    }
            }
            }
        }
    ],
    "events": [
        {
            "identifier": "事件唯一标识符(物模型模块下唯一)。",
            "name": "事件名称。",
            "desc": "事件描述。",
            "type": "事件类型(info、alert、error)。",
            "outputData": [
                {
                    "identifier": "参数唯一标识符。",
                    "name": "参数名称。",
                    "dataType": {
                        "type": "属性类型: int32、float、bool、enum、string、timestamp、array、struct(下面使用"specs":[{}]描述包含的对象)",
                        "specs": {
                            "min": "参数最小值(int32、float类型特有)。",
                            "max": "参数最大值(int32、float类型特有)。",
                            "unit": "属性单位(int32、float类型特有)。",
                            "init": "初始化值(int32、float类型特有)。",
                            "step": "步长(int32、float类型特有)。",
                             "size": "数组元素的个数,最大512(array类型特有)。", 
                             "maxLength": "数据长度(text类型特有)。",
                             "0": "0的值(bool类型特有)。",
                             "1": "1的值(bool类型特有)。",
                             "item": {
                                "type": "数组元素的类型(array类型特有)。"
                            }
                         }
                    }
                }
            ]
        }
    ],
    "actions": [
        {
            "identifier": "服务唯一标识符(物模型模块下唯一)。",
            "name": "服务名称。",
            "desc": "服务描述。",
            "inputData": [
                {
                    "identifier": "入参唯一标识符。",
                    "name": "入参名称。",
                    "dataType": {
                        "type": "属性类型: int32、float、bool、enum、string、timestamp、array、struct(下面使用"specs":[{}]描述包含的对象)",
                        "specs": {
                            "min": "参数最小值(int32、float类型特有)。",
                            "max": "参数最大值(int32、float类型特有)。",
                            "unit": "属性单位(int32、float类型特有)。",
                            "init": "初始化值(int32、float类型特有)。",
                            "step": "步长(int32、float类型特有)。",
                            "size": "数组元素的个数,最大512(array类型特有)。",
                            "maxLength": "数据长度(text类型特有)。",
                            "0": "0的值(bool类型特有)。",
                            "1": "1的值(bool类型特有)。",
                            "item": {
                                "type": "数组元素的类型(array类型特有)。"
                            }
                          }
                        }
                    }
            ],
            "outputData": [
                {
                    "identifier": "出参唯一标识符。",
                    "name": "出参名称。",
                    "dataType": {
                        "type": "属性类型: int32、float、bool、enum、string、timestamp、array、struct(下面使用"specs":[{}]描述包含的对象)",
                        "specs": {
                            "min": "参数最小值(int32、float类型特有)。",
                            "max": "参数最大值(int32、float类型特有)。",
                            "unit": "属性单位(int32、float类型特有)。",
                            "init": "初始化值(int32、float类型特有)。",
                            "step": "步长(int32、float类型特有)。",
                            "size": "数组元素的个数,最大512(array类型特有)。", 
                            "maxLength": "数据长度(text类型特有)。",
                            "0": "0的值(bool类型特有)。",
                            "1": "1的值(bool类型特有)。",
                            "item": {
                                "type": "数组元素的类型(array类型特有)。"
                            }
                         }
                    }
                }
            ]
        }
    ]
}
 创建时间:2023-05-09 16:57
最后编辑:陈勇琦  更新时间:2024-10-18 10:58