Tutorial: Static Templating

What Does This Tutorial Cover?

This tutorial will walk you through the basics of working with Templating. Templating is supported for Inputs, Instances, and Flows. 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. 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

  1. You have completed the initial Installation of the Intelligence Hub
  2. You have applied your Intelligence Hub license to your environment
  3. It is recommended to read the Getting Started Series before completing this tutorial exercise
  4. It is recommended to complete “Tutorial: Connections” and “Tutorial: Models and Instances”

Tutorial Preparation

  1. 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 save
  2. 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
    • Change the Import Type to JSON and paste in the following with the Project box
{
	"productInfo": {
		"company": "HighByte",
		"product": "IntelligenceHub",
		"version": "3.2.0",
		"build": "2023.8.24.982",
		"stage": "Alpha"
	},
	"project": {
		"version": 5,
		"connections": [
			{
				"name": "Tutorial_CMMS_servicelogs",
				"uri": "jdbc.sqlserver://52.10.6.4:1433",
				"tags": [
					"Share",
					"Share2"
				],
				"writes": {
					"flattenModeledValues": false
				},
				"storeForward": {
					"enabled": false,
					"maxEntries": 100,
					"waitOnFailureInterval": {
						"duration": 1,
						"units": "Seconds"
					}
				},
				"settings": {
					"database": "serviceinfo",
					"username": "highbyte"
				}
			},
			{
				"name": "Tutorial_MQTT",
				"uri": "mqtt://0.0.0.0:1885",
				"tags": [
					"Share",
					"Share2"
				],
				"writes": {
					"flattenModeledValues": false
				},
				"storeForward": {
					"enabled": false,
					"maxEntries": 100,
					"waitOnFailureInterval": {
						"duration": 1,
						"units": "Seconds"
					}
				},
				"settings": {
					"connectionTimeoutSeconds": 10,
					"keepAliveSeconds": 60,
					"requestTimeoutMS": 5000,
					"cleanSession": true,
					"ssl": false,
					"redundantBrokers": [],
					"inputDiscovery": ""
				}
			},
			{
				"name": "Tutorial_OPC_UA",
				"uri": "opc.tcp://52.10.6.4:49320",
				"tags": [
					"Share",
					"Share2"
				],
				"writes": {
					"flattenModeledValues": false
				},
				"subscriptions": {
					"subscriptionRate": {
						"duration": 1,
						"units": "Seconds"
					}
				},
				"storeForward": {
					"enabled": false,
					"maxEntries": 100,
					"waitOnFailureInterval": {
						"duration": 1,
						"units": "Seconds"
					}
				},
				"settings": {
					"security": "None",
					"authentication": {
						"type": "Anonymous"
					},
					"connectTimeoutSeconds": 5,
					"requestTimeoutMS": 5000,
					"maxItemsPerRead": 512,
					"maxItemsPerWrite": 256,
					"certificateKeyPair": "app-certificate-private-key",
					"sessionName": ""
				}
			}
		],
		"inputs": [
			{
				"name": "Tutorial_All_Assets",
				"connection": "Tutorial_CMMS_servicelogs",
				"type": "jdbc.sqlserver",
				"qualifier": {
					"query": "select * from [dbo].[cmms_servicelogs]"
				},
				"cacheLifetime": {
					"enabled": false
				}
			},
			{
				"name": "Tutorial_All_Assets_CNC",
				"connection": "Tutorial_CMMS_servicelogs",
				"type": "jdbc.sqlserver",
				"qualifier": {
					"query": "select * from [dbo].[cmms_servicelogs] where [dbo].[cmms_servicelogs].[asset_type] = 'CNC'"
				},
				"cacheLifetime": {
					"enabled": false
				}
			},
			{
				"name": "Tutorial_CNC_AssetIDs",
				"connection": "Tutorial_CMMS_servicelogs",
				"type": "jdbc.sqlserver",
				"qualifier": {
					"query": "select  [dbo].[cmms_servicelogs].[asset_id] from [dbo].[cmms_servicelogs] where [dbo].[cmms_servicelogs].[asset_type] = 'CNC'"
				},
				"cacheLifetime": {
					"enabled": false
				}
			},
			{
				"name": "Templated_Tutorial_CNC_Fanuc_Branch",
				"connection": "Tutorial_OPC_UA",
				"type": "opc.tcp",
				"qualifier": {
					"namespaceIndex": 2,
					"identifierType": "String",
					"identifier": "Tutorial.CNC_Fanuc_1001",
					"dataType": "Auto",
					"type": "Branch",
					"maxDepth": 1,
					"cacheInterval": {
						"duration": 1,
						"units": "Hours"
					},
					"ignoreBadQuality": false,
					"browseVariableNodes": false
				},
				"cacheLifetime": {
					"enabled": false
				}
			},
			{
				"name": "Tutorial_Branch",
				"connection": "Tutorial_OPC_UA",
				"type": "opc.tcp",
				"qualifier": {
					"namespaceIndex": 2,
					"identifierType": "String",
					"identifier": "Tutorial",
					"dataType": "Auto",
					"type": "Branch",
					"maxDepth": 1,
					"cacheInterval": {
						"duration": 1,
						"units": "Hours"
					},
					"ignoreBadQuality": false,
					"browseVariableNodes": false
				},
				"cacheLifetime": {
					"enabled": false
				}
			},
			{
				"name": "Tutorial_CNC_Fanuc_1001_AirPressure",
				"connection": "Tutorial_OPC_UA",
				"type": "opc.tcp",
				"qualifier": {
					"namespaceIndex": 2,
					"identifierType": "String",
					"identifier": "Tutorial.CNC_Fanuc_1001.AirPressure",
					"type": "Tag",
					"dataType": "Real32"
				},
				"cacheLifetime": {
					"enabled": false
				}
			},
			{
				"name": "Tutorial_CNC_Fanuc_1001_AssetID",
				"connection": "Tutorial_OPC_UA",
				"type": "opc.tcp",
				"qualifier": {
					"namespaceIndex": 2,
					"identifierType": "String",
					"identifier": "Tutorial.CNC_Fanuc_1001.AssetID",
					"type": "Tag",
					"dataType": "String"
				},
				"cacheLifetime": {
					"enabled": false
				}
			},
			{
				"name": "Tutorial_CNC_Fanuc_1001_AxisPositionX",
				"connection": "Tutorial_OPC_UA",
				"type": "opc.tcp",
				"qualifier": {
					"namespaceIndex": 2,
					"identifierType": "String",
					"identifier": "Tutorial.CNC_Fanuc_1001.AxisPositionX",
					"type": "Tag",
					"dataType": "Real32"
				},
				"cacheLifetime": {
					"enabled": false
				}
			},
			{
				"name": "Tutorial_CNC_Fanuc_1001_AxisPositionY",
				"connection": "Tutorial_OPC_UA",
				"type": "opc.tcp",
				"qualifier": {
					"namespaceIndex": 2,
					"identifierType": "String",
					"identifier": "Tutorial.CNC_Fanuc_1001.AxisPositionY",
					"type": "Tag",
					"dataType": "Real32"
				},
				"cacheLifetime": {
					"enabled": false
				}
			},
			{
				"name": "Tutorial_CNC_Fanuc_1001_AxisPositionZ",
				"connection": "Tutorial_OPC_UA",
				"type": "opc.tcp",
				"qualifier": {
					"namespaceIndex": 2,
					"identifierType": "String",
					"identifier": "Tutorial.CNC_Fanuc_1001.AxisPositionZ",
					"type": "Tag",
					"dataType": "Real32"
				},
				"cacheLifetime": {
					"enabled": false
				}
			},
			{
				"name": "Tutorial_CNC_Fanuc_1001_CoolantpH",
				"connection": "Tutorial_OPC_UA",
				"type": "opc.tcp",
				"qualifier": {
					"namespaceIndex": 2,
					"identifierType": "String",
					"identifier": "Tutorial.CNC_Fanuc_1001.CoolantpH",
					"type": "Tag",
					"dataType": "Int16"
				},
				"cacheLifetime": {
					"enabled": false
				}
			},
			{
				"name": "Tutorial_CNC_Fanuc_1001_CuttingSpeed",
				"connection": "Tutorial_OPC_UA",
				"type": "opc.tcp",
				"qualifier": {
					"namespaceIndex": 2,
					"identifierType": "String",
					"identifier": "Tutorial.CNC_Fanuc_1001.CuttingSpeed",
					"type": "Tag",
					"dataType": "Real32"
				},
				"cacheLifetime": {
					"enabled": false
				}
			},
			{
				"name": "Tutorial_CNC_Fanuc_1001_FaultCode",
				"connection": "Tutorial_OPC_UA",
				"type": "opc.tcp",
				"qualifier": {
					"namespaceIndex": 2,
					"identifierType": "String",
					"identifier": "Tutorial.CNC_Fanuc_1001.FaultCode",
					"type": "Tag",
					"dataType": "Int16"
				},
				"cacheLifetime": {
					"enabled": false
				}
			},
			{
				"name": "Tutorial_CNC_Fanuc_1001_FeedRate",
				"connection": "Tutorial_OPC_UA",
				"type": "opc.tcp",
				"qualifier": {
					"namespaceIndex": 2,
					"identifierType": "String",
					"identifier": "Tutorial.CNC_Fanuc_1001.FeedRate",
					"type": "Tag",
					"dataType": "Real32"
				},
				"cacheLifetime": {
					"enabled": false
				}
			},
			{
				"name": "Tutorial_CNC_Fanuc_1001_MachineState",
				"connection": "Tutorial_OPC_UA",
				"type": "opc.tcp",
				"qualifier": {
					"namespaceIndex": 2,
					"identifierType": "String",
					"identifier": "Tutorial.CNC_Fanuc_1001.MachineState",
					"type": "Tag",
					"dataType": "Int16"
				},
				"cacheLifetime": {
					"enabled": false
				}
			},
			{
				"name": "Tutorial_CNC_Fanuc_1001_MachineTemperature",
				"connection": "Tutorial_OPC_UA",
				"type": "opc.tcp",
				"qualifier": {
					"namespaceIndex": 2,
					"identifierType": "String",
					"identifier": "Tutorial.CNC_Fanuc_1001.MachineTemperature",
					"type": "Tag",
					"dataType": "Real32"
				},
				"cacheLifetime": {
					"enabled": false
				}
			},
			{
				"name": "Tutorial_CNC_Fanuc_1001_PartProgramID",
				"connection": "Tutorial_OPC_UA",
				"type": "opc.tcp",
				"qualifier": {
					"namespaceIndex": 2,
					"identifierType": "String",
					"identifier": "Tutorial.CNC_Fanuc_1001.PartProgramID",
					"type": "Tag",
					"dataType": "String"
				},
				"cacheLifetime": {
					"enabled": false
				}
			},
			{
				"name": "Tutorial_CNC_Fanuc_1001_PowerCurrent",
				"connection": "Tutorial_OPC_UA",
				"type": "opc.tcp",
				"qualifier": {
					"namespaceIndex": 2,
					"identifierType": "String",
					"identifier": "Tutorial.CNC_Fanuc_1001.PowerCurrent",
					"type": "Tag",
					"dataType": "Real32"
				},
				"cacheLifetime": {
					"enabled": false
				}
			},
			{
				"name": "Tutorial_CNC_Fanuc_1001_PowerCurrentXAxis",
				"connection": "Tutorial_OPC_UA",
				"type": "opc.tcp",
				"qualifier": {
					"namespaceIndex": 2,
					"identifierType": "String",
					"identifier": "Tutorial.CNC_Fanuc_1001.PowerCurrentXAxis",
					"type": "Tag",
					"dataType": "Real32"
				},
				"cacheLifetime": {
					"enabled": false
				}
			},
			{
				"name": "Tutorial_CNC_Fanuc_1001_PowerCurrentYAxis",
				"connection": "Tutorial_OPC_UA",
				"type": "opc.tcp",
				"qualifier": {
					"namespaceIndex": 2,
					"identifierType": "String",
					"identifier": "Tutorial.CNC_Fanuc_1001.PowerCurrentYAxis",
					"type": "Tag",
					"dataType": "Real32"
				},
				"cacheLifetime": {
					"enabled": false
				}
			},
			{
				"name": "Tutorial_CNC_Fanuc_1001_PowerCurrentZAxis",
				"connection": "Tutorial_OPC_UA",
				"type": "opc.tcp",
				"qualifier": {
					"namespaceIndex": 2,
					"identifierType": "String",
					"identifier": "Tutorial.CNC_Fanuc_1001.PowerCurrentZAxis",
					"type": "Tag",
					"dataType": "Real32"
				},
				"cacheLifetime": {
					"enabled": false
				}
			},
			{
				"name": "Tutorial_CNC_Fanuc_1001_ProductionCount",
				"connection": "Tutorial_OPC_UA",
				"type": "opc.tcp",
				"qualifier": {
					"namespaceIndex": 2,
					"identifierType": "String",
					"identifier": "Tutorial.CNC_Fanuc_1001.ProductionCount",
					"type": "Tag",
					"dataType": "Int16"
				},
				"cacheLifetime": {
					"enabled": false
				}
			},
			{
				"name": "Tutorial_CNC_Fanuc_1001_RejectCount",
				"connection": "Tutorial_OPC_UA",
				"type": "opc.tcp",
				"qualifier": {
					"namespaceIndex": 2,
					"identifierType": "String",
					"identifier": "Tutorial.CNC_Fanuc_1001.RejectCount",
					"type": "Tag",
					"dataType": "Int16"
				},
				"cacheLifetime": {
					"enabled": false
				}
			},
			{
				"name": "Tutorial_CNC_Fanuc_1001_SpindleLoad",
				"connection": "Tutorial_OPC_UA",
				"type": "opc.tcp",
				"qualifier": {
					"namespaceIndex": 2,
					"identifierType": "String",
					"identifier": "Tutorial.CNC_Fanuc_1001.SpindleLoad",
					"type": "Tag",
					"dataType": "Real32"
				},
				"cacheLifetime": {
					"enabled": false
				}
			},
			{
				"name": "Tutorial_CNC_Fanuc_1001_SpindleSpeed",
				"connection": "Tutorial_OPC_UA",
				"type": "opc.tcp",
				"qualifier": {
					"namespaceIndex": 2,
					"identifierType": "String",
					"identifier": "Tutorial.CNC_Fanuc_1001.SpindleSpeed",
					"type": "Tag",
					"dataType": "Real32"
				},
				"cacheLifetime": {
					"enabled": false
				}
			},
			{
				"name": "Tutorial_CNC_Fanuc_1001_SpindleTemperature",
				"connection": "Tutorial_OPC_UA",
				"type": "opc.tcp",
				"qualifier": {
					"namespaceIndex": 2,
					"identifierType": "String",
					"identifier": "Tutorial.CNC_Fanuc_1001.SpindleTemperature",
					"type": "Tag",
					"dataType": "Real32"
				},
				"cacheLifetime": {
					"enabled": false
				}
			},
			{
				"name": "Tutorial_CNC_Fanuc_1001_StateDescription",
				"connection": "Tutorial_OPC_UA",
				"type": "opc.tcp",
				"qualifier": {
					"namespaceIndex": 2,
					"identifierType": "String",
					"identifier": "Tutorial.CNC_Fanuc_1001.StateDescription",
					"type": "Tag",
					"dataType": "String"
				},
				"cacheLifetime": {
					"enabled": false
				}
			},
			{
				"name": "Tutorial_CNC_Fanuc_1001_ToolID",
				"connection": "Tutorial_OPC_UA",
				"type": "opc.tcp",
				"qualifier": {
					"namespaceIndex": 2,
					"identifierType": "String",
					"identifier": "Tutorial.CNC_Fanuc_1001.ToolID",
					"type": "Tag",
					"dataType": "String"
				},
				"cacheLifetime": {
					"enabled": false
				}
			},
			{
				"name": "_DynamicSource_Tutorial_CNC_Fanuc_MachineState",
				"connection": "Tutorial_OPC_UA",
				"type": "opc.tcp",
				"qualifier": {
					"namespaceIndex": 2,
					"identifierType": "String",
					"identifier": "Tutorial.CNC_1001.MachineState",
					"type": "Tag",
					"dataType": "Int16",
					"samplingInterval": {
						"units": "Seconds",
						"duration": 1
					}
				},
				"cacheLifetime": {
					"enabled": false
				}
			},
			{
				"name": "_DynamicSource_Tutorial_CNC_Fanuc_PartProgramID",
				"connection": "Tutorial_OPC_UA",
				"type": "opc.tcp",
				"qualifier": {
					"namespaceIndex": 2,
					"identifierType": "String",
					"identifier": "Tutorial.CNC_1001.PartProgramID",
					"type": "Tag",
					"dataType": "String",
					"samplingInterval": {
						"units": "Seconds",
						"duration": 1
					}
				},
				"cacheLifetime": {
					"enabled": false
				}
			},
			{
				"name": "_DynamicSource_Tutorial_CNC_Fanuc_RejectCount",
				"connection": "Tutorial_OPC_UA",
				"type": "opc.tcp",
				"qualifier": {
					"namespaceIndex": 2,
					"identifierType": "String",
					"identifier": "Tutorial.CNC_1001.RejectCount",
					"type": "Tag",
					"dataType": "Int16",
					"samplingInterval": {
						"units": "Seconds",
						"duration": 1
					}
				},
				"cacheLifetime": {
					"enabled": false
				}
			},
			{
				"name": "_DynamicSource_Tutorial_CNC_Fanuc_ToolID",
				"connection": "Tutorial_OPC_UA",
				"type": "opc.tcp",
				"qualifier": {
					"namespaceIndex": 2,
					"identifierType": "String",
					"identifier": "Tutorial.CNC_1001.ToolID",
					"type": "Tag",
					"dataType": "String",
					"samplingInterval": {
						"units": "Seconds",
						"duration": 1
					}
				},
				"cacheLifetime": {
					"enabled": false
				}
			}
		],
		"outputs": [
			{
				"name": "Tutorial_CNC_Output",
				"connection": "Tutorial_MQTT",
				"type": "mqtt",
				"qualifier": {
					"qos": 0,
					"namedRoot": false,
					"breakupArrays": true,
					"topic": "Tutorial/Templating/{{this.AssetID}}",
					"retained": false
				}
			},
			{
				"name": "Tutorial_CNC_Output_DynamicTemplate",
				"connection": "Tutorial_MQTT",
				"type": "mqtt",
				"qualifier": {
					"qos": 0,
					"namedRoot": false,
					"breakupArrays": true,
					"topic": "Tutorial/Templating/DynamicFlow/{{this.AssetID}}",
					"retained": false
				}
			},
			{
				"name": "Tutorial_CNC_Templated_Branch_Output",
				"connection": "Tutorial_MQTT",
				"type": "mqtt",
				"qualifier": {
					"qos": 0,
					"namedRoot": false,
					"breakupArrays": true,
					"topic": "Tutorial/Templating/TemplatedConnection/{{this.AssetID}}",
					"retained": true
				}
			},
			{
				"name": "Tutorial_CNC_Templated_Flow_Output",
				"connection": "Tutorial_MQTT",
				"type": "mqtt",
				"qualifier": {
					"qos": 0,
					"namedRoot": false,
					"breakupArrays": true,
					"topic": "Tutorial/Templating/TemplatedFlow/{{this._name}}",
					"retained": true
				}
			},
			{
				"name": "Tutorial_CNC_Templated_Instance_Output",
				"connection": "Tutorial_MQTT",
				"type": "mqtt",
				"qualifier": {
					"qos": 0,
					"namedRoot": false,
					"breakupArrays": true,
					"topic": "Tutorial/Templating/TemplatedInstance/{{this.AssetID}}",
					"retained": true
				}
			},
			{
				"name": "Tutorial_Model_Complex",
				"connection": "Tutorial_MQTT",
				"type": "mqtt",
				"qualifier": {
					"qos": 0,
					"namedRoot": false,
					"breakupArrays": false,
					"topic": "Tutorial/Model/Complex",
					"retained": false
				}
			},
			{
				"name": "Tutorial_Model_Simple",
				"connection": "Tutorial_MQTT",
				"type": "mqtt",
				"qualifier": {
					"qos": 0,
					"namedRoot": false,
					"breakupArrays": false,
					"topic": "Tutorial/Model/Simple",
					"retained": false
				}
			}
		],
		"modeling": {
			"models": [
				{
					"name": "CNC_Asset_Info",
					"tags": [
						"Share",
						"Share2"
					],
					"attributes": [
						{
							"name": "AssetID",
							"type": "String",
							"array": false,
							"required": true
						},
						{
							"name": "Temperature",
							"type": "Any",
							"array": false,
							"required": true
						},
						{
							"name": "Temperature_UOM",
							"type": "Any",
							"array": false,
							"required": false
						},
						{
							"name": "CuttingSpeed",
							"type": "Any",
							"array": false,
							"required": true
						},
						{
							"name": "PowerCurrent",
							"type": "Any",
							"array": false,
							"required": true
						},
						{
							"name": "FeedRate",
							"type": "Any",
							"array": false,
							"required": true
						},
						{
							"name": "LastServiceDate",
							"type": "Any",
							"array": false,
							"required": false
						},
						{
							"name": "LastServiceNotes",
							"type": "Any",
							"array": false,
							"required": false
						}
					]
				},
				{
					"name": "CNC_Asset_ServiceInfo",
					"tags": [
						"Share"
					],
					"attributes": [
						{
							"name": "AssetID",
							"type": "String",
							"array": false,
							"required": false
						},
						{
							"name": "LastServiceDate",
							"type": "Any",
							"array": false,
							"required": false
						},
						{
							"name": "LastServiceNotes",
							"type": "Any",
							"array": false,
							"required": false
						}
					]
				},
				{
					"name": "Enterprise_CNC_Model",
					"tags": [],
					"attributes": [
						{
							"name": "Enterprise",
							"type": "Any",
							"array": false,
							"required": false
						},
						{
							"name": "Site",
							"type": "Any",
							"array": false,
							"required": false
						},
						{
							"name": "Area",
							"type": "Any",
							"array": false,
							"required": false
						},
						{
							"name": "Line",
							"type": "Any",
							"array": false,
							"required": false
						},
						{
							"name": "Values",
							"type": "CNC_Asset_Info",
							"array": false,
							"required": false
						},
						{
							"name": "ProgramInfo",
							"type": "ProgramInfo_Model",
							"array": false,
							"required": false
						}
					]
				},
				{
					"name": "ProgramInfo_Model",
					"tags": [],
					"attributes": [
						{
							"name": "ProgramID",
							"type": "Any",
							"array": false,
							"required": false
						},
						{
							"name": "ToolID",
							"type": "Any",
							"array": false,
							"required": false
						},
						{
							"name": "MachineState",
							"type": "Any",
							"array": false,
							"required": false
						},
						{
							"name": "RejectCount",
							"type": "Any",
							"array": false,
							"required": false
						}
					]
				}
			],
			"instances": [
				{
					"name": "CNC_Asset_Info_Instance",
					"tags": [
						"Share",
						"Share2"
					],
					"model": "CNC_Asset_Info",
					"rootValueAs": "Object",
					"attributes": [
						{
							"name": "AssetID",
							"expression": "{{Connection.Tutorial_OPC_UA.Tutorial_CNC_Fanuc_1001_AssetID}}"
						},
						{
							"name": "Temperature",
							"expression": "({{Connection.Tutorial_OPC_UA.Tutorial_CNC_Fanuc_1001_MachineTemperature}}-32)*.5556"
						},
						{
							"name": "Temperature_UOM"
						},
						{
							"name": "CuttingSpeed",
							"expression": "{{Connection.Tutorial_OPC_UA.Tutorial_CNC_Fanuc_1001_CuttingSpeed}}"
						},
						{
							"name": "PowerCurrent",
							"expression": "{{Connection.Tutorial_OPC_UA.Tutorial_CNC_Fanuc_1001_PowerCurrent}}"
						},
						{
							"name": "FeedRate",
							"expression": "{{Connection.Tutorial_OPC_UA.Tutorial_CNC_Fanuc_1001_FeedRate}}"
						},
						{
							"name": "LastServiceDate",
							"expression": "{{Connection.Tutorial_CMMS_servicelogs.Tutorial_All_Assets_CNC}}[0].date"
						},
						{
							"name": "LastServiceNotes",
							"expression": "{{Connection.Tutorial_CMMS_servicelogs.Tutorial_All_Assets_CNC}}[0].notes"
						}
					]
				},
				{
					"name": "Enterprise_CNC_Model_Instance",
					"tags": [],
					"model": "Enterprise_CNC_Model",
					"rootValueAs": "Object",
					"attributes": [
						{
							"name": "Enterprise",
							"default": "Tutorial"
						},
						{
							"name": "Site",
							"default": "Site1"
						},
						{
							"name": "Area",
							"default": "Area1"
						},
						{
							"name": "Line",
							"default": "Line1"
						},
						{
							"name": "Values",
							"expression": "{{Instance.CNC_Asset_Info_Instance}}"
						},
						{
							"name": "ProgramInfo",
							"expression": "{{Instance.Enterprise_CNC_Model_Instance_ProgramInfo}}"
						}
					]
				},
				{
					"name": "Enterprise_CNC_Model_Instance_ProgramInfo",
					"tags": [],
					"model": "ProgramInfo_Model",
					"rootValueAs": "Object",
					"attributes": [
						{
							"name": "ProgramID",
							"expression": "{{Connection.Tutorial_OPC_UA.Tutorial_CNC_Fanuc_1001_PartProgramID}}"
						},
						{
							"name": "ToolID",
							"expression": "{{Connection.Tutorial_OPC_UA.Tutorial_CNC_Fanuc_1001_ToolID}}"
						},
						{
							"name": "MachineState",
							"expression": "{{Connection.Tutorial_OPC_UA.Tutorial_CNC_Fanuc_1001_MachineState}}"
						},
						{
							"name": "RejectCount",
							"expression": "{{Connection.Tutorial_OPC_UA.Tutorial_CNC_Fanuc_1001_RejectCount}}"
						}
					]
				}
			]
		},
		"flows": [],
		"conditions": [],
		"functions": [],
		"tags": [
			{
				"name": "Share"
			}
		],
		"pipelines": []
	},
	"network": {
		"groups": [],
		"hubs": []
	}
}
  1. Update the imported Connections as required

    • Navigate to Configure and click Connections, Click Tutorial_MQTT and Update the MQTT settings as required based on the prior preparation step #1
    • Navigate to Configure and click Connections, Click “Tutorial_CMMS_servicelogs”, type the following within the password field and click Save.
                          password
  1. Setup UNS Client

    • In the left-hand navigation panel, navigate to Tools and right click UNS client and open Link in New Tab
    • Enter login information
    • For Connection select Tutorial_MQTT
    • For Subscribed Topics remove the default wildcard entry # and Subscribe to Topic Tutorial/#
    • Click Add
    • Click Connect and confirm UNS client says “Connected to Tutorial_MQTT”
    • Return to the previous tab

