Getting Started: Models and Instances
What Does This Article Cover?
- What is a Model?
- What is an Instance?
- Building Models
- Building Instances
- Modeling Considerations
- Instance Considerations
- Other related material
What is a Model?
A model is a template that defines the structure and types of data you want to work with. Think of it as a blueprint that outlines the attributes (like speed, temperature, status) for a specific type of asset or process, such as a conveyor belt, a machine, or even an entire production line.
Models allow you to define what data points are important, how they are related, and what types of values they should hold. For example, a model for a conveyor might include attributes for speed, motor status, and a vibration sensor. Once a model is defined, it can be reused across multiple instances, ensuring consistency and reducing configuration time.
What is an Instance?
An instance is a specific realization of a model. If a model is the blueprint, the instance is the actual machine or process in your operation that is being monitored or controlled. When you create an instance in HighByte Intelligence Hub, you map real data sources (like sensors or databases) to the attributes defined in the model. This allows you to monitor and interact with the actual asset using the structure you defined in the model.
For example, if you have three conveyor belts in your facility, you could create one model for a conveyor and then three instances—one for each conveyor—mapping each instance to its respective data sources.
Building Models:
1. Start a New Model:
Navigate to the left nav and click on Models. Next click 'Create New Model'. Give your model a meaningful name, such as 'Conveyor'.
2. Add Attributes:
Define the attributes that are important for your model, like Speed, Status, Motor, and Vibration Sensor.
Each attribute should be assigned a data type, such as integer, string, or boolean. If you choose 'any' the Intelligence Hub will determine the type when an instance gets populated.
3. (Optional)Inline Hierarchies:
With v4.0, you can create complex models using inline hierarchies. This feature allows you to define nested structures directly within a model without needing separate child models. For example, if your conveyor model includes a motor with its own attributes (like voltage and current), you can define this directly within the conveyor model using the new "Object" type.
4. Nullable Fields:
You can also specify if an attribute can be null using the new "Nullable" option. This is useful when some data points might not always be available or applicable.
Building Instances:
-
Create a new Instance:
Navigate to Instances and click the New Instance button in the upper right corner
-
Specify Details:
Within the Details screen, specify the following:
Name (Required): The component Object name as it will be displayed and referenced in Intelligence Hub (Example: Motor_123_Instance)
Description (Optional): Brief description of the Component Object
Tags (Optional): Used to group like Component Objects together
Group As: Used to organize Instances
Model: the Model to be used as a reference for the InstanceClick the Next button
- Map Attributes:
In the attributes menu click on an attribute to configure its mapping.
Attributes have two types, Reference and Expression- Reference : Use this if you are just using a component reference without JavaScript. This Note : If you type casting your reference, this type is okay to use
- Expression : This is used when JavaScript is involved.
On the Attributes screen, map the Attributes to Expressions using the drag and drop from the References:
Select the Reference Type:
Select the Reference Connection
Select a specific Reference and drag into the Expression field and add JavaScript to the reference if necessary - Create the Instance:
When all mappings are completed, click the 'create' button to create the instance. (Note : Instances can be edited after creation)
Modeling Considerations:
When modeling consider the following
- Keep it simple. Do not try to create the perfect Model. Intelligence Hub is flexible and the Model can be changed over time.
- Assume that the Model will change, so start by modeling the minimum data payload for the respective use case. It is easier to add to a Model than to remove or change existing attributes.
- Model asset hierarchy as attributes in a Model rather than creating many Models to define a hierarchy. For example, rather than creating a “Site” Model, with a single attribute, simply put a “Site” attribute in the machine Model. Excessive hierarchy will make creating and maintaining integrations more difficult.
- Keep data types simple and uniform. To mitigate complexity, keep type information simple. When possible, treat numbers like integers or floats.
- Consider templating Instances. Dynamic and Static Templates can be configured in the Intelligence Hub to ease the creation of many Instances.
- Consider limiting the number of Instances. For example, if data is being obtained from a SQL query and each row is a single machine, then multiple Instances are not necessary. A single Instance that queries the rows is sufficient. Data may also be merged in a Pipeline as well as an Instance.
- Consider using a single timestamp. It is often best to deliver the model with a single timestamp that is UTC and in epoch (milliseconds since midnight, January 1970).
- OPC UA quality considerations. By default, the HighByte Intelligence Hub will not send data for an Instance if one of its required attributes has poor data quality.
Instance Considerations
When creating instances consider the following:
- If you are not using JavaScript in an attribute, make sure the type is set to 'Reference'. Using the 'Expression' type won't break your project, but it will cause your runtime to use unnecessary resources.
- Legacy Mode is designed to support the import of version 3.0 configurations into the current system. In version 3.0, return statements for instance attributes were implicit, which caused some confusion due to the deviation from standard syntax. In non-legacy mode, we enforce proper syntax and recommend that you follow it.
- Consider using expand arrays when the source data is an array of objects (e.g. SQL rows) and you want to transform each row through the model and output a transformed array. When this feature is enabled all references must be at index[0] of the array. If multiple array sources are referenced in the model ensure that the cardinality of those arrays are equal.