Tutorial: Models and Instances
This step-by-step interactive tutorial provides an introduction to modeling in Intelligence Hub.
What Does This Tutorial Cover?
This tutorial will walk you through the basics of working with Models and Instances. Modeling is fundamental to HighByte Intelligence Hub. Modeling allows for pulling data from many discrete data sources (e.g., OPC UA, SQL, REST API) and combining that data into useful information in a common format. Upstream data consumers can then rely on standardized information regardless of the underlying data sources, which can differ greatly per location. The Intelligence Hub breaks modeling into Models and Instances.
When building a new Model, it’s important to consider the use case problem statement and data requirements to ensure that the consumer(s) are successful. This tutorial use case is to develop a standardized format for all makes and models of our CNC machine tools. We also want to incorporate data from our CMMS to the consuming endpoints as it will be critical to display within our visualization system.
- Tutorial Prerequisites
- Tutorial Preparation
- Tutorial Instructions
- 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".
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
Consider the use case and design your Model with re-usability in mind, we know we have two sources of data and two types of data including real-time data and transactional data. We also know we will have different needs of the data. We'll account for these considerations in the following Instructions.
-
Login to the Intelligence Hub environment
-
Review source data
- Navigate to Connections
- Select "HB_Tutorial_OPC_UA".
- Navigate to the Inputs tab and review the imported Tutorial_CNC_Fanuc_#### OPC UA tags.
- Navigate to Connections
- Select "HB_Tutorial_SQL_Server".
- Navigate to the Inputs tab.
- Select "HB_Tutorial_SQL_Server_Input_Get_All_CNC_Assets".
- Click the Test Input button and review the source data.
-
Review the imported Model.
-
Navigate to Models
-
Select "HB_Tutorial_Models_CNC_Asset_Info".
-
Review the existing Attributes, we can see the AssetID is being set as a String data type and all five attributes are required.
- NOTE: Required attributes will ensure these attributes always have values when outputted
-
-
Create an Instance from the "HB_Tutorial_Models_CNC_Asset_Info" Model
-
Click the Create Instance button.
- From the New Instance screen, accept the defaults and click the Next button.
- Within the New Instance screen, set the References Panel type to Input.
- Within the References Panel, set the Type to Input and Connections to "HB_Tutorial_OPC_UA".
- From the References Panel, map the following OPC UA tags to the attributes.
- AssetID – Tutorial_CNC_Fanuc_1001_AssetID
- Temperature - HB_Tutorial_CNC_Fanuc_1001_MachineTemperature
-
CuttingSpeed - HB_Tutorial_CNC_Fanuc_1001_CuttingSpeed
-
PowerCurrent - HB_Tutorial_CNC_Fanuc_1001_PowerCurrent
-
FeedRate - HB_Tutorial_CNC_Fanuc_1001_FeedRate
- Click the Create button.
- Click the Test Instance button to view the data.
-
- Add new values to the existing Model
-
- Navigate to "HB_Tutorial_Models_CNC_Asset_Info" by clicking the hyperlink in the Instance.
- Click the green add New Attribute button to add a new attribute.
- Enter “Temperature_UOM” for the name of the first new attribute.
- Click the green add New Attribute button to add a new attribute.
- Enter “LastServiceDate” for the name of the second new attribute.
- Click the green add New Attribute button to add a new attribute.
- Enter “LastServiceNotes” for the name of the third new attribute
- Leave the attribute type and required as default values.
- Move the new Temperature_UOM attribute to Attribute order three (below the Temperature attribute) so it's inline with the Temperature reading.
- Click the Save button.
- Add new attribute values to the existing Instance.
-
From the "HB_Tutorial_Models_CNC_Asset_Info" Model, click the Usage tab and click "HB_Tutorial_Models_CNC_Asset_Info_Instance".
-
For the Temperature_UOM attribute, let’s assume we do not have a source input to provide a unit of measure, and type “F” in the default value field.
-
Set the References Panel type to Input.
-
Within the References Panel, set Connections to "HB_Tutorial_SQL_Server".
-
Expand "HB_Tutorial_SQL_Server_Input_Get_All_CNC_Assets", and also expand object 0"
-
From the References Panel, map the following attributes to the Model attributes.
- LastServiceDate - date
- LastServiceNotes - notes
-
-
-
Click the Save button
-
Click the Test Instance button to view the data.
-
- Create a Pipeline for the Instance.
- Navigate to Pipelines
- Click New Pipeline.
- Enter “HB_Tutorial_CNC_Asset_Info_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” into the Sources box.
- Change Type to Output.
- Set Connections to "HB_Tutorial_MQTT".
- Drag "HB_Tutorial_MQTT_Output_Model_Simple" 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.
- Click on Save button.
- Review the results in the UNS client.
-
Create a new complex Model
-
Navigate to Models
-
Click New Model
-
From the New Model Details screen, enter “HB_Tutorial_Models_Enterprise_CNC” as the name and click next
-
From the New Model screen, add the following attributes:
- Enterprise
- Site
- Area
- Line
- Values
- ProgramInfo
-
For the Values attribute select Attribute Type Model and select Model "HB_Tutorial_Models_CNC_Asset_Info".
-
For the ProgramInfo attribute select Attribute Type Object and add the following attributes.
- ProgramID
- ToolID
- MachineState
- RejectCount
-
Click the Create button and view the model that has been created.
-
-
Create an Instance of Enterprise_CNC_Model
-
From the "HB_Tutorial_Models_Enterprise_CNC" Model, click the Create Instance button.
-
From the New Instance screen, accept the defaults and click the Next button
-
From the New Instance screen, add the following for default values:
- Enterprise: Tutorial
- Site: Site1
- Area: Area1
- Line: Line1
-
-
-
From the New Instance screen, map the Values as described in the previous steps.
-
For the ProgramInfo attribute, click the select drop-down and select Create ProgramInfo_Model
- From the References Panel, set your type to Input, Connection to "HB_Tutorial_OPC_UA" and map the following attributes to the ProgramInfo object.
- ProgramID - HB_Tutorial_CNC_Fanuc_1001_PartProgramID
- ToolID - HB_Tutorial_CNC_Fanuc_1001_ToolID
- MachineState - HB_Tutorial_CNC_Fanuc_1001_MachineState
- RejectCount - HB_Tutorial_CNC_Fanuc_1001_RejectionCount
-
Click the Save button
-
Click the Test Instance button to review the results
-
- Use a JavaScript expression to manipulate an attribute
-
Let’s assume that we have an Enterprise initiative to standardize our temperature UOM to Celsius, we can utilize Intelligence Hub’s expressions to handle this UOM change. Instance Expressions support the JavaScript language, let’s incorporate a basic example of this to our use case
-
From the "HB_Tutorial_Models_Enterprise_CNC_Instance", select the Temperature attribute and change the Expression Type to Expression.
-
Update the Temperature attribute to the following
-
Add () around the whole expression after the return
-
After MachineTemperature}}. add "-32"
-
After the closing ), add "*.5556"
-
Before: return {{Connection.Tutorial_OPC_UA.Tutorial_CNC_Fanuc_1001_MachineTemperature}}
After: return ({{Connection.Tutorial_OPC_UA.Tutorial_CNC_Fanuc_1001_MachineTemperature}}-32)*.5556
-
-
-
Within the default field, change the Temperature_UOM to “C”
-
Click the Save button and the Test Instance button.
-
Create a Pipeline for the new Instance.
-
- Navigate to Pipelines
- Click New Pipeline.
- Enter “HB_Tutorial_Enterprise_Asset_Info_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_Enterprise_CNC_Instance” into the Sources box.
- Change Type to Output.
- Set Connections to "HB_Tutorial_MQTT".
- Drag "HB_Tutorial_MQTT_Output_Model_Complex" 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.
- Click on Save button.
- Review the results in the UNS client.
The answer to this tutorial can be found in the beginning of the next tutorial section. It is found in the Project JSON in the next tutorial. The Project JSON in each section is cumulative. It is built based on the previous tutorial sections as well as new components needed for the current section.
Tutorial Summary
This exercise focused on the basics of working with Models and Instances. You should be more familiar with how Intelligence Hub Models can help solve real problems around standardization and contextualization with your organization. We covered how to build complex models that involve nesting child models with a parent model. Finally, we covered how to utilize JavaScript expressions to our advantage to solve real problems such as unit of measure conversions, safely at the abstraction layer Intelligence Hub provides.
Next Page