跳转至

自定义模板#

customtemplatessvg

“自定义模板”任务用于通过 JSON 内容向驱动程序定义添加属性、事件和命令。

customtemplates_01

输入#

没有输入。

输出#

没有输出。

设置#

在常规选项卡上,您只有常用设置:

customtemplates_02

模板选项卡上,您有以下设置:

名称 数据类型 默认值 描述
名称 String 模板名称
描述 String 模板值的描述
模板 any 模板值 (JSON)

customtemplates_03

行为#

该任务用于通过 JSON 内容向驱动程序定义添加属性、事件和命令。 为此,您可以在“模板”选项卡和“模板”部分添加模板,您可以编写/粘贴定义属性、事件和/或命令的 json。 有一个层负责存储该信息,并将其与当前正在使用的驱动程序定义相关联。 信息以顺序方式存储,即,例如,如果用户添加两个事件,并且第二个事件与第一个事件具有相同的名称,则最后添加的事件就是将被存储的事件。 当您仅向任务添加事件时,如果图层已存储具有定义名称的事件,则该事件也将被替换。

此任务无需在驱动程序定义页面手动添加属性、事件和命令。

评论#

此任务应在“模板”部分接收特定的数据结构。 该结构在示例主题中有所体现。

例子#

添加属性的结构:

{
    "property": [
        {
            "Name": "FileName",
            "Description": "Name of the file identified in the watched directory",
            "DevicePropertyId": "FileName",
            "DataType": "String",
            "IsWritable": false,
            "IsReadable": true,
            "AutomationProtocolDataType": "String",
            "ExtendedData": {
                "propertyType": "FileName",
                "identifierType": "None"
            }
        },
        {
            "Name": "FullPath",
            "Description": "Full path of the file found in the directory",
            "DevicePropertyId": "FullPath",
            "DataType": "String",
            "IsWritable": false,
            "IsReadable": true,
            "AutomationProtocolDataType": "String",
            "ExtendedData": {
                "propertyType": "FullPath",
                "identifierType": "None"
            }
        },
        {
            "Name": "FileSize",
            "Description": "Size of the file",
            "DevicePropertyId": "FileSize",
            "DataType": "Integer",
            "IsWritable": false,
            "IsReadable": true,
            "AutomationProtocolDataType": "Integer",
            "ExtendedData": {
                "propertyType": "Size",
                "identifierType": "None"
            }
        },
        {
            "Name": "EndOfFile",
            "Description": "End of file reached",
            "DevicePropertyId": "EndOfFile",
            "DataType": "Boolean",
            "IsWritable": false,
            "IsReadable": true,
            "AutomationProtocolDataType": "Boolean",
            "ExtendedData": {
                "propertyType": "EndOfFile",
                "identifierType": "None"
            }
        }
    ]
}

Structure to add an event (properties are needed too):

{
    "property": [
        {
            "Name": "FileName",
            "Description": "Name of the file identified in the watched directory",
            "DevicePropertyId": "FileName",
            "DataType": "String",
            "IsWritable": false,
            "IsReadable": true,
            "AutomationProtocolDataType": "String",
            "ExtendedData": {
                "propertyType": "FileName",
                "identifierType": "None"
            }
        },
        {
            "Name": "FullPath",
            "Description": "Full path of the file found in the directory",
            "DevicePropertyId": "FullPath",
            "DataType": "String",
            "IsWritable": false,
            "IsReadable": true,
            "AutomationProtocolDataType": "String",
            "ExtendedData": {
                "propertyType": "FullPath",
                "identifierType": "None"
            }
        },
        {
            "Name": "FileSize",
            "Description": "Size of the file",
            "DevicePropertyId": "FileSize",
            "DataType": "Integer",
            "IsWritable": false,
            "IsReadable": true,
            "AutomationProtocolDataType": "Integer",
            "ExtendedData": {
                "propertyType": "Size",
                "identifierType": "None"
            }
        },
        {
            "Name": "EndOfFile",
            "Description": "End of file reached",
            "DevicePropertyId": "EndOfFile",
            "DataType": "Boolean",
            "IsWritable": false,
            "IsReadable": true,
            "AutomationProtocolDataType": "Boolean",
            "ExtendedData": {
                "propertyType": "EndOfFile",
                "identifierType": "None"
            }
        }
    ],
    "event": [
        {
            "Name": "OnNewFile",
            "Description": "Triggered when the watcher detects a file that was not previously identified appears",
            "DeviceEventId": "NewFile",
            "IsEnabled": true,
            "ExtendedData": {
                "eventTrigger": "NewFile"
            },
            "EventProperties": [
                {
                    "Property": "FileName",
                    "Order": 1,
                    "ExtendedData": {}
                },
                {
                    "Property": "FullPath",
                    "Order": 2,
                    "ExtendedData": {}
                },
                {
                    "Property": "FileSize",
                    "Order": 3,
                    "ExtendedData": {}
                }
            ]
        }
    ]
}

