Working with Templates
    • 19 Nov 2021
    • 1 Minute to read
    • PDF

    Working with Templates

    • PDF

    Article summary

    Templates can be created and used at different levels of configuration:

    •  Tag level: Tag templates and device templates containing tags.
    • Communications level: Templates for communication clients (Modbus, OPC, Siemens, etc.) including preliminary configuration of the connection.

    The Model tree for each section can be used to instantiate templates and provide the values for Custom Properties, assigning different values for each instance.

    This User Guide assumes a basic understanding of Object-Oriented paradigm. 

    Custom Properties

    In order to use the templates, it is possible to create Custom Properties within each template to be used as parameters. Custom properties are what differentiate instances derived from the same template. These Custom Properties can then be referenced in the Expressions to calculate specific values for each instance. Custom properties are referenced in the Expressions using the name of the Custom Property in curly braces { }.

    Expressions

    JavaScript expressions can be used on each data entry to calculate the value. All expressions start with “=” (like in spreadsheets). Expressions are only evaluated during the start-up of the module.

    Examples of expressions assuming the following Custom Properties:

    Custom Property Name
    Type
    Value
    Boolean01
    Boolean
    True
    Boolean02
    Boolean
    False
    Number01
    Number
    5
    Number02
    Number
    25
    Text01
    Text
    Hello
    Text02
    Text
    World!


    Action
    Expression
    Result
    Concatenation
    ={Text01}+" "+{Text02}
    Hello World!
    Sum
    ={Number01}+{Number02}
    30
    Conditional
    ={Boolean01}==1?{Number01}:{Number02}
    5
    Conditional
    =['A','B','C','D','E'][{Number01}-2]
    D
    String methods
    ={Text02}.substr(0,1)+{Text01}.slice(1,4)
    Well

    Was this article helpful?

    What's Next