TSL field descriptions

更新时间:
复制 MD 格式

This topic describes the JSON fields in a Thing Specification Language (TSL) model file and provides detailed descriptions for each field.

Note The following example includes all parameters to demonstrate the complete TSL structure. This does not represent an actual combination of parameters that you might use. The text after each parameter is its description, not its value. For information about the use case of each parameter, see its description.
{
    "schema": "The access URL for the TSL model structure definition.",
    "profile": {
        "productKey": "The ProductKey of the current product."
    },
    "properties": [
        {
            "identifier": "The unique identifier of the property. It must be unique within the TSL module.",
            "name": "The property name.",
            "accessMode": "The read/write type of the property: read-only (r) or read/write (rw).",
            "required": "Specifies whether the property is required for the standard function plan: true (yes) or false (no).",
            "dataType": {
                "type": "The property type. Valid values: int (native), float (native), double (native), text (native), date (String type in UTC milliseconds), bool (int type with a value of 0 or 1), enum (int type, with values defined similarly to the bool type), struct (a structure that can contain the other seven types, described in \"specs\"), and array (supports int, double, float, text, and struct).",
                "specs": {
                    "min": "The minimum value of the parameter. Specific to int, float, and double types.",
                    "max": "The maximum value of the parameter. Specific to int, float, and double types.",
                    "unit": "The unit of the property. Specific to int, float, and double types. This parameter is optional.",
                    "unitName": "The name of the unit. Specific to int, float, and double types. This parameter is optional.",
                    "size": "The number of array elements. Maximum: 512. Specific to the array type.",
                    "step": "The step size. This parameter is not available for text and enum types.",
                    "length": "The data length. Maximum: 10240. Specific to the text type.",
                    "0": "The value for 0. Specific to the bool type.",
                    "1": "The value for 1. Specific to the bool type.",
                    "item": {
                        "type": "The type of the array elements. Specific to the array type."
                    }
                }
            }
        }
    ],
    "events": [
        {
            "identifier": "The unique identifier of the event. It must be unique within the TSL module. The 'post' event is generated by default for property reporting.",
            "name": "The event name.",
            "desc": "The event description.",
            "type": "The event type. Valid values: info, alert, and error.",
            "required": "Specifies whether the event is required for the standard function plan: true (yes) or false (no).",
            "outputData": [
                {
                    "identifier": "The unique identifier of the parameter.",
                    "name": "The parameter name.",
                    "dataType": {
                        "type": "The property type. Valid values: int (native), float (native), double (native), text (native), date (String type in UTC milliseconds), bool (int type with a value of 0 or 1), enum (int type, with values defined similarly to the bool type), struct (a structure that can contain the other seven types, described in \"specs\"), and array (supports int, double, float, text, and struct).",
                        "specs": {
                            "min": "The minimum value of the parameter. Specific to int, float, and double types.",
                            "max": "The maximum value of the parameter. Specific to int, float, and double types.",
                            "unit": "The unit of the property. Specific to int, float, and double types. This parameter is optional.",
                            "unitName": "The name of the unit. Specific to int, float, and double types. This parameter is optional.",
                            "size": "The number of array elements. Maximum: 512. Specific to the array type.",
                            "step": "The step size. This parameter is not available for text and enum types.",
                            "length": "The data length. Maximum: 10240. Specific to the text type.",
                            "0": "The value for 0. Specific to the bool type.",
                            "1": "The value for 1. Specific to the bool type.",
                            "item": {
                                "type": "The type of the array elements. Specific to the array type."
                            }
                        }
                    }
                }
            ],
            "method": "The name of the method that corresponds to the event. It is generated based on the identifier."
        }
    ],
    "services": [
        {
            "identifier": "The unique identifier of the service. It must be unique within the TSL module. The 'set' and 'get' services are generated by default based on the accessMode of properties.",
            "name": "The service name.",
            "desc": "The service description.",
            "required": "Specifies whether the service is required for the standard function plan: true (yes) or false (no).",
            "callType": "async (asynchronous invocation) or sync (synchronous call).",
            "inputData": [
                {
                    "identifier": "The unique identifier of the input parameter.",
                    "name": "The name of the input parameter.",
                    "dataType": {
                        "type": "The property type. Valid values: int (native), float (native), double (native), text (native), date (String type in UTC milliseconds), bool (int type with a value of 0 or 1), enum (int type, with values defined similarly to the bool type), struct (a structure that can contain the other seven types, described in \"specs\"), and array (supports int, double, float, text, and struct).",
                        "specs": {
                            "min": "The minimum value of the parameter. Specific to int, float, and double types.",
                            "max": "The maximum value of the parameter. Specific to int, float, and double types.",
                            "unit": "The unit of the property. Specific to int, float, and double types. This parameter is optional.",
                            "unitName": "The name of the unit. Specific to int, float, and double types. This parameter is optional.",
                            "size": "The number of array elements. Maximum: 512. Specific to the array type.",
                            "step": "The step size. This parameter is not available for text and enum types.",
                            "length": "The data length. Maximum: 10240. Specific to the text type.",
                            "0": "The value for 0. Specific to the bool type.",
                            "1": "The value for 1. Specific to the bool type.",
                            "item": {
                                "type": "The type of the array elements. Specific to the array type."
                            }
                        }
                    }
                }
            ],
            "outputData": [
                {
                    "identifier": "The unique identifier of the response parameter.",
                    "name": "The name of the response parameter.",
                    "dataType": {
                        "type": "The property type. Valid values: int (native), float (native), double (native), text (native), date (String type in UTC milliseconds), bool (int type with a value of 0 or 1), enum (int type, with values defined similarly to the bool type), struct (a structure that can contain the other seven types, described in \"specs\"), and array (supports int, double, float, text, and struct).",
                        "specs": {
                            "min": "The minimum value of the parameter. Specific to int, float, and double types.",
                            "max": "The maximum value of the parameter. Specific to int, float, and double types.",
                            "unit": "The unit of the property. Specific to int, float, and double types. This parameter is optional.",
                            "unitName": "The name of the unit. Specific to int, float, and double types. This parameter is optional.",
                            "size": "The number of array elements. Maximum: 512. Specific to the array type.",
                            "step": "The step size. This parameter is not available for text and enum types.",
                            "length": "The data length. Maximum: 10240. Specific to the text type.",
                            "0": "The value for 0. Specific to the bool type.",
                            "1": "The value for 1. Specific to the bool type.",
                            "item": {
                                "type": "The type of the array elements. Specific to the array type."
                            }
                        }
                    }
                }
            ],
            "method": "The name of the method that corresponds to the service. It is generated based on the identifier."
        }
    ],
    // The following parameters are available only in the TSL of a custom module.
    "functionBlockId": "The unique identifier of the custom module. This is the module ID.",
    "functionBlockName": "The name of the custom module.",

    // If a custom module is added to a product, the TSL of the default module contains the following parameters, which represent the list of added custom modules.
    "functionBlocks": [
    {
      "functionBlockId": "The unique identifier of the custom module. This is the module ID.",
      "functionBlockName": "The name of the custom module.",
      "productKey": "The ProductKey of the product."
    }
  ]
}

