Skip to content

Custom Templates#

customtemplatessvg

The task Custom Templates is used to add properties, events and commands to a Driver Definition through JSON content.

customtemplates_01

Inputs#

There are no inputs.

Outputs#

There are no outputs.

Settings#

On the General Tab, you have only the usual settings:

customtemplates_02

On the Templates Tab you have the following settings:

Name Data Type Default Value Description
Name String Template Name.
Description String The description of template value.
Template any Value for the template (JSON)

customtemplates_03

Behavior#

The task is used to add properties, events and commands to a Driver Definition through JSON content. In order to do this, you can add a template on Templates Tab and at Template section, you have the possibility to write/paste a json that defines your properties, events and/or commands. There is a layer responsible for storing that information, associating it with the Driver Definition that is currently being used. The information is stored in a sequencial way, i.e. if user adds, for example, two events and the second one has the same name as the first, the last event added is the one that will be stored. When you add just an event to the task, if the layer already has stored an event with the name defined, that event will be replaced too.

This task removes the need to add properties, events and commands manually at the Driver Definition page.

Remarks#

This task should receive a specific structure of data at Template section. That structure is represented at the Example topic.

Example#

Structure to add properties:

{
    "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"
            },
            "Parameters": [
                {
                    "Name": "path",
                    "Description": "Path of the file",
                    "Order": 1,
                    "DataType": "String",
                    "AutomationProtocolDataType": "String",
                    "DefaultValue": "",
                    "IsMandatory": true,
                    "ExtendedData": {}
                }
            ]
        }
    ]
}