Part 5 - Equipment instances

This article is a part of "Creating an Equipment model" tutorial.

New equipment instances, i.e., the digital twins of the actual physical equipment, can be added with the following piece of code utilizing the VtrinLib data abstraction library. Let's add a tank as a first example.

ABB.Vtrin.cDbClass tankEquipmentType = RTDBDriver.Classes["Path_Tank"];

var sourceTank = equipmentType.Instances.Add();
sourceTank.Name = "Example site.Tank area.Source tank";
sourceTank.CommitChanges();

Now that we have equipment instances created, it is time to define the instance properties. An instance property can be easily defined, just like this:

sourceTank = sourceTank.BeginUpdate();
sourceTank["Volume"] = 1000;
sourceTank["Manufacturer"] = "Tank Company";
sourceTank.CommitChanges();

Implementing the full method

Just like before, let us write a helper method to handle equipment instance creation.

private static ABB.Vtrin.cDbClassInstance GetOrCreateEquipmentInstance(
    string instanceName,
    ABB.Vtrin.cDbClass equipmentType)
{

    // Try to find existing instance by the given name
    var instance = equipmentType.Instances.GetInstanceByName(instanceName);

    // Case: No existing instance found
    // > Create a new one and set info
    if (instance == null)
    {
        instance = equipmentType.Instances.Add();
        instance.Name = instanceName;
        instance.CommitChanges();
    }

    return instance;
}

Now, equipment instances are easy to create the following way.

// Define tank instances
// =====================

var sourceTank = GetOrCreateEquipmentInstance(
    instanceName: "Example site.Tank area.Source tank",
    equipmentType: RTDBDriver.Classes["Path_Tank"]);

var targetTank = GetOrCreateEquipmentInstance(
    instanceName: "Example site.Tank area.Target tank",
    equipmentType: RTDBDriver.Classes["Path_Tank"]);


// Define pipe instances
// =====================

var mainPipe = GetOrCreateEquipmentInstance(
    instanceName: "Example site.Pipe",
    equipmentType: RTDBDriver.Classes["Path_Pipe"]);

var flowbackPipe = GetOrCreateEquipmentInstance(
    instanceName: "Example site.Flowback pipe",
    equipmentType: RTDBDriver.Classes["Path_Pipe"]);

// Define pump instance
// ====================

var pump = GetOrCreateEquipmentInstance(
    instanceName: "Example site.Pump section.Pump",
    equipmentType: RTDBDriver.Classes["Path_Pump"]);

Next, we can define the instance properties.

pump = pump.BeginUpdate();
pump["Source tank"] = sourceTank.Id;
pump["Target tank"] = targetTank.Id;
pump["Nominal power"] = 1000;
pump["Manufacturer"] = "Pumps & Pipes Inc.";
pump.CommitChanges();

targetTank = targetTank.BeginUpdate();
targetTank["Volume"] = 1000;
targetTank["Manufacturer"] = "Tank Company";
targetTank.CommitChanges();

sourceTank = sourceTank.BeginUpdate();
sourceTank["Volume"] = 1000;
sourceTank["Manufacturer"] = "Tank Company";
sourceTank.CommitChanges();

mainPipe = mainPipe.BeginUpdate();
mainPipe["Diameter"] = 20;
mainPipe["Manufacturer"] = "Pumps & Pipes Inc.";
mainPipe.CommitChanges();

flowbackPipe = flowbackPipe.BeginUpdate();
flowbackPipe["Diameter"] = 10;
flowbackPipe["Manufacturer"] = "Pumps & Pipes Inc.";
flowbackPipe.CommitChanges();

What do we have now?​​

This was everything you need to set up a working system using equipment model. You have now a fully configured system featuring equipment types, equipment properties, equipment instances, and instance properties. You can use Engineering UI to list your equipment type, equipment properties, equipment instances, and equipment instance properties.

The next parts of the tutorial will focus on the system maintainability. They will cover areas such as feeding and reading data, and monitoring the system using Engineering UI.

📘

Compare your code

This tutorial is following the code that can be found from our GitHub repository. Checking out the full example code is highly recommended.