Analytics Builder 10.13.0 | Using Analytics Builder for Cumulocity IoT | Using the Model Editor | Working with blocks and wires | Managing template parameters
 
Managing template parameters
A model may specify zero or more template parameters, which can be used in place of defined values for block parameters. For example, instead of defining 100 as the threshold value for a Threshold block in the block parameter editor, you can assign a template parameter.
If a model has any template parameters, then multiple instances of the model can be created, and different values can be specified for the template parameters. See also Models which explains the difference between models without template parameters and models with template parameters, and the different roles: model author and instance maintainer.
If you want to use template parameters, you must first define them in the Template Parameters dialog box as described below. After you defined a template parameter, you can assign it to specific parameters of the same type in the block parameter editor (see also Editing the parameters of a block).
Note:
It is also possible to define template parameters directly in the block parameter editor.
Models with no template parameters can be directly activated in the model manager, with a single instance of the model running. This is different when you save the model after you have assigned at least one template parameter to one or more block parameters, you can no longer activate the model directly in the model manager. Instead, you must create at least one instance of the model, and you then activate that instance using the instance editor. See Using the Instance Editor for detailed information.
*To define the template parameters for the instances of the current model
1. In the toolbar of the model editor, click Template parameters icon to invoke the Template Parameters dialog box.
When at least one template parameter has been defined, a checkmark is shown on the above toolbar icon: Template parameters icon with a checkmark.
This dialog box is initially empty and you have to create the template parameters that you want to use in your model. When template parameters have already been defined, they are all shown in this dialog box.
If you have a long list of template parameters, you can easily locate the template parameter that you are looking for by entering its name or part of the name in the search box. When search criteria are currently applied, an X is shown in the search box; click this to clear the search and thus to show all available template parameters.
After a template parameter has been assigned to one or more block parameters, the Usage Count column indicates the number of places in which the template parameter is used. For example, when a template parameter is used in two places, this means that it has been assigned to two block parameters. These can be within the same block or in different blocks.
2. To create a template parameter, click Create new template parameter.
This adds an empty row at the bottom of the dialog box. You can click Create new template parameter several times to add several empty rows that you can fill one after the other.
3. Specify the following information for each template parameter:
*Name. Type a unique name to identify the template parameter within the current model. This name can later be selected in the block parameter editor.
*Type. Select the value type of the template parameter from the drop-down list box. The type can be, for example, a string or float, the name of a device or device group, or the parameter of a specific block.
An input block specifies a device or a device group, while an output block specifies a device or a trigger device. For template parameters, the same template parameter and thus value can be used for both input and output blocks. If a template parameter is set to refer to a device group, then using it in an output block will be treated as the trigger device. Typically, a single template parameter would be used for all input and output blocks, and may be a single device or a device group, in which case the block output goes to the device within the group that triggered a model evaluation (so a model calculating an average of a measurement and outputting to a measurement would generate a new measurement for each device independently). Even if a different template parameter whose value refers to a different group was used, the model output would only be sent to the device that triggered a model's evaluation.
*Optional. An optional value can remain blank or can be set later by the instance maintainer. When you select this check box, it is not possible to specify a default value.
*Default Value. You can only specify a default value when the Optional check box is not selected.
Exception: Boolean types always have a value and cannot be optional. They are false by default (that is, the check box for the default value is not selected).
If you specify a default value, this default value will be provided in the instance editor when the instance maintainer creates a new instance. The instance maintainer can then either leave this default value unmodified or change it as required for that instance.
When setting the default value for a device, an additional dialog box appears when you click the Default Value field. The dialog box is the same as when selecting a different device, device group or asset in the block parameter editor (see Editing the parameters of a block for more information on this dialog box). Click the Use button (this is shown when you move the mouse over an entry) to select the device that you want to use.
Note:
If there is a block parameter for which a required value has not been specified, then the instance cannot be activated. Attempting to do so will report an error.
4. You can update a template parameter at any time. This includes the name, whether it is optional or not, and the default value. All blocks in which the updated template parameter is defined are automatically adapted to use the new values. The only exception is the type. You can only change the type if the template parameter is not used in any block of the model.
5. When the model is inactive, you can reorder the template parameters. This affects the sequence in which they are shown in the instance editor. Drag a row to a different position using the Drag icon control that is shown next to that row. See also Filtering and sorting the instances.
6. You can only remove a template parameter if it is not used in any block of the model. To remove a template parameter, click the actions menu (the three vertical dots at the end of a row) and then click Remove.
7. Click OK to store the changes in memory and to close the dialog.
Note:
Keep in mind that your changes are only written to the inventory when you save the model. See also Saving a model.