Creating/Adding OPC Tags to a Managed Tag Provider via SDK

Creating/Adding OPC Tags to a Managed Tag Provider via SDK

Hello everyone,

I'm currently working on adding OPC tags to a managed tag provider using the Ignition SDK, and I've run into a few challenges. While I've successfully created OPC tags under the standard default tag provider, I’m having trouble doing the same for a managed tag provider.

Here is the code that works perfectly for the default tag provider:

public void createOPCTag(String tagProviderName, String tagName, String opcServer, String opcItemPath) throws Exception {
    GatewayTagManager tagManager = context.getTagManager();
    TagProvider provider = tagManager.getTagProvider(tagProviderName);
    logger.info(provider.getName());
    TagPath method_tagName = TagPathParser.parse(tagName);
    TagConfiguration tagConfig = BasicTagConfiguration.createNew(method_tagName);
    tagConfig.setType(TagObjectType.AtomicTag);
    tagConfig.set(WellKnownTagProps.DataType, DataType.Float4);
    tagConfig.set(WellKnownTagProps.ValueSource, OpcTagTypeProperties.TAG_TYPE);
    tagConfig.set(OpcTagTypeProperties.OPCServer, opcServer);
    tagConfig.set(OpcTagTypeProperties.OPCItemPath, "ns=1;s=" + opcItemPath);
    List<TagConfiguration> newTagConfigs = new ArrayList<>();
    newTagConfigs.add(tagConfig);
    assert provider != null;
    CompletableFuture<List<QualityCode>> future =
            provider.saveTagConfigsAsync(newTagConfigs, CollisionPolicy.Overwrite);

    List<QualityCode> results = future.get(30, TimeUnit.SECONDS);

    for (int i = 0; i < results.size(); i++) {
        QualityCode result = results.get(i);
        if (result.isNotGood()) {
            throw new Exception(String.format("Add tag operation returned bad result for tag '%s'", newTagConfigs.get(i).getName()));
        }
    }
    newTagConfigs.clear();
}

Issue

This code works as expected when targeting the default tag provider. However, when I attempt to create OPC tags under a managed tag provider, the tags don’t appear in the tag browser, and I don't receive any specific error messages that help identify the issue.

Has anyone successfully implemented OPC tags under a managed tag provider using the SDK? I'm looking for advice or best practices to ensure that OPC tags are correctly created and managed.

Additional Resources

I’ve referred to the Ignition SDK documentation on creating tags, but I haven’t found specific details related to managed tag providers.

Any help or pointers would be greatly appreciated!

Thanks in advance!