Working with TagProvider and NodeMapDriver

I’m implementing a driver module. I add some nodes, and then automatically create some tags connected to those nodes. I’ve encoutered a few challenges so far.

Quick description:

  • The main driver class extends NodeMapDriver, and implements TagProvider.
  • The tags all extend DirectSubscribedNodeTag
  • The non-folder nodes all extend DataVariableNode

The questions:
[1] Right now, I am hard-coding “Ignition OPC-UA Server” for the TagProp.OPCServer attribute for the tags. That seems like it may not be constant across all Ignition Gateways everywhere. Can I retrieve the server name from the GatewayContext?
[2] When I Add a new device in Gateway configuration, I give it some name. I can retrieve this name via the log manager, but is there a better way? I believe I need this for the TagProp.OPCItemPath attribute.
[3] DirectSubscribedNodeTag implements NodeSubscriptionDefinition, but getServerNodeId() always returns null. Do I have to override this method, or am I missing some initialization step?

Any advice would be appreciated.

Thanks.

[1] If there were functionality for this, it would be on the OPCManager provided by GatewayContext, but unfortunately not even a list of configured servers is currently provided.

Even if there were, the name of the server is not guaranteed, and it's possible that the connection could be removed or renamed, as well as for other connection to other OPC servers to exist.

[2] AbstractDriver#getName() will return the configured name. NodeMapDriver extends AbstractDriver, so the method will be accessible.

[3] I don't know much about this so I'll point another developer to this thread...

Despite the fact that what you’re trying to do probably seems normal enough, I think you’re going to have some difficulty. The problem is, the drivers provide data to OPC, and then the user is expected to make tags out of them. Making the tags programmatically is going to be a little tough.

  1. As Kevin mentioned, the name of the OPC server connection could be anything. It is possible to get a list of the servers available, by calling [tt]OPCManager#browse()[/tt] with a null ServerNodeId. However, that will just be a list of names, not very useful in determining which server is the one you’re running under.

  2. Implementing your own Tag Provider is not really what you want to do. If you did, you’d have to handle everything about tag execution. Instead, you should probably create TagDefinitions for each of your tags, and then call [tt]SQLTagManager#addTags()[/tt] to add them to an existing provider. You’ll be in something of the same predicament as with the server name, in that you probably won’t be able to know which provider to add them to, but every new system has an internal provider named “default”. So, you could create a new tag path using the source name “default”, and pass that in to the addTags call.

  3. Just for the record, even though #2 above advises against making your own, the DirectSubscribedNodeId creates the server node ID based on the OPCItemPath and OPCServer tag properties in its attributes set.

For what it’s worth, in 7.3 we’re making it easier to write your own tag providers that expose data quickly, but take care of alerting, history, etc. for you. We’ve noticed many module developers want to expose data through tags, but don’t really care if it’s through OPC. They usually end up trying to do what you’re trying to do, and some are fairly succesful at it. But, we’re trying to make it easier for modules to simply expose tags.

Regards,

Thanks, Colby and Kevin.
I’ll take your advice, change my approach, and add tags to the default provider through SQLTagsManager.