Tutorial Instructions

  1. Login to your Intelligence Hub environment

  2. Review source data

    • Navigate to Connections

    • Select “Tutorial_OPC_UA”

    • Navigate to Inputs

    • Select “Templated_Tutorial_CNC_Fanuc_Branch”

      • NOTE: This is a Branch OPC_UA input, with the Branch type we specify a Max Branch Depth to read under the base Identifier.
    • Test Input and review the data

  3. Update Templated_Tutorial_CNC_Fanuc_Branch to a Templated object using Static Parameters - This will take the configuration component from 1 asset input, to many asset inputs.

    • Within the Templated_Tutorial_CNC_Fanuc_Branch Input, enable the Use Template flag at the bottom of the page

    • Ensure Type is set to “Static” - we’ll review “Dynamic” in another lesson

    • Click Add Value

    • Enter “InputAssetID” as the Value Name

    • Enter “1001-1003” as the pattern, note another valid pattern would be “1001,1002,1003”

    • To utilize the InputAssetID parameter, we will use the syntax of “{{this.InputAssetID}}”, enter this as the “Template Name” value

    • We will now utilize this parameter within Identifier field, replace 1001 with {{this.InputAssetID}}

      • Note: Keep the leading underscore
    • Click save and Test Input to review the results

Before"

