Creating and connecting Twin Units
As we already explained in the Twins article, a Twin represents a global view of all assets of the corporation, from countries to factories, to assembly lines, to machines, to equipment. You can build a meaningful representation of processes, digitizing only what is needed to solve your business issues, through an intuitive drag & drop interface or also with the power of the Python DSAPI toolkit.
Building our digital twins
The steps to create twins are pretty simple. To start on, just click on Create a new twin under the Data Hub section.
Or click on the Add button at the menu bar in the Twins section. To respect the parent-child hierarchy order, we will start by creating an Area twin, that will be our empty space to add twin units.
Alternately, we can create it using the Wizata DSAPI Python toolkit: Like in the example below, we will declare our Twin object, with a mandatory name
and an optional hardware_id
, and use the upsert_twin
method to save it on the platform:
# Creating the digital twin tree
factory_twin_object = wizata_dsapi.Twin(
name="My example factory",
hardware_id="example_factory",
ttype=wizata_dsapi.TwinBlockType.AREA
)
# Creating the digital twin
wizata_dsapi.api().upsert_twin(twin=factory_twin_object)
You will notice that a new empty space has been created on the Platform and now its time to populate it with our machines and equipment. As you may have read on the Twins introduction page, in our sample case we will have three areas inside our factory: Plant A, B and C . In the next section, we will create these areas inside the factory, to also show you the parent-child connection between twins.
Connecting our twins
In the introduction, we also briefly discussed about the parent-child hierarchy. The following section will explore the different ways you can establish proper internal connections between your twins on the platform.
We will begin by retrieving the parent unit's ID (using get
method and passing the twin_hardware_id
as a key
), which will then be used as a variable for the child connection. Next, we will create the previously mentioned plant A located in Argentina within our factory twin. For this example, we will use the Python toolkit to create an area unit, similar to how we did before, but this time adding a parent_id
value to establish the connection:
parent = wizata_dsapi.api().get(key="example_factory", entity=wizata_dsapi.Twin)
# Creating plant A
plant_a = wizata_dsapi.Twin(
name="Plant A: Argentina",
parent_id=parent.twin_id,
hardware_id="plant_Argentina",
ttype=wizata_dsapi.TwinBlockType.AREA
)
wizata_dsapi.api().upsert_twin(twin=plant_a)
In the
ttype
options, we can choose betweenTwinBlockType.AREA
(defualt),TwinBlockType.MACHINE
andTwinBlockType.EQUIPMENT
For the plant B located in Belgium, we will create the twin unit and its connection using the UI: Right-click with the mouse -> Add -> Area
And we will see a right-side panel opening with all the options to add for the creation of the twin. On the available options, we can select a parent twin unit. We can select the parent twin clicking in the dropdown list and adding the corresponding twin, like in the image below, with our factory example.
We will leave plant C creation as an exercise for you to practice, whether is with the UI or using the Python DSAPI.
Adding machines and equipment
Now that we have our plants created, we will populate them with their correspondent machines and equipment. In this example, we will add a motor for plant A, and then we will attach a sensor equipment to that motor (That will save the bearings of the machine)
For the motor 1 creation, we will use the Python DSAPI, changing the parent unit's ID to match plant A's id and also modifying the TwinBlockType
to be a machine instead of an area:
plant_parent = wizata_dsapi.api().get(key="plant_Argentina", entity=wizata_dsapi.Twin)
# Creating motor 1 inside plant A
motor1 = wizata_dsapi.Twin(
name="Motor 1",
parent_id=plant_parent.twin_id,
hardware_id="motor_1",
ttype=wizata_dsapi.TwinBlockType.MACHINE
)
wizata_dsapi.api().upsert_twin(twin=motor1)
We will visualize the changes automatically updated on the platform UI, with the line connection refering the parent-child connection mode:
Another fast way of creating a unit child inside a parent is by clicking on the parent twin and drag and drop the child inside. The connection will be made automatically. To demonstrate this example, we will create a sensor equipment, that will calculate the bearings of the motor.
As you saw on the gif, we can navigate between the children of the main area by clicking on the name of the twin at the top-bar of the interface. When drag and dropping, the equipment sensor will be created with default values, so we will need to edit its properties. For that, we have prepared another article, that you can access by clicking here.
Updated 3 months ago