If the Node Type of a product is Gateway Sub-device and the gateway access protocol is Modbus, OPC UA, or custom, you can view the extended configuration information of the TSL model.

The extended configuration for Modbus products is used with IoT Edge to manage Modbus sub-devices. For more information, see the IoT Edge documentation.

The data structure for the extended configuration of a Modbus product is as follows:

{
    "profile": {
        "productKey": "The ProductKey of the product."
    },
    "properties": [
        {
            "identifier": "The unique identifier of the property. It must be unique within the product.",
            "operateType": "The operation type. Valid values: coilStatus (Coil), inputStatus (Discrete Input), holdingRegister (Holding Register), and inputRegister (Input Register).",
            "registerAddress": "The register address.",
            "originalDataType": {
                "type": "The raw data type: int16, uint16, int32, uint32, int64, uint64, float, double, string, bool, or customized data (returns hex data in big-endian order).",
                "specs": {
                    "registerCount": "The number of data registers. Specific to string and customized data types.",
                    "swap16": "Swaps the high and low bytes within a register. This exchanges the first 8 bits and the last 8 bits of 16-bit data within the register (byte1byte2 -> byte2byte1). Specific to data types other than string and bool.",
                    "reverseRegister": "Reverses the register order. This exchanges the first 16 bits and the last 16 bits of 32-bit raw data (byte1byte2byte3byte4 -> byte3byte4byte1byte2). Specific to data types other than string and bool."
                }
            },
            "scaling": "The scaling factor. Specific to data types other than string and bool.",
            "trigger": "The data reporting method. 1: report on a schedule. 2: report on change.",
            "writeFunctionCode":"The read/write operation. The valid values depend on the operateType. For coilStatus, valid values are 5 (read 0x01, write 0x05), 15 (read 0x01, write 0x0F), 0 (read-only 0x01), 6 (write-only 0x05), and 15 (write-only 0x0F). For inputStatus, the valid value is 0 (read-only 0x02). For holdingRegister, valid values are 6 (read 0x03, write 0x06), 16 (read 0x03, write 0x10), 0 (read-only 0x03), 6 (write-only 0x06), and 16 (write-only 0x10). For inputRegister, the valid value is 0 (read-only 0x04).",
            "writeOnly":"Specifies whether the property is write-only. 0: not write-only. 1: write-only.",
            "pollingTime":"The polling interval in ms. You do not need to pass this parameter. The polling interval configured for the device is used.",
            "bitMask":"The bit mask. Specific to the bool type. Valid values: 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, and 32768, which correspond to 1<<(0~15)."
        }
    ]
}