After:

  1. Review the Output target

    • Navigate to Connections
    • Select Tutorial_MQTT
    • Navigate to Outputs
    • Select Tutorial_CNC_Templated_Branch_Output
    • 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
  2. Create a flow to send Templated Branch to UNS

    • Navigate to Flows
    • Click New Flow
    • Within the New Flow details view, enter “CNC_Branch_Templated_Flow” as the name
    • Click Next
    • Within the new Sources & Targets view, set the references panel to type: Input
    • Set Connection to Tutorial_OPC_UA
    • Map Templated_Tutorial_CNC_Fanuc_Branch to the Sources panel
    • Change reference panel to type: Output
    • Set Connection to Tutorial_MQTT
    • Map Tutorial_CNC_Templated_Branch_Output to the targets panel
    • Click next
    • Set the interval to 10 seconds
    • Click the enabled flag
    • Click Submit
    • Navigate to UNS client and review the result
  3. Build a new Instance from an existing Model

    • Navigate to Models

    • Select CNC_Asset_Info

    • Click actions, create Instance

    • Within the New Instance Details view, enter “CNC_Asset_Info_Instance_Templated” as the name

    • Click next

    • Within the New Instance Model view, accept the default and click next

    • Within the New Instance Attributes view, set your reference panel to Type: Input

    • In the References Panel, set Connection to Tutorial_OPC_UA

    • In the References Panel, expand Tutorial_Branch - NOTE this is a different input then what we just templated in the previous steps

    • In the References Panel, expand CNC_Fanuc_1001 and map the following attributes to the corresponding expressions:

      AssetID - {{Connection.Tutorial_OPC_UA.Tutorial_Branch}}.CNC_Fanuc_1001.AssetID
      Temperature - {{Connection.Tutorial_OPC_UA.Tutorial_Branch}}.CNC_Fanuc_1001.MachineTemperature
      CuttingSpeed - {{Connection.Tutorial_OPC_UA.Tutorial_Branch}}.CNC_Fanuc_1001.CuttingSpeed
      PowerCurrent - {{Connection.Tutorial_OPC_UA.Tutorial_Branch}}.CNC_Fanuc_1001.PowerCurrent
      FeedRate - {{Connection.Tutorial_OPC_UA.Tutorial_Branch}}.CNC_Fanuc_1001.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 submit

    • Click Test Instance and review the results

  1. Template CNC_Asset_Info_Instance_Templated

    • Within CNC_Asset_Info_Instance_Templated, enable the Use Template flag

    • Ensure Type is set to “Static”

    • Click Add Value

    • Enter “InstanceAssetID” as the Value Name

    • Enter “1001-1003” as the pattern

      • 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}}

      Before
      {{Connection.Tutorial_OPC_UA.Tutorial_Branch}}.CNC_Fanuc_1001.AssetID
      
      After
      {{Connection.Tutorial_OPC_UA.Tutorial_Branch}}.CNC_Fanuc_{{this.InstanceAssetID}}.AssetID
    • Repeat with the remaining attribute expressions

      Before
      {{Connection.Tutorial_OPC_UA.Tutorial_Branch}}.CNC_Fanuc_1001.MachineTemperature
      {{Connection.Tutorial_OPC_UA.Tutorial_Branch}}.CNC_Fanuc_1001.CuttingSpeed
      {{Connection.Tutorial_OPC_UA.Tutorial_Branch}}.CNC_Fanuc_1001.PowerCurrent
      {{Connection.Tutorial_OPC_UA.Tutorial_Branch}}.CNC_Fanuc_1001.FeedRate
      
      After
      {{Connection.Tutorial_OPC_UA.Tutorial_Branch}}.CNC_Fanuc_{{this.InstanceAssetID}}.MachineTemperature
      {{Connection.Tutorial_OPC_UA.Tutorial_Branch}}.CNC_Fanuc_{{this.InstanceAssetID}}.CuttingSpeed
      {{Connection.Tutorial_OPC_UA.Tutorial_Branch}}.CNC_Fanuc_{{this.InstanceAssetID}}.PowerCurrent
      {{Connection.Tutorial_OPC_UA.Tutorial_Branch}}.CNC_Fanuc_{{this.InstanceAssetID}}.FeedRate
    • Click save

    • Click Test Instance to review the results

  1. Review the Output target

    • Navigate to Connections

    • Select Tutorial_MQTT

    • Navigate to Outputs

    • Select Tutorial_CNC_Templated_Instance_Output

      • 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
  2. Output the templated Instance to the UNS

    • Navigate to Flows

    • Click New Flow

    • Enter “Tutorial_Template_Flow” for the name

    • Click next

    • Set the References type to Instance and map the CNC_Asset_Info_Instance_Templated to the Sources panel

    • Set the References type to Output, set Connections to Tutorial_MQTT and map Tutorial_CNC_Templated_Instance_Output to the Targets panel

    • Click next

    • Change the Interval to 10 seconds

    • Click the enabled flag

    • Click submit

    • Review the results within 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.

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.