This topic describes the parameters in the JSON file where a Thing Specification Language (TSL) model is defined.

Note To demonstrate the full structure of the TSL model, the following example includes all parameters. However, the parameters may vary based on the actual scenario. The string that follows each parameter is the description of the parameter. For the scenarios where each parameter is used, see the parameter description.
{
    "schema": "The URL of the TSL model.",
    "profile": {
        "productKey": "The ProductKey of the product."
    },
    "properties": [
        {
            "identifier": "The ID of the property. The ID must be unique in a TSL module.",
            "name": "The property name.",
            "accessMode": "The level of access to the property. Valid values: r (read-only) and rw (read and write).",
            "required": "Specifies whether the property is required. Valid values: true (required) and false (optional).",
            "dataType": {
                "type": "The data type of the property. Valid values: int, float, double, text, date (UTC timestamp in the string format, in milliseconds), bool (0 or 1), enum (integers that are defined in the same manner as data of the bool data type), struct (a struct that can include the preceding seven data types, where "specs": [{}] is used to describe the included objects), and array (an array that can include the int, double, float, text, and struct data types).",
                "specs": {
                    "min": "The minimum value. This parameter is available only for properties of the int, float, and double data types.",
                    "max": "The maximum value. This parameter is available only for properties of the int, float, and double data types.",
                    "unit": "Optional. The unit of the property. This parameter is available only for properties of the int, float, and double data types.",
                    "unitName": "Optional. The name of the unit. This parameter is available only for properties of the int, float, and double data types.",
                    "size": "The number of elements in the array. Maximum value: 512. This parameter is available only for properties of the array data type.",
                    "step": "The step size. This parameter is not available for properties of the text and enum data types.",
                    "length": "The length of the data. Maximum value: 10240. This parameter is available only for properties of the text data type.",
                    "0": "The value of 0. This parameter is available only for properties of the bool data type.",
                    "1": "The value of 1. This parameter is available only for properties of the bool data type.",
                    "item": {
                        "type": "The type of the array element. This parameter is available only for properties of the array data type."
                    }
                }
            }
        }
    ],
    "events": [
        {
            "identifier": "The ID of each event. The ID must be unique in a TSL module. The post event is predefined and used to report properties.",
            "name": "The name of the event.",
            "desc": "The description of the event.",
            "type": "The type of the event. Valid values: info, alert, and error.",
            "required": "Specifies whether the event is required. Valid values: true (required) and false (optional).",
            "outputData": [
                {
                    "identifier": "The unique ID of the parameter.",
                    "name": "The name of the parameter",
                    "dataType": {
                        "type": "The data type of the parameter. Valid values: int, float, double, text, date (UTC timestamp in the string format, in milliseconds), bool (0 or 1), enum (integers that are defined in the same manner as data of the bool data type), struct (a struct that can include the preceding seven data types, where "specs": [{}] is used to describe the included objects), and array (an array that can include the int, double, float, text, and struct data types).",
                        "specs": {
                            "min": "The minimum value. This parameter is available only for event parameters of the int, float, and double data types.",
                            "max": "The maximum value. This parameter is available only for event parameters of the int, float, and double types.",
                            "unit": "Optional. The unit of the parameter. This parameter is available only for event parameters of the int, float, and double data types.",
                            "unitName": "Optional. The name of the unit. This parameter is available only for event parameters of the int, float, and double data types.",
                            "size": "The number of elements in the array. Maximum value: 512. This parameter is available only for event parameters of the array data type.",
                            "step": "The step size. This parameter is not available for properties of the text and enum data types.",
                            "length": "The length of the data. Maximum value: 10240. This parameter is available only for event parameters of the text data type.",
                            "0": "The value of 0. This parameter is available only for event parameters of the bool data type.",
                            "1": "The value of 1. This parameter is available only for event parameters of the bool data type.",
                            "item": {
                                "type": "The type of the array element. This parameter is available only for event parameters of the array data type."
                            }
                        }
                    }
                }
            ],
            "method": "The name of a method that can access the event. The name is generated based on the value of the identifier parameter."
        }
    ],
    "services": [
        {
            "identifier": "The ID of the service. The ID must be unique in a TSL module. The set and get services are pre-defined based on the value of the accessMode parameter that is specified in the properties.",
            "name": "The name of the service.",
            "desc": "The description of the service.",
            "required": "Specifies whether the service is required. Valid values: true (required) and false (optional).",
            "callType": "The call type. Valid values: async (asynchronous call) and sync (synchronous call).",
            "inputData": [
                {
                    "identifier": "The unique ID of the input parameter.",
                    "name": "The name of the input parameter.",
                    "dataType": {
                        "type": "The data type of the input parameter. Valid values: int, float, double, text, date (UTC timestamp in the string format, in milliseconds), bool (0 or 1), enum (integers that are defined in the same manner as data of the bool data type), struct (a struct that can include the preceding seven data types, where "specs": [{}] is used to describe the included objects), and array (an array that can include the int, double, float, text, and struct data types).",
                        "specs": {
                            "min": "The minimum value. This parameter is available only for input parameters of the int, float, and double data types.",
                            "max": "The maximum value. This parameter is available only for input parameters of the int, float, and double data types.",
                            "unit": "Optional. The unit of the property. This parameter is available only for input parameters of the int, float, and double data types.",
                            "unitName": "Optional. The name of the unit. This parameter is available only for input parameters of the int, float, and double data types.",
                            "size": "The number of elements in the array. Maximum value: 512. This parameter is available only for input parameters of the array data type.",
                            "step": "The step size. This parameter is not available for input parameters of the text and enum data types.",
                            "length": "The length of the data. Maximum value: 10240. This parameter is available only for input parameters of the text data type.",
                            "0": "The value of 0. This parameter is available only for input parameters of the bool data type.",
                            "1": "The value of 1. This parameter is available only for input parameters of the bool data type.",
                            "item": {
                                "type": "The type of the array element. This parameter is available only for input parameters of the array data type."
                            }
                        }
                    }
                }
            ],
            "outputData": [
                {
                    "identifier": "The ID of the output parameter.",
                    "name": "The name of the output parameter.",
                    "dataType": {
                        "type": "The data type of the output parameter. Valid values: int, float, double, text, date (UTC timestamp in the string format, in milliseconds), bool (0 or 1), enum (integers that are defined in the same manner as data of the bool data type), struct (a struct that can include the preceding seven data types, where "specs": [{}] is used to describe the included objects), and array (an array that can include the int, double, float, text, and struct data types).",
                        "specs": {
                            "min": "The minimum value. This parameter is available only for output parameters of the int, float, and double data types.",
                            "max": "The maximum value. This parameter is available only for output parameters of the int, float, and double data types.",
                            "unit": "Optional. The unit of the property. This parameter is available only for output parameters of the int, float, and double data types.",
                            "unitName": "Optional. The name of the unit. This parameter is available only for output parameters of the int, float, and double data types.",
                            "size": "The number of elements in the array. Maximum value: 512. This parameter is available only for output parameters of the array data type.",
                            "step": "The step size. This parameter is not available for output parameters of the text and enum data types.",
                            "length": "The length of the data. Maximum value: 10240. This parameter is available only for output parameters of the text data type.",
                            "0": "The value of 0. This parameter is available only for output parameters of the bool data type.",
                            "1": "The value of 1. This parameter is available only for output parameters of the bool data type.",
                            "item": {
                                "type": "The type of the array element. This parameter is available only for output parameters of the array data type."
                            }
                        }
                    }
                }
            ],
            "method": "The name of a method that can access the service. The name is generated based on the value of the identifier parameter."
        }
    ],
    // A TSL model in a custom module has the following parameters: 
    "functionBlockId": "The unique ID of the custom module.",
    "functionBlockName": "The name of the custom module.",

    // If you create a custom module for the product, the TSL model in the default module has the following parameters. The parameters specify the details of the custom module. 
    "functionBlocks": [
    {
      "functionBlockId": "The unique ID of the custom module.",
      "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 connection protocol is Modbus, OPC UA, or custom, you can view the extended information about the TSL model.

For example, the node type of a product is gateway sub-device and the gateway connection protocol is Modbus. The extended information about the TSL model can be used in Link IoT Edge for sub-devices. For more information, see Modbus drivers.

Example of a Modbus product:

{
    "profile": {
        "productKey": "The ProductKey of the product."
    },
    "properties": [
        {
            "identifier": "The ID of the property. The ID must be unique in a TSL module.",
            "operateType": "The operation type. Valid values: coilStatus, inputStatus, holdingRegister, and inputRegister.",
            "registerAddress": "The register address.",
            "originalDataType": {
                "type": "The type of the original data. Valid values: int16, uint16, int32, uint32, int64, uint64, float, double, string, bool, and customized (hex values in big-endian format).",
                "specs": {
                    "registerCount": "The number of registers. This parameter is available only for properties of the string and customized data types.",
                    "swap16": "Specifies whether to switch the high byte and low byte in the register. If so, the first and last 8 bits of the 16-bit integer in the register are swapped, such as from byte1byte2 to byte2byte1. This parameter is not available for properties of string and bool data types.",
                    "reverseRegister": "Specifies whether to switch the high byte and low byte in the register. If so, the first and last 16 bits of the 32-bit integer in the register are swapped, such as from byte1byte2byte3byte4 to byte3byte4byte1byte2. This parameter is not available for properties of string and bool data types."
                }
            },
            "scaling": "The zoom factor. This parameter is not available for properties of string and bool data types.",
            "trigger": "The data reporting method. Valid values: 1 and 2. The value 1 indicates that data is submitted at a specific time. The value 2 indicates that data changes are submitted.",
            "writeFunctionCode": "The read/write operation. The valid values of this parameter vary based on the value of the operateType parameter. If the operateType parameter is set to coilStatus, the valid values are: 5 (read/write: read 0x01 and write 0x05), 15 (read/write: read 0x01 and write 0x0F), 0 (read-only 0x01), 6 (write-only 0x05), and 15 (write-only 0x0F). If the operateType parameter is set to inputStatus, the valid value is 0 (read-only 0x02). If the operateType parameter is set to holdingRegister, the valid values are: 6 (read/write: read 0x03 and write 0x06), 16 (read/write: read 0x03 and write 0x10), 0 (read-only 0x03), 6 (write-only 0x06), and 16 (write-only 0x10). If the operateType parameter is set to inputRegister, the valid value is 0 (read-only 0x04).",
            "writeOnly": "Specifies whether the permission is write-only. Valid values: 0 and 1. The value 0 indicates that the permission is not write-only. The value 1 indicates that the permission is write-only.",
            "pollingTime": "The collection interval. Unit: milliseconds. You do not need to configure this parameter. The collection intervals of devices are used.",
            "bitMask": "The mask. This parameter is available only for properties of the bool data type. Valid values: 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, and 32768."
        }
    ]
}