Instanciate UDT tags with the SDK

Hi,

Is there a way with the SDK to instanciate UDT tags :

I need to be able to create some new equipement from an existing type (defined by an UDT), on the fly from a sql table witch contains the new equipement to add.

It is possible to create new UDT Instance tags, as well as other types of tags, by defining them through the creation of a TagDefinition, and then adding them to the correct provider with GatewayContext.getTagManager().addTags(…). Obviously, this is a bit tricky, and isn’t very well documented for module authors, but possible.

So, a few notes:

  1. addTags() takes the parent folder path for the new tags, in addition to the list of tags to add. This parent path must be a full tag path, with the provider name specified (that’s how it knows which provider to add to).
  2. That function takes a list of “TagNode” object, which TagDefinition implements.
  3. The tag type will be TagType.UDT_INST
  4. The tag must have the TagProp.UDTParentType property set, with the full string path of the UDT Type Definition that it is an instance of.

Example:

TagDefinition newInst = new TagDefinition("ExampleInstance",TagType.UDT_INST);
newInst.setAttribute(TagProp.UDTParentType, new BasicTagValue("ParentUDTTag"));

context.getTagManager().addTags(TagPathParser.parse("[default]InstanceFolder/"), Arrays.asList((TagNode)newInst),CollisionPolicy.Overwrite);

Now, the problem is, overridding properties is not nearly so simple. You need to get the UUID of the member whose property you want to override, and create various structures. Perhaps the easiest route is for you to tell me which properties you need to modify, and I can try to give you some direction.

Regards,

1 Like

Thanks a lot for this accurate response.
SDK is a bit complex but so powerfull :open_mouth:
My need is just to instanciate in the first time.
Properties are the same for all the equipement and I use a gateway module to change the tags values collected from the equipement through TCP connexion with a non standard-protocol.

I begin with the 7.3 version, no UDT.
I create 1 folder by equipement and acces the tag with the SDK.
With the 7.4, I convert folder to UDT and the module work without any change ! and the HMI as well !
Really impressive !