Structure to add a command:

{
    "command": [
        {
            "Name": "MoreDataRequest",
            "Description": "After Data is processed, request for the next chunk.",
            "DeviceCommandId": "MoreDataRequest",
            "ExtendedData": {
                "commandType": "MoreDataRequest"
            },
            "Parameters": [
                {
                    "Name": "path",
                    "Description": "Path of the file",
                    "Order": 1,
                    "DataType": "String",
                    "AutomationProtocolDataType": "String",
                    "DefaultValue": "",
                    "IsMandatory": true,
                    "ExtendedData": {}
                }
            ]
        }
    ]
}

Structure to add properties, events and commands:

{
    "property": [
        {
            "Name": "FileName",
            "Description": "Name of the file identified in the watched directory",
            "DevicePropertyId": "FileName",
            "DataType": "String",
            "IsWritable": false,
            "IsReadable": true,
            "AutomationProtocolDataType": "String",
            "ExtendedData": {
                "propertyType": "FileName",
                "identifierType": "None"
            }
        },
        {
            "Name": "FullPath",
            "Description": "Full path of the file found in the directory",
            "DevicePropertyId": "FullPath",
            "DataType": "String",
            "IsWritable": false,
            "IsReadable": true,
            "AutomationProtocolDataType": "String",
            "ExtendedData": {
                "propertyType": "FullPath",
                "identifierType": "None"
            }
        },
        {
            "Name": "FileSize",
            "Description": "Size of the file",
            "DevicePropertyId": "FileSize",
            "DataType": "Integer",
            "IsWritable": false,
            "IsReadable": true,
            "AutomationProtocolDataType": "Integer",
            "ExtendedData": {
                "propertyType": "Size",
                "identifierType": "None"
            }
        },
        {
            "Name": "EndOfFile",
            "Description": "End of file reached",
            "DevicePropertyId": "EndOfFile",
            "DataType": "Boolean",
            "IsWritable": false,
            "IsReadable": true,
            "AutomationProtocolDataType": "Boolean",
            "ExtendedData": {
                "propertyType": "EndOfFile",
                "identifierType": "None"
            }
        }
    ],
    "event": [
        {
            "Name": "OnNewFile",
            "Description": "Triggered when the watcher detects a file that was not previously identified appears",
            "DeviceEventId": "NewFile",
            "IsEnabled": true,
            "ExtendedData": {
                "eventTrigger": "NewFile"
            },
            "EventProperties": [
                {
                    "Property": "FileName",
                    "Order": 1,
                    "ExtendedData": {}
                },
                {
                    "Property": "FullPath",
                    "Order": 2,
                    "ExtendedData": {}
                },
                {
                    "Property": "FileSize",
                    "Order": 3,
                    "ExtendedData": {}
                }
            ]
        },
        {
            "Name": "OnFileChanged",
            "Description": "Triggered when the watcher detects a file that was already identified (and triggered the OnNewFile event), and it was changed in some way",
            "DeviceEventId": "ChangedFile",
            "IsEnabled": true,
            "ExtendedData": {
                "eventTrigger": "ChangedFile"
            },
            "EventProperties": [
                {
                    "Property": "FileName",
                    "Order": 1,
                    "ExtendedData": {}
                },
                {
                    "Property": "FullPath",
                    "Order": 2,
                    "ExtendedData": {}
                },
                {
                    "Property": "FileSize",
                    "Order": 3,
                    "ExtendedData": {}
                }
            ]
        }
    ],
    "command": [
        {
            "Name": "MoreDataRequest",
            "Description": "After Data is processed, request for the next chunk.",
            "DeviceCommandId": "MoreDataRequest",
            "ExtendedData": {
                "commandType": "MoreDataRequest"
            },
            "Parameters": [
                {
                    "Name": "path",
                    "Description": "Path of the file",
                    "Order": 1,
                    "DataType": "String",
                    "AutomationProtocolDataType": "String",
                    "DefaultValue": "",
                    "IsMandatory": true,
                    "ExtendedData": {}
                }
            ]
        },
        {
            "Name": "FileOrDirectoryExists",
            "Description": "Checks if the path location exists.",
            "DeviceCommandId": "Exists",
            "ExtendedData": {
                "commandType": "Exists"
            },
            "CommandParameters": [
                {
                    "Name": "path",
                    "Description": "Path of the file",
                    "Order": 1,
                    "DataType": "String",
                    "AutomationProtocolDataType": "String",
                    "DefaultValue": "",
                    "IsMandatory": true,
                    "ExtendedData": {}
                }
            ]
        }
    ]
}