Tutorial: Static Templating
This step-by-step interactive tutorial provides an introduction to templating in Intelligence Hub.
What Does This Tutorial Cover?
This tutorial will walk you through the basics of working with Templating. Templating is supported for Inputs, Instances, and Pipelines. Templating offers an efficient method for generating hundreds of configuration objects, with only minor variations between them. For example, if an OPC UA Server has 100 machines and the address of each machine only differs by a unique machineID, a single Input can represent all 100 machines. In this Tutorial, we'll start by templating an OPC UA Branch Connection Input. After that, using the same branch data, we'll create and template an Instance.
- Tutorial Prerequisites
- Tutorial Preparation
- Tutorial Instructions - Static Templating
- Tutorial Summary
Tutorial Prerequisites
- You have completed the initial installation of the Intelligence Hub.
- It is recommended to read the Getting Started Series before completing this tutorial exercise.
- It is recommended to complete "Tutorial: Connections" and "Tutorial: Models and Instances".
Tutorial Preparation
-
Enable Intelligence Hub MQTT broker.
- In the left-hand navigation panel, navigate to Manage, and click Settings
- Under the MQTT Broker section enable the broker, if ports 1885 and 1886 are being utilized on your Intelligence Hub server, update to ports of your choosing, otherwise accept the defaults and click the Save button.
- Import the required Components
- In the left-hand navigation panel, navigate to Manage, and click Project.
- Within the Import screen, ensure Full Project is off (otherwise your existing project will be overwritten).
- Copy the JSON provided here. Project JSON
- Change the Import Type to JSON and paste in the following with the Project box and click the Import button.
-
Update the imported Connections as required
- Navigate to Configure and click Connections, click "HB_Tutorial_MQTT" and update the MQTT settings as required based on the prior preparation step #1.
- Navigate to Configure and click Connections, Click "HB_Tutorial_SQL_Server" and type the following within the password field and click the Save button.
-
password
-
-
Setup UNS Client
- In the left-hand navigation panel, navigate to Tools and right click UNS Client and select Open Link in New Tab.
- Enter login information.
-
For Connection select "HB_Tutorial_MQTT".
-
For Subscribed Topics enter "Tutorial/#".
-
Click Add.
-
Click the "x" to remove topic "#".
-
Click the Connect button.
-
Confirm the UNS Client says "Connected to HB_Tutorial_MQTT".
-
Return to the previous web browser tab.
Tutorial Instructions
-
Login to your Intelligence Hub environment
-
Review source data
-
Navigate to Connections.
-
Select "HB_Tutorial_OPC_UA".
-
Navigate to the Inputs tab.
-
Select "Tutorial_CNC_Fanuc_Branch_Templated".
- NOTE: This is a Branch OPC UA input, with the Branch Type we specify a Max Branch Depth to read under the base Identifier.
-
Click the Test Input button and review the data.
-
-
Update the "Tutorial_CNC_Fanuc_Branch_Templated" Connection Input to a Templated object using Static Parameters. This will take the configuration component from one asset input, to many asset inputs.
-
Within the "Tutorial_CNC_Fanuc_Branch_Templated" Input, select Template Type Static in the drop down box at the bottom of the page.
-
Ensure the Template Type is set to Static. We will review Dynamic Templates in another tutorial.
-
Click the Add Value button.
-
Enter [InputAssetID] as the Name value. Do not include the brackets.
-
Enter [1001-1003] as the pattern, note another valid pattern would be [1001,1002,1003]. Do not include the brackets.
-
To utilize the InputAssetID parameter, we will use the syntax of [{{this.InputAssetID}}], enter this as the "Template Name" value. Do not include the brackets.
-
We will now utilize this parameter within Identifier field, replace 1001 with {{this.InputAssetID}}. Note: Keep the leading underscore.
-
Click the Save Button and then the Test Input button to review the results.
-
-
Review the Output target
- Navigate to Connections.
- Select "HB_Tutorial_MQTT".
- Navigate to the Outputs tab.
- Select "HB_Tutorial_MQTT_Output_CNC_Templated_Branch".
- Take note of the topic "Tutorial/Templating/TemplatedConnection/{{this.AssetID}}" - we need to ensure we have a dynamic reference ({{this.AssetID}} to iterate through the templated source.
- Create a Pipeline to publish the Templated Branch Connection Input via MQTT.
- Navigate to Pipelines
- Click New Pipeline.
- Enter “HB_Tutorial_OPC_UA_Templated_Input_To_MQTT” for the Name.
- Select the Build Flow option to create a Pipeline with Sources, Targets, and a Trigger.
- Click the Next button.
- Within the Sources & Target view, use the References Panel and set Type to Input.
- Select Connection "HB_Tutorial_OPC_UA".
- Drag “Tutorial_CNC_Fanuc_Branch_Templated” into the Sources box.
- Change Type to Output.
- Set Connections to "HB_Tutorial_MQTT".
- Drag "HB_Tutorial_MQTT_Output_CNC_Templated_Branch" to the Targets box.
- Click the Next button.
- Change the interval to 10 seconds.
- Click the Create button.
- Click on the Pipeline "Flow" stage and Enable the Pipeline.
- Review the results in the UNS client.
-
Build a new Instance from an existing Model
-
Navigate to Models.
-
Select "HB_Tutorial_Models_CNC_Asset_Info".
-
Click the Create Instance button.
-
Within the New Instance Details view, enter "HB_Tutorial_Models_CNC_Asset_Info_Instance_Templated" as the Name.
-
Click the Next button.
- Within the New Instance view, set the Reference Panel to Type Input.
- In the References Panel, set Connection to "HB_Tutorial_OPC_UA".
-
In the References Panel, expand "Tutorial".
-
In the References Panel, expand "CNC_Fanuc_1001" and map the following attributes to the corresponding expressions:
- AssetID
- Temperature
- CuttingSpeed
- PowerCurrent
- FeedRate
-
For attribute Temperature_UOM, enter "F" as the Default Value.
-
Leave the Instance values LastServiceDate and LasteServiceNotes blank as they will not be utilized for this exercise for the sake of simplicity.
-
Click the Create button.
-
Click the Test Instance button and review the results.
-
-
Template the Instance
-
Within "HB_Tutorial_Models_CNC_Asset_Info_Instance_Templated", select Static from the Template Type drop down list.
-
Click the Add Value button.
-
Enter [InstanceAssetID] as the Name. Do not include the brackets.
-
Enter [1001-1003] as the pattern. Do not include the brackets. Note: another valid pattern would be [1001,1002,1003].
-
To utilize the InstanceAssetID parameter, we will use the syntax of {{this.InstanceAssetID}}, enter this as the Template Name value.
-
Starting with the AssetID attribute expression, replace 1001 with {{this.InstanceAssetID}}.
- Repeat for the remaining attribute expressions
- Click the Save button.
-
Click the Test Instance button to review the results.
-
-
Review the Output target
-
Navigate to Connections
-
Select "HB_Tutorial_MQTT".
-
Navigate to Outputs
-
Select "HB_Tutorial_MQTT_Output_CNC_Templated_Instance".
- Take note of the topic "Tutorial/Templating/TemplatedInstance/{{this.AssetID}}" - we need to ensure we have a dynamic reference ({{this.AssetID}} to iterate through the templated source
-
- Output the templated Instance to the
-
Navigate to Pipelines
-
Click the New Pipeline button.
- Enter “HB_Tutorial_CNC_Templated_Instance_To_MQTT” for the Name.
- Select the Build Flow option to create a Pipeline with Sources, Targets, and a Trigger.
- Click the Next button.
- Within the Sources & Target view, use the References Panel and set Type to Instance.
- Drag “HB_Tutorial_Models_CNC_Asset_Info_Instance_Templated” into the Sources box.
- Change Type to Output.
- Set Connections to "HB_Tutorial_MQTT".
- Drag "HB_Tutorial_MQTT_Output_CNC_Templated_Instance" to the Targets box.
- Click the Next button.
- Change the interval to 10 seconds.
- Click the Create button.
- Click on the Pipeline "Flow" stage and Enable the Pipeline.
- Review the results in the UNS client.
-
Take note that the template source payload was broken up into individual topics based on the {{this.AssetID}} syntax within our output. We are seeing Dynamic Referencing in action here; we can manage one output, allow the system to dynamically reference each individual AssetID and build the organized output for us.
Tutorial Summary
This tutorial covered how to utilize templating within Intelligence Hub components to assist in scaling successful use cases from one configuration object to many. Templating can happen within Inputs, Instances and Flows. We covered how to connect multiple templated objects together to ensure consistency with our